Package htsjdk.samtools.util
Class OverlapDetector<T>
- java.lang.Object
-
- htsjdk.samtools.util.OverlapDetector<T>
-
public class OverlapDetector<T> extends Object
Utility class to efficiently do in memory overlap detection between a large set of mapping like objects, and one or more candidate mappings. You can use it for example to detect all locatables overlapping a given set of locatables:OverlapDetector<Locatable> detector = OverlapDetector.create(locatables); Set<Locatable> overlaps = detector.getOverlaps(query); boolean anyOverlap = detector.overlapsAny(query); //faster API for checking presence of any overlap
-
-
Constructor Summary
Constructors Constructor Description OverlapDetector(int lhsBuffer, int rhsBuffer)
Constructs an overlap detector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(List<T> objects, List<? extends Locatable> intervals)
Adds all items to the overlap detector.void
addLhs(T object, Locatable interval)
Adds a Locatable to the set of Locatables against which to match candidates.static <T extends Locatable>
OverlapDetector<T>create(List<T> intervals)
Creates a new OverlapDetector with no trim and the given set of intervals.Set<T>
getAll()
Gets all the objects that could be returned by the overlap detector.Set<T>
getOverlaps(Locatable locatable)
Gets the Set of objects that overlap the provided locatable.boolean
overlapsAny(Locatable locatable)
Returns true iff the given locatable overlaps any locatable in this detector.
-
-
-
Constructor Detail
-
OverlapDetector
public OverlapDetector(int lhsBuffer, int rhsBuffer)
Constructs an overlap detector.- Parameters:
lhsBuffer
- the amount by which to "trim" coordinates of mappings on the left hand side when calculating overlapsrhsBuffer
- the amount by which to "trim" coordinates of mappings on the right hand side when calculating overlaps
-
-
Method Detail
-
create
public static <T extends Locatable> OverlapDetector<T> create(List<T> intervals)
Creates a new OverlapDetector with no trim and the given set of intervals.
-
addLhs
public void addLhs(T object, Locatable interval)
Adds a Locatable to the set of Locatables against which to match candidates.
-
addAll
public void addAll(List<T> objects, List<? extends Locatable> intervals)
Adds all items to the overlap detector. The order of the lists matters only in the sense that it needs to be the same for the intervals and the corresponding objects.
-
overlapsAny
public boolean overlapsAny(Locatable locatable)
Returns true iff the given locatable overlaps any locatable in this detector. This is a performance shortcut API functionally equivalent to:! getOverlaps(locatable).isEmpty()
-
-