Search in sources :

Example 21 with Expectation

use of test.beast.beast2vs1.trace.Expectation in project bacter by tgvaughan.

the class RegionShiftTest method testRegionShift.

@Test
public void testRegionShift() throws Exception {
    Randomizer.setSeed(1);
    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(new File("examples/regionShiftTests/regionShiftTest5taxon.xml"));
    disableScreenLog(runnable);
    runnable.run();
    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.606, 0.2));
    expectations.add(new Expectation("acg.CFlength", 4.181, 0.5));
    expectations.add(new Expectation("acg.nConv", 21.0, 0.5));
    LogAnalyser logAnalyser = new LogAnalyser("regionShiftTest5taxon.stats", expectations);
    for (int i = 0; i < expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.stats"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.converted"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.trees"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.cf"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.xml.state"));
}
Also used : LogAnalyser(test.beast.beast2vs1.trace.LogAnalyser) ArrayList(java.util.ArrayList) XMLParser(beast.util.XMLParser) Expectation(test.beast.beast2vs1.trace.Expectation) File(java.io.File) Test(org.junit.Test)

Example 22 with Expectation

use of test.beast.beast2vs1.trace.Expectation in project bacter by tgvaughan.

the class SimulatedACGTest method test5Taxon.

@Test
public void test5Taxon() throws Exception {
    Randomizer.setSeed(1);
    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(new File("examples/ACGsimulations/simulateACGs5taxon.xml"));
    runnable.run();
    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.606, 1e-2));
    expectations.add(new Expectation("acg.CFlength", 4.181, 1e-2));
    expectations.add(new Expectation("acg.nConv", 21.0, 5e-2));
    LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxon.stats", expectations);
    for (int i = 0; i < expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }
    Files.deleteIfExists(Paths.get("simulateACGs5taxon.stats"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxon.converted"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxon.trees"));
}
Also used : LogAnalyser(test.beast.beast2vs1.trace.LogAnalyser) ArrayList(java.util.ArrayList) XMLParser(beast.util.XMLParser) Expectation(test.beast.beast2vs1.trace.Expectation) File(java.io.File) Test(org.junit.Test)

Example 23 with Expectation

use of test.beast.beast2vs1.trace.Expectation in project beast2 by CompEvol.

the class TestFramework method addExpIntoList.

protected void addExpIntoList(List<Expectation> expList, String traceName, Double expValue, Double stdError) throws Exception {
    Expectation exp = new Expectation(traceName, expValue, stdError);
    expList.add(exp);
}
Also used : Expectation(test.beast.beast2vs1.trace.Expectation)

Example 24 with Expectation

use of test.beast.beast2vs1.trace.Expectation in project beast2 by CompEvol.

the class TestFramework method analyse.

// protected abstract void analyse() throws Exception;
public void analyse(int index_XML) throws Exception {
    // for (int i = 0; i < xmls.length; i++) {
    // if (giveExpectations(i).size() > 0) {
    Randomizer.setSeed(SEED);
    Logger.FILE_MODE = Logger.LogFileMode.overwrite;
    long beagleFlags = BeagleFlag.PROCESSOR_CPU.getMask() | BeagleFlag.VECTOR_SSE.getMask();
    System.setProperty("beagle.preferred.flags", Long.toString(beagleFlags));
    String fileName = dirName + xmls[index_XML];
    System.out.println("Processing " + fileName);
    XMLParser parser = new XMLParser();
    beast.core.Runnable runable = parser.parseFile(new File(fileName));
    runable.setStateFile("tmp.state", false);
    // runable.setInputValue("preBurnin", 0);
    // runable.setInputValue("chainLength", 1000);
    runable.run();
    String logFile = logDir + testFile + (useSeed ? SEED : "") + ".log";
    System.out.println("\nAnalysing log " + logFile);
    // burnIn = 0.1 * maxState
    LogAnalyser logAnalyser = new LogAnalyser(logFile, giveExpectations(index_XML));
    for (Expectation expectation : logAnalyser.m_pExpectations.get()) {
        Assert.assertTrue(xmls[index_XML] + ": Expected " + expectation.traceName.get() + " delta mean: " + expectation.expValue.get() + " - " + expectation.getTraceStatistics().getMean() + " <= delta stdErr: 2*(" + expectation.getStdError() + " + " + expectation.getTraceStatistics().getStdErrorOfMean() + ")", expectation.isPassed());
        if (checkESS)
            Assert.assertTrue(xmls[index_XML] + ":  has very low effective sample sizes (ESS) " + expectation.getTraceStatistics().getESS(), expectation.isValid());
    }
    System.out.println("\nSucceed " + fileName);
    System.out.println("\n***************************************\n");
// }
// }
}
Also used : LogAnalyser(test.beast.beast2vs1.trace.LogAnalyser) XMLParser(beast.util.XMLParser) Expectation(test.beast.beast2vs1.trace.Expectation) File(java.io.File)

Aggregations

Expectation (test.beast.beast2vs1.trace.Expectation)24 XMLParser (beast.util.XMLParser)23 File (java.io.File)23 LogAnalyser (test.beast.beast2vs1.trace.LogAnalyser)23 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)22