pal.datatype
Class DataType.Utils

java.lang.Object
  extended by pal.datatype.DataType.Utils
Enclosing interface:
DataType

public static final class DataType.Utils
extends java.lang.Object

Some useful methods for implmenting classes and for DataType users


Constructor Summary
DataType.Utils()
           
 
Method Summary
static byte[] getByteStates(char[] sequence, DataType dt)
          For converting a sequence to an array of bytes where each byte represents the state of the corresponding character in sequence
static byte[] getByteStates(java.lang.String sequence, DataType dt)
          For converting a sequence to an array of bytes where each byte represents the state of the corresponding character in sequence
static char[][] getChars(int[][] sequences, char unknownChar, char gapChar, DataType dt)
          For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence
static char[] getChars(int[] sequence, char unknownChar, char gapChar, DataType dt)
          For converting a sequence of ints representing states to an array of chars
static char[] getChars(int[] sequence, DataType dt)
          For converting a sequence of ints representing states to an array of chars
static DataType getInstance(int typeID)
          create object according to this code
static char[] getPreferredChars(char[] sequence, DataType dt)
          Converts a sequence of characters to the preferred form for a data type
static char[] getPreferredChars(char[] sequence, DataType dt, boolean specialDots)
          Converts a sequence of characters to the preferred form for a data type
static java.lang.String getPreferredChars(java.lang.String sequence, DataType dt)
          Converts a sequence of characters to the preferred form for a data type (using Strings)
static java.lang.String getPreferredChars(java.lang.String sequence, DataType dt, boolean specialDots)
          Converts a sequence of characters to the preferred form for a data type (using Strings) * @param specialDots if true then the dot (period) '.' is used even if it is not the prefered character by the data type
static int[][] getStates(char[][] sequences, DataType dt)
          For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence
static int[][] getStates(char[][] sequences, int unknownState, int gapState, DataType dt)
          For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence
static int[] getStates(char[] sequence, DataType dt)
          For converting a sequence to an array of ints where each int represents the state of the corresponding character in sequence
static int[] getStates(char[] sequence, int unknownState, int gapState, DataType dt)
          For converting a sequence to an array of ints where each int represents the state of the corresponding character in sequence Allows user selection of unknown and gap states
static boolean isGap(DataType d, char c)
          Deprecated. use DataType.isGapChar()
static boolean isSuggestedGap(char c)
          Useful for implementing classes to check if a character is a suggest gap character Users of datatypes should query the datatype to see if a character is a gap - not use this method.
static void leftAlignSequence(int[] sequence, DataType dt)
          Realigns a sequence of states so that there are no gaps at the beggining (shifts to the left if necessary)
static void reverseSequence(int[] sequence)
          Reverses an array of states
static java.lang.String toString(DataType dt, int[] states)
          For converting an array of states into a String of characters, based on a DataType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataType.Utils

public DataType.Utils()
Method Detail

isSuggestedGap

public static final boolean isSuggestedGap(char c)
Useful for implementing classes to check if a character is a suggest gap character Users of datatypes should query the datatype to see if a character is a gap - not use this method.


getInstance

public static DataType getInstance(int typeID)
create object according to this code

Parameters:
typeID - selected data type
Returns:
DataType object

isGap

public static final boolean isGap(DataType d,
                                  char c)
Deprecated. use DataType.isGapChar()

Returns:
true if the character represents a gap in the sequence.

getPreferredChars

public static final char[] getPreferredChars(char[] sequence,
                                             DataType dt)
Converts a sequence of characters to the preferred form for a data type


getPreferredChars

public static final char[] getPreferredChars(char[] sequence,
                                             DataType dt,
                                             boolean specialDots)
Converts a sequence of characters to the preferred form for a data type

Parameters:
specialDots - if true then the dot (period) '.' is used even if it is not the prefered character by the data type

getPreferredChars

public static final java.lang.String getPreferredChars(java.lang.String sequence,
                                                       DataType dt)
Converts a sequence of characters to the preferred form for a data type (using Strings)


getPreferredChars

public static final java.lang.String getPreferredChars(java.lang.String sequence,
                                                       DataType dt,
                                                       boolean specialDots)
Converts a sequence of characters to the preferred form for a data type (using Strings) * @param specialDots if true then the dot (period) '.' is used even if it is not the prefered character by the data type

Parameters:
specialDots - if true then the dot (period) '.' is used even if it is not the prefered character by the data type

getByteStates

public static final byte[] getByteStates(java.lang.String sequence,
                                         DataType dt)
For converting a sequence to an array of bytes where each byte represents the state of the corresponding character in sequence


getByteStates

public static final byte[] getByteStates(char[] sequence,
                                         DataType dt)
For converting a sequence to an array of bytes where each byte represents the state of the corresponding character in sequence


getStates

public static final int[][] getStates(char[][] sequences,
                                      int unknownState,
                                      int gapState,
                                      DataType dt)
For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence

Parameters:
unknownState - ensures that the state representation is set to this value (like -1)

getStates

public static final int[] getStates(char[] sequence,
                                    int unknownState,
                                    int gapState,
                                    DataType dt)
For converting a sequence to an array of ints where each int represents the state of the corresponding character in sequence Allows user selection of unknown and gap states


getStates

public static final int[][] getStates(char[][] sequences,
                                      DataType dt)
For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence


getStates

public static final int[] getStates(char[] sequence,
                                    DataType dt)
For converting a sequence to an array of ints where each int represents the state of the corresponding character in sequence


getChars

public static final char[][] getChars(int[][] sequences,
                                      char unknownChar,
                                      char gapChar,
                                      DataType dt)
For converting an array of sequence to arrays of ints where each int represents the state of the corresponding character in sequence

Parameters:
unknownChar - The character uses for unknown states
gapChar - the character to use for gap states (may be the same as the unknownChar)

getChars

public static final char[] getChars(int[] sequence,
                                    char unknownChar,
                                    char gapChar,
                                    DataType dt)
For converting a sequence of ints representing states to an array of chars

Parameters:
unknownChar - The character uses for unknown states
gapChar - the character to use for gap states (may be the same as the unknownChar)

getChars

public static final char[] getChars(int[] sequence,
                                    DataType dt)
For converting a sequence of ints representing states to an array of chars


toString

public static final java.lang.String toString(DataType dt,
                                              int[] states)
For converting an array of states into a String of characters, based on a DataType


reverseSequence

public static final void reverseSequence(int[] sequence)
Reverses an array of states

Parameters:
sequence - the sequence of states

leftAlignSequence

public static final void leftAlignSequence(int[] sequence,
                                           DataType dt)
Realigns a sequence of states so that there are no gaps at the beggining (shifts to the left if necessary)

Parameters:
sequence - the base sequence
dt - the datatype of the sequence states