{"id":545,"date":"2013-07-01T13:24:15","date_gmt":"2013-07-01T12:24:15","guid":{"rendered":"http:\/\/nextmovesoftware.com\/blog\/?p=545"},"modified":"2013-07-01T13:24:15","modified_gmt":"2013-07-01T12:24:15","slug":"accessing-smiles-atom-order","status":"publish","type":"post","link":"https:\/\/nextmovesoftware.com\/blog\/2013\/07\/01\/accessing-smiles-atom-order\/","title":{"rendered":"Accessing SMILES atom order"},"content":{"rendered":"<p>In the course of my work, I sometimes have to search the dustier corners of cheminformatics toolkits to find features which are seldom used and may be undocumented. One example of this is how to relate the atoms of a toolkit molecule to their order in an output SMILES string. The various toolkits that I use allow one to do this, but the exact method is somewhat different in each case.<\/p>\n<p>Open Babel stores it in a property of a molecule which you can access after writing a SMILES string. The value returned is a string containing the atom indices separated by spaces. This must be parsed before it can be used as a lookup:<\/p>\n<pre>OBPairData *pd = (OBPairData*) mol-&gt;GetData(\"SMILES Atom Order\");\r\nstd::string atomOrder = pd->GetValue();<\/pre>\n<p>RDKit also does something similar but it returns the desired vector of atom indices directly:<\/p>\n<pre>std::vector&lt;unsigned int&gt; *atomOrder;\r\nmol-&gt;getProp(\"_smilesAtomOutputOrder\", *atomOrder);<\/pre>\n<p>In contrast, OEChem fills the atom order information into a data structure that you (optionally) provide when calling the function to create a SMILES string. To get the atom order as indices you need to remember the atom order of the current atoms, and then iterate over the data structure accessing the second item of the pair, and looking up the corresponding index.<\/p>\n<pre>\r\nsize_t count = mol-&gt;GetMaxAtomIdx();\r\nstd::pair&lt;const OEChem::OEAtomBase*,const OEChem::OEAtomBase*&gt; *atmord =\r\n      (std::pair&lt;const OEChem::OEAtomBase*,const OEChem::OEAtomBase*&gt;*)\r\n      malloc(count*sizeof(std::pair&lt;const OEChem::OEAtomBase*,OEChem::OEAtomBase*&gt;));\r\nOEChem::OECreateSmiString(smiles, *mol, OEChem::OESMILESFlag::AtomStereo ^ OEChem::OESMILESFlag::BondStereo, atmord);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the course of my work, I sometimes have to search the dustier corners of cheminformatics toolkits to find features which are seldom used and may be undocumented. One example of this is how to relate the atoms of a toolkit molecule to their order in an output SMILES string. The various toolkits that I &hellip; <a href=\"https:\/\/nextmovesoftware.com\/blog\/2013\/07\/01\/accessing-smiles-atom-order\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Accessing SMILES atom order<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/545"}],"collection":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=545"}],"version-history":[{"count":9,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"predecessor-version":[{"id":554,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions\/554"}],"wp:attachment":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}