Skip to content

Commit

Permalink
fix: apply black
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskrt committed May 23, 2024
1 parent 27f48f6 commit 5c90742
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,11 @@ def filter_substructures(
f"{keep} is not a valid SMILES/SELFIES. Instead substructure filtering "
f"based on sequence alone can be done and is set to: {self.text_filtering}"
)
if keep not in self.substructures_to_keep and not Chem.MolFromSmiles( # type: ignore
if keep not in self.substructures_to_keep and not Chem.MolFromSmiles( # type: ignore
self.target
).HasSubstructMatch(subs_mol):
).HasSubstructMatch(
subs_mol
):
logger.info(
f"{keep} could not be identified in SMILES/SELFIES on text level AND no "
"substructure match occurred, hence it will be ignored"
Expand Down Expand Up @@ -1120,7 +1122,7 @@ def filter_substructures(
sane = False
break
else:
if not mol.HasSubstructMatch(subs_mol): # type: ignore
if not mol.HasSubstructMatch(subs_mol): # type: ignore
# Desired substructure not found
sane = False
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ def filter_stubbed(
Tuple of tuples of length 2 with filtered, generated molecule and its properties.
"""

seed = Chem.MolFromSmiles(target) # type: ignore
seed = Chem.MolFromSmiles(target) # type: ignore

seed_atoms = len(list(seed.GetAtoms()))
seed_bonds = seed.GetNumBonds() # type: ignore
seed_bonds = seed.GetNumBonds() # type: ignore

smis: List[str] = []
props: List[str] = []
for smi, prop in property_sequences:
if smi == "":
continue
try:
mol = Chem.MolFromSmiles(smi) # type: ignore
mol = Chem.MolFromSmiles(smi) # type: ignore
num_atoms = len(list(mol.GetAtoms()))
num_bonds = mol.GetNumBonds()

Expand Down
4 changes: 2 additions & 2 deletions src/gt4sd/algorithms/generation/diffusion/geodiff/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ def visualize_2d_input(self, data: Data) -> None:
molSize = (450, 300)
drawer = MD2.MolDraw2DSVG(molSize[0], molSize[1])
drawer.DrawMolecule(mc)
drawer.FinishDrawing() # type: ignore
svg = drawer.GetDrawingText() #type: ignore
drawer.FinishDrawing() # type: ignore
svg = drawer.GetDrawingText() # type: ignore
display(SVG(svg.replace("svg:", "")))

def visualize_3d(self, mols_gen: List[Chem.Mol]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/gt4sd/domains/materials/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def validate_smiles(
for index, molecule in enumerate(molecules)
if molecule is not None and molecule != ""
]
return molecules, valid_ids # type: ignore
return molecules, valid_ids # type: ignore


def validate_selfies(
Expand Down
2 changes: 1 addition & 1 deletion src/gt4sd/properties/molecules/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def number_of_rotatable_bonds(mol: SmallMolecule) -> int:
def number_of_large_rings(mol: SmallMolecule) -> int:
"""Calculate the amount of large rings (> 6 atoms) of a molecule."""
mol = to_mol(mol)
ringinfo = mol.GetRingInfo() # type: ignore
ringinfo = mol.GetRingInfo() # type: ignore
return len([x for x in ringinfo.AtomRings() if len(x) > 6])


Expand Down
4 changes: 2 additions & 2 deletions src/gt4sd/properties/scores/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def score(self, smiles: str) -> float:
descriptor=self.descriptor,
score_modifier=self.modifier,
)
return scoring_function.score_mol(Chem.MolFromSmiles(smiles)) # type: ignore
return scoring_function.score_mol(Chem.MolFromSmiles(smiles)) # type: ignore


class TanimotoScorer(TargetValueScorer):
Expand Down Expand Up @@ -274,7 +274,7 @@ def score(self, smiles: str) -> float:
fp_type=self.fp_type,
score_modifier=self.modifier,
)
return scoring_function.score_mol(Chem.MolFromSmiles(smiles)) # type: ignore
return scoring_function.score_mol(Chem.MolFromSmiles(smiles)) # type: ignore


class IsomerScorer(TargetValueScorer):
Expand Down
8 changes: 4 additions & 4 deletions src/gt4sd/properties/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def to_mol(mol: SmallMolecule) -> Chem.Mol:
a rdkit.Chem.Mol object.
"""
if isinstance(mol, str):
mol = Chem.MolFromSmiles(mol) # type: ignore
mol = Chem.MolFromSmiles(mol) # type: ignore
elif isinstance(mol, Chem.Mol):
pass
else:
raise TypeError(
f"Please provide SMILES string or rdkit.Chem.Mol object not {type(mol)}"
)
return mol # type: ignore
return mol # type: ignore


def to_smiles(mol: SmallMolecule) -> str:
Expand All @@ -70,7 +70,7 @@ def to_smiles(mol: SmallMolecule) -> str:
"""
if isinstance(mol, str):
try:
mol = Chem.MolFromSmiles(mol) # type: ignore
mol = Chem.MolFromSmiles(mol) # type: ignore
except Exception:
raise ValueError(
f"Could not convert SMILES string to rdkit.Chem.Mol: {mol}"
Expand All @@ -82,7 +82,7 @@ def to_smiles(mol: SmallMolecule) -> str:
f"Pass a SMILES string or rdkit.Chem.Mol object not {type(mol)}"
)

return Chem.MolToSmiles(mol, canonical=True) # type: ignore
return Chem.MolToSmiles(mol, canonical=True) # type: ignore


def get_similarity_fn(
Expand Down

0 comments on commit 5c90742

Please sign in to comment.