-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved records correctness's checking from nextContainer() to next() Moved records correctness's validation in the separate method Added tests relate new functionality Add inheriting from HtsjdkTest in new test
- Loading branch information
AntonMazur
authored and
AntonMazur
committed
Feb 20, 2018
1 parent
e051a56
commit b3e4f77
Showing
2 changed files
with
75 additions
and
13 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,53 @@ | ||
package htsjdk.samtools; | ||
|
||
import htsjdk.HtsjdkTest; | ||
import htsjdk.samtools.cram.ref.ReferenceSource; | ||
import htsjdk.samtools.seekablestream.SeekableStream; | ||
import org.junit.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
|
||
|
||
/** | ||
* @author [email protected], EPAM Systems, Inc. | ||
* | ||
* This test serve for verifying CRAMIterator records validation using strict validation strategy | ||
**/ | ||
|
||
public class CRAMIteratorTest extends HtsjdkTest { | ||
private static final File refFile = new File("src/test/resources/htsjdk/samtools/cram/ce.fa"); | ||
private static final File cramFile = new File("src/test/resources/htsjdk/samtools/cram/ce#supp.3.0.cram"); | ||
ReferenceSource source = new ReferenceSource(refFile); | ||
|
||
@Test() | ||
public void shouldNotThrowsExceptionIfCRAMfileContainsInvalidRecords() { | ||
SAMRecordIterator cramIter = | ||
getCramFileIterator(cramFile, source, ValidationStringency.STRICT); | ||
|
||
Assert.assertTrue(cramIter.hasNext()); | ||
} | ||
|
||
@Test(expectedExceptions = SAMException.class) | ||
public void shouldThrowExceptionIfCRAMFileContainsInvalidRecods() { | ||
SAMRecordIterator cramIter = | ||
getCramFileIterator(cramFile, source, ValidationStringency.STRICT); | ||
|
||
while (cramIter.hasNext()) | ||
{ | ||
cramIter.next(); | ||
} | ||
} | ||
|
||
private SAMRecordIterator getCramFileIterator(File cramFile, | ||
ReferenceSource source, | ||
ValidationStringency valStrigency) { | ||
|
||
CRAMFileReader cramFileReader = new CRAMFileReader(cramFile, (SeekableStream) null, source); | ||
cramFileReader.setValidationStringency(valStrigency); | ||
return cramFileReader.getIterator(); | ||
} | ||
} | ||
|
||
|
||
|