Search in sources :

Example 66 with Alignment

use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.

the class FilteredAlignmentTest method testRangeFiltered.

@Test
public void testRangeFiltered() throws Exception {
    Alignment data = getAlignment();
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data, "filter", "1-9");
    assertEquals(9, data2.getSiteCount());
    assertEquals(9, data2.getPatternCount());
    data2.initByName("data", data, "filter", "2-9");
    assertEquals(8, data2.getSiteCount());
    assertEquals(8, data2.getPatternCount());
    data2.initByName("data", data, "filter", "10-");
    assertEquals(7, data2.getSiteCount());
    data2.initByName("data", data, "filter", "-10");
    assertEquals(10, data2.getSiteCount());
    data2.initByName("data", data, "filter", "-");
    assertEquals(16, data2.getSiteCount());
    data2.initByName("data", data, "filter", "2-5,7-10");
    assertEquals(8, data2.getSiteCount());
    assertEquals(8, data2.getPatternCount());
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Test(org.junit.Test)

Example 67 with Alignment

use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.

the class FilteredAlignmentTest method testReordered.

@Test
public void testReordered() throws Exception {
    // make sure the order of sites is not affected by filtering
    Alignment data = getAlignmentNoTInHuman();
    data.setID("data");
    // second sequence not in alphabetical order
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data, "filter", "3:6:1");
    System.out.println("human\t" + alignmentToString(data2, 0) + "\n1chimp\t" + alignmentToString(data2, 1));
    assertEquals(alignmentToString(data2, 0), "AACC");
    assertEquals(alignmentToString(data2, 1), "GTAC");
    // first sequence not in alphabetical order
    FilteredAlignment data3 = new FilteredAlignment();
    data3.initByName("data", data, "filter", "11:14:1");
    System.out.println("human\t" + alignmentToString(data3, 0) + "\n1chimp\t" + alignmentToString(data3, 1));
    assertEquals(alignmentToString(data3, 0), "GGAA");
    assertEquals(alignmentToString(data3, 1), "GTAC");
    // first sequence not in alphabetical order, repeat site
    FilteredAlignment data4 = new FilteredAlignment();
    data4.initByName("data", data, "filter", "3:16:4");
    System.out.println("human\t" + alignmentToString(data4, 0) + "\n1chimp\t" + alignmentToString(data4, 1));
    assertEquals(alignmentToString(data4, 0), "ACGA");
    assertEquals(alignmentToString(data4, 1), "GGGG");
    // first and second sequence not in alphabetical order
    FilteredAlignment data5 = new FilteredAlignment();
    data5.initByName("data", data, "filter", "4:14:3");
    System.out.println("human\t" + alignmentToString(data5, 0) + "\n1chimp\t" + alignmentToString(data5, 1));
    assertEquals(alignmentToString(data5, 0), "ACGA");
    assertEquals(alignmentToString(data5, 1), "TGCA");
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Test(org.junit.Test)

Example 68 with Alignment

use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.

the class FilteredAlignmentTest method testFilteredFileredAlignment.

@Test
public void testFilteredFileredAlignment() throws Exception {
    Alignment data1 = getAlignment();
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data1, "filter", "2:16:2");
    FilteredAlignment data3 = new FilteredAlignment();
    // , "ascertained", true, "excludeto", 1);
    data3.initByName("data", data2, "filter", "-");
    assertEquals(alignmentToString(data2, 0), alignmentToString(data3, 0));
    assertEquals(alignmentToString(data2, 1), alignmentToString(data3, 1));
    FilteredAlignment data4 = new FilteredAlignment();
    data4.initByName("data", data3, "filter", "-", "ascertained", true, "excludeto", 1);
    assertEquals(alignmentToString(data2, 0), alignmentToString(data4, 0));
    assertEquals(alignmentToString(data2, 1), alignmentToString(data4, 1));
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Test(org.junit.Test)

Example 69 with Alignment

use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.

the class FilteredAlignmentTest method testIteratorFiltered.

@Test
public void testIteratorFiltered() throws Exception {
    Alignment data = getAlignment();
    FilteredAlignment data2 = new FilteredAlignment();
    data2.initByName("data", data, "filter", "1:16:2");
    assertEquals(8, data2.getSiteCount());
    assertEquals(8, data2.getPatternCount());
    int iPattern = data2.getPatternIndex(0);
    int[] pattern = data2.getPattern(iPattern);
    assertEquals(0, pattern[0]);
    assertEquals(0, pattern[1]);
    data2.initByName("data", data, "filter", "2:16:2");
    assertEquals(8, data2.getSiteCount());
    iPattern = data2.getPatternIndex(0);
    pattern = data2.getPattern(iPattern);
    assertEquals(0, pattern[0]);
    assertEquals(1, pattern[1]);
    data2.initByName("data", data, "filter", "1:10:2");
    assertEquals(5, data2.getSiteCount());
    data2.initByName("data", data, "filter", "1::3");
    assertEquals(6, data2.getSiteCount());
    data2.initByName("data", data, "filter", "2::3");
    assertEquals(5, data2.getSiteCount());
    data2.initByName("data", data, "filter", "::");
    assertEquals(16, data2.getSiteCount());
    data2.initByName("data", data, "filter", "2:5:");
    assertEquals(4, data2.getSiteCount());
    data2.initByName("data", data, "filter", ":5:");
    assertEquals(5, data2.getSiteCount());
    data2.initByName("data", data, "filter", "1::3,2::3");
    assertEquals(11, data2.getSiteCount());
    // System.out.println(alignmentToString(data2, 1));
    data2.initByName("data", data, "filter", "3::3");
    assertEquals(5, data2.getSiteCount());
// System.out.println(alignmentToString(data2, 1));
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Test(org.junit.Test)

Example 70 with Alignment

use of beast.evolution.alignment.Alignment in project beast2 by CompEvol.

the class FilteredAlignmentTest method getAlignmentNoTInHuman.

public static Alignment getAlignmentNoTInHuman() throws Exception {
    Sequence human = new Sequence("0human", "AAAACCCCGGGGAAAA");
    Sequence chimp = new Sequence("1chimp", "ACGTACGTACGTACGT");
    Alignment data = new Alignment();
    data.initByName("sequence", human, "sequence", chimp, "dataType", "nucleotide");
    return data;
}
Also used : Alignment(beast.evolution.alignment.Alignment) FilteredAlignment(beast.evolution.alignment.FilteredAlignment) Sequence(beast.evolution.alignment.Sequence)

Aggregations

Alignment (beast.evolution.alignment.Alignment)102 Test (org.junit.Test)43 Sequence (beast.evolution.alignment.Sequence)31 FilteredAlignment (beast.evolution.alignment.FilteredAlignment)30 Tree (beast.evolution.tree.Tree)29 SiteModel (beast.evolution.sitemodel.SiteModel)27 TreeLikelihood (beast.evolution.likelihood.TreeLikelihood)22 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)20 ArrayList (java.util.ArrayList)17 UncertainAlignmentTest (test.beast.evolution.alignment.UncertainAlignmentTest)17 Frequencies (beast.evolution.substitutionmodel.Frequencies)13 RealParameter (beast.core.parameter.RealParameter)12 TaxonSet (beast.evolution.alignment.TaxonSet)11 BEASTInterface (beast.core.BEASTInterface)10 ClusterTree (beast.util.ClusterTree)9 Taxon (beast.evolution.alignment.Taxon)6 HKY (beast.evolution.substitutionmodel.HKY)6 Node (beast.evolution.tree.Node)6 TreeParser (beast.util.TreeParser)6 IOException (java.io.IOException)6