Skip to content

Commit

Permalink
fixed bug for mapped molecules
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramil Nugmanov committed Mar 23, 2019
1 parent 859fb1f commit ac49080
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions CGRtools/utils/rdkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ def from_rdkit_molecule(data):
RDKit molecule object to MoleculeContainer converter
"""
m = MoleculeContainer()
atoms = []
atoms, mapping = [], []
for a in data.GetAtoms():
atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
atoms.append(atom)
mapping.append(a.GetAtomMapNum())

mapping = a.GetAtomMapNum()
if mapping:
atom['mapping'] = mapping
isotope = a.GetIsotope()
if isotope:
atom['isotope'] = isotope
Expand All @@ -47,8 +45,10 @@ def from_rdkit_molecule(data):
atom['y'] = y
atom['z'] = z

for atom in atoms:
m.add_atom(atom)
for atom, mapping in zip(atoms, mapping):
a = m.add_atom(atom)
if mapping:
m.atom(a)._parsed_mapping = mapping

for bond in data.GetBonds():
m.add_bond(bond.GetBeginAtomIdx() + 1, bond.GetEndAtomIdx() + 1, _rdkit_bond_map[bond.GetBondType()])
Expand Down

0 comments on commit ac49080

Please sign in to comment.