33from __future__ import annotations
44
55import copy
6- from importlib import resources
76from pathlib import Path
8- from typing import TYPE_CHECKING , Any , Literal
7+ from typing import TYPE_CHECKING , Any
98
109try :
1110 from typing import Self # type: ignore[attr-defined]
@@ -49,11 +48,10 @@ class MolToPharmacophore2DFP( # pylint: disable=too-many-instance-attributes
4948 - Distance bins for feature pairs
5049 - Configurable parameters for feature factory and signature factory
5150
52- References
53- ----------
54- [1] RDKit Documentation on 2D Pharmacophore Fingerprints
55- [2] Gobbi, A. & Poppinger, D. Genetic optimization of combinatorial libraries.
56- Biotechnology and Bioengineering 61, 47-54 (1998).
51+ Per default, the 2d pharmacophore fingerprint described by Gobbi et al. is used.
52+ See:
53+ Gobbi, A. & Poppinger, D. Genetic optimization of combinatorial libraries.
54+ Biotechnology and Bioengineering 61, 47-54 (1998).
5755
5856 """
5957
@@ -79,8 +77,8 @@ def __init__(
7977 Parameters
8078 ----------
8179 feature_definition : Path, str, or None, optional
82- Path or content of a feature definition file (.fdef). If None, uses RDKit's
83- default MinimalFeatures.fdef .
80+ Path or content of a feature definition file (.fdef). If None, uses
81+ configuration by Gobbi et al .
8482 min_point_count : int, default=2
8583 Minimum number of pharmacophore points in a signature.
8684 max_point_count : int, default=3
@@ -95,7 +93,7 @@ def __init__(
9593 List of feature types to skip. If None, no features are skipped.
9694 distance_bins : list[tuple[float, float]], optional
9795 List of distance bins as (min_distance, max_distance) tuples.
98- If None, uses default bins: [(1, 2), (2, 5), (5, 8)] .
96+ If None, uses default bins by Gobbi et al .
9997 counted : bool, default=False
10098 If True, the fingerprint will be counted (values represent occurrence).
10199 If False, the fingerprint will be binary (values are 0 or 1).
@@ -137,7 +135,7 @@ def __init__(
137135
138136 # Set default distance bins if not provided
139137 if distance_bins is None :
140- distance_bins = [( 1 , 2 ), ( 2 , 5 ), ( 5 , 8 )]
138+ distance_bins = Gobbi_Pharm2D . defaultBins
141139 self ._validate_distance_bins (distance_bins )
142140 self ._distance_bins = distance_bins
143141
@@ -170,9 +168,8 @@ def _read_feature_factory_content(
170168 """
171169 if feature_definition is None :
172170 # Set default feature factory path if not provided
173- resource_files = resources .files ("molpipeline.resources" )
174- feat_def_path = resource_files / "MinimalFeatures.fdef"
175- elif isinstance (feature_definition , Path ):
171+ return Gobbi_Pharm2D .fdef
172+ if isinstance (feature_definition , Path ):
176173 # If feature_definition is a Path, use it directly
177174 feat_def_path = feature_definition
178175 elif isinstance (feature_definition , str ):
@@ -538,46 +535,3 @@ def pretransform_single(
538535 if self .counted :
539536 return fp .GetNonzeroElements ()
540537 return dict .fromkeys (fp .GetOnBits (), 1 )
541-
542- @staticmethod
543- def from_preconfiguration (
544- config_name : Literal ["gobbi" ],
545- ** kwargs : Any ,
546- ) -> MolToPharmacophore2DFP :
547- """Create a preconfigured MolToPharmacophore2DFP instance.
548-
549- Preconfigurations:
550- - "gobbi": Uses Gobbi's pharmacophore features as defined in:
551- Gobbi, A. & Poppinger, D. Genetic optimization of combinatorial libraries.
552- Biotechnology and Bioengineering 61, 47-54 (1998).
553-
554- Parameters
555- ----------
556- config_name : Literal["gobbi"]
557- Name of the preconfiguration to use.
558- **kwargs : Any
559- Additional parameters to the MolToPharmacophore2DFP constructor.
560-
561- Returns
562- -------
563- MolToPharmacophore2DFP
564- Preconfigured MolToPharmacophore2DFP instance.
565-
566- Raises
567- ------
568- ValueError
569- If the configuration name is unknown.
570-
571- """
572- if config_name == "gobbi" :
573- # gobbi pharmacophore features are also implemented in RDKit. We just
574- # borrow the definition here from the Gobbi_Pharm2D module.
575- return MolToPharmacophore2DFP (
576- feature_definition = Gobbi_Pharm2D .fdef ,
577- min_point_count = 2 ,
578- max_point_count = 3 ,
579- distance_bins = Gobbi_Pharm2D .defaultBins ,
580- ** kwargs ,
581- )
582-
583- raise ValueError (f"Unknown configuration name: { config_name } " )
0 commit comments