Skip to content

Commit 278bcc8

Browse files
wconnellKiddoZhu
authored andcommitted
avoid rdkit mol creation if lazy load
1 parent c067129 commit 278bcc8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

torchdrug/data/dataset.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ def load_smiles(self, smiles_list, targets, transform=None, lazy=False, verbose=
5757

5858
if verbose:
5959
smiles_list = tqdm(smiles_list, "Constructing molecules from SMILES")
60+
6061
for i, smiles in enumerate(smiles_list):
61-
mol = Chem.MolFromSmiles(smiles)
62-
if not mol:
63-
logger.debug("Can't construct molecule from SMILES `%s`. Ignore this sample." % smiles)
64-
continue
6562
if not self.lazy or len(self.data) == 0:
63+
mol = Chem.MolFromSmiles(smiles)
64+
if not mol:
65+
logger.debug("Can't construct molecule from SMILES `%s`. Ignore this sample." % smiles)
66+
continue
6667
mol = data.Molecule.from_molecule(mol, **kwargs)
6768
else:
6869
mol = None

0 commit comments

Comments
 (0)