Alignments
Class Alignment

java.lang.Object
  extended by Alignments.Alignment
All Implemented Interfaces:
java.lang.Iterable<Site>
Direct Known Subclasses:
DuplicationAlignment, FastaAlignment, PhylipAlignment, SequenceAlignment

public class Alignment
extends java.lang.Object
implements java.lang.Iterable<Site>

Represents an "alignment", used very losely. Classes should extend this to represent the different types of alignment, e.g. DuplicationAlignment, SequenceAlignment.

Version:
1.2

Nested Class Summary
 class Alignment.UniqueSite
          Used to represent a unique site in an alignment.
 
Field Summary
protected  java.util.List<Site> data
          The list of sites in the alignment
protected  boolean hasClasses
          Whether the sites in this alignment contain site information
protected  java.util.Set<java.lang.String> taxa
          The list of taxa in the alignment
 
Constructor Summary
protected Alignment()
          Default constructor.
  Alignment(java.util.List<Site> data)
          Creates an alignment
 
Method Summary
 boolean check(java.util.Map<java.lang.String,?> map)
          Checks whether the map contains an entry for every class in the alignment
 int getCount(Site s)
          Gets a count of hoften a site occurs in the alignment
 int getLength()
          Gets the length of the aligmnet
 int getNumber()
          Gets the number of taxa in the alignment
 double getRawFreq(java.lang.String character)
          Gets the frequency of a raw character
 Site getSite(int s)
          Returns the site at a given position in the alignment
 java.util.Set<java.lang.String> getTaxa()
          Gets the names of the taxa in the aligment
 java.util.List<Alignment.UniqueSite> getUniqueSites()
          Returns a list of unique sites in the aligment.
 java.util.Iterator<Site> iterator()
           
 Alignment limitToTaxa(java.util.Collection<java.lang.String> limit)
          Returns a new Alignment which is the same as this one except it is limited to certain taxa
 Alignment recode(java.util.Map<java.lang.String,java.lang.String> recode)
          Recodes the alignment and returns it
 Alignment recode(java.util.Map<java.lang.String,java.lang.String> recode, Ambiguous ambig)
          Recodes the alignment and returns it and also allows the definition of new ambiguous states
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.List<Site> data
The list of sites in the alignment


taxa

protected java.util.Set<java.lang.String> taxa
The list of taxa in the alignment


hasClasses

protected boolean hasClasses
Whether the sites in this alignment contain site information

Constructor Detail

Alignment

protected Alignment()
Default constructor. Called by classed that extend this one. Classes that do extend this class should ensure that they populate data and taxa appropiately.


Alignment

public Alignment(java.util.List<Site> data)
          throws AlignmentException
Creates an alignment

Parameters:
data - A list of sites in the alignment
Throws:
AlignmentException - Thrown if the sites passed have different taxa
Method Detail

getLength

public int getLength()
Gets the length of the aligmnet

Returns:
The length of the alignment

getNumber

public int getNumber()
Gets the number of taxa in the alignment

Returns:
The number of taxa in the alignment

getUniqueSites

public java.util.List<Alignment.UniqueSite> getUniqueSites()
Returns a list of unique sites in the aligment. Useful for calculating likelihoods as each site pattern only has to be calculated once.

Returns:
A set of unique sites

getSite

public Site getSite(int s)
Returns the site at a given position in the alignment

Parameters:
s - The site to be returned
Returns:
The site at posiiton s

getTaxa

public java.util.Set<java.lang.String> getTaxa()
Gets the names of the taxa in the aligment

Returns:
List of taxa names

iterator

public java.util.Iterator<Site> iterator()
Specified by:
iterator in interface java.lang.Iterable<Site>

check

public boolean check(java.util.Map<java.lang.String,?> map)
Checks whether the map contains an entry for every class in the alignment

Parameters:
map - The map
Returns:
Whether the map has an entry for every class

recode

public Alignment recode(java.util.Map<java.lang.String,java.lang.String> recode)
Recodes the alignment and returns it

Parameters:
recode - A map from original state to new state, e.g. to recode DNA to RY it would contains A -> R, G -> R, C -> Y, T -> Y
Returns:
A recoded alignment

recode

public Alignment recode(java.util.Map<java.lang.String,java.lang.String> recode,
                        Ambiguous ambig)
Recodes the alignment and returns it and also allows the definition of new ambiguous states

Parameters:
recode - A map from original state to new state, e.g. to recode DNA to RY it would contains A -> R, G -> R, C -> Y, T -> Y
ambig - The new ambiiguous states
Returns:
A recoded alignment

limitToTaxa

public Alignment limitToTaxa(java.util.Collection<java.lang.String> limit)
Returns a new Alignment which is the same as this one except it is limited to certain taxa

Parameters:
limit - The taxa to limit the new alignment to
Returns:
The limited alignment

getRawFreq

public double getRawFreq(java.lang.String character)
Gets the frequency of a raw character

Parameters:
character - The character to get the frequency for
Returns:
The frequency of that chaacter

getCount

public int getCount(Site s)
Gets a count of hoften a site occurs in the alignment

Parameters:
s - The site
Returns:
How often it occurs