public static <T extends Locatable> void setIntervals(Configuration conf, List<T> intervals) { StringBuilder sb = new StringBuilder(); for (Iterator<T> it = intervals.iterator(); it.hasNext(); ) { Locatable l = it.next(); sb.append(String.format("%s:%d-%d", l.getContig(), l.getStart(), l.getEnd())); if (it.hasNext()) { sb.append(","); } } conf.set(INTERVALS_PROPERTY, sb.toString()); }
public static <T extends Locatable> void setIntervals(Configuration conf, List<T> intervals) { StringBuilder sb = new StringBuilder(); for (Iterator<T> it = intervals.iterator(); it.hasNext(); ) { Locatable l = it.next(); sb.append(String.format("%s:%d-%d", l.getContig(), l.getStart(), l.getEnd())); if (it.hasNext()) { sb.append(","); } } conf.set(INTERVALS_PROPERTY, sb.toString()); }
public static <T extends Locatable> void setIntervals(Configuration conf, List<T> intervals) { StringBuilder sb = new StringBuilder(); for (Iterator<T> it = intervals.iterator(); it.hasNext(); ) { Locatable l = it.next(); sb.append(String.format("%s:%d-%d", l.getContig(), l.getStart(), l.getEnd())); if (it.hasNext()) { sb.append(","); } } conf.set(INTERVALS_PROPERTY, sb.toString()); }
public Collection<T> getOverlapping(final Locatable key) { final List<T> result = new ArrayList<T>(); final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree != null) { final Iterator<IntervalTree.Node<T>> iterator = tree.overlappers(key.getStart(), key.getEnd()); while (iterator.hasNext()) { result.add(iterator.next().getValue()); } } return result; } /**
/** * @return number of bases of reference covered by this interval */ default int getLengthOnReference() { return CoordMath.getLength(getStart(), getEnd()); }
/** * Determines whether this interval contains the entire region represented by other * (in other words, whether it covers it). * * * @param other interval to check * @return true if this interval contains all of the base positions spanned by other, otherwise false */ default boolean contains(Locatable other) { return contigsMatch(other) && CoordMath.encloses(getStart(), getEnd(), other.getStart(), other.getEnd()); }
/** * Constructs an interval with the supplied {@link Locatable}. */ public Interval(final Locatable locatable) { this(locatable.getContig(), locatable.getStart(), locatable.getEnd()); }
/** * Determines whether this interval comes within {@code distance} of overlapping the provided locatable. * When distance = 0 this is equal to {@link #overlaps(Locatable)} * * @param other interval to check * @param distance how many bases may be between the two intervals for us to still consider them overlapping. * @return true if this interval overlaps other, otherwise false */ default boolean withinDistanceOf(Locatable other, int distance) { return contigsMatch(other) && CoordMath.overlaps(getStart(), getEnd(), other.getStart()-distance, other.getEnd()+distance); }
/** * @return number of bases of reference covered by this interval */ default int getLengthOnReference() { return CoordMath.getLength(getStart(), getEnd()); }
/** * Determines whether this interval contains the entire region represented by other * (in other words, whether it covers it). * * * @param other interval to check * @return true if this interval contains all of the base positions spanned by other, otherwise false */ default boolean contains(Locatable other) { return contigsMatch(other) && CoordMath.encloses(getStart(), getEnd(), other.getStart(), other.getEnd()); }
/** * Constructs an interval with the supplied {@link Locatable}. */ public Interval(final Locatable locatable) { this(locatable.getContig(), locatable.getStart(), locatable.getEnd()); }
/** * Test overlapping interval * @param key the Locatable * @return true if it contains an object overlapping the interval */ public boolean containsOverlapping(final Locatable key) { final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); return tree!=null && tree.overlappers(key.getStart(), key.getEnd()).hasNext(); }
public Collection<T> getOverlapping(final Locatable key) { final List<T> result = new ArrayList<T>(); final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree != null) { final Iterator<IntervalTree.Node<T>> iterator = tree.overlappers(key.getStart(), key.getEnd()); while (iterator.hasNext()) { result.add(iterator.next().getValue()); } } return result; } /**
/** * Determines whether this interval comes within {@code distance} of overlapping the provided locatable. * When distance = 0 this is equal to {@link #overlaps(Locatable)} * * @param other interval to check * @param distance how many bases may be between the two intervals for us to still consider them overlapping. * @return true if this interval overlaps other, otherwise false */ default boolean withinDistanceOf(Locatable other, int distance) { return contigsMatch(other) && CoordMath.overlaps(getStart(), getEnd(), other.getStart()-distance, other.getEnd()+distance); }
/** * Test overlapping interval * @param key the Locatable * @return true if it contains an object overlapping the interval */ public boolean containsOverlapping(final Locatable key) { final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); return tree!=null && tree.overlappers(key.getStart(), key.getEnd()).hasNext(); }
public Collection<T> getContained(final Locatable key) { final List<T> result = new ArrayList<T>(); final IntervalTree<T> tree = mSequenceMap.get(key.getContig()); if (tree != null) { final Iterator<IntervalTree.Node<T>> iterator = tree.overlappers(key.getStart(), key.getEnd()); while (iterator.hasNext()) { final IntervalTree.Node<T> node = iterator.next(); if (node.getStart() >= key.getStart() && node.getEnd() <= key.getEnd()) { result.add(node.getValue()); } } } return result; }
/** * Queries for records overlapping the {@link Locatable} specified. * Note that this method requires VCF files with an associated index. If no index exists a TribbleException will be thrown. * * @return non-null iterator over VariantContexts */ public CloseableIterator<VariantContext> query(final Locatable locatable) { return query(locatable.getContig(), locatable.getStart(), locatable.getEnd()); }
/** * Query the reader for a particular interval corresponding to a contig and a 1-based closed * * @param locus The locus to be queried * @return an iterator containing the features that at in the interval. * @throws IOException If there's a problem reading or if the reader is not queryable, e.g. if it doesn't have an index. */ default CloseableTribbleIterator<T> query(Locatable locus) throws IOException { return query(locus.getContig(), locus.getStart(), locus.getEnd()); }
/** * Queries for records overlapping the {@link Locatable} specified. * Note that this method requires VCF files with an associated index. If no index exists a TribbleException will be thrown. * * @return non-null iterator over VariantContexts */ public CloseableIterator<VariantContext> query(final Locatable locatable) { return query(locatable.getContig(), locatable.getStart(), locatable.getEnd()); }
/** * Query the reader for a particular interval corresponding to a contig and a 1-based closed * * @param locus The locus to be queried * @return an iterator containing the features that at in the interval. * @throws IOException If there's a problem reading or if the reader is not queryable, e.g. if it doesn't have an index. */ default CloseableTribbleIterator<T> query(Locatable locus) throws IOException { return query(locus.getContig(), locus.getStart(), locus.getEnd()); }