Skip to content

Commit

Permalink
more on modularising TreeAnnotator #71
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Aug 10, 2023
1 parent c92c7b3 commit 8dccfaf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/beastfx/app/tools/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public Application(beast.base.inference.Runnable analyser, String[] suppressedIn
/** default input used for argument parsing **/
protected Input<?> defaultInput = null;

public void setDefaultInput(Input input) {
defaultInput = input;
}

/**
* Arguments of the form -name value are processed by finding Inputs with
* matching name and setting their value.
Expand Down Expand Up @@ -254,7 +258,7 @@ public void parseArgs(String[] args, boolean sloppy) throws Exception {
}
} else {
if (i == args.length - 1 && defaultInput != null) {
defaultInput.setValue(arg, null);
defaultInput.setValue(arg, myBeastObject);
done = true;
}
}
Expand Down
24 changes: 15 additions & 9 deletions src/beastfx/app/treeannotator/TreeAnnotator2.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@



import static beast.pkgmgmt.BEASTClassLoader.addServices;

import java.io.*;
import java.util.*;

Expand Down Expand Up @@ -72,7 +74,8 @@ public class TreeAnnotator2 extends beast.base.inference.Runnable {
final public Input<Double> hpd2DInput = new Input<> ("hpd2D", "the HPD interval to be used for the bivariate traits");
final public Input<Boolean> nohpd2DInput = new Input<> ("nohpd2D", "suppress calculation of HPD intervals for the bivariate traits");
final public Input<Boolean> noSAInput = new Input<> ("noSA", "interpret the tree set as begin from a not being from a sampled ancestor analysis, even if there are zero branch lengths in the tree set");

final public Input<List<String>> versionFileInput = new Input<> ("version_file", "Provide a version file containing a list of services to explicitly allow. (Useful for package development.)", new ArrayList<>());

private final static BEASTVersion version = new BEASTVersion();

private final static boolean USE_R = false;
Expand All @@ -87,7 +90,7 @@ public class TreeAnnotator2 extends beast.base.inference.Runnable {
public TopologySettingService topologySettingService;
private int burninPercentage;
// arguments that do not set any input option
static public Input<List<File>> filesInput = new Input<> ("file", "Specify the input filename and (optional) output file name" , new ArrayList<>());
public Input<List<File>> filesInput = new Input<> ("file", "Specify the input filename and (optional) output file name" , new ArrayList<>());

public abstract class TreeSet {
public abstract boolean hasNext();
Expand Down Expand Up @@ -1254,13 +1257,12 @@ public static void main(String[] args) throws Exception {
// return;
// }

new Application(new TreeAnnotator2(), "Tree Annotator", args) {
@Override
public void parseArgs(String[] args, boolean sloppy) throws Exception {
defaultInput = filesInput;
super.parseArgs(args, true);
}
};
TreeAnnotator2 annotator = new TreeAnnotator2();
Application app = new Application(annotator);
app.setDefaultInput(annotator.filesInput);
app.parseArgs(args, true);
annotator.initAndValidate();
annotator.run();
}

@Override
Expand All @@ -1271,6 +1273,10 @@ public void initAndValidate() {
@Override
public void run() throws Exception {

for (String versionFile : versionFileInput.get()) {
BEASTClassLoader.addServices(versionFile);
}

String targetTreeFileName = null;
String inputFileName = null;
String outputFileName = null;
Expand Down
13 changes: 13 additions & 0 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@
<provider classname="beastfx.app.methodsection.XML2HTMLPaneFX"/>
</service>

<service type="beastfx.app.treeannotator.services.TopologySettingService">
<provider classname="beastfx.app.treeannotator.services.MCCTopologyService"/>
<provider classname="beastfx.app.treeannotator.services.MaxSumCladeCrediblityTopologyService"/>
<provider classname="beastfx.app.treeannotator.services.UserTargetTreeTopologyService"/>
</service>

<service type="beastfx.app.treeannotator.services.NodeHeightSettingService">
<provider classname="beastfx.app.treeannotator.services.CommonAncestorNodeHeigtService"/>
<provider classname="beastfx.app.treeannotator.services.KeepHeightsNodeHeightsService"/>
<provider classname="beastfx.app.treeannotator.services.MeanNodeHeightService"/>
<provider classname="beastfx.app.treeannotator.services.MedianNodeHeightService"/>
</service>

<packageapp description="Interactive Methods Section Generator"
class="beastfx.app.methodsection.XML2HTMLPaneFX"
/>
Expand Down

0 comments on commit 8dccfaf

Please sign in to comment.