source: cobios/intact.py

Last change on this file was 4, checked in by jjbot, 11 years ago

Initial import of new code base.

File size: 2.7 KB
Line 
1from container import utility
2
3def getintact(db,name,accmap):
4    protein = db.accession[_.accession == name].bioentrys.join(db.taxon_bioentry)[_.bioentry.bioentry_id == _.taxon_bioentry.bioentry_id][_.taxon_id == 4071,0].children.require_type("CDS")()
5    print protein
6    if(len(protein) == 0):
7        return 
8    x1 = db.biorelationship[(_.directed == False) & (_.source_bioentry_id == protein.bioentry_id)].join(db.term)[_.type_id == _.term_id].join(db.bioentry.bm("bla"))[_.target_bioentry_id == _.bla.bioentry_id]
9    x2 = db.biorelationship[(_.directed == False) & (_.target_bioentry_id == protein.bioentry_id)].join(db.term)[_.type_id == _.term_id].join(db.bioentry.bm("bla"))[_.source_bioentry_id == _.bla.bioentry_id]
10    res = (x1++x2)[:,[7,8,11,13,14]].jparents[:,[0,1,3,11,13,14]].require_type("gene")[:,[0,3]]()
11    res = utility.dim2(res)
12    for i in range(len(res)):
13        res[i,1] = accmap[res[i,1]]
14    return res
15           
16
17def getprob(db,v,name,accmap):
18    v = v.copy() 
19    for i in range(len(v)):
20        v[i,0] = float(str(v[i,0]))
21        v[i,1] = int(float(str(v[i,1])))
22        v[i,2] = int(float(str(v[i,2])))
23
24    genes = db.accession[_.accession == name].bioentrys.join(db.taxon_bioentry)[_.bioentry.bioentry_id == _.taxon_bioentry.bioentry_id][_.taxon_id == 4071].require_type("gene")[:,0]()
25    print genes
26    print v
27    x = v[(v[:,2] == genes)]
28    #x = v[(v[:,1] == genes) | (v[:,2] == genes)]
29    x = utility.dim2(x)
30#    x = x[x[:,4]]
31    for i in range(len(x)):
32        x[i,1] = accmap[int(float(x[i,1]))]
33        x[i,2] = accmap[int(float(x[i,2]))]
34    return x
35
36   
37def gettransfac(db,name,accmap):
38    genes = db.accession[_.accession == name].bioentrys.join(db.taxon_bioentry)[_.bioentry.bioentry_id == _.taxon_bioentry.bioentry_id][_.taxon_id == 4071].require_type("gene")[:,0]()
39    res = db.bioentry[_.bioentry_id == genes].children.require_type("promoter binding site").parents_rel.require_type("transfac regulation").sources.parents_rel.require_type("gene_part").sources.bioentry_id()
40    r = []
41    for i in utility.ensure_seq(res):
42        r.append(accmap[i])
43    return r
44
45
46   
47   
48   
49
50def accmap(db):
51    r = db.bioentry.require_type("gene").join(db.bioentry_qualifier_accession)[_.bioentry.bioentry_id == _.bioentry_qualifier_accession.bioentry_id].join(db.accession.bm("xa"))[_.bioentry_qualifier_accession.accession_id == _.xa.accession_id,[0,2,10,12]].require_type("GENENAME")()
52    r2 = db.bioentry.require_type("gene")()
53    res = dict()
54    for i in r:
55        if(i.bioentry_id in res):
56            res[i.bioentry_id].append(i.accession)
57        else:
58            res[i.bioentry_id] = [i.name,i.accession]
59    for i in r2:
60        if(i.bioentry_id not in res):
61            res[i.bioentry_id] = [i.name]
62    return res
Note: See TracBrowser for help on using the repository browser.