diff --git a/prolif/ifp.py b/prolif/ifp.py index 7935350..4f586ee 100644 --- a/prolif/ifp.py +++ b/prolif/ifp.py @@ -2,6 +2,7 @@ Storing interactions --- :mod:`prolif.ifp` ========================================== """ + from collections import UserDict from prolif.residue import ResidueId diff --git a/prolif/interactions/base.py b/prolif/interactions/base.py index 6bbe237..0e2df25 100644 --- a/prolif/interactions/base.py +++ b/prolif/interactions/base.py @@ -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 diff --git a/prolif/interactions/interactions.py b/prolif/interactions/interactions.py index f3f733f..7fe576c 100644 --- a/prolif/interactions/interactions.py +++ b/prolif/interactions/interactions.py @@ -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__( @@ -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), diff --git a/prolif/molecule.py b/prolif/molecule.py index f44a0ed..3d28d69 100644 --- a/prolif/molecule.py +++ b/prolif/molecule.py @@ -2,6 +2,7 @@ Reading proteins and ligands --- :mod:`prolif.molecule` ======================================================= """ + import copy from collections import defaultdict from collections.abc import Sequence @@ -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) diff --git a/prolif/parallel.py b/prolif/parallel.py index 3705087..c35dd51 100644 --- a/prolif/parallel.py +++ b/prolif/parallel.py @@ -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 diff --git a/prolif/pickling.py b/prolif/pickling.py index 4b455d6..b97bc55 100644 --- a/prolif/pickling.py +++ b/prolif/pickling.py @@ -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 diff --git a/prolif/plotting/barcode.py b/prolif/plotting/barcode.py index 225765b..046c61e 100644 --- a/prolif/plotting/barcode.py +++ b/prolif/plotting/barcode.py @@ -8,6 +8,7 @@ :members: """ + from __future__ import annotations from typing import TYPE_CHECKING, ClassVar, Dict, List, Literal, Optional, Tuple @@ -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) @@ -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()) diff --git a/prolif/plotting/complex3d.py b/prolif/plotting/complex3d.py index a8573cc..26022e4 100644 --- a/prolif/plotting/complex3d.py +++ b/prolif/plotting/complex3d.py @@ -8,6 +8,7 @@ :members: """ + from __future__ import annotations from copy import deepcopy @@ -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'}); @@ -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) diff --git a/prolif/plotting/network.py b/prolif/plotting/network.py index 2230693..cfbc6a1 100644 --- a/prolif/plotting/network.py +++ b/prolif/plotting/network.py @@ -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) @@ -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): diff --git a/prolif/plotting/residues.py b/prolif/plotting/residues.py index 7ae68b5..ec3545e 100644 --- a/prolif/plotting/residues.py +++ b/prolif/plotting/residues.py @@ -7,6 +7,7 @@ .. autofunction:: display_residues """ + from typing import Any, Optional, Tuple from rdkit import Chem diff --git a/prolif/rdkitmol.py b/prolif/rdkitmol.py index eed076c..5967b92 100644 --- a/prolif/rdkitmol.py +++ b/prolif/rdkitmol.py @@ -2,6 +2,7 @@ Reading RDKit molecules --- :mod:`prolif.rdkitmol` ================================================== """ + from rdkit import Chem from rdkit.Chem.rdMolTransforms import ComputeCentroid diff --git a/prolif/residue.py b/prolif/residue.py index d646446..d92334e 100644 --- a/prolif/residue.py +++ b/prolif/residue.py @@ -2,6 +2,7 @@ Residue-related classes --- :mod:`prolif.residue` ================================================= """ + import re from collections import UserDict from typing import List, Optional @@ -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] @@ -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): diff --git a/prolif/utils.py b/prolif/utils.py index c838135..65fa1d9 100644 --- a/prolif/utils.py +++ b/prolif/utils.py @@ -2,6 +2,7 @@ Helper functions --- :mod:`prolif.utils` ======================================== """ + import warnings from collections import defaultdict from contextlib import contextmanager