// Path: src/main/java/net/sf/cram/AlignmentSliceQuery.java
// public class AlignmentSliceQuery {
// 	public String sequence;
// 	public int sequenceId;
// 	public int start;
// 	public int end = Integer.MAX_VALUE;
// 
// 	public AlignmentSliceQuery(String spec) {
// 		String[] chunks = spec.split(":");
// 
// 		sequence = chunks[0];
// 
// 		if (chunks.length > 1) {
// 			chunks = chunks[1].split("-");
// 			start = Integer.valueOf(chunks[0]);
// 			if (chunks.length == 2)
// 				end = Integer.valueOf(chunks[1]);
// 		}
// 
// 	}
// 
// 	@Override
// 	public String toString() {
// 		StringBuffer sb = new StringBuffer(sequence);
// 		if (start > 1 || end < Integer.MAX_VALUE)
// 			sb.append(":").append(start);
// 		if (end < Integer.MAX_VALUE)
// 			sb.append("-").append(end);
// 		return sb.toString();
// 	}
// }


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Scanner;
import htsjdk.samtools.SAMSequenceDictionary;
import htsjdk.samtools.SAMSequenceRecord;
import htsjdk.samtools.cram.io.InputStreamUtils;
import htsjdk.samtools.reference.ReferenceSequence;
import htsjdk.samtools.reference.ReferenceSequenceFile;
import htsjdk.samtools.seekablestream.SeekableFileStream;
import htsjdk.samtools.util.BlockCompressedInputStream;
import htsjdk.samtools.util.Log;
import net.sf.cram.AlignmentSliceQuery;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.converters.FileConverter;
			bufPos += entry.getBasesPerLine();
			is.skip(lineBreakLen);
		}

		// read the rest of the last incomplete line:
		while ((b = (byte) is.read()) != -1 && bufPos < len && b != '\r' && b != '\n')
			data[bufPos++] = b;

		return new ReferenceSequence(entry.getName(), entry.getIndex(), data);
	}

	public static void main(String[] args) throws FileNotFoundException {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		jc.setProgramName("bquery");
		try {
			jc.parse(args);
		} catch (Exception e) {
			jc.usage();
			return;
		}

		if (params.file == null) {
			jc.usage();
			return;
		}

		BGZF_ReferenceSequenceFile rsf = new BGZF_ReferenceSequenceFile(params.file);

		for (String stringQuery : params.queries) {
// Path: src/main/java/net/sf/cram/AlignmentSliceQuery.java
// public class AlignmentSliceQuery {
// 	public String sequence;
// 	public int sequenceId;
// 	public int start;
// 	public int end = Integer.MAX_VALUE;
// 
// 	public AlignmentSliceQuery(String spec) {
// 		String[] chunks = spec.split(":");
// 
// 		sequence = chunks[0];
// 
// 		if (chunks.length > 1) {
// 			chunks = chunks[1].split("-");
// 			start = Integer.valueOf(chunks[0]);
// 			if (chunks.length == 2)
// 				end = Integer.valueOf(chunks[1]);
// 		}
// 
// 	}
// 
// 	@Override
// 	public String toString() {
// 		StringBuffer sb = new StringBuffer(sequence);
// 		if (start > 1 || end < Integer.MAX_VALUE)
// 			sb.append(":").append(start);
// 		if (end < Integer.MAX_VALUE)
// 			sb.append("-").append(end);
// 		return sb.toString();
// 	}
// }


// Path: src/main/java/net/sf/cram/fasta/BGZF_ReferenceSequenceFile.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Scanner;
import htsjdk.samtools.SAMSequenceDictionary;
import htsjdk.samtools.SAMSequenceRecord;
import htsjdk.samtools.cram.io.InputStreamUtils;
import htsjdk.samtools.reference.ReferenceSequence;
import htsjdk.samtools.reference.ReferenceSequenceFile;
import htsjdk.samtools.seekablestream.SeekableFileStream;
import htsjdk.samtools.util.BlockCompressedInputStream;
import htsjdk.samtools.util.Log;
import net.sf.cram.AlignmentSliceQuery;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.converters.FileConverter;

			bufPos += entry.getBasesPerLine();
			is.skip(lineBreakLen);
		}

		// read the rest of the last incomplete line:
		while ((b = (byte) is.read()) != -1 && bufPos < len && b != '\r' && b != '\n')
			data[bufPos++] = b;

		return new ReferenceSequence(entry.getName(), entry.getIndex(), data);
	}

	public static void main(String[] args) throws FileNotFoundException {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		jc.setProgramName("bquery");
		try {
			jc.parse(args);
		} catch (Exception e) {
			jc.usage();
			return;
		}

		if (params.file == null) {
			jc.usage();
			return;
		}

		BGZF_ReferenceSequenceFile rsf = new BGZF_ReferenceSequenceFile(params.file);

		for (String stringQuery : params.queries) {
			AlignmentSliceQuery q = new AlignmentSliceQuery(stringQuery);