Expanding simulation to attempt CDR3/CDR1 matching - doubles size of cells

This commit is contained in:
2021-11-15 15:00:11 -06:00
parent c425b05d8c
commit 13b58e3204
5 changed files with 445 additions and 56 deletions

View File

@@ -25,7 +25,7 @@ public class UserInterface {
case 1 -> makeCells();
case 2 -> makePlate();
case 3 -> matchCells();
//case 4 -> //method call here
case 4 -> matchCellsExpanded();
case 5 -> acknowledge();
case 0 -> quit = true;
default -> throw new InputMismatchException("Invalid input.");
@@ -42,10 +42,9 @@ public class UserInterface {
String filename = null;
Integer numCells = 0;
try {
System.out.println("\nSimulated T-Cells consist of matched pairs of alpha and beta peptides, " +
"represented by unique integer values.");
System.out.println("(Note: peptide values are unique within a simulated population, " +
"but repeated between simulated populations.)");
System.out.println("\nSimulated T-Cells consist of integer values representing:\n" +
"* a pair of alpha and beta CDR3 peptides (unique within simulated population)\n" +
"* a pair of alpha and beta CDR1 peptides (not necessarily unique).");
System.out.println("\nThe cells will be written to a file.");
System.out.print("Please enter a file name: ");
filename = sc.next();
@@ -58,7 +57,7 @@ public class UserInterface {
System.out.println(ex);
sc.next();
}
CellSample sample = Simulator.generateCellSample(numCells);
CellSample sample = Simulator.generateExpandedCellSample(numCells);
CellFileWriter writer = new CellFileWriter(filename, sample);
writer.writeCellsToFile();
}
@@ -187,7 +186,82 @@ public class UserInterface {
highThreshold = plate.getSize() - 1;
}
List<Integer[]> cells = cellReader.getCells();
Simulator.matchCDR3s(filename, cells, plate, lowThreshold, highThreshold);
MatchingResult results = Simulator.matchCDR3s(cells, plate, lowThreshold, highThreshold);
//result writer
MatchingFileWriter writer = new MatchingFileWriter(filename, results.getComments(),
results.getHeaders(), results.getAllResults());
writer.writeResultsToFile();
}
}
public static void matchCellsExpanded(){
/*
The idea here is that we'll get the CDR3 alpha/beta matches first. Then we'll try to match CDR3s to CDR1s by
looking at the top two matches for each CDR3. If CDR3s in the same cell simply swap CDR1s, we assume a correct
match
*/
String filename = null;
String cellFile = null;
String plateFile = null;
Integer lowThresholdCDR3 = 0;
Integer highThresholdCDR3 = Integer.MAX_VALUE;
Integer lowThresholdCDR1 = 0;
Integer highThresholdCDR1 = Integer.MAX_VALUE;
try {
System.out.println("\nSimulated experiment requires a cell sample file and a sample plate file.");
System.out.print("Please enter name of an existing cell sample file: ");
cellFile = sc.next();
System.out.print("Please enter name of an existing sample plate file: ");
plateFile = sc.next();
System.out.println("The matching results will be written to a file.");
System.out.print("Please enter a name for the output file: ");
filename = sc.next();
System.out.println("What is the minimum number of CDR3 alpha/beta overlap wells to attempt matching?");
lowThresholdCDR3 = sc.nextInt();
if(lowThresholdCDR3 < 1){
throw new InputMismatchException("Minimum value for low threshold is 1");
}
System.out.println("What is the maximum number of CDR3 alpha/beta overlap wells to attempt matching?");
highThresholdCDR3 = sc.nextInt();
System.out.println("What is the minimum number of CDR3/CDR1 overlap wells to attempt matching?");
lowThresholdCDR1 = sc.nextInt();
if(lowThresholdCDR1 < 1){
throw new InputMismatchException("Minimum value for low threshold is 1");
}
System.out.println("What is the maximum number of CDR3/CDR1 overlap wells to attempt matching?");
highThresholdCDR1 = sc.nextInt();
} catch (InputMismatchException ex) {
System.out.println(ex);
sc.next();
}
CellFileReader cellReader = new CellFileReader(cellFile);
PlateFileReader plateReader = new PlateFileReader(plateFile);
Plate plate = new Plate(plateReader.getWells());
if (cellReader.getCells().size() == 0){
System.out.println("No cell sample found.");
System.out.println("Returning to main menu.");
}
else if(plate.getWells().size() == 0){
System.out.println("No sample plate found.");
System.out.println("Returning to main menu.");
}
else{
if(highThresholdCDR3 >= plate.getSize()){
highThresholdCDR3 = plate.getSize() - 1;
}
if(highThresholdCDR1 >= plate.getSize()){
highThresholdCDR1 = plate.getSize() - 1;
}
List<Integer[]> cells = cellReader.getCells();
MatchingResult preliminaryResults = Simulator.matchCDR3s(cells, plate, lowThresholdCDR3, highThresholdCDR3);
MatchingResult results = Simulator.matchCDR1s(cells, plate, lowThresholdCDR1,
highThresholdCDR1, preliminaryResults.getMatchMap());
//result writer
MatchingFileWriter writer = new MatchingFileWriter(filename, results.getComments(),
results.getHeaders(), results.getAllResults());
writer.writeResultsToFile();
}
}