org.biojavax.bio.seq
Class SimplePosition

java.lang.Object
  extended by org.biojavax.bio.seq.SimplePosition
All Implemented Interfaces:
Position

public class SimplePosition
extends Object
implements Position

A simple implementation of the Position interface.

Since:
1.5
Author:
Richard Holland

Field Summary
 
Fields inherited from interface org.biojavax.bio.seq.Position
BETWEEN_BASES, EMPTY_POSITION, IN_RANGE
 
Constructor Summary
protected SimplePosition()
           
  SimplePosition(boolean fs, boolean fe, int p)
          Constructs a point position, with optionally fuzzy start and end.
  SimplePosition(boolean fs, boolean fe, int s, int e, String t)
          Constructs a range position, with optionally fuzzy start and end.
  SimplePosition(int p)
          Constructs a point position, with no fuzzy start or end.
  SimplePosition(int s, int e)
          Constructs a range position, with no fuzzy start or end.
 
Method Summary
 boolean equals(Object o)
           Two positions are equal if they share all parameters in common, eg.
 int getEnd()
          Returns the end of the range of bases this base could lie in.
 boolean getFuzzyEnd()
          Returns true if the position has a fuzzy end.
 boolean getFuzzyStart()
          Returns true if the position has a fuzzy start.
 Integer getId()
          Gets the Hibernate ID.
 int getStart()
          Returns the beginning of the range of bases this base could lie in.
 String getType()
          Returns the type of this position if it is not a point/single position.
 void setId(Integer id)
          Sets the Hibernate ID.
 String toString()
          
 Position translate(int distance)
          Takes this position and returns a copy translated by 'distance' bases.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimplePosition

public SimplePosition(int p)
Constructs a point position, with no fuzzy start or end. (eg. 1, 2, or 3).

Parameters:
p - the point position

SimplePosition

public SimplePosition(int s,
                      int e)
Constructs a range position, with no fuzzy start or end. (eg. 1..2, 2..5, or 3..8).

Parameters:
s - the start position
e - the end position

SimplePosition

public SimplePosition(boolean fs,
                      boolean fe,
                      int p)
Constructs a point position, with optionally fuzzy start and end. (eg. <1 or 3> or 2 or even <5>).

Parameters:
fs - fuzzy start?
fe - fuzzy end?
p - the point position

SimplePosition

public SimplePosition(boolean fs,
                      boolean fe,
                      int s,
                      int e,
                      String t)
Constructs a range position, with optionally fuzzy start and end. (eg. <1.2 or 1^3> or 2.2 or even <5^6>). The type of the range is given, it should normally be one of the two defined in the Position interface, but its up to you.

Parameters:
fs - fuzzy start?
fe - fuzzy end?
s - the start of the position
e - the end of the position
t - the type of the position

SimplePosition

protected SimplePosition()
Method Detail

getFuzzyStart

public boolean getFuzzyStart()
Returns true if the position has a fuzzy start.

Specified by:
getFuzzyStart in interface Position
Returns:
the fuzziness of the start.

getFuzzyEnd

public boolean getFuzzyEnd()
Returns true if the position has a fuzzy end.

Specified by:
getFuzzyEnd in interface Position
Returns:
the fuzziness of the end.

getStart

public int getStart()
Returns the beginning of the range of bases this base could lie in. If this position is a single position, then start=end.

Specified by:
getStart in interface Position
Returns:
the start of this position.

getEnd

public int getEnd()
Returns the end of the range of bases this base could lie in. If this position is a single position, then start=end.

Specified by:
getEnd in interface Position
Returns:
the end of this position.

getType

public String getType()
Returns the type of this position if it is not a point/single position. Types are usually BETWEEN_BASES or IN_RANGE but could be any string value.

Specified by:
getType in interface Position
Returns:
the type of this position.

translate

public Position translate(int distance)
Takes this position and returns a copy translated by 'distance' bases.

Specified by:
translate in interface Position
Parameters:
distance - the distance to translate it.
Returns:
the translated position.

equals

public boolean equals(Object o)
Two positions are equal if they share all parameters in common, eg. fuzzy start+end, start, end, type.

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object

getId

public Integer getId()
Gets the Hibernate ID. Should be used with caution.

Returns:
the Hibernate ID, if using Hibernate.

setId

public void setId(Integer id)
Sets the Hibernate ID. Should be used with caution.

Parameters:
id - the Hibernate ID, if using Hibernate.