Hi Marina,

If you wish to assign stereochemistry from the atom block parity flag rather than from 3D coordinates you might try the following:

#include <GraphMol/RDKitBase.h>
#include <GraphMol/FileParsers/MolSupplier.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
#include <string>
#include <iostream>

int main(int argc, char **argv) {
    std::string in_file_name = "zinc_3833800.sdf";

    RDKit::SDMolSupplier mol_supplier( in_file_name , true );

    for (unsigned int i = 0; i < mol_supplier.length(); ++i) {
            RDKit::ROMOL_SPTR mol(mol_supplier[i]);

            if (!mol){
                std::cout << "Error, molecule not found!" << std::endl;
                continue;
            }


            for (unsigned int j = 0; j < mol->getNumAtoms(); j++){
                RDKit::Atom* atom = mol->getAtomWithIdx(j);
                if (atom->hasProp(RDKit::common_properties::molParity)) {
                    int parity;
atom->getProp(RDKit::common_properties::molParity, parity);
                    switch (parity) {
                    case 1:
atom->setChiralTag(RDKit::Atom::CHI_TETRAHEDRAL_CW);
                        break;
                    case 2:
atom->setChiralTag(RDKit::Atom::CHI_TETRAHEDRAL_CCW);
                        break;
                    default:
atom->setChiralTag(RDKit::Atom::CHI_UNSPECIFIED);
                        break;
                    }
                }
                std::cout << "Chirality atom " << j+1  << ": " << atom->getChiralTag() << std::endl;
            }

            std::string usmiles = RDKit::MolToSmiles (*mol, true);
            std::cout << "Mol: " << usmiles << std::endl;
    }
}

Cheers,
p.

On 13/12/2017 09:39, Marina Garcia de Lomana wrote:
Thanks for your answer Paolo!
But I would need to read in the stereochemistry information from the SD file (7th column in the atom block) and not calculate the chirality from the coordinates, since this way the information about racemates would get lost.

Is there a way to do that?


El 13 dic 2017, a las 10:27, Paolo Tosco <paolo.to...@unito.it <mailto:paolo.to...@unito.it>> escribió:

Hi Marina,

I assume you are using this SDF file:

http://zinc11.docking.org/fget.pl?l=0&z=57393683&f=d

which contains 3D coordinates and no wedge bond information. If this is the case, you will need to call MolOps::assignStereochemistryFrom3D() <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#af8d126c8da82e0ee29d586e615f26e8e> to assign the chiral tags before accessing them.

If you are also interested in E/Z double bond stereochemistry you will need the following three calls before accessing stereochemistry descriptors:

MolOps:: <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#af8d126c8da82e0ee29d586e615f26e8e>detectBondStereochemistry <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#a992d63a45590b287f310a88228659991> (*mol) MolOps:: <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#af8d126c8da82e0ee29d586e615f26e8e>assignStereochemistryFrom3D <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#af8d126c8da82e0ee29d586e615f26e8e> (*mol) MolOps:: <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#af8d126c8da82e0ee29d586e615f26e8e>assignStereochemistry <http://www.rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#abae38bdd181c070deee55a4d3ee12885> (*mol);

Hope that helps, cheers
p.

On 12/12/17 18:18, Marina Garcia de Lomana wrote:

Hi,
I am using the following C++ script to read a molecule from a SD file (with defined stereochemistry), but the information about the stereochemistry gets lost. The file I am using is from glucose (ZINC03833800; http://zinc.docking.org/substance/3833800) When I check the chiral information of the atoms, all of them have the chiral tag 0.

How can I keep the stereo information?

SCRIPT:

|std::fstream infilestr; infilestr.open(in_file_name.c_str( )); RDKit::SDMolSupplier mol_supplier( in_file_name , true ); for (unsigned i = 0; i < mol_supplier.length(); ++i) { RDKit::ROMOL_SPTR mol(mol_supplier[i]); if (!mol){ std::cout << "Error, molecule not found!" << std::endl; continue; } for (unsigned int j = 0; j < mol->getNumAtoms(); j++){ RDKit::Atom* atom = mol->getAtomWithIdx(j); std::cout << "Chirality atom " << j+1 << ": " << atom->getChiralTag() << std::endl; } std::string usmiles = RDKit::MolToSmiles (*mol); std::cout << "Mol: " << usmiles << std::endl; } |


OUTPUT FOR GLUCOSE (ZINC03833800):

Chirality atom 1: 0
Chirality atom 2: 0
Chirality atom 3: 0
Chirality atom 4: 0
Chirality atom 5: 0
Chirality atom 6: 0
Chirality atom 7: 0
Chirality atom 8: 0
Chirality atom 9: 0
Chirality atom 10: 0
Chirality atom 11: 0
Chirality atom 12: 0
Mol: OCC1OC(O)C(O)C(O)C1O



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


_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to