Package htsjdk.samtools.util
Class OverlapDetector<T>
java.lang.Object
htsjdk.samtools.util.OverlapDetector<T>
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
ConstructorDescriptionOverlapDetector
(int lhsBuffer, int rhsBuffer) Constructs an overlap detector. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds all items to the overlap detector.void
Adds a Locatable to the set of Locatables against which to match candidates.static <T extends Locatable>
OverlapDetector<T>Creates a new OverlapDetector with no trim and the given set of intervals.getAll()
Gets all the objects that could be returned by the overlap detector.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 Details
-
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 Details
-
create
Creates a new OverlapDetector with no trim and the given set of intervals. -
addLhs
Adds a Locatable to the set of Locatables against which to match candidates. -
addAll
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. -
getAll
Gets all the objects that could be returned by the overlap detector. -
overlapsAny
Returns true iff the given locatable overlaps any locatable in this detector. This is a performance shortcut API functionally equivalent to:! getOverlaps(locatable).isEmpty()
-
getOverlaps
Gets the Set of objects that overlap the provided locatable. The returned set may not be modifiable.
-