Skip to content

Commit

Permalink
ignore non-primary reads in target BAM when replacing reads
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewing committed Apr 3, 2018
1 parent 32b3fae commit 3d17e97
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bamsurgeon/replacereads.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ def replaceReads(targetbam, donorbam, outputbam, nameprefix=None, excludefile=No
recount = 0 # number of replaced reads
used = {}
prog = 0
ignored_target = 0 # number of supplemental / secondary reads in original

for read in targetbam.fetch(until_eof=True):
if read.is_secondary or read.is_supplementary:
ignored_target += 1
continue

prog += 1
if progress and prog % 10000000 == 0:
Expand Down Expand Up @@ -192,6 +196,7 @@ def replaceReads(targetbam, donorbam, outputbam, nameprefix=None, excludefile=No
sys.stdout.write("replaced " + str(recount) + " reads (" + str(excount) + " excluded )\n")
sys.stdout.write("kept " + str(sum([len(v) for k,v in secondary.iteritems()])) + " secondary reads.\n")
sys.stdout.write("kept " + str(sum([len(v) for k,v in supplementary.iteritems()])) + " supplementary reads.\n")
sys.stdout.write("ignored %d non-primary reads in target BAM.\n" % ignored_target)

nadded = 0
# dump the unused reads from the donor if requested with --all
Expand Down

0 comments on commit 3d17e97

Please sign in to comment.