<commit_before>#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <zlib.h>
#include <stdio.h>
#include <getopt.h>
#include "sickle.h"
#include "kseq.h"

int get_quality_num (char qualchar, int qualtype) {
  /* 
     Return the adjusted quality, depending on quality type.

     Note that this uses the array in sickle.h, which *approximates*
     the SOLEXA (pre-1.6 pipeline) qualities as linear. This is
     inaccurate with low-quality bases.
  */
  return((int) qualchar - quality_constants[qualtype][Q_OFFSET]);
}


cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int qual_threshold, int no_fiveprime, int discard_n) {

	int window_size = (int) (0.1 * fqrec->seq.l);
	int i,j;
	int window_start=0;
	int window_total=0;
	int three_prime_cut = fqrec->seq.l;
	int five_prime_cut = 0;
	int found_five_prime = 0;
	double window_avg;
	cutsites* retvals;

	/* If the sequence contains an "N" then discard if the option has been selected */
	if (discard_n && (strstr(fqrec->seq.s, "N") || strstr(fqrec->seq.s, "n"))) {
		retvals = (cutsites*) malloc (sizeof(cutsites));
		retvals->three_prime_cut = -1;
		retvals->five_prime_cut = -1;
		return (retvals);
	}

	/* if the seq length is less then 10bp, */
	/* then make the window size the length of the seq */
	if (window_size == 0) window_size = fqrec->seq.l;

	for (i=0; i<window_size; i++) {
		window_total += get_quality_num (fqrec->qual.s[i], qualtype);
	}

	for (i=0; i<fqrec->qual.l; i++) {<commit_msg>fixed bug where sickle was not discarding reads below the length threshold if the read had all good quality<commit_after>#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <zlib.h>
#include <stdio.h>
#include <getopt.h>
#include "sickle.h"
#include "kseq.h"

int get_quality_num (char qualchar, int qualtype) {
  /* 
     Return the adjusted quality, depending on quality type.

     Note that this uses the array in sickle.h, which *approximates*
     the SOLEXA (pre-1.3 pipeline) qualities as linear. This is
     inaccurate with low-quality bases.
  */
  return((int) qualchar - quality_constants[qualtype][Q_OFFSET]);
}


cutsites* sliding_window (kseq_t *fqrec, int qualtype, int length_threshold, int qual_threshold, int no_fiveprime, int discard_n) {

	int window_size = (int) (0.1 * fqrec->seq.l);
	int i,j;
	int window_start=0;
	int window_total=0;
	int three_prime_cut = fqrec->seq.l;
	int five_prime_cut = 0;
	int found_five_prime = 0;
	double window_avg;
	cutsites* retvals;

	/* If the sequence contains an "N" then discard if the option has been selected */
	/* Also discard if the length of the sequence is less than the length threshold */
	if ((discard_n && (strstr(fqrec->seq.s, "N") || strstr(fqrec->seq.s, "n"))) || 
			(fqrec->seq.l < length_threshold)) {
		retvals = (cutsites*) malloc (sizeof(cutsites));
		retvals->three_prime_cut = -1;
		retvals->five_prime_cut = -1;
		return (retvals);
	}

	/* if the seq length is less then 10bp, */
	/* then make the window size the length of the seq */
	if (window_size == 0) window_size = fqrec->seq.l;

	for (i=0; i<window_size; i++) {
		window_total += get_quality_num (fqrec->qual.s[i], qualtype);
	}

	for (i=0; i<fqrec->qual.l; i++) {
{'fraction_non_alphanumeric': 0.13536168891648556, 'fraction_numerical': 0.009313877677739833, 'mean_word_length': 4.0501567398119125, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4388556', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1181, 'n_words': 352}