Exemplo 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()
Exemplo 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()
Exemplo n.º 3
0
from parameter import Parameter
from ligand import Ligand
from receptor import Receptor


def line(id, ligand):
    ids = [str(id)]
    ligand.foreachId(lambda id: ids.append(str(id)))
    return '\t'.join(ids)


p = Parameter()

ligand = Ligand(p._('project.ligand.db'))
receptor = Receptor(p._('project.receptor.db'))

receptor.foreachId(lambda id: print(line(id, ligand)))

ligand.close()
receptor.close()
Exemplo n.º 4
0

def ok(line):
    field = re.split('\s+', line)
    if field[0] == 'ANISOU':
        return False

    if field[0] in ['ATOM', 'HETATM']:
        return field[2].upper() not in ['NA']

    return True


def remove_noise(id, path, incl):
    if id in incl:
        content = open(path).read().strip('\n').split('\n')
        newcontent = [s for s in content if ok(s)]

        if len(content) != len(newcontent):
            open(path, 'w').write('\n'.join(newcontent))
            print(id)


p = Parameter()
pt = Path(p)

molecule = Receptor(pt.receptordb)
incl = p._('project.wizard.receptor_remove_noise.include').split(',')

molecule.foreachId(lambda id: remove_noise(id, pt.receptor(id), incl))