Skip to content

Commit d977e53

Browse files
committed
fix styling
1 parent ff6b5f7 commit d977e53

4 files changed

Lines changed: 78 additions & 82 deletions

File tree

prolif/fingerprint.py

Lines changed: 76 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -578,91 +578,91 @@ def run(
578578
) -> "Fingerprint":
579579
"""Generates the fingerprint on a trajectory for a ligand and a protein
580580
581-
Parameters
582-
----------
583-
traj : MDAnalysis.coordinates.base.ProtoReader or MDAnalysis.coordinates.base.FrameIteratorSliced or MDAnalysis.coordinates.base.FrameIteratorIndices or MDAnalysis.coordinates.timestep.Timestep
584-
Iterate over this Universe trajectory or sliced trajectory object
585-
to extract the frames used for the fingerprint extraction
586-
lig : MDAnalysis.core.groups.AtomGroup
587-
An MDAnalysis AtomGroup for the ligand
588-
prot : MDAnalysis.core.groups.AtomGroup
589-
An MDAnalysis AtomGroup for the protein (with multiple residues)
590-
residues : list or "all" or None
591-
A list of protein residues (:class:`str`, :class:`int` or
592-
:class:`~prolif.residue.ResidueId`) to take into account for
593-
the fingerprint extraction. If ``"all"``, all residues will be
594-
used. If ``None``, at each frame the
595-
:func:`~prolif.utils.get_residues_near_ligand` function is used to
596-
automatically use protein residues that are distant of 6.0 Å or
597-
less from each ligand residue.
598-
converter_kwargs : tuple[dict, dict], optional
599-
Tuple of kwargs passed to the underlying
600-
:class:`~MDAnalysis.converters.RDKit.RDKitConverter` from MDAnalysis: the
601-
first for the ligand, and the second for the protein
602-
progress : bool
603-
Display a :class:`~tqdm.std.tqdm` progressbar while running the calculation
604-
n_jobs : int or None
605-
Number of processes to run in parallel. If ``n_jobs=1``, the analysis
606-
will run in serial. If ``n_jobs=None``, see
607-
:func:`~prolif.parallel.get_n_jobs` for the default behavior.
608-
parallel_strategy : {"chunk", "queue"}, optional
609-
Strategy for parallel execution:
610-
611-
- ``"chunk"``: Split trajectory into chunks and distribute to workers.
612-
Each worker pickles the full MDAnalysis objects once per chunk.
613-
Scales better for small trajectories.
614-
- ``"queue"``: Main thread converts frames to Molecules and enqueues
615-
them for workers. Avoids repeated MDAnalysis pickling overhead.
616-
Better when pickling is expensive, e.g. large trajectories with many
617-
atoms.
618-
- ``None``: See :func:`~prolif.parallel.get_mda_parallel_strategy` for
619-
the default behavior.
620-
621-
Raises
622-
------
623-
ValueError
624-
If ``n_jobs <= 0``
581+
Parameters
582+
----------
583+
traj : MDAnalysis.coordinates.base.ProtoReader or MDAnalysis.coordinates.base.FrameIteratorSliced or MDAnalysis.coordinates.base.FrameIteratorIndices or MDAnalysis.coordinates.timestep.Timestep
584+
Iterate over this Universe trajectory or sliced trajectory object
585+
to extract the frames used for the fingerprint extraction
586+
lig : MDAnalysis.core.groups.AtomGroup
587+
An MDAnalysis AtomGroup for the ligand
588+
prot : MDAnalysis.core.groups.AtomGroup
589+
An MDAnalysis AtomGroup for the protein (with multiple residues)
590+
residues : list or "all" or None
591+
A list of protein residues (:class:`str`, :class:`int` or
592+
:class:`~prolif.residue.ResidueId`) to take into account for
593+
the fingerprint extraction. If ``"all"``, all residues will be
594+
used. If ``None``, at each frame the
595+
:func:`~prolif.utils.get_residues_near_ligand` function is used to
596+
automatically use protein residues that are distant of 6.0 Å or
597+
less from each ligand residue.
598+
converter_kwargs : tuple[dict, dict], optional
599+
Tuple of kwargs passed to the underlying
600+
:class:`~MDAnalysis.converters.RDKit.RDKitConverter` from MDAnalysis: the
601+
first for the ligand, and the second for the protein
602+
progress : bool
603+
Display a :class:`~tqdm.std.tqdm` progressbar while running the calculation
604+
n_jobs : int or None
605+
Number of processes to run in parallel. If ``n_jobs=1``, the analysis
606+
will run in serial. If ``n_jobs=None``, see
607+
:func:`~prolif.parallel.get_n_jobs` for the default behavior.
608+
parallel_strategy : {"chunk", "queue"}, optional
609+
Strategy for parallel execution:
610+
611+
- ``"chunk"``: Split trajectory into chunks and distribute to workers.
612+
Each worker pickles the full MDAnalysis objects once per chunk.
613+
Scales better for small trajectories.
614+
- ``"queue"``: Main thread converts frames to Molecules and enqueues
615+
them for workers. Avoids repeated MDAnalysis pickling overhead.
616+
Better when pickling is expensive, e.g. large trajectories with many
617+
atoms.
618+
- ``None``: See :func:`~prolif.parallel.get_mda_parallel_strategy` for
619+
the default behavior.
620+
621+
Raises
622+
------
623+
ValueError
624+
If ``n_jobs <= 0``
625625
626-
Returns
627-
-------
628-
prolif.fingerprint.Fingerprint
629-
The Fingerprint instance that generated the fingerprint
626+
Returns
627+
-------
628+
prolif.fingerprint.Fingerprint
629+
The Fingerprint instance that generated the fingerprint
630630
631-
Example
632-
-------
633-
::
631+
Example
632+
-------
633+
::
634634
635-
>>> u = mda.Universe("top.pdb", "traj.nc")
636-
>>> lig = u.select_atoms("resname LIG")
637-
>>> prot = u.select_atoms("protein")
638-
>>> fp = prolif.Fingerprint().run(u.trajectory[:10], lig, prot)
635+
>>> u = mda.Universe("top.pdb", "traj.nc")
636+
>>> lig = u.select_atoms("resname LIG")
637+
>>> prot = u.select_atoms("protein")
638+
>>> fp = prolif.Fingerprint().run(u.trajectory[:10], lig, prot)
639639
640-
.. seealso::
640+
.. seealso::
641641
642-
- :meth:`Fingerprint.generate` to generate the fingerprint between
643-
two single structures.
644-
- :meth:`Fingerprint.run_from_iterable` to generate the fingerprint
645-
between a protein and a collection of ligands.
642+
- :meth:`Fingerprint.generate` to generate the fingerprint between
643+
two single structures.
644+
- :meth:`Fingerprint.run_from_iterable` to generate the fingerprint
645+
between a protein and a collection of ligands.
646646
647-
.. versionchanged:: 0.3.2
648-
Moved the ``return_atoms`` parameter from the ``run`` method to the
649-
dataframe conversion code
647+
.. versionchanged:: 0.3.2
648+
Moved the ``return_atoms`` parameter from the ``run`` method to the
649+
dataframe conversion code
650650
651-
.. versionchanged:: 1.0.0
652-
Added support for multiprocessing
651+
.. versionchanged:: 1.0.0
652+
Added support for multiprocessing
653653
654-
.. versionchanged:: 1.1.0
655-
Added support for passing kwargs to the RDKitConverter through
656-
the ``converter_kwargs`` parameter
654+
.. versionchanged:: 1.1.0
655+
Added support for passing kwargs to the RDKitConverter through
656+
the ``converter_kwargs`` parameter
657657
658-
.. versionchanged:: 2.0.0
659-
Changed the format of the :attr:`~Fingerprint.ifp` attribute to be a
660-
dictionary containing more complete interaction metadata instead of just
661-
atom indices.
658+
.. versionchanged:: 2.0.0
659+
Changed the format of the :attr:`~Fingerprint.ifp` attribute to be a
660+
dictionary containing more complete interaction metadata instead of just
661+
atom indices.
662662
663-
.. versionchanged:: 2.1.0
664-
Added ``use_segid``, ``parallel_strategy`` parameter and changed the
665-
default behavior of ``n_jobs=None``.
663+
.. versionchanged:: 2.1.0
664+
Added ``use_segid``, ``parallel_strategy`` parameter and changed the
665+
default behavior of ``n_jobs=None``.
666666
667667
""" # noqa: E501
668668
if converter_kwargs is not None and len(converter_kwargs) != 2:
@@ -959,9 +959,7 @@ def _run_iter_serial(
959959
iterator = tqdm(lig_iterable, **kwargs) if progress else lig_iterable
960960
ifp: "IFPResults" = {}
961961
for i, lig_mol in enumerate(iterator):
962-
ifp[i] = self.generate(
963-
lig_mol, prot_mol, residues=residues, metadata=True
964-
)
962+
ifp[i] = self.generate(lig_mol, prot_mol, residues=residues, metadata=True)
965963
return ifp
966964

967965
def _run_iter_parallel(

prolif/molecule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def from_mda(
157157
158158
.. versionchanged:: 2.1.0
159159
Added `use_segid`.
160-
"""
160+
""" # noqa: E501
161161
ag = obj.select_atoms(selection) if selection else obj.atoms
162162
if ag.n_atoms == 0:
163163
raise mda.SelectionError("AtomGroup is empty, please check your selection")

prolif/parallel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,6 @@ class TrajectoryPoolQueue:
458458
459459
.. versionadded:: 2.1.0
460460
461-
.. versionchanged:: 2.2.0
462-
Added ``ignore`` parameter to :class:`~prolif.fingerprint.Fingerprint` constructor.
463461
"""
464462

465463
fp: ClassVar["Fingerprint"]

tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def test_engine_exc_shows_residue_id(
254254

255255
with pytest.raises(
256256
ValueError,
257-
match="Could not apply template for residue ALA1.A: test",
257+
match=r"Could not apply template for residue ALA1.A: test",
258258
):
259259
standardizer(Chem.MolFromSequence("AA"))
260260

0 commit comments

Comments
 (0)