-
-
Save mbohun/9cd8a67bb1aed767f38530d827291b2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rdkit import Chem | |
from rdkit.Chem import AllChem | |
from itertools import islice | |
raw_smiles = ['NCCN'] | |
smiles_list = ['NCCN'] | |
rxn_smarts_list = ['[C:1][*:2][C:3]>>[C:1]1[*:2][C:3]1','[C:1][C:2]>>[C:1][C][C:2]'] | |
molecules = [] | |
mol = Chem.MolFromSmiles(smiles_list[0]) | |
molecules.append(mol) | |
substitutions = 6 | |
for i in range(substitutions): | |
for smiles in islice(raw_smiles,i,len(raw_smiles)): | |
mol = Chem.MolFromSmiles(smiles) | |
for rxn_smarts in rxn_smarts_list: | |
rxn = AllChem.ReactionFromSmarts(rxn_smarts) | |
new_mols = rxn.RunReactants((mol,)) | |
for new_mol in new_mols: | |
new_smiles = Chem.MolToSmiles(new_mol[0]) | |
if new_smiles not in raw_smiles: | |
raw_smiles.append(new_smiles) | |
for smiles in raw_smiles: | |
try: | |
mol = Chem.MolFromSmiles(smiles) | |
except: | |
continue | |
if mol != None: | |
smiles = Chem.MolToSmiles(Chem.MolFromSmiles(smiles)) | |
if smiles not in smiles_list: | |
smiles_list.append(smiles) | |
molecules.append(mol) | |
print len(smiles_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment