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

Remove hash sets for counting various classes of CBC, to reduce memor… #430

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ protected void splitBAMs() {

if (METRICS != null) {
final MetricsFile<BarcodeCorrectionMetrics, Integer> metricsFile = getMetricsFile();
metrics.NUM_BARCODES_EXACT_MATCH = exactMatchBarcodes.size();
metrics.NUM_BARCODES_CORRECTED_SINGLE_ED1 = singleEd1Barcodes.size();
metrics.NUM_BARCODES_UNCORRECTABLE_NO_ED1_BARCODES = noEd1Barcodes.size();
metrics.NUM_BARCODES_CORRECTED_MULTI_ED1 = multiEd1Barcodes.size();
metrics.NUM_BARCODES_UNCORRECTED_AMBIGUOUS = ambiguousBarcodes.size();
metricsFile.addMetric(metrics);
metricsFile.addHistogram(numCandidatesHist);
metricsFile.write(METRICS);
Expand All @@ -161,7 +156,6 @@ private String getCorrectedCellBarcode(final SAMRecord readWithBarcode) {
log.debug("EXACT_MATCH " + readWithBarcode);
}
++metrics.NUM_READS_EXACT_MATCH;
exactMatchBarcodes.add(cellBarcode);
return cellBarcode;
} else {
List<String> ed1Matches = ed1MatchCache.get(cellBarcode);
Expand All @@ -170,14 +164,12 @@ private String getCorrectedCellBarcode(final SAMRecord readWithBarcode) {
log.debug("UNCORRECTABLE_NO_ED1 " + readWithBarcode);
}
++metrics.NUM_READS_UNCORRECTABLE_NO_ED1_BARCODES;
noEd1Barcodes.add(cellBarcode);
return cellBarcode;
} else if (ed1Matches.size() == 1) {
if (VERBOSITY == Log.LogLevel.DEBUG && metrics.NUM_READS_CORRECTED_SINGLE_ED1 == 0) {
log.debug("CORRECTED_SINGLE_ED1 " + readWithBarcode);
}
++metrics.NUM_READS_CORRECTED_SINGLE_ED1;
singleEd1Barcodes.add(cellBarcode);
numCandidatesHist.increment(1);
return ed1Matches.getFirst();
} else {
Expand All @@ -199,15 +191,13 @@ private String getCorrectedCellBarcode(final SAMRecord readWithBarcode) {
log.debug("CORRECTED_MULTI_ED1 " + readWithBarcode);
}
++metrics.NUM_READS_CORRECTED_MULTI_ED1;
multiEd1Barcodes.add(cellBarcode);
numCandidatesHist.increment(ed1Matches.size());
return bestBarcode;
} else {
if (VERBOSITY == Log.LogLevel.DEBUG && metrics.NUM_READS_UNCORRECTED_AMBIGUOUS == 0) {
log.debug("UNCORRECTED_AMBIGUOUS " + readWithBarcode);
}
++metrics.NUM_READS_UNCORRECTED_AMBIGUOUS;
ambiguousBarcodes.add(cellBarcode);
return cellBarcode;
}
}
Expand Down Expand Up @@ -267,23 +257,12 @@ protected String[] customCommandLineValidation() {
return CustomCommandLineValidationHelper.makeValue(super.customCommandLineValidation(), list);
}

// Sets for counting number of unique barcodes in each category
private final Set<String> exactMatchBarcodes = new HashSet<>();
private final Set<String> singleEd1Barcodes = new HashSet<>();
private final Set<String> multiEd1Barcodes = new HashSet<>();
private final Set<String> noEd1Barcodes = new HashSet<>();
private final Set<String> ambiguousBarcodes = new HashSet<>();
public static class BarcodeCorrectionMetrics extends MetricBase {
public long NUM_READS_EXACT_MATCH;
public long NUM_READS_CORRECTED_SINGLE_ED1;
public long NUM_READS_CORRECTED_MULTI_ED1;
public long NUM_READS_UNCORRECTABLE_NO_ED1_BARCODES;
public long NUM_READS_UNCORRECTED_AMBIGUOUS;
public long NUM_BARCODES_EXACT_MATCH;
public long NUM_BARCODES_CORRECTED_SINGLE_ED1;
public long NUM_BARCODES_CORRECTED_MULTI_ED1;
public long NUM_BARCODES_UNCORRECTABLE_NO_ED1_BARCODES;
public long NUM_BARCODES_UNCORRECTED_AMBIGUOUS;
}

/** Stock main method. */
Expand Down
Loading