Hi Team, I have done some coding on the basis of your suggestion. My present code gives me the Molecular Weight and Number of bonds present in SMILES. Now I want to know other vital information like how many rings, double bonds and triple bonds are present in SMILES. My code is as:
OBConversion obconv = new OBConversion(); obconv.SetInFormat("smi"); OBMol mol = new OBMol(); obconv.ReadString(mol, "Oc1ccc(Cl)c(C)c1"); System.Console.WriteLine(mol.GetMolWt()); System.Console.WriteLine(mol.NumBonds()); System.Console.ReadKey(); Please let me know how to code further to get other information as mentioned above. Thanks! Regards, Pranav Thakur -----Original Message----- From: ernst-georg.sch...@bayerbbs.com [mailto:ernst-georg.sch...@bayerbbs.com] Sent: Tuesday, April 20, 2010 3:24 PM To: Pranav Thakur Cc: 'openbabel-discuss@lists.sourceforge.net'; 'openbabel-discuss-ow...@lists.sourceforge.net' Subject: Antwort: [Open Babel] How to calcualate atom count and bond unsigned int ob_num_atoms (char *smiles) { OBMol mol; OBConversion conv; string tmpStr (smiles); istringstream molstream (tmpStr); unsigned int numatoms = 0; conv.SetInAndOutFormats ("SMI", "SMI"); conv.Read (&mol, &molstream); numatoms = mol.NumAtoms (); return (numatoms); } is the basic skeleton to read a SMILES into an OBMol and get the atom count. FOR_BONDS_OF_MOL(bond, mol) // iterator access (see OBMolBondIter) will give you an iterator over the bonds OBBond->GetBO gives you the order. Then you can increment your counts per bond order. Take a look at http://openbabel.org/api/2.2.0/classOpenBabel_1_1OBMol.shtml and the examples at the bottom. regards, Ernst-Georg The information in this e-mail is the property of Evalueserve and is confidential and privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and will be unlawful. If you receive this message in error, please notify the sender immediately and delete all copies of this message. ------------------------------------------------------------------------------ _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss