Search in sources :

Example 26 with Arguments

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

the class MakeAncestralSequenceAnnotatedTree method main.

/**
     * Main method
     */
public static void main(String[] args) throws IOException, TraceException {
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { new Arguments.IntegerOption("thin", "thin"), new Arguments.IntegerOption("skip", "skip"), 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 skip = -1;
    if (arguments.hasOption("skip")) {
        skip = arguments.getIntegerOption("skip");
    }
    int thin = -1;
    if (arguments.hasOption("thin")) {
        thin = arguments.getIntegerOption("thin");
    }
    //        String discreteVariableName = null;
    //        if (arguments.hasOption("discreteVariable")) {
    //            discreteVariableName = arguments.getStringOption("discreteVariable");
    //        }
    String outInputFileName = null;
    String fastasInputFileName = null;
    String treesInputfileName = null;
    String outputFileName = null;
    String[] args2 = arguments.getLeftoverArguments();
    if (args2.length > 4) {
        System.err.println("Unknown option: " + args2[2]);
        System.err.println();
        printUsage(arguments);
        System.exit(1);
    }
    if (args2.length > 0) {
        outInputFileName = args2[0];
    }
    if (args2.length > 0) {
        fastasInputFileName = args2[1];
    }
    if (args2.length > 0) {
        treesInputfileName = args2[2];
    }
    if (args2.length > 3) {
        outputFileName = args2[3];
    }
    if (outInputFileName == null) {
        // No input file name was given so throw up a dialog box...
        outInputFileName = Utils.getLoadFileName("MakeAncestralSequenceAnnotatedTree " + version.getVersionString() + " - Select *.out file to analyse");
    }
    if (fastasInputFileName == null) {
        // No input file name was given so throw up a dialog box...
        fastasInputFileName = Utils.getLoadFileName("MakeAncestralSequenceAnnotatedTree " + version.getVersionString() + " - Select *.fastas file to analyse");
    }
    if (treesInputfileName == null) {
        // No input file name was given so throw up a dialog box...
        treesInputfileName = Utils.getLoadFileName("MakeAncestralSequenceAnnotatedTree " + version.getVersionString() + " - Select *.trees file to analyse");
    }
    if (skip == -1) {
        System.out.println("Enter skip: ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        skip = Integer.parseInt(br.readLine());
    }
    if (thin == -1) {
        System.out.println("Enter thin: ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        thin = Integer.parseInt(br.readLine());
    }
    //        if(discreteVariableName==null) {
    //            System.out.println("Enter name of discrete variable: ");
    //            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //            discreteVariableName = br.readLine();
    //        }
    new MakeAncestralSequenceAnnotatedTree(thin, skip, outInputFileName, fastasInputFileName, treesInputfileName, outputFileName);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Example 27 with Arguments

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

the class GetNSCountsFromTrees 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' [default = 0]"), new Arguments.StringOption(BRANCHINFO, falseTrue, false, "include a summary for the root [default=off]"), new Arguments.StringOption(BRANCHSET, TimeSlicer.enumNamesToStringArray(BranchSet.values()), false, "branch set [default = all]"), //                        new Arguments.StringOption(CLADETAXA, "clade taxa file", "specifies a file with taxa that define the clade"),
    new Arguments.StringOption(INCLUDECLADES, "clade exclusion files", "specifies files with taxa that define clades to be excluded"), new Arguments.StringOption(CLADESTEM, falseTrue, false, "include clade stem [default=false]"), new Arguments.StringOption(EXCLUDECLADESTEM, falseTrue, true, "include clade stem in the exclusion [default=true]"), new Arguments.StringOption(BACKBONETAXA, "Backbone taxa file", "specifies a file with taxa that define the backbone"), new Arguments.StringOption(ZEROBRANCHES, falseTrue, true, "include branches with 0 N and S subtitutions [default=included]"), new Arguments.StringOption(SUMMARY, falseTrue, true, "provide a summary of the N and S counts per tree [default=detailed output]"), new Arguments.RealOption(MRSD, "specifies the most recent sampling data in fractional years to rescale time [default=0]"), new Arguments.StringOption(EXCLUDECLADES, "clade exclusion files", "specifies files with taxa that define clades to be excluded"), new Arguments.IntegerOption(SITESUM, "the number of nucleotide sites to summarize rates in per site per time unit [default = 1]"), new Arguments.StringOption(CODONSITELIST, "list of sites", "sites for which the summary is restricted to"), 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.err.println("Ignoring a burnin of " + burnin + " trees.");
    }
    boolean branchInfo = false;
    String infoString = arguments.getStringOption(BRANCHINFO);
    if (infoString != null && infoString.compareToIgnoreCase("true") == 0) {
        branchInfo = true;
    }
    BranchSet set = BranchSet.ALL;
    String branch = arguments.getStringOption(BRANCHSET);
    List<Set> inclusionSets = new ArrayList();
    if (branch != null) {
        set = BranchSet.valueOf(branch.toUpperCase());
        progressStream.println("Using the branch set: " + set.name());
    }
    if (set == set.BACKBONE) {
        if (arguments.hasOption(BACKBONETAXA)) {
            String[] fileList = parseVariableLengthStringArray(arguments.getStringOption(BACKBONETAXA));
            for (String singleSet : fileList) {
                inclusionSets.add(getTargetSet(singleSet));
                progressStream.println("getting target set for backbone inclusion: " + singleSet);
            }
        } else {
            progressStream.println("you want to get summaries for (a) backbone(s), but no files with taxa to define it are provided??");
        }
    }
    if (set == set.CLADE) {
        if (arguments.hasOption(INCLUDECLADES)) {
            String[] fileList = parseVariableLengthStringArray(arguments.getStringOption(INCLUDECLADES));
            for (String singleSet : fileList) {
                inclusionSets.add(getTargetSet(singleSet));
                progressStream.println("getting target set for clade inclusion: " + singleSet);
            }
        } else {
            progressStream.println("you want to get summaries for one or more clades, but no files with taxa to define it are provided??");
        }
    }
    boolean cladeStem = false;
    String cladeStemString = arguments.getStringOption(CLADESTEM);
    if (cladeStemString != null && cladeStemString.compareToIgnoreCase("true") == 0) {
        cladeStem = true;
    }
    boolean excludeCladeStems = true;
    String excludeCladeStemString = arguments.getStringOption(CLADESTEM);
    if (excludeCladeStemString != null && excludeCladeStemString.compareToIgnoreCase("false") == 0) {
        excludeCladeStems = false;
    }
    boolean zeroBranches = true;
    String zeroBranchString = arguments.getStringOption(ZEROBRANCHES);
    if (zeroBranchString != null && zeroBranchString.compareToIgnoreCase("false") == 0) {
        zeroBranches = false;
    }
    boolean summary = false;
    String summaryString = arguments.getStringOption(SUMMARY);
    if (summaryString != null && summaryString.compareToIgnoreCase("true") == 0) {
        summary = true;
    }
    int sites = 1;
    if (arguments.hasOption(SITESUM)) {
        sites = arguments.getIntegerOption(SITESUM);
    }
    double mrsd = 0;
    if (arguments.hasOption(MRSD)) {
        mrsd = arguments.getRealOption(MRSD);
    }
    List<Set> exclusionSets = new ArrayList();
    if (arguments.hasOption(EXCLUDECLADES)) {
        String[] fileList = parseVariableLengthStringArray(arguments.getStringOption(EXCLUDECLADES));
        for (String singleSet : fileList) {
            exclusionSets.add(getTargetSet(singleSet));
            progressStream.println("getting target set for clade exclusion: " + singleSet);
        }
    }
    double[] siteList = null;
    if (arguments.hasOption(CODONSITELIST)) {
        siteList = parseVariableLengthDoubleArray(arguments.getStringOption(CODONSITELIST));
        progressStream.println("site list provided: note that dN/dS will not be accurately estimated because the neutral expectation to get dN/dS (uN and uS) is for all sites along a branch.");
    }
    String inputFileName = null;
    String outputFileName = null;
    String[] args2 = arguments.getLeftoverArguments();
    if (args2.length > 2) {
        progressStream.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("GetNSCountsFromTrees " + version.getVersionString() + " - Select tree file to analyse");
    }
    if (burnin == -1) {
        System.err.println("Enter number of trees to burn-in (integer): ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        burnin = Integer.parseInt(br.readLine());
    }
    new GetNSCountsFromTrees(burnin, inputFileName, outputFileName, branchInfo, set, inclusionSets, cladeStem, zeroBranches, summary, sites, mrsd, exclusionSets, excludeCladeStems, siteList);
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments)

Example 28 with Arguments

use of dr.app.util.Arguments 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);
}
Also used : Arguments(dr.app.util.Arguments) IOException(java.io.IOException) ImportException(jebl.evolution.io.ImportException) TraceException(dr.inference.trace.TraceException) HashSet(java.util.HashSet)

Example 29 with Arguments

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

the class LogAnalyser method main.

//Main method
public static void main(String[] args) throws java.io.IOException, TraceException {
    // 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);
    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("short", "use this option to produce a short report"), new Arguments.Option("hpd", "use this option to produce hpds for each trace"), new Arguments.Option("ess", "use this option to produce ESSs for each trace"), new Arguments.Option("stdErr", "use this option to produce standard Error"), new Arguments.StringOption("marginal", "trace_name", "specify the trace to use to calculate the marginal likelihood"), //				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("LogAnalyser " + version.getVersionString() + " - Select log file to analyse");
        File[] files = Utils.getLoadFiles("LogAnalyser " + version.getVersionString() + " - Select log file to analyse", openDefaultDirectory, "BEAST log (*.log) Files", "log", "txt");
        new LogAnalyser(burnin, files, outputFileName, !shortReport, hpds, ess, stdErr, marginalLikelihood);
    } else {
        new LogAnalyser(burnin, inputFileName, outputFileName, !shortReport, hpds, ess, stdErr, marginalLikelihood);
    }
    System.exit(0);
}
Also used : Arguments(dr.app.util.Arguments) File(java.io.File)

Example 30 with Arguments

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

the class GetAncestralSequenceFromSplitTrait method main.

//Main method
public static void main(String[] args) throws IOException, TraceException {
    printTitle();
    Arguments arguments = new Arguments(new Arguments.Option[] { 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);
    }
    String outInputFileName = 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) {
        outInputFileName = args2[0];
    }
    if (args2.length > 1) {
        outputFileName = args2[1];
    }
    if (outInputFileName == null) {
        // No input file name was given so throw up a dialog box...
        outInputFileName = Utils.getLoadFileName("GetAncestralSequenceFromSplitTrait " + version.getVersionString() + " - Select *.tree file to analyse");
    }
    new GetAncestralSequenceFromSplitTrait(outInputFileName, outputFileName);
    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