77from abc import ABC , abstractmethod
88from collections import Counter
99
10- import tqdm
1110import networkx as nx
1211
1312from loguru import logger
13+ from tqdm .auto import tqdm
14+
1415from rdkit import RDLogger
1516from rdkit .Chem import rdMolHash , MolToSmiles , rdmolops
1617from rdkit .Chem .rdMolDescriptors import CalcNumRings
@@ -33,15 +34,18 @@ def init_molecule_name(mol):
3334class ScaffoldGraph (nx .DiGraph , ABC ):
3435 """Abstract base class for ScaffoldGraphs"""
3536
36- def __init__ (self , graph = None , fragmenter = None ):
37+ def __init__ (self , graph = None , fragmenter = None , graph_type = None ):
3738 """
3839 Initialize a ScaffoldGraph object
3940
4041 Parameters
4142 ----------
4243 graph: Graph data to inherit (optional, default=None)
44+ fragmenter: fragmenter class for producing the next scaffold hierarchy
45+ of a given molecular input with fragmenter.fragment(input)
46+ graph_type: the type of graph being constructed (graph attribute)
4347 """
44- super (ScaffoldGraph , self ).__init__ (graph )
48+ super (ScaffoldGraph , self ).__init__ (graph , graph_type = graph_type )
4549 self .fragmenter = fragmenter
4650
4751 def _construct (self , molecules , ring_cutoff = 10 , progress = False , annotate = True ):
@@ -60,7 +64,7 @@ def _construct(self, molecules, ring_cutoff=10, progress=False, annotate=True):
6064 rdlogger .setLevel (4 ) # Suppress the RDKit logs
6165 progress = progress is False
6266 desc = self .__class__ .__name__
63- for molecule in tqdm . tqdm (molecules , disable = progress , desc = desc , miniters = 1 , dynamic_ncols = True ):
67+ for molecule in tqdm (molecules , disable = progress , desc = desc , miniters = 1 , dynamic_ncols = True ):
6468 if molecule is None : # logged in suppliers
6569 continue
6670 init_molecule_name (molecule )
0 commit comments