public ArtificialSingleSampleReadStreamTest( ArtificialSingleSampleReadStream stream ) { super(ArtificialSingleSampleReadStreamTest.class); this.stream = stream; setName(String.format("%s: numContigs=%d stacksPerContig=%d readsPerStack=%d-%d distanceBetweenStacks=%d-%d readLength=%d-%d unmappedReads=%d", getClass().getSimpleName(), stream.getNumContigs(), stream.getNumStacksPerContig(), stream.getMinReadsPerStack(), stream.getMaxReadsPerStack(), stream.getMinDistanceBetweenStacks(), stream.getMaxDistanceBetweenStacks(), stream.getMinReadLength(), stream.getMaxReadLength(), stream.getNumUnmappedReads())); }
@Test(dataProvider = "ArtificialSingleSampleReadStreamInvalidArgumentsTestDataProvider", expectedExceptions = ReviewedGATKException.class) public void testInvalidArguments( String testName, SAMFileHeader header, String readGroupID, int numContigs, int numStacksPerContig, int minReadsPerStack, int maxReadsPerStack, int minDistanceBetweenStacks, int maxDistanceBetweenStacks, int minReadLength, int maxReadLength, int numUnmappedReads ) { logger.warn("Running test: " + testName); ArtificialSingleSampleReadStream stream = new ArtificialSingleSampleReadStream(header, readGroupID, numContigs, numStacksPerContig, minReadsPerStack, maxReadsPerStack, minDistanceBetweenStacks, maxDistanceBetweenStacks, minReadLength, maxReadLength, numUnmappedReads); } }
public DownsamplingReadsIteratorTest( ArtificialSingleSampleReadStream stream, int targetCoverage ) { super(DownsamplingReadsIteratorTest.class); this.stream = stream; this.targetCoverage = targetCoverage; setName(String.format("%s: targetCoverage=%d numContigs=%d stacksPerContig=%d readsPerStack=%d-%d distanceBetweenStacks=%d-%d readLength=%d-%d unmappedReads=%d", getClass().getSimpleName(), targetCoverage, stream.getNumContigs(), stream.getNumStacksPerContig(), stream.getMinReadsPerStack(), stream.getMaxReadsPerStack(), stream.getMinDistanceBetweenStacks(), stream.getMaxDistanceBetweenStacks(), stream.getMinReadLength(), stream.getMaxReadLength(), stream.getNumUnmappedReads())); }
new DownsamplingReadsIteratorTest(new ArtificialSingleSampleReadStream(header, readGroupID, numContigs,
if ( (originalStream.getNumContigs() == 0 || originalStream.getNumStacksPerContig() == 0) && originalStream.getNumUnmappedReads() == 0 ) { if ( totalReads != 0 ) { throw new ReviewedGATKException("got reads from the stream, but the stream was configured to have 0 reads"); if ( numContigs != originalStream.getNumContigs() ) { throw new ReviewedGATKException("number of contigs not correct"); if ( stacksPerContig.size() != originalStream.getNumContigs() ) { throw new ReviewedGATKException(String.format("bug in analyzer code: calculated sizes for %d contigs even though there were only %d contigs", stacksPerContig.size(), originalStream.getNumContigs())); if ( contigStackCount != originalStream.getNumStacksPerContig() ) { throw new ReviewedGATKException("contig had incorrect number of stacks"); if ( originalStream.getNumStacksPerContig() > 0 ) { if ( minReadsPerStack < originalStream.getMinReadsPerStack() ) { throw new ReviewedGATKException("stack had fewer than the minimum number of reads"); if ( maxReadsPerStack > originalStream.getMaxReadsPerStack() ) { throw new ReviewedGATKException("stack had more than the maximum number of reads"); if ( originalStream.getNumStacksPerContig() > 1 ) { if ( minDistanceBetweenStacks < originalStream.getMinDistanceBetweenStacks() ) { throw new ReviewedGATKException("stacks were separated by less than the minimum distance"); if ( maxDistanceBetweenStacks > originalStream.getMaxDistanceBetweenStacks() ) { throw new ReviewedGATKException("stacks were separated by more than the maximum distance"); if ( minReadLength < originalStream.getMinReadLength() ) {
private void createReadStreams() { perSampleArtificialReadStreams = new HashMap<String, ArtificialSingleSampleReadStream>(numSamples); perSampleStreamAnalyzers = new HashMap<String, ArtificialSingleSampleReadStreamAnalyzer>(numSamples); for (SAMReadGroupRecord readGroup : header.getReadGroups() ) { String readGroupID = readGroup.getReadGroupId(); String sampleName = readGroup.getSample(); int thisSampleNumContigs = MathUtils.randomIntegerInRange(minContigs, maxContigs); int thisSampleStacksPerContig = MathUtils.randomIntegerInRange(streamStacksPerContig.minStacksPerContig, streamStacksPerContig.maxStacksPerContig); int thisSampleNumUnmappedReads = Utils.getRandomGenerator().nextDouble() < unmappedReadsFraction ? unmappedReadsCount : 0; ArtificialSingleSampleReadStream thisSampleStream = new ArtificialSingleSampleReadStream(header, readGroupID, thisSampleNumContigs, thisSampleStacksPerContig, streamStackDepth.minReadsPerStack, streamStackDepth.maxReadsPerStack, streamDensity.minDistanceBetweenStacks, streamDensity.maxDistanceBetweenStacks, MIN_READ_LENGTH, MAX_READ_LENGTH, thisSampleNumUnmappedReads); perSampleArtificialReadStreams.put(sampleName, thisSampleStream); perSampleStreamAnalyzers.put(sampleName, new PositionallyDownsampledArtificialSingleSampleReadStreamAnalyzer(thisSampleStream, targetCoverage)); } mergedReadStream = new ArtificialMultiSampleReadStream(perSampleArtificialReadStreams.values()); }
if ( (originalStream.getNumContigs() == 0 || originalStream.getNumStacksPerContig() == 0) && originalStream.getNumUnmappedReads() == 0 ) { if ( totalReads != 0 ) { throw new ReviewedGATKException("got reads from the stream, but the stream was configured to have 0 reads"); if ( numContigs != originalStream.getNumContigs() ) { throw new ReviewedGATKException("number of contigs not correct"); if ( stacksPerContig.size() != originalStream.getNumContigs() ) { throw new ReviewedGATKException(String.format("bug in analyzer code: calculated sizes for %d contigs even though there were only %d contigs", stacksPerContig.size(), originalStream.getNumContigs())); if ( contigStackCount != originalStream.getNumStacksPerContig() ) { throw new ReviewedGATKException("contig had incorrect number of stacks"); if ( originalStream.getNumStacksPerContig() > 0 ) { int stackMinimumAfterDownsampling = Math.min(targetCoverage, originalStream.getMinReadsPerStack()); int stackMaximumAfterDownsampling = targetCoverage; if ( originalStream.getNumStacksPerContig() > 1 ) { if ( minDistanceBetweenStacks < originalStream.getMinDistanceBetweenStacks() ) { throw new ReviewedGATKException("stacks were separated by less than the minimum distance"); if ( maxDistanceBetweenStacks > originalStream.getMaxDistanceBetweenStacks() ) { throw new ReviewedGATKException("stacks were separated by more than the maximum distance"); if ( minReadLength < originalStream.getMinReadLength() ) { throw new ReviewedGATKException("read was shorter than the minimum allowed length");
((numContigs > 0 && stacksPerContig > 0) || (numContigs == 0 && stacksPerContig == 0)) ) { new ArtificialSingleSampleReadStreamTest(new ArtificialSingleSampleReadStream(header, readGroupID, numContigs,
private void createTestBAM() { header = ArtificialSAMUtils.createArtificialSamHeader(numContigs, 1, 100000); SAMReadGroupRecord readGroup = new SAMReadGroupRecord("foo"); readGroup.setSample("testSample"); header.addReadGroup(readGroup); ArtificialSingleSampleReadStream artificialReads = new ArtificialSingleSampleReadStream(header, "foo", numContigs, numStacksPerContig, stackSize, stackSize, 1, 100, 50, 150, numUnmappedReads); final File testBAMFile = createTempFile("SAMDataSourceFillShardBoundaryTest", ".bam"); SAMFileWriter bamWriter = new SAMFileWriterFactory().setCreateIndex(true).makeBAMWriter(header, true, testBAMFile); for ( SAMRecord read : artificialReads ) { bamWriter.addAlignment(read); } bamWriter.close(); testBAM = new SAMReaderID(testBAMFile, new Tags()); new File(testBAM.getSamFilePath().replace(".bam", ".bai")).deleteOnExit(); new File(testBAM.getSamFilePath() + ".bai").deleteOnExit(); } }