// Path: src/main/java/genepi/imputationserver/steps/vcf/sort/VcfLine.java
// public class VcfLine {
// 
// 	private String data;
// 
// 	private String contig;
// 
// 	private int position;
// 
// 	public VcfLine(String line) {
// 		String tiles[] = line.split("\t", 3);
// 		this.contig = tiles[0];
// 		this.position = Integer.parseInt(tiles[1]);
// 		this.data = tiles[2];
// 	}
// 
// 	public String getLine() {
// 		return this.contig + "\t" + this.position + "\t" + this.data;
// 	}
// 
// 	public int getPosition() {
// 		return position;
// 	}
// 
// 	public void setPosition(int position) {
// 		this.position = position;
// 	}
// 
// 	public void setContig(String contig) {
// 		this.contig = contig;
// 	}
// 
// 	public String getContig() {
// 		return contig;
// 	}
// 
// }
// 
// Path: src/main/java/genepi/imputationserver/steps/vcf/sort/VcfLineSortingCollection.java
// public class VcfLineSortingCollection {
// 
// 	public static SortingCollection<VcfLine> newInstance(int maxRecords, String tempDir) {
// 		return SortingCollection.newInstance(VcfLine.class, new VcfLineCodec(), new VcfLineComparator(), maxRecords,
// 				new File(tempDir));
// 	}
// 
// }


import java.io.File;
import java.io.IOException;
import java.util.Vector;
import genepi.imputationserver.steps.vcf.sort.VcfLine;
import genepi.imputationserver.steps.vcf.sort.VcfLineSortingCollection;
import genepi.io.text.LineReader;
import htsjdk.samtools.liftover.LiftOver;
import htsjdk.samtools.util.Interval;
import htsjdk.samtools.util.SortingCollection;
package genepi.imputationserver.steps.vcf;



public class VcfLiftOverFast {

	private static final int MAX_RECORDS_IN_RAM = 1000;

	public static Vector<String> liftOver(String input, String output, String chainFile, String tempDir)
			throws IOException {

		LineReader reader = new LineReader(input);

		LiftOver liftOver = new LiftOver(new File(chainFile));

		Vector<String> errors = new Vector<String>();

		SortingCollection<VcfLine> sorter = VcfLineSortingCollection.newInstance(MAX_RECORDS_IN_RAM, tempDir);

		BGzipLineWriter writer = new BGzipLineWriter(output);
		while (reader.next()) {
			String line = reader.get();
			if (line.startsWith("#")) {
				writer.write(line);
			} else {

				VcfLine vcfLine = new VcfLine(line);
// Path: src/main/java/genepi/imputationserver/steps/vcf/sort/VcfLine.java
// public class VcfLine {
// 
// 	private String data;
// 
// 	private String contig;
// 
// 	private int position;
// 
// 	public VcfLine(String line) {
// 		String tiles[] = line.split("\t", 3);
// 		this.contig = tiles[0];
// 		this.position = Integer.parseInt(tiles[1]);
// 		this.data = tiles[2];
// 	}
// 
// 	public String getLine() {
// 		return this.contig + "\t" + this.position + "\t" + this.data;
// 	}
// 
// 	public int getPosition() {
// 		return position;
// 	}
// 
// 	public void setPosition(int position) {
// 		this.position = position;
// 	}
// 
// 	public void setContig(String contig) {
// 		this.contig = contig;
// 	}
// 
// 	public String getContig() {
// 		return contig;
// 	}
// 
// }
// 
// Path: src/main/java/genepi/imputationserver/steps/vcf/sort/VcfLineSortingCollection.java
// public class VcfLineSortingCollection {
// 
// 	public static SortingCollection<VcfLine> newInstance(int maxRecords, String tempDir) {
// 		return SortingCollection.newInstance(VcfLine.class, new VcfLineCodec(), new VcfLineComparator(), maxRecords,
// 				new File(tempDir));
// 	}
// 
// }


// Path: src/main/java/genepi/imputationserver/steps/vcf/VcfLiftOverFast.java
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import genepi.imputationserver.steps.vcf.sort.VcfLine;
import genepi.imputationserver.steps.vcf.sort.VcfLineSortingCollection;
import genepi.io.text.LineReader;
import htsjdk.samtools.liftover.LiftOver;
import htsjdk.samtools.util.Interval;
import htsjdk.samtools.util.SortingCollection;

package genepi.imputationserver.steps.vcf;



public class VcfLiftOverFast {

	private static final int MAX_RECORDS_IN_RAM = 1000;

	public static Vector<String> liftOver(String input, String output, String chainFile, String tempDir)
			throws IOException {

		LineReader reader = new LineReader(input);

		LiftOver liftOver = new LiftOver(new File(chainFile));

		Vector<String> errors = new Vector<String>();

		SortingCollection<VcfLine> sorter = VcfLineSortingCollection.newInstance(MAX_RECORDS_IN_RAM, tempDir);

		BGzipLineWriter writer = new BGzipLineWriter(output);
		while (reader.next()) {
			String line = reader.get();
			if (line.startsWith("#")) {
				writer.write(line);
			} else {

				VcfLine vcfLine = new VcfLine(line);
				String contig = "";