org.biojava.bio.symbol
Interface Location

All Known Implementing Classes:
CompoundLocation, PointLocation, RangeLocation, Location.EmptyLocation

public interface Location

A biological location.

The location will contain some symbols between getMin and getMax inclusive. It is not required to contain all locations within this range. It is meant to contain getMin or getMax. In the event that an operation would produce an invalid or nonsensical range, empty should be returned.

Location objects are always immutable.

Author:
Matthew Pocock, Thomas Down

Inner Class Summary
static class Location.EmptyLocation
          The implementation of Location that contains no positions at all.
static class Location.LocationComparator
           
 
Field Summary
static Location empty
          The empty range.
static Location.LocationComparator naturalOrder
           
 
Method Summary
 java.util.Iterator blockIterator()
          Return an Iterator over the set of maximal contiguous sub-locations.
 boolean contains(int p)
          Checks if this location contains a point.
 boolean contains(Location l)
          Checks if this location contains the other.
 boolean equals(java.lang.Object l)
          Checks if this location is equivalent to the other.
 int getMax()
          The maximum position contained.
 int getMin()
          The minimum position contained.
 Location intersection(Location l)
          Returns a Location that contains all points common to both ranges.
 boolean isContiguous()
          Determine if a Location is contiguous.
 boolean overlaps(Location l)
          Checks if these two locations overlap, using this locations's concept of overlaping.
 SymbolList symbols(SymbolList seq)
          Return the symbols in a sequence that fall within this range.
 Location translate(int dist)
          Create a location that is a translation of this location.
 Location union(Location l)
          Return a Loctaion containing all points in either ranges.
 

Field Detail

empty

public static final Location empty
The empty range.

This object contains nothing. Its minimum value is Integer.MAX_VALUE. Its maximum value is Integer.MIN_VALUE. It overlaps nothing. It is equal to nothing. Intersection results in the empty range. Union results in the argument range. Symbols returns an empty array.

Every day, in every way, empty becomes more and more boring.


naturalOrder

public static final Location.LocationComparator naturalOrder
Method Detail

getMin

public int getMin()
The minimum position contained.
Returns:
the minimum position contained

getMax

public int getMax()
The maximum position contained.
Returns:
the maximum position contained

overlaps

public boolean overlaps(Location l)
Checks if these two locations overlap, using this locations's concept of overlaping.

Abstractly, two locations overlap if they both contain any point.

Parameters:
l - the Location to check
Returns:
true if they overlap, otherwise false

contains

public boolean contains(Location l)
Checks if this location contains the other.

Abstractly, a location contains another if every point in the other location is contained within this one.

Parameters:
l - the Location to check
Returns:
true if this contains l, otherwise false

contains

public boolean contains(int p)
Checks if this location contains a point.
Parameters:
p - the point to check
Returns:
true if this contains p, otherwise false

equals

public boolean equals(java.lang.Object l)
Checks if this location is equivalent to the other.

Abstractly, a location is equal to another if for every point in one it is also in the other. This is equivalent to a.contains(b) && b.contains(a).

Overrides:
equals in class java.lang.Object
Parameters:
l - the Object to check
Returns:
true if this equals l, otherwise false

intersection

public Location intersection(Location l)
Returns a Location that contains all points common to both ranges.
Parameters:
l - the Location to intersect with
Returns:
a Location containing all points common to both, or the empty range if there are no such points

union

public Location union(Location l)
Return a Loctaion containing all points in either ranges.
Parameters:
l - the Location to union with
Returns:
a Location representing the union

symbols

public SymbolList symbols(SymbolList seq)
Return the symbols in a sequence that fall within this range.
Parameters:
seq - the SymbolList to process
Returns:
the SymbolList containing the symbols in seq in this range

translate

public Location translate(int dist)
Create a location that is a translation of this location.
Parameters:
dist - the distance to translate (to the right)

isContiguous

public boolean isContiguous()
Determine if a Location is contiguous.
Returns:
true if and only if this Location contains every point from min to max inclusive.

blockIterator

public java.util.Iterator blockIterator()
Return an Iterator over the set of maximal contiguous sub-locations.

Given any location, it can be considered to contain zero or more maximal contiguous blocks of width 1 or greater. The empty location is composed from nothing. A contiguous location is composed from itself. A non-contiguous location is composed from contiguous blocks seperated by gaps.

This method should return an Iterator over these maximally contiguous blocks starting with the left-most block, and finnishing at the right-most block.

Returns:
an Iterator over Location objects that are the maximaly contiguous set of locations contained within this location