Search in sources :

Example 11 with TraceException

use of dr.inference.trace.TraceException in project beast-mcmc by beast-dev.

the class JumpHistoryAnalyser method main.

public static void main(String[] args) {
    String inputFileName = null;
    //        printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { new Arguments.IntegerOption("burnin", "the number of states to be considered as 'burn-in'"), new Arguments.StringOption("from", "from_states", "set of 'from' states to limit the history [default all states]"), new Arguments.StringOption("to", "to_states", "set of 'to' states to limit the history [default all states]"), new Arguments.Option("iterateFrom", "iterate over 'from' states [default combine states]"), new Arguments.Option("iterateTo", "iterate over 'to' states [default combine states]"), new Arguments.Option("backwardsTime", "time runs backwards [default false]"), new Arguments.IntegerOption("bins", "the number of discrete bins [default 100]"), new Arguments.RealOption("min", "the minimum bound of the time range"), new Arguments.RealOption("max", "the maximum bound of the time range"), new Arguments.RealOption("mrsd", "the date of the most recently sampled tip"), new Arguments.Option("help", "option to print this message") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        System.err.println(ae);
        printUsage(arguments);
        System.exit(1);
    }
    if (arguments.hasOption("help")) {
        printUsage(arguments);
        System.exit(0);
    }
    int burnin = -1;
    if (arguments.hasOption("burnin")) {
        burnin = arguments.getIntegerOption("burnin");
    }
    int binCount = 100;
    if (arguments.hasOption("bins")) {
        binCount = arguments.getIntegerOption("bins");
    }
    double minTime = arguments.getRealOption("min");
    double maxTime = arguments.getRealOption("max");
    if (minTime >= maxTime) {
        System.err.println("The minimum time must be less than the maximum time");
        printUsage(arguments);
        System.exit(1);
    }
    double mrsd = arguments.getRealOption("mrsd");
    Set<String> fromStates = new HashSet<String>();
    Set<String> toStates = new HashSet<String>();
    if (arguments.hasOption("from")) {
        String stateString = arguments.getStringOption("from");
        String[] states = stateString.split("[\"\\s,]");
        for (String state : states) {
            if (state.length() > 0) {
                fromStates.add(state);
            }
        }
    }
    if (arguments.hasOption("to")) {
        String stateString = arguments.getStringOption("to");
        String[] states = stateString.split("[\"\\s,]");
        for (String state : states) {
            if (state.length() > 0) {
                toStates.add(state);
            }
        }
    }
    boolean iterateFrom = arguments.hasOption("iterateFrom");
    boolean iterateTo = arguments.hasOption("iterateTo");
    boolean backwardsTime = arguments.hasOption("backwardsTime");
    final String[] args2 = arguments.getLeftoverArguments();
    switch(args2.length) {
        case 1:
            inputFileName = args2[0];
            break;
        default:
            {
                System.err.println("Unknown option: " + args2[2]);
                System.err.println();
                printUsage(arguments);
                System.exit(1);
            }
    }
    // command line options to follow shortly...
    try {
        JumpHistoryAnalyser jumpHistory = new JumpHistoryAnalyser(inputFileName, fromStates, toStates, iterateFrom, iterateTo, burnin, binCount, minTime, maxTime, backwardsTime, mrsd);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ImportException e) {
        e.printStackTrace();
    } catch (TraceException e) {
        e.printStackTrace();
    }
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments) IOException(java.io.IOException) ImportException(jebl.evolution.io.ImportException) TraceException(dr.inference.trace.TraceException) HashSet(java.util.HashSet)

Aggregations

TraceException (dr.inference.trace.TraceException)11 File (java.io.File)8 LogFileTraces (dr.inference.trace.LogFileTraces)7 MarginalLikelihoodAnalysis (dr.inference.trace.MarginalLikelihoodAnalysis)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)3 Importer (dr.evolution.io.Importer)2 ImportException (jebl.evolution.io.ImportException)2 Arguments (dr.app.util.Arguments)1 EBSPAnalysis (dr.evomodel.coalescent.EBSPAnalysis)1 GPSkytrackAnalysis (dr.evomodel.coalescent.GPSkytrackAnalysis)1 VariableDemographicModel (dr.evomodel.coalescent.VariableDemographicModel)1 Parameter (dr.inference.model.Parameter)1 Distribution (dr.math.distributions.Distribution)1 Variate (dr.stats.Variate)1 XMLObject (dr.xml.XMLObject)1 XMLParseException (dr.xml.XMLParseException)1 FileWriter (java.io.FileWriter)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1