org.biojava3.core.sequence.location.template
Class AbstractLocation

java.lang.Object
  extended by org.biojava3.core.sequence.location.template.AbstractLocation
All Implemented Interfaces:
Iterable<Location>, Location, Accessioned
Direct Known Subclasses:
InsdcLocations.BondLocation, InsdcLocations.OneOfLocation, SimpleLocation

public abstract class AbstractLocation
extends Object
implements Location

Base abstraction of a location which encodes for the majority of important features about a location such as the start, end and strand

Author:
ayates

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava3.core.sequence.location.template.Location
Location.Tools
 
Field Summary
 
Fields inherited from interface org.biojava3.core.sequence.location.template.Location
EMPTY
 
Constructor Summary
protected AbstractLocation()
           
  AbstractLocation(Point start, Point end, Strand strand, boolean circular, boolean betweenCompounds, AccessionID accession, List<Location> subLocations)
          Default constructor
  AbstractLocation(Point start, Point end, Strand strand, boolean circular, boolean betweenCompounds, List<Location> subLocations)
          Default constructor
 
Method Summary
protected  void assertLocation()
           
protected
<C extends Compound>
boolean
canComplement(Sequence<C> sequence)
          Uses the Sequence's CompoundSet to decide if a compound can be assgined to ComplementCompound meaning it can complement
 boolean equals(Object obj)
           
 AccessionID getAccession()
          Returns the AccessionID this location is currently bound with
 Point getEnd()
          End of the location
 int getLength()
          Returns the length of the outer bounds of this location
 List<Location> getRelevantSubLocations()
          Returns the normalised list of sub locations i.e.
<C extends Compound>
Sequence<C>
getRelevantSubSequence(Sequence<C> sequence)
          Will return a SequenceReader object which offers a view of all resolved locations i.e.
 Point getStart()
          Start of the location
 Strand getStrand()
          Strand which the location is located on
 List<Location> getSubLocations()
          Gives access to the sub locations for this location.
<C extends Compound>
Sequence<C>
getSubSequence(Sequence<C> sequence)
          If circular this will return the sequence represented by the sub locations joined.
 int hashCode()
           
 boolean isBetweenCompounds()
          Returns true if the position is meant to represent a point between two points such as 78^79.
 boolean isCircular()
          Indicates if this location is circular.
 boolean isComplex()
          Returns true if the location is considered to be complex meaning the location is actually composed of sub-locations.
 Iterator<Location> iterator()
          Iterates through all known sub-locations for this location but does not descend
protected
<C extends Compound>
Sequence<C>
reverseSequence(Sequence<C> sequence)
          Reverses and (if possible) complements the Sequence so as to represent the reverse strand (if one exists).
protected  void setAccession(AccessionID accession)
           
protected  void setBetweenCompounds(boolean betweenCompounds)
           
protected  void setCircular(boolean circular)
           
protected  void setEnd(Point end)
           
protected  void setStart(Point start)
           
protected  void setStrand(Strand strand)
           
protected  void setSubLocations(List<Location> subLocations)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLocation

protected AbstractLocation()

AbstractLocation

public AbstractLocation(Point start,
                        Point end,
                        Strand strand,
                        boolean circular,
                        boolean betweenCompounds,
                        List<Location> subLocations)
Default constructor

Parameters:
start - start of the location
end - end of the location
strand - strand it is located on
circular - Boolean which says if the current location was circular or not
betweenCompounds - Indicates the location lies at the position between a pair of bases; means the bases must be next to each other (and therefore cannot be complex)
subLocations - Sub locations which composes this location

AbstractLocation

public AbstractLocation(Point start,
                        Point end,
                        Strand strand,
                        boolean circular,
                        boolean betweenCompounds,
                        AccessionID accession,
                        List<Location> subLocations)
Default constructor

Parameters:
start - start of the location
end - end of the location
strand - strand it is located on
circular - Boolean which says if the current location was circular or not
betweenCompounds - Indicates the location lies at the position between a pair of bases; means the bases must be next to each other (and therefore cannot be complex)
accession - The accession ID to link this location to
subLocations - Sub locations which composes this location
Method Detail

assertLocation

protected void assertLocation()

getEnd

public Point getEnd()
Description copied from interface: Location
End of the location

Specified by:
getEnd in interface Location

getStart

public Point getStart()
Description copied from interface: Location
Start of the location

Specified by:
getStart in interface Location

getLength

public int getLength()
Description copied from interface: Location
Returns the length of the outer bounds of this location

Specified by:
getLength in interface Location

getStrand

public Strand getStrand()
Description copied from interface: Location
Strand which the location is located on

Specified by:
getStrand in interface Location

getSubLocations

public List<Location> getSubLocations()
Description copied from interface: Location
Gives access to the sub locations for this location. However this does not return sub-locations of sub-locations. For that functionality use #getAllSubLocations().

Specified by:
getSubLocations in interface Location
Returns:
A list of a single level of sub-locations

isComplex

public boolean isComplex()
Description copied from interface: Location
Returns true if the location is considered to be complex meaning the location is actually composed of sub-locations.

Specified by:
isComplex in interface Location

getAccession

public AccessionID getAccession()
Description copied from interface: Accessioned
Returns the AccessionID this location is currently bound with

Specified by:
getAccession in interface Accessioned

iterator

public Iterator<Location> iterator()
Iterates through all known sub-locations for this location but does not descend

Specified by:
iterator in interface Iterable<Location>

getRelevantSubLocations

public List<Location> getRelevantSubLocations()
Returns the normalised list of sub locations i.e. only those locations which do not have a sub location. Useful for when you need to get the exact elements of a location back for sub sequences.

Specified by:
getRelevantSubLocations in interface Location
Returns:
List of all sub locations including sub-locations of sub locations

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isCircular

public boolean isCircular()
Description copied from interface: Location
Indicates if this location is circular.

Specified by:
isCircular in interface Location

isBetweenCompounds

public boolean isBetweenCompounds()
Description copied from interface: Location
Returns true if the position is meant to represent a point between two points such as 78^79. Only valid if start and stop are next to each other.

Specified by:
isBetweenCompounds in interface Location

getSubSequence

public <C extends Compound> Sequence<C> getSubSequence(Sequence<C> sequence)
If circular this will return the sequence represented by the sub locations joined. If not circular then we get the Sequence for the outer-bounds defined by this location.

Specified by:
getSubSequence in interface Location
Parameters:
sequence - The sequence object to work with
Returns:
The sequence

getRelevantSubSequence

public <C extends Compound> Sequence<C> getRelevantSubSequence(Sequence<C> sequence)
Description copied from interface: Location
Will return a SequenceReader object which offers a view of all resolved locations i.e. those locations which are not complex and define the true Sequence represented

Specified by:
getRelevantSubSequence in interface Location
Parameters:
sequence - The sequence object to work with
Returns:
The full assembled sequence

reverseSequence

protected <C extends Compound> Sequence<C> reverseSequence(Sequence<C> sequence)
Reverses and (if possible) complements the Sequence so as to represent the reverse strand (if one exists). Also does checking to see if the location we are on is on the reverse strand or not.


canComplement

protected <C extends Compound> boolean canComplement(Sequence<C> sequence)
Uses the Sequence's CompoundSet to decide if a compound can be assgined to ComplementCompound meaning it can complement


toString

public String toString()
Overrides:
toString in class Object

setCircular

protected void setCircular(boolean circular)

setEnd

protected void setEnd(Point end)

setStart

protected void setStart(Point start)

setStrand

protected void setStrand(Strand strand)

setBetweenCompounds

protected void setBetweenCompounds(boolean betweenCompounds)

setSubLocations

protected void setSubLocations(List<Location> subLocations)

setAccession

protected void setAccession(AccessionID accession)