Search in sources :

Example 11 with Arguments

use of dr.app.util.Arguments in project beast-mcmc by beast-dev.

the class TreeAnnotator method main.

//Main method
public static void main(String[] args) throws IOException {
    // There is a major issue with languages that use the comma as a decimal separator.
    // To ensure compatibility between programs in the package, enforce the US locale.
    Locale.setDefault(Locale.US);
    String targetTreeFileName = null;
    String inputFileName = null;
    String outputFileName = null;
    if (args.length == 0) {
        System.setProperty("com.apple.macos.useScreenMenuBar", "true");
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("apple.awt.showGrowBox", "true");
        java.net.URL url = LogCombiner.class.getResource("/images/utility.png");
        javax.swing.Icon icon = null;
        if (url != null) {
            icon = new javax.swing.ImageIcon(url);
        }
        final String versionString = version.getVersionString();
        String nameString = "TreeAnnotator " + versionString;
        String aboutString = "<html><center><p>" + versionString + ", " + version.getDateString() + "</p>" + "<p>by<br>" + "Andrew Rambaut and Alexei J. Drummond</p>" + "<p>Institute of Evolutionary Biology, University of Edinburgh<br>" + "<a href=\"mailto:a.rambaut@ed.ac.uk\">a.rambaut@ed.ac.uk</a></p>" + "<p>Department of Computer Science, University of Auckland<br>" + "<a href=\"mailto:alexei@cs.auckland.ac.nz\">alexei@cs.auckland.ac.nz</a></p>" + "<p>Part of the BEAST package:<br>" + "<a href=\"http://beast.bio.ed.ac.uk/\">http://beast.bio.ed.ac.uk/</a></p>" + "</center></html>";
        new ConsoleApplication(nameString, aboutString, icon, true);
        // The ConsoleApplication will have overridden System.out so set progressStream
        // to capture the output to the window:
        progressStream = System.out;
        printTitle();
        TreeAnnotatorDialog dialog = new TreeAnnotatorDialog(new JFrame());
        if (!dialog.showDialog("TreeAnnotator " + versionString)) {
            return;
        }
        int burninStates = dialog.getBurninStates();
        int burninTrees = dialog.getBurninTrees();
        double posteriorLimit = dialog.getPosteriorLimit();
        double[] hpd2D = { 0.80 };
        Target targetOption = dialog.getTargetOption();
        HeightsSummary heightsOption = dialog.getHeightsOption();
        targetTreeFileName = dialog.getTargetFileName();
        if (targetOption == Target.USER_TARGET_TREE && targetTreeFileName == null) {
            System.err.println("No target file specified");
            return;
        }
        inputFileName = dialog.getInputFileName();
        if (inputFileName == null) {
            System.err.println("No input file specified");
            return;
        }
        outputFileName = dialog.getOutputFileName();
        if (outputFileName == null) {
            System.err.println("No output file specified");
            return;
        }
        try {
            new TreeAnnotator(burninTrees, burninStates, heightsOption, posteriorLimit, hpd2D, targetOption, targetTreeFileName, inputFileName, outputFileName);
        } catch (Exception ex) {
            System.err.println("Exception: " + ex.getMessage());
        }
        progressStream.println("Finished - Quit program to exit.");
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { //new Arguments.StringOption("target", new String[] { "maxclade", "maxtree" }, false, "an option of 'maxclade' or 'maxtree'"),
    new Arguments.StringOption("heights", new String[] { "keep", "median", "mean", "ca" }, false, "an option of 'keep' (default), 'median', 'mean' or 'ca'"), new Arguments.IntegerOption("burnin", "the number of states to be considered as 'burn-in'"), new Arguments.IntegerOption("burninTrees", "the number of trees to be considered as 'burn-in'"), new Arguments.RealOption("limit", "the minimum posterior probability for a node to be annotated"), new Arguments.StringOption("target", "target_file_name", "specifies a user target tree to be annotated"), new Arguments.Option("help", "option to print this message"), new Arguments.Option("forceDiscrete", "forces integer traits to be treated as discrete traits."), new Arguments.StringOption("hpd2D", "the HPD interval to be used for the bivariate traits", "specifies a (vector of comma seperated) HPD proportion(s)") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        progressStream.println(ae);
        printUsage(arguments);
        System.exit(1);
    }
    if (arguments.hasOption("forceDiscrete")) {
        System.out.println("  Forcing integer traits to be treated as discrete traits.");
        forceIntegerToDiscrete = true;
    }
    if (arguments.hasOption("help")) {
        printUsage(arguments);
        System.exit(0);
    }
    HeightsSummary heights = HeightsSummary.KEEP_HEIGHTS;
    if (arguments.hasOption("heights")) {
        String value = arguments.getStringOption("heights");
        if (value.equalsIgnoreCase("mean")) {
            heights = HeightsSummary.MEAN_HEIGHTS;
        } else if (value.equalsIgnoreCase("median")) {
            heights = HeightsSummary.MEDIAN_HEIGHTS;
        } else if (value.equalsIgnoreCase("ca")) {
            heights = HeightsSummary.CA_HEIGHTS;
            System.out.println("Please cite: Heled and Bouckaert: Looking for trees in the forest:\n" + "summary tree from posterior samples. BMC Evolutionary Biology 2013 13:221.");
        }
    }
    int burninStates = -1;
    int burninTrees = -1;
    if (arguments.hasOption("burnin")) {
        burninStates = arguments.getIntegerOption("burnin");
    }
    if (arguments.hasOption("burninTrees")) {
        burninTrees = arguments.getIntegerOption("burninTrees");
    }
    double posteriorLimit = 0.0;
    if (arguments.hasOption("limit")) {
        posteriorLimit = arguments.getRealOption("limit");
    }
    double[] hpd2D = { 80 };
    if (arguments.hasOption("hpd2D")) {
        try {
            hpd2D = parseVariableLengthDoubleArray(arguments.getStringOption("hpd2D"));
        } catch (Arguments.ArgumentException e) {
            System.err.println("Error reading " + arguments.getStringOption("hpd2D"));
        }
    }
    Target target = Target.MAX_CLADE_CREDIBILITY;
    if (arguments.hasOption("target")) {
        target = Target.USER_TARGET_TREE;
        targetTreeFileName = arguments.getStringOption("target");
    }
    final String[] args2 = arguments.getLeftoverArguments();
    switch(args2.length) {
        case 2:
            outputFileName = args2[1];
        // fall to
        case 1:
            inputFileName = args2[0];
            break;
        default:
            {
                System.err.println("Unknown option: " + args2[2]);
                System.err.println();
                printUsage(arguments);
                System.exit(1);
            }
    }
    new TreeAnnotator(burninTrees, burninStates, heights, posteriorLimit, hpd2D, target, targetTreeFileName, inputFileName, outputFileName);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments) IOException(java.io.IOException) ConsoleApplication(jam.console.ConsoleApplication) javax.swing(javax.swing)

Example 12 with Arguments

use of dr.app.util.Arguments in project beast-mcmc by beast-dev.

the class TreeLengthFinder method main.

//Main method
public static void main(String[] args) throws IOException, TraceException {
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { new Arguments.IntegerOption("burnin", "the number of states to be considered as 'burn-in'"), //				new Arguments.Option("svg", "generate svg graphics"),
    new Arguments.Option("help", "option to print this message") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        System.out.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");
    }
    /*boolean hpds = arguments.hasOption("hpd");
        boolean ess = arguments.hasOption("ess");
        boolean stdErr = arguments.hasOption("stdErr");
        boolean shortReport = arguments.hasOption("short");

        String marginalLikelihood = null;
        if (arguments.hasOption("marginal")) {
            marginalLikelihood = arguments.getStringOption("marginal");
        }*/
    String inputFileName = null;
    String outputFileName = null;
    String[] args2 = arguments.getLeftoverArguments();
    if (args2.length > 2) {
        System.err.println("Unknown option: " + args2[2]);
        System.err.println();
        printUsage(arguments);
        System.exit(1);
    }
    if (args2.length > 0) {
        inputFileName = args2[0];
    }
    if (args2.length > 1) {
        outputFileName = args2[1];
    }
    if (inputFileName == null) {
        // No input file name was given so throw up a dialog box...
        inputFileName = Utils.getLoadFileName("TreeLengthFinder " + version.getVersionString() + " - Select tree file to analyse");
    }
    if (burnin == -1) {
        System.out.println("Enter number of trees to burn-in (integer): ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        burnin = Integer.parseInt(br.readLine());
    }
    new TreeLengthFinder(burnin, inputFileName, outputFileName);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Example 13 with Arguments

use of dr.app.util.Arguments in project beast-mcmc by beast-dev.

the class TreeSummary method main.

//Main method
public static void main(String[] args) throws IOException {
    // There is a major issue with languages that use the comma as a decimal separator.
    // To ensure compatibility between programs in the package, enforce the US locale.
    Locale.setDefault(Locale.US);
    String inputFileName = null;
    String outputFileName = 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.IntegerOption("burninTrees", "the number of trees to be considered as 'burn-in'"), new Arguments.Option("clademap", "show states of all clades over chain length"), new Arguments.RealOption("limit", "the minimum posterior probability for a subtree to be included"), new Arguments.Option("help", "option to print this message") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        progressStream.println(ae);
        printUsage(arguments);
        System.exit(1);
    }
    if (arguments.hasOption("help")) {
        printUsage(arguments);
        System.exit(0);
    }
    int burninStates = -1;
    int burninTrees = -1;
    if (arguments.hasOption("burnin")) {
        burninStates = arguments.getIntegerOption("burnin");
    }
    if (arguments.hasOption("burninTrees")) {
        burninTrees = arguments.getIntegerOption("burninTrees");
    }
    double posteriorLimit = 0.5;
    if (arguments.hasOption("limit")) {
        posteriorLimit = arguments.getRealOption("limit");
    }
    final String[] args2 = arguments.getLeftoverArguments();
    boolean createCladeMap = false;
    boolean createSummaryTree = true;
    if (arguments.hasOption("clademap")) {
        createCladeMap = true;
        createSummaryTree = false;
    }
    switch(args2.length) {
        case 2:
            outputFileName = args2[1];
        // fall to
        case 1:
            inputFileName = args2[0];
            break;
        default:
            {
                System.err.println("Unknown option: " + args2[2]);
                System.err.println();
                printUsage(arguments);
                System.exit(1);
            }
    }
    new TreeSummary(burninTrees, burninStates, posteriorLimit, createSummaryTree, createCladeMap, inputFileName, outputFileName);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Example 14 with Arguments

use of dr.app.util.Arguments in project beast-mcmc by beast-dev.

the class TimeSlicer method main.

public static void main(String[] args) throws IOException {
    String inputFileName = null;
    String outputFileName = null;
    String[] traitNames = null;
    double[] sliceHeights = null;
    OutputFormat outputFormat = OutputFormat.KML;
    boolean impute = false;
    boolean trueNoise = true;
    boolean summaryOnly = true;
    ContourMode contourMode = ContourMode.SNYDER;
    Normalization normalize = Normalization.LENGTH;
    int burnin = -1;
    int skipEvery = 1;
    double mrsd = 0;
    boolean summarizeRoot = false;
    boolean summarizeTips = false;
    boolean contours = true;
    boolean points = false;
    double[] hpdValues = { 0.80 };
    String outputFileSDR = null;
    String outputFileSNR = null;
    boolean getSDR = false;
    boolean getSNR = false;
    String progress = null;
    boolean branchNormalization = false;
    BranchSet set = BranchSet.ALL;
    Set taxaSet = null;
    SliceMode sliceMode = SliceMode.BRANCHES;
    int grid = 200;
    double latMax = Double.MAX_VALUE;
    double latMin = -Double.MAX_VALUE;
    double longMax = Double.MAX_VALUE;
    double longMin = -Double.MAX_VALUE;
    String rateString = "location.rate";
    Set descendents = null;
    //        if (args.length == 0) {
    //          // TODO Make flash GUI
    //        }
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { new Arguments.IntegerOption(BURNIN, "the number of states to be considered as 'burn-in' [default = 0]"), new Arguments.IntegerOption(SKIP, "skip every i'th tree [default = 0]"), new Arguments.StringOption(TRAIT, "trait_name", "specifies an attribute-list to use to create a density map [default = location.rate]"), new Arguments.StringOption(SLICE_TIMES, "slice_times", "specifies a slice time-list [default=none]"), new Arguments.StringOption(SLICE_HEIGHTS, "slice_heights", "specifies a slice height-list [default=none]"), new Arguments.StringOption(SLICE_FILE_HEIGHTS, "heights_file", "specifies a file with a slice heights-list, is overwritten by command-line specification of slice heights [default=none]"), new Arguments.StringOption(SLICE_FILE_TIMES, "Times_file", "specifies a file with a slice Times-list, is overwritten by command-line specification of slice times [default=none]"), new Arguments.StringOption(RATE_ATTRIBUTE, "rate_attribute", "specifies the trait rate attribute string [default=location.rate]; use 'none' when no rate needs to be used (homogeneous Brownian model)"), new Arguments.IntegerOption(SLICE_COUNT, "the number of time slices to use [default=0]"), new Arguments.StringOption(SLICE_MODE, "Slice_mode", "specifies how to perform the slicing [default=branches]"), new Arguments.StringOption(ROOT, falseTrue, false, "include a summary for the root [default=off]"), new Arguments.StringOption(TIPS, falseTrue, false, "include a summary for the tips [default=off]"), new Arguments.StringOption(CONTOURS, falseTrue, true, "include contours in summary [default=true]"), new Arguments.StringOption(POINTS, falseTrue, false, "include all points for the summary [default=off]"), new Arguments.RealOption(START_TIME, "the time of the earliest slice [default=0]"), new Arguments.RealOption(MRSD, "specifies the most recent sampling data in fractional years to rescale time [default=0]"), new Arguments.Option(HELP, "option to print this message"), new Arguments.StringOption(NOISE, falseTrue, false, "add true noise [default = true])"), new Arguments.StringOption(IMPUTE, falseTrue, false, "impute trait at time-slice [default = false]"), new Arguments.StringOption(SUMMARY, falseTrue, false, "compute summary statistics [default = true]"), new Arguments.StringOption(FORMAT, enumNamesToStringArray(OutputFormat.values()), false, "summary output format [default = KML]"), new Arguments.StringOption(HPD, "hpd", "mass (1 - 99%) to include in HPD regions (or list) [default = 80]"), new Arguments.StringOption(CONTOUR_MODE, enumNamesToStringArray(ContourMode.values()), false, "contouring model [default = snyder]"), new Arguments.StringOption(NORMALIZATION, enumNamesToStringArray(Normalization.values()), false, "tree normalization [default = length"), new Arguments.StringOption(SDR, "sliceDispersalRate", "specifies output file name for dispersal rates for each slice (from previous sliceTime[or root of the trees] up to current sliceTime"), new Arguments.StringOption(SNR, "sliceNonynonymousRate", "specifies output file name for Nonynsonymous rates for each slice (from previous sliceTime[or root of the trees] up to current sliceTime"), new Arguments.StringOption(PROGRESS, "progress report", "reports slice progress and checks the bivariate contour HPD regions by calculating what fraction of points the polygons for a given slice contain  [default = false]"), new Arguments.StringOption(BRANCH_NORMALIZE, falseTrue, false, "devide a branch trait by branch length (can be useful for 'rewards' [default = false]"), new Arguments.StringOption(BRANCHSET, TimeSlicer.enumNamesToStringArray(BranchSet.values()), false, "branch set [default = all]"), new Arguments.StringOption(BACKBONETAXA, "Backbone taxa file", "specifies a file with taxa that define the backbone"), new Arguments.RealOption(LATMAX, "specifies the maximum latitude for a child node for a branch to be included in the summary [default=MAX_VALUE]"), new Arguments.RealOption(LATMIN, "specifies the minimum latitude for a child node for a branch to be included in the summary [default=MIN_VALUE]"), new Arguments.RealOption(LONGMAX, "specifies the maximum longitude for a child node for a branch to be included in the summary [default=MAX_VALUE]"), new Arguments.RealOption(LONGMIN, "specifies the minimum longitude for a child node for a branch to be included in the summary [default=MIN_VALUE]"), new Arguments.IntegerOption(GRIDSIZE, "the grid size for contouring [default=200]"), new Arguments.StringOption(DESCENDENTS, "descendent taxa", "specifies a branch based on the descendent taxa [default=all branches]") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        progressStream.println(ae);
        printUsage(arguments);
        System.exit(1);
    }
    if (arguments.hasOption(HELP)) {
        printUsage(arguments);
        System.exit(0);
    }
    try {
        // Make sense of arguments
        String sliceHeightsFileString = arguments.getStringOption(SLICE_FILE_HEIGHTS);
        if (sliceHeightsFileString != null) {
            sliceHeights = parseFileWithArray(sliceHeightsFileString);
        }
        if (arguments.hasOption(MRSD)) {
            mrsd = arguments.getRealOption(MRSD);
        }
        if (arguments.hasOption(LATMAX)) {
            latMax = arguments.getRealOption(LATMAX);
        }
        if (arguments.hasOption(LATMIN)) {
            latMin = arguments.getRealOption(LATMIN);
        }
        if (arguments.hasOption(LONGMAX)) {
            longMax = arguments.getRealOption(LONGMAX);
        }
        if (arguments.hasOption(LONGMIN)) {
            longMin = arguments.getRealOption(LONGMIN);
        }
        String taxaString = arguments.getStringOption(DESCENDENTS);
        if (taxaString != null) {
            descendents = parseVariableLengthStringSet(taxaString);
        }
        String sliceTimesFileString = arguments.getStringOption(SLICE_FILE_TIMES);
        if (sliceTimesFileString != null) {
            //System.out.println(sliceTimesFileString);
            double[] sliceTimes = parseFileWithArray(sliceTimesFileString);
            sliceHeights = new double[sliceTimes.length];
            for (int i = 0; i < sliceTimes.length; i++) {
                if (mrsd == 0) {
                    sliceHeights[i] = sliceTimes[i];
                } else {
                    //System.out.println((mrsd - sliceTimes[i]));
                    sliceHeights[i] = mrsd - sliceTimes[i];
                }
            }
        }
        String sliceModeString = arguments.getStringOption(SLICE_MODE);
        if (sliceModeString != null) {
            try {
                sliceMode = SliceMode.valueOf(sliceModeString.toUpperCase());
            } catch (IllegalArgumentException iae) {
                System.err.println("Unrecognized slice mode: " + sliceModeString);
            }
        }
        String traitRateString = arguments.getStringOption(RATE_ATTRIBUTE);
        if (traitRateString != null) {
            rateString = traitRateString;
        }
        if (arguments.hasOption(BURNIN)) {
            burnin = arguments.getIntegerOption(BURNIN);
            System.err.println("Ignoring a burnin of " + burnin + " trees.");
        }
        if (arguments.hasOption(SKIP)) {
            skipEvery = arguments.getIntegerOption(SKIP);
            System.err.println("Skipping every " + skipEvery + " trees.");
        }
        if (skipEvery < 1) {
            skipEvery = 1;
        }
        String hpdString = arguments.getStringOption(HPD);
        if (hpdString != null) {
            hpdValues = parseVariableLengthDoubleArray(hpdString);
            if (hpdValues.length > 0) {
                for (int i = 0; i < hpdValues.length; i++) {
                    if (hpdValues[i] < 1 || hpdValues[i] > 99) {
                        progressStream.println("HPD Region mass falls outside of 1 - 99% range.");
                        System.exit(-1);
                    }
                    hpdValues[i] = hpdValues[i] / 100.0;
                }
            } else {
                hpdValues = new double[] { 80.0 };
            }
        }
        String traitString = arguments.getStringOption(TRAIT);
        if (traitString != null) {
            traitNames = parseVariableLengthStringArray(traitString);
        //employed to get dispersal rates across the whole tree
        //                for (int y = 0; y < traitNames.length; y++) {
        //                    if (traitNames[y].equals(LOCATIONTRAIT)){
        //                       containsLocation =  true;
        //                    }
        //                }
        }
        if (traitNames == null) {
            traitNames = new String[1];
            traitNames[0] = "location.rate";
        }
        String sliceTimeString = arguments.getStringOption(SLICE_TIMES);
        if (sliceTimeString != null) {
            double[] sliceTimes = parseVariableLengthDoubleArray(sliceTimeString);
            sliceHeights = new double[sliceTimes.length];
            for (int i = 0; i < sliceTimes.length; i++) {
                if (mrsd == 0) {
                    sliceHeights[i] = sliceTimes[i];
                } else {
                    sliceHeights[i] = mrsd - sliceTimes[i];
                }
            }
        }
        String sliceHeightString = arguments.getStringOption(SLICE_HEIGHTS);
        if (sliceHeightString != null) {
            if (sliceTimeString != null) {
                progressStream.println("Either sliceTimes, sliceHeights, timesFile or sliceCount" + "nt.");
                System.exit(-1);
            }
            sliceHeights = parseVariableLengthDoubleArray(sliceHeightString);
        }
        if (arguments.hasOption(SLICE_COUNT)) {
            int sliceCount = arguments.getIntegerOption(SLICE_COUNT);
            double startTime = arguments.getRealOption(START_TIME);
            double delta;
            if (mrsd != 0) {
                delta = (mrsd - startTime) / (sliceCount - 1);
            } else {
                delta = startTime / (sliceCount - 1);
            }
            sliceHeights = new double[sliceCount];
            //                double height = mrsd - startTime;
            //                for (int i = 0; i < sliceCount; i++) {
            //                   sliceHeights[i] = height;
            //                   height -= delta;
            //                }
            double height = 0;
            for (int i = 0; i < sliceCount; i++) {
                sliceHeights[i] = height;
                height += delta;
            }
        }
        String optionString = arguments.getStringOption(ROOT);
        if (optionString != null && optionString.compareToIgnoreCase("true") == 0) {
            summarizeRoot = true;
        }
        optionString = arguments.getStringOption(TIPS);
        if (optionString != null && optionString.compareToIgnoreCase("true") == 0) {
            summarizeTips = true;
        }
        optionString = arguments.getStringOption(CONTOURS);
        if (optionString != null && optionString.compareToIgnoreCase("false") == 0) {
            contours = false;
        }
        optionString = arguments.getStringOption(POINTS);
        if (optionString != null && optionString.compareToIgnoreCase("true") == 0) {
            points = true;
        }
        //sorting sliceHeights
        if (sliceHeights != null) {
            Arrays.sort(sliceHeights);
        }
        String imputeString = arguments.getStringOption(IMPUTE);
        if (imputeString != null && imputeString.compareToIgnoreCase("true") == 0)
            impute = true;
        String branchNormString = arguments.getStringOption(BRANCH_NORMALIZE);
        if (branchNormString != null && branchNormString.compareToIgnoreCase("true") == 0)
            branchNormalization = true;
        String noiseString = arguments.getStringOption(NOISE);
        if (noiseString != null && noiseString.compareToIgnoreCase("false") == 0)
            trueNoise = false;
        String summaryString = arguments.getStringOption(SUMMARY);
        if (summaryString != null && summaryString.compareToIgnoreCase("true") == 0)
            summaryOnly = true;
        String modeString = arguments.getStringOption(CONTOUR_MODE);
        if (modeString != null) {
            contourMode = ContourMode.valueOf(modeString.toUpperCase());
            if (contourMode == ContourMode.R && !ContourWithR.processWithR)
                contourMode = ContourMode.SNYDER;
        }
        String normalizeString = arguments.getStringOption(NORMALIZATION);
        if (normalizeString != null) {
            normalize = Normalization.valueOf(normalizeString.toUpperCase());
        }
        String summaryFormat = arguments.getStringOption(FORMAT);
        if (summaryFormat != null) {
            outputFormat = OutputFormat.valueOf(summaryFormat.toUpperCase());
        }
        String sdrString = arguments.getStringOption(SDR);
        if (sdrString != null) {
            outputFileSDR = sdrString;
            getSDR = true;
        }
        String snrString = arguments.getStringOption(SNR);
        if (snrString != null) {
            outputFileSNR = snrString;
            getSNR = true;
        }
        String progressString = arguments.getStringOption(PROGRESS);
        if (progressString != null) {
            progress = progressString;
        }
        String branch = arguments.getStringOption(BRANCHSET);
        if (branch != null) {
            set = BranchSet.valueOf(branch.toUpperCase());
            System.out.println("Using the branch set: " + set.name());
        }
        if (set == set.BACKBONE) {
            if (arguments.hasOption(BACKBONETAXA)) {
                taxaSet = getTargetSet(arguments.getStringOption(BACKBONETAXA));
            } else {
                System.err.println("you want to summarize the backbone, but have no taxa to define it??");
            }
        }
        if (set == set.CLADE) {
            if (arguments.hasOption(CLADETAXA)) {
                taxaSet = getTargetSet(arguments.getStringOption(BACKBONETAXA));
            } else {
                System.err.println("you want to get summaries for a clade, but have no taxa to define it??");
            }
        }
        if (arguments.hasOption(GRIDSIZE)) {
            grid = arguments.getIntegerOption(GRIDSIZE);
        }
    } catch (Arguments.ArgumentException e) {
        progressStream.println(e);
        printUsage(arguments);
        System.exit(-1);
    }
    final String[] args2 = arguments.getLeftoverArguments();
    switch(args2.length) {
        case 0:
            printUsage(arguments);
            System.exit(1);
        case 2:
            outputFileName = args2[1];
        // fall to
        case 1:
            inputFileName = args2[0];
            break;
        default:
            {
                System.err.println("Unknown option: " + args2[2]);
                System.err.println();
                printUsage(arguments);
                System.exit(1);
            }
    }
    TimeSlicer timeSlicer = new TimeSlicer(inputFileName, burnin, skipEvery, traitNames, sliceHeights, impute, trueNoise, mrsd, contourMode, sliceMode, summarizeRoot, summarizeTips, normalize, getSDR, getSNR, progress, branchNormalization, set, taxaSet, grid, latMin, latMax, longMin, longMax, descendents, rateString);
    timeSlicer.output(outputFileName, summaryOnly, summarizeRoot, summarizeTips, contours, points, outputFormat, hpdValues, outputFileSDR, outputFileSNR);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Example 15 with Arguments

use of dr.app.util.Arguments in project beast-mcmc by beast-dev.

the class SpeciesDelimitationAnalyser method main.

public static void main(String[] args) throws java.io.IOException {
    Locale.setDefault(Locale.US);
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { new Arguments.IntegerOption("burnin", "the number of states to be considered as 'burn-in' [default = none]"), new Arguments.RealOption("collapseheight", "the height below which nodes get collapsed [default = .001]"), new Arguments.RealOption("simcutoff", "the value above which two clusters are regarded as similar enough to support one another's credibility [default = .9]"), new Arguments.Option("help", "option to print this message") });
    try {
        arguments.parseArguments(args);
    } catch (Arguments.ArgumentException ae) {
        System.out.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");
    }
    System.out.println();
    double collapseheight = 0.001;
    if (arguments.hasOption("collapseheight")) {
        collapseheight = arguments.getRealOption("collapseheight");
    }
    double similaritycutoff = 0.9;
    if (arguments.hasOption("simcutoff")) {
        similaritycutoff = arguments.getRealOption("simcutoff");
    }
    System.out.println("burnin " + burnin + " collapseheight " + collapseheight + " simcutoff " + similaritycutoff);
    String[] args2 = arguments.getLeftoverArguments();
    if (args2.length > 2) {
        System.err.println("Unknown option: " + args2[2]);
        System.err.println();
        printUsage(arguments);
        System.exit(1);
    }
    if (args2.length < 2) {
        System.err.println("Input filename and outputfilename required");
        System.err.println();
        printUsage(arguments);
        System.exit(1);
    }
    String inputFileName = args2[0];
    String outputFileName = args2[1];
    SpeciesDelimitationAnalyser spDA = new SpeciesDelimitationAnalyser(burnin, collapseheight, similaritycutoff, inputFileName, outputFileName);
    spDA.readtrees();
    spDA.countclusterings();
    spDA.writeresults();
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Aggregations

Arguments (dr.app.util.Arguments)35 IOException (java.io.IOException)4 File (java.io.File)3 javax.swing (javax.swing)3 ConsoleApplication (jam.console.ConsoleApplication)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ImportException (jebl.evolution.io.ImportException)2 RootedTree (jebl.evolution.trees.RootedTree)2 BeastParser (dr.app.beast.BeastParser)1 DateGuesser (dr.app.beauti.options.DateGuesser)1 ConstantPopulation (dr.evolution.coalescent.ConstantPopulation)1 DemographicFunction (dr.evolution.coalescent.DemographicFunction)1 ExponentialGrowth (dr.evolution.coalescent.ExponentialGrowth)1 LogisticGrowthN0 (dr.evomodel.epidemiology.LogisticGrowthN0)1 TraceException (dr.inference.trace.TraceException)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 Method (java.lang.reflect.Method)1 Set (java.util.Set)1