本文整理汇总了Java中beast.util.XMLParser类的典型用法代码示例。如果您正苦于以下问题:Java XMLParser类的具体用法?Java XMLParser怎么用?Java XMLParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLParser类属于beast.util包,在下文中一共展示了XMLParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import beast.util.XMLParser; //导入依赖的package包/类
void process(Alignment data, int iteration) throws IOException, XMLParserException, IllegalArgumentException, IllegalAccessException {
// read template
String templateXML = BeautiDoc.load(templateFile);
templateXML = templateXML.replaceAll("\\$\\(n\\)", iteration+"");
XMLParser parser = new XMLParser();
BEASTInterface b = parser.parseBareFragment(templateXML, false);
// repalce alignment
Alignment a = getAlignment(b);
List<Sequence> sequences = a.sequenceInput.get();
sequences.clear();
sequences.addAll(data.sequenceInput.get());
// write file
String outputFile = outputFileInput.get();
outputFile = outputFile.replaceAll("\\$\\(n\\)", iteration+"");
FileWriter outfile = new FileWriter(outputFile);
Set<BEASTInterface> beastObjects = new HashSet<>();
String xml = new XMLProducer().toXML(b, beastObjects);
outfile.write(xml);
outfile.close();
}
示例2: testScaleWithInt
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void testScaleWithInt() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("test/epiinf/xmltests/ScaleWithIntTest.xml"));
Logger.FILE_MODE = Logger.LogFileMode.overwrite;
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("x1", 0.5, 0.01));
expectations.add(new Expectation("y1", 0.5, 0.01));
expectations.add(new Expectation("y2", 0.5, 0.01));
expectations.add(new Expectation("y3", 0.5, 0.01));
expectations.add(new Expectation("n", 50.0, 1.0));
LogAnalyser logAnalyser = new LogAnalyser("ScaleWithIntTest.log", expectations);
try {
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
} catch (Exception e) {
throw e;
} finally {
Files.deleteIfExists(Paths.get("ScaleWithIntTest.xml.state"));
Files.deleteIfExists(Paths.get("ScaleWithIntTest.log"));
}
}
示例3: test2Taxon
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void test2Taxon() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/ACGsimulations/simulateACGs2taxon.xml"));
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 1.0, 1e-2));
expectations.add(new Expectation("acg.CFlength", 2.0, 1e-2));
expectations.add(new Expectation("acg.nConv", 10.0, 5e-2));
LogAnalyser logAnalyser = new LogAnalyser("simulateACGs2taxon.stats",
expectations);
for (int i=0; i<expectations.size(); i++) {
assertTrue(expectations.get(i).isValid());
assertTrue(expectations.get(i).isPassed());
}
Files.deleteIfExists(Paths.get("simulateACGs2taxon.stats"));
Files.deleteIfExists(Paths.get("simulateACGs2taxon.converted"));
Files.deleteIfExists(Paths.get("simulateACGs2taxon.trees"));
}
示例4: testShortMultiLocus
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void testShortMultiLocus() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/allOperatorTests/allOperatorTestShortSSML.xml"));
disableScreenLog(runnable);
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 1.601, 0.2));
expectations.add(new Expectation("acg.CFlength", 4.17, 0.5));
expectations.add(new Expectation("acg.nConv", 39.61, 0.5));
LogAnalyser logAnalyser = new LogAnalyser("allOperatorTestShortSSML.stats",
expectations);
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
Files.deleteIfExists(Paths.get("allOperatorTestShortSSML.stats"));
Files.deleteIfExists(Paths.get("allOperatorTestShortSSML.converted"));
Files.deleteIfExists(Paths.get("allOperatorTestShortSSML.trees"));
Files.deleteIfExists(Paths.get("allOperatorTestShortSSML.cf"));
Files.deleteIfExists(Paths.get("allOperatorTestShortSSML.xml.state"));
}
示例5: loadFile
import beast.util.XMLParser; //导入依赖的package包/类
public void loadFile(String fileName) {
m_objects.clear();
XMLParser parser = new XMLParser();
try {
//fileName;
StringBuilder xml = new StringBuilder();
String NL = System.getProperty("line.separator");
Scanner scanner = new Scanner(new File(fileName));
try {
while (scanner.hasNextLine()) {
xml.append(scanner.nextLine() + NL);
}
} finally {
scanner.close();
}
BEASTInterface plugin0 = parser.parseBareFragment(xml.toString(), false);
init(plugin0);
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
示例6: loadTemplate
import beast.util.XMLParser; //导入依赖的package包/类
void loadTemplate(String xml) throws XMLParserException, SAXException, IOException, ParserConfigurationException {
// load the template and its beauti configuration parts
XMLParser parser = new XMLParser();
BEASTObjectPanel.init();
List<BEASTInterface> beastObjects = parser.parseTemplate(xml, new HashMap<>(), true);
for (BEASTInterface beastObject : beastObjects) {
if (beastObject instanceof beast.core.Runnable) {
mcmc.setValue(beastObject, this);
} else if (beastObject instanceof BeautiConfig) {
beautiConfig = (BeautiConfig) beastObject;
beautiConfig.setDoc(this);
} else {
Log.warning.println("template item " + beastObject.getID() + " is ignored");
}
BEASTObjectPanel.addPluginToMap(beastObject, this);
}
}
示例7: makeSureXMLParses
import beast.util.XMLParser; //导入依赖的package包/类
void makeSureXMLParses() {
warning("Make sure that XML that BEAUti produces parses");
File XMLFile = new File(org.fest.util.Files.temporaryFolder() + "/x.xml");
if (XMLFile.exists()) {
XMLFile.delete();
}
saveFile(""+org.fest.util.Files.temporaryFolder(), "x.xml");
// JFileChooserFixture fileChooser = findFileChooser().using(robot());
// fileChooser.setCurrentDirectory(org.fest.util.Files.temporaryFolder());
// fileChooser.selectFile(new File("x.xml")).approve();
XMLParser parser = new XMLParser();
XMLFile = new File(org.fest.util.Files.temporaryFolder() + "/x.xml");
try {
parser.parseFile(XMLFile);
} catch (Exception e) {
e.printStackTrace();
assertThat(0).as("Parser exception: " + e.getMessage()).isEqualTo(1);
}
}
示例8: testAnnotatedConstructor2
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void testAnnotatedConstructor2() throws Exception {
List<Taxon> taxa = new ArrayList<>();
taxa.add(new Taxon("first one"));
taxa.add(new Taxon("second one"));
AnnotatedRunnableTestClass t = new AnnotatedRunnableTestClass(3, taxa);
XMLProducer producer = new XMLProducer();
String xml = producer.toXML(t);
assertEquals(3, (int) t.getParam1());
FileWriter outfile = new FileWriter(new File("/tmp/XMLTest.xml"));
outfile.write(xml);
outfile.close();
XMLParser parser = new XMLParser();
BEASTInterface b = parser.parseFile(new File("/tmp/XMLTest.xml"));
assertEquals(3, (int) ((AnnotatedRunnableTestClass) b).getParam1());
assertEquals(2, ((AnnotatedRunnableTestClass) b).getTaxon().size());
}
示例9: testCFSTS
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void testCFSTS() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/CFOperatorTests/CFSubtreeSlideTest5taxon.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("CFSubtreeSlideTest5taxon.stats", expectations);
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
Files.deleteIfExists(Paths.get("CFSubtreeSlideTest5taxon.stats"));
Files.deleteIfExists(Paths.get("CFSubtreeSlideTest5taxon.trees"));
Files.deleteIfExists(Paths.get("CFSubtreeSlideTest5taxon.xml.state"));
}
示例10: testCFSTX
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void testCFSTX() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/CFOperatorTests/CFSubtreeExchangeTest5taxon.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("CFSubtreeExchangeTest5taxon.stats", expectations);
for (Expectation expectation : expectations) {
assertTrue(expectation.isValid());
assertTrue(expectation.isPassed());
}
Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.stats"));
Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.trees"));
Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.xml.state"));
}
示例11: test5Taxon
import beast.util.XMLParser; //导入依赖的package包/类
@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"));
}
示例12: test5TaxonDynamicPopSize
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void test5TaxonDynamicPopSize() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/ACGsimulations/simulateACGs5taxonDynamicPopSize.xml"));
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 8.840, 1e-2));
expectations.add(new Expectation("acg.CFlength", 25.312, 1e-2));
expectations.add(new Expectation("acg.nConv", 25.464, 5e-2));
LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxonDynamicPopSize.stats",
expectations);
for (int i=0; i<expectations.size(); i++) {
assertTrue(expectations.get(i).isValid());
assertTrue(expectations.get(i).isPassed());
}
Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.stats"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.converted"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.trees"));
}
示例13: test5TaxonSerialSampling
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void test5TaxonSerialSampling() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/ACGsimulations/simulateACGs5taxonSerialSampling.xml"));
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 1.909, 1e-2));
expectations.add(new Expectation("acg.CFlength", 4.655, 1e-2));
expectations.add(new Expectation("acg.nConv", 23.381, 5e-2));
LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxonSerialSampling.stats",
expectations);
for (int i=0; i<expectations.size(); i++) {
assertTrue(expectations.get(i).isValid());
assertTrue(expectations.get(i).isPassed());
}
Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.stats"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.converted"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.trees"));
}
示例14: test5TaxonMultiLocus
import beast.util.XMLParser; //导入依赖的package包/类
@Test
public void test5TaxonMultiLocus() throws Exception {
Randomizer.setSeed(1);
XMLParser parser = new XMLParser();
beast.core.Runnable runnable = parser.parseFile(
new File("examples/ACGsimulations/simulateACGs5taxonMultiLocus.xml"));
runnable.run();
List<Expectation> expectations = new ArrayList<>();
expectations.add(new Expectation("acg.CFheight", 1.917, 1e-2));
expectations.add(new Expectation("acg.CFlength", 4.672, 1e-2));
expectations.add(new Expectation("acg.nConv", 23.614, 5e-2));
LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxonMultiLocus.stats",
expectations);
for (int i=0; i<expectations.size(); i++) {
assertTrue(expectations.get(i).isValid());
assertTrue(expectations.get(i).isPassed());
}
Files.deleteIfExists(Paths.get("simulateACGs5taxonMultiLocus.stats"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonMultiLocus.converted"));
Files.deleteIfExists(Paths.get("simulateACGs5taxonMultiLocus.trees"));
}
示例15: initAndValidate
import beast.util.XMLParser; //导入依赖的package包/类
@Override
public void initAndValidate() {
particlePool = new LinkedHashMap<>();
threadCount = threadsInput.get();
exec = Executors.newFixedThreadPool(threadCount);
XMLProducer xmlProducer = new XMLProducer();
String xml = xmlProducer.toRawXML(this);
xml = "<beast version='2.4'>\n" +
xml.replaceAll("spec='" + this.getClass().getCanonicalName() + "'",
"spec='" + NSThread.class.getCanonicalName() + "'").
replaceAll("threads='" + threadCount+"'", "")
+ "\n</beast>";
NS = new NSThread[threadCount];
runnable = new CoreRunnable[threadCount];
for (int i = 0; i < threadCount; i++) {
try {
XMLParser xmlParser = new XMLParser();
String xml2 = xml.replaceAll("fileName='", "fileName='" + i);
Object o = xmlParser.parseFragment(xml2, true);
NS[i] = (NSThread) o;
runnable[i] = new CoreRunnable(NS[i]);
} catch (XMLParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}