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());
}
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");
}
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));
}
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));
}
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;
}
Aggregations