Skip to content

Commit 6504001

Browse files
committed
fixed bug where excessive 5-prime low qualities caused incorrect trimming
1 parent ce5abe1 commit 6504001

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROGRAM_NAME = sickle
2-
VERSION = 1.21
2+
VERSION = 1.29
33
CC = gcc
44
CFLAGS = -Wall -pedantic -DVERSION=$(VERSION)
55
DEBUG = -g

src/sliding.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int
9595
for (j=window_start; j<window_start+window_size; j++) {
9696
if (get_quality_num (fqrec->qual.s[j], qualtype, fqrec, j) < qual_threshold) {
9797
three_prime_cut = j;
98-
99-
/* if cutting length is less than threshold then return -1 for both */
100-
/* to indicate that the read should be discarded */
101-
if (three_prime_cut - five_prime_cut < length_threshold) {
102-
three_prime_cut = -1;
103-
five_prime_cut = -1;
104-
}
10598
break;
10699
}
107100
}
@@ -117,12 +110,16 @@ cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int
117110
window_start++;
118111
}
119112

120-
/* If you never find a five prime cut site, then discard whole read */
121-
if (found_five_prime == 0) {
113+
114+
/* if cutting length is less than threshold then return -1 for both */
115+
/* to indicate that the read should be discarded */
116+
/* Also, if you never find a five prime cut site, then discard whole read */
117+
if ((found_five_prime == 0) || (three_prime_cut - five_prime_cut < length_threshold)) {
122118
three_prime_cut = -1;
123119
five_prime_cut = -1;
124120
}
125121

122+
126123
retvals = (cutsites*) malloc (sizeof(cutsites));
127124
retvals->three_prime_cut = three_prime_cut;
128125
retvals->five_prime_cut = five_prime_cut;

src/trim_paired.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ int paired_main (int argc, char *argv[]) {
324324
p1cut = sliding_window (fqrec1, qualtype, paired_length_threshold, paired_qual_threshold, no_fiveprime, discard_n);
325325
p2cut = sliding_window (fqrec2, qualtype, paired_length_threshold, paired_qual_threshold, no_fiveprime, discard_n);
326326

327+
if (debug) {printf ("p1cut: %d,%d\n", p1cut->five_prime_cut, p1cut->three_prime_cut);}
328+
if (debug) {printf ("p2cut: %d,%d\n", p2cut->five_prime_cut, p2cut->three_prime_cut);}
329+
327330
/* The sequence and quality print statements below print out the sequence string starting from the 5' cut */
328331
/* and then only print out to the 3' cut, however, we need to adjust the 3' cut */
329332
/* by subtracting the 5' cut because the 3' cut was calculated on the original sequence */

src/trim_single.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ int single_main (int argc, char *argv[]) {
170170

171171
p1cut = sliding_window (fqrec, qualtype, single_length_threshold, single_qual_threshold, no_fiveprime, discard_n);
172172

173+
if (debug) {printf ("P1cut: %d,%d\n", p1cut->five_prime_cut, p1cut->three_prime_cut);}
174+
173175
/* if sequence quality and length pass filter then output record, else discard */
174176
if (p1cut->three_prime_cut >= 0) {
175177
fprintf (outfile, "@%s", fqrec->name.s);

0 commit comments

Comments
 (0)