Add -help CLI option

This commit is contained in:
2022-02-27 16:45:30 -06:00
parent 32c5bcaaff
commit 12b003a69f

View File

@@ -49,14 +49,30 @@ import java.util.stream.Stream;
public class CommandLineInterface { public class CommandLineInterface {
public static void startCLI(String[] args) { public static void startCLI(String[] args) {
//main options set - for the four different program modes //Options sets for the different modes
Options mainOptions = buildMainOptions(); Options mainOptions = buildMainOptions();
Options cellOptions = buildCellOptions();
Options plateOptions = buildPlateOptions();
Options graphOptions = buildGraphOptions();
Options matchOptions = buildMatchCDR3options();
CommandLineParser parser = new DefaultParser(); CommandLineParser parser = new DefaultParser();
try{ try{
CommandLine line = parser.parse(mainOptions, Arrays.copyOfRange(args, 0, 1)); CommandLine line = parser.parse(mainOptions, Arrays.copyOfRange(args, 0, 1));
if (line.hasOption("cells")) { if (line.hasOption("help")) {
Options cellOptions = buildCellOptions(); HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("BiGpairSEQ_Sim", mainOptions);
System.out.println();
formatter.printHelp("BiGpairSEQ_SIM -cells", cellOptions);
System.out.println();
formatter.printHelp("BiGpairSEQ_Sim -plate", plateOptions);
System.out.println();
formatter.printHelp("BiGpairSEQ_Sim -graph", graphOptions);
System.out.println();
formatter.printHelp("BiGpairSEQ_Sim -match", matchOptions);
}
else if (line.hasOption("cells")) {
line = parser.parse(cellOptions, Arrays.copyOfRange(args, 1, args.length)); line = parser.parse(cellOptions, Arrays.copyOfRange(args, 1, args.length));
Integer number = Integer.valueOf(line.getOptionValue("n")); Integer number = Integer.valueOf(line.getOptionValue("n"));
Integer diversity = Integer.valueOf(line.getOptionValue("d")); Integer diversity = Integer.valueOf(line.getOptionValue("d"));
@@ -65,7 +81,6 @@ public class CommandLineInterface {
} }
else if (line.hasOption("plate")) { else if (line.hasOption("plate")) {
Options plateOptions = buildPlateOptions();
line = parser.parse(plateOptions, Arrays.copyOfRange(args, 1, args.length)); line = parser.parse(plateOptions, Arrays.copyOfRange(args, 1, args.length));
//get the cells //get the cells
String cellFilename = line.getOptionValue("c"); String cellFilename = line.getOptionValue("c");
@@ -116,7 +131,6 @@ public class CommandLineInterface {
} }
else if (line.hasOption("graph")) { //Making a graph else if (line.hasOption("graph")) { //Making a graph
Options graphOptions = buildGraphOptions();
line = parser.parse(graphOptions, Arrays.copyOfRange(args, 1, args.length)); line = parser.parse(graphOptions, Arrays.copyOfRange(args, 1, args.length));
String cellFilename = line.getOptionValue("c"); String cellFilename = line.getOptionValue("c");
String plateFilename = line.getOptionValue("p"); String plateFilename = line.getOptionValue("p");
@@ -137,7 +151,6 @@ public class CommandLineInterface {
} }
else if (line.hasOption("match")) { //can add a flag for which match type in future, spit this in two else if (line.hasOption("match")) { //can add a flag for which match type in future, spit this in two
Options matchOptions = buildMatchCDR3options();
line = parser.parse(matchOptions, Arrays.copyOfRange(args, 1, args.length)); line = parser.parse(matchOptions, Arrays.copyOfRange(args, 1, args.length));
String graphFilename = line.getOptionValue("g"); String graphFilename = line.getOptionValue("g");
String outputFilename = line.getOptionValue("o"); String outputFilename = line.getOptionValue("o");
@@ -184,6 +197,7 @@ public class CommandLineInterface {
private static Options buildMainOptions() { private static Options buildMainOptions() {
Options mainOptions = new Options(); Options mainOptions = new Options();
Option help = Option.builder("help").build();
Option makeCells = Option.builder("cells") Option makeCells = Option.builder("cells")
.longOpt("make-cells") .longOpt("make-cells")
.desc("Makes a cell sample file of distinct T cells") .desc("Makes a cell sample file of distinct T cells")
@@ -201,6 +215,7 @@ public class CommandLineInterface {
.desc("Matches CDR3s. Requires a graph/data file.") .desc("Matches CDR3s. Requires a graph/data file.")
.build(); .build();
OptionGroup mainGroup = new OptionGroup(); OptionGroup mainGroup = new OptionGroup();
mainGroup.addOption(help);
mainGroup.addOption(makeCells); mainGroup.addOption(makeCells);
mainGroup.addOption(makePlate); mainGroup.addOption(makePlate);
mainGroup.addOption(makeGraph); mainGroup.addOption(makeGraph);
@@ -236,11 +251,13 @@ public class CommandLineInterface {
.longOpt("cell-file") .longOpt("cell-file")
.desc("The cell sample file to use") .desc("The cell sample file to use")
.hasArg() .hasArg()
.argName("filename")
.required().build(); .required().build();
Option numWells = Option.builder("w")// add this to plate options Option numWells = Option.builder("w")// add this to plate options
.longOpt("wells") .longOpt("wells")
.desc("The number of wells on the sample plate") .desc("The number of wells on the sample plate")
.hasArg() .hasArg()
.argName("number")
.required().build(); .required().build();
//options group for choosing with distribution to use //options group for choosing with distribution to use
OptionGroup distributions = new OptionGroup();// add this to plate options OptionGroup distributions = new OptionGroup();// add this to plate options
@@ -260,12 +277,14 @@ public class CommandLineInterface {
//options group for statistical distribution parameters //options group for statistical distribution parameters
OptionGroup statParams = new OptionGroup();// add this to plate options OptionGroup statParams = new OptionGroup();// add this to plate options
Option stdDev = Option.builder("stddev") Option stdDev = Option.builder("stddev")
.desc("Standard deviation for Gaussian distribution") .desc("If using -gaussian flag, standard deviation for distrbution")
.hasArg() .hasArg()
.argName("value")
.build(); .build();
Option lambda = Option.builder("lambda") Option lambda = Option.builder("lambda")
.desc("Lambda value for exponential distribution") .desc("If using -exponential flag, lambda value for distribution")
.hasArg() .hasArg()
.argName("value")
.build(); .build();
statParams.addOption(stdDev); statParams.addOption(stdDev);
statParams.addOption(lambda); statParams.addOption(lambda);
@@ -275,19 +294,20 @@ public class CommandLineInterface {
Option randomWellPopulations = Option.builder("random") Option randomWellPopulations = Option.builder("random")
.desc("Randomize well populations on sample plate.") .desc("Randomize well populations on sample plate.")
.hasArgs() .hasArgs()
.argName("MIN_POP MAX_POP") .numberOfArgs(2)
.argName("max_pop min_pop")
.build(); .build();
Option specificWellPopulations = Option.builder("pop") Option specificWellPopulations = Option.builder("pop")
.longOpt("populations") .longOpt("populations")
.desc("The well populations for each section of the sample plate") .desc("The well populations for each section of the sample plate. There will be as many sections as populations given.")
.hasArgs() .hasArgs()
.argName("SECTION_1_POP [SECTION_2_POP] [SECTION_3_POP] ...") .argName("1st_pop [2nd_pop]...")
.build(); .build();
Option dropoutRate = Option.builder("err") //add this to plate options Option dropoutRate = Option.builder("err") //add this to plate options
.longOpt("dropout-rate") .longOpt("dropout-rate")
.hasArg() .hasArg()
.desc("The sequence dropout rate due to amplification error") .desc("The sequence dropout rate due to amplification error")
.argName("DROPOUT_RATE (value between 0.0 and 1.0)") .argName("rate")
.required() .required()
.build(); .build();
wellPopOptions.addOption(randomWellPopulations); wellPopOptions.addOption(randomWellPopulations);
@@ -308,13 +328,13 @@ public class CommandLineInterface {
.longOpt("cell-file") .longOpt("cell-file")
.desc("Cell sample file to use for checking accuracy") .desc("Cell sample file to use for checking accuracy")
.hasArg() .hasArg()
.argName("CELL_FILENAME") .argName("filename")
.required().build(); .required().build();
Option plateFilename = Option.builder("p") Option plateFilename = Option.builder("p")
.longOpt("plate-filename") .longOpt("plate-filename")
.desc("Sample plate file (made from given cell sample file) to construct graph from") .desc("Sample plate file (made from given cell sample file) to construct graph from")
.hasArg() .hasArg()
.argName("PLATE_FILENAME") .argName("filename")
.required().build(); .required().build();
Option outputGraphML = Option.builder("graphml") Option outputGraphML = Option.builder("graphml")
.desc("Output GraphML file") .desc("Output GraphML file")
@@ -337,29 +357,31 @@ public class CommandLineInterface {
.longOpt("graph-file") .longOpt("graph-file")
.desc("Graph/data file to use") .desc("Graph/data file to use")
.hasArg() .hasArg()
.argName("GRAPH/DATA_FILENAME") .argName("filename")
.required().build(); .required().build();
Option minOccupancyOverlap = Option.builder("min") Option minOccupancyOverlap = Option.builder("min")
.longOpt("min-overlap-size") .longOpt("min-overlap-size")
.desc("The minimum number of shared wells to attempt to match a sequence pair") .desc("The minimum number of shared wells to attempt to match a sequence pair")
.hasArg() .hasArg()
.argName("MIN_OVERLAP") .argName("minimum")
.required().build(); .required().build();
Option maxOccupancyOverlap = Option.builder("max") Option maxOccupancyOverlap = Option.builder("max")
.longOpt("max_overlap_size") .longOpt("max_overlap_size")
.desc("The maximum number of shared wells to attempt to match a sequence pair") .desc("The maximum number of shared wells to attempt to match a sequence pair")
.hasArg() .hasArg()
.argName("MAX_OVERLAP") .argName("maximum")
.required().build(); .required().build();
Option minOverlapPercent = Option.builder("minpct") Option minOverlapPercent = Option.builder("minpct")
.longOpt("min-overlap-percent") .longOpt("min-overlap-percent")
.desc("The minimum percentage of a sequence's total occupancy shared by another sequence to attempt matching") .desc("(Optional) The minimum percentage of a sequence's total occupancy shared by another sequence to attempt matching. (0 - 100) ")
.hasArg() .hasArg()
.argName("minimum")
.build(); .build();
Option maxOccupancyDifference = Option.builder("maxdiff") Option maxOccupancyDifference = Option.builder("maxdiff")
.longOpt("max-occupancy-difference") .longOpt("max-occupancy-difference")
.desc("The maximum difference in total occupancy between two sequences to attempt matching") .desc("(Optional) The maximum difference in total occupancy between two sequences to attempt matching.")
.hasArg() .hasArg()
.argName("maximum")
.build(); .build();
matchCDR3options.addOption(graphFilename); matchCDR3options.addOption(graphFilename);
matchCDR3options.addOption(minOccupancyOverlap); matchCDR3options.addOption(minOccupancyOverlap);
@@ -367,6 +389,9 @@ public class CommandLineInterface {
matchCDR3options.addOption(minOverlapPercent); matchCDR3options.addOption(minOverlapPercent);
matchCDR3options.addOption(maxOccupancyDifference); matchCDR3options.addOption(maxOccupancyDifference);
matchCDR3options.addOption(outputFileOption()); matchCDR3options.addOption(outputFileOption());
//options for output to System.out
//Option printPairingErrorRate = Option.builder()
return matchCDR3options; return matchCDR3options;
} }