Refactor to read/write files of graph and map data
This commit is contained in:
@@ -55,13 +55,13 @@ public class Simulator {
|
||||
// }
|
||||
|
||||
|
||||
//Make the maps needed for matching CDR3s
|
||||
public static MapData makeMaps(List<Integer[]> distinctCells,
|
||||
Plate samplePlate, Integer lowThreshold, boolean verbose) {
|
||||
//Make the graph needed for matching CDR3s
|
||||
public static GraphWithMapData makeGraph(List<Integer[]> distinctCells, Plate samplePlate, Integer lowThreshold,
|
||||
Integer highThreshold, boolean verbose) {
|
||||
Instant start = Instant.now();
|
||||
int numWells = samplePlate.getSize();
|
||||
int[] alphaIndex = {cdr3AlphaIndex};
|
||||
int[] betaIndex = {cdr3BetaIndex};
|
||||
int numWells = samplePlate.getSize();
|
||||
|
||||
if(verbose){System.out.println("Making cell maps");}
|
||||
//HashMap keyed to Alphas, values Betas
|
||||
@@ -109,24 +109,6 @@ public class Simulator {
|
||||
//keys are betas, values are sequential integer vertices from previous map
|
||||
Map<Integer, Integer> plateBtoVMap = invertVertexMap(plateVtoBMap);
|
||||
if(verbose){System.out.println("Vertex maps made");}
|
||||
Instant stop = Instant.now();
|
||||
Duration time = Duration.between(start, stop);
|
||||
return new MapData(distCellsMapAlphaKey, allAlphas, allBetas, plateVtoAMap, plateVtoBMap, plateAtoVMap,
|
||||
plateBtoVMap, time);
|
||||
}
|
||||
|
||||
//Make the graph needed for matching CDR3s
|
||||
public static GraphWithMapData makeGraph(Plate samplePlate, MapData maps, Integer lowThreshold,
|
||||
Integer highThreshold, boolean verbose) {
|
||||
int[] alphaIndex = {cdr3AlphaIndex};
|
||||
int[] betaIndex = {cdr3BetaIndex};
|
||||
Instant start = Instant.now();
|
||||
Map<Integer, Integer> plateVtoAMap = maps.getPlateVtoAMap();
|
||||
Map<Integer, Integer> plateVtoBMap = maps.getPlateVtoBMap();
|
||||
Map<Integer, Integer> plateAtoVMap = maps.getPlateAtoVMap();
|
||||
Map<Integer, Integer> plateBtoVMap = maps.getPlateBtoVMap();
|
||||
Map<Integer, Integer> allAlphas = maps.getAllAlphas();
|
||||
Map<Integer, Integer> allBetas = maps.getAllBetas();
|
||||
|
||||
if(verbose){System.out.println("Creating adjacency matrix");}
|
||||
//Count how many wells each alpha appears in
|
||||
@@ -160,16 +142,18 @@ public class Simulator {
|
||||
if(verbose){System.out.println("Over- and under-weight edges set to 0.0");}
|
||||
Instant stop = Instant.now();
|
||||
Duration time = Duration.between(start, stop);
|
||||
time = time.plus(maps.getTime());
|
||||
return new GraphWithMapData(graph, maps, alphaWellCounts, betaWellCounts, time);
|
||||
return new GraphWithMapData(graph, numWells, lowThreshold, highThreshold, distCellsMapAlphaKey, allAlphas,
|
||||
allBetas, plateVtoAMap, plateVtoBMap, plateAtoVMap, plateBtoVMap, alphaWellCounts, betaWellCounts,
|
||||
time);
|
||||
}
|
||||
|
||||
//match CDR3s
|
||||
public static MatchingResult matchCDR3s(Plate samplePlate, GraphWithMapData data, Integer lowThreshold,
|
||||
Integer highThreshold, Integer maxOccupancyDifference,
|
||||
public static MatchingResult matchCDR3s(GraphWithMapData data, Integer maxOccupancyDifference,
|
||||
Integer minOverlapPercent, boolean verbose) {
|
||||
Instant start = Instant.now();
|
||||
int numWells = samplePlate.getSize();
|
||||
int numWells = data.getNumWells();
|
||||
Integer highThreshold = data.getHighThreshold();
|
||||
Integer lowThreshold = data.getLowThreshold();
|
||||
Map<Integer, Integer> distCellsMapAlphaKey = data.getDistCellsMapAlphaKey();
|
||||
Map<Integer, Integer> plateVtoAMap = data.getPlateVtoAMap();
|
||||
Map<Integer, Integer> plateVtoBMap = data.getPlateVtoBMap();
|
||||
@@ -280,7 +264,7 @@ public class Simulator {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
return new MatchingResult(samplePlate.getSourceFileName(), comments, header, allResults, matchMap, time);
|
||||
return new MatchingResult(data.getSourceFilename(), comments, header, allResults, matchMap, time);
|
||||
}
|
||||
|
||||
public static MatchingResult matchCDR3s(List<Integer[]> distinctCells,
|
||||
@@ -371,7 +355,7 @@ public class Simulator {
|
||||
if(verbose){System.out.println("Graph created");}
|
||||
|
||||
//write graph to file
|
||||
GraphFileWriter writer = new GraphFileWriter("graph", graph);
|
||||
GraphMLFileWriter writer = new GraphMLFileWriter("graph", graph);
|
||||
writer.writeGraphToFile();
|
||||
|
||||
if(verbose){System.out.println("Eliminating edges with weights outside threshold values");}
|
||||
|
||||
Reference in New Issue
Block a user