Пример #1
0
    def testSaveRead(self):
        from decaf import Pharmacophore
        from os import remove
        filename = "test.p"
        self.phar.save(filename)
        p_copy = Pharmacophore.read(filename)

        self.assertEqual(self.phar.numnodes, p_copy.numnodes)
        self.assertEqual(self.phar.nodes, p_copy.nodes)
        for i in range(p_copy.numnodes):
            for j in range(p_copy.numnodes):
                self.assertEqual(self.phar.edges[i, j], p_copy.edges[i, j])
        self.assertEqual(self.phar.title, p_copy.title)
        self.assertEqual(self.phar.molecules, p_copy.molecules)
        remove(filename)
        self.assertRaises(IOError, Pharmacophore.read, filename)
        self.assertRaises(IOError, Pharmacophore.save, p_copy,
                          "nonexist/" + filename)
Пример #2
0
Created on Mon Mar 16 10:11:53 2015
@author: Marta Stepniewska
"""

from pybel import readfile
from decaf import Pharmacophore
from decaf.toolkits.ob import phar_from_mol
from decaf.utils import similarity
from multiprocessing import Process, Manager, cpu_count
from time import sleep

NUM_PROCESSES = cpu_count()
cutoff = 0.8

database = readfile("smi", "all.ism")
model = Pharmacophore.read("model.p")

print "Read model with %s nodes created from %s molecules." % (model.numnodes,
                                                               model.molecules)

manager = Manager()
similar = manager.list()
proc = [None] * NUM_PROCESSES


def check_mol(mol):
    p = phar_from_mol(mol)
    s, c = similarity(model, p)
    #print s, c
    if s > cutoff:
        similar.append((mol.write(), s, c))
Пример #3
0
 def setUp(self):
     from decaf import Pharmacophore
     self.phars = [Pharmacophore.read(fname) for fname in self.files]