Mercurial > repos > iuc > control_freec
annotate ratio2circos.py @ 2:f923c54a17ee draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit 30718e775cd7cd2a7746608a0c99e86521cf8d7b"
author | iuc |
---|---|
date | Sat, 13 Nov 2021 18:28:40 +0000 |
parents | 2c6349fb175c |
children |
rev | line source |
---|---|
0
e46944a59b31
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit bec4fb59dc4776d33c2ce8c0bd614c90e5d4ecb2"
iuc
parents:
diff
changeset
|
1 import math |
1
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
2 import sys |
0
e46944a59b31
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit bec4fb59dc4776d33c2ce8c0bd614c90e5d4ecb2"
iuc
parents:
diff
changeset
|
3 |
1
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
4 ploidy = int(sys.argv[1]) |
0
e46944a59b31
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit bec4fb59dc4776d33c2ce8c0bd614c90e5d4ecb2"
iuc
parents:
diff
changeset
|
5 |
1
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
6 with open("./output/sample.bam_ratio.BedGraph") as bed: |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
7 with open("./output/sample.bam_ratio_log2_circos.txt", "w+") as olog2r: |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
8 for line in bed.readlines(): |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
9 ls = line.split() |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
10 if ls[0] != "track" and float(ls[3]) > 0: |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
11 log2_ratio = math.log2(float(ls[3]) / ploidy) |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
12 olog2r.write("{}\t{}\t{}\t{}\n".format(ls[0], ls[1], ls[2], log2_ratio)) |
0
e46944a59b31
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit bec4fb59dc4776d33c2ce8c0bd614c90e5d4ecb2"
iuc
parents:
diff
changeset
|
13 |
1
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
14 with open("./genome.fa.fai") as fai: |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
15 with open("./output/karyotype_circos.txt", "w+") as ochr: |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
16 for line in fai.readlines(): |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
17 ls = line.split() |
2c6349fb175c
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/freec commit a8b671c0a0d277296751dd2ae403603bea1c58dd"
iuc
parents:
0
diff
changeset
|
18 ochr.write("chr - {}\t{}\t0\t{}\t{}\n".format(ls[0], ls[0].strip("chr").lower(), ls[1], ls[0])) |