Bug: mad interference between matplotlib and openbabel

Hi folks!

I' m working on a code to identify ligand's information from pdb crystal
structures. For this purpose I use the openbabel package. I' m encoding
the ligand's information in smarts.
For checking if the smarts are assigned correctly I 'm writing a sdf
file (to control whether the features are placed correctly).

This part works fine - but I get into deep trouble when I try to plot
simple count statistics of my smarts, when I use the "from pylab
import*" , or "from pylab import matplotlib" statements (trouble appears
just after IMPORTING - I do not use a pylab function in this state of
the program yet):

Smart features are not recognized anymore, the feature coordinates are
shifted and so on - But I don' t know why.

my code snip:

import os
from numpy import*
from time import*

#### SMARTING
import numpy

import openbabel
from openbabel import*
import pybel
from pybel import*

#### LIGAND DETECTION
import Bio.PDB
from Bio.PDB import*
import Numeric
from Bio.PDB.StructureBuilder import *

#from pylab import* --> RAISES THE PROBLEMS !!!!

def projecting_smarts(isolated_ligand, method ,color, output):
   
#### Bio PDB -> 2 get ligand coords
    parser =PDBParser()
   
    structure = parser.get_structure('s', isolated_ligand)
    atom = structure.get_atoms()

···

###

    print "smarting successfully started!"
   
    mol = readfile("pdb", isolated_ligand).next()

    smart_list = []
   
    result_acceptor = method.findall(mol) #finds acceptors
   
    for i in result_acceptor: #Result
Donor= list from tuples
        list_element1 = (list(i)[0]) # ->
resolve hierarchy
        smart_list.append(list_element1)
   
    print smart_list,"ACCEPTOR_LIST" #list of smart features

Maybe one of you might know what to do!

Thanx alot!

flo

Hi Florian,
   you should try "import pylab" or "import pylab as P". "from pylab import *" might overwrite some functions or methods ... if a pylab function/method has the same name as one in a module imported with * before.

See the following example:

#file a.py
def foo():
     print "I'm a"

# file b.py
def foo():
     print "I'm b"

# file import_ab.py
from a import *
foo()
from b import *
foo()

The output is:
I'm a
I'm b

as the function foo() is overwritten by the second import...

Manuel

Florian Koelling wrote:

···

Hi folks!

I' m working on a code to identify ligand's information from pdb crystal
structures. For this purpose I use the openbabel package. I' m encoding
the ligand's information in smarts.
For checking if the smarts are assigned correctly I 'm writing a sdf
file (to control whether the features are placed correctly).

This part works fine - but I get into deep trouble when I try to plot
simple count statistics of my smarts, when I use the "from pylab
import*" , or "from pylab import matplotlib" statements (trouble appears
just after IMPORTING - I do not use a pylab function in this state of
the program yet):
Smart features are not recognized anymore, the feature coordinates are shifted and so on - But I don' t know why.

my code snip:

import os
from numpy import*
from time import*

#### SMARTING
import numpy

import openbabel
from openbabel import*
import pybel
from pybel import*

#### LIGAND DETECTION
import Bio.PDB
from Bio.PDB import*
import Numeric
from Bio.PDB.StructureBuilder import *

#from pylab import* --> RAISES THE PROBLEMS !!!!

def projecting_smarts(isolated_ligand, method ,color, output):
   
    parser =PDBParser()
       structure = parser.get_structure('s', isolated_ligand)
    atom = structure.get_atoms() ###

    print "smarting successfully started!"
       mol = readfile("pdb", isolated_ligand).next()

       smart_list =
       result_acceptor = method.findall(mol) #finds acceptors
   
Donor= list from tuples
        list_element1 = (list(i)[0]) # -> resolve hierarchy smart_list.append(list_element1)
       print smart_list,"ACCEPTOR_LIST" #list of smart features

Maybe one of you might know what to do!

Thanx alot!

flo

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options