Added timing to CDR3/CDR1 matching
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -6,12 +7,15 @@ public class MatchingResult {
|
|||||||
private List<String> headers;
|
private List<String> headers;
|
||||||
private List<List<String>> allResults;
|
private List<List<String>> allResults;
|
||||||
private Map<Integer, Integer> matchMap;
|
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.comments = comments;
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
this.allResults = allResults;
|
this.allResults = allResults;
|
||||||
this.matchMap = matchMap;
|
this.matchMap = matchMap;
|
||||||
|
this.time = time;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getComments() {
|
public List<String> getComments() {
|
||||||
@@ -29,4 +33,8 @@ public class MatchingResult {
|
|||||||
public Map<Integer, Integer> getMatchMap() {
|
public Map<Integer, Integer> getMatchMap() {
|
||||||
return matchMap;
|
return matchMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Duration getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,12 +283,12 @@ public class Simulator {
|
|||||||
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
|
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
|
||||||
System.out.println("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,
|
public static MatchingResult[] matchCDR1s(List<Integer[]> distinctCells,
|
||||||
Plate samplePlate, Integer lowThreshold,
|
Plate samplePlate, Integer lowThreshold,
|
||||||
Integer highThreshold, Map<Integer, Integer> previousMatches){
|
Integer highThreshold, Map<Integer, Integer> previousMatches, Duration previousTime){
|
||||||
Instant start = Instant.now();
|
Instant start = Instant.now();
|
||||||
|
|
||||||
int numWells = samplePlate.getSize();
|
int numWells = samplePlate.getSize();
|
||||||
@@ -548,11 +548,16 @@ public class Simulator {
|
|||||||
comments.add("Number of correct matches: " + trueCount);
|
comments.add("Number of correct matches: " + trueCount);
|
||||||
double correctRate = (double) trueCount / allResults.size();
|
double correctRate = (double) trueCount / allResults.size();
|
||||||
comments.add("Correct matching rate: " + correctRate);
|
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){
|
for(String s: comments){
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<String> headers = new ArrayList<>();
|
List<String> headers = new ArrayList<>();
|
||||||
headers.add("CDR3 alpha");
|
headers.add("CDR3 alpha");
|
||||||
headers.add("CDR3 beta");
|
headers.add("CDR3 beta");
|
||||||
@@ -560,7 +565,7 @@ public class Simulator {
|
|||||||
headers.add("second matched CDR1");
|
headers.add("second matched CDR1");
|
||||||
headers.add("Correct match?");
|
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
|
//results for dual map
|
||||||
System.out.println("Results for second pass");
|
System.out.println("Results for second pass");
|
||||||
@@ -602,18 +607,15 @@ public class Simulator {
|
|||||||
comments.add("Number of correct matches: " + trueCount);
|
comments.add("Number of correct matches: " + trueCount);
|
||||||
correctRate = (double) trueCount / allResults.size();
|
correctRate = (double) trueCount / allResults.size();
|
||||||
comments.add("Correct matching rate: " + correctRate);
|
comments.add("Correct matching rate: " + correctRate);
|
||||||
|
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
|
||||||
|
|
||||||
|
|
||||||
for(String s: comments){
|
for(String s: comments){
|
||||||
System.out.println(s);
|
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");
|
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};
|
MatchingResult[] output = {firstTest, dualTest};
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ public class UserInterface {
|
|||||||
List<Integer[]> cells = cellReader.getCells();
|
List<Integer[]> cells = cellReader.getCells();
|
||||||
MatchingResult preliminaryResults = Simulator.matchCDR3s(cells, plate, lowThresholdCDR3, highThresholdCDR3);
|
MatchingResult preliminaryResults = Simulator.matchCDR3s(cells, plate, lowThresholdCDR3, highThresholdCDR3);
|
||||||
MatchingResult[] results = Simulator.matchCDR1s(cells, plate, lowThresholdCDR1,
|
MatchingResult[] results = Simulator.matchCDR1s(cells, plate, lowThresholdCDR1,
|
||||||
highThresholdCDR1, preliminaryResults.getMatchMap());
|
highThresholdCDR1, preliminaryResults.getMatchMap(), preliminaryResults.getTime());
|
||||||
|
|
||||||
//result writer
|
//result writer
|
||||||
MatchingFileWriter writer = new MatchingFileWriter(filename + "First", results[0].getComments(),
|
MatchingFileWriter writer = new MatchingFileWriter(filename + "First", results[0].getComments(),
|
||||||
|
|||||||
Reference in New Issue
Block a user