First attempt at command line arguments
This commit is contained in:
@@ -48,43 +48,44 @@ public class Simulator {
|
||||
}
|
||||
|
||||
public static MatchingResult matchCDR3s(List<Integer[]> distinctCells,
|
||||
Plate samplePlate, Integer lowThreshold, Integer highThreshold){
|
||||
System.out.println("Cells: " + distinctCells.size());
|
||||
Plate samplePlate, Integer lowThreshold,
|
||||
Integer highThreshold, boolean verbose){
|
||||
if(verbose){System.out.println("Cells: " + distinctCells.size());}
|
||||
|
||||
Instant start = Instant.now();
|
||||
int numWells = samplePlate.getSize();
|
||||
int[] alphaIndex = {cdr3AlphaIndex};
|
||||
int[] betaIndex = {cdr3BetaIndex};
|
||||
|
||||
System.out.println("Making cell maps");
|
||||
if(verbose){System.out.println("Making cell maps");}
|
||||
//HashMap keyed to Alphas, values Betas
|
||||
Map<Integer, Integer> distCellsMapAlphaKey = makePeptideToPeptideMap(distinctCells, 0, 1);
|
||||
System.out.println("Cell maps made");
|
||||
if(verbose){System.out.println("Cell maps made");}
|
||||
|
||||
System.out.println("Making well maps");
|
||||
if(verbose){System.out.println("Making well maps");}
|
||||
Map<Integer, Integer> allAlphas = samplePlate.assayWellsPeptideP(alphaIndex);
|
||||
Map<Integer, Integer> allBetas = samplePlate.assayWellsPeptideP(betaIndex);
|
||||
int alphaCount = allAlphas.size();
|
||||
System.out.println("all alphas count: " + alphaCount);
|
||||
if(verbose){System.out.println("all alphas count: " + alphaCount);}
|
||||
int betaCount = allBetas.size();
|
||||
System.out.println("all betas count: " + betaCount);
|
||||
if(verbose){System.out.println("all betas count: " + betaCount);}
|
||||
|
||||
System.out.println("Well maps made");
|
||||
if(verbose){System.out.println("Well maps made");}
|
||||
|
||||
//Remove saturating-occupancy peptides because they have no signal value.
|
||||
//Remove below-minimum-overlap-threshold peptides because they can't possibly have an overlap with another
|
||||
//peptide that's above the threshold.
|
||||
System.out.println("Removing peptides present in all wells.");
|
||||
System.out.println("Removing peptides with occupancy below the minimum overlap threshold");
|
||||
if(verbose){System.out.println("Removing peptides present in all wells.");}
|
||||
if(verbose){System.out.println("Removing peptides with occupancy below the minimum overlap threshold");}
|
||||
filterByOccupancyThreshold(allAlphas, lowThreshold, numWells - 1);
|
||||
filterByOccupancyThreshold(allBetas, lowThreshold, numWells - 1);
|
||||
System.out.println("Peptides removed");
|
||||
if(verbose){System.out.println("Peptides removed");}
|
||||
int pairableAlphaCount = allAlphas.size();
|
||||
System.out.println("Remaining alpha count: " + pairableAlphaCount);
|
||||
if(verbose){System.out.println("Remaining alpha count: " + pairableAlphaCount);}
|
||||
int pairableBetaCount = allBetas.size();
|
||||
System.out.println("Remaining beta count: " + pairableBetaCount);
|
||||
if(verbose){System.out.println("Remaining beta count: " + pairableBetaCount);}
|
||||
|
||||
System.out.println("Making vertex maps");
|
||||
if(verbose){System.out.println("Making vertex maps");}
|
||||
//For the SimpleWeightedBipartiteGraphMatrixGenerator, all vertices must have
|
||||
// distinct numbers associated with them. Since I'm using a 2D array, that means
|
||||
// distinct indices between the rows and columns. vertexStartValue lets me track where I switch
|
||||
@@ -101,9 +102,9 @@ public class Simulator {
|
||||
Map<Integer, Integer> plateAtoVMap = invertVertexMap(plateVtoAMap);
|
||||
//keys are betas, values are sequential integer vertices from previous map
|
||||
Map<Integer, Integer> plateBtoVMap = invertVertexMap(plateVtoBMap);
|
||||
System.out.println("Vertex maps made");
|
||||
if(verbose){System.out.println("Vertex maps made");}
|
||||
|
||||
System.out.println("Creating adjacency matrix");
|
||||
if(verbose){System.out.println("Creating adjacency matrix");}
|
||||
//Count how many wells each alpha appears in
|
||||
Map<Integer, Integer> alphaWellCounts = new HashMap<>();
|
||||
//count how many wells each beta appears in
|
||||
@@ -112,9 +113,9 @@ public class Simulator {
|
||||
|
||||
countPeptidesAndFillMatrix(samplePlate, allAlphas, allBetas, plateAtoVMap,
|
||||
plateBtoVMap, alphaIndex, betaIndex, alphaWellCounts, betaWellCounts, weights);
|
||||
System.out.println("matrix created");
|
||||
if(verbose){System.out.println("matrix created");}
|
||||
|
||||
System.out.println("creating graph");
|
||||
if(verbose){System.out.println("creating graph");}
|
||||
SimpleWeightedGraph<Integer, DefaultWeightedEdge> graph =
|
||||
new SimpleWeightedGraph<>(DefaultWeightedEdge.class);
|
||||
SimpleWeightedBipartiteGraphMatrixGenerator graphGenerator = new SimpleWeightedBipartiteGraphMatrixGenerator();
|
||||
@@ -126,18 +127,18 @@ public class Simulator {
|
||||
graphGenerator.second(betaVertices); //This will work because LinkedHashMap preserves order of entry
|
||||
graphGenerator.weights(weights);
|
||||
graphGenerator.generateGraph(graph);
|
||||
System.out.println("Graph created");
|
||||
if(verbose){System.out.println("Graph created");}
|
||||
|
||||
System.out.println("Eliminating edges with weights outside threshold values");
|
||||
if(verbose){System.out.println("Eliminating edges with weights outside threshold values");}
|
||||
filterByOccupancyThreshold(graph, lowThreshold, highThreshold);
|
||||
System.out.println("Over- and under-weight edges set to 0.0");
|
||||
if(verbose){System.out.println("Over- and under-weight edges set to 0.0");}
|
||||
|
||||
|
||||
System.out.println("Finding maximum weighted matching");
|
||||
if(verbose){System.out.println("Finding maximum weighted matching");}
|
||||
MaximumWeightBipartiteMatching maxWeightMatching =
|
||||
new MaximumWeightBipartiteMatching(graph, plateVtoAMap.keySet(), plateVtoBMap.keySet());
|
||||
MatchingAlgorithm.Matching<String, DefaultWeightedEdge> graphMatching = maxWeightMatching.getMatching();
|
||||
System.out.println("Matching completed");
|
||||
if(verbose){System.out.println("Matching completed");}
|
||||
Instant stop = Instant.now();
|
||||
|
||||
//Header for CSV file
|
||||
@@ -209,10 +210,13 @@ public class Simulator {
|
||||
comments.add("Pairing error rate: " + pairingErrorRateTrunc);
|
||||
Duration time = Duration.between(start, stop);
|
||||
comments.add("Simulation time: " + nf.format(time.toSeconds()) + " seconds");
|
||||
for(String s: comments){
|
||||
System.out.println(s);
|
||||
if(verbose){
|
||||
for(String s: comments){
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new MatchingResult(samplePlate.getSourceFileName(), comments, header, allResults, matchMap, time);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user