use of beast.util.XMLParser in project beast2 by CompEvol.
the class ExampleXmlParsingTest method test_ThatXmlExamplesParse.
public void test_ThatXmlExamplesParse(String dir) {
try {
Randomizer.setSeed(127);
Logger.FILE_MODE = Logger.LogFileMode.overwrite;
System.out.println("Test XML Examples 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>();
for (String fileName : exampleFiles) {
System.out.println("Processing " + fileName);
XMLParser parser = new XMLParser();
try {
parser.parseFile(new File(dir + "/" + fileName));
} 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_ThatXmlExamplesParse::Failed for : " + failedFiles.toString());
} else {
System.out.println("\ntest_ThatXmlExamplesParse::Success");
}
assertTrue(failedFiles.toString(), failedFiles.size() == 0);
} catch (Exception e) {
System.out.println("exception thrown ");
System.out.println(e.getMessage());
}
}
use of beast.util.XMLParser in project beast2 by CompEvol.
the class XMLProducerTest method test_ThatNexusExamplesProduces.
// @Test
// public void test_ThatXmlExamplesProduces() {
// System.setProperty("java.only", "true");
// String dir = System.getProperty("user.dir") + "/examples";
// //String dir = "/tmp";
// List<String> exceptions = new ArrayList<String>();
// exceptions.add("testExponentialGrowth.xml");
// test_ThatXmlExamplesProduces(dir, exceptions);
// }
@Test
public void test_ThatNexusExamplesProduces() {
try {
String dirName = System.getProperty("user.dir") + "/examples/nexus";
System.out.println("Test Nexus Examples in " + dirName);
File exampleDir = new File(dirName);
String[] exampleFiles = exampleDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".nex") || name.endsWith(".nxs");
}
});
List<String> failedFiles = new ArrayList<>();
for (String fileName : exampleFiles) {
System.out.println("Processing " + fileName);
NexusParser parser = new NexusParser();
try {
parser.parseFile(new File(dirName + "/" + fileName));
} catch (Exception e) {
System.out.println("ExampleNexusParsing::Failed for " + fileName + ": " + e.getMessage());
failedFiles.add(fileName);
}
XMLProducer producer = new XMLProducer();
BEASTInterface o = parser.m_alignment;
if (o != null) {
String xml = producer.toXML(o);
// FileWriter outfile = new FileWriter(new File("/tmp/XMLProducerTest.xml"));
// outfile.write(xml);
// outfile.close();
XMLParser parser2 = new XMLParser();
try {
BEASTInterface o2 = parser2.parseFragment(xml, false);
System.out.println(o2);
} catch (Exception e) {
System.out.println("test_ThatNexusExamplesProduces::Failed for " + fileName + ": " + e.getMessage());
failedFiles.add(fileName);
}
}
System.out.println("Done " + fileName);
}
if (failedFiles.size() > 0) {
System.out.println("\test_ThatNexusExamplesProduces::Failed for : " + failedFiles.toString());
} else {
System.out.println("\test_ThatNexusExamplesProduces::Success");
}
assertTrue(failedFiles.toString(), failedFiles.size() == 0);
} catch (Exception e) {
System.out.println("exception thrown ");
System.out.println(e.getMessage());
}
}
use of beast.util.XMLParser in project bacter by tgvaughan.
the class AddRemoveDetourTest method test5Taxon.
@Test
public void test5Taxon() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(new File("examples/addRemoveDetourTests/addRemoveDetourTest5taxon.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("addRemoveDetourTest5taxon.stats", expectations);
for (int i = 0; i < expectations.size(); i++) {
assertTrue(expectations.get(i).isValid());
assertTrue(expectations.get(i).isPassed());
}
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon.stats"));
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon.converted"));
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon.trees"));
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon_trimmed.trees"));
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon.cf"));
Files.deleteIfExists(Paths.get("addRemoveDetourTest5taxon.xml.state"));
}
use of beast.util.XMLParser in project bacter by tgvaughan.
the class AllOperatorTest method testMultiLocus.
@Test
public void testMultiLocus() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(new File("examples/allOperatorTests/allOperatorTestSSMultiLocus.xml"));
disableScreenLog(runnable);
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 1.909, 0.2));
expectations.add(new Expectation("acg.CFlength", 4.655, 0.5));
expectations.add(new Expectation("acg.nConv", 23.381, 0.5));
LogAnalyser logAnalyser = new LogAnalyser("allOperatorTestSSMultiLocus.stats", expectations);
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
Files.deleteIfExists(Paths.get("allOperatorTestSSMultiLocus.stats"));
Files.deleteIfExists(Paths.get("allOperatorTestSSMultiLocus.converted"));
Files.deleteIfExists(Paths.get("allOperatorTestSSMultiLocus.trees"));
Files.deleteIfExists(Paths.get("allOperatorTestSSMultiLocus.cf"));
Files.deleteIfExists(Paths.get("allOperatorTestSSMultiLocus.xml.state"));
}
use of beast.util.XMLParser in project bacter by tgvaughan.
the class CFOperatorTest method testCFUniform.
@Test
public void testCFUniform() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(new File("examples/CFOperatorTests/CFUniformTest5taxon.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));
new LogAnalyser("CFUniformTest5taxon.stats", expectations);
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
Files.deleteIfExists(Paths.get("CFUniformTest5taxon.stats"));
Files.deleteIfExists(Paths.get("CFUniformTest5taxon.converted"));
Files.deleteIfExists(Paths.get("CFUniformTest5taxon.trees"));
Files.deleteIfExists(Paths.get("CFUniformTest5taxon.cf"));
Files.deleteIfExists(Paths.get("CFUniformTest5taxon.xml.state"));
}
Aggregations