/** * Create the contigDictionary from the contigLines extracted from the VCF header * * @param contigLines */ private void createContigDictionary(final Collection<VCFContigHeaderLine> contigLines) { int offset = 0; for ( VCFContigHeaderLine contig : contigLines ) contigDictionary.put(contig.getID(), offset++); } }
/** * Create the contigDictionary from the contigLines extracted from the VCF header * * @param contigLines */ private void createContigDictionary(final Collection<VCFContigHeaderLine> contigLines) { int offset = 0; for ( VCFContigHeaderLine contig : contigLines ) contigDictionary.put(contig.getID(), offset++); } }
/** * Add a contig header line to the lookup list for contig lines (contigMetaData). If there's * already a contig line with the same ID, does not add the line. * * Note: does not add the contig line to the master list of header lines in mMetaData -- * this must be done separately if desired. * * @param line contig header line to add * @return true if line was added to the list of contig lines, otherwise false */ private boolean addContigMetaDataLineLookupEntry(final VCFContigHeaderLine line) { // if we are trying to add a contig for the same ID if (contigMetaData.containsKey(line.getID())) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Found duplicate VCF contig header lines for " + line.getID() + "; keeping the first only" ); } // do not add this contig if it exists return false; } contigMetaData.put(line.getID(), line); return true; }
/** * Add a contig header line to the lookup list for contig lines (contigMetaData). If there's * already a contig line with the same ID, does not add the line. * * Note: does not add the contig line to the master list of header lines in mMetaData -- * this must be done separately if desired. * * @param line contig header line to add * @return true if line was added to the list of contig lines, otherwise false */ private boolean addContigMetaDataLineLookupEntry(final VCFContigHeaderLine line) { // if we are trying to add a contig for the same ID if (contigMetaData.containsKey(line.getID())) { if ( GeneralUtils.DEBUG_MODE_ENABLED ) { System.err.println("Found duplicate VCF contig header lines for " + line.getID() + "; keeping the first only" ); } // do not add this contig if it exists return false; } contigMetaData.put(line.getID(), line); return true; }
/** * Create the contigDictionary from the contigLines extracted from the VCF header * * @param contigLines */ @Requires("contigDictionary.isEmpty()") private void createContigDictionary(final Collection<VCFContigHeaderLine> contigLines) { int offset = 0; for ( VCFContigHeaderLine contig : contigLines ) contigDictionary.put(contig.getID(), offset++); } }
/** * Returns true if the given header lines are from a file sorted according to this VariantContextComparator. * For sorting to work properly, the contig in each header line must have the same index. */ public boolean isCompatible(final Collection<VCFContigHeaderLine> headerLines) { for (final VCFContigHeaderLine headerLine : headerLines) { final Integer existingIndex = this.contigIndexLookup.get(headerLine.getID()); if (existingIndex == null || headerLine.getContigIndex() != existingIndex.intValue()) return false; } return true; } }
/** * Returns true if the given header lines are from a file sorted according to this VariantContextComparator. * For sorting to work properly, the contig in each header line must have the same index. */ public boolean isCompatible(final Collection<VCFContigHeaderLine> headerLines) { for (final VCFContigHeaderLine headerLine : headerLines) { final Integer existingIndex = this.contigIndexLookup.get(headerLine.getID()); if (existingIndex == null || headerLine.getContigIndex() != existingIndex.intValue()) return false; } return true; } }
/** * Returns true if the given header lines are from a file sorted according to this VariantContextComparator. * For sorting to work properly, the contig in each header line must have the same index. */ public boolean isCompatible(final Collection<VCFContigHeaderLine> headerLines) { for (final VCFContigHeaderLine headerLine : headerLines) { final Integer existingIndex = this.contigIndexLookup.get(headerLine.getID()); if (existingIndex == null || headerLine.getContigIndex() != existingIndex.intValue()) return false; } return true; } }
/** * Creates a VariantContextComparator from the given VCF contig header lines. The header lines' * index values are used to order the contigs. Throws IllegalArgumentException if there are dupe * */ public VariantContextComparator(final Collection<VCFContigHeaderLine> headerLines) { if (headerLines.isEmpty()) throw new IllegalArgumentException("One or more header lines must be in the header line collection."); final Map<String, Integer> protoContigIndexLookup = new HashMap<String, Integer>(); for (final VCFContigHeaderLine headerLine : headerLines) { protoContigIndexLookup.put(headerLine.getID(), headerLine.getContigIndex()); } if (protoContigIndexLookup.size() != headerLines.size()) { throw new IllegalArgumentException("There are duplicate contigs/chromosomes in the input header line collection."); } final Set<Integer> protoIndexValues = new HashSet<Integer>(protoContigIndexLookup.values()); if (protoIndexValues.size() != headerLines.size()) { throw new IllegalArgumentException("One or more contigs share the same index number."); } this.contigIndexLookup = Collections.unmodifiableMap(protoContigIndexLookup); }
/** * Creates a VariantContextComparator from the given VCF contig header lines. The header lines' * index values are used to order the contigs. Throws IllegalArgumentException if there are dupe * */ public VariantContextComparator(final Collection<VCFContigHeaderLine> headerLines) { if (headerLines.size() == 0) throw new IllegalArgumentException("One or more header lines must be in the header line collection."); final Map<String, Integer> protoContigIndexLookup = new HashMap<String, Integer>(); for (final VCFContigHeaderLine headerLine : headerLines) { protoContigIndexLookup.put(headerLine.getID(), headerLine.getContigIndex()); } if (protoContigIndexLookup.size() != headerLines.size()) { throw new IllegalArgumentException("There are duplicate contigs/chromosomes in the input header line collection."); } final Set<Integer> protoIndexValues = new HashSet<Integer>(protoContigIndexLookup.values()); if (protoIndexValues.size() != headerLines.size()) { throw new IllegalArgumentException("One or more contigs share the same index number."); } this.contigIndexLookup = Collections.unmodifiableMap(protoContigIndexLookup); }
/** * Creates a VariantContextComparator from the given VCF contig header lines. The header lines' * index values are used to order the contigs. Throws IllegalArgumentException if there are dupe * */ public VariantContextComparator(final Collection<VCFContigHeaderLine> headerLines) { if (headerLines.isEmpty()) throw new IllegalArgumentException("One or more header lines must be in the header line collection."); final Map<String, Integer> protoContigIndexLookup = new HashMap<String, Integer>(); for (final VCFContigHeaderLine headerLine : headerLines) { protoContigIndexLookup.put(headerLine.getID(), headerLine.getContigIndex()); } if (protoContigIndexLookup.size() != headerLines.size()) { throw new IllegalArgumentException("There are duplicate contigs/chromosomes in the input header line collection."); } final Set<Integer> protoIndexValues = new HashSet<Integer>(protoContigIndexLookup.values()); if (protoIndexValues.size() != headerLines.size()) { throw new IllegalArgumentException("One or more contigs share the same index number."); } this.contigIndexLookup = Collections.unmodifiableMap(protoContigIndexLookup); }
public SAMSequenceRecord getSAMSequenceRecord() { final String lengthString = this.getGenericFieldValue("length"); if (lengthString == null) throw new TribbleException("Contig " + this.getID() + " does not have a length field."); final SAMSequenceRecord record = new SAMSequenceRecord(this.getID(), Integer.valueOf(lengthString)); record.setSequenceIndex(this.contigIndex); return record; }
private void initContigDict() { final VCFHeader header = (VCFHeader)codec.readHeader(in).getHeaderValue(); contigDict.clear(); int i = 0; for (final VCFContigHeaderLine contig : header.getContigLines()) contigDict.put(contig.getID(), i++); }
private void initContigDict() { final VCFHeader header = (VCFHeader)codec.readHeader(in).getHeaderValue(); contigDict.clear(); int i = 0; for (final VCFContigHeaderLine contig : header.getContigLines()) contigDict.put(contig.getID(), i++); }
private void initContigDict() { final VCFHeader header = (VCFHeader)codec.readHeader(in).getHeaderValue(); contigDict.clear(); int i = 0; for (final VCFContigHeaderLine contig : header.getContigLines()) contigDict.put(contig.getID(), i++); }
public SAMSequenceRecord getSAMSequenceRecord() { final String lengthString = this.getGenericFieldValue("length"); if (lengthString == null) throw new TribbleException("Contig " + this.getID() + " does not have a length field."); final SAMSequenceRecord record = new SAMSequenceRecord(this.getID(), Integer.valueOf(lengthString)); record.setAssembly(this.getGenericFieldValue("assembly")); record.setSequenceIndex(this.contigIndex); return record; }
public SAMSequenceRecord getSAMSequenceRecord() { final String lengthString = this.getGenericFieldValue("length"); if (lengthString == null) throw new TribbleException("Contig " + this.getID() + " does not have a length field."); final SAMSequenceRecord record = new SAMSequenceRecord(this.getID(), Integer.valueOf(lengthString)); record.setAssembly(this.getGenericFieldValue("assembly")); record.setSequenceIndex(this.contigIndex); return record; }
/** * Initialization function that's used by all constructors * @param loaderJSONFile GenomicsDB loader JSON configuration file * @param queryJSONFile GenomicsDB query JSON configuration file * @param codec FeatureCodec, currently only {@link htsjdk.variant.bcf2.BCF2Codec} is tested * @throws IOException when data cannot be read from the stream */ public void initialize(final String loaderJSONFile, final String queryJSONFile, final FeatureCodec<T, SOURCE> codec) throws IOException { mCodec = codec; mLoaderJSONFile = loaderJSONFile; mQueryJSONFile = queryJSONFile; //Read header GenomicsDBQueryStream gdbStream = new GenomicsDBQueryStream(loaderJSONFile, queryJSONFile); SOURCE source = codec.makeSourceFromStream(gdbStream); mFCHeader = codec.readHeader(source); //Store sequence names mVCFHeader = (VCFHeader)(mFCHeader.getHeaderValue()); mSequenceNames = new ArrayList<String>(mVCFHeader.getContigLines().size()); for(final VCFContigHeaderLine contigHeaderLine : mVCFHeader.getContigLines()) mSequenceNames.add(contigHeaderLine.getID()); gdbStream.close(); }
contigIndexMap.put(vcfContig.getID(), vcfContig.getContigIndex());
contigIndexMap.put(vcfContig.getID(), vcfContig.getContigIndex());