comparison ratio2circos.py @ 0:e46944a59b31 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit bec4fb59dc4776d33c2ce8c0bd614c90e5d4ecb2"
author iuc
date Thu, 13 Aug 2020 09:50:35 -0400
parents
children 2c6349fb175c
comparison
equal deleted inserted replaced
-1:000000000000 0:e46944a59b31
1 import argparse
2 import math
3 import os
4
5 parser = argparse.ArgumentParser()
6 parser.add_argument('-i', '--input', required=True, default='./output/sample.bam_ratio.BedGraph', type=str)
7 parser.add_argument('-o', '--output', required=True, default='./output/sample.bam_ratio_log2_circos.txt', type=str)
8 parser.add_argument('-p', '--ploidy', required=True, default=2, type=int)
9 args = parser.parse_args()
10
11 path = os.path.dirname(args.input)
12 output = os.path.join(path, args.output)
13
14 with open(args.input) as file:
15 for line in file.readlines():
16 ls = line.split()
17 if ls[0] != "track" and float(ls[3]) > 0:
18 log2_ratio = math.log2(float(ls[3]) / args.ploidy)
19 with open(output, "a") as out:
20 out.write("{}\t{}\t{}\t{}\n".format(ls[0], ls[1], ls[2], log2_ratio))