LocationTools (BioJava-1.5-beta API)
Keywords: org.biojava.bio.symbol.LocationTools class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojava.bio.symbol
Class LocationTools

    java.lang.Object
      org.biojava.bio.symbol.LocationTools

    public final class LocationTools

extends Object

Tools class containing a number of operators for working with `Location` objects.

Most of the methods in this class are simple set-wise binary operators: for example, calculate the intersection of two locations.

Since:
  1.2
Author:
  Matthew Pocock, Greg Cox, Thomas Down, Mark Schreiber, Francois Pepin
For general use:
  This class provides helpful methods for set-wise manipulation of Location objects.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### union

    public static Location union(Location locA,
                                 Location locB)

  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 Location
    `locB` - the second Location
  Returns:
    a Location that is the union of locA and locB

### intersection

    public static Location intersection(Location locA,
                                        Location locB)

  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 Location
    `locB` - the second Location
  Returns:
    a Location that is the intersection of locA and locB

### canMerge

    public static boolean canMerge(Location locA,
                                   Location locB)

  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 Location
    `locB` - the second Location
  Returns:
    `true` if they can merge, `false` otherwise

### overlaps

    public static boolean overlaps(Location locA,
                                   Location locB)

  Determines whether the locations overlap or not.

  Two locations overlap if they contain at least one index in common.

  Parameters:
    `locA` - the first Location
    `locB` - the second Location
  Returns:
    `true` if they overlap, `false` otherwise

### contains

    public static boolean contains(Location locA,
                                   Location locB)

  Return `true` iff all indices in `locB` are also contained by `locA`.

  Parameters:
    `locA` - The containing location
    `locB` - The contained location
  Returns:
    `true` is locA contains locB

### areEqual

    public static boolean areEqual(Location locA,
                                   Location locB)

  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 Location
    `locB` - the second Location
  Returns:
    true if they are equivalent, false otherwise

### union

    public static Location union(Collection locs)

  The n-way union of a Collection of locations. Returns a Location which covers every point covered by at least one of the locations in `locs`

  Parameters:
    `locs` - A collection of locations.
  Returns:
    A union location
  Throws:
    `ClassCastException` - if the collection contains non-Location objects.

### makeLocation

    public static Location makeLocation(int min,
                                        int max)

  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 value
    `max` - the Location max value
  Returns:
    a new Location from min to max

### makeCircularLocation

    public static CircularLocation makeCircularLocation(int min,
                                                        int max,
                                                        int seqLength)

  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 location
    `max` - the "right" end of the location
    `seqLength` - the lenght of the sequence that the location will be applied to (for purposes of determining origin).
  Returns:
    the new `CircularLocation`

### flip

    public static Location flip(Location loc,
                                int len)

  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 flip
    `len` - the length of the region to flip within
  Returns:
    a flipped view of the location

### subtract

    public static Location subtract(Location keep,
                                    Location remove)

  Subtract one location from another. This methods calculates the set of points which are contains in location `keep` but not in `remove`.

  Parameters:
    `keep` - A location
    `remove` - A location
  Returns:
    a location containing all points which are in x but not y
  Since:
    1.3

### coverage

    public static int coverage(Location loc)

  Return the number of positions which are covered by a `Location`

  Parameters:
    `loc` - A location
  Returns:
    the number of distinct points contained by that location
  Since:
    1.4

### shadow

    public static Location shadow(Location loc)

  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

    public static int blockCount(Location loc)

  Return the number of contiguous blocks in a location.

  Parameters:
    `loc` - a location
  Returns:
    the number of blocks
  Since:
    1.4

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD