Skip to content

Commit

Permalink
added and option to hide the progress bar in RDKitDescriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
PatWalters committed Jul 30, 2024
1 parent fd85bcb commit 6a3c942
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion useful_rdkit_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
from .split_utils import *
from .scaffold_finder import *

__version__ = "0.60"
__version__ = "0.61"
9 changes: 6 additions & 3 deletions useful_rdkit_utils/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ def apply_func(name, mol):
class RDKitDescriptors:
""" Calculate RDKit descriptors"""

def __init__(self: "RDKitDescriptors") -> None:
def __init__(self: "RDKitDescriptors", hide_progress: bool = False) -> None:
"""
Initialize the RDKitDescriptors class.
:param self: An instance of the RDKitDescriptors class
:type self: RDKitDescriptors
:param hide_progress: Flag to hide progress bar
:type hide_progress: bool
:return: None
:rtype: None
"""
self.hide_progress = hide_progress
self.desc_names: List[str] = [desc_name for desc_name, _ in sorted(Descriptors.descList)]

def calc_mol(self, mol: Mol) -> np.ndarray:
Expand Down Expand Up @@ -135,7 +138,7 @@ def pandas_smiles(self, smiles_list: List[str]) -> pd.DataFrame:
:return: DataFrame with calculated descriptors. Each row corresponds to a SMILES string and each column to a descriptor.
"""
desc_list = []
for smi in tqdm(smiles_list):
for smi in tqdm(smiles_list, disable=self.hide_progress):
desc_list.append(self.calc_smiles(smi))
df = pd.DataFrame(desc_list, columns=self.desc_names)
return df
Expand All @@ -148,7 +151,7 @@ def pandas_mols(self, mol_list: List[Mol]) -> pd.DataFrame:
:return: DataFrame with calculated descriptors. Each row corresponds to a molecule and each column to a descriptor.
"""
desc_list = []
for mol in tqdm(mol_list):
for mol in tqdm(mol_list, disable=self.hide_progress):
desc_list.append(self.calc_mol(mol))
df = pd.DataFrame(desc_list, columns=self.desc_names)
return df
Expand Down

0 comments on commit 6a3c942

Please sign in to comment.