Skip to content

Commit

Permalink
Fix off by 1 error on merge lengths. Cleanups for warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMah committed Nov 2, 2023
1 parent 50d89e5 commit 3f2b707
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.harvard.hms.reichlab</groupId>
<artifactId>adnascreen</artifactId>
<version>1.11.4-SNAPSHOT</version>
<version>1.11.5-SNAPSHOT</version>
<name>Ancient DNA Tools</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/adnascreen/IndexAndBarcodeScreener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/adnascreen/Read.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static List<Integer> 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;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/adnascreen/SampleSetsCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/adnascreen/MergeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> 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<Integer> 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",
Expand Down

0 comments on commit 3f2b707

Please sign in to comment.