use of dr.app.beauti.util.XMLWriter in project beast-mcmc by beast-dev.
the class GetDateFromTree method writeHeadAndTaxa.
private static XMLWriter writeHeadAndTaxa(String curD, int index, double[][] tips) throws IOException {
String f = path + curD + "/T_" + Integer.toString(index) + ".xml";
System.out.println("Creating xml : " + f);
XMLWriter w = new XMLWriter(new BufferedWriter(new FileWriter(new File(f))));
w.writeText("<?xml version=\"1.0\" standalone=\"yes\"?>\n" + "\n" + "<!-- Generated by BEAUTi v1.7.0 Prerelease r3910 -->\n" + "<!-- by Alexei J. Drummond and Andrew Rambaut -->\n" + "<!-- Department of Computer Science, University of Auckland and -->\n" + "<!-- Institute of Evolutionary Biology, University of Edinburgh -->\n" + "<!-- http://beast.bio.ed.ac.uk/ -->\n" + "<beast>\n" + "\n" + "\t<!-- The list of taxa to be analysed (can also include dates/ages). -->\n" + "\t<!-- ntax=" + tips[0].length + " -->\n" + "\t<taxa id=\"taxa\">\n");
for (int n = 1; n < tips[0].length; n++) {
w.writeText("\t<taxon id=\"" + n + "\">\n" + "\t\t<date value=\"" + tips[0][n] + "\" direction=\"backwards\" units=\"years\" />\n" + "\t</taxon>\n");
}
w.writeText("\t</taxa>\n");
for (int tree = 2; tree <= combiTrees; tree++) {
w.writeText("\t<taxa id=\"taxa" + tree + "\">\n");
for (int n = 1; n < tips[tree - 1].length; n++) {
w.writeText("\t<taxon id=\"" + n + "t" + tree + "\">\n" + "\t\t<date value=\"" + tips[tree - 1][n] + "\" direction=\"backwards\" units=\"years\" />\n" + "\t</taxon>\n");
}
w.writeText("\t</taxa>\n");
}
return w;
}
use of dr.app.beauti.util.XMLWriter in project beast-mcmc by beast-dev.
the class GenerateRelaxedClockXMLByData method main.
public static void main(String[] args) {
int taxonNum = 14;
for (int c = 1; c <= 100; c++) {
String inputFileName = "geneRRNP" + c + ".phy";
String[][] data = new String[taxonNum][2];
try {
System.out.println("Input data from " + path + inputFileName + "\n\n");
FileReader fileReader = new FileReader(path + inputFileName);
LineNumberReader lineNumberReader = new LineNumberReader(fileReader);
String line = "";
int lineNum = 0;
while ((line = lineNumberReader.readLine()) != null) {
lineNum = lineNumberReader.getLineNumber();
System.out.println("Line: " + lineNum + ": " + line);
if (lineNumberReader.getLineNumber() > 1) {
// not need 1st row
String[] d = line.split("\\s+");
if (d.length != 2)
throw new IOException("d " + d.length);
// taxon name
data[lineNum - 2][0] = d[0];
// alignment
data[lineNum - 2][1] = d[1];
}
}
if (lineNum != 15)
throw new IOException("not have 15 line " + lineNum);
fileReader.close();
String outputFileName = "geneRRNP" + c + ".xml";
System.out.println("\n\nCreating xml : " + path + outputFileName);
XMLWriter w = new XMLWriter(new BufferedWriter(new FileWriter(new File(path + outputFileName))));
writeData(w, data);
writeRestXML(w, outputFileName);
w.close();
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++\n\n");
} catch (FileNotFoundException e) {
//To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
} catch (IOException e) {
//To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
}
}
Aggregations