/** * 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; } }
/** * Completely replaces the contig records in this header with those in the given SAMSequenceDictionary. */ public void setSequenceDictionary(final SAMSequenceDictionary dictionary) { this.contigMetaData.clear(); for (final SAMSequenceRecord record : dictionary.getSequences()) { contigMetaData.add(new VCFContigHeaderLine(record, null)); } this.mMetaData.addAll(contigMetaData); }
/** * Returns the contigs in this VCF file as a SAMSequenceDictionary. Returns null if contigs lines are * not present in the header. Throws SAMException if one or more contig lines do not have length * information. */ public SAMSequenceDictionary getSequenceDictionary() { final List<VCFContigHeaderLine> contigHeaderLines = this.getContigLines(); if (contigHeaderLines.isEmpty()) return null; final List<SAMSequenceRecord> sequenceRecords = new ArrayList<SAMSequenceRecord>(contigHeaderLines.size()); for (final VCFContigHeaderLine contigHeaderLine : contigHeaderLines) { sequenceRecords.add(contigHeaderLine.getSAMSequenceRecord()); } return new SAMSequenceDictionary(sequenceRecords); }
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; }
/** * 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++); } }
VCFContigHeaderLine contigHeaderLine = (VCFContigHeaderLine) headerLine; long length = contigHeaderLine.getSAMSequenceRecord().getSequenceLength(); GenomicsDBVidMapProto.Chromosome.Builder contigBuilder = GenomicsDBVidMapProto.Chromosome.newBuilder(); contigBuilder .setName(contigHeaderLine.getID()) .setLength(length) .setTiledbColumnOffset(columnOffset);
/** * 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++); } }
int end = 1000 * 1000 * 1000; // "some large number" for (VCFContigHeaderLine line : vcfHeader.getContigLines()) { if (line.getID().equals(itv.getContig())) end = line.getSAMSequenceRecord().getSequenceLength();
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; }
/** * 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; } }
/** * 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; }
private static VCFContigHeaderLine makeContigHeaderLine(final SAMSequenceRecord contig, final String assembly) { final Map<String, String> map = new LinkedHashMap<>(3); map.put("ID", contig.getSequenceName()); map.put("length", String.valueOf(contig.getSequenceLength())); if (assembly != null) map.put("assembly", assembly); return new VCFContigHeaderLine(map, contig.getSequenceIndex()); }
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; }
/** * Returns the contigs in this VCF file as a SAMSequenceDictionary. Returns null if contigs lines are * not present in the header. Throws SAMException if one or more contig lines do not have length * information. */ public SAMSequenceDictionary getSequenceDictionary() { final List<VCFContigHeaderLine> contigHeaderLines = this.getContigLines(); if (contigHeaderLines.isEmpty()) return null; final List<SAMSequenceRecord> sequenceRecords = new ArrayList<SAMSequenceRecord>(contigHeaderLines.size()); for (final VCFContigHeaderLine contigHeaderLine : contigHeaderLines) { sequenceRecords.add(contigHeaderLine.getSAMSequenceRecord()); } return new SAMSequenceDictionary(sequenceRecords); }
/** * 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; } }
/** * 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; }
private static VCFContigHeaderLine makeContigHeaderLine(final SAMSequenceRecord contig, final String assembly) { final Map<String, String> map = new LinkedHashMap<>(3); map.put("ID", contig.getSequenceName()); map.put("length", String.valueOf(contig.getSequenceLength())); if (assembly != null) map.put("assembly", assembly); return new VCFContigHeaderLine(map, contig.getSequenceIndex()); }
/** * Returns the contigs in this VCF file as a SAMSequenceDictionary. Returns null if contigs lines are * not present in the header. Throws SAMException if one or more contig lines do not have length * information. */ public SAMSequenceDictionary getSequenceDictionary() { final List<VCFContigHeaderLine> contigHeaderLines = this.getContigLines(); if (contigHeaderLines.isEmpty()) return null; final List<SAMSequenceRecord> sequenceRecords = new ArrayList<SAMSequenceRecord>(contigHeaderLines.size()); for (final VCFContigHeaderLine contigHeaderLine : contigHeaderLines) { sequenceRecords.add(contigHeaderLine.getSAMSequenceRecord()); } return new SAMSequenceDictionary(sequenceRecords); }
/** * 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); }
/** * 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++); } }