From c30167d5ec2b7c46ef49bf7d40c3d09ae11d1090 Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Wed, 28 Sep 2022 23:15:55 -0500 Subject: [PATCH] Change real sequence collision so it isn't biased toward sequences in the earlier wells. --- src/main/java/Plate.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/Plate.java b/src/main/java/Plate.java index b81a140..c790be8 100644 --- a/src/main/java/Plate.java +++ b/src/main/java/Plate.java @@ -166,6 +166,8 @@ public class Plate { Map> sequencesAndMisreads = new HashMap<>(); //Map of all sequences read. Keys are sequences, values are associated SequenceRecords Map 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 assayWells(int[] indices) { + HashSet allSequences = new HashSet<>(); + for (List well: wells) { + for (String[] cell: well) { + for(int index: indices) { + allSequences.add(cell[index]); + } + } + } + return allSequences; + } + public String getSourceFileName() { return sourceFile; }