modified: pixi.toml
[GalaxyCodeBases.git] / BioInfo / BS-Seq / bwa-meth / compare / src / bsmooth-adjust-crick.py
blob4ffff62b675bce7d455ed9706fea32519263af09
1 import sys
3 seq_lens = {}
5 for line in sys.stdin:
6 if line.startswith('@'):
7 print line,
8 if line.startswith('@SQ'):
9 #@SQ SN:chr1 LN:195471971
10 _, sn, ln = line.rstrip().split()
11 sn, ln = sn.split(":")[1], int(ln.split(":")[1])
12 seq_lens[sn] = ln
13 continue
14 toks = line.rstrip().split("\t")
15 chrom = toks[2]
16 flag = int(toks[1])
17 if chrom != "*" and not flag & 0x4:
18 pos = int(toks[3])
19 pos = max(1, seq_lens[chrom] - pos - len(toks[9]))
20 toks[3] = str(pos)
21 print "\t".join(toks)