org.biojava.bio.symbol
Class CompoundLocation

java.lang.Object
  |
  +--org.biojava.bio.symbol.CompoundLocation

public class CompoundLocation
extends java.lang.Object
implements Location, java.io.Serializable

A complex location. It is made up from multiple sub-locations and is essentially the point-wise union of the child locations.

Currently this is implemented very badly. I need a maths person to look over it, and sort stuff out.

Author:
Matthew Pocock, Thomas Down
See Also:
Serialized Form

Inner classes inherited from class org.biojava.bio.symbol.Location
Location.EmptyLocation, Location.LocationComparator
 
Fields inherited from interface org.biojava.bio.symbol.Location
empty, naturalOrder
 
Constructor Summary
CompoundLocation(java.util.List locs)
          Generate a new CompoundLocation from a list of locations.
 
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.
 java.lang.String toString()
           
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundLocation

public CompoundLocation(java.util.List locs)
Generate a new CompoundLocation from a list of locations.

The generated location will contain exactly those points that are within at least one of the Locations in the list.

Parameters:
locations - a list of Location instances to combine into a single compound location
Method Detail

contains

public boolean contains(int p)
Description copied from interface: Location
Checks if this location contains a point.
Specified by:
contains in interface Location
Tags copied from interface: Location
Parameters:
p - the point to check
Returns:
true if this contains p, otherwise false

contains

public boolean contains(Location l)
Description copied from interface: Location
Checks if this location contains the other.

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

Specified by:
contains in interface Location
Tags copied from interface: Location
Parameters:
l - the Location to check
Returns:
true if this contains l, otherwise false

overlaps

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

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

Specified by:
overlaps in interface Location
Tags copied from interface: Location
Parameters:
l - the Location to check
Returns:
true if they overlap, otherwise false

equals

public boolean equals(java.lang.Object l)
Description copied from interface: Location
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).

Specified by:
equals in interface Location
Overrides:
equals in class java.lang.Object
Tags copied from interface: Location
Parameters:
l - the Object to check
Returns:
true if this equals l, otherwise false

getMin

public int getMin()
Description copied from interface: Location
The minimum position contained.
Specified by:
getMin in interface Location
Tags copied from interface: Location
Returns:
the minimum position contained

getMax

public int getMax()
Description copied from interface: Location
The maximum position contained.
Specified by:
getMax in interface Location
Tags copied from interface: Location
Returns:
the maximum position contained

intersection

public Location intersection(Location l)
Description copied from interface: Location
Returns a Location that contains all points common to both ranges.
Specified by:
intersection in interface Location
Tags copied from interface: Location
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)
Description copied from interface: Location
Return a Loctaion containing all points in either ranges.
Specified by:
union in interface Location
Tags copied from interface: Location
Parameters:
l - the Location to union with
Returns:
a Location representing the union

symbols

public SymbolList symbols(SymbolList seq)
Description copied from interface: Location
Return the symbols in a sequence that fall within this range.
Specified by:
symbols in interface Location
Tags copied from interface: Location
Parameters:
seq - the SymbolList to process
Returns:
the SymbolList containing the symbols in seq in this range

translate

public Location translate(int dist)
Description copied from interface: Location
Create a location that is a translation of this location.
Specified by:
translate in interface Location
Tags copied from interface: Location
Parameters:
dist - the distance to translate (to the right)

isContiguous

public boolean isContiguous()
Description copied from interface: Location
Determine if a Location is contiguous.
Specified by:
isContiguous in interface Location
Tags copied from interface: Location
Returns:
true if and only if this Location contains every point from min to max inclusive.

blockIterator

public java.util.Iterator blockIterator()
Description copied from interface: Location
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.

Specified by:
blockIterator in interface Location
Tags copied from interface: Location
Returns:
an Iterator over Location objects that are the maximaly contiguous set of locations contained within this location

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object