Thank you both,

@Geoff: I could draw the molecule and use a Jupyter notebook
I think I could get the right bond with
$ m1.AddBond(1,13,1)
But instead of getting 'C1=CC=CC=C1C' I get 'c1(ccccc1)C'. Are these equivalent?
Actually this is an easy case and I know that the atom to be bound is the 
central C in the methane, but in reality I have many different molecules to 
bind, and I would like to iterate over all atoms in the molecule which do not 
belong to the ring (as below).

@Noel
What argument should I pass to DeleteAtom()?
I am stuck on a NotImplementedError: Wrong number or type of arguments for 
overloaded function 'OBMol_DeleteAtom'.

Specifically,

$ import pybel as pb
$ import openbabel as ob
$ benz_pyb = next(pb.readfile('xyz', 'benzene.xyz'))   #pybel object
$ benz_obm = benz_pyb.OBMol                                     #openbabel 
object

$ print(benz_pyb.atoms)
>> [<pybel.Atom object at 0x10e02a6a0>, <pybel.Atom object at 0x10e02aa58>, 
>> <pybel.Atom object at 0x10e02aa90>, <pybel.Atom object at 0x10e042b70>, 
>> <pybel.Atom object at 0x10e042c88>, <pybel.Atom object at 0x10e042cf8>, 
>> <pybel.Atom object at 0x10e042e10>, <pybel.Atom object at 0x10e042978>, 
>> <pybel.Atom object at 0x10e0429e8>, <pybel.Atom object at 0x10e042ef0>, 
>> <pybel.Atom object at 0x10e5f4c50>, <pybel.Atom object at 0x10e5f4cc0>]

$ print(benz_obm.GetAtom)
>> <bound method OBMol_GetAtom of <openbabel.OBMol; proxy of <Swig Object of 
>> type 'OpenBabel::OBMol *' at 0x106b441b0> >>

But then either
$ ob.OBMol.DeleteAtom(benz_pyb.atoms[0])
or
$ ob.OBMol.DeleteAtom(benz_obm.GetAtom)

Give me the same error

>> NotImplementedError: Wrong number or type of arguments for overloaded 
>> function 'OBMol_DeleteAtom'.
>>  Possible C/C++ prototypes are:
>>    OpenBabel::OBMol::DeleteAtom(OpenBabel::OBAtom *,bool)
>>    OpenBabel::OBMol::DeleteAtom(OpenBabel::OBAtom *)


This e-mail may contain confidential information. If you are not an addressee 
or otherwise authorised to receive this message, you should not use, copy, 
disclose or take any action based on this e-mail. If you have received this 
e-mail in error, please inform the sender promptly and delete this message and 
any attachments immediately.
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to