forked from fak/mapChEMBLPfam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoSam.py
64 lines (54 loc) · 2.17 KB
/
toSam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Function: forSam
--------------------
Write all conflicts out for Sam to classify.
"""
def toSam(conflicts, threshold, user, pword, host, release, port):
import parse
import getLigands
import filterForTarget
import queryDevice
conf = {}
for confStr in conflicts.keys():
for target in conflicts[confStr]:
ligands = getLigands.getLigandsForTarget(target, release, user, pword, host, port)
ligands = filterForTarget.filterForTarget(ligands, threshold)
for ligand in ligands:
molregno = ligand[2]
actId = ligand[3]
pubmed = queryDevice.queryDevice("SELECT pubmed_id FROM docs JOIN activities act ON act.doc_id = docs.doc_id WHERE activity_id = %s"%actId,release, user, pword, host, port)[0][0]
pubmed = pubmed
try:
conf[confStr][molregno]['actId'].append(actId)
conf[confStr][molregno]['pubmed'].append(pubmed)
conf[confStr][molregno]['pubmed'] = []
conf[confStr][molregno]['pubmed'].append(pubmed)
except KeyError:
try:
conf[confStr][molregno] = {}
conf[confStr][molregno]['actId'] = []
conf[confStr][molregno]['actId'].append(actId)
conf[confStr][molregno]['pubmed'] = []
conf[confStr][molregno]['pubmed'].append(pubmed)
except KeyError:
conf[confStr]={}
conf[confStr][molregno] = {}
conf[confStr][molregno]['actId'] = []
conf[confStr][molregno]['actId'].append(actId)
conf[confStr][molregno]['pubmed'] = []
conf[confStr][molregno]['pubmed'].append(pubmed)
confLkp = {}
for confStr in conf.keys():
confLkp[confStr] = 0
for confStr in confLkp.keys():
out = open('data/forSam_%s.pred'%confStr, 'w')
out.write('molregno\tpubmed\tprediction\tactivity_id\n')
for conflict in conf[confStr]:
for molregno in conf[confStr].keys():
pubmed = conf[confStr][molregno]['pubmed']
domain = 'None'
actId = conf[confStr][molregno]['actId']
for act in actId:
out.write('%s\t%s\t%s\t%s\n'%(molregno, pubmed[0], domain, act))
out.close()