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);
}
Aggregations