-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change CRAM validation error reporting granularity from container to …
…record (#1091) Defer validation checking until records are retrieved, rather than validating the entire container.
- Loading branch information
Showing
3 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package htsjdk.samtools; | ||
|
||
import htsjdk.HtsjdkTest; | ||
import htsjdk.samtools.cram.ref.ReferenceSource; | ||
import htsjdk.samtools.seekablestream.SeekableStream; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
|
||
|
||
/** | ||
* This test serves for verifying CRAMIterator records validation using strict validation strategy | ||
* | ||
* @author Anton_Mazur@epam.com, EPAM Systems, Inc. | ||
**/ | ||
|
||
public class CRAMIteratorTest extends HtsjdkTest { | ||
|
||
@Test(description = "This test checks that records validation is deferred until they are retrieved") | ||
public void noValidationFailureOnContainerOpen() { | ||
try (SAMRecordIterator cramIteratorOverInvalidRecords = getCramFileIterator(ValidationStringency.STRICT)) { | ||
Assert.assertTrue(cramIteratorOverInvalidRecords.hasNext()); | ||
} | ||
} | ||
|
||
@Test(expectedExceptions = SAMException.class) | ||
public void throwOnRecordValidationFailure() { | ||
try (SAMRecordIterator cramIteratorOverInvalidRecords = getCramFileIterator(ValidationStringency.STRICT)) { | ||
while (cramIteratorOverInvalidRecords.hasNext()) { | ||
cramIteratorOverInvalidRecords.next(); | ||
} | ||
} | ||
} | ||
|
||
private SAMRecordIterator getCramFileIterator(ValidationStringency valStringency) { | ||
final File refFile = new File("src/test/resources/htsjdk/samtools/cram/ce.fa"); | ||
final File cramFile = new File("src/test/resources/htsjdk/samtools/cram/ce#containsInvalidRecords.3.0.cram"); | ||
final ReferenceSource source = new ReferenceSource(refFile); | ||
|
||
final CRAMFileReader cramFileReader = new CRAMFileReader(cramFile, (SeekableStream) null, source); | ||
cramFileReader.setValidationStringency(valStringency); | ||
return cramFileReader.getIterator(); | ||
} | ||
} |
Binary file added
BIN
+809 Bytes
src/test/resources/htsjdk/samtools/cram/ce#containsInvalidRecords.3.0.cram
Binary file not shown.