@@ -0,0 +1,2053 @@
+package fi.csc.microarray.client.visualisation.methods.gbrowser.fileFormat;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.io.StringReader;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport fi.csc.microarray.client.visualisation.methods.gbrowser.dataFetcher.Chunk;%0Aimport fi.csc.microarray.client.visualisation.methods.gbrowser.message.RegionContent;%0Aimport fi.csc.microarray.util.IOUtils;%0A%0A%0Apublic class VcfParser extends TsvParser %7B%0A%0A%09private static final String VCF_HEADER_START = %22#%22;%0A%0A%09public static List%3CColumnDefinition%3E completeVcfColumns = Arrays.asList(new ColumnDefinition%5B%5D %7B %0A%09%09%09new ColumnDefinition(ColumnType.CHROMOSOME, Type.STRING), %0A%09%09%09new ColumnDefinition(ColumnType.BP_START, Type.LONG), %0A%09%7D);%0A%0A%09private Long headerLength;%0A%0A%09public VcfParser() %7B%0A%09%09super(new FileDefinition(completeVcfColumns));%0A%09%7D%0A%0A%09public VcfParser(FileDefinition fileDefinition) %7B%0A%09%09super(fileDefinition);%0A%09%7D%0A%0A%09@Override%0A%09public String getName() %7B%0A%09%09return %22Vcf%22;%0A%09%7D%0A%0A%09@Override%0A%09public long getDefaulChunkLength() %7B%0A%09%09return 128;%0A%09%7D%0A%0A%09@Override%0A%09public RegionContent%5B%5D concise(Chunk chunk) %7B%0A%09%09return new RegionContent%5B%5D %7B%7D;%0A%09%7D%0A%0A%09public long getHeaderLength(String string) throws IOException %7B%0A%09%09BufferedReader reader = new BufferedReader(new StringReader(string));%0A%09%09return getHeaderLength(reader);%0A%09%7D%0A%0A%09public long getHeaderLength(BufferedReader reader) throws IOException %7B%0A%09%09String line = reader.readLine();%0A%09%09long bytes = 0;%0A%09%09while (line != null && line.startsWith(VCF_HEADER_START)) %7B%0A%09%09%09%0A%09%09%09bytes += line.length() + 1; //plus one is the new line character%0A%09%09%7D %0A%0A%09%09return bytes;%0A%09%7D%0A%0A%09@Override%0A%09public long getHeaderLength(File file) throws IOException %7B%0A%0A%09%09if (this.headerLength == null) %7B%0A%09%09%09BufferedReader in = null;%0A%09%09%09try %7B%0A%09%09%09%09in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));%0A%09%09%09%09this.headerLength = getHeaderLength(in);%0A%0A%09%09%09%7D finally %7B%0A%09%09%09%09IOUtils.closeIfPossible(in);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return headerLength;%0A%09%7D%0A%7D

create vcf parser