Search in sources :

Example 1 with CommandLine

use of org.dishevelled.commandline.CommandLine in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class ExtractMugs method main.

/**
 * Main.
 *
 * @param args command line args
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument Hmlfile = new FileArgument("i", "hml-file", "hml file file, default stdin; at least one of expected or observed file must be provided", false);
    FileArgument outputFile = new FileArgument("o", "output-file", "output file, default stdout", false);
    StringArgument sample = new StringArgument("s", "sample-id", "sample ID", false);
    ArgumentList arguments = new ArgumentList(about, help, Hmlfile, outputFile, sample);
    CommandLine commandLine = new CommandLine(args);
    ExtractMugs validateLdHml = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        // todo: allow for configuration of glclient
        validateLdHml = new ExtractMugs(Hmlfile.getValue(), outputFile.getValue(), sample.getValue(), LocalGlClient.create());
    } catch (CommandLineParseException e) {
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(validateLdHml.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : CommandLine(org.dishevelled.commandline.CommandLine) Switch(org.dishevelled.commandline.Switch) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) FileArgument(org.dishevelled.commandline.argument.FileArgument) ArgumentList(org.dishevelled.commandline.ArgumentList) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) StringArgument(org.dishevelled.commandline.argument.StringArgument)

Example 2 with CommandLine

use of org.dishevelled.commandline.CommandLine in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class ValidateLdGlstrings method main.

/**
 * Main.
 *
 * @param args command line args
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument inputHmlFile = new FileArgument("i", "input-file", "input file, default stdin", false);
    FileArgument outputFile = new FileArgument("o", "output-file", "output allele assignment file, default stdout", false);
    ArgumentList arguments = new ArgumentList(about, help, inputHmlFile, outputFile);
    CommandLine commandLine = new CommandLine(args);
    ValidateLdGlstrings validateLdGlstrings = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        validateLdGlstrings = new ValidateLdGlstrings(inputHmlFile.getValue(), outputFile.getValue());
    } catch (CommandLineParseException | IllegalArgumentException e) {
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(validateLdGlstrings.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : CommandLine(org.dishevelled.commandline.CommandLine) Switch(org.dishevelled.commandline.Switch) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) FileArgument(org.dishevelled.commandline.argument.FileArgument) ArgumentList(org.dishevelled.commandline.ArgumentList) IOException(java.io.IOException) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException)

Example 3 with CommandLine

use of org.dishevelled.commandline.CommandLine in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class NormalizeFrequencyFile method main.

/**
 * Main.
 *
 * @param args command line args
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument inputFile = new FileArgument("i", "input-file", "input file, default stdin", false);
    StringArgument frequencies = new StringArgument("f", "frequencies", "frequencies (acb, cb, drb1_dqb1, drb_dqb, five_loc, six_loc, single), default five_loc", false);
    FileArgument outputFile = new FileArgument("o", "output-file", "output allele assignment file, default stdout", false);
    ArgumentList arguments = new ArgumentList(about, help, inputFile, frequencies, outputFile);
    CommandLine commandLine = new CommandLine(args);
    NormalizeFrequencyFile normalizeFrequencyFile = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        normalizeFrequencyFile = new NormalizeFrequencyFile(inputFile.getValue(), frequencies.getValue(), outputFile.getValue());
    } catch (CommandLineParseException | IllegalArgumentException e) {
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(normalizeFrequencyFile.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : CommandLine(org.dishevelled.commandline.CommandLine) Switch(org.dishevelled.commandline.Switch) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) FileArgument(org.dishevelled.commandline.argument.FileArgument) ArgumentList(org.dishevelled.commandline.ArgumentList) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) StringArgument(org.dishevelled.commandline.argument.StringArgument)

Example 4 with CommandLine

use of org.dishevelled.commandline.CommandLine in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class AnalyzeGLStrings method main.

/**
 * Main.
 *
 * @param args command line args
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument inputFile = new FileArgument("i", "input-file", "input file, default stdin", false);
    FileArgument outputFile = new FileArgument("o", "output-location", "specify an output file or an existing directory, default stdout", false);
    StringArgument hladb = new StringArgument("v", "hladb-version", "HLA DB version (e.g. 3.19.0), default latest", false);
    StringArgument freq = new StringArgument("f", "frequencies", "Frequency Set (e.g. nmdp, nmdp-2007, wiki), default nmdp-2007", false);
    BooleanArgument warnings = new BooleanArgument("w", "warnings-only", "Only log warnings, default all GL String output", false);
    FileSetArgument frequencyFiles = new FileSetArgument("q", "frequency-file(s)", "frequency input files (comma separated), default nmdp-2007 five locus", false);
    FileArgument allelesFile = new FileArgument("l", "allele-file", "alleles known to have frequencies, default none", false);
    ArgumentList arguments = new ArgumentList(about, help, inputFile, outputFile, hladb, freq, warnings, frequencyFiles, allelesFile);
    CommandLine commandLine = new CommandLine(args);
    AnalyzeGLStrings analyzeGLStrings = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        analyzeGLStrings = new AnalyzeGLStrings(inputFile.getValue(), outputFile.getValue(), hladb.getValue(), freq.getValue(), warnings.getValue(), frequencyFiles.getValue(), allelesFile.getValue());
    } catch (CommandLineParseException | IllegalArgumentException e) {
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(analyzeGLStrings.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : CommandLine(org.dishevelled.commandline.CommandLine) Switch(org.dishevelled.commandline.Switch) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) BooleanArgument(org.dishevelled.commandline.argument.BooleanArgument) FileArgument(org.dishevelled.commandline.argument.FileArgument) FileSetArgument(org.dishevelled.commandline.argument.FileSetArgument) ArgumentList(org.dishevelled.commandline.ArgumentList) IOException(java.io.IOException) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) StringArgument(org.dishevelled.commandline.argument.StringArgument)

Aggregations

ArgumentList (org.dishevelled.commandline.ArgumentList)4 CommandLine (org.dishevelled.commandline.CommandLine)4 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)4 Switch (org.dishevelled.commandline.Switch)4 FileArgument (org.dishevelled.commandline.argument.FileArgument)4 StringArgument (org.dishevelled.commandline.argument.StringArgument)3 IOException (java.io.IOException)2 BooleanArgument (org.dishevelled.commandline.argument.BooleanArgument)1 FileSetArgument (org.dishevelled.commandline.argument.FileSetArgument)1