} catch(UnrecognizedOptionException e) {
System.err.println(e.getMessage());
printUsage();
return;
}
UnifracTree unifracTree = null;
PrintStream out = System.out;
if (line.hasOption("tree") && line.hasOption("sequence-files")) {
printUsage();
} else if (!(line.hasOption("weighted") || line.hasOption("unweighted") || line.hasOption("significance"))) {
System.err.println("Must specify at least one calculation option");
printUsage();
} else if (line.hasOption("sample-mapping")) {
Map<String, UnifracSample> sampleMap = readSampleMap(line.getOptionValue("sample-mapping"));
if (line.hasOption("tree")) {
unifracTree = parseNewickTree(line.getOptionValue("tree"), sampleMap);
}
} else {
if (!line.hasOption("sample-mapping")) {
System.err.println("A sample mapping file must be provided");
}
printUsage();
}
if (line.hasOption("outfile")) {
out = new PrintStream(line.getOptionValue("outfile"));
}
if (unifracTree != null) {
if (line.hasOption("unweighted")) {
printResults(out, unifracTree.computeUnifrac(), "Unweighted Unifrac");
if (line.hasOption("significance")) {
printResults(out, unifracTree.computeUnifracSig(1000, false), "Unweighted Unifrac Significance");
}
}
if (line.hasOption("weighted")) {
printResults(out, unifracTree.computeWeightedUnifrac(), "Weighted Unifrac");
if (line.hasOption("significance")) {
printResults(out, unifracTree.computeUnifracSig(1000, true), "Weighted Unifrac Significance");
}
}
}
}