Skip to content

Commit

Permalink
fix: Isomery removal with flexible sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisborn committed Nov 30, 2023
1 parent 27ca3f8 commit bc896fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pytoda/datasets/smiles_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __init__(
logger.error('Looking great, no problems found!')
else:
logger.error(
'To get rid of this, adapt the smiles_language *offline*, feed it'
'To get rid of this, adapt the smiles_language *offline*, feed it '
'ready for intended usage, and adapt the constructor args to be '
'identical with their equivalents in the language object'
)
Expand Down
9 changes: 5 additions & 4 deletions pytoda/smiles/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def compose_smiles_transforms(
else:
if remove_bonddir or remove_chirality:
smiles_transforms += [
RemoveIsomery(bonddir=remove_bonddir, chirality=remove_chirality)
RemoveIsomery(
bonddir=remove_bonddir,
chirality=remove_chirality,
sanitize=sanitize,
)
]
if kekulize:
smiles_transforms += [
Expand Down Expand Up @@ -274,7 +278,6 @@ class Kekulize(Transform):
"""Transform SMILES to Kekule version."""

def __init__(self, all_bonds_explicit=False, all_hs_explicit=False, sanitize=True):

# NOTE: Explicit bonds or Hs without Kekulization is not supported
self.all_bonds_explicit = all_bonds_explicit
self.all_hs_explicit = all_hs_explicit
Expand Down Expand Up @@ -486,7 +489,6 @@ def __call__tensor(self, smiles_numerical: Tensor) -> torch.Tensor:
"""
# Infer the padding type to ensure returning tensor of same shape.
if self.smiles_language.padding_index in smiles_numerical.flatten():

padding = True
left_padding = any(
[
Expand Down Expand Up @@ -516,7 +518,6 @@ def __call__tensor(self, smiles_numerical: Tensor) -> torch.Tensor:
# if it violates the padding
augmented = []
for smiles in smiles_numerical:

lenx = seq_len + 1
while lenx > seq_len:
augmented_smiles = self.__call__(smiles)
Expand Down

0 comments on commit bc896fa

Please sign in to comment.