public class Location extends Object implements Iterable<Location>
Constructor and Description |
---|
Location(int start,
int end)
Construct new location from coordinates.
|
Location(Location other)
Clone other location.
|
Modifier and Type | Method and Description |
---|---|
int |
bioEnd()
Get end index, in biocoordinates.
|
int |
bioStart()
Get start index, in biocoordinates.
|
char |
bioStrand()
Get character representation of strand.
|
boolean |
contains(Location other)
Check if this location contains the other.
|
int |
distance(Location other)
Return distance between this location and the other location.
|
Location |
downstream(int length)
Return the adjacent location of specified length directly downstream of this location.
|
int |
end()
Get the ending index.
|
boolean |
endsAfter(Location other)
Check if this location ends after other location ends.
|
boolean |
endsBefore(Location other)
Check if this location ends before other location ends.
|
boolean |
equals(Object obj) |
static Location |
fromBio(int start,
int end,
char strand)
Create location from "biocoordinates", as in GFF file.
|
static Location |
fromBioExt(int start,
int length,
char strand,
int totalLength)
Create a location from MAF file coordinates, which represent negative
strand locations as the distance from the end of the sequence.
|
int |
getBegin() |
int |
getEnd() |
int |
hashCode() |
Location |
intersection(Location other)
Return the intersection, or null if no overlap.
|
boolean |
isAfter(Location other)
Check if this location is entirely after the other location (no overlap).
|
boolean |
isBefore(Location other)
Check if this location is entirely before other location (no overlap).
|
boolean |
isNegative()
Check if location is on negative strand.
|
boolean |
isSameStrand(Location other)
Check if this location is on same strand as other location.
|
LocIterator |
iterator()
Create a location iterator over this location with a window size of 1 and
an increment of +1 (successive symbols from start to end).
|
LocIterator |
iterator(int windowSize,
int increment)
Create a location iterator over this location,
using specified window size and increment.
|
int |
length()
Get length of range.
|
Location |
minus()
Return location that is in same position on negative strand.
|
Location |
opposite()
Return location that is in same position on opposite strand.
|
boolean |
overlaps(Location other)
Check if this location and other location overlap.
|
double |
percentOverlap(Location other)
Return percent overlap of two locations.
|
Location |
plus()
Return location that is in same position on plus strand.
|
Location |
prefix(int position)
The part of this location before the specified position.
|
Location |
prefix(Location other)
The part of this location before the other location (not inclusive).
|
int |
start()
Get starting index (origin 0).
|
boolean |
startsAfter(Location other)
Check if this location starts after the other location starts.
|
boolean |
startsBefore(Location other)
Check if this location starts before other location starts.
|
Location |
suffix(int position)
The part of this location after the specified position.
|
Location |
suffix(Location other)
The part of this location after the other location (not inclusive).
|
String |
toString()
Return a string representation of location.
|
Location |
union(Location other)
Return the union.
|
Location |
upstream(int length)
Return the adjacent location of specified length directly upstream of this location.
|
Iterable<Location> |
window(int windowSize,
int increment)
Enable a "sliding window" iteration over a location
to use with Java's "for" loop construct.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public Location(int start, int end)
start
- Origin 0 index of first symbol.end
- Origin 0 index of last symbol + 1.IllegalArgumentException
- End is not after start, or location spans the originpublic int getBegin()
public int getEnd()
public static Location fromBio(int start, int end, char strand)
start
- Origin 1 index of first symbol.end
- Origin 1 index of last symbol.strand
- '+' or '-' or '.' ('.' is interpreted as '+').IllegalArgumentException
- strand must be '+', '-' or '.'public static Location fromBioExt(int start, int length, char strand, int totalLength)
start
- Origin 1 index of first symbol.length
- Number of symbols in range.strand
- '+' or '-' or '.' ('.' is interpreted as '+').totalLength
- Total number of symbols in sequence.IllegalArgumentException
- Strand must be '+', '-', '.'public char bioStrand()
public int bioStart()
public int bioEnd()
public Location plus()
public Location minus()
public Location union(Location other)
other
- The location to join.IllegalArgumentException
- Locations are on opposite strands.public Location intersection(Location other)
other
- The location to intersect.IllegalArgumentException
- Locations are on opposite strands.public int start()
public int end()
public int length()
public Iterable<Location> window(int windowSize, int increment)
//use window size of 3 and increment of +3 for( Location temp: loc.window( 3, 3 )) { //at each iteration, temp will be the location of the next 3 symbols }
windowSize
- The number of symbols to get on each iteration.increment
- The direction and number of symbols to advance at each iteration.public LocIterator iterator()
public LocIterator iterator(int windowSize, int increment)
windowSize
- The number of symbols to get on each iteration.increment
- The direction and number of symbols to advance at each iteration.public Location prefix(int position)
position
- Where the prefix ends.IndexOutOfBoundsException
- Specified prefix is longer than location.public Location suffix(int position)
position
- Where the suffix starts.IndexOutOfBoundsException
- Specified suffix is longer than location.public Location prefix(Location other)
other
- The other location.IllegalArgumentException
- Locations are on opposite strands.IndexOutOfBoundsException
- This location does not contain other location.public Location suffix(Location other)
other
- The other location.IllegalArgumentException
- Locations are on opposite strands.IndexOutOfBoundsException
- This location does not contain other location.public Location upstream(int length)
length
- The length of the upstream location.IndexOutOfBoundsException
- Specified length causes crossing of origin.public Location downstream(int length)
length
- The length of the downstream location.IndexOutOfBoundsException
- Specified length causes crossing of origin.public int distance(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public double percentOverlap(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean overlaps(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean contains(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean startsAfter(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean startsBefore(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean endsAfter(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean endsBefore(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean isAfter(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean isBefore(Location other)
other
- The location to compare.IllegalArgumentException
- Locations are on opposite strands.public boolean isNegative()
public Location opposite()
public boolean isSameStrand(Location other)
other
- The location to compare.Copyright © 2000–2018 BioJava. All rights reserved.