Skip to content

Commit

Permalink
flake8/linter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Feb 24, 2025
1 parent ca59428 commit cdd158c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions examples/chem_utils/canonicalize_smiles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example for computing Canonicalize SMILES strings"""

import pandas as pd
from workbench.utils.chem_utils import canonicalize

Expand Down
4 changes: 3 additions & 1 deletion examples/chem_utils/tautomerize_smiles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Example for Tautomerizing SMILES strings"""

import pandas as pd
from workbench.utils.chem_utils import tautomerize_smiles

pd.options.display.max_columns = None
pd.options.display.width = 1200

Expand All @@ -24,7 +26,7 @@
# Urea undergoes a proton shift between nitrogen atoms.
{"id": "Urea", "smiles": "C(=O)(N)N", "expected": "NC(N)=O"},
# Phenol standardizes hydroxyl group placement in the aromatic system.
{"id": "Phenol", "smiles": "c1ccc(cc1)O", "expected": "Oc1ccccc1"}
{"id": "Phenol", "smiles": "c1ccc(cc1)O", "expected": "Oc1ccccc1"},
]

# Convert test data to a DataFrame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,14 @@ def create_and_register_model(self):
if __name__ == "__main__":
"""Exercise the FeaturesToModel Class"""

"""
# Regression Model
input_uuid = "abalone_features"
output_uuid = "abalone-regression"
to_model = FeaturesToModel(input_uuid, output_uuid, model_type=ModelType.REGRESSOR)
to_model.set_output_tags(["abalone", "public"])
to_model.transform(target_column="class_number_of_rings", description="Abalone Regression")

"""
# Classification Model
input_uuid = "wine_features"
output_uuid = "wine-classification"
Expand Down Expand Up @@ -357,7 +356,6 @@ def create_and_register_model(self):
to_model = FeaturesToModel(input_uuid, output_uuid, model_type=ModelType.CLASSIFIER, custom_script=my_custom_script)
to_model.set_output_tags(["wine", "custom"])
to_model.transform(target_column="wine_class", description="Wine Custom Classification")
"""
# Molecular Descriptors Model
scripts_root = Path(__file__).resolve().parents[3] / "model_scripts"
Expand All @@ -368,7 +366,6 @@ def create_and_register_model(self):
to_model.set_output_tags(["smiles", "molecular descriptors"])
to_model.transform(target_column=None, feature_list=["smiles"], description="Smiles to Molecular Descriptors")
"""
# Molecular Fingerprints Model
scripts_root = Path(__file__).resolve().parents[3] / "model_scripts"
my_script = scripts_root / "custom_models" / "chem_info" / "morgan_fingerprints.py"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ def canonicalize(df: pd.DataFrame, remove_mol_col: bool = True) -> pd.DataFrame:
df["molecule"] = df["molecule"].apply(lambda mol: remove_disconnected_fragments(mol) if mol else None)

# Convert molecules to canonical SMILES (preserving isomeric information)
df["smiles_canonical"] = df["molecule"].apply(lambda mol: Chem.MolToSmiles(mol, isomericSmiles=True) if mol else None)
df["smiles_canonical"] = df["molecule"].apply(
lambda mol: Chem.MolToSmiles(mol, isomericSmiles=True) if mol else None
)

# Drop intermediate RDKit molecule column if requested
if remove_mol_col:
Expand Down
4 changes: 3 additions & 1 deletion src/workbench/utils/chem_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ def canonicalize(df: pd.DataFrame, remove_mol_col: bool = True) -> pd.DataFrame:
df["molecule"] = df["molecule"].apply(lambda mol: remove_disconnected_fragments(mol) if mol else None)

# Convert molecules to canonical SMILES (preserving isomeric information)
df["smiles_canonical"] = df["molecule"].apply(lambda mol: Chem.MolToSmiles(mol, isomericSmiles=True) if mol else None)
df["smiles_canonical"] = df["molecule"].apply(
lambda mol: Chem.MolToSmiles(mol, isomericSmiles=True) if mol else None
)

# Drop intermediate RDKit molecule column if requested
if remove_mol_col:
Expand Down

0 comments on commit cdd158c

Please sign in to comment.