Hello,

I am trying to create a molecule from a connectivity table and xyz
coordinates, however, when I try to do that I get an Argument Error:

ArgumentError: Python argument types in
    Mol.AddConformer(Mol, Conformer)
did not match C++ signature:
    AddConformer(RDKit::ROMol {lvalue} self, RDKit::Conformer* conf,
bool assignId=False)


Below is what I did:


from rdkit import Chem
import numpy as np
from rdkit.Geometry.rdGeometry import Point3D


hooh = {
        'symbols': ['H', 'O', 'O', 'H'],
        'geometry': [
             1.84719633,  1.47046223,  0.80987166,
             1.3126021,  -0.13023157, -0.0513322,
            -1.31320906,  0.13130216, -0.05020593,
            -1.83756335, -1.48745318,  0.80161212
        ],
        'name': 'HOOH',
        'connectivity': [[0, 1, 1], [1, 2, 1], [2, 3, 1]],
    }

_atomic_number = {'H': 1, 'O':8}
bond_types = {1:Chem.BondType.SINGLE, 2:Chem.BondType.DOUBLE,
3:Chem.BondType.TRIPLE}
BOHR_2_ANGSTROM = 0.529177210
symbols = hooh['symbols']
geometry = np.array(hooh['geometry'],
dtype=float).reshape(int(len(hooh['geometry'])/3), 3)*BOHR_2_ANGSTROM
connectivity = hooh['connectivity']

molecule = Chem.Mol()
editable_mol = Chem.RWMol(molecule)
conformer = Chem.Conformer(len(symbols))
for i, s in enumerate(symbols):
    atom = editable_mol.AddAtom(Chem.Atom(_atomic_number[s]))
    atom_position = Point3D(geometry[i][0], geometry[i][1], geometry[i][2])
    conformer.SetAtomPosition(atom, atom_position)

# Add connectivity
for bond in connectivity:
    bond_type = bond_types[bond[-1]]
    editable_mol.AddBond(bond[0], bond[1], bond_type)
mol = editable_mol.GetMol()
Chem.SanitizeMol(mol)
initial_conformer = mol.AddConformer(conformer, assignID=True)

I am using rdkit version 2018.09.1 on OSX. I am not sure what I am doing
wrong. Any help will be appreciated.

Thank you,
Chaya
-- 
Chaya D Stern
Memorial Sloan Kettering Cancer Center
Tri-Institutional Chemical Biology Program
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to