diff --git a/src/beastfx/app/treeannotator/TreeAnnotator.java b/src/beastfx/app/treeannotator/TreeAnnotator.java index 4986153..d94bd28 100644 --- a/src/beastfx/app/treeannotator/TreeAnnotator.java +++ b/src/beastfx/app/treeannotator/TreeAnnotator.java @@ -36,7 +36,6 @@ import beast.base.core.Description; import beast.base.core.Input; import beast.base.core.Log; -import beast.base.evolution.alignment.TaxonSet; import beast.base.evolution.tree.Node; import beast.base.evolution.tree.Tree; import beast.base.evolution.tree.TreeParser; @@ -61,7 +60,7 @@ public class TreeAnnotator extends beast.base.inference.Runnable { final public Input burnInPercentageInput = new Input<>("burnin", "percentage of trees to used as burn-in (and will be ignored)", 10); final public Input limitInput = new Input<>("limit", "the minimum posterior probability for a node to be annotated", 0.0); final public Input topologyInput = new Input<> ("topology", "name of the method for determining topology", "MCC"); - final public Input targetInput = new Input<> ("target", "target_file_name, specifies a user target tree to be annotated"); + final public Input targetInput = new Input<> ("target", "target_file_name, specifies a user target tree to be annotated", ""); final public Input forceDiscreteInput = new Input<> ("forceDiscrete", "forces integer traits to be treated as discrete traits."); final public Input lowMemInput = new Input<> ("lowMem", "use less memory, which is a bit slower."); final public Input hpd2DInput = new Input<> ("hpd2D", "the HPD interval to be used for the bivariate traits"); @@ -544,8 +543,6 @@ public void run(final int burninPercentage, // HeightsSummary heightsOption, double posteriorLimit, double hpd2D, - // Target targetOption, - String targetTreeFileName, String inputFileName, String outputFileName ) throws IOException { @@ -553,12 +550,8 @@ public void run(final int burninPercentage, topologySettingService = getTopologySettingService(); nodeHeightSettingService = getNodeHeightSettingService(); - // Get citations, only print if eihter of them is not empty. - - + // Get citations, only print if either of them is not empty. String nodeCitation = nodeHeightSettingService.getCitations(); - - String topoCitation = topologySettingService.getCitations(); if (!nodeCitation.isBlank() || !topoCitation.isBlank()) { @@ -619,11 +612,19 @@ public void run(final int burninPercentage, } } - Tree targetTree = topologySettingService.setTopology(treeSet, progressStream, this); + if (targetInput.get() != null && !targetInput.get().isEmpty()) { + String current = topologySettingService.getServiceName(); + String required = UserTargetTreeTopologyService.SERVICE_NAME; + if (!required.equals(current)) { + Log.info("Setting topology to be the target tree..."); + topologyInput.setValue("target", this); + topologySettingService = getTopologySettingService(); + } + } - + Tree targetTree = topologySettingService.setTopology(treeSet, progressStream, this); cladeSystem = getCladeSystem(targetTree); - + // progressStream.println("Collecting node information..."); // progressStream.println("0 25 50 75 100"); // progressStream.println("|--------------|--------------|--------------|--------------|"); @@ -684,7 +685,7 @@ public void run(final int burninPercentage, progressStream.println("Writing annotated tree...."); - + processMetaData(targetTree.getRoot()); try { final PrintStream stream = outputFileName != null ? @@ -692,10 +693,10 @@ public void run(final int burninPercentage, System.out; targetTree.init(stream); stream.println(); - - stream.print("tree TREE_" + - topologySettingService.getServiceName() + "_" + - nodeHeightSettingService.getServiceName() + " = "); + + stream.print("tree TREE_" + + topologySettingService.getServiceName() + "_" + + nodeHeightSettingService.getServiceName() + " = "); int[] dummy = new int[1]; String newick = targetTree.getRoot().toSortedNewick(dummy, true); stream.print(newick); @@ -1175,7 +1176,7 @@ private void annotate2DHPDAttribute(Node node, String preLabel, String postLabel private final List beastObjects = new ArrayList<>(); Set attributeNames = new HashSet<>(); - TaxonSet taxa = null; +// TaxonSet taxa = null; static boolean processBivariateAttributes = true; @@ -1387,8 +1388,7 @@ public void run() throws Exception { for (String versionFile : versionFileInput.get()) { BEASTClassLoader.addServices(versionFile); } - - String targetTreeFileName = null; + String inputFileName = null; String outputFileName = null; @@ -1453,20 +1453,12 @@ public void run() throws Exception { hpd2D = hpd2DInput.get(); if (hpd2D <= 0 || hpd2D >=1) { Log.err.println("hpd2D is a fraction and should be in between 0.0 and 1.0."); - System.exit(1); + System.exit(1); } processBivariateAttributes = true; } - -// Target target = Target.MAX_CLADE_CREDIBILITY; -// if (targetInput.get() != null) { -// target = Target.USER_TARGET_TREE; -// targetTreeFileName = arguments.getStringOption("target"); -// } - final List args2 = filesInput.get(); - switch (args2.size()) { case 2: @@ -1484,9 +1476,7 @@ public void run() throws Exception { } try { - run(burninPercentage, lowMem, posteriorLimit, hpd2D, targetTreeFileName, inputFileName, outputFileName); - //} catch (IOException e) { - // throw e; + run(burninPercentage, lowMem, posteriorLimit, hpd2D, inputFileName, outputFileName); } catch (Exception e) { e.printStackTrace(); }