Dear all,
        I'm tryting to delete a ring atom with the following script:
--------------------Start of the Script-------------------------
#!/usr/bin/env python
import pybel
import openbabel as ob
obconversion = ob.OBConversion()
obconversion.SetInAndOutFormats('smi','can')
def main():
        m=pybel.readstring('smi',"c1ccccc1O RingMol")
        print obconversion.WriteString(m.OBMol)
        for i in m.atoms:
                print i,i.OBAtom.IsInRing()
        print

        m.OBMol.BeginModify()
        atom_d=m.atoms[2].OBAtom ##randomly pick an atom of ring to delete
        m.OBMol.DeleteAtom(atom_d)
        m.OBMol.SetTitle('NoRingMol')
        m.OBMol.EndModify()

        print obconversion.WriteString(m.OBMol)
        for i in m.atoms:
                print i,i.OBAtom.IsInRing()

if __name__ == '__main__':
        main()
---------------------End of the Script-------------------------------

        It gives the following output:
>>> 
Oc1ccccc1       RingMol

Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 8 (0.00 0.00 0.00) False

C/C=C(/O)\C=C   NoRingMol

Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 6 (0.00 0.00 0.00) True
Atom: 8 (0.00 0.00 0.00) False

        From the output SMILES, we can find the final molecule "C/C=C(/O)\C=C   
NoRingMol" 
contains no ring after we remove a ring atom of the initial molecule. That is 
what I'm expecting.
However, when I retrieved the atom information of the final molecule, I found 
that all carbon atoms 
are still ring atoms. I guess there might be some flags should be updated when 
a molecule is 
modified. An easy but expensive solution is to parse the output SMILES again to 
get the correct 
ring information of each atom, but I wonder if there is a better way to do 
that. 
Thanks in advance!
                                        
2010-12-16
------------------------------------------------
Mingyue Zheng, Ph.D.
Drug Discovery and Design Center (DDDC)
Box 1201, Shanghai Institute of Materia Medica.
No. 555 Rd. Zuchongzhi, Shanghai, China
Tel:   86-021-50806600-1308
Email: [email protected]

------------------------------------------------


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to