Skip to content

Commit

Permalink
no read in bam error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maxibor committed Oct 24, 2018
1 parent 7124bde commit aa53aa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions bin/normalizedReadCount
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,15 @@ def getNumberMappedReadsMultiprocess(bam, processes, id, commonReads=[]):


def writeBam(inbam, outbam, commonReads):
bamin = pysam.AlignmentFile(inbam, "rb")
bamout = pysam.AlignmentFile(outbam, 'w', template=bamin)
for s in bamin:
if s.query_name not in commonReads:
bamout.write(s)
try:
bamin = pysam.AlignmentFile(inbam, "rb")
bamout = pysam.AlignmentFile(outbam, 'w', template=bamin)
for s in bamin:
if s.query_name not in commonReads:
bamout.write(s)
except ValueError:
with open("error_readme_"+outbam, "w") as o:
o.write("Error writing this BAM file, input bam file was erroneous")


def getCommonReads(readsBam1, readsBam2):
Expand Down
4 changes: 2 additions & 2 deletions bin/plotAndReport
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ if __name__ == "__main__":
fw.write(conclusion + '\n\n')
fw.write("- **MapDamage plots**\n\n")
fw.write("![MapDamage Fragmisincorporation plot for " +
orga1_clean + ". Very jagged and irregular substitutions are likely indicating spurious damages caused by a lack of reads.](./" + asample + "." + d[asample]["orga1"] + ".fragmisincorporation_plot.png)\n\n")
orga1_clean + ". Very jagged and irregular substitutions are likely indicating spurious damages caused by a lack of reads. If there is not plot displayed, the aligned read count was too low for mapDamage](./" + asample + "." + d[asample]["orga1"] + ".fragmisincorporation_plot.png)\n\n")
fw.write("![MapDamage Fragmisincorporation plot for " +
orga2_clean + ". Very jagged and irregular substitutions are likely indicating spurious damages caused by a lack of reads.](./" + asample + "." + d[asample]["orga2"] + ".fragmisincorporation_plot.png)\n\n")
orga2_clean + ". Very jagged and irregular substitutions are likely indicating spurious damages caused by a lack of reads. If there is not plot displayed, the aligned read count was too low for mapDamage](./" + asample + "." + d[asample]["orga2"] + ".fragmisincorporation_plot.png)\n\n")
fw.write("\n\n***\n")

0 comments on commit aa53aa0

Please sign in to comment.