Class LocationTools
Location objects.
Most of the methods in this class are simple set-wise binary operators: for example, calculate the intersection of two locations.
This class provides helpful methods for set-wise manipulation of Location objects.- Since:
- 1.2
- Author:
- Matthew Pocock, Greg Cox, Thomas Down, Mark Schreiber, Francois Pepin
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturn whether two locations are equal.static intblockCount(Location loc) Return the number of contiguous blocks in a location.static booleanDetermines whether the locations are touching or not (if they could be merged in a single Location.static booleanReturntrueiff all indices inlocBare also contained bylocA.static intReturn the number of positions which are covered by aLocationstatic LocationFlips a location relative to a length.static Locationintersection(Location locA, Location locB) Return the intersection of two locations.static CircularLocationmakeCircularLocation(int min, int max, int seqLength) A simple method to generate a RangeLocation wrapped in a CircularLocation.static LocationmakeLocation(int min, int max) Return a contiguous Location from min to max.static booleanDetermines whether the locations overlap or not.static LocationReturn a contiguous location running from the minimum to the maximum points of the specified location.static LocationSubtract one location from another.static Locationunion(Collection locs) The n-way union of a Collection of locations.static LocationReturn the union of two locations.
-
Method Details
-
union
Return the union of two locations.The union will be a Location instance that contains every index contained by either locA or locB.
- Parameters:
locA- the first LocationlocB- the second Location- Returns:
- a Location that is the union of locA and locB
-
intersection
Return the intersection of two locations.The intersection will be a Location instance that contains every index contained by both locA and locB.
- Parameters:
locA- the first LocationlocB- the second Location- Returns:
- a Location that is the intersection of locA and locB
-
canMerge
Determines whether the locations are touching or not (if they could be merged in a single Location.Two locations can merge if they contain at least one index of one beside one index of the other.
- Parameters:
locA- the first LocationlocB- the second Location- Returns:
trueif they can merge,falseotherwise
-
overlaps
Determines whether the locations overlap or not.Two locations overlap if they contain at least one index in common.
- Parameters:
locA- the first LocationlocB- the second Location- Returns:
trueif they overlap,falseotherwise
-
contains
Returntrueiff all indices inlocBare also contained bylocA.- Parameters:
locA- The containing locationlocB- The contained location- Returns:
trueis locA contains locB
-
areEqual
Return whether two locations are equal.They are equal if both a contains b and b contains a. Equivalently, they are equal if for every point p, locA.contains(p) == locB.contains(p).
- Parameters:
locA- the first LocationlocB- the second Location- Returns:
- true if they are equivalent, false otherwise
-
union
The n-way union of a Collection of locations. Returns a Location which covers every point covered by at least one of the locations inlocs- Parameters:
locs- A collection of locations.- Returns:
- A union location
- Throws:
ClassCastException- if the collection contains non-Location objects.
-
makeLocation
Return a contiguous Location from min to max.If min == max then a PointLocation will be made, otherwise, a RangeLocation will be returned.
- Parameters:
min- the Location min valuemax- the Location max value- Returns:
- a new Location from min to max
-
makeCircularLocation
A simple method to generate a RangeLocation wrapped in a CircularLocation. The method will cope with situtations where the min is greater than the max. Either of min or max can be negative, or greater than the underlying sequence length. If min and max are equal a wrapped point location will be made.- Parameters:
min- the "left" end of the locationmax- the "right" end of the locationseqLength- the lenght of the sequence that the location will be applied to (for purposes of determining origin).- Returns:
- the new
CircularLocation
-
flip
Flips a location relative to a length.It is very common in biological sequences to represent locations on a sequence and then reverse that sequence. This method allows locations in the original coordinate space to be transformed int locations in the reverse one.
- Parameters:
loc- the Location to fliplen- the length of the region to flip within- Returns:
- a flipped view of the location
-
subtract
Subtract one location from another. This methods calculates the set of points which are contains in locationkeepbut not inremove.- Parameters:
keep- A locationremove- A location- Returns:
- a location containing all points which are in x but not y
- Since:
- 1.3
-
coverage
Return the number of positions which are covered by aLocation- Parameters:
loc- A location- Returns:
- the number of distinct points contained by that location
- Since:
- 1.4
-
shadow
Return a contiguous location running from the minimum to the maximum points of the specified location.- Parameters:
loc- a location- Returns:
- a corresponding contiguous location
-
blockCount
Return the number of contiguous blocks in a location.- Parameters:
loc- a location- Returns:
- the number of blocks
- Since:
- 1.4
-