/** * Gets the name of the sequence on which the interval resides. * This is a simple alias of getContig() * * @deprecated use getContig() instead */ @Deprecated public String getSequence() { return getContig(); }
private void advanceInterval() { if (intervals.hasNext()) { currentInterval = intervals.next(); currentSequenceIndex = samHeader.getSequenceIndex(currentInterval.getContig()); } else { currentInterval = null; } }
@Override public int hashCode() { int result = getContig().hashCode(); result = 31 * result + getStart(); result = 31 * result + getEnd(); return result; }
/** * Tests whether the variant is within one of the pseudo-autosomal regions */ private boolean isInPseudoAutosomalRegion(final String chr, final int pos) { for (final Interval par : parIntervals) { if (par.getContig().equals(chr) && pos >= par.getStart() && pos <= par.getEnd()) return true; } return false; }
/** * Tests whether the variant is within one of the pseudo-autosomal regions */ private boolean isInPseudoAutosomalRegion(final String chr, final int pos) { for (final Interval par : parIntervals) { if (par.getContig().equals(chr) && pos >= par.getStart() && pos <= par.getEnd()) return true; } return false; }
public T remove(final Interval key) { final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree == null) { return null; } return tree.remove(key.getStart(), key.getEnd()); }
public T remove(final Interval key) { final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree == null) { return null; } return tree.remove(key.getStart(), key.getEnd()); }
/** If the current iterator is null or exhausted, move to the next interval. */ private void advance() { while ((currentIterator == null || !currentIterator.hasNext()) && this.intervals.hasNext()) { if (currentIterator != null) currentCloseableIterator.close(); final Interval interval = this.intervals.next(); final Interval previousInterval = this.lastInterval; this.currentCloseableIterator = this.reader.query(interval.getContig(), interval.getStart(), interval.getEnd()); this.currentIterator = this.currentCloseableIterator.stream().filter ( ctx -> null == previousInterval || !overlapsInterval(ctx, previousInterval) ).iterator(); this.lastInterval = interval; } }
/** * Returns a new interval that is padded by the amount of bases specified on either side. */ public Interval pad(final int left, final int right) { return new Interval(this.getContig(), this.getStart() - left, this.getEnd() + right, this.negativeStrand, this.name); }
/** * Returns a new interval that is padded by the amount of bases specified on either side. */ public Interval pad(final int left, final int right) { return new Interval(this.getContig(), this.getStart() - left, this.getEnd() + right, this.negativeStrand, this.name); }
public T get(final Interval key) { final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree == null) { return null; } final IntervalTree.Node<T> node = tree.find(key.getStart(), key.getEnd()); if (node == null) { return null; } return node.getValue(); }
/** * Returns a new Interval that represents the intersection between the two intervals. */ public Interval intersect(final Interval that) { if (!intersects(that)) throw new IllegalArgumentException(that + " does not intersect " + this); return new Interval(this.getContig(), Math.max(this.getStart(), that.getStart()), Math.min(this.getEnd(), that.getEnd()), this.negativeStrand, this.name + " intersection " + that.name); }
private static Interval lookupIntervalContainingLocus(final IntervalList source, final String chromosome, final int startIndex) { for (final Interval interval : source) { if (interval.getContig().equals(chromosome) && startIndex >= interval.getStart() && startIndex <= interval.getEnd()) { return interval; } } throw new NoSuchElementException(); } }
/** Returns true if the variant and interval overlap. */ private boolean overlapsInterval(final VariantContext ctx, final Interval interval) { if (!ctx.getContig().equals(interval.getContig())) return false; else if (CoordMath.overlaps(ctx.getStart(), ctx.getEnd(), interval.getStart(), interval.getEnd())) return true; else return false; }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }