Skip to content

Instantly share code, notes, and snippets.

@jhjensen2
Last active August 21, 2018 17:47
Show Gist options
  • Save jhjensen2/c4e0e7e057cb3466c5eb30a368e5f77c to your computer and use it in GitHub Desktop.
Save jhjensen2/c4e0e7e057cb3466c5eb30a368e5f77c to your computer and use it in GitHub Desktop.
from rdkit import Chem
import itertools
smiles = 'CNCC[NH+](C)CC(F)C'
mol = Chem.MolFromSmiles(smiles)
N_atoms = mol.GetSubstructMatches(Chem.MolFromSmarts('N([*])[*]'))
chiral = Chem.FindMolChiralCenters(mol, includeUnassigned=True)
chiral_atoms = [item[0] for item in N_atoms] + [item[0] for item in chiral if item[1]=='?']
chiral_atoms = list(set(chiral_atoms))
chiral_tags = len(chiral_atoms)*[[Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CW,Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CCW]]
chiral_products = list(itertools.product(*chiral_tags))
mol_list = []
smiles_list = []
for chirality in chiral_products:
newmol = Chem.Mol(mol)
for atom, chiral_tag in zip(chiral_atoms,chirality):
newmol.GetAtomWithIdx(atom).SetChiralTag(chiral_tag)
new_smiles = Chem.MolToSmiles(newmol, isomericSmiles=True)
if new_smiles not in smiles_list:
mol_list.append(newmol)
smiles_list.append(new_smiles)
for newmol in mol_list:
print Chem.MolToSmiles(newmol, isomericSmiles=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment