Skip to content

Commit

Permalink
Fix handling of hard-clipped bases
Browse files Browse the repository at this point in the history
  • Loading branch information
dpryan79 committed May 10, 2016
1 parent 9bd4eb9 commit abd5ac1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.1.12:

* Fixed handling of hard-clipped bases, which caused a segfault before.

Version 0.1.11:

* The --minDepth/-d option is actually recognized now. Sorry about that!
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OPTS ?= -Wall -g -O3
all: lib PileOMeth

OBJS = common.o bed.o svg.o pileup.o extract.o MBias.o mergeContext.o
VERSION = 0.1.11
VERSION = 0.1.12

#If we're building from a git repo, then append the most recent tag
ifneq "$(wildcard .git)" ""
Expand Down
11 changes: 6 additions & 5 deletions pileup.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ int32_t *calculate_positions(bam1_t *read) {
if(op == 0 || op == 7 || op == 8) { //M, =, X
*(positions+offset) = previous_position++;
offset++;
} else if(op == 1 || op == 4 || op == 5) { //I, S, H
} else if(op == 1 || op == 4) { //I, S, H
*(positions+offset) = -1;
offset++;
} else if(op == 2 || op == 3) { //D, N
previous_position++;
} else if(op == 5) { //H, which isn't in the sequence
} else { //P
fprintf(stderr, "[calculate_positions] We encountered a CIGAR operation that we're not ready to deal with in %s\n", bam_get_qname(read));
}
Expand All @@ -105,15 +106,15 @@ static void cust_tweak_overlap_quality(bam1_t *a, bam1_t *b) {
if(((sa-sb)&1) == 1) goto quit;

//Go to the first mapped position
while(posa[ia]<0 && ia<na) ia++;
while(posa[ib]<0 && ib<nb) ib++;
while(ia<na && posa[ia]<0) ia++;
while(ib<nb && posa[ib]<0) ib++;
if(ia==na || ib==nb) goto quit;

//Go to the first overlapping position
if(posa[ia]<posb[ib]) {
while(posa[ia]<posb[ib] && ia<na) ia++;
while(ia<na && posa[ia]<posb[ib]) ia++;
} else {
while(posb[ib]<posa[ia] && ib<nb) ib++;
while(ib<nb && posb[ib]<posa[ia]) ib++;
}
if(ia==na || ib==nb) goto quit;

Expand Down

0 comments on commit abd5ac1

Please sign in to comment.