use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class IntervalUtilsUnitTest method genomeLocsFromLocatablesData.
@DataProvider(name = "genomeLocsFromLocatablesData")
public Object[][] genomeLocsFromLocatablesData() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 10);
final GenomeLocParser genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
return new Object[][] { { genomeLocParser, Collections.emptyList() }, { genomeLocParser, Collections.singletonList(new SimpleInterval("1", 1, 2)) }, { genomeLocParser, Arrays.asList(new SimpleInterval("1", 1, 2), new SimpleInterval("1", 1, 1), new SimpleInterval("1", 5, 9)) }, { genomeLocParser, Arrays.asList(new SimpleInterval("1", 9, 10), new SimpleInterval("1", 5, 9), new SimpleInterval("1", 1, 9)) } };
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ContextCovariateUnitTest method testSimpleContexts.
@Test
public void testSimpleContexts() {
final Random rnd = Utils.getRandomGenerator();
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
for (int i = 0; i < 10; i++) {
final GATKRead read = ArtificialReadUtils.createRandomRead(header, 1000);
read.setIsReverseStrand(rnd.nextBoolean());
final GATKRead clippedRead = ReadClipper.clipLowQualEnds(read, RAC.LOW_QUAL_TAIL, ClippingRepresentation.WRITE_NS);
final ReadCovariates readCovariates = new ReadCovariates(read.getLength(), 1, new CovariateKeyCache());
covariate.recordValues(read, header, readCovariates, true);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), RAC.MISMATCHES_CONTEXT_SIZE, clippedRead, covariate, RAC.LOW_QUAL_TAIL);
verifyCovariateArray(readCovariates.getInsertionsKeySet(), RAC.INDELS_CONTEXT_SIZE, clippedRead, covariate, RAC.LOW_QUAL_TAIL);
verifyCovariateArray(readCovariates.getDeletionsKeySet(), RAC.INDELS_CONTEXT_SIZE, clippedRead, covariate, RAC.LOW_QUAL_TAIL);
}
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class CycleCovariateUnitTest method testMaxCyclePasses.
@Test
public void testMaxCyclePasses() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeaderWithReadGroup(illuminaReadGroup);
int readLength = RAC.MAXIMUM_CYCLE_VALUE;
GATKRead read = ArtificialReadUtils.createRandomRead(readLength);
read.setIsPaired(true);
read.setReadGroup(illuminaReadGroup.getReadGroupId());
ReadCovariates readCovariates = new ReadCovariates(read.getLength(), 1, new CovariateKeyCache());
covariate.recordValues(read, header, readCovariates, true);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class CycleCovariateUnitTest method testSimpleCycles.
@Test
public void testSimpleCycles() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeaderWithReadGroup(illuminaReadGroup);
short readLength = 10;
GATKRead read = ArtificialReadUtils.createRandomRead(header, readLength);
read.setIsPaired(true);
read.setReadGroup(illuminaReadGroup.getReadGroupId());
ReadCovariates readCovariates = new ReadCovariates(read.getLength(), 1, new CovariateKeyCache());
covariate.recordValues(read, header, readCovariates, true);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), 1, (short) 1);
read.setIsReverseStrand(true);
covariate.recordValues(read, header, readCovariates, true);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), readLength, -1);
read.setIsSecondOfPair();
covariate.recordValues(read, header, readCovariates, true);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), -readLength, 1);
read.setIsReverseStrand(false);
covariate.recordValues(read, header, readCovariates, true);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), -1, -1);
}
use of htsjdk.samtools.SAMFileHeader in project gatk-protected by broadinstitute.
the class ReadThreadingGraphUnitTest method testDanglingTails.
@Test(dataProvider = "DanglingTails")
public void testDanglingTails(final String refEnd, final String altEnd, final String cigar, final boolean cigarIsGood, final int mergePointDistanceFromSink) {
final int kmerSize = 15;
// construct the haplotypes
final String commonPrefix = "AAAAAAAAAACCCCCCCCCCGGGGGGGGGGTTTTTTTTTT";
final String ref = commonPrefix + refEnd;
final String alt = commonPrefix + altEnd;
// create the graph and populate it
final ReadThreadingGraph rtgraph = new ReadThreadingGraph(kmerSize);
rtgraph.addSequence("ref", ref.getBytes(), true);
final GATKRead read = ArtificialReadUtils.createArtificialRead(alt.getBytes(), Utils.dupBytes((byte) 30, alt.length()), alt.length() + "M");
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
rtgraph.addRead(read, header);
rtgraph.buildGraphIfNecessary();
// confirm that we have just a single dangling tail
MultiDeBruijnVertex altSink = null;
for (final MultiDeBruijnVertex v : rtgraph.vertexSet()) {
if (rtgraph.isSink(v) && !rtgraph.isReferenceNode(v)) {
Assert.assertTrue(altSink == null, "We found more than one non-reference sink");
altSink = v;
}
}
Assert.assertTrue(altSink != null, "We did not find a non-reference sink");
// confirm that the SW alignment agrees with our expectations
final ReadThreadingGraph.DanglingChainMergeHelper result = rtgraph.generateCigarAgainstDownwardsReferencePath(altSink, 0, 4);
if (result == null) {
Assert.assertFalse(cigarIsGood);
return;
}
Assert.assertTrue(cigar.equals(result.cigar.toString()), "SW generated cigar = " + result.cigar.toString());
// confirm that the goodness of the cigar agrees with our expectations
Assert.assertEquals(ReadThreadingGraph.cigarIsOkayToMerge(result.cigar, false, true), cigarIsGood);
// confirm that the tail merging works as expected
if (cigarIsGood) {
final int mergeResult = rtgraph.mergeDanglingTail(result);
Assert.assertTrue(mergeResult == 1 || mergePointDistanceFromSink == -1);
// confirm that we created the appropriate edge
if (mergePointDistanceFromSink >= 0) {
MultiDeBruijnVertex v = altSink;
for (int i = 0; i < mergePointDistanceFromSink; i++) {
if (rtgraph.inDegreeOf(v) != 1)
Assert.fail("Encountered vertex with multiple edges");
v = rtgraph.getEdgeSource(rtgraph.incomingEdgeOf(v));
}
Assert.assertTrue(rtgraph.outDegreeOf(v) > 1);
}
}
}
Aggregations