Or, if you import openbabel you can directly do:

for bond in openbabel.OBMolBondIter(obmol):
   print bond.GetBeginAtomIdx(), bond.GetEndAtomIdx(), bond.GetBondOrder()


12 nov 2013 kl. 07:55 skrev Fredrik Wallner <fred...@wallner.nu>:

> Hi,
> 
> Since pybel doesn’t have a ”bond-concept” at the moment, I suppose it needs 
> to be defined first. But if you will settle for OBBonds, the following short 
> generator could work:
> 
> def pybelbonditer(pybmol):
>   for i in range(pybmol.OBMol.NumBonds()):
>       yield pybmol.OBMol.GetBond(i)
> 
> It’s now possible to iterate over the bonds with
> 
> for bond in pybelbonditer(pybelmolecule):
>       print bond.GetBeginAtomIdx(), bond.GetEndAtomIdx(), bond.GetBondOrder()
> 
> Kind regards,
> Fredrik
> 12 nov 2013 kl. 01:01 skrev Dimitri Maziuk <dmaz...@bmrb.wisc.edu>:
> 
>> Hi guys,
>> 
>> one for the next release wishlist: is it possible to expose bonds as an
>> iterable, similar to atoms?
>> 
>> -- 
>> Dimitri Maziuk
>> Programmer/sysadmin
>> BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
>> 
>> ------------------------------------------------------------------------------
>> November Webinars for C, C++, Fortran Developers
>> Accelerate application performance with scalable programming models. Explore
>> techniques for threading, error checking, porting, and tuning. Get the most 
>> from the latest Intel processors and coprocessors. See abstracts and register
>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________
>> OpenBabel-discuss mailing list
>> OpenBabel-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
> 
> ------------------------------------------------------------------------------
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models. Explore
> techniques for threading, error checking, porting, and tuning. Get the most 
> from the latest Intel processors and coprocessors. See abstracts and register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to