use of jebl.evolution.io.ImportException 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);
}
use of jebl.evolution.io.ImportException in project beast-mcmc by beast-dev.
the class TreeKMLGenerator method main.
public static void main(String[] args) {
String inputTreeFile = args[0];
RootedTree tree = null;
try {
TreeImporter importer = new NexusImporter(new FileReader(inputTreeFile));
tree = (RootedTree) importer.importNextTree();
} catch (ImportException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
TreeKMLGenerator generator = new TreeKMLGenerator(tree);
Settings settings = new Settings(AnalysisType.CONTINUOUS);
// settings.getAltitudeTreeSettings().setTreeType(TreeType.ARC_TREE);
// settings.getAltitudeTreeSettings().getBranchStyle().setColorProperty("height");
settings.getGroundTreeSettings().setTreeType(TreeType.SURFACE_TREE);
settings.getGroundTreeSettings().getBranchStyle().setColorProperty("height");
settings.setPlotAltitude(0);
settings.setMostRecentDate(2003);
//settings.setAgeCutOff(1995);
settings.setTimeDivisionCount(0);
settings.setTraitName("antigenic");
settings.setLatitudeName("antigenic1");
settings.setLongitudeName("antigenic2");
try {
BufferedWriter out = new BufferedWriter(new FileWriter(args[0] + ".kml"));
Document doc = new Document(generator.generate(args[0], settings));
try {
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
outputter.output(doc, out);
} catch (IOException e) {
System.err.println(e);
}
out.close();
} catch (IOException e) {
e.printStackTrace();
return;
}
}
use of jebl.evolution.io.ImportException in project beast-mcmc by beast-dev.
the class TreeGeoJSONGenerator method main.
public static void main(String[] args) {
String inputTreeFile = args[0];
RootedTree tree = null;
try {
TreeImporter importer = new NexusImporter(new FileReader(inputTreeFile));
tree = (RootedTree) importer.importNextTree();
} catch (ImportException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
TreeGeoJSONGenerator generator = new TreeGeoJSONGenerator(tree, null);
try {
generator.generate("", new PrintWriter(new File("output.geojson")));
} catch (FileNotFoundException e) {
//To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
}
Aggregations