Dear Aniko,

properties are associated to the Mol object, not to the Conformer object. If you wish to retain the original properties associated with each Mol you may copy the aligned coordinates to the original Mol object and write that instead. This will allow you to retain the original properties. Please note that I haven't tried to run my own sample code below, so please bear with me if it does not quite work as is, but it was just to give you an idea how to achieve your goal:


def copy_coords(from, to):
    for i in range(from.GetNumAtoms()):
        to.SetAtomPosition(i, from.GetAtomPosition(i))

w = Chem.SDWriter(“aligned.sdf”)
nconfs = len(allconfs.GetConformers())
i = 0
for conf in confs:   # loop over my sdf files
    suppl = Chem.SDMolSupplier(conf, removeHs = False)
    if “_c0.sdf” in conf:
        copy_coords(allconfs.GetConformer(0), suppl[0].GetConformer())
        w.write(suppl[0])
    else:
        for mol in suppl:
            i += 1
            if (i == nconfs):
                raise RuntimeError('Something went wrong, i = nconfs = {0:d}'.format(nconfs))
            copy_coords(allconfs.GetConformer(i), mol.GetConformer())
            w.write(mol)
w.close()

******
HTH, Cheers,
p.

On 05/23/18 09:11, Udvarhelyi, Aniko wrote:

Dear Greg,

I have separate SDF files of conformers of the same molecule (they are called xxxx_c0.sdf, xxxx_c1.sdf, xxxx_c2.sdf and so on), with a few properties for each conformer. I am using the following code to read them into RDKit and align them:

*for conf in confs:   # loop over my sdf files*

*    suppl = Chem.SDMolSupplier(conf, removeHs = False)*

*    if “_c0.sdf” in conf:*

*        allconfs = suppl[0]*

*    else:*

*        for i,mol in enumerate(suppl):*

*allconfs.AddConformer(mol.GetConformer(), assignId = True)*

And then I am using *AllChem.AlignMolConformers(allconfs)*to align the conformers. It all works fine BUT: when I save the aligned conformers with the SDWriter, all the conformers have the properties of the very first conformer. What should I do to keep the original SDF properties of the conformers from before the alignment? Does AddConformer lose the properties or is something wrong with how I write them out? I am using the following to save the aligned conformers into one sdf:

*w = Chem.SDWriter(“aligned.sdf”)*

*for conf_id in range(len(allconf.GetConformers)):*

*    w.write(allconfs, confId=conf_id)*

*w.close()*

What should I do to have all the original SDF properties from the initial conformers in the aligned.sdf file?

Many thanks and best regards,

Anikó



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to