Added timing to CDR3/CDR1 matching

This commit is contained in:
2021-11-16 16:37:29 -06:00
parent 48510a5b60
commit 255a3ba66c
3 changed files with 22 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
import java.time.Duration;
import java.util.List;
import java.util.Map;
@@ -6,12 +7,15 @@ public class MatchingResult {
private List<String> headers;
private List<List<String>> allResults;
private Map<Integer, Integer> matchMap;
private Duration time;
public MatchingResult(List<String> comments, List<String> headers, List<List<String>> allResults, Map<Integer, Integer>matchMap){
public MatchingResult(List<String> comments, List<String> headers, List<List<String>> allResults, Map<Integer, Integer>matchMap, Duration time){
this.comments = comments;
this.headers = headers;
this.allResults = allResults;
this.matchMap = matchMap;
this.time = time;
}
public List<String> getComments() {
@@ -29,4 +33,8 @@ public class MatchingResult {
public Map<Integer, Integer> getMatchMap() {
return matchMap;
}
public Duration getTime() {
return time;
}
}

View File

@@ -283,12 +283,12 @@ public class Simulator {
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
System.out.println("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
return new MatchingResult(comments, header, allResults, matchMap);
return new MatchingResult(comments, header, allResults, matchMap, time);
}
public static MatchingResult[] matchCDR1s(List<Integer[]> distinctCells,
Plate samplePlate, Integer lowThreshold,
Integer highThreshold, Map<Integer, Integer> previousMatches){
Integer highThreshold, Map<Integer, Integer> previousMatches, Duration previousTime){
Instant start = Instant.now();
int numWells = samplePlate.getSize();
@@ -548,11 +548,16 @@ public class Simulator {
comments.add("Number of correct matches: " + trueCount);
double correctRate = (double) trueCount / allResults.size();
comments.add("Correct matching rate: " + correctRate);
NumberFormat nf = NumberFormat.getInstance(Locale.US);
Duration time = Duration.between(start, stop);
time.plus(previousTime);
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
for(String s: comments){
System.out.println(s);
}
List<String> headers = new ArrayList<>();
headers.add("CDR3 alpha");
headers.add("CDR3 beta");
@@ -560,7 +565,7 @@ public class Simulator {
headers.add("second matched CDR1");
headers.add("Correct match?");
MatchingResult firstTest = new MatchingResult(comments, headers, allResults, dualMatchesMap);
MatchingResult firstTest = new MatchingResult(comments, headers, allResults, dualMatchesMap, time);
//results for dual map
System.out.println("Results for second pass");
@@ -602,18 +607,15 @@ public class Simulator {
comments.add("Number of correct matches: " + trueCount);
correctRate = (double) trueCount / allResults.size();
comments.add("Correct matching rate: " + correctRate);
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
for(String s: comments){
System.out.println(s);
}
NumberFormat nf = NumberFormat.getInstance(Locale.US);
Duration time = Duration.between(start, stop);
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
System.out.println("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
MatchingResult dualTest = new MatchingResult(comments, headers, allResults, dualMatchesMap);
MatchingResult dualTest = new MatchingResult(comments, headers, allResults, dualMatchesMap, time);
MatchingResult[] output = {firstTest, dualTest};

View File

@@ -256,7 +256,7 @@ public class UserInterface {
List<Integer[]> cells = cellReader.getCells();
MatchingResult preliminaryResults = Simulator.matchCDR3s(cells, plate, lowThresholdCDR3, highThresholdCDR3);
MatchingResult[] results = Simulator.matchCDR1s(cells, plate, lowThresholdCDR1,
highThresholdCDR1, preliminaryResults.getMatchMap());
highThresholdCDR1, preliminaryResults.getMatchMap(), preliminaryResults.getTime());
//result writer
MatchingFileWriter writer = new MatchingFileWriter(filename + "First", results[0].getComments(),