@@ -51,13 +51,14 @@ def chromosomes_from_fai(genome_fai):
5151 return chromosomes
5252
5353
54- def run_mutation_aggregator (job , mutation_results , univ_options ):
54+ def run_mutation_aggregator (job , mutation_results , univ_options , consensus_options ):
5555 """
5656 Aggregate all the called mutations.
5757
5858 :param dict mutation_results: Dict of dicts of the various mutation callers in a per chromosome
5959 format
6060 :param dict univ_options: Dict of universal options used by almost all tools
61+ :param dict consensus_options: options specific for consensus mutation calling
6162 :returns: fsID for the merged mutations file
6263 :rtype: toil.fileStore.FileID
6364 """
@@ -80,7 +81,7 @@ def run_mutation_aggregator(job, mutation_results, univ_options):
8081 if chroms :
8182 for chrom in chroms :
8283 out [chrom ] = job .addChildJobFn (merge_perchrom_mutations , chrom , mutation_results ,
83- univ_options ).rv ()
84+ univ_options , consensus_options ).rv ()
8485 merged_snvs = job .addFollowOnJobFn (merge_perchrom_vcfs , out , 'merged' , univ_options )
8586 job .fileStore .logToMaster ('Aggregated mutations for %s successfully' % univ_options ['patient' ])
8687 return merged_snvs .rv ()
@@ -89,14 +90,15 @@ def run_mutation_aggregator(job, mutation_results, univ_options):
8990
9091
9192
92- def merge_perchrom_mutations (job , chrom , mutations , univ_options ):
93+ def merge_perchrom_mutations (job , chrom , mutations , univ_options , consensus_options ):
9394 """
9495 Merge the mutation calls for a single chromosome.
9596
9697 :param str chrom: Chromosome to process
9798 :param dict mutations: dict of dicts of the various mutation caller names as keys, and a dict of
9899 per chromosome job store ids for vcfs as value
99100 :param dict univ_options: Dict of universal options used by almost all tools
101+ :param dict consensus_options: options specific for consensus mutation calling
100102 :returns fsID for vcf contaning merged calls for the given chromosome
101103 :rtype: toil.fileStore.FileID
102104 """
@@ -109,13 +111,13 @@ def merge_perchrom_mutations(job, chrom, mutations, univ_options):
109111 mutations .pop ('indels' )
110112 mutations ['strelka_indels' ] = mutations ['strelka' ]['indels' ]
111113 mutations ['strelka_snvs' ] = mutations ['strelka' ]['snvs' ]
112- vcf_processor = {'snvs ' : {'mutect' : process_mutect_vcf ,
114+ vcf_processor = {'snv ' : {'mutect' : process_mutect_vcf ,
113115 'muse' : process_muse_vcf ,
114116 'radia' : process_radia_vcf ,
115117 'somaticsniper' : process_somaticsniper_vcf ,
116118 'strelka_snvs' : process_strelka_vcf
117119 },
118- 'indels ' : {'strelka_indels' : process_strelka_vcf
120+ 'indel ' : {'strelka_indels' : process_strelka_vcf
119121 }
120122 }
121123 accepted_hits = defaultdict (dict )
@@ -131,7 +133,12 @@ def merge_perchrom_mutations(job, chrom, mutations, univ_options):
131133 if 'strelka_' + mut_type in perchrom_mutations :
132134 perchrom_mutations ['strelka' ] = perchrom_mutations ['strelka_' + mut_type ]
133135 perchrom_mutations .pop ('strelka_' + mut_type )
134- majority = 1 if len (perchrom_mutations ) <= 2 else (len (perchrom_mutations ) + 1 ) / 2
136+ if consensus_options [mut_type + '_majority' ] is not None :
137+ majority = consensus_options [mut_type + '_majority' ]
138+ elif len (perchrom_mutations ) <= 2 :
139+ majority = 1
140+ else :
141+ majority = (len (perchrom_mutations ) + 1 ) / 2
135142 # Read in each file to a dict
136143 vcf_lists = {caller : read_vcf (vcf_file ) for caller , vcf_file in perchrom_mutations .items ()}
137144 all_positions = list (set (itertools .chain (* vcf_lists .values ())))
@@ -171,7 +178,7 @@ def read_vcf(vcf_file):
171178 if line .startswith ('#' ):
172179 continue
173180 line = line .strip ().split ()
174- vcf_dict .append ((line [0 ], line [1 ], line [3 ], line [4 ]))
181+ vcf_dict .append ((line [0 ], line [1 ], line [3 ]. upper () , line [4 ]. upper () ))
175182 return vcf_dict
176183
177184
0 commit comments