Search in sources :

Example 1 with BeastVersion

use of dr.app.beast.BeastVersion in project beast-mcmc by beast-dev.

the class LoggerParser method parseXMLObject.

/**
     * @return an object based on the XML element it was passed.
     */
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    // You must say how often you want to log
    final int logEvery = xo.getIntegerAttribute(LOG_EVERY);
    final PrintWriter pw = getLogFile(xo, getParserName());
    final LogFormatter formatter = new TabDelimitedFormatter(pw);
    boolean performanceReport = false;
    if (!xo.hasAttribute(FILE_NAME)) {
        // is a screen log
        performanceReport = true;
    }
    // added a performance measurement delay to avoid the full evaluation period.
    final MCLogger logger = new MCLogger(formatter, logEvery, performanceReport, 10000);
    String title = null;
    if (xo.hasAttribute(TITLE)) {
        title = xo.getStringAttribute(TITLE);
    }
    String header = null;
    if (xo.hasAttribute(HEADER)) {
        header = xo.getStringAttribute(HEADER);
    }
    if (title == null) {
        final BeastVersion version = new BeastVersion();
        title = "BEAST " + version.getVersionString() + "\n" + (header != null ? header + "\n" : "") + "Generated " + (new Date()).toString() + " [seed=" + MathUtils.getSeed() + "]\n" + System.getProperty("command_line", "");
    } else {
        if (header != null) {
            title += "\n" + header;
        }
    }
    logger.setTitle(title);
    for (int i = 0; i < xo.getChildCount(); i++) {
        final Object child = xo.getChild(i);
        if (child instanceof Columns) {
            logger.addColumns(((Columns) child).getColumns());
        } else if (child instanceof Loggable) {
            logger.add((Loggable) child);
        } else if (child instanceof Identifiable) {
            logger.addColumn(new LogColumn.Default(((Identifiable) child).getId(), child));
        } else if (child instanceof Property) {
            logger.addColumn(new LogColumn.Default(((Property) child).getAttributeName(), child));
        } else {
            logger.addColumn(new LogColumn.Default(child.getClass().toString(), child));
        }
    }
    return logger;
}
Also used : Date(java.util.Date) Identifiable(dr.util.Identifiable) BeastVersion(dr.app.beast.BeastVersion) Property(dr.util.Property) PrintWriter(java.io.PrintWriter)

Aggregations

BeastVersion (dr.app.beast.BeastVersion)1 Identifiable (dr.util.Identifiable)1 Property (dr.util.Property)1 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1