Alignments
Class Site

java.lang.Object
  extended by Alignments.Site
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Alignment.UniqueSite

public class Site
extends java.lang.Object
implements java.io.Serializable

Represents a "site" in an "alignment". Both terms used generously.

Version:
1.2
See Also:
Serialized Form

Constructor Summary
Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites)
          Creates a site in a alignment with no ambiguous data
Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites, Ambiguous ambig)
          Creates a site in a alignment with ambiguous data
Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites, Ambiguous ambig, java.lang.String siteClass)
          Creates a site in a alignment with ambiguous data and with the given class.
Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites, java.lang.String siteClass)
          Creates a site in a alignment with no ambiguous data and with the given class.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 Ambiguous getAmbiguous()
          Gets the information about ambiguous states for this site
 java.util.Set<java.lang.String> getCharacter(java.lang.String taxa)
          Gets the possible characters for a given taxa.
 ArrayMap<java.lang.String,Likelihood.NodeLikelihood> getInitialNodeLikelihoods(Tree t, ArrayMap<java.lang.String,java.lang.Integer> map, SiteConstraints scon)
          Gdets initial node likelihoods based on the site, tree and any constraints.
 int getNum()
          Get the number of taxa
 java.lang.String getRawCharacter(java.lang.String taxa)
          Gets the raw charcater for a given taxa.
 java.lang.String getSiteClass()
          Gets the class of this site
 java.util.Set<java.lang.String> getTaxa()
          Get the set of taxa
 int hashCode()
           
 Site limitToTaxa(java.util.Collection<java.lang.String> limit)
          Returns a new Site which is the same as this one except it is limited to certain taxa
 Site recode(java.util.Map<java.lang.String,java.lang.String> recode)
          Recodes the site and returns it
 Site 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
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Site

public Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites)
Creates a site in a alignment with no ambiguous data

Parameters:
sites - Map from taxa name to state

Site

public Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites,
            java.lang.String siteClass)
Creates a site in a alignment with no ambiguous data and with the given class. Note that either all sites in an alignment must have a class or none should.

Parameters:
sites - Map from taxa name to state
siteClass - The class of this site

Site

public Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites,
            Ambiguous ambig)
Creates a site in a alignment with ambiguous data

Parameters:
sites - Map from taxa name to state
ambig - Description of ambiguous data

Site

public Site(java.util.LinkedHashMap<java.lang.String,java.lang.String> sites,
            Ambiguous ambig,
            java.lang.String siteClass)
Creates a site in a alignment with ambiguous data and with the given class. Note that either all sites in an alignment must have a class or none should.

Parameters:
sites - Map from taxa name to state
ambig - Description of ambiguous data
siteClass - The class of this site
Method Detail

getCharacter

public java.util.Set<java.lang.String> getCharacter(java.lang.String taxa)
Gets the possible characters for a given taxa. This returns a set as it takes into account ambiguous data. For example if N is defined to be A, C, T or G then this function will return a set containing A, C, T and G if the raw data contains a N

Parameters:
taxa - Taxa to return the character for
Returns:
The character for the given taxa

getRawCharacter

public java.lang.String getRawCharacter(java.lang.String taxa)
Gets the raw charcater for a given taxa. This no account of ambiguous data and will just return the raw character

Parameters:
taxa - Taxa to return the character for
Returns:
The character for the given taxa

getNum

public int getNum()
Get the number of taxa

Returns:
The number of taxa

getTaxa

public java.util.Set<java.lang.String> getTaxa()
Get the set of taxa

Returns:
Set containing taxa names

getSiteClass

public java.lang.String getSiteClass()
Gets the class of this site

Returns:
The class of this site

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInitialNodeLikelihoods

public ArrayMap<java.lang.String,Likelihood.NodeLikelihood> getInitialNodeLikelihoods(Tree t,
                                                                                      ArrayMap<java.lang.String,java.lang.Integer> map,
                                                                                      SiteConstraints scon)
Gdets initial node likelihoods based on the site, tree and any constraints. Done like this as creating the node likelihoods is time consuming whereas copying them once initialised is not. As they only need to be initalised once for each site this saves time as they then need only be copied for each likelihood calculation.

Parameters:
t - The tree
map - A map from state to position in array
scon - Any constraints on the site
Returns:
An ArrayMap of NodeLikelihoods which can be used to initialise likelihood calculations

recode

public Site recode(java.util.Map<java.lang.String,java.lang.String> recode)
Recodes the site 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 site

recode

public Site 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 site

limitToTaxa

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

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

getAmbiguous

public Ambiguous getAmbiguous()
Gets the information about ambiguous states for this site

Returns:
Information about the ambiguous states