org.biojava.bio.symbol
Class FuzzyLocation

java.lang.Object
  extended by org.biojava.bio.symbol.AbstractLocation
      extended by org.biojava.bio.symbol.AbstractRangeLocation
          extended by org.biojava.bio.symbol.FuzzyLocation
All Implemented Interfaces:
Serializable, Location

public class FuzzyLocation
extends AbstractRangeLocation
implements Serializable

A 'fuzzy' location a-la Embl fuzzy locations.

Fuzzy locations have propreties that indicate that they may start before min and end after max. However, this in no way affects how they interact with other locations.

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

Nested Class Summary
static interface FuzzyLocation.RangeResolver
          Determines how a FuzzyLocation should be treated when used as a normal Location.
 
Field Summary
static FuzzyLocation.RangeResolver RESOLVE_AVERAGE
          Use the arithmetic mean of the `inner' and `outer' values, unless the outer value is unbounded.
static FuzzyLocation.RangeResolver RESOLVE_INNER
          Always use the `inner' values.
static FuzzyLocation.RangeResolver RESOLVE_OUTER
          Use the `outer' values, unless they are unbounded in which case the `inner' values are used.
 
Fields inherited from interface org.biojava.bio.symbol.Location
empty, full, naturalOrder
 
Constructor Summary
FuzzyLocation(int outerMin, int outerMax, int innerMin, int innerMax, boolean isMinFuzzy, boolean isMaxFuzzy, FuzzyLocation.RangeResolver resolver)
          Create a new FuzzyLocation with endpoints (outerMin.innerMin) and (innerMax.outerMax).
FuzzyLocation(int outerMin, int outerMax, int innerMin, int innerMax, FuzzyLocation.RangeResolver resolver)
          Create a new FuzzyLocation with endpoints (outerMin.innerMin) and (innerMax.outerMax).
 
Method Summary
 int getInnerMax()
           
 int getInnerMin()
           
 int getMax()
          The maximum position contained.
 int getMin()
          The minimum position contained.
 int getOuterMax()
           
 int getOuterMin()
           
 FuzzyLocation.RangeResolver getResolver()
          Retrieve the Location that this decorates.
 boolean hasBoundedMax()
           
 boolean hasBoundedMin()
           
protected  void initializeVariables(int outerMin, int outerMax, int innerMin, int innerMax, boolean isMinFuzzy, boolean isMaxFuzzy, FuzzyLocation.RangeResolver resolver)
          Refactored initialization code from the constructors.
 boolean isMaxFuzzy()
           
 boolean isMinFuzzy()
           
 String toString()
           
 Location translate(int dist)
          Create a location that is a translation of this location.
 
Methods inherited from class org.biojava.bio.symbol.AbstractRangeLocation
blockIterator, contains, isContiguous, symbols
 
Methods inherited from class org.biojava.bio.symbol.AbstractLocation
contains, equals, getDecorator, hashCode, intersection, newInstance, overlaps, union
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOLVE_INNER

public static final FuzzyLocation.RangeResolver RESOLVE_INNER
Always use the `inner' values.


RESOLVE_OUTER

public static final FuzzyLocation.RangeResolver RESOLVE_OUTER
Use the `outer' values, unless they are unbounded in which case the `inner' values are used.


RESOLVE_AVERAGE

public static final FuzzyLocation.RangeResolver RESOLVE_AVERAGE
Use the arithmetic mean of the `inner' and `outer' values, unless the outer value is unbounded.

Constructor Detail

FuzzyLocation

public FuzzyLocation(int outerMin,
                     int outerMax,
                     int innerMin,
                     int innerMax,
                     FuzzyLocation.RangeResolver resolver)
Create a new FuzzyLocation with endpoints (outerMin.innerMin) and (innerMax.outerMax).

Parameters:
outerMin - the lower bound on the location's min value. Integer.MIN_VALUE indicates unbounded.
outerMax - the upper bound on the location's max value. Integer.MAX_VALUE indicates unbounded.
innerMin - the upper bound on the location's min value.
innerMax - the lower bound on the location's max value.
resolver - a RangeResolver object which defines the policy used to calculate the location's min and max properties.

FuzzyLocation

public FuzzyLocation(int outerMin,
                     int outerMax,
                     int innerMin,
                     int innerMax,
                     boolean isMinFuzzy,
                     boolean isMaxFuzzy,
                     FuzzyLocation.RangeResolver resolver)
Create a new FuzzyLocation with endpoints (outerMin.innerMin) and (innerMax.outerMax). This constructor allows you to explicitly mark an endpoint as fuzzy, even if there is no other information about it. For example, a valid swissprot location "?5 10" would be a fuzzy location 5 to 10 where the min is fuzzy and the max is not.

Note that it is not logical to specify inner and outer values that clearly denote fuzzy boundaries and the set the isMinFuzzy or isMaxFuzzy value to false. This object makes no specific check of your logic so be careful.

Parameters:
outerMin - the lower bound on the location's min value. Integer.MIN_VALUE indicates unbounded.
outerMax - the upper bound on the location's max value. Integer.MAX_VALUE indicates unbounded.
innerMin - the upper bound on the location's min value.
innerMax - the lower bound on the location's max value.
isMinFuzzy - Explictly state if the minimum is fuzzy
isMaxFuzzy - Explictly state if the maximum is fuzzy
resolver - a RangeResolver object which defines the policy used to calculate the location's min and max properties.
Method Detail

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
Parameters:
dist - the distance to translate (to the right)

getResolver

public FuzzyLocation.RangeResolver getResolver()
Retrieve the Location that this decorates.

Returns:
the Location instance that stores all of the Location interface data

getOuterMin

public int getOuterMin()

getOuterMax

public int getOuterMax()

getInnerMin

public int getInnerMin()

getInnerMax

public int getInnerMax()

getMin

public int getMin()
Description copied from interface: Location
The minimum position contained.

WARNING: The location will not contain every point between getMin() and getMax() if isContiguous() is false. If isContiguous() does return false you should use the Iterator returned by blockIterator() to iterate over the minimum set of contiguous blocks that make up this Location

Specified by:
getMin in interface Location
Returns:
the minimum position contained

getMax

public int getMax()
Description copied from interface: Location
The maximum position contained.

WARNING: The location will not contain every point between getMin() and getMax() if isContiguous() is false. If isContiguous() does return false you should use the Iterator returned by blockIterator() to iterate over the minimum set of contiguous blocks that make up this Location

Specified by:
getMax in interface Location
Returns:
the maximum position contained

hasBoundedMin

public boolean hasBoundedMin()

hasBoundedMax

public boolean hasBoundedMax()

toString

public String toString()
Overrides:
toString in class Object

isMinFuzzy

public boolean isMinFuzzy()

isMaxFuzzy

public boolean isMaxFuzzy()

initializeVariables

protected void initializeVariables(int outerMin,
                                   int outerMax,
                                   int innerMin,
                                   int innerMax,
                                   boolean isMinFuzzy,
                                   boolean isMaxFuzzy,
                                   FuzzyLocation.RangeResolver resolver)
Refactored initialization code from the constructors.

Parameters:
outerMin - the lower bound on the location's min value. Integer.MIN_VALUE indicates unbounded.
outerMax - the upper bound on the location's max value. Integer.MAX_VALUE indicates unbounded.
innerMin - the upper bound on the location's min value.
innerMax - the lower bound on the location's max value.
resolver - a RangeResolver object which defines the policy used to calculate the location's min and max properties.