Skip to content

Commit 3b57fbe

Browse files
author
Oliver Scott
committed
Changed tqdm.tqdm to tqdm.auto for notebook pbar support + added graph_type attribute
1 parent eb32175 commit 3b57fbe

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

scaffoldgraph/core/graph.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
from abc import ABC, abstractmethod
88
from collections import Counter
99

10-
import tqdm
1110
import networkx as nx
1211

1312
from loguru import logger
13+
from tqdm.auto import tqdm
14+
1415
from rdkit import RDLogger
1516
from rdkit.Chem import rdMolHash, MolToSmiles, rdmolops
1617
from rdkit.Chem.rdMolDescriptors import CalcNumRings
@@ -33,15 +34,18 @@ def init_molecule_name(mol):
3334
class 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

Comments
 (0)