use of beast.core.MCMC in project beast2 by CompEvol.
the class ExampleXmlParsingTest method test_ThatXmlExamplesRun.
public void test_ThatXmlExamplesRun(String dir) {
try {
Logger.FILE_MODE = Logger.LogFileMode.overwrite;
System.out.println("Test that XML Examples run in " + dir);
File exampleDir = new File(dir);
String[] exampleFiles = exampleDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xml");
}
});
List<String> failedFiles = new ArrayList<String>();
int seed = 127;
for (String fileName : exampleFiles) {
Randomizer.setSeed(seed);
// need more than one to prevent trouble with multiMCMC logs
seed += 10;
System.out.println("Processing " + fileName);
XMLParser parser = new XMLParser();
try {
beast.core.Runnable runable = parser.parseFile(new File(dir + "/" + fileName));
if (runable instanceof MCMC) {
MCMC mcmc = (MCMC) runable;
mcmc.setInputValue("preBurnin", 0);
mcmc.setInputValue("chainLength", 1000l);
mcmc.run();
}
} catch (Exception e) {
System.out.println("ExampleXmlParsing::Failed for " + fileName + ": " + e.getMessage());
failedFiles.add(fileName);
}
System.out.println("Done " + fileName);
}
if (failedFiles.size() > 0) {
System.out.println("\ntest_ThatXmlExamplesRun::Failed for : " + failedFiles.toString());
} else {
System.out.println("SUCCESS!!!");
}
assertTrue(failedFiles.toString(), failedFiles.size() == 0);
} catch (Exception e) {
System.out.println("exception thrown ");
System.out.println(e.getMessage());
;
}
}
use of beast.core.MCMC in project beast2 by CompEvol.
the class ResumeTest method test_ThatXmlExampleResumes.
@Test
public void test_ThatXmlExampleResumes() throws Exception {
Randomizer.setSeed(127);
Logger.FILE_MODE = Logger.LogFileMode.overwrite;
String dir = System.getProperty("user.dir") + "/examples";
String fileName = dir + "/" + XML_FILE;
System.out.println("Processing " + fileName);
XMLParser parser = new XMLParser();
beast.core.Runnable runable = parser.parseFile(new File(fileName));
runable.setStateFile("tmp.state", false);
if (runable instanceof MCMC) {
MCMC mcmc = (MCMC) runable;
mcmc.setInputValue("preBurnin", 0);
mcmc.setInputValue("chainLength", 1000l);
mcmc.run();
}
System.out.println("Done " + fileName);
System.out.println("Resuming " + fileName);
Logger.FILE_MODE = Logger.LogFileMode.resume;
parser = new XMLParser();
runable = parser.parseFile(new File(fileName));
runable.setStateFile("tmp.state", true);
if (runable instanceof MCMC) {
MCMC mcmc = (MCMC) runable;
mcmc.setInputValue("preBurnin", 0);
mcmc.setInputValue("chainLength", 1000l);
mcmc.run();
}
System.out.println("Done " + fileName);
}
Aggregations