lphy.base.evolution.alignment.TaxaCharacterMatrix Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lphy-base Show documentation
Show all versions of lphy-base Show documentation
The standard library of LPhy, which contains the required generative distributions and basic functions.
The newest version!
package lphy.base.evolution.alignment;
import lphy.base.evolution.HasTaxa;
import lphy.base.evolution.NChar;
import lphy.core.model.MultiDimensional;
import java.lang.reflect.Array;
public interface TaxaCharacterMatrix extends NChar, HasTaxa, MultiDimensional {
/**
* @param taxon
* @param characterColumn
* @return the character for the given taxon
*/
T getState(String taxon, int characterColumn);
/**
* @return the class of this character (e.g. Double for continuous characters, Integer for discrete characters)
*/
Class getComponentType();
/**
* @param taxon the taxon to get a sequence of
* @return an array of character states for the given taxon
*/
default T[] getCharacterSequence(String taxon) {
T[] sequence = (T[]) Array.newInstance(getComponentType(),nchar());
for (int i = 0; i < sequence.length; i++) {
sequence[i] = getState(taxon, i);
}
return sequence;
}
/**
* @return a JSON for pretty printing
*/
String toJSON();
}