Skip to content

Commit

Permalink
chore: formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cbouysset committed Mar 1, 2024
1 parent 9526b2e commit d83dd27
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions prolif/ifp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Storing interactions --- :mod:`prolif.ifp`
==========================================
"""

from collections import UserDict

from prolif.residue import ResidueId
Expand Down
1 change: 1 addition & 0 deletions prolif/interactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module contains the base classes used to build most of the interactions.
"""

import warnings
from itertools import product
from math import degrees, radians
Expand Down
10 changes: 2 additions & 8 deletions prolif/interactions/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class Hydrophobic(Distance):

def __init__(
self,
hydrophobic=(
"[c,s,Br,I,S&H0&v2," "$([D3,D4;#6])&!$([#6]~[#7,#8,#9])&!$([#6X4H0]);+0]"
),
hydrophobic="[c,s,Br,I,S&H0&v2,$([D3,D4;#6])&!$([#6]~[#7,#8,#9])&!$([#6X4H0]);+0]",
distance=4.5,
):
super().__init__(
Expand Down Expand Up @@ -99,11 +97,7 @@ class HBAcceptor(SingleAngle):

def __init__(
self,
acceptor=(
"[#7&!$([nX3])&!$([NX3]-*=[O,N,P,S])&!$([NX3]-[a])&!$([Nv4&+1]),"
"O&!$([OX2](C)C=O)&!$(O(~a)~a)&!$(O=N-*)&!$([O-]-N=O),o+0,"
"F&$(F-[#6])&!$(F-[#6][F,Cl,Br,I])]"
),
acceptor="[#7&!$([nX3])&!$([NX3]-*=[O,N,P,S])&!$([NX3]-[a])&!$([Nv4&+1]),O&!$([OX2](C)C=O)&!$(O(~a)~a)&!$(O=N-*)&!$([O-]-N=O),o+0,F&$(F-[#6])&!$(F-[#6][F,Cl,Br,I])]",
donor="[$([O,S;+0]),$([N;v3,v4&+1]),n+0]-[H]",
distance=3.5,
DHA_angle=(130, 180),
Expand Down
3 changes: 2 additions & 1 deletion prolif/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Reading proteins and ligands --- :mod:`prolif.molecule`
=======================================================
"""

import copy
from collections import defaultdict
from collections.abc import Sequence
Expand Down Expand Up @@ -116,7 +117,7 @@ def from_mda(cls, obj, selection=None, **kwargs):
"""
ag = obj.select_atoms(selection) if selection else obj.atoms
if ag.n_atoms == 0:
raise mda.SelectionError(f"AtomGroup is empty, please check your selection")
raise mda.SelectionError("AtomGroup is empty, please check your selection")
mol = ag.convert_to.rdkit(**kwargs)
return cls(mol)

Expand Down
1 change: 1 addition & 0 deletions prolif/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
in :meth:`~prolif.fingerprint.Fingerprint.run` and
:meth:`~prolif.fingerprint.Fingerprint.run_from_iterable` respectively.
"""

from ctypes import c_uint32
from threading import Event, Thread
from time import sleep
Expand Down
1 change: 1 addition & 0 deletions prolif/pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
behavior upon importing the `prolif` package to ensure that the parallelization code
works as on other platforms.
"""

import sys
from typing import Optional

Expand Down
10 changes: 6 additions & 4 deletions prolif/plotting/barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:members:
"""

from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar, Dict, List, Literal, Optional, Tuple
Expand Down Expand Up @@ -73,9 +74,9 @@ def _bit_to_color_value(s: pd.Series) -> pd.Series:
"""Replaces a bit value with it's corresponding color value"""
interaction = s.name[-1]
return s.apply(
lambda v: self.color_mapper[interaction]
if v
else self.color_mapper[None]
lambda v: (
self.color_mapper[interaction] if v else self.color_mapper[None]
)
)

self.df = df.astype(np.uint8).T.apply(_bit_to_color_value, axis=1)
Expand All @@ -85,7 +86,8 @@ def from_fingerprint(cls, fp: Fingerprint) -> Barcode:
"""Creates a barcode object from a fingerprint."""
if not hasattr(fp, "ifp"):
raise RunRequiredError(
"Please run the fingerprint analysis before attempting to display results."
"Please run the fingerprint analysis before attempting to display"
" results."
)
return cls(fp.to_dataframe())

Expand Down
7 changes: 5 additions & 2 deletions prolif/plotting/complex3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:members:
"""

from __future__ import annotations

from copy import deepcopy
Expand Down Expand Up @@ -101,7 +102,8 @@ class Complex3D:
PROTEIN_RING_INTERACTIONS: ClassVar[Set[str]] = {*RING_SYSTEMS, "CationPi"}
RESIDUE_HOVER_CALLBACK: ClassVar[
str
] = """function(atom,viewer) {
] = """
function(atom,viewer) {
if(!atom.label) {
atom.label = viewer.addLabel('%s:'+atom.atom+atom.serial,
{position: atom, backgroundColor: 'mintcream', fontColor:'black'});
Expand Down Expand Up @@ -157,7 +159,8 @@ def from_fingerprint(
"""
if not hasattr(fp, "ifp"):
raise RunRequiredError(
"Please run the fingerprint analysis before attempting to display results."
"Please run the fingerprint analysis before attempting to display"
" results."
)
ifp = fp.ifp[frame]
return cls(ifp, lig_mol, prot_mol)
Expand Down
7 changes: 3 additions & 4 deletions prolif/plotting/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def from_fingerprint(
"""
if not hasattr(fp, "ifp"):
raise RunRequiredError(
"Please run the fingerprint analysis before attempting to display results."
"Please run the fingerprint analysis before attempting to display"
" results."
)
if kind == "frame":
df = cls._make_frame_df_from_fp(fp, frame=frame, display_all=display_all)
Expand Down Expand Up @@ -790,9 +791,7 @@ def _get_legend(self, height="90px"):
});
legend.appendChild(div_residues);
legend.appendChild(div_interactions);
""" % dict(
div_id="networklegend", buttons=json.dumps(buttons)
)
""" % dict(div_id="networklegend", buttons=json.dumps(buttons))

@requires("IPython.display")
def display(self, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions prolif/plotting/residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.. autofunction:: display_residues
"""

from typing import Any, Optional, Tuple

from rdkit import Chem
Expand Down
1 change: 1 addition & 0 deletions prolif/rdkitmol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Reading RDKit molecules --- :mod:`prolif.rdkitmol`
==================================================
"""

from rdkit import Chem
from rdkit.Chem.rdMolTransforms import ComputeCentroid

Expand Down
6 changes: 3 additions & 3 deletions prolif/residue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Residue-related classes --- :mod:`prolif.residue`
=================================================
"""

import re
from collections import UserDict
from typing import List, Optional
Expand Down Expand Up @@ -182,8 +183,7 @@ def __getitem__(self, key):
# bool is a subclass of int but shouldn't be used here
if isinstance(key, bool):
raise KeyError(
"Expected a ResidueId, int, or str, "
f"got {type(key).__name__!r} instead"
f"Expected a ResidueId, int, or str, got {type(key).__name__!r} instead"
)
if isinstance(key, int):
return self._residues[key]
Expand All @@ -193,7 +193,7 @@ def __getitem__(self, key):
elif isinstance(key, ResidueId):
return self.data[key]
raise KeyError(
"Expected a ResidueId, int, or str, " f"got {type(key).__name__!r} instead"
f"Expected a ResidueId, int, or str, got {type(key).__name__!r} instead"
)

def select(self, mask):
Expand Down
1 change: 1 addition & 0 deletions prolif/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Helper functions --- :mod:`prolif.utils`
========================================
"""

import warnings
from collections import defaultdict
from contextlib import contextmanager
Expand Down

0 comments on commit d83dd27

Please sign in to comment.