org.jscience.biology.alignment
Class Factor

java.lang.Object
  extended by org.jscience.biology.alignment.Factor

public class Factor
extends java.lang.Object

This class is used by FactorSequence to create a linked list of factors of a text as induced by its Lempel-Ziv (LZ78) factorisation.

Each instance of this class represent a string composed of its an ancestor factor's string plus one character, and contains:

See Also:
FactorSequence

Field Summary
protected  Factor ancestor
          A pointer to this factor's ancestor, which represents a prefix of this factor's text.
protected  int length
          The number of characters of the text represented by this factor.
protected  char new_char
          The new character of this factor.
protected  Factor next
          A pointer to the next factor.
protected  int serial_number
          This factor's serial number, which indicates the order of this factor inside the linked list of factors of a text.
 
Constructor Summary
Factor()
          Creates a new empty Factor.
Factor(Factor ancestor, int serial_number, char new_char)
          Creates a new Factor instance with the specified serial number and new character, and pointing to the given ancestor.
 
Method Summary
 Factor getAncestor()
          Returns this factor's ancestor factor.
 int getAncestorSerialNumber()
          This method is a shorthand to return the serial number of this factor's ancestor.
 char getNewChar()
          Returns this factor's new character.
 Factor getNext()
          Returns this factor's next factor.
 int getSerialNumber()
          Returns this factor's serial number.
 int length()
          Returns this factor's length.
 void setNext(Factor next)
          Sets this factor's next pointer to point to the specified factor.
 java.lang.String toString()
          Returns a string representation of the text represented by this factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ancestor

protected Factor ancestor
A pointer to this factor's ancestor, which represents a prefix of this factor's text.


next

protected Factor next
A pointer to the next factor.


serial_number

protected int serial_number
This factor's serial number, which indicates the order of this factor inside the linked list of factors of a text.


length

protected int length
The number of characters of the text represented by this factor.


new_char

protected char new_char
The new character of this factor.

Constructor Detail

Factor

public Factor()
Creates a new empty Factor. It has no ancestor and no character (both are set to null). Its serial number is set to zero as well as its length.

This constructor is used to initiate the a linked list of factors of a text. Its next pointer is initially null, but it is typically set to point to the first factor afterwards (with the setNext method).

See Also:
setNext(org.jscience.biology.alignment.Factor)

Factor

public Factor(Factor ancestor,
              int serial_number,
              char new_char)
Creates a new Factor instance with the specified serial number and new character, and pointing to the given ancestor. Its length is set to its ancestor's length plus 1.

Its next pointer is initially null, but it is typically set to point to the next factor afterwards (with the setNext method).

Parameters:
ancestor - this factor's ancestor
serial_number - this factor's serial number
new_char - this factor's new character
See Also:
setNext(org.jscience.biology.alignment.Factor)
Method Detail

setNext

public void setNext(Factor next)
Sets this factor's next pointer to point to the specified factor. Although the next factor has typically a serial number equal to this factor's serial number plus 1, no attempt is made to guarantee this rule. This allows special constructs or a different order in the factorisation.

Parameters:
next - the factor that will be pointed to
See Also:
getNext()

getAncestor

public Factor getAncestor()
Returns this factor's ancestor factor.

Returns:
this factor's ancestor factor

getAncestorSerialNumber

public int getAncestorSerialNumber()
This method is a shorthand to return the serial number of this factor's ancestor. Note that it does not check if this factor has an ancestor or not, therefore, if it is called on the root factor, a NullPointerException is raised.

Returns:
the serial number of this factor's ancestor

getNext

public Factor getNext()
Returns this factor's next factor.

Returns:
this factor's next factor
See Also:
setNext(org.jscience.biology.alignment.Factor)

getSerialNumber

public int getSerialNumber()
Returns this factor's serial number.

Returns:
this factor's serial number

length

public int length()
Returns this factor's length.

Returns:
this factor's length

getNewChar

public char getNewChar()
Returns this factor's new character.

Returns:
this factor's new character

toString

public java.lang.String toString()
Returns a string representation of the text represented by this factor. It inspects its chain of ancestors up until as far as the root factor, spelling their new characters out.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the text denoted by this factor