Modify a molecule

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

Modify a molecule

Prashanth Athri

Hello,

 

Is there a good example in the API docs which illustrates how to modify a molecule?

 

For example, if I read in a mol2 into OB and wish to delete a carbon atom, replace it with an oxygen and re-write that into a new file (that has all the carbon’s extra hydrogens deleted and in general a chemically correct molecule). Something in those lines.

 

In advance --Thanks very much for your help!

 

Rgds,

Prashanth

 
--
Prashanth Athri


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Modify a molecule

Geoffrey Hutchison

For example, if I read in a mol2 into OB and wish to delete a carbon atom, replace it with an oxygen and re-write that into a new file (that has all the carbon’s extra hydrogens deleted and in general a chemically correct molecule). Something in those lines.


I think that would be something like:

OBMol mol; // read in from mol2 somewhere
OBAtom carbonAtom; // set to particular carbon atom

mol.DeleteHydrogens(carbonAtom);
carbonAtom.SetAtomicNum(8);
mol.AddHydrogens(carbonAtom);

// then write the file

Hope that helps,
-Geoff

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss