SimpleRichLocation (BioJava-1.5-beta API)
Keywords: org.biojavax.bio.seq.SimpleRichLocation 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.biojavax.bio.seq
Class SimpleRichLocation

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojavax.bio.seq.SimpleRichLocation

All Implemented Interfaces:
  Comparable, Annotatable, Location, Changeable, RichLocation, RichAnnotatable

Direct Known Subclasses:
  CompoundRichLocation

    public class SimpleRichLocation

extends AbstractChangeable
implements RichLocation

A simple implementation of RichLocation.

Since:
  1.5
Author:
  Richard Holland, Mark Schreiber

Nested Class Summary

Nested classes/interfaces inherited from interface org.biojavax.bio.seq.RichLocation
`RichLocation.Strand, RichLocation.Tools`

Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
`Annotatable.AnnotationForwarder`

Field Summary
`protected int` | `circularLength`
`protected ComparableTerm` | `term`

Fields inherited from interface org.biojavax.bio.seq.RichLocation
`CIRCULAR, EMPTY_LOCATION, FEATURE, NOTE, RANK, TERM`

Fields inherited from interface org.biojava.bio.symbol.Location
`empty, full, naturalOrder`

Fields inherited from interface org.biojava.bio.Annotatable
`ANNOTATION`

Constructor Summary
`protected` | `SimpleRichLocation()`
`` | `SimpleRichLocation(Position pos, int rank)` Creates a new instance of SimpleRichSequenceLocation that points to a single position on the positive strand.
`` | `SimpleRichLocation(Position pos, int rank, RichLocation.Strand strand)` Creates a new instance of SimpleRichSequenceLocation that points to a single position.
`` | `SimpleRichLocation(Position pos, int rank, RichLocation.Strand strand, CrossRef crossRef)` Creates a new instance of SimpleRichSequenceLocation that points to a single position on another sequence.
`` | `SimpleRichLocation(Position min, Position max, int rank)` Creates a new instance of SimpleRichSequenceLocation that points to a range position on the positive strand.
`` | `SimpleRichLocation(Position min, Position max, int rank, RichLocation.Strand strand)` Creates a new instance of SimpleRichSequenceLocation that points to a range position.
`` | `SimpleRichLocation(Position min, Position max, int rank, RichLocation.Strand strand, CrossRef crossRef)` Creates a new instance of SimpleRichSequenceLocation that points to a range position on another sequence.

Method Summary
`Iterator` | `blockIterator()` Return an Iterator over the set of maximal contiguous sub-locations.
`int` | `compareTo(Object o)` Locations are sorted first by rank, then crossref, then strand, then term, then min, then max.
`boolean` | `contains(int p)` Checks if this location contains a point.
`boolean` | `contains(Location l)` Checks if this location contains the other. A location contains another location if it overlaps it, and the coordinates enclose those of the other location at both ends, and they fall on the same strand.
`boolean` | `equals(Object o)` Checks if this location is equivalent to the other. Locations are equal if their term, min, max, strand, and crossref are the same, and if their rank is the same too.
`Annotation` | `getAnnotation()` Should return the associated annotation object.
`int` | `getCircularLength()` Retrieves the circular length of this location.
`CrossRef` | `getCrossRef()` Retrieves the crossref associated with this location.
`Location` | `getDecorator(Class decoratorClass)` Checks the decorator chain for an instance of decoratorClass and return it if found.
`RichFeature` | `getFeature()` Retrieves the feature this location is associated with.
`int` | `getMax()` The maximum position contained.
`Position` | `getMaxPosition()` Retrieves the end position of this location.
`int` | `getMin()` The minimum position contained.
`Position` | `getMinPosition()` Retrieves the start position of this location.
`Set` | `getNoteSet()` Returns the set of notes associated with this object. Warning this method gives access to the original Collection not a copy.
`int` | `getRank()` Retrieves the rank associated with this location.
`RichLocation.Strand` | `getStrand()` Retrieves the strand associated with this location.
`ComparableTerm` | `getTerm()` Retrieves the term associated with this location.
`int` | `hashCode()`
`Location` | `intersection(Location l)` Returns a Location that contains all points common to both ranges. If the locations overlap and are on the same strand, the intersection is returned.
`boolean` | `isContiguous()` Determine if a Location is contiguous.
`Location` | `newInstance(Location loc)` Create a new instance of Location with all of the same decorators as this instance but with the data stored in `loc`.
`boolean` | `overlaps(Location l)` Checks if these two locations overlap, using this location's concept of overlapping. A location overlaps another location if it is on the same sequence, and the coordinates overlap, and both are of the same circularity.
`protected Position` | `posmax(Position a, Position b)`
`protected Position` | `posmin(Position a, Position b)`
`void` | `setCircularLength(int circularLength)` Sets the circular length of this location.
`protected void` | `setCrossRef(CrossRef crossRef)`
`void` | `setCrossRefResolver(CrossReferenceResolver r)` Sets the cross ref resolver to use when retrieving remote symbols.
`void` | `setFeature(RichFeature feature)` Sets the feature this location is associated with.
`protected void` | `setMaxPosition(Position max)`
`protected void` | `setMinPosition(Position min)`
`void` | `setNoteSet(Set notes)` Clears the notes associated with this object and replaces them with the contents of this set. Warning this method gives access to the original Collection not a copy.
`void` | `setPositionResolver(PositionResolver p)` Sets the resolver to use when working out actual base coordinates from fuzzy positions.
`void` | `setRank(int rank)` Sets the rank for this location.
`protected void` | `setStrand(RichLocation.Strand strand)`
`void` | `setTerm(ComparableTerm term)` Sets the term for this location.
`void` | `sort()` Sorts the member locations of a compound location.
`SymbolList` | `symbols(SymbolList seq)` Return the symbols in a sequence that fall within this range. If the location is circular but the sequence is not, or they are both circular but of different circular lengths, an exception is thrown.
`String` | `toString()` Form: "start..end" or just "point" for point locations
`Location` | `translate(int dist)` Create a location that is a translation of this location.
`Location` | `union(Location l)` Return a Location containing all points in either ranges. A merged SimpleRichLocation is returned if the two locations overlap and are on the same strand.

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

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

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Field Detail

### term

    protected ComparableTerm term

### circularLength

    protected int circularLength

Constructor Detail

### SimpleRichLocation

    public SimpleRichLocation(Position pos,
                              int rank)

  Creates a new instance of SimpleRichSequenceLocation that points to a single position on the positive strand.

  Parameters:
    `pos` - the location position (a point).
    `rank` - Rank of location.

### SimpleRichLocation

    public SimpleRichLocation(Position pos,
                              int rank,
                              RichLocation.Strand strand)

  Creates a new instance of SimpleRichSequenceLocation that points to a single position.

  Parameters:
    `pos` - the location position (a point).
    `rank` - Rank of location.
    `strand` - The strand of the location

### SimpleRichLocation

    public SimpleRichLocation(Position pos,
                              int rank,
                              RichLocation.Strand strand,
                              CrossRef crossRef)

  Creates a new instance of SimpleRichSequenceLocation that points to a single position on another sequence.

  Parameters:
    `pos` - the location position (a point).
    `rank` - Rank of location.
    `strand` - the strand of the location
    `crossRef` - a cross reference to another object (null for parent sequence)

### SimpleRichLocation

    public SimpleRichLocation(Position min,
                              Position max,
                              int rank)

  Creates a new instance of SimpleRichSequenceLocation that points to a range position on the positive strand.

  Parameters:
    `min` - the minimum bound of the location
    `max` - the maximum bound of the location
    `rank` - Rank of location.

### SimpleRichLocation

    public SimpleRichLocation(Position min,
                              Position max,
                              int rank,
                              RichLocation.Strand strand)

  Creates a new instance of SimpleRichSequenceLocation that points to a range position.

  Parameters:
    `min` - the minimum bound of the location
    `max` - the maximum bound of the location
    `rank` - Rank of location.
    `strand` - the strand of the location

### SimpleRichLocation

    public SimpleRichLocation(Position min,
                              Position max,
                              int rank,
                              RichLocation.Strand strand,
                              CrossRef crossRef)

  Creates a new instance of SimpleRichSequenceLocation that points to a range position on another sequence.

  Parameters:
    `min` - the minimum bound of the location
    `max` - the maximum bound of the location
    `rank` - Rank of location.
    `strand` - the strand of the location
    `crossRef` - a cross reference to another object (null for parent sequence)

### SimpleRichLocation

    protected SimpleRichLocation()

Method Detail

### sort

    public void sort()

  Sorts the member locations of a compound location. Does nothing for non-compound locations. Sorting depends on the compareTo() method of the member locations - usually they will be sorted by their start position. This might be useful when used with the location returned by a union or intersection, or when setting the term of a compound location to ORDER_TERM.

  Specified by:
    `sort` in interface `RichLocation`

### getFeature

    public RichFeature getFeature()

  Retrieves the feature this location is associated with. May be null.

  Specified by:
    `getFeature` in interface `RichLocation`
  Returns:
    the feature.

### setFeature

    public void setFeature(RichFeature feature)
                    throws ChangeVetoException

  Sets the feature this location is associated with. If null, that's fine, but you won't be able to persist it to the database until you give it a not-null value.

  Specified by:
    `setFeature` in interface `RichLocation`
  Parameters:
    `feature` - the feature.
  Throws:
    `ChangeVetoException`

### getCrossRef

    public CrossRef getCrossRef()

  Retrieves the crossref associated with this location.

  Specified by:
    `getCrossRef` in interface `RichLocation`
  Returns:
    the crossref.

### setCrossRef

    protected void setCrossRef(CrossRef crossRef)

### getAnnotation

    public Annotation getAnnotation()

  Should return the associated annotation object.

  Specified by:
    `getAnnotation` in interface `Annotatable`
  Returns:
    an Annotation object, never null

### getNoteSet

    public Set getNoteSet()

  Returns the set of notes associated with this object. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getNoteSet` in interface `RichAnnotatable`
  Returns:
    set a set of Note objects.
  See Also:
    `Note`

### setNoteSet

    public void setNoteSet(Set notes)
                    throws ChangeVetoException

  Clears the notes associated with this object and replaces them with the contents of this set. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setNoteSet` in interface `RichAnnotatable`
  Parameters:
    `notes` - the set of Note objects to replace the existing ones with.
  Throws:
    `ChangeVetoException` - if the set is null or contains any objects that are not Note objects.
  See Also:
    `Note`

### getTerm

    public ComparableTerm getTerm()

  Retrieves the term associated with this location.

  Specified by:
    `getTerm` in interface `RichLocation`
  Returns:
    the term.

### setTerm

    public void setTerm(ComparableTerm term)
                 throws ChangeVetoException

  Sets the term for this location.

  Specified by:
    `setTerm` in interface `RichLocation`
  Parameters:
    `term` - the term this location should adopt.
  Throws:
    `ChangeVetoException` - in case of error.

### getCircularLength

    public int getCircularLength()

  Retrieves the circular length of this location. If it is 0, the location is not circular. If it is not zero, then the number refers to the wrapping length of the location. eg. 100 would signify that a position of 112 would actually be a position of 112-100 = 12.

  Specified by:
    `getCircularLength` in interface `RichLocation`
  Returns:
    the position.

### setCircularLength

    public void setCircularLength(int circularLength)
                           throws ChangeVetoException

  Sets the circular length of this location. If it is 0, the location is not circular. If it is not zero, then the number refers to the wrapping length of the location. eg. 100 would signify that a position of 112 would actually be a position of 112-100 = 12.

  Specified by:
    `setCircularLength` in interface `RichLocation`
  Parameters:
    `circularLength` - the circular length of this location
  Throws:
    `ChangeVetoException` - if it doesn't want to change.

### getStrand

    public RichLocation.Strand getStrand()

  Retrieves the strand associated with this location.

  Specified by:
    `getStrand` in interface `RichLocation`
  Returns:
    the strand.

### setStrand

    protected void setStrand(RichLocation.Strand strand)

### getRank

    public int getRank()

  Retrieves the rank associated with this location.

  Specified by:
    `getRank` in interface `RichLocation`
  Returns:
    the rank.

### setRank

    public void setRank(int rank)
                 throws ChangeVetoException

  Sets the rank for this location.

  Specified by:
    `setRank` in interface `RichLocation`
  Parameters:
    `rank` - the rank this location should adopt.
  Throws:
    `ChangeVetoException` - in case of error.

### getMax

    public int getMax()

  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

### getMin

    public int getMin()

  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

### getMinPosition

    public Position getMinPosition()

  Retrieves the start position of this location.

  Specified by:
    `getMinPosition` in interface `RichLocation`
  Returns:
    the position.

### setMinPosition

    protected void setMinPosition(Position min)

### getMaxPosition

    public Position getMaxPosition()

  Retrieves the end position of this location.

  Specified by:
    `getMaxPosition` in interface `RichLocation`
  Returns:
    the position.

### setMaxPosition

    protected void setMaxPosition(Position max)

### setPositionResolver

    public void setPositionResolver(PositionResolver p)

  Sets the resolver to use when working out actual base coordinates from fuzzy positions.

  Specified by:
    `setPositionResolver` in interface `RichLocation`
  Parameters:
    `p` - the position resolver to use.

### blockIterator

    public 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 finishing at the right-most block.

  Specified by:
    `blockIterator` in interface `Location`
  Returns:
    an Iterator over Location objects that are the maximally contiguous set of locations contained within this location

### isContiguous

    public boolean isContiguous()

  Determine if a Location is contiguous.

  Specified by:
    `isContiguous` in interface `Location`
  Returns:
    `true` if and only if this Location contains every point from `min` to `max` inclusive.

### contains

    public boolean contains(int p)

  Checks if this location contains a point.

  Specified by:
    `contains` in interface `Location`
  Parameters:
    `p` - the point to check
  Returns:
    true if this contains p, otherwise false

### getDecorator

    public Location getDecorator(Class decoratorClass)

  Checks the decorator chain for an instance of decoratorClass and return it if found.

  The default behavior is to return null. If the current object is a decorator and is an instance of decoratorClass it should return itself. Otherwise, the decorator should chain this method onto the instance it wraps.

  Specified by:
    `getDecorator` in interface `Location`
  Parameters:
    `decoratorClass` - the Class to check
  Returns:
    a Location if an instance of this class is present in the decorator chain and null otherwise.

### newInstance

    public Location newInstance(Location loc)

  Create a new instance of Location with all of the same decorators as this instance but with the data stored in `loc`.

  The default behavior is to return loc unchanged. If the class is a location decorator then it should instantiate an instance of the same type that decorates `loc`.

  Specified by:
    `newInstance` in interface `Location`
  Parameters:
    `loc` - the Location to use as template
  Returns:
    a Location instance based on loc with the same decorators as the current instance

### translate

    public Location translate(int dist)

  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)

### 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. A location contains another location if it overlaps it, and the coordinates enclose those of the other location at both ends, and they fall on the same strand.

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

### overlaps

    public boolean overlaps(Location l)

  Checks if these two locations overlap, using this location's concept of overlapping.

  Abstractly, two locations overlap if they both contain any point. A location overlaps another location if it is on the same sequence, and the coordinates overlap, and both are of the same circularity.

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

### union

    public Location union(Location l)

  Return a Location containing all points in either ranges. A merged SimpleRichLocation is returned if the two locations overlap and are on the same strand. Otherwise, a CompoundRichLocation is returned containing the two locations as members.

  Specified by:
    `union` in interface `Location`
  Parameters:
    `l` - the Location to union with
  Returns:
    a Location representing the union

### intersection

    public Location intersection(Location l)

  Returns a Location that contains all points common to both ranges. If the locations overlap and are on the same strand, the intersection is returned. If they overlap but are on different strands, a CompoundRichLocation of the overlapping portions is returned. If they do not overlap, the empty sequence is returned.

  Specified by:
    `intersection` in 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

### posmin

    protected Position posmin(Position a,
                              Position b)

### posmax

    protected Position posmax(Position a,
                              Position b)

### setCrossRefResolver

    public void setCrossRefResolver(CrossReferenceResolver r)

  Sets the cross ref resolver to use when retrieving remote symbols. If none is given, then the default from RichObjectFactory.getDefaultCrossRefResolver() is used.

  Specified by:
    `setCrossRefResolver` in interface `RichLocation`
  Parameters:
    `r` - the resolver to use.

### symbols

    public SymbolList symbols(SymbolList seq)

  Return the symbols in a sequence that fall within this range. If the location is circular but the sequence is not, or they are both circular but of different circular lengths, an exception is thrown. The symbol list passed in is the sequence used to obtain symbols if the cross reference for this location has not been set. If the cross reference has been set, then the symbol list passed in is only used if it has the same accession, namespace and version as the cross reference on this location. Otherwise, the cross referenced symbol list is looked up and used instead.

  Specified by:
    `symbols` in interface `Location`
  Parameters:
    `seq` - the SymbolList to process
  Returns:
    the SymbolList containing the symbols in seq in this range

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object o)

  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). You should call LocationTools.areEqual after casting l to Location. Locations are equal if their term, min, max, strand, and crossref are the same, and if their rank is the same too.

  Specified by:
    `equals` in interface `Location`
  Overrides:
    `equals` in class `Object`
  Parameters:
    `o` - the Object to check
  Returns:
    true if this equals l, otherwise false

### compareTo

    public int compareTo(Object o)

  Locations are sorted first by rank, then crossref, then strand, then term, then min, then max.

  Specified by:
    `compareTo` in interface `Comparable`

### toString

    public String toString()

  Form: "start..end" or just "point" for point locations

  Overrides:
    `toString` in class `Object`

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