Skip to content

Commit

Permalink
fix for issue #64 (non-mito case in ataqc)
Browse files Browse the repository at this point in the history
  • Loading branch information
leepc12 committed Dec 6, 2018
1 parent 96ea305 commit 95a2c19
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/run_ataqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,16 @@ def get_chr_m(sorted_bam_file):
logging.info('Getting mitochondrial chromosome fraction...')
chrom_list = pysam.idxstats(sorted_bam_file, split_lines=True)
tot_reads = 0
chr_m_reads = 0
for chrom in chrom_list:
chrom_stats = chrom.split('\t')
if chrom_stats[0] == 'chrM':
chr_m_reads = int(chrom_stats[2])
tot_reads += int(chrom_stats[2])
fract_chr_m = float(chr_m_reads) / tot_reads
if tot_reads==0:
fract_chr_m = 0
else
fract_chr_m = float(chr_m_reads) / tot_reads

return chr_m_reads, fract_chr_m

Expand Down

0 comments on commit 95a2c19

Please sign in to comment.