comparison read2mut.py @ 3:4fc62ab6e9e8 draft

planemo upload for repository https://github.com/gpovysil/VariantAnalyzerGalaxy/tree/master/tools/variant_analyzer commit ee4a8e6cf290e6c8a4d55f9cd2839d60ab3b11c8
author mheinzl
date Sat, 17 Oct 2020 09:11:53 +0000
parents 9d74f30275c6
children 386438cd4c3b
comparison
equal deleted inserted replaced
2:9d74f30275c6 3:4fc62ab6e9e8
742 else: 742 else:
743 chimeric_dcs_high_tiers += high_tiers 743 chimeric_dcs_high_tiers += high_tiers
744 chimera_dict[key1] = (chimeric_dcs, chimeric_dcs_high_tiers) 744 chimera_dict[key1] = (chimeric_dcs, chimeric_dcs_high_tiers)
745 # sheet 2 745 # sheet 2
746 if chimera_correction: 746 if chimera_correction:
747 header_line2 = ('variant ID', 'cvrg', 'AC alt (all tiers)', 'AF (all tiers)', 'chimeras in AC alt (all tiers)', 'chimera-corrected AF (all tiers)', 'cvrg (tiers 1.1-2.4)', 'AC alt (tiers 1.1-2.4)', 'AF (tiers 1.1-2.4)', 'chimeras in AC alt (tiers 1.1-2.4)', 'chimera-corrected AF (tiers 1.1-2.4)', 'AC alt (orginal DCS)', 'AF (original DCS)', 747 header_line2 = ('variant ID', 'cvrg', 'AC alt (all tiers)', 'AF (all tiers)', 'chimeras in AC alt (all tiers)', 'chimera-corrected cvrg', 'chimera-corrected AF (all tiers)', 'cvrg (tiers 1.1-2.4)', 'AC alt (tiers 1.1-2.4)', 'AF (tiers 1.1-2.4)', 'chimeras in AC alt (tiers 1.1-2.4)', 'chimera-corrected cvrg (tiers 1.1-2.4)', 'chimera-corrected AF (tiers 1.1-2.4)', 'AC alt (orginal DCS)', 'AF (original DCS)',
748 'tier 1.1', 'tier 1.2', 'tier 2.1', 'tier 2.2', 'tier 2.3', 'tier 2.4', 748 'tier 1.1', 'tier 1.2', 'tier 2.1', 'tier 2.2', 'tier 2.3', 'tier 2.4',
749 'tier 3.1', 'tier 3.2', 'tier 4.1', 'tier 4.2', 'tier 5', 'AF 1.1-1.2', 'AF 1.1-2.1', 'AF 1.1-2.2', 749 'tier 3.1', 'tier 3.2', 'tier 4.1', 'tier 4.2', 'tier 5', 'AF 1.1-1.2', 'AF 1.1-2.1', 'AF 1.1-2.2',
750 'AF 1.1-2.3', 'AF 1.1-2.4', 'AF 1.1-3.1', 'AF 1.1-3.2', 'AF 1.1-4.1', 'AF 1.1-4.2', 'AF 1.1-5') 750 'AF 1.1-2.3', 'AF 1.1-2.4', 'AF 1.1-3.1', 'AF 1.1-3.2', 'AF 1.1-4.1', 'AF 1.1-4.2', 'AF 1.1-5')
751 else: 751 else:
752 header_line2 = ('variant ID', 'cvrg', 'AC alt (all tiers)', 'AF (all tiers)', 'cvrg (tiers 1.1-2.4)', 'AC alt (tiers 1.1-2.4)', 'AF (tiers 1.1-2.4)', 'AC alt (orginal DCS)', 'AF (original DCS)', 752 header_line2 = ('variant ID', 'cvrg', 'AC alt (all tiers)', 'AF (all tiers)', 'cvrg (tiers 1.1-2.4)', 'AC alt (tiers 1.1-2.4)', 'AF (tiers 1.1-2.4)', 'AC alt (orginal DCS)', 'AF (original DCS)',
784 new_alt = sum(used_tiers) - chimeras_all 784 new_alt = sum(used_tiers) - chimeras_all
785 fraction_chimeras = safe_div(chimeras_all, float(sum(used_tiers))) 785 fraction_chimeras = safe_div(chimeras_all, float(sum(used_tiers)))
786 if fraction_chimeras is None: 786 if fraction_chimeras is None:
787 fraction_chimeras = 0. 787 fraction_chimeras = 0.
788 new_cvrg = cvrg * (1. - fraction_chimeras) 788 new_cvrg = cvrg * (1. - fraction_chimeras)
789 lst.extend([chimeras_all, safe_div(new_alt, new_cvrg)]) 789 lst.extend([chimeras_all, new_cvrg, safe_div(new_alt, new_cvrg)])
790 lst.extend([(cvrg - sum(used_tiers[-5:])), sum(used_tiers[0:6]), safe_div(sum(used_tiers[0:6]), (cvrg - sum(used_tiers[-5:])))]) 790 lst.extend([(cvrg - sum(used_tiers[-5:])), sum(used_tiers[0:6]), safe_div(sum(used_tiers[0:6]), (cvrg - sum(used_tiers[-5:])))])
791 if chimera_correction: 791 if chimera_correction:
792 chimeras_all = chimera_dict[key1][1] 792 chimeras_all = chimera_dict[key1][1]
793 new_alt = sum(used_tiers[0:6]) - chimeras_all 793 new_alt = sum(used_tiers[0:6]) - chimeras_all
794 fraction_chimeras = safe_div(chimeras_all, float(sum(used_tiers[0:6]))) 794 fraction_chimeras = safe_div(chimeras_all, float(sum(used_tiers[0:6])))
795 if fraction_chimeras is None: 795 if fraction_chimeras is None:
796 fraction_chimeras = 0. 796 fraction_chimeras = 0.
797 new_cvrg = (cvrg - sum(used_tiers[-5:])) * (1. - fraction_chimeras) 797 new_cvrg = (cvrg - sum(used_tiers[-5:])) * (1. - fraction_chimeras)
798 lst.extend([chimeras_all, safe_div(new_alt, new_cvrg)]) 798 lst.extend([chimeras_all, new_cvrg, safe_div(new_alt, new_cvrg)])
799 lst.extend([alt_count, safe_div(alt_count, cvrg)]) 799 lst.extend([alt_count, safe_div(alt_count, cvrg)])
800 lst.extend(used_tiers) 800 lst.extend(used_tiers)
801 lst.extend(cum_af) 801 lst.extend(cum_af)
802 lst = tuple(lst) 802 lst = tuple(lst)
803 ws2.write_row(row + 1, 0, lst) 803 ws2.write_row(row + 1, 0, lst)
804 if chimera_correction: 804 if chimera_correction:
805 ws2.conditional_format('N{}:O{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$N$1="tier 1.1"', 'format': format1, 'multi_range': 'N{}:O{} N1:O1'.format(row + 2, row + 2)}) 805 ws2.conditional_format('P{}:Q{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$P$1="tier 1.1"', 'format': format1, 'multi_range': 'P{}:Q{} P1:Q1'.format(row + 2, row + 2)})
806 ws2.conditional_format('P{}:S{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$P$1="tier 2.1"', 'format': format3, 'multi_range': 'P{}:S{} P1:S1'.format(row + 2, row + 2)}) 806 ws2.conditional_format('R{}:U{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$R$1="tier 2.1"', 'format': format3, 'multi_range': 'R{}:U{} R1:U1'.format(row + 2, row + 2)})
807 ws2.conditional_format('T{}:X{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$T$1="tier 3.1"', 'format': format2, 'multi_range': 'T{}:X{} T1:X1'.format(row + 2, row + 2)}) 807 ws2.conditional_format('V{}:Z{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$V$1="tier 3.1"', 'format': format2, 'multi_range': 'V{}:Z{} V1:Z1'.format(row + 2, row + 2)})
808 else: 808 else:
809 ws2.conditional_format('J{}:K{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$J$1="tier 1.1"', 'format': format1, 'multi_range': 'J{}:K{} J1:K1'.format(row + 2, row + 2)}) 809 ws2.conditional_format('J{}:K{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$J$1="tier 1.1"', 'format': format1, 'multi_range': 'J{}:K{} J1:K1'.format(row + 2, row + 2)})
810 ws2.conditional_format('L{}:O{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$L$1="tier 2.1"', 'format': format3, 'multi_range': 'L{}:O{} L1:O1'.format(row + 2, row + 2)}) 810 ws2.conditional_format('L{}:O{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$L$1="tier 2.1"', 'format': format3, 'multi_range': 'L{}:O{} L1:O1'.format(row + 2, row + 2)})
811 ws2.conditional_format('P{}:T{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$P$1="tier 3.1"', 'format': format2, 'multi_range': 'P{}:T{} P1:T1'.format(row + 2, row + 2)}) 811 ws2.conditional_format('P{}:T{}'.format(row + 2, row + 2), {'type': 'formula', 'criteria': '=$P$1="tier 3.1"', 'format': format2, 'multi_range': 'P{}:T{} P1:T1'.format(row + 2, row + 2)})
812 row += 1 812 row += 1