use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReadPileupUnitTest method testSplitBySampleMissingReadGroupException.
@Test(expectedExceptions = UserException.ReadMissingReadGroup.class)
public void testSplitBySampleMissingReadGroupException() throws Exception {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "nullRG", 0, 1, 10);
final ReadPileup pileup = new ReadPileup(loc, Collections.singletonList(read), 1);
final Map<String, ReadPileup> error = pileup.splitBySample(header, null);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReadPileupUnitTest method testInvalidConstructorParametersReadsAndOffsetsLists.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInvalidConstructorParametersReadsAndOffsetsLists() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
final GATKRead read1 = ArtificialReadUtils.createArtificialRead(header, "read1", 0, 1, 10);
new ReadPileup(loc, Arrays.asList(read1), Arrays.asList(1, 2, 3));
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReadPileupUnitTest method testNullConstructorParametersLoc.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullConstructorParametersLoc() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
final GATKRead read1 = ArtificialReadUtils.createArtificialRead(header, "read1", 0, 1, 10);
new ReadPileup(null, Arrays.asList(read1), Arrays.asList(1));
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class LocusWalker method traverse.
/**
* Implementation of locus-based traversal.
* Subclasses can override to provide their own behavior but default implementation should be suitable for most uses.
*
* The default implementation iterates over all positions in the reference covered by reads (filtered and transformed)
* for all samples in the read groups, using the downsampling method provided by {@link #getDownsamplingInfo()}
* and including deletions only if {@link #includeDeletions()} returns {@code true}.
*/
@Override
public void traverse() {
final SAMFileHeader header = getHeaderForReads();
// get the samples from the read groups
final Set<String> samples = header.getReadGroups().stream().map(SAMReadGroupRecord::getSample).collect(Collectors.toSet());
final CountingReadFilter countedFilter = makeReadFilter();
// get the filter and transformed iterator
final Iterator<GATKRead> readIterator = getTransformedReadStream(countedFilter).iterator();
// get the LIBS
final LocusIteratorByState libs = new LocusIteratorByState(readIterator, getDownsamplingInfo(), keepUniqueReadListInLibs(), samples, header, includeDeletions(), includeNs());
final Iterator<AlignmentContext> iterator = createAlignmentContextIterator(header, libs);
// iterate over each alignment, and apply the function
final Spliterator<AlignmentContext> spliterator = Spliterators.spliteratorUnknownSize(iterator, 0);
StreamSupport.stream(spliterator, false).forEach(alignmentContext -> {
final SimpleInterval alignmentInterval = new SimpleInterval(alignmentContext);
apply(alignmentContext, new ReferenceContext(reference, alignmentInterval), new FeatureContext(features, alignmentInterval));
progressMeter.update(alignmentInterval);
});
logger.info(countedFilter.getSummaryLine());
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReplaceSamHeader method doWork.
/**
* Do the work after command line has been parsed.
* RuntimeException may be thrown by this method, and are reported appropriately.
*
* @return program exit status.
*/
@Override
protected Object doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsReadable(HEADER);
IOUtil.assertFileIsWritable(OUTPUT);
final SAMFileHeader replacementHeader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).getFileHeader(HEADER);
if (BamFileIoUtils.isBamFile(INPUT)) {
blockCopyReheader(replacementHeader);
} else {
standardReheader(replacementHeader);
}
return null;
}
Aggregations