diff --git a/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java b/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java index 1e420373..e4a358e6 100644 --- a/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java +++ b/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java @@ -34,6 +34,7 @@ import org.broadinstitute.dropseqrna.utils.AbstractSplitBamClp; import org.broadinstitute.dropseqrna.utils.BaseRange; import org.broadinstitute.dropseqrna.utils.PairedSamRecordIterator; +import org.broadinstitute.dropseqrna.utils.StringInterner; import org.broadinstitute.dropseqrna.utils.readpairs.ReadPair; import picard.cmdline.StandardOptionDefinitions; @@ -79,6 +80,8 @@ public class CorrectAndSplitScrnaReadPairs public String BARCODE_QUALS_TAG; private Map allowedBarcodeNormalizedOccurences; + // Don't store many copies of the same allowed barcode in ed1MatchCache + private final StringInterner allowedBarcodeInterner = new StringInterner(); private final ResourceLimitedMap> ed1MatchCache = new ResourceLimitedMap<>( @@ -145,7 +148,7 @@ private Map getNormalizedAllowedBarcodes() { double allowedBarcodeOccurenceCount = allowedBarcodeHistogram.getSumOfValues(); final Map ret = new HashMap<>(allowedBarcodeHistogram.size()); for (final String allowedBarcode: allowedBarcodeHistogram.keySet()) { - ret.put(allowedBarcode, allowedBarcodeHistogram.get(allowedBarcode).getValue()/allowedBarcodeOccurenceCount); + ret.put(allowedBarcodeInterner.intern(allowedBarcode), allowedBarcodeHistogram.get(allowedBarcode).getValue()/allowedBarcodeOccurenceCount); } return ret; } @@ -230,7 +233,7 @@ private List getEd1Matches(final String cellBarcode) { cellBarcodeBytes[i] = b; final String candidate = StringUtil.bytesToString(cellBarcodeBytes); if (allowedBarcodeNormalizedOccurences.containsKey(candidate)) { - ret.add(candidate); + ret.add(allowedBarcodeInterner.intern(candidate)); } } cellBarcodeBytes[i] = original;