collapse_coverages.py stumbles on empty bam files
I noticed a problem with collapse_coverages.py
. It seems that the script fails with an error if any of the bam
files (and therefor the corresponding cov
files) are empty. This is what I got:
$folder_metaSNV/src/collapse_coverages.py $folder_PROJ
Traceback (most recent call last):
File "[...]/collapse_coverages.py", line 38, in <module>
write_matrix(avg_cov, 'Average_cov', path.join(project_dir, '{}.all_cov.tab'.format(project_name)))
File "[...]/collapse_coverages.py", line 34, in write_matrix
out.write('\t'.join([c[bf] for bf in bamfiles]))
File "[...]/collapse_coverages.py", line 34, in <listcomp>
out.write('\t'.join([c[bf] for bf in bamfiles]))
KeyError: '160400887.210.gut.RepGenomesv9.unique.sorted.bam'
I followed up and found that the problematic file 160400887.210.gut.RepGenomesv9.unique.sorted.bam
is indeed empty. My quick workaround will be to add a check that all bam
files in my (long) bamlist do indeed contain reads, but I think that an empty file should not cause this error.
Not being a python person though, I do not feel comfortable messing with your code and submitting a merge request...