Change real sequence collision so it isn't biased toward sequences in the earlier wells.

This commit is contained in:
eugenefischer
2022-09-28 23:15:55 -05:00
parent a19525f5bb
commit c30167d5ec

View File

@@ -166,6 +166,8 @@ public class Plate {
Map<String, List<String>> sequencesAndMisreads = new HashMap<>();
//Map of all sequences read. Keys are sequences, values are associated SequenceRecords
Map<String, SequenceRecord> sequenceMap = new LinkedHashMap<>();
//get list of all distinct, real sequences
String[] realSequences = assayWells(sIndices).toArray(new String[0]);
for (int well = 0; well < size; well++) {
for (String[] cell: wells.get(well)) {
for (int sIndex: sIndices) {
@@ -201,8 +203,8 @@ public class Plate {
String wrongSequence;
do{
//get a random real sequence that's been read from the plate before
int index = rand.nextInt(sequencesAndMisreads.size());
wrongSequence = sequencesAndMisreads.keySet().toArray(new String[0])[index];
int index = rand.nextInt(realSequences.length);
wrongSequence = realSequences[index];
//make sure it's not accidentally the *right* sequence
//Also that it's not a wrong sequence already in the misread list
} while(currentSequence.equals(wrongSequence) || sequencesAndMisreads.get(currentSequence).contains(wrongSequence));
@@ -240,6 +242,18 @@ public class Plate {
return sequenceMap;
}
private HashSet<String> assayWells(int[] indices) {
HashSet<String> allSequences = new HashSet<>();
for (List<String[]> well: wells) {
for (String[] cell: well) {
for(int index: indices) {
allSequences.add(cell[index]);
}
}
}
return allSequences;
}
public String getSourceFileName() {
return sourceFile;
}