private final ArrayList<String> parseDictionary(final VCFHeader header) { final ArrayList<String> dict = BCF2Utils.makeDictionary(header); // if we got here we never found a dictionary, or there are no elements in the dictionary if ( dict.isEmpty() ) error("Dictionary header element was absent or empty"); return dict; }
private final ArrayList<String> parseDictionary(final VCFHeader header) { final ArrayList<String> dict = BCF2Utils.makeDictionary(header); // if we got here we never found a dictionary, or there are no elements in the dictionary if ( dict.isEmpty() ) error("Dictionary header element was absent or empty"); return dict; }
@Requires("header != null") @Ensures({"result != null", "! result.isEmpty()"}) private final ArrayList<String> parseDictionary(final VCFHeader header) { final ArrayList<String> dict = BCF2Utils.makeDictionary(header); // if we got here we never found a dictionary, or there are no elements in the dictionary if ( dict.isEmpty() ) error("Dictionary header element was absent or empty"); return dict; }
@Override public void setHeader(VCFHeader header) { genoFieldDecoders = new BCF2GenotypeFieldDecoders(header); fieldDict = BCF2Utils.makeDictionary(header); builders = new GenotypeBuilder[header.getNGenotypeSamples()]; final List<String> genotypeSamples = header.getGenotypeSamples(); for (int i = 0; i < builders.length; ++i) builders[i] = new GenotypeBuilder(genotypeSamples.get(i)); sampleNamesInOrder = header.getSampleNamesInOrder(); sampleNameToOffset = header.getSampleNameToOffset(); }
@Override public void setHeader(VCFHeader header) { genoFieldDecoders = new BCF2GenotypeFieldDecoders(header); fieldDict = BCF2Utils.makeDictionary(header); builders = new GenotypeBuilder[header.getNGenotypeSamples()]; final List<String> genotypeSamples = header.getGenotypeSamples(); for (int i = 0; i < builders.length; ++i) builders[i] = new GenotypeBuilder(genotypeSamples.get(i)); sampleNamesInOrder = header.getSampleNamesInOrder(); sampleNameToOffset = header.getSampleNameToOffset(); }
@Override public void setHeader(VCFHeader header) { genoFieldDecoders = new BCF2GenotypeFieldDecoders(header); fieldDict = BCF2Utils.makeDictionary(header); builders = new GenotypeBuilder[header.getNGenotypeSamples()]; final List<String> genotypeSamples = header.getGenotypeSamples(); for (int i = 0; i < builders.length; ++i) builders[i] = new GenotypeBuilder(genotypeSamples.get(i)); sampleNamesInOrder = header.getSampleNamesInOrder(); sampleNameToOffset = header.getSampleNameToOffset(); }
@Override public void setHeader(final VCFHeader header) { if (outputHasBeenWritten) { throw new IllegalStateException("The header cannot be modified after the header or variants have been written to the output stream."); } // make sure the header is sorted correctly this.header = doNotWriteGenotypes ? new VCFHeader(header.getMetaDataInSortedOrder()) : new VCFHeader( header.getMetaDataInSortedOrder(), header.getGenotypeSamples()); // create the config offsets map if ( this.header.getContigLines().isEmpty() ) { if ( ALLOW_MISSING_CONTIG_LINES ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("No contig dictionary found in header, falling back to reference sequence dictionary"); } createContigDictionary(VCFUtils.makeContigHeaderLines(getRefDict(), null)); } else { throw new IllegalStateException("Cannot write BCF2 file with missing contig lines"); } } else { createContigDictionary(this.header.getContigLines()); } // set up the map from dictionary string values -> offset final ArrayList<String> dict = BCF2Utils.makeDictionary(this.header); for ( int i = 0; i < dict.size(); i++ ) { stringDictionaryMap.put(dict.get(i), i); } sampleNames = this.header.getGenotypeSamples().toArray(new String[this.header.getNGenotypeSamples()]); // setup the field encodings fieldManager.setup(this.header, encoder, stringDictionaryMap); }
@Override public void setHeader(final VCFHeader header) { if (outputHasBeenWritten) { throw new IllegalStateException("The header cannot be modified after the header or variants have been written to the output stream."); } // make sure the header is sorted correctly this.header = doNotWriteGenotypes ? new VCFHeader(header.getMetaDataInSortedOrder()) : new VCFHeader( header.getMetaDataInSortedOrder(), header.getGenotypeSamples()); // create the config offsets map if ( this.header.getContigLines().isEmpty() ) { if ( ALLOW_MISSING_CONTIG_LINES ) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("No contig dictionary found in header, falling back to reference sequence dictionary"); } createContigDictionary(VCFUtils.makeContigHeaderLines(getRefDict(), null)); } else { throw new IllegalStateException("Cannot write BCF2 file with missing contig lines"); } } else { createContigDictionary(this.header.getContigLines()); } // set up the map from dictionary string values -> offset final ArrayList<String> dict = BCF2Utils.makeDictionary(this.header); for ( int i = 0; i < dict.size(); i++ ) { stringDictionaryMap.put(dict.get(i), i); } sampleNames = this.header.getGenotypeSamples().toArray(new String[this.header.getNGenotypeSamples()]); // setup the field encodings fieldManager.setup(this.header, encoder, stringDictionaryMap); }
final ArrayList<String> dict = BCF2Utils.makeDictionary(header); for ( int i = 0; i < dict.size(); i++ ) { stringDictionaryMap.put(dict.get(i), i);
@Test public void testCreateDictionary() { final List<VCFHeaderLine> inputLines = new ArrayList<VCFHeaderLine>(); int counter = 0; inputLines.add(new VCFFilterHeaderLine(String.valueOf(counter++))); inputLines.add(new VCFFilterHeaderLine(String.valueOf(counter++))); inputLines.add(new VCFContigHeaderLine(Collections.singletonMap("ID", String.valueOf(counter++)), counter)); inputLines.add(new VCFContigHeaderLine(Collections.singletonMap("ID", String.valueOf(counter++)), counter)); inputLines.add(new VCFInfoHeaderLine(String.valueOf(counter++), VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.Integer, "x")); inputLines.add(new VCFInfoHeaderLine(String.valueOf(counter++), VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.Integer, "x")); inputLines.add(new VCFHeaderLine("x", "misc")); inputLines.add(new VCFHeaderLine("y", "misc")); inputLines.add(new VCFSimpleHeaderLine("GATKCommandLine","z","misc")); inputLines.add(new VCFFormatHeaderLine(String.valueOf(counter++), VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.Integer, "x")); inputLines.add(new VCFFormatHeaderLine(String.valueOf(counter++), VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.Integer, "x")); final int inputLineCounter = counter; final VCFHeader inputHeader = new VCFHeader(new LinkedHashSet<VCFHeaderLine>(inputLines)); final ArrayList<String> dict = BCF2Utils.makeDictionary(inputHeader); final int dict_size = dict.size(); Assert.assertEquals(7,dict_size); }