Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an LRU cache with CorrectAndSplitScrnaReadPairs to reduce mem #427

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 21 cannot run Gradle 8.4: via https://docs.gradle.org/current/userguide/compatibility.html#java

Makes it difficult to debug in IntelliJ.

networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,26 @@ public class CorrectAndSplitScrnaReadPairs
public String BARCODE_QUALS_TAG;

private Map<String, Double> allowedBarcodeNormalizedOccurences;
private final Map<String, List<String>> ed1MatchCache = new HashMap<>();

private final ResourceLimitedMap<String, List<String>> ed1MatchCache =
new ResourceLimitedMap<>(
1_000_000,
new ResourceLimitedMapFunctor<>() {
@Override
public List<String> makeValue(final String key) {
return CorrectAndSplitScrnaReadPairs.this.getEd1Matches(key);
}

@Override
public void finalizeValue(final String key, final List<String> strings) {
}
}
);

private List<BaseRange> baseRanges;

private BarcodeCorrectionMetrics metrics = new BarcodeCorrectionMetrics();
private Histogram<Integer> numCandidatesHist = new Histogram<>("NUM_ED1_CANDIDATES", "NUM_READS");
private final BarcodeCorrectionMetrics metrics = new BarcodeCorrectionMetrics();
private final Histogram<Integer> numCandidatesHist = new Histogram<>("NUM_ED1_CANDIDATES", "NUM_READS");

@Override
protected void splitBAMs() {
Expand Down Expand Up @@ -146,7 +161,7 @@ private String getCorrectedCellBarcode(final SAMRecord readWithBarcode) {
exactMatchBarcodes.add(cellBarcode);
return cellBarcode;
} else {
List<String> ed1Matches = ed1MatchCache.computeIfAbsent(cellBarcode, this::getEd1Matches);
List<String> ed1Matches = ed1MatchCache.get(cellBarcode);
if (ed1Matches.isEmpty()) {
if (VERBOSITY == Log.LogLevel.DEBUG && metrics.NUM_READS_UNCORRECTABLE_NO_ED1_BARCODES == 0) {
log.debug("UNCORRECTABLE_NO_ED1 " + readWithBarcode);
Expand Down Expand Up @@ -267,4 +282,9 @@ public static class BarcodeCorrectionMetrics extends MetricBase {
public long NUM_BARCODES_UNCORRECTABLE_NO_ED1_BARCODES;
public long NUM_BARCODES_UNCORRECTED_AMBIGUOUS;
}

/** Stock main method. */
public static void main(final String[] args) {
System.exit(new CorrectAndSplitScrnaReadPairs().instanceMain(args));
}
}
Loading