@Override
	public QualityDecoder createQualityDecoder() {
		if (in == null)
			return null;
		
		// Mark Buffered input stream
		in.mark(BYTE_TO_READ);

		// Initialize new byte buffer
		byte head[] = new byte[BYTE_TO_READ];

		try {
			// Reading bytes into the new buffer
			in.read(head);
			// Reset the buffer
			in.reset();
		} catch (IOException e) {
			System.err.println("I/O error/s occurs reading sequence file.");
			System.exit(-1);
		}

		// Generate an input stream from the buffer and pass it to a sequence
		// reader
		ByteArrayInputStream byteIn = new ByteArrayInputStream(head);
		@SuppressWarnings("resource")
		FastqSequenceReader reader = new FastqSequenceReader(byteIn);

		// Guessing quality
		QualityEncodingGuess guess = new QualityEncodingGuess();
		reader.addListener(guess);

		try {
			reader.readAllSequence();
		} catch (IOException e) {
			System.err.println("I/O error/s occurs reading sequence file.");
			System.exit(-1);
		} catch (FileFormatException e) {
			String error = String.format(
					"Sequence at line %d is not well formatted", e.getLine());
			System.err.println(error);
			System.exit(-1);
		} finally {
			try {
				byteIn.close();
			} catch (IOException e) {
				// Nothing we can do
			}
		}

		// If the guessing class has recognized the encoding it will return a
		// quality decoder otherwise it will return null
		if (guess.encoding != null) {
			return new FastqQualityDecoder(guess.encoding);
		}
		return null;
	}