Esempio n. 1
0
class Pair:
    def __init__(self, receptordb, liganddb):
        self.ligand = Ligand(liganddb)
        self.receptor = Receptor(receptordb)

    def foreachPair(self, pid, sink):
        self.ligand.foreachId(lambda cid: sink(pid, cid))

    def foreach(self, sink, criteria=''):
        self.receptor.foreachId(lambda pid: self.foreachPair(pid, sink))

    def size(self, rcriteria='1=1', lcriteria='1=1'):
        ligands = self.ligand.size(lcriteria)
        receptors = self.receptor.size(rcriteria)
        return ligands * receptors

    def close(self):
        self.ligand.close()
        self.receptor.close()
Esempio n. 2
0
import os
from parameter import Parameter
from ligand import Ligand
from receptor import Receptor
from path import Path


def print_pairs(pid, ligand):
    ligand.foreachId(lambda cid: print(pid, cid, sep='\t'))


p = Parameter()
pt = Path(p)

ligand = Ligand(pt.data + p._('project.wizard.ligand.db'))
receptor = Receptor(pt.data + p._('project.wizard.receptor.db'))

receptor.foreachId(lambda id: print_pairs(id, ligand))

ligand.close()
receptor.close()
Esempio n. 3
0
import os
from parameter import Parameter
from receptor import Receptor

p = Parameter()

dir = p._('project.dir') + '/'
project_dir = dir + p._('project.wizard.create.name')
data_dir = project_dir + '/data/'

molecule = Receptor(data_dir + p._('project.wizard.receptor.db'))

columns = p._('project.wizard.receptor_report.columns')
molecule.foreachRecord(columns, lambda id, fields: print(id, fields, sep='\t'))

molecule.close()