comparison pafcount.py @ 23:39b717d934a8 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit be2268f4c11d54bdd44789dd88dd9017cad27887-dirty
author fubar
date Sat, 03 Feb 2024 10:17:27 +0000
parents 2ddd41a0c2d5
children
comparison
equal deleted inserted replaced
22:2ddd41a0c2d5 23:39b717d934a8
1 import sys 1 import sys
2
2 """ 3 """
3 4
4 Col Type Description 5 Col Type Description
5 1 string Query sequence name 6 1 string Query sequence name
6 2 int Query sequence length 7 2 int Query sequence length
19 qcis = {} 20 qcis = {}
20 tcis = {} 21 tcis = {}
21 qtrans = {} 22 qtrans = {}
22 ttrans = {} 23 ttrans = {}
23 pafname = sys.argv[1] 24 pafname = sys.argv[1]
24 pf = open(pafname, 'r').readlines() 25 pf = open(pafname, "r").readlines()
25 for row in pf: 26 for row in pf:
26 qn,ql,qs,qe,qrs,tn,tl,ts,te,nm,abl,mq = row.strip().split("\t")[:12] 27 qn, ql, qs, qe, qrs, tn, tl, ts, te, nm, abl, mq = row.strip().split("\t")[:12]
27 28
28 if (qn == tn): # cis 29 if qn == tn: # cis
29 print('cis', qn,tn) 30 print("cis", qn, tn)
30 tcis.setdefault(tn, 0) 31 tcis.setdefault(tn, 0)
31 tcis[tn] = tcis[tn] + 1 32 tcis[tn] = tcis[tn] + 1
32 qcis.setdefault(qn, 0) 33 qcis.setdefault(qn, 0)
33 qcis[qn] = qcis[qn] + 1 34 qcis[qn] = qcis[qn] + 1
34 else: # trans 35 else: # trans
35 print('trans', qn,tn) 36 print("trans", qn, tn)
36 k = '%s_%s' % (qn,tn) 37 k = "%s_%s" % (qn, tn)
37 ttrans.setdefault(k, 0) 38 ttrans.setdefault(k, 0)
38 ttrans[k] = ttrans[k]+ 1 39 ttrans[k] = ttrans[k] + 1
39 qtrans.setdefault(k, 0) 40 qtrans.setdefault(k, 0)
40 qtrans[k] = qtrans[k] + 1 41 qtrans[k] = qtrans[k] + 1
41 #print('qcis', qcis,'\nqtrans', qtrans,'\ntcis', tcis,'\ntt', ttrans) 42 # print('qcis', qcis,'\nqtrans', qtrans,'\ntcis', tcis,'\ntt', ttrans)
42 #print('\nqtrans', qtrans,'\nttrans', ttrans) 43 # print('\nqtrans', qtrans,'\nttrans', ttrans)
43 chroms = list(qtrans.keys()) 44 chroms = list(qtrans.keys())
44 print('chroms=', chroms) 45 print("chroms=", chroms)
45 #print('chrom\tqcis\ttcis\tqtrans\tttrans') 46 # print('chrom\tqcis\ttcis\tqtrans\tttrans')
46 print('chrom\tqtrans\tttrans') 47 print("chrom\tqtrans\tttrans")
47 for cr in chroms: 48 for cr in chroms:
48 #print('%s\t%d\t%d\t%d\t%d' % (cr, qcis[cr], tcis[cr], qtrans[cr], ttrans[cr])) 49 # print('%s\t%d\t%d\t%d\t%d' % (cr, qcis[cr], tcis[cr], qtrans[cr], ttrans[cr]))
49 print('%s\t%d\t%d' % (cr, qtrans[cr], ttrans[cr])) 50 print("%s\t%d\t%d" % (cr, qtrans[cr], ttrans[cr]))