comparison pafcount.py @ 22:2ddd41a0c2d5 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit be4f98b07024b59ff5e1ae0d8b467eecb15c7521-dirty
author fubar
date Thu, 01 Feb 2024 01:58:58 +0000
parents
children 39b717d934a8
comparison
equal deleted inserted replaced
21:8e34214ccee4 22:2ddd41a0c2d5
1 import sys
2 """
3
4 Col Type Description
5 1 string Query sequence name
6 2 int Query sequence length
7 3 int Query start (0-based; BED-like; closed)
8 4 int Query end (0-based; BED-like; open)
9 5 char Relative strand: "+" or "-"
10 6 string Target sequence name
11 7 int Target sequence length
12 8 int Target start on original strand (0-based)
13 9 int Target end on original strand (0-based)
14 10 int Number of residue matches
15 11 int Alignment block length
16 12 int Mapping quality (0-255; 255 for missing)
17 """
18
19 qcis = {}
20 tcis = {}
21 qtrans = {}
22 ttrans = {}
23 pafname = sys.argv[1]
24 pf = open(pafname, 'r').readlines()
25 for row in pf:
26 qn,ql,qs,qe,qrs,tn,tl,ts,te,nm,abl,mq = row.strip().split("\t")[:12]
27
28 if (qn == tn): # cis
29 print('cis', qn,tn)
30 tcis.setdefault(tn, 0)
31 tcis[tn] = tcis[tn] + 1
32 qcis.setdefault(qn, 0)
33 qcis[qn] = qcis[qn] + 1
34 else: # trans
35 print('trans', qn,tn)
36 k = '%s_%s' % (qn,tn)
37 ttrans.setdefault(k, 0)
38 ttrans[k] = ttrans[k]+ 1
39 qtrans.setdefault(k, 0)
40 qtrans[k] = qtrans[k] + 1
41 #print('qcis', qcis,'\nqtrans', qtrans,'\ntcis', tcis,'\ntt', ttrans)
42 #print('\nqtrans', qtrans,'\nttrans', ttrans)
43 chroms = list(qtrans.keys())
44 print('chroms=', chroms)
45 #print('chrom\tqcis\ttcis\tqtrans\tttrans')
46 print('chrom\tqtrans\tttrans')
47 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' % (cr, qtrans[cr], ttrans[cr]))