Example #1
0
    def OnInit(self):
        from frowns import MDL
        reader = MDL.mdlin(open("../test/data/bad.sdf"))

        mol = reader.next()
        wxInitAllImageHandlers()
        frame = wxFrame(None, -1, "", size=(350, 200))

        drawer = self.drawer = wxMoleculeDrawer(frame, drawAromatic=1)
        drawer.setMolecule(mol)
        frame.Show(TRUE)
        return TRUE
Example #2
0
    def OnInit(self):
        from frowns import MDL
        from StringIO import StringIO
        reader = MDL.sdin(StringIO(test))

        mol, error, text = reader.next()
        wxInitAllImageHandlers()
        frame = wxFrame(None, -1, "", size=(350, 200))

        drawer = self.drawer = MoleculeDrawer(frame, drawAromatic=0)
        drawer.setMolecule(mol)
        frame.Show(TRUE)
        return TRUE
    def OnInit(self):
        from frowns import MDL
        reader = MDL.mdlin(open("../test/data/bad.sdf"))
        
        mol = reader.next()
        wxInitAllImageHandlers()
        frame = wxFrame(None, -1, "", size=(350,200))

        
        drawer = self.drawer = wxMoleculeDrawer(frame, drawAromatic=1)
        drawer.setMolecule(mol)
        frame.Show(TRUE)
        return TRUE
Example #4
0
    def OnInit(self):
        from frowns import MDL
        reader = MDL.sdin(open("data\chiral3.sdf"))
        
        mol, error, text = reader.next()

        wxInitAllImageHandlers()
        frame = wxFrame(None, -1, "", size=(350,200))

        
        drawer = self.drawer = MoleculeDrawer(frame, drawAromatic=1)
        drawer.setMolecule(mol)
        frame.Show(TRUE)
        return TRUE
Example #5
0
    def map(self, workingPath, verbose=False):
        if verbose:
            sys.stderr.write("Brique.map: Will load %s ... wp %s\n" %
                             (self.cansmiles(), workingPath))
        file = self.load(workingPath, verbose=verbose)
        if verbose:
            sys.stderr.write("Brique.map: %s Loaded ...\n" % workingPath)
        if not file:
            if verbose:
                sys.stderr.write("Brique.map: ring not found ...\n")
            # Here we should use AMMOS to generate ring conformation
            raise CycleUnknown, "cycle " + self.cansmiles(
            ) + " is not present in the ring library"
        # sys.stderr.write("Brique.map: will read %s ...\n" % file)
        f = open(file)
        reader = MDL.sdin(f)
        # m = reader.next()[0]
        m, err, txt = reader.next()

        # sys.stderr.write("Brique.map: MDL reader got %s\n" % err)
        f.close()
        # sys.stderr.write("Brique.map: read as SDF ...\n")
        Disambiguate.FreedDisambiguate(m)
        atomsSDF = m.atoms[:]
        atomsSDF.sort(key=lambda x: x.symorder)
        # sys.stderr.write("Brique.map: ordered by symorder ...\n")
        try:
            Disambiguate.FreedDisambiguate(self.molecule)
            atomsBrick = self.molecule.atoms[:]
            atomsBrick.sort(key=lambda x: x.symorder)
            # sys.stderr.write("Brique.map: Loaded %d atoms ...\n" % len(atomsSDF))
            for i in range(len(atomsBrick)):
                for oatB in atomsBrick[i].oatoms:
                    if oatB.symorder not in [
                            oatS.symorder for oatS in atomsSDF[i].oatoms
                    ]:
                        for j in range(i):
                            atomsBrick[j].x = None
                            atomsBrick[j].y = None
                            atomsBrick[j].z = None
                            self.map2(workingPath)
                            return
                atomsBrick[i].x = atomsSDF[i].x
                atomsBrick[i].y = atomsSDF[i].y
                atomsBrick[i].z = atomsSDF[i].z
        except:
            # sys.stderr.write("Brique.map: Something went wrong. Attempting map2\n")
            self.map2(workingPath)
            return
Example #6
0
 def map(self, workingPath, verbose = False):
     if verbose:
         sys.stderr.write("Brique.map: Will load %s ... wp %s\n" % (self.cansmiles(), workingPath))
     file = self.load(workingPath, verbose = verbose)
     if verbose:
         sys.stderr.write("Brique.map: %s Loaded ...\n" % workingPath)
     if not file :
         if verbose:
             sys.stderr.write("Brique.map: ring not found ...\n")
         # Here we should use AMMOS to generate ring conformation
         raise CycleUnknown, "cycle " + self.cansmiles() + " is not present in the ring library"
     # sys.stderr.write("Brique.map: will read %s ...\n" % file)
     f = open(file)
     reader = MDL.sdin(f)
     # m = reader.next()[0]
     m, err, txt = reader.next()
     
     # sys.stderr.write("Brique.map: MDL reader got %s\n" % err)
     f.close()
     # sys.stderr.write("Brique.map: read as SDF ...\n")
     Disambiguate.FreedDisambiguate(m)
     atomsSDF = m.atoms[:]
     atomsSDF.sort(key = lambda x: x.symorder)
     # sys.stderr.write("Brique.map: ordered by symorder ...\n")
     try:
         Disambiguate.FreedDisambiguate(self.molecule)
         atomsBrick = self.molecule.atoms[:]
         atomsBrick.sort(key = lambda x: x.symorder)
         # sys.stderr.write("Brique.map: Loaded %d atoms ...\n" % len(atomsSDF))
         for i in range(len(atomsBrick)):
             for oatB in atomsBrick[i].oatoms:
                 if oatB.symorder not in [oatS.symorder for oatS in atomsSDF[i].oatoms]:
                     for j in range(i):
                         atomsBrick[j].x = None
                         atomsBrick[j].y = None
                         atomsBrick[j].z = None
                         self.map2(workingPath)
                         return			
             atomsBrick[i].x = atomsSDF[i].x
             atomsBrick[i].y = atomsSDF[i].y
             atomsBrick[i].z = atomsSDF[i].z
     except:
         # sys.stderr.write("Brique.map: Something went wrong. Attempting map2\n")
         self.map2(workingPath)
         return
Example #7
0
def readSDF(file) :
    """
    idem ci-dessus pr fichier SDF
    """
    f = open(file)
    reader = MDL.sdin(f)
    mo = []
    try :
        m = reader.next()[0]
        while m :
            if m.fields.keys():
                for key in m.fields.keys():
                    if "ID" in key :
                        mo.append(iMolecule(sd=m,id=m.fields[key]))
                        break
            else :
                mo.append(iMolecule(sd=m,id=m.name))
            m = reader.next()[0]
            
    except :
        f.close()
        return mo
Example #8
0
def readSDF(file):
    """
    idem ci-dessus pr fichier SDF
    """
    f = open(file)
    reader = MDL.sdin(f)
    mo = []
    try:
        m = reader.next()[0]
        while m:
            if m.fields.keys():
                for key in m.fields.keys():
                    if "ID" in key:
                        mo.append(iMolecule(sd=m, id=m.fields[key]))
                        break
            else:
                mo.append(iMolecule(sd=m, id=m.name))
            m = reader.next()[0]

    except:
        f.close()
        return mo
Example #9
0
    def map2(self, workingPath):
        """
        #correspondance entre atomes de la brique et du fichier sdf
        """
        file = self.load(workingPath)
        if not file:
            raise CycleUnknown, self.cansmiles()
        f = open(file)
        reader = MDL.sdin(f)
        m = reader.next()[0]
        # mx = reader.next() # ou while reader.next()
        # m = mx[0]
        f.close()

        # output :

        i = j = tentativeRate = 0
        cyclesChecked = []
        cyclesMapped = []
        #print "nb cycles", len(self.molecule.cycles)
        while tentativeRate < len(
                self.molecule.cycles
        ):  # boucle tant que le nb de tentative rate de mapping n'est pas egale au nb de cycle ds la molecule
            #print j,i,len(self.molecule.cycles[j]),len(m.cycles[i])
            if len(self.molecule.cycles[j]) == len(
                    m.cycles[i]
            ):  # si les 2 cycles ont le meme nb d'atomes, on peut essayer de les mapper
                if mapCycles(self.molecule.cycles[j], m.cycles[i]):
                    #print "mapCycles(self.molecule.cycles[j],m.cycles[i])"
                    cyclesChecked.append(i)
                    cyclesMapped.append(j)
                    j += 1
                    tentativeRate = 0
                    break
                else:
                    tentativeRate += 1
            else:
                tentativeRate += 1
            i += 1

        while len(cyclesMapped) < len(
                self.molecule.cycles) and tentativeRate < len(
                    self.molecule.cycles) - len(cyclesChecked):
            if i in cyclesChecked:
                i += 1
                continue
            if i == len(m.cycles):
                i = 0
                continue
            if j in cyclesMapped:
                j += 1
                continue
            if j == len(self.molecule.cycles):
                j = 0
                continue
            coord = 0
            for atom in self.molecule.cycles[j].atoms:
                if atom.x != None:
                    coord = 1
                    break
            if not coord:
                j += 1
                continue

            if len(self.molecule.cycles[j]) == len(m.cycles[i]):
                if mapCycles2(self.molecule.cycles[j], m.cycles[i]):
                    cyclesChecked.append(i)
                    cyclesMapped.append(j)
                    j += 1
                    tentativeRate = 0
                else:
                    tentativeRate += 1
            else:
                tentativeRate += 1
            i += 1

        return tentativeRate == 0
Example #10
0
    def map2(self, workingPath) :
        """
        #correspondance entre atomes de la brique et du fichier sdf
        """
        file = self.load(workingPath)
        if not file :
            raise CycleUnknown, self.cansmiles()
        f = open(file)
        reader = MDL.sdin(f)
        m = reader.next()[0]
		# mx = reader.next() # ou while reader.next()
		# m = mx[0]
        f.close()

		# output : 
        
        i = j = tentativeRate = 0
        cyclesChecked = []
        cyclesMapped = []
        #print "nb cycles", len(self.molecule.cycles)
        while tentativeRate < len(self.molecule.cycles): # boucle tant que le nb de tentative rate de mapping n'est pas egale au nb de cycle ds la molecule
            #print j,i,len(self.molecule.cycles[j]),len(m.cycles[i])
            if len(self.molecule.cycles[j]) == len(m.cycles[i]) : # si les 2 cycles ont le meme nb d'atomes, on peut essayer de les mapper
                if mapCycles(self.molecule.cycles[j],m.cycles[i]) :
                    #print "mapCycles(self.molecule.cycles[j],m.cycles[i])"
                    cyclesChecked.append(i)
                    cyclesMapped.append(j)
                    j += 1
                    tentativeRate = 0
                    break
                else :
                    tentativeRate += 1
            else :
                tentativeRate += 1
            i += 1


        while len(cyclesMapped) < len(self.molecule.cycles) and tentativeRate < len(self.molecule.cycles)-len(cyclesChecked) :
            if i in cyclesChecked :
                i += 1
                continue
            if i == len(m.cycles) :
                i = 0
                continue
            if j in cyclesMapped :
                j += 1
                continue
            if j == len(self.molecule.cycles) :
                j = 0
                continue
            coord = 0
            for atom in self.molecule.cycles[j].atoms :
                if atom.x != None :
                    coord = 1
                    break
            if not coord :
                j += 1
                continue

            if len(self.molecule.cycles[j]) == len(m.cycles[i]) :
                if mapCycles2(self.molecule.cycles[j],m.cycles[i]) :
                    cyclesChecked.append(i)
                    cyclesMapped.append(j)
                    j += 1
                    tentativeRate = 0
                else :
                    tentativeRate += 1
            else :
                tentativeRate += 1
            i += 1
        
        return tentativeRate == 0
Example #11
0
from frowns import MDL
from frowns.Depict.MoleculeDrawer import *
file = open("data\\bad.sdf")

reader = MDL.mdlin(file, stripHydrogens=0)
mol = reader.next()

from Tkinter import *
root = Tk()
d = DrawMolHarness(root, mol, "bad")
d.pack(expand=1, fill=BOTH)

mainloop()
Example #12
0
        
        d = MoleculeDrawer(self._int,
                           mol,
                           name)
        self.c += 1
        if self.c >= self.cols:
            self.c = 0
            self.r += 1
            self._int.grid_rowconfigure(self.r, weight=1)

        d.grid(row=self.r, column=self.c, sticky="NEWS")


if __name__ == "__main__":
    from frowns import MDL
    reader = MDL.mdlin(open("../test/data/bad.sdf"))
    mol = reader.next()
    tk = top = Tk()

    m = MoleculeDock(top)
    m.pack(fill=BOTH, expand=1)
    m.addMolecule(mol)
    m.addMolecule(mol)
    m.addMolecule(mol)
    m.addMolecule(mol)

    mainloop()

        
Example #13
0
    def load(self, workingPath, verbose = False) :
        """
        charger le fichier sdf de la brique
        """
        if verbose:
            sys.stderr.write("Brique.load: %s\n" % LIBRARY_PATH)
        if not LIBRARY_PATH :
            sys.stderr.wirte( "variable path de la classe Brique non initialisee\n")
            return 0
        try:
            listFile = os.listdir(LIBRARY_PATH) # liste des fichier contenu ds 'PAHT' -> listFile
        except:
            sys.stderr.write("Brique.load: Failed to access ring library at %s\n" % LIBRARY_PATH)
        # sys.exit(0)
        name = self.cansmiles()

        if verbose:
            sys.stderr.write("Brique.load: Attempting %s ...\n" % str(name))
            # print "Brique.load:",name
        if workingPath[-1] != "/":
            workingPath += "/"
    
        fileSmi = open(workingPath + "brique.smi", "w")
        fileSmi.write(name + "\n")
        fileSmi.close()
        if verbose:
            sys.stderr.write("Brique.load: babel sdf conversion ...\n")
        os.system(BABEL_PATH + " -ismi " + workingPath + "brique.smi -osdf " + workingPath + "brique.sdf 2> /dev/null")
        os.system("echo '$$$$' >> " + workingPath + "brique.sdf")
        # sys.stderr.write("Brique.load: Will read %s/brique.sdf\n" % (workingPath))
        fileSdf = open(workingPath + "brique.sdf")
        reader = MDL.sdin(fileSdf)
        name2 = reader.next()[0].cansmiles()
        # sys.stderr.write("Brique.load: read sdf as %s\n" %  name2)
        fileSdf.close()
            # print "brique", name, name2
        # if name2 in listFile: # si le fichier est ds la liste
        #     return LIBRARY_PATH+name2 # on renvoie le chemin complet du fichier
        # elif name in listFile:
        #     return LIBRARY_PATH+name
        if name in listFile:
            return LIBRARY_PATH+name
        else:
            # 11 fevrier 2010: We attempt to generate using AMMOS, not to use babel conversion for name.
            name2 = name
            if verbose:
                sys.stderr.write("Brique.load: Building %s as %s ...\n" % ( str(name), str(name2)))
            try:
                # Generer du mol2.
                uName = name2.replace("(","\(").replace(")","\)").replace("[","\[").replace("]","\]")
                # f  =open("%s/%s.smi" % (LIBRARY_PATH, name2), "w")
                sys.stderr.write("Creating %s%s.smi\n" % (LIBRARY_PATH, uName))
                f = open("%s%s.smi" % (LIBRARY_PATH, name2), "w") # in python do not escape names !!!
                f.write("%s\n" %  name2)
                f.close()
                cmd = "%s -h -ismi %s/%s.smi -omol2 %s/%s.mol2" % (BABEL_PATH, LIBRARY_PATH, uName, LIBRARY_PATH, uName)
                # cmd = "%s -h -ismi %s/%s.smi -omol2 %s/%s.mol2" % (BABEL_PATH, LIBRARY_PATH, "itest", LIBRARY_PATH, "itest")
                sys.stderr.write("%s\n" % cmd)
                os.system(cmd)

                # Generer le fichier input.param
                # path_of_DG-AMMOS= /Users/DG-AMMOS
                # bank= input_dataset.mol2
                f=  open("%s/%s.dgammos" % (LIBRARY_PATH, name2), "w")
                # f=  open("%s.dgammos" % ("itest"), "w")
                f.write("path_of_DG-AMMOS= %s\n" % DGAMMOSHOME)
                f.write("bank= %s%s.mol2\n" % (LIBRARY_PATH, name2))
                # f.write("bank= %s%s.mol2\n" % (LIBRARY_PATH, "itest"))
                f.close()
                sys.stderr.write("Generated %s/%s.dgammos\n" % (LIBRARY_PATH, uName))

                sys.stderr.write("Generating %s/%s.mol2\n" % (LIBRARY_PATH, uName))
                cmd = "%s %s/%s.dgammos" % (AMMOSBUILD, LIBRARY_PATH, uName)
                # cmd = "%s %s.dgammos" % (AMMOSBUILD, uName)
                sys.stderr.write("DG_AMMOS cmd:  %s\n" % (cmd))
                os.system(cmd)
                # sys.exit(0)

                # Convertir en sdf, oter les H
                # cmd = "%s -d -imol2 %s/%s_Built.mol2 -osdf %s/%s.sdf 2> %s/%s.log" % (BABEL_PATH, LIBRARY_PATH, name2, LIBRARY_PATH, name2, LIBRARY_PATH, name2)
                cmd = "%s -d -imol2 %s/%s_Built.mol2 -osdf %s/%s 2> %s/%s.log" % (BABEL_PATH, LIBRARY_PATH, uName, LIBRARY_PATH, uName, LIBRARY_PATH, uName)
                os.system(cmd)
                os.system("echo '$$$$' >> %s/%s" % (LIBRARY_PATH, uName))
                # sys.exit(0)
                # self.load(workingPath)
                return LIBRARY_PATH+name2
                # SI AMMOS N'A PAS PUS GENERER LE CYCLE: le mol2 sera dans %s/%s_BadMolecules.mol2
                # os.system(cmd)
            except:
                return 0
            return 0
Example #14
0
from frowns import MDL
from frowns.mdl_parsers import sdfile


file = open("data\\bad_compounds.sdf")

for mol, error, record in MDL.sdin(file):
    print type(mol), `error`, len(record)

Example #15
0
            
m = Smiles.smilin("c1ccccc1CCNc1cccc1CCC")

print m.cansmiles()
removeTerminalAtoms(m)
smarts = m.arbsmarts()
print smarts

pat = Smarts.compile(smarts)
assert pat.match(m)

smiles = []

file = open("F:\\Chemical Libraries\\Libraries to Purchase\\Nat_425.sdf")

reader = MDL.mdlin(file)
mol = reader.next()

print "reading natural products"
i = 0
while mol:
    fp = Fingerprint.generateFingerprint(mol)
    smile = mol.cansmiles()
    mol = removeTerminalAtoms(mol)
    smiles.append((len(mol.atoms), len(mol.bonds), smile, mol.arbsmarts(), i, fp))
    i += 1
    mol = reader.next()

search = smiles
search.sort()
Example #16
0
from Tkinter import *
from frowns.Depict.TkMoleculeDrawer import MoleculeDrawer
from frowns import MDL

# read in a molecule
reader = MDL.sdin(open("bad.sdf"))
mol, error, text = reader.next()

# create the moleculedock widget and place it
# into a tk window
tk = top = Tk()
m = MoleculeDrawer(top, mol, 0)
m.pack(fill=BOTH, expand=1)

mainloop()

        
Example #17
0
from frowns import MDL
from frowns.mdl_parsers import sdfile

file = open("data\\bad_compounds.sdf")

for mol, error, record in MDL.sdin(file):
    print type(mol), ` error `, len(record)
Example #18
0
from frowns import MDL

for mol, text, error in MDL.sdin(open("../../test/data/bad.sdf")):
    if not mol:
        print "cannot parse sd file"
        print error
        print text
    else:
        print mol.cansmiles()
        print "data"
        for key, value in mol.fields.items():
            print "\t%s: %s" % (key, value)
Example #19
0
>  <LIBRARY> (ST012965)
TimTec

>  <96PLATE> (ST012965)
TIMTEC010

>  <96ROW> (ST012965)
B

>  <96COL> (ST012965)
6

>  <384PLATE> (ST012965)
TIC384003

>  <384COL> (ST012965)
12

>  <384ROW> (ST012965)
C

$$$$"""

from cStringIO import StringIO
data = StringIO(text)

from frowns import MDL
mol, errors, text = MDL.sdin(data).next()
print mol
Example #20
0
from frowns import MDL

for mol, text, error in MDL.sdin(open("../../test/data/bad.sdf")):
    if not mol:
        print "cannot parse sd file"
        print error
        print text
    else:
        print mol.cansmiles()
        print "data"
        for key, value in mol.fields.items():
            print "\t%s: %s"%(key, value)

Example #21
0
    def load(self, workingPath, verbose=False):
        """
        charger le fichier sdf de la brique
        """
        if verbose:
            sys.stderr.write("Brique.load: %s\n" % LIBRARY_PATH)
        if not LIBRARY_PATH:
            sys.stderr.wirte(
                "variable path de la classe Brique non initialisee\n")
            return 0
        try:
            listFile = os.listdir(
                LIBRARY_PATH
            )  # liste des fichier contenu ds 'PAHT' -> listFile
        except:
            sys.stderr.write(
                "Brique.load: Failed to access ring library at %s\n" %
                LIBRARY_PATH)
        # sys.exit(0)
        name = self.cansmiles()

        if verbose:
            sys.stderr.write("Brique.load: Attempting %s ...\n" % str(name))
            # print "Brique.load:",name
        if workingPath[-1] != "/":
            workingPath += "/"

        fileSmi = open(workingPath + "brique.smi", "w")
        fileSmi.write(name + "\n")
        fileSmi.close()
        if verbose:
            sys.stderr.write("Brique.load: babel sdf conversion ...\n")
        os.system(BABEL_PATH + " -ismi " + workingPath + "brique.smi -osdf " +
                  workingPath + "brique.sdf 2> /dev/null")
        os.system("echo '$$$$' >> " + workingPath + "brique.sdf")
        # sys.stderr.write("Brique.load: Will read %s/brique.sdf\n" % (workingPath))
        fileSdf = open(workingPath + "brique.sdf")
        reader = MDL.sdin(fileSdf)
        name2 = reader.next()[0].cansmiles()
        # sys.stderr.write("Brique.load: read sdf as %s\n" %  name2)
        fileSdf.close()
        # print "brique", name, name2
        # if name2 in listFile: # si le fichier est ds la liste
        #     return LIBRARY_PATH+name2 # on renvoie le chemin complet du fichier
        # elif name in listFile:
        #     return LIBRARY_PATH+name
        if name in listFile:
            return LIBRARY_PATH + name
        else:
            # 11 fevrier 2010: We attempt to generate using AMMOS, not to use babel conversion for name.
            name2 = name
            if verbose:
                sys.stderr.write("Brique.load: Building %s as %s ...\n" %
                                 (str(name), str(name2)))
            try:
                # Generer du mol2.
                uName = name2.replace("(", "\(").replace(")", "\)").replace(
                    "[", "\[").replace("]", "\]")
                # f  =open("%s/%s.smi" % (LIBRARY_PATH, name2), "w")
                sys.stderr.write("Creating %s%s.smi\n" % (LIBRARY_PATH, uName))
                f = open("%s%s.smi" % (LIBRARY_PATH, name2),
                         "w")  # in python do not escape names !!!
                f.write("%s\n" % name2)
                f.close()
                cmd = "%s -h -ismi %s/%s.smi -omol2 %s/%s.mol2" % (
                    BABEL_PATH, LIBRARY_PATH, uName, LIBRARY_PATH, uName)
                # cmd = "%s -h -ismi %s/%s.smi -omol2 %s/%s.mol2" % (BABEL_PATH, LIBRARY_PATH, "itest", LIBRARY_PATH, "itest")
                sys.stderr.write("%s\n" % cmd)
                os.system(cmd)

                # Generer le fichier input.param
                # path_of_DG-AMMOS= /Users/DG-AMMOS
                # bank= input_dataset.mol2
                f = open("%s/%s.dgammos" % (LIBRARY_PATH, name2), "w")
                # f=  open("%s.dgammos" % ("itest"), "w")
                f.write("path_of_DG-AMMOS= %s\n" % DGAMMOSHOME)
                f.write("bank= %s%s.mol2\n" % (LIBRARY_PATH, name2))
                # f.write("bank= %s%s.mol2\n" % (LIBRARY_PATH, "itest"))
                f.close()
                sys.stderr.write("Generated %s/%s.dgammos\n" %
                                 (LIBRARY_PATH, uName))

                sys.stderr.write("Generating %s/%s.mol2\n" %
                                 (LIBRARY_PATH, uName))
                cmd = "%s %s/%s.dgammos" % (AMMOSBUILD, LIBRARY_PATH, uName)
                # cmd = "%s %s.dgammos" % (AMMOSBUILD, uName)
                sys.stderr.write("DG_AMMOS cmd:  %s\n" % (cmd))
                os.system(cmd)
                # sys.exit(0)

                # Convertir en sdf, oter les H
                # cmd = "%s -d -imol2 %s/%s_Built.mol2 -osdf %s/%s.sdf 2> %s/%s.log" % (BABEL_PATH, LIBRARY_PATH, name2, LIBRARY_PATH, name2, LIBRARY_PATH, name2)
                cmd = "%s -d -imol2 %s/%s_Built.mol2 -osdf %s/%s 2> %s/%s.log" % (
                    BABEL_PATH, LIBRARY_PATH, uName, LIBRARY_PATH, uName,
                    LIBRARY_PATH, uName)
                os.system(cmd)
                os.system("echo '$$$$' >> %s/%s" % (LIBRARY_PATH, uName))
                # sys.exit(0)
                # self.load(workingPath)
                return LIBRARY_PATH + name2
                # SI AMMOS N'A PAS PUS GENERER LE CYCLE: le mol2 sera dans %s/%s_BadMolecules.mol2
                # os.system(cmd)
            except:
                return 0
            return 0
Example #22
0
m = Smiles.smilin("c1ccccc1CCNc1cccc1CCC")

print m.cansmiles()
removeTerminalAtoms(m)
smarts = m.arbsmarts()
print smarts

pat = Smarts.compile(smarts)
assert pat.match(m)

smiles = []

file = open("F:\\Chemical Libraries\\Libraries to Purchase\\Nat_425.sdf")

reader = MDL.mdlin(file)
mol = reader.next()

print "reading natural products"
i = 0
while mol:
    fp = Fingerprint.generateFingerprint(mol)
    smile = mol.cansmiles()
    mol = removeTerminalAtoms(mol)
    smiles.append(
        (len(mol.atoms), len(mol.bonds), smile, mol.arbsmarts(), i, fp))
    i += 1
    mol = reader.next()

search = smiles
search.sort()
Example #23
0
   -0.3583    0.2083    0.0000 C   0  0  2  0  0  0  0  0  0  0  0  0
   -0.3583    1.0333    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.3583   -1.4416    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0708    1.4458    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0666   -0.2083    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.0666   -1.0333    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.3583    1.4458    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    1.0708   -1.4458    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0  0  0  0
  1  3  1  0  0  0  0
  2  5  1  0  0  0  0
  2 10  1  0  0  0  0
  3  4  1  1  0  0  0
  3  7  1  0  0  0  0
  4  6  2  0  0  0  0
  4  9  1  0  0  0  0
  5  8  1  0  0  0  0
  7  8  1  0  0  0  0
M  END
$$$$
"""
if __name__ == "__main__":
   import StringIO
   from frowns import MDL
   mol, error, text = MDL.sdin(StringIO.StringIO(__test__)).next()

   print mol
#   app = wxPySimpleApp()
   d = Drawer()
   print d.makeGif(mol)
Example #24
0
from frowns import MDL
from frowns.Depict.wxMoleculeDrawer import MoleculeDrawer

for mol, error, text in MDL.sdin(open("data\chiral.sdf")):
    for bond in mol.bonds:
        print bond.stereo
    print mol, error
    print mol.cansmiles()

from wxPython.wx import *
class testApp(wxApp):
    def OnInit(self):
        from frowns import MDL
        reader = MDL.sdin(open("data\chiral3.sdf"))
        
        mol, error, text = reader.next()

        wxInitAllImageHandlers()
        frame = wxFrame(None, -1, "", size=(350,200))

        
        drawer = self.drawer = MoleculeDrawer(frame, drawAromatic=1)
        drawer.setMolecule(mol)
        frame.Show(TRUE)
        return TRUE