3 Commits

Author SHA1 Message Date
bc5d67680d Add flag to print metadata to stdout 2022-02-27 17:36:23 -06:00
f2347e8fc2 check verbose flag 2022-02-27 17:35:50 -06:00
c8364d8a6e check verbose flag 2022-02-27 17:34:20 -06:00
2 changed files with 57 additions and 20 deletions

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
line = parser.parse(matchOptions, Arrays.copyOfRange(args, 1, args.length));
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 maxThreshold = Integer.parseInt(line.getOptionValue("max"));
Integer minOverlapPct;
int minOverlapPct;
if (line.hasOption("minpct")) { //see if this filter is being used
minOverlapPct = Integer.parseInt(line.getOptionValue("minpct"));
}
else {
minOverlapPct = 0;
}
Integer maxOccupancyDiff;
int maxOccupancyDiff;
if (line.hasOption("maxdiff")) { //see if this filter is being used
maxOccupancyDiff = Integer.parseInt(line.getOptionValue("maxdiff"));
}
@@ -173,10 +180,17 @@ public class CommandLineInterface {
GraphWithMapData graph = getGraph(graphFilename);
MatchingResult result = Simulator.matchCDR3s(graph, graphFilename, minThreshold, maxThreshold,
maxOccupancyDiff, minOverlapPct, false);
MatchingFileWriter writer = new MatchingFileWriter(outputFilename, result);
writer.writeResultsToFile();
if(outputFilename != null){
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
//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) {
@@ -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.")
.hasArgs()
.numberOfArgs(2)
.argName("minimum maximum")
.argName("min> <max")
.build();
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.")
@@ -326,22 +340,22 @@ public class CommandLineInterface {
Options graphOptions = new Options();
Option cellFilename = Option.builder("c")
.longOpt("cell-file")
.desc("Cell sample file to use for checking accuracy")
.desc("Cell sample file to use for checking pairing accuracy")
.hasArg()
.argName("filename")
.required().build();
Option plateFilename = Option.builder("p")
.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()
.argName("filename")
.required().build();
Option outputGraphML = Option.builder("graphml")
.desc("Output GraphML file")
.desc("(Optional) Output GraphML file")
.build();
Option outputSerializedBinary = Option.builder("nb")
.longOpt("no-binary")
.desc("Don't output serialized binary file")
.desc("(Optional) Don't output serialized binary file")
.build();
graphOptions.addOption(cellFilename);
graphOptions.addOption(plateFilename);
@@ -379,15 +393,36 @@ public class CommandLineInterface {
.hasArg()
.argName("number")
.build();
matchCDR3options.addOption(graphFilename);
matchCDR3options.addOption(minOccupancyOverlap);
matchCDR3options.addOption(maxOccupancyOverlap);
matchCDR3options.addOption(minOverlapPercent);
matchCDR3options.addOption(maxOccupancyDifference);
matchCDR3options.addOption(outputFileOption());
//options for output to System.out
//Option printPairingErrorRate = Option.builder()
Option outputFile = Option.builder("o") //can't call the method this time, because this one's optional
.longOpt("output-file")
.hasArg()
.argName("filename")
.desc("(Optional) Name of output the output file. If not present, no file will be written.")
.build();
matchCDR3options.addOption(graphFilename)
.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;
}

View File

@@ -15,8 +15,10 @@ public class GraphDataObjectReader {
BufferedInputStream fileIn = new BufferedInputStream(new FileInputStream(filename));
ObjectInputStream in = new ObjectInputStream(fileIn))
{
System.out.println("Reading graph data from file. This may take some time");
System.out.println("File I/O time is not included in results");
if (this.verbose) {
System.out.println("Reading graph data from file. This may take some time");
System.out.println("File I/O time is not included in results");
}
data = (GraphWithMapData) in.readObject();
} catch (FileNotFoundException | ClassNotFoundException ex) {
ex.printStackTrace();