|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmesquite.lib.characters.CharacterState
mesquite.categ.lib.CategoricalState
public class CategoricalState
This class provides some basic utilities for sets of states of categorical characters. Many of the utilities are static to be used for basic set calculations, but a categorical set can also be instantiated so as to have a parameter to pass by reference. In most calculates, state sets of categorical characters are NOT stored with these objects because it would be too costly. Instead, they are stored as simple long variables (64 bits, 56 possible states).
| Field Summary | |
|---|---|
static long |
dataBitsMask
The mask that preserves bits 0.. |
static long |
highBitsMask
The mask that preserves the high bits used for special flags |
static long |
impossible
The state (1L<<62) that corresponds to an invalid CategoricalState. |
static long |
inapplicable
The state that corresponds to a gap (inapplicable) |
static int |
inapplicableBit
The bit that signals a gap (inapplicable) |
static int |
inapplicableBitInt
|
static long |
intStatesBitsMaskL
|
static int |
lowerCaseBit
The bit that signals the symbol is to be shown lower case |
static int |
maxCategoricalState
The maximum allowed categorical state (55) |
static int |
polymorphismElement
a value for arrays that store information about frequency of states; this would need to change if ever maxCategoricalState goes to 58 |
static long |
shortStatesBitsMaskL
The masks that preserves bits 0.. |
static long |
statesBitsMask
The mask that preserves bits 0.. |
static int |
statesBitsMaskInt
|
static int |
TOTALBITS
|
static long |
unassigned
The state (1L<<63) that corresponds to missing data. |
static int |
unassignedBit
The bit that signals missing data |
static int |
unassignedBitInt
Bits to be used if int used instead of long for state storage |
static int |
uncertainBit
The bit that signals uncertainty |
static int |
uncertainBitInt
|
| Constructor Summary | |
|---|---|
CategoricalState()
|
|
CategoricalState(long initial)
|
|
| Method Summary | |
|---|---|
static long |
addToSet(long s,
int e)
return the result of adding state e to state set s |
int |
cardinality()
returns number of states in state set |
static int |
cardinality(int shortS)
returns number of states in state set shortS |
static int |
cardinality(long s)
returns number of states in state set s |
static long |
chooseHighest(double[] values,
double toleranceProportion)
|
static long |
chooseHighestWithinFactor(double[] values,
double factor)
|
static long |
chooseLowest(double[] values,
double toleranceProportion)
|
static long |
clearFromSet(long s,
int e)
return the result of subtracting state e to state set s |
static long |
clearFromSet(long s,
long e)
return the result of subtracting state e to state set s |
static long |
compressFromList(int[] states)
Compresses array listing included elements into state set form (long, with bits set). |
static long |
compressFromPresence(double[] states)
Compresses array with presence (>0) or absence (<=0) for each element into state set form (long, with bits set). |
static boolean |
compressibleToInt(long s)
|
static boolean |
compressibleToShort(long s)
|
static int |
compressToInt(long s)
|
static short |
compressToShort(long s)
|
static long |
emptySet()
returns state set |
boolean |
equals(CharacterState s)
returns true iff state sets are same |
boolean |
equals(CharacterState s,
boolean allowMissing)
returns true iff state sets are same |
boolean |
equals(CharacterState s,
boolean allowMissing,
boolean allowNearExact)
returns true iff state sets are same |
boolean |
equals(CharacterState s,
boolean allowMissing,
boolean allowNearExact,
boolean allowSubset)
returns true iff state sets are same |
static int[] |
expand(long s)
Expands state set (passed as long) to full array of included elements. |
static long |
expandFromInt(int s)
|
static long |
expandFromShort(short s)
|
static long |
firstSet(int numInSet)
Returns the set that is {0,...,(numInSet-1)} That is, the first "numInSet" bits are set. |
long |
fromChar(char c)
return the state set containing the state represented by the character (e.g., '0' to {0}); Used default symbols since no CharacterData is specified � |
static long |
fullSet()
returns state set consisting of all elements |
java.lang.Class |
getCharacterDataClass()
returns the class of the corresponding (i.e. |
java.lang.Class |
getCharacterDistributionClass()
returns the Adjustable class of the corresponding (i.e. |
java.lang.Class |
getCharacterHistoryClass()
returns the class of the corresponding (i.e. |
java.lang.String |
getDataTypeName()
returns the name of the type of data stored |
int |
getMaxPossibleState()
returns the maximum possible state |
static int |
getMaxPossibleStateStatic()
returns the maximum possible state |
java.lang.Class |
getMCharactersDistributionClass()
returns the Adjustable class of the corresponding (i.e. |
static int |
getOnlyElement(long s)
Returns the only element in state set s. |
static int |
getTotalBitsInStateSet()
|
long |
getValue()
gets the value of the state set |
static boolean |
hasMultipleStates(long s)
returns whether number of states in state set s is greater than 1 |
static long |
intersection(long s1,
long s2)
return the result of taking the intersection of two states |
boolean |
isCombinable()
returns whether value is combinable (i.e. |
static boolean |
isCombinable(long s)
returns whether value is combinable (i.e. |
boolean |
isElement(int e)
returns true iff e is element in state set |
static boolean |
isElement(long s,
int e)
returns true iff e is element in state set s |
static boolean |
isEmpty(long s)
returns state set |
boolean |
isImpossible()
returns whether value is valid or not. |
static boolean |
isImpossible(long s)
returns whether value is valid or not. |
boolean |
isInapplicable()
returns true iff state set is inapplicable |
static boolean |
isInapplicable(long s)
returns true iff state set passed is inapplicable. |
boolean |
isLowerCase()
return whether uncertainty flag is set in state set s |
static boolean |
isLowerCase(long s)
return whether uncertainty flag is set in state set s |
static boolean |
isOnlyElement(long s,
int e)
returns true if e is only state in state set s |
static boolean |
isSubset(long sub,
long s)
returns true iff the first long is a subset of the second |
boolean |
isUnassigned()
returns true iff stateset is unassigned (missing data) |
static boolean |
isUnassigned(long s)
returns true iff state set passed is unassigned (missing data) |
static boolean |
isUnassignedInt(int s)
return whether uncertainty flag is set in state set s |
static boolean |
isUncertain(long s)
return whether uncertainty flag is set in state set s |
static boolean |
legalState(int e)
returns whether state is within allowed range. |
AdjustableDistribution |
makeAdjustableDistribution(Taxa taxa,
int numNodes)
returns a AdjustableDistribution that is equivalent to this character type (i.e., in which sort of matrix would this character state reside? |
CharacterHistory |
makeCharacterHistory(Taxa taxa,
int numNodes)
returns a CharacterHistory that is equivalent to this character type (i.e., in which sort of matrix would this character state reside? |
static long |
makeSet(int e)
returns a state set including only the state e |
static long |
makeSet(int e1,
int e2)
returns a state set including only the states e1 & e2 |
static long |
makeSet(int e1,
int e2,
int e3)
returns a state set including only the states e1 & e2 & e3 |
static long |
makeSet(int e1,
int e2,
int e3,
int e4)
returns a state set including only the states e1 & e2 & e3 & e4 |
static long |
makeSetFromLowerBits(int shortS)
returns a state set including only elements in shortS; if shortS has multiple elements, the uncertainty bit is set. |
static int |
maximum(long s)
return maximum value of states in state set s |
static long |
mergeStates(long s1,
long s2)
merges the states |
static int |
minimum(long s)
returns minimum element in state set s |
static CategoricalState |
newState()
returns new state |
static long |
nextSet(long current,
int maxS)
When passed a set, returns the next set in sequence with the same number of elements and with maximum element maxS. |
static long |
setInapplicable(long s,
boolean b)
Adds or clears the inapplicable bit of state set s , used for merging operations |
static long |
setLowerCase(long s,
boolean lowerCase)
return the result of setting or clearing the lowerCase flag of state set s |
void |
setToInapplicable()
sets the value to inapplicable |
void |
setToUnassigned()
sets the value to unassigned |
static long |
setUnassigned(long s,
boolean b)
Adds or clears the unassigned bit of state set s , used for merging operations |
static long |
setUncertainty(long s,
boolean uncertain)
return the result of setting or clearing the uncertainty flag of state set s |
void |
setValue(CharacterState cs)
sets the value using the passed CharacterState's value if of same type |
void |
setValue(long value)
sets the value of the state set to the long variable passed |
void |
setValue(java.lang.String s,
CharacterData parentData)
sets its value to the value given by the String passed to it |
void |
setValue(java.lang.String s,
MesquiteInteger pos)
sets its value to the value given by the String passed to it starting at position pos � |
static long |
span(int a,
int b)
return a state set with all states a through b inclusive. |
static long |
span(long s)
returns the state set spanning min to max of s |
boolean |
statesShared(CategoricalState cs)
return whether or not the two state sets share any states |
static boolean |
statesShared(long s1,
long s2)
return whether or not the two state sets share any states |
java.lang.String |
toDisplayString()
Returns string as would be displayed to user (not necessarily internal shorthand). |
java.lang.String |
toNEXUSString()
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toNEXUSString(long s)
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toSimpleString(long s)
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toSimpleStringHB(long s)
converts passed long (treated as CategoricalState) to string. |
java.lang.String |
toString()
returns the String description of the state set |
static java.lang.String |
toString(long s)
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toString(long s,
boolean useBraces)
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toString(long s,
CategoricalData data,
int ic,
boolean useBraces)
converts passed long (treated as CategoricalState) to string. |
static java.lang.String |
toString(long s,
CategoricalData data,
int ic,
boolean useBraces,
boolean useSymbols)
converts passed long (treated as CategoricalState) to string. |
static long |
union(long s1,
long s2)
return the result of taking the union of two states |
int |
whichState(char c)
|
| Methods inherited from class mesquite.lib.characters.CharacterState |
|---|
makeMCharactersDistribution |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long unassigned
public static final long inapplicable
public static final long impossible
public static final int polymorphismElement
public static final int unassignedBit
public static final int inapplicableBit
public static final int uncertainBit
public static final int lowerCaseBit
public static final int maxCategoricalState
public static final long highBitsMask
public static final long statesBitsMask
public static final long dataBitsMask
public static final int unassignedBitInt
public static final int inapplicableBitInt
public static final int uncertainBitInt
public static final int statesBitsMaskInt
public static final int TOTALBITS
public static final long shortStatesBitsMaskL
public static final long intStatesBitsMaskL
| Constructor Detail |
|---|
public CategoricalState()
public CategoricalState(long initial)
| Method Detail |
|---|
public java.lang.String getDataTypeName()
getDataTypeName in class CharacterStatepublic java.lang.Class getCharacterDataClass()
getCharacterDataClass in class CharacterStatepublic java.lang.Class getMCharactersDistributionClass()
getMCharactersDistributionClass in class CharacterStatepublic java.lang.Class getCharacterDistributionClass()
getCharacterDistributionClass in class CharacterStatepublic java.lang.Class getCharacterHistoryClass()
getCharacterHistoryClass in class CharacterState
public AdjustableDistribution makeAdjustableDistribution(Taxa taxa,
int numNodes)
CharacterState
makeAdjustableDistribution in class CharacterState
public CharacterHistory makeCharacterHistory(Taxa taxa,
int numNodes)
CharacterState
makeCharacterHistory in class CharacterStatepublic static boolean isUnassigned(long s)
public boolean isUnassigned()
isUnassigned in class CharacterStatepublic static boolean isInapplicable(long s)
public boolean isInapplicable()
isInapplicable in class CharacterStatepublic boolean isImpossible()
isImpossible in class CharacterStatepublic static boolean isImpossible(long s)
public boolean isCombinable()
isCombinable in class CharacterStatepublic static boolean isCombinable(long s)
public static boolean legalState(int e)
public boolean equals(CharacterState s)
equals in class CharacterState
public boolean equals(CharacterState s,
boolean allowMissing)
equals in class CharacterState
public boolean equals(CharacterState s,
boolean allowMissing,
boolean allowNearExact)
equals in class CharacterState
public boolean equals(CharacterState s,
boolean allowMissing,
boolean allowNearExact,
boolean allowSubset)
equals in class CharacterStatepublic static CategoricalState newState()
public static boolean isEmpty(long s)
public static long emptySet()
public static long fullSet()
public static long firstSet(int numInSet)
public static long nextSet(long current,
int maxS)
public boolean isElement(int e)
public static boolean isElement(long s,
int e)
public static boolean isSubset(long sub,
long s)
public static int minimum(long s)
public static int getOnlyElement(long s)
public static int cardinality(int shortS)
public static int cardinality(long s)
public int cardinality()
public static boolean hasMultipleStates(long s)
public static int maximum(long s)
public static boolean isOnlyElement(long s,
int e)
public static long makeSet(int e)
public static long makeSetFromLowerBits(int shortS)
public static long makeSet(int e1,
int e2)
public static long makeSet(int e1,
int e2,
int e3)
public static long makeSet(int e1,
int e2,
int e3,
int e4)
public static long span(int a,
int b)
public static long span(long s)
public static long mergeStates(long s1,
long s2)
public static long setInapplicable(long s,
boolean b)
public static long setUnassigned(long s,
boolean b)
public static long setLowerCase(long s,
boolean lowerCase)
public static boolean isLowerCase(long s)
public boolean isLowerCase()
public static long setUncertainty(long s,
boolean uncertain)
public static boolean isUncertain(long s)
public static long addToSet(long s,
int e)
public static long union(long s1,
long s2)
public static long intersection(long s1,
long s2)
public static boolean statesShared(long s1,
long s2)
public boolean statesShared(CategoricalState cs)
public static long clearFromSet(long s,
long e)
public static long clearFromSet(long s,
int e)
public static long chooseHighestWithinFactor(double[] values,
double factor)
public static long chooseHighest(double[] values,
double toleranceProportion)
public static long chooseLowest(double[] values,
double toleranceProportion)
public static boolean compressibleToShort(long s)
public static short compressToShort(long s)
public static long expandFromShort(short s)
public static boolean compressibleToInt(long s)
public static int compressToInt(long s)
public static long expandFromInt(int s)
public static int[] expand(long s)
public static long compressFromList(int[] states)
public static long compressFromPresence(double[] states)
public void setToInapplicable()
setToInapplicable in class CharacterStatepublic void setToUnassigned()
setToUnassigned in class CharacterStatepublic long getValue()
public void setValue(long value)
public void setValue(CharacterState cs)
setValue in class CharacterState
public void setValue(java.lang.String s,
MesquiteInteger pos)
setValue in class CharacterState
public void setValue(java.lang.String s,
CharacterData parentData)
CharacterState
setValue in class CharacterStatepublic long fromChar(char c)
public int whichState(char c)
public java.lang.String toString()
toString in class CharacterStatepublic static java.lang.String toString(long s)
public static java.lang.String toString(long s,
boolean useBraces)
public static java.lang.String toString(long s,
CategoricalData data,
int ic,
boolean useBraces)
public static java.lang.String toString(long s,
CategoricalData data,
int ic,
boolean useBraces,
boolean useSymbols)
public java.lang.String toDisplayString()
toDisplayString in class CharacterStatepublic static java.lang.String toSimpleString(long s)
public java.lang.String toNEXUSString()
public static java.lang.String toNEXUSString(long s)
public static java.lang.String toSimpleStringHB(long s)
public static int getMaxPossibleStateStatic()
public static int getTotalBitsInStateSet()
public int getMaxPossibleState()
public static boolean isUnassignedInt(int s)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||