On 18/09/2007, Matic Cankar <matic.cankar@...> wrote:
> Thank you Noel for the answer.
> I'll need information about the atoms and the bonds with which are they
> connected to the "processed" atom. That's the reason why I chose that way of
> programming.
Ah, OK. So you want information on the bonds.
> So if I understand you clear is better way that I use "
> openbabel.OBAtomAtomIter" to get the atoms and then I get the bonds with
> GetBond(OBAtom) like:
Yes, this seems like the best way if you're interested in both the
atoms and the bonds attached to a particular atom. However, if you're
just interested in the bond orders of the bonds attached, you would
just use openbabel.OBAtomBondIter(obatom) to iterate over the bonds
attached to a particular atom.
> #######
> import openbabel as ob
> import pybel
>
> mol = pybel.readstring("smi", "COCC")
> mol.OBMol.AddHydrogens()
>
> obatom = mol.atoms[0].OBAtom
> for neighbour_atom in ob.OBAtomAtomIter(obatom):
> print neighbour_atom.GetAtomicNum()
> bond = obatom.GetBond(neighbour_atom)
> print bond.GetBondOrder ()
>
> ######
> Matic
>
>
>
> On 9/18/07, Noel O'Boyle <baoilleach@...> wrote:
> > You can use openbabel.OBAtomAtomIter to iterate over the OBAtoms
> > attached to an OBAtom. (I really should improve the documentation) You
> > should familiarise yourself with all of the "Iter" methods in the OB
> > API, as they are very useful for this type of problem:
> >
> > import openbabel as ob
> > import pybel
> >
> > mol = pybel.readstring("smi", "COCC")
> > mol.OBMol.AddHydrogens()
> >
> > obatom = mol.atoms[0].OBAtom
> > for neighbour_atom in ob.OBAtomAtomIter(obatom):
> > print neighbour_atom.GetAtomicNum()
> >
> > Result is: 8 1 1 1
> >
> > (If you don't add hydrogens, you just get 8)
> >
> > Noel
> >
> > On 18/09/2007, Matic Cankar <matic.cankar@...> wrote:
> > > Hello,
> > >
> > > I have a question about bonds of the atom in the molecule. I would like
> to
> > > get all atoms, that are connected to one specific atom.
> > >
> > > I solved my problem this way (code is just symbolic, not actual code):
> > > -> I make the bond iterator for the specific atom
> > >
> > > bonds = coreAtom.BeginBonds()
> > > bond = coreAtom.BeginBond(bonds)
> > >
> > > -> and for each bond I use method "GetEndAtom()"
> > > bond.GetEndAtom()
> > >
> > > but I for the end atom from the first bond I get the specific atom that
> I
> > > choose first (I get the atom that I'm processing not the end atom). When
> I
> > > repaired the code so that I used "GetBeginAtom()" for the first bond
> and,
> > > the "GetEndAtom()" for all others, I get the correct answer.
> > >
> > > The molecule is kind of graph and bonds are kind of edges. Are bonds
> > > directed edges, and why so?
> > > Will my corrected code worked in all conditions? Is first bond always
> > > directed to the specified (processing atom in my code) atom and others
> away
> > > of the specified atom?
> > >
> > > thank you for your answer!
> > >
> > > Matic
> > >
> > >
> > >
> > >
> > >
> -------------------------------------------------------------------------
> > > This SF.net email is sponsored by: Microsoft
> > > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > _______________________________________________
> > > OpenBabel-scripting mailing list
> > > OpenBabel-scripting@...
> > >
> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
> > >
> > >
> >
>
>
|