Created
August 2, 2017 04:21
-
-
Save greglandrum/f4e2f2f2ad311560d8ab36874d503843 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 | |
m = Chem.RWMol() | |
for i in range(3): | |
a = Chem.Atom(6) | |
m.AddAtom(a) | |
a = Chem.Atom(0) | |
m.AddAtom(a) | |
m.GetAtomWithIdx(0).SetIsAromatic(True) # set atom 0 as aromatic | |
m.GetAtomWithIdx(0).SetNoImplicit(True) | |
m.GetAtomWithIdx(2).SetNoImplicit(True) | |
m.GetAtomWithIdx(0).SetNumExplicitHs(1) | |
m.GetAtomWithIdx(2).SetNumExplicitHs(2) | |
m.GetAtomWithIdx(3).SetAtomMapNum(1) | |
m.AddBond(0, 1, Chem.rdchem.BondType.SINGLE) | |
m.AddBond(1, 2, Chem.rdchem.BondType.SINGLE) | |
m.AddBond(1, 3, Chem.rdchem.BondType.SINGLE) | |
print(Chem.MolToSmiles(m)) | |
#2 =========== | |
m2 = Chem.RWMol() | |
for i in range(3): | |
a = Chem.Atom(6) | |
m2.AddAtom(a) | |
a = Chem.Atom(0) | |
m2.AddAtom(a) | |
m2.GetAtomWithIdx(2).SetIsAromatic(True) # set atom 2 as aromatic | |
m2.GetAtomWithIdx(3).SetAtomMapNum(1) | |
m2.GetAtomWithIdx(0).SetNoImplicit(True) | |
m2.GetAtomWithIdx(2).SetNoImplicit(True) | |
m2.GetAtomWithIdx(2).SetNumExplicitHs(1) | |
m2.GetAtomWithIdx(0).SetNumExplicitHs(2) | |
m2.AddBond(0, 1, Chem.rdchem.BondType.SINGLE) | |
m2.AddBond(1, 2, Chem.rdchem.BondType.SINGLE) | |
m2.AddBond(1, 3, Chem.rdchem.BondType.SINGLE) | |
print(Chem.MolToSmiles(m2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment