Package pal.datatype
Class IUPACNucleotides
- java.lang.Object
-
- pal.datatype.SimpleDataType
-
- pal.datatype.IUPACNucleotides
-
- All Implemented Interfaces:
java.io.Serializable,AmbiguousDataType,DataType,MolecularDataType
public class IUPACNucleotides extends SimpleDataType implements MolecularDataType, AmbiguousDataType
implements DataType for nucleotides with ambiguous characters- Version:
- $Id: IUPACNucleotides.java,v 1.19 2004/09/13 05:20:47 matt Exp $
- Author:
- Alexei Drummond
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface pal.datatype.DataType
DataType.Utils
-
Nested classes/interfaces inherited from interface pal.datatype.MolecularDataType
MolecularDataType.Utils
-
-
Field Summary
Fields Modifier and Type Field Description static IUPACNucleotidesDEFAULT_INSTANCEstatic IUPACNucleotidesDNA_INSTANCEstatic IUPACNucleotidesRNA_INSTANCE-
Fields inherited from interface pal.datatype.DataType
AMINO_ACID_DESCRIPTION, AMINOACIDS, CODON_DESCRIPTION, CODONS, GAP_BALANCED, GAP_BALANCED_DESCRIPTION, IUPAC_NUCELOTIDES_DESCRIPTION, IUPACNUCLEOTIDES, NUCLEOTIDE_DESCRIPTION, NUCLEOTIDES, NUMERIC, PRIMARY_SUGGESTED_GAP_CHARACTER, SUGGESTED_GAP_CHARACTERS, SUGGESTED_GAP_STATE, SUGGESTED_UNKNOWN_STATE, TWO_STATE_DESCRIPTION, TWOSTATES, UNKNOWN, UNKNOWN_CHARACTER, UNKNOWN_TLA
-
-
Constructor Summary
Constructors Constructor Description IUPACNucleotides()IUPACNucleotides(boolean isRNA)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidgetAmbiguity(int ambiguousState, boolean[] specificInclusion)Attempts to "resolve" the ambiguity in a state with regard to the specific data type.voidgetAmbiguity(int ambiguousState, double[] specificInclusion)A more accurate attempt to "resolve" the ambiguity in a state with regard to the specific data type.AmbiguousDataTypegetAmbiguousVersion()protected chargetCharImpl(int state)java.lang.StringgetDescription()description of data typestatic intgetIUPACState(boolean maybeA, boolean maybeC, boolean maybeG, boolean maybeT)static intgetIUPACState(int inclusion)int[]getMolecularStatesFromIUPACNucleotides(int[] nucleotideStates, int startingIndex)int[]getMolecularStatesFromSimpleNucleotides(int[] nucleotideStates, int startingIndex)intgetNucleotideLength()int[]getNucleotideStates(int[] residueStates)intgetNumStates()Get number of states.intgetRecommendedUnknownState()static intgetSimpleState(int state)Converts an IUPAC State to either a A,T,G,C state (eg.static int[]getSimpleStates(int[] states)Converts an IUPAC State array to either a A,T,G,C state (eg.static int[]getSimpleStates(int[] states, int startingIndex)Converts an IUPAC State array to either a A,T,G,C state (eg.DataTypegetSpecificDataType()int[]getSpecificStates(int state)returns an array containing the non-ambiguous states that this state represents.protected intgetStateImpl(char c)For sub classes to implement main functionality of getState.intgetTypeID()get numerical code describing the data typebooleanisAmbiguous()booleanisCreatesIUPACNuecleotides()static booleanisNucleotideState(int iupacState, int nucleotideState)protected booleanisUnknownStateImpl(int state)For subclasses to handle, without regard for gapsjava.lang.StringtoString()-
Methods inherited from class pal.datatype.SimpleDataType
getChar, getPreferredChar, getPreferredCharImpl, getRecommendedGapState, getState, hasGap, isGapChar, isGapState, isUnknownChar, isUnknownState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface pal.datatype.DataType
getChar, getPreferredChar, getRecommendedGapState, getState, hasGap, isGapChar, isGapState, isUnknownChar, isUnknownState
-
-
-
-
Field Detail
-
DEFAULT_INSTANCE
public static final IUPACNucleotides DEFAULT_INSTANCE
-
DNA_INSTANCE
public static final IUPACNucleotides DNA_INSTANCE
-
RNA_INSTANCE
public static final IUPACNucleotides RNA_INSTANCE
-
-
Method Detail
-
getNumStates
public int getNumStates()
Get number of states.- Specified by:
getNumStatesin interfaceDataType- Returns:
- number of unique states
-
isUnknownStateImpl
protected boolean isUnknownStateImpl(int state)
Description copied from class:SimpleDataTypeFor subclasses to handle, without regard for gaps- Specified by:
isUnknownStateImplin classSimpleDataType
-
getStateImpl
protected final int getStateImpl(char c)
Description copied from class:SimpleDataTypeFor sub classes to implement main functionality of getState. Gaps do not need to be considered- Specified by:
getStateImplin classSimpleDataType
-
getCharImpl
protected char getCharImpl(int state)
- Specified by:
getCharImplin classSimpleDataType
-
getDescription
public java.lang.String getDescription()
Description copied from interface:DataTypedescription of data type- Specified by:
getDescriptionin interfaceDataType- Returns:
- string describing the data type
-
getTypeID
public int getTypeID()
Description copied from interface:DataTypeget numerical code describing the data type
-
isNucleotideState
public static final boolean isNucleotideState(int iupacState, int nucleotideState)- Returns:
- true if the iupacState is an state which includes the possibility of being of a nucleotide state
-
getRecommendedUnknownState
public int getRecommendedUnknownState()
- Specified by:
getRecommendedUnknownStatein interfaceDataType- Overrides:
getRecommendedUnknownStatein classSimpleDataType- Returns:
- -1 (not getNumStates())
-
getIUPACState
public static final int getIUPACState(int inclusion)
- Parameters:
inclusion- should be a number constructed as follows 1. start at zero 2. if maybe A add 1 3. if maybe C add 2 4. if maybe G add 4 5. if maybe T add 8
-
getIUPACState
public static final int getIUPACState(boolean maybeA, boolean maybeC, boolean maybeG, boolean maybeT)
-
getSimpleState
public static final int getSimpleState(int state)
Converts an IUPAC State to either a A,T,G,C state (eg. if state represents either C or G, state becomes C - an arbitary choice is made to take "lowest" letter)
-
getSimpleStates
public static final int[] getSimpleStates(int[] states)
Converts an IUPAC State array to either a A,T,G,C state (eg. if state represents either C or G, state becomes C - an arbitary choice is made to take "lowest" letter)- Returns:
- new array containing only simple states (orignal is not altered)
-
getSimpleStates
public static final int[] getSimpleStates(int[] states, int startingIndex)Converts an IUPAC State array to either a A,T,G,C state (eg. if state represents either C or G, state becomes C - an arbitary choice is made to take "lowest" letter)- Parameters:
staringIndex- amount to skip at beginning of input array- Returns:
- new array containing only simple states (orignal is not altered)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classSimpleDataType
-
getNucleotideStates
public int[] getNucleotideStates(int[] residueStates)
- Specified by:
getNucleotideStatesin interfaceMolecularDataType- Parameters:
residueStates- an array of states corresponding to states ofthis datatype- Returns:
- a copy of the input
-
getMolecularStatesFromSimpleNucleotides
public int[] getMolecularStatesFromSimpleNucleotides(int[] nucleotideStates, int startingIndex)- Specified by:
getMolecularStatesFromSimpleNucleotidesin interfaceMolecularDataType- Returns:
- a copy of the input
-
getMolecularStatesFromIUPACNucleotides
public final int[] getMolecularStatesFromIUPACNucleotides(int[] nucleotideStates, int startingIndex)- Specified by:
getMolecularStatesFromIUPACNucleotidesin interfaceMolecularDataType- Returns:
- a copy of the input
-
isCreatesIUPACNuecleotides
public boolean isCreatesIUPACNuecleotides()
- Specified by:
isCreatesIUPACNuecleotidesin interfaceMolecularDataType- Returns:
- true
-
getNucleotideLength
public final int getNucleotideLength()
- Specified by:
getNucleotideLengthin interfaceMolecularDataType- Returns:
- 1
-
getSpecificStates
public int[] getSpecificStates(int state)
returns an array containing the non-ambiguous states that this state represents.- Specified by:
getSpecificStatesin interfaceAmbiguousDataType
-
isAmbiguous
public boolean isAmbiguous()
- Specified by:
isAmbiguousin interfaceDataType- Overrides:
isAmbiguousin classSimpleDataType- Returns:
- true
-
getAmbiguousVersion
public AmbiguousDataType getAmbiguousVersion()
- Specified by:
getAmbiguousVersionin interfaceDataType- Overrides:
getAmbiguousVersionin classSimpleDataType- Returns:
- this!
-
getSpecificDataType
public DataType getSpecificDataType()
- Specified by:
getSpecificDataTypein interfaceAmbiguousDataType- Returns:
- Nucleotides
-
getAmbiguity
public void getAmbiguity(int ambiguousState, boolean[] specificInclusion)Attempts to "resolve" the ambiguity in a state with regard to the specific data type.- Specified by:
getAmbiguityin interfaceAmbiguousDataType- Parameters:
ambiguousState- the state of this data type (the ambiguous one!)specificInclusion- An array of length equal to or greater than the number of states of the specific DataType. Each state of the specific data type is represented by the corresponding element in this array. The result of this method will be to set the states that the ambiguous state cannot represent to false, and those states that the ambiguous state might represent to true.
-
getAmbiguity
public void getAmbiguity(int ambiguousState, double[] specificInclusion)A more accurate attempt to "resolve" the ambiguity in a state with regard to the specific data type.- Specified by:
getAmbiguityin interfaceAmbiguousDataType- Parameters:
ambiguousState- the state of this data type (the ambiguous one!)specificInclusion- An array of length equal to or greater than the number of states of the specific DataType. Each state of the specific data type is represented by the corresponding element in this array. The result of this method will be to set the states that the ambiguous state cannot represent to zero, and those states that the ambiguous state might represent to a value representing the frequency that the ambiguous state is actually that specific state. In general this should be one for each specific state covered by the ambiguous state (result should be suitable for use in likelihood calculations).
-
-