@Override
	int trimIndex(Fastq fastq) {
		int qual[] = FastqTools.qualtityArray(fastq);

		int i;
		for( i = 0; i < qual.length - runningMedianLength; i += 2 ) {

			// Sorted list of qualities
			LinkedList<Integer> list = new LinkedList<Integer>();
			for( int k = 1; k <= runningMedianLength; k++ )
				list.add(qual[i + k]);
			Collections.sort(list);

			// Median
			int size = list.size(), med = 0;
			if( list.size() % 2 == 1 ) med = list.get(size / 2);
			else med = (list.get(size / 2 - 1) + list.get(size / 2)) / 2;

			if( med < qualityThreshold ) break;
		}

		// Do we have at least 'minBases'?
		i -= runningMedianLength - 1;
		if( i > minBases ) return i;
		return 0;
	}