Sorry about that, didn't pay attention..

With this:
import openbabel
ring3 = openbabel.OBMol()
ra1=ring3.NewAtom()
ra2=ring3.NewAtom()
ra3=ring3.NewAtom()
ra1.SetAtomicNum(6)
ra2.SetAtomicNum(6)
ra3.SetAtomicNum(6)
ring3.AddBond(1, 2, 1)
ring3.AddBond(2, 3, 1)
ring3.AddBond(3, 1, 1)
print len(ring3.GetSSSR())
builder = openbabel.OBOp.FindType("Gen3D")
builder.Do(ring3)
print len(ring3.GetSSSR())
ra1.SetVector(1,0,0)
ra2.SetVector(0,-1,0)
ra3.SetVector(0,1,0)

I now get the proper behavior of GetSSSR(), but I still get a segfault when I 
try to move the atoms. I assume this is because the pointers are not valid 
anymore. Why is this?

Also, why would it work when I add a bond as you described and not work when I 
did it the way I was doing it? Does AddBond make some connections that I 
wasn't doing?

Thanks, I think with this I can get my code to work!
Jason

On Thursday 11 March 2010 09:52:27 am Noel O'Boyle wrote:
> (Please cc to list)
> 
> How about commenting about:
> 
> ##rb1=ring3.NewBond()
> ##rb2=ring3.NewBond()
> ##rb3=ring3.NewBond()
> ##rb1.SetBegin(ra1)
> ##rb1.SetEnd(ra2)
> ##rb2.SetBegin(ra2)
> ##rb2.SetEnd(ra3)
> ##rb3.SetBegin(ra3)
> ##rb3.SetEnd(ra1)
> ##rb1.SetBO(1)
> ##rb2.SetBO(1)
> ##rb3.SetBO(1)
> 
> and replacing it with:
> 
> ring3.AddBond(1, 2, 1)
> ring3.AddBond(2, 3, 1)
> ring3.AddBond(3, 1, 1)
> 
> - Noel
> 
> On 11 March 2010 14:28, Jason Power <[email protected]> wrote:
> > Here is something that causes a segfault every time:
> >
> > import openbabel
> > ring3 = openbabel.OBMol()
> > ra1=ring3.NewAtom()
> > ra2=ring3.NewAtom()
> > ra3=ring3.NewAtom()
> > ra1.SetAtomicNum(6)
> > ra2.SetAtomicNum(6)
> > ra3.SetAtomicNum(6)
> > rb1=ring3.NewBond()
> > rb2=ring3.NewBond()
> > rb3=ring3.NewBond()
> > rb1.SetBegin(ra1)
> > rb1.SetEnd(ra2)
> > rb2.SetBegin(ra2)
> > rb2.SetEnd(ra3)
> > rb3.SetBegin(ra3)
> > rb3.SetEnd(ra1)
> > rb1.SetBO(1)
> > rb2.SetBO(1)
> > rb3.SetBO(1)
> > print len(ring3.GetSSSR())    # OUTPUT: 0
> > builder = openbabel.OBOp.FindType("Gen3D")
> > builder.Do(ring3)
> > print len(ring3.GetSSSR())   # OUTPUT: 1
> > ra1.SetVector(1,0,0)
> > ra2.SetVector(0,-1,0)
> > ra3.SetVector(0,1,0)
> >
> > Sometimes is segfaults on ra2.SetVector(0,-1,0) and sometimes on
> > ra3.SetVector(0,1,0). Also, I don't understand why the first call the
> > GetSSSR() doesn't return the right number.
> >
> > Thanks again!
> > Jason
> >
> > On Thursday 11 March 2010 04:48:45 am you wrote:
> >> Where do beginAtom and endAtom come from in your code snippet.
> >>
> >> The best thing would be if you can you create a simple and short
> >> self-contained script that exhibits the problem.
> >>
> >> - Noel
> >>
> >> On 11 March 2010 03:59, Jason Power <[email protected]> wrote:
> >> > Hi all,
> >> >
> >> > I am currently developing a pure-python 2-D molecule editor for use
> >> > within another project I am currently working on. To begin with I
> >> > decided to use the OBMol object as a model, thinking it would save me
> >> > time and effort. However, I have run into a variety of issues that I'm
> >> > not sure are due to my own misunderstandings, limitations of the
> >> > python bindings, or bugs.
> >> >
> >> > I am building the OBMol object slowly over time as the user adds atoms
> >> > and bonds. So I have a numerous places where I basically call
> >> >
> >> > self.mol.BeginModify()
> >> > bond = self.mol.NewBond()
> >> > bond.SetBegin(beginAtom)
> >> > bond.SetEnd(endAtom)
> >> > self.mol.EndModify()
> >> >
> >> > and
> >> >
> >> > self.mol.BeginModify()
> >> > newAtom = self.mol.NewAtom()
> >> > newAtom.SetVector(self.translateToAtomCoords(pos))
> >> > newAtom.SetAtomicNum(atomicNum)
> >> > self.mol.EndModify()
> >> >
> >> > and similar to delete. I find that with these calls when I go on to do
> >> > other interesting things it fails, often as a segfault. Also, if I try
> >> > to make a call like self.mol.GetSSSR() even though there is a ring, (I
> >> > can trace the indices of the ends of the bonds myself), it returns a
> >> > zero length list.
> >> >
> >> > I have found that if I call self.builder.Do(self.mol) before I run
> >> > GetSSSR() it will return the right numbers, but I do not want to build
> >> > the full 3-D coords, and worse, self.builder.Do(self.mol) randomly
> >> > segfaults.
> >> >
> >> > Am I doing something wrong? Is there something that I am missing while
> >> > building the molecule?
> >> >
> >> > Thanks for you help!
> >> > Jason
> >> >
> >> >
> >> > ----------------------------------------------------------------------
> >> >--- ----- Download Intel&#174; 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-scripting mailing list
> >> > [email protected]
> >> > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
> 

------------------------------------------------------------------------------
Download Intel&#174; 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-scripting mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-scripting

Reply via email to