How to calcualate atom count and bond

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to calcualate atom count and bond

Pranav Thakur

Hi Team,

 

I would like to know how I can use OpenBabelGUI to calculate all the atoms count of a SMILES and number of single bond, double bond and triple bond present.

 

Please suggest.

 

Thanks.

Regards,
Pranav Thakur

 



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.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

How to calcualate atom count and bond

Pranav Thakur

Hi Team,

 

I would like to know how I can use OpenBabelGUI to calculate all the atoms count of a SMILES and number of single bond, double bond and triple bond present.

 

I want output to be something like this:

 

Number of triple bonds = 3

Number of double bonds= 2

Number of rings =1

 

Please suggest.

 

Thanks.

Regards,
Pranav Thakur

 



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.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Antwort: How to calcualate atom count and bond

ernst-georg.schmid
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

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: How to calcualate atom count and bond

Pranav Thakur
Thank you very much for your instant reply. Since I am a .NET developer, I will download the relevant .NET libraries and get this done. I hope this is very much possible in .NET as OpenBabel provides access to the Open Babel libraries for .NET languages.

Thanks.


Regards,
Pranav Thakur


-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Tuesday, April 20, 2010 3:24 PM
To: Pranav Thakur
Cc: '[hidden email]'; '[hidden email]'
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.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Antwort: RE: Antwort: How to calcualate atom count and bond

ernst-georg.schmid
I dont't know about the .NET wrappers but such basic functionality should
be there also.

Good luck

Ernst-Georg Schmid


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: How to calcualate atom count and bond

Chris Morley-3
In reply to this post by Pranav Thakur
Pranav Thakur wrote:
> I would like to know how I can use OpenBabelGUI to calculate all the
> atoms count of a SMILES and number of single bond, double bond and
> triple bond present.

> I want output to be something like this:
> Number of triple bonds = 3
> Number of double bonds= 2
> Number of rings =1

Sorry not to reply earlier.

The GUI does not provide this straight out of the box, but can be
extended as shown below, which may also be useful for more complicated
queries. For flexibility and beautiful formatting you would need to
use scripting - see, for instance, http://openbabel.org/wiki/Python.

Paste the following text into the file plugindefines.txt:

SmartsDescriptor
sbonds
*-*
Number of single bonds

SmartsDescriptor
dbonds
*=*
Number of double bonds

#SmartsDescriptor
#tbonds
#*#*
#Number of triple bonds

SmartsDescriptor
abonds
*:*
Number of aromatic bonds

SmartsDescriptor
bonds
*~*
Number of bonds\n
Add or remove hydrogens to count total or bonds between heavy atoms

SmartsDescriptor
atoms
*
Number of atoms\n
Add or remove hydrogens to count total or heavy atoms


When the GUI is restarted the descriptors sbond, dbonds, etc. will be
available (see them listed in the menu item Plugins).

In the option "Appends properties or descriptors in list to title"
enter, for instance:

sbonds dbonds

On doing a SMILES to SMILES conversion with "Add hydrogens(make
explicit)" checked the numbers of bonds will appear after the title, e.g.

CC=C propene 7 1

Additionally, entering _Number single,double bonds=  into the "Append
to title" box gives
CC=C propene_Number single,double bonds= 7 1

There is a bug which prevents triple bonds being counted, so the
descriptor for it is commented out above. (Which also illustrates what
the bug is!) The development code is corrected.




------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: How to calcualate atom count and bond

Pranav Thakur
In reply to this post by ernst-georg.schmid
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: [hidden email] [mailto:[hidden email]]
Sent: Tuesday, April 20, 2010 3:24 PM
To: Pranav Thakur
Cc: '[hidden email]'; '[hidden email]'
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: How to calcualate atom count and bond

Geoffrey Hutchison
> 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:

...
>>     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.

There's your answer about counting double or triple bonds.

> Take a look at
> http://openbabel.org/api/2.2.0/classOpenBabel_1_1OBMol.shtml and the
> examples at the bottom.

Ernst-Georg gave you this link too, which gives you a whole range of methods like counting the number of rings.

Please read the documentation.

Best regards,
-Geoff
------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: How to calcualate atom count and bond

arianapham
In reply to this post by Pranav Thakur
I'm happy I found this blog. Thank you for sharing with us, I too always learn something new from your post play learn to fly