Add flag to print metadata to stdout

This commit is contained in:
2022-02-27 17:36:23 -06:00
parent f2347e8fc2
commit bc5d67680d

View File

@@ -153,17 +153,24 @@ 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
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;
if(line.hasOption("o")) {
outputFilename = line.getOptionValue("o");
}
else {
outputFilename = null;
}
Integer minThreshold = Integer.parseInt(line.getOptionValue("min")); Integer minThreshold = Integer.parseInt(line.getOptionValue("min"));
Integer maxThreshold = Integer.parseInt(line.getOptionValue("max")); Integer maxThreshold = Integer.parseInt(line.getOptionValue("max"));
Integer minOverlapPct; int minOverlapPct;
if (line.hasOption("minpct")) { //see if this filter is being used if (line.hasOption("minpct")) { //see if this filter is being used
minOverlapPct = Integer.parseInt(line.getOptionValue("minpct")); minOverlapPct = Integer.parseInt(line.getOptionValue("minpct"));
} }
else { else {
minOverlapPct = 0; minOverlapPct = 0;
} }
Integer maxOccupancyDiff; int maxOccupancyDiff;
if (line.hasOption("maxdiff")) { //see if this filter is being used if (line.hasOption("maxdiff")) { //see if this filter is being used
maxOccupancyDiff = Integer.parseInt(line.getOptionValue("maxdiff")); maxOccupancyDiff = Integer.parseInt(line.getOptionValue("maxdiff"));
} }
@@ -173,10 +180,17 @@ public class CommandLineInterface {
GraphWithMapData graph = getGraph(graphFilename); GraphWithMapData graph = getGraph(graphFilename);
MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold, MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold,
maxOccupancyDiff, minOverlapPct, false); maxOccupancyDiff, minOverlapPct, false);
MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result); if(outputFilename != null){
writer.writeResultsToFile(); MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result);
writer.writeResultsToFile();
}
//can put a bunch of ifs for outputting various things from the MatchingResult to System.out here //can put a bunch of ifs for outputting various things from the MatchingResult to System.out here
//after I put those flags in the matchOptions //after I put those flags in the matchOptions
if(line.hasOption("print-metadata")) {
for (String k : result.getMetadata().keySet()) {
System.out.println(k + ": " + result.getMetadata().get(k));
}
}
} }
} }
catch (ParseException exp) { catch (ParseException exp) {
@@ -297,7 +311,7 @@ public class CommandLineInterface {
.desc("Randomize well populations on sample plate. Takes two arguments: the minimum possible population and the maximum possible population.") .desc("Randomize well populations on sample plate. Takes two arguments: the minimum possible population and the maximum possible population.")
.hasArgs() .hasArgs()
.numberOfArgs(2) .numberOfArgs(2)
.argName("minimum maximum") .argName("min> <max")
.build(); .build();
Option specificWellPopulations = Option.builder("pop") Option specificWellPopulations = Option.builder("pop")
.desc("The well populations for each section of the sample plate. There will be as many sections as there are populations given.") .desc("The well populations for each section of the sample plate. There will be as many sections as there are populations given.")
@@ -326,22 +340,22 @@ public class CommandLineInterface {
Options graphOptions = new Options(); Options graphOptions = new Options();
Option cellFilename = Option.builder("c") Option cellFilename = Option.builder("c")
.longOpt("cell-file") .longOpt("cell-file")
.desc("Cell sample file to use for checking accuracy") .desc("Cell sample file to use for checking pairing accuracy")
.hasArg() .hasArg()
.argName("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 from which to construct graph")
.hasArg() .hasArg()
.argName("filename") .argName("filename")
.required().build(); .required().build();
Option outputGraphML = Option.builder("graphml") Option outputGraphML = Option.builder("graphml")
.desc("Output GraphML file") .desc("(Optional) Output GraphML file")
.build(); .build();
Option outputSerializedBinary = Option.builder("nb") Option outputSerializedBinary = Option.builder("nb")
.longOpt("no-binary") .longOpt("no-binary")
.desc("Don't output serialized binary file") .desc("(Optional) Don't output serialized binary file")
.build(); .build();
graphOptions.addOption(cellFilename); graphOptions.addOption(cellFilename);
graphOptions.addOption(plateFilename); graphOptions.addOption(plateFilename);
@@ -379,15 +393,36 @@ public class CommandLineInterface {
.hasArg() .hasArg()
.argName("number") .argName("number")
.build(); .build();
matchCDR3options.addOption(graphFilename); Option outputFile = Option.builder("o") //can't call the method this time, because this one's optional
matchCDR3options.addOption(minOccupancyOverlap); .longOpt("output-file")
matchCDR3options.addOption(maxOccupancyOverlap); .hasArg()
matchCDR3options.addOption(minOverlapPercent); .argName("filename")
matchCDR3options.addOption(maxOccupancyDifference); .desc("(Optional) Name of output the output file. If not present, no file will be written.")
matchCDR3options.addOption(outputFileOption()); .build();
//options for output to System.out matchCDR3options.addOption(graphFilename)
//Option printPairingErrorRate = Option.builder() .addOption(minOccupancyOverlap)
.addOption(maxOccupancyOverlap)
.addOption(minOverlapPercent)
.addOption(maxOccupancyDifference)
.addOption(outputFile);
//options for output to System.out
// Option printErrorRate = Option.builder().longOpt("print-error")
// .desc("(Optional) Print the pairing error rate to stdout").build();
// Option printAttempt = Option.builder().longOpt("print-attempt")
// .desc("(Optional) Print the pairing attempt rate to stdout").build();
// Option printCorrect = Option.builder().longOpt("print-correct")
// .desc("(Optional) Print the number of correct pairs to stdout").build();
// Option printIncorrect = Option.builder().longOpt("print-incorrect")
// .desc("(Optional) Print the number of incorrect pairs to stdout").build();
Option printMetadata = Option.builder().longOpt("print-metadata")
.desc("(Optional) Print all metadata to stdout").build();
matchCDR3options
// .addOption(printErrorRate)
// .addOption(printAttempt)
// .addOption(printCorrect)
// .addOption(printIncorrect)
.addOption(printMetadata);
return matchCDR3options; return matchCDR3options;
} }