Mercurial > repos > iuc > control_freec
diff ratio2circos.py @ 1:1204e79d3a99 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit e0d4688a59e6eeba33adcfe803ac43d0bc2863e7"
author | iuc |
---|---|
date | Tue, 31 Aug 2021 08:10:37 +0000 |
parents | 5330cf818142 |
children |
line wrap: on
line diff
--- a/ratio2circos.py Thu Aug 13 13:49:44 2020 +0000 +++ b/ratio2circos.py Tue Aug 31 08:10:37 2021 +0000 @@ -1,20 +1,18 @@ -import argparse import math -import os +import sys -parser = argparse.ArgumentParser() -parser.add_argument('-i', '--input', required=True, default='./output/sample.bam_ratio.BedGraph', type=str) -parser.add_argument('-o', '--output', required=True, default='./output/sample.bam_ratio_log2_circos.txt', type=str) -parser.add_argument('-p', '--ploidy', required=True, default=2, type=int) -args = parser.parse_args() +ploidy = int(sys.argv[1]) -path = os.path.dirname(args.input) -output = os.path.join(path, args.output) +with open("./output/sample.bam_ratio.BedGraph") as bed: + with open("./output/sample.bam_ratio_log2_circos.txt", "w+") as olog2r: + for line in bed.readlines(): + ls = line.split() + if ls[0] != "track" and float(ls[3]) > 0: + log2_ratio = math.log2(float(ls[3]) / ploidy) + olog2r.write("{}\t{}\t{}\t{}\n".format(ls[0], ls[1], ls[2], log2_ratio)) -with open(args.input) as file: - for line in file.readlines(): - ls = line.split() - if ls[0] != "track" and float(ls[3]) > 0: - log2_ratio = math.log2(float(ls[3]) / args.ploidy) - with open(output, "a") as out: - out.write("{}\t{}\t{}\t{}\n".format(ls[0], ls[1], ls[2], log2_ratio)) +with open("./genome.fa.fai") as fai: + with open("./output/karyotype_circos.txt", "w+") as ochr: + for line in fai.readlines(): + ls = line.split() + ochr.write("chr - {}\t{}\t0\t{}\t{}\n".format(ls[0], ls[0].strip("chr").lower(), ls[1], ls[0]))