From 3f2b707ad64d03a6b8f97f753f727a27a481cdf1 Mon Sep 17 00:00:00 2001 From: Matthew Mah Date: Thu, 2 Nov 2023 14:45:42 -0400 Subject: [PATCH] Fix off by 1 error on merge lengths. Cleanups for warnings. --- pom.xml | 2 +- .../adnascreen/IndexAndBarcodeScreener.java | 2 +- src/main/java/adnascreen/Read.java | 2 +- .../java/adnascreen/SampleSetsCounter.java | 1 - src/test/java/adnascreen/MergeTests.java | 26 +++++++++++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 599fc4d..d2f4cbd 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 edu.harvard.hms.reichlab adnascreen - 1.11.4-SNAPSHOT + 1.11.5-SNAPSHOT Ancient DNA Tools 1.8 diff --git a/src/main/java/adnascreen/IndexAndBarcodeScreener.java b/src/main/java/adnascreen/IndexAndBarcodeScreener.java index 14648bc..5de0c6a 100644 --- a/src/main/java/adnascreen/IndexAndBarcodeScreener.java +++ b/src/main/java/adnascreen/IndexAndBarcodeScreener.java @@ -283,7 +283,7 @@ public Boolean call() throws IOException, InterruptedException{ try { // queue each paired read for merging enqueuePairedReads(pool, resultsQueue, r1Filename, r2Filename, i1Filename, i2Filename, i5Label, i7Label); - return new Boolean(true); + return Boolean.TRUE; } catch (IOException | InterruptedException e) { throw(e); } finally { diff --git a/src/main/java/adnascreen/Read.java b/src/main/java/adnascreen/Read.java index 248164e..e64ec59 100644 --- a/src/main/java/adnascreen/Read.java +++ b/src/main/java/adnascreen/Read.java @@ -162,7 +162,7 @@ public static List findBestAlignment(Read a, Read b, int maxPenalty, in // bbbbbbbbbbb // starting position is for minimum required overlap // ending position is for minimum result length - for(int offset = a.length() - minOverlapLength; b.length() + offset > minResultLength; offset--){ + for(int offset = a.length() - minOverlapLength; b.length() + offset >= minResultLength; offset--){ int aOffset, bOffset; if(offset >= 0){ aOffset = offset; diff --git a/src/main/java/adnascreen/SampleSetsCounter.java b/src/main/java/adnascreen/SampleSetsCounter.java index 9f00a08..c323fe9 100644 --- a/src/main/java/adnascreen/SampleSetsCounter.java +++ b/src/main/java/adnascreen/SampleSetsCounter.java @@ -7,7 +7,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.stream.Stream; /** diff --git a/src/test/java/adnascreen/MergeTests.java b/src/test/java/adnascreen/MergeTests.java index 8031705..d6d7d4f 100644 --- a/src/test/java/adnascreen/MergeTests.java +++ b/src/test/java/adnascreen/MergeTests.java @@ -60,6 +60,32 @@ public void duplicateAlignment(){ assertEquals(0, offset); } + @Test + public void duplicateAlignmentMinLength(){ + // reads minus barcodes + Read r1 = new Read("@NS500217:348:HTW2FBGXY:1:11101:22352:1064 1:N:0:0", + "CTAGCATTACTTATATGATATGTCTCCATA", + "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); + + List alignments = Read.findBestAlignment(r1, r1, maxPenalty, minOverlapLength, minResultLength, maxPositions, + mismatchPenaltyHigh, mismatchPenaltyLow, mismatchBaseQualityThreshold); + assertEquals(1, alignments.size()); + int offset = alignments.get(0); + assertEquals(0, offset); + } + + @Test + public void duplicateAlignmentBelowMinLength(){ + // reads minus barcodes + Read r1 = new Read("@NS500217:348:HTW2FBGXY:1:11101:22352:1064 1:N:0:0", + "CTAGCATTACTTATATGATATGTCTCCAT", + "EEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); + + List alignments = Read.findBestAlignment(r1, r1, maxPenalty, minOverlapLength, minResultLength, maxPositions, + mismatchPenaltyHigh, mismatchPenaltyLow, mismatchBaseQualityThreshold); + assertEquals(0, alignments.size()); + } + @Test public void testTrimTrailingN(){ Read r1 = new Read("@NS500217:348:HTW2FBGXY:1:11101:22352:1064 1:N:0:0",