Skip to content

Commit

Permalink
handle cases where the read length is longer than the reference
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewing committed Jul 6, 2023
1 parent 1762bfd commit 7b48512
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions methylartist
Original file line number Diff line number Diff line change
Expand Up @@ -876,15 +876,28 @@ def parse_methbam(bam_fn, reads, chrom, start, end, motifsize=2, meth_thresh=0.8
genome_pos = None

if rec.is_reverse:
genome_pos = ap[len(rec.seq)-base_pos[i]-1]
try:
genome_pos = ap[len(rec.seq)-base_pos[i]-1]
except IndexError:
if i >= len(base_pos):
genome_pos = None
else:
raise IndexError(".bam parsing error: position not in aligned pairs")

if genome_pos is None:
continue

genome_pos -= (int(motifsize)-1)

else:
genome_pos = ap[base_pos[i]]
try:
genome_pos = ap[base_pos[i]]

except IndexError:
if i >= len(base_pos):
genome_pos = None
else:
raise IndexError(".bam parsing error: position not in aligned pairs")

if genome_pos is None:
continue
Expand Down

0 comments on commit 7b48512

Please sign in to comment.