From 54d0c4b292a2e5b48ad423f14ba8c064b7136165 Mon Sep 17 00:00:00 2001 From: Nikhil Joshi Date: Tue, 9 Jul 2013 19:35:57 -0700 Subject: [PATCH] fixed 5 prime trimming bug --- src/sliding.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sliding.c b/src/sliding.c index d6865f1..7713efa 100644 --- a/src/sliding.c +++ b/src/sliding.c @@ -66,6 +66,10 @@ cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int window_avg = (double)window_total / (double)window_size; + /* If it is the first window, and the qual average is already above + the threshold, then we have already found the five prime cut at pos 0 */ + if (i==0 && window_avg >= qual_threshold) {found_five_prime = 1;} + /* Finding the 5' cutoff */ /* Find when the average quality in the window goes above the threshold starting from the 5' end */ if (no_fiveprime == 0 && found_five_prime == 0 && window_avg >= qual_threshold) { @@ -84,8 +88,8 @@ cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int /* Finding the 3' cutoff */ /* if the average quality in the window is less than the threshold */ /* or if the window is the last window in the read */ - if ((window_avg < qual_threshold) || - (window_start+window_size > fqrec->qual.l)) { + if ((window_avg < qual_threshold || + window_start+window_size > fqrec->qual.l) && found_five_prime == 1) { /* at what point in the window does the quality dip below the threshold? */ for (j=window_start; jthree_prime_cut = three_prime_cut; retvals->five_prime_cut = five_prime_cut;