public final class LocationTools extends Object
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.Modifier and Type | Method and Description |
---|---|
static boolean |
areEqual(Location locA,
Location locB)
Return whether two locations are equal.
|
static int |
blockCount(Location loc)
Return the number of contiguous blocks in a location.
|
static boolean |
canMerge(Location locA,
Location locB)
Determines whether the locations are touching or not (if they could be
merged in a single Location.
|
static boolean |
contains(Location locA,
Location locB)
Return
true iff all indices in locB are also contained
by locA . |
static int |
coverage(Location loc)
Return the number of positions which are covered by a
Location |
static Location |
flip(Location loc,
int len)
Flips a location relative to a length.
|
static Location |
intersection(Location locA,
Location locB)
Return the intersection of two locations.
|
static CircularLocation |
makeCircularLocation(int min,
int max,
int seqLength)
A simple method to generate a RangeLocation wrapped
in a CircularLocation.
|
static Location |
makeLocation(int min,
int max)
Return a contiguous Location from min to max.
|
static boolean |
overlaps(Location locA,
Location locB)
Determines whether the locations overlap or not.
|
static Location |
shadow(Location loc)
Return a contiguous location running from the minimum to the maximum points of
the specified location.
|
static Location |
subtract(Location keep,
Location remove)
Subtract one location from another.
|
static Location |
union(Collection locs)
The n-way union of a Collection of locations.
|
static Location |
union(Location locA,
Location locB)
Return the union of two locations.
|
public static Location union(Location locA, Location locB)
The union will be a Location instance that contains every index contained by either locA or locB.
locA
- the first LocationlocB
- the second Locationpublic static Location intersection(Location locA, Location locB)
The intersection will be a Location instance that contains every index contained by both locA and locB.
locA
- the first LocationlocB
- the second Locationpublic static boolean canMerge(Location locA, Location locB)
Two locations can merge if they contain at least one index of one beside one index of the other.
locA
- the first LocationlocB
- the second Locationtrue
if they can merge, false
otherwisepublic static boolean overlaps(Location locA, Location locB)
Two locations overlap if they contain at least one index in common.
locA
- the first LocationlocB
- the second Locationtrue
if they overlap, false
otherwisepublic static boolean contains(Location locA, Location locB)
true
iff all indices in locB
are also contained
by locA
.locA
- The containing locationlocB
- The contained locationtrue
is locA contains locBpublic static boolean areEqual(Location locA, Location locB)
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).
locA
- the first LocationlocB
- the second Locationpublic static Location union(Collection locs)
locs
locs
- A collection of locations.ClassCastException
- if the collection contains non-Location objects.public static Location makeLocation(int min, int max)
If min == max then a PointLocation will be made, otherwise, a RangeLocation will be returned.
min
- the Location min valuemax
- the Location max valuepublic static CircularLocation makeCircularLocation(int min, int max, int seqLength)
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).CircularLocation
public static Location flip(Location loc, int len)
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.
loc
- the Location to fliplen
- the length of the region to flip withinpublic static Location subtract(Location keep, Location remove)
keep
but not in
remove
.keep
- A locationremove
- A locationpublic static int coverage(Location loc)
Location
loc
- A locationpublic static Location shadow(Location loc)
loc
- a locationpublic static int blockCount(Location loc)
loc
- a locationCopyright © 2014 BioJava. All rights reserved.