Refactor plate assay methods to use maps passed as parameters rather than returning maps
This commit is contained in:
@@ -149,24 +149,22 @@ public class Plate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//returns a map of the counts of the sequence at cell index sIndex, in all wells
|
//returns a map of the counts of the sequence at cell index sIndex, in all wells
|
||||||
public Map<String, Integer> assayWellsSequenceS(int... sIndices){
|
public void assayWellsSequenceS(Map<String, Integer> sequences, int... sIndices){
|
||||||
return this.assayWellsSequenceS(0, size, sIndices);
|
this.assayWellsSequenceS(sequences, 0, size, sIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns a map of the counts of the sequence at cell index sIndex, in a specific well
|
//returns a map of the counts of the sequence at cell index sIndex, in a specific well
|
||||||
public Map<String, Integer> assayWellsSequenceS(int n, int... sIndices) {
|
public void assayWellsSequenceS(Map<String, Integer> sequences, int n, int... sIndices) {
|
||||||
return this.assayWellsSequenceS(n, n+1, sIndices);
|
this.assayWellsSequenceS(sequences, n, n+1, sIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns a map of the counts of the sequence at cell index sIndex, in a range of wells
|
//returns a map of the counts of the sequence at cell index sIndex, in a range of wells
|
||||||
public Map<String, Integer> assayWellsSequenceS(int start, int end, int... sIndices) {
|
public void assayWellsSequenceS(Map<String, Integer> sequences, int start, int end, int... sIndices) {
|
||||||
Map<String, Integer> assay = new HashMap<>();
|
|
||||||
for(int sIndex: sIndices){
|
for(int sIndex: sIndices){
|
||||||
for(int i = start; i < end; i++){
|
for(int i = start; i < end; i++){
|
||||||
countSequences(assay, wells.get(i), sIndex);
|
countSequences(sequences, wells.get(i), sIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return assay;
|
|
||||||
}
|
}
|
||||||
//For the sequences at cell indices sIndices, counts number of unique sequences in the given well into the given map
|
//For the sequences at cell indices sIndices, counts number of unique sequences in the given well into the given map
|
||||||
private void countSequences(Map<String, Integer> wellMap, List<String[]> well, int... sIndices) {
|
private void countSequences(Map<String, Integer> wellMap, List<String[]> well, int... sIndices) {
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
|
|
||||||
if(verbose){System.out.println("Making well maps");}
|
if(verbose){System.out.println("Making well maps");}
|
||||||
|
|
||||||
Map<String, Integer> allAlphas = samplePlate.assayWellsSequenceS(alphaIndices);
|
Map<String, Integer> allAlphas = new HashMap<>();
|
||||||
Map<String, Integer> allBetas = samplePlate.assayWellsSequenceS(betaIndices);
|
samplePlate.assayWellsSequenceS(allAlphas, alphaIndices);
|
||||||
|
Map<String, Integer> allBetas = new HashMap<>();
|
||||||
|
samplePlate.assayWellsSequenceS(allBetas, betaIndices);
|
||||||
int alphaCount = allAlphas.size();
|
int alphaCount = allAlphas.size();
|
||||||
if(verbose){System.out.println("All alphas count: " + alphaCount);}
|
if(verbose){System.out.println("All alphas count: " + alphaCount);}
|
||||||
int betaCount = allBetas.size();
|
int betaCount = allBetas.size();
|
||||||
@@ -658,18 +660,20 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
Map<String, Integer> rowSequenceCounts,
|
Map<String, Integer> rowSequenceCounts,
|
||||||
Map<String, Integer> columnSequenceCounts,
|
Map<String, Integer> columnSequenceCounts,
|
||||||
double[][] weights){
|
double[][] weights){
|
||||||
Map<String, Integer> wellNRowSequences = null;
|
Map<String, Integer> wellNRowSequences;
|
||||||
Map<String, Integer> wellNColumnSequences = null;
|
Map<String, Integer> wellNColumnSequences;
|
||||||
int vertexStartValue = rowSequenceToVertexMap.size();
|
int vertexStartValue = rowSequenceToVertexMap.size();
|
||||||
int numWells = samplePlate.getSize();
|
int numWells = samplePlate.getSize();
|
||||||
for (int n = 0; n < numWells; n++) {
|
for (int n = 0; n < numWells; n++) {
|
||||||
wellNRowSequences = samplePlate.assayWellsSequenceS(n, rowSequenceIndices);
|
wellNRowSequences = new HashMap<>();
|
||||||
|
samplePlate.assayWellsSequenceS(wellNRowSequences, n, rowSequenceIndices);
|
||||||
for (String a : wellNRowSequences.keySet()) {
|
for (String a : wellNRowSequences.keySet()) {
|
||||||
if(allRowSequences.containsKey(a)){
|
if(allRowSequences.containsKey(a)){
|
||||||
rowSequenceCounts.merge(a, 1, (oldValue, newValue) -> oldValue + newValue);
|
rowSequenceCounts.merge(a, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wellNColumnSequences = samplePlate.assayWellsSequenceS(n, colSequenceIndices);
|
wellNColumnSequences = new HashMap<>();
|
||||||
|
samplePlate.assayWellsSequenceS(wellNColumnSequences, n, colSequenceIndices);
|
||||||
for (String b : wellNColumnSequences.keySet()) {
|
for (String b : wellNColumnSequences.keySet()) {
|
||||||
if(allColumnSequences.containsKey(b)){
|
if(allColumnSequences.containsKey(b)){
|
||||||
columnSequenceCounts.merge(b, 1, (oldValue, newValue) -> oldValue + newValue);
|
columnSequenceCounts.merge(b, 1, (oldValue, newValue) -> oldValue + newValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user