Skip to content

Commit

Permalink
sort output vcf positions numerically (resolves #290)
Browse files Browse the repository at this point in the history
resolves #290

outputted vcfs after merging are sorted chromosomes 1..22,X,Y,M
and positions within are sorted numerically.
  • Loading branch information
davidstew committed Jun 5, 2018
1 parent 0631068 commit 4a2d984
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/protect/mutation_calling/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ def merge_perchrom_mutations(job, chrom, mutations, univ_options):
file=outfile)
print('#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO', file=outfile)
for chrom in chrom_sorted(accepted_hits.keys()):
for position in sorted(accepted_hits[chrom]):
print(chrom, position, '.', accepted_hits[chrom][position][0],
accepted_hits[chrom][position][1], '.', 'PASS',
'callers=' + accepted_hits[chrom][position][2], sep='\t', file=outfile)
for position in sorted(accepted_hits[chrom], key=lambda x: int(x)):
print(chrom, position, '.', accepted_hits[chrom][position][0], accepted_hits[chrom][position][1], '.',
'PASS', 'callers=' + accepted_hits[chrom][position][2], sep='\t', file=outfile)
fsid = job.fileStore.writeGlobalFile(outfile.name)
export_results(job, fsid, outfile.name, univ_options, subfolder='mutations/merged')
return fsid
Expand Down

0 comments on commit 4a2d984

Please sign in to comment.