Search in sources :

Example 1 with IntegerData

use of beast.evolution.datatype.IntegerData in project beast2 by CompEvol.

the class IntegerDataTest method testIntegerData.

@Test
public void testIntegerData() {
    IntegerData datatype = new IntegerData();
    assertEquals("?", datatype.getCharacter(-1));
    assertEquals("0", datatype.getCharacter(0));
    assertEquals("1", datatype.getCharacter(1));
    assertEquals("10", datatype.getCharacter(10));
    assertEquals("123", datatype.getCharacter(123));
    Randomizer.setSeed(127);
    for (int i = 0; i < 100; i++) {
        int state = Randomizer.nextInt(100000000);
        int x = state;
        String str = "";
        while (state > 0) {
            str = (char) ('0' + state % 10) + str;
            state /= 10;
        }
        assertEquals(str, datatype.getCharacter(x));
    }
}
Also used : IntegerData(beast.evolution.datatype.IntegerData) Test(org.junit.Test)

Example 2 with IntegerData

use of beast.evolution.datatype.IntegerData in project beast2 by CompEvol.

the class DataTypeDeEncodeTest method typestrings.

@Parameterized.Parameters
public static Collection<Object[]> typestrings() {
    Base dAa = new Aminoacid();
    Base dBi = new Binary();
    Base dIn = new IntegerData();
    Base dNt = new Nucleotide();
    Base d2C = new TwoStateCovarion();
    return Arrays.asList(new Object[][] { { dIn, "1,2,14,23,?", Arrays.asList(new Integer[] { 1, 2, 14, 23, -1 }) }, { dNt, "ACGTURYMWSKBDHVNX", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }) }, { dBi, "01-?10", Arrays.asList(new Integer[] { 0, 1, 2, 3, 1, 0 }) }, { d2C, "01ABCD-?", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7 }) }, { dAa, "ACDEFGHIKLMNPQRSTVWY", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }) } });
}
Also used : Aminoacid(beast.evolution.datatype.Aminoacid) IntegerData(beast.evolution.datatype.IntegerData) Nucleotide(beast.evolution.datatype.Nucleotide) Binary(beast.evolution.datatype.Binary) TwoStateCovarion(beast.evolution.datatype.TwoStateCovarion) Base(beast.evolution.datatype.DataType.Base)

Aggregations

IntegerData (beast.evolution.datatype.IntegerData)2 Aminoacid (beast.evolution.datatype.Aminoacid)1 Binary (beast.evolution.datatype.Binary)1 Base (beast.evolution.datatype.DataType.Base)1 Nucleotide (beast.evolution.datatype.Nucleotide)1 TwoStateCovarion (beast.evolution.datatype.TwoStateCovarion)1 Test (org.junit.Test)1