use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class GATKProtectedVariantContextUtilsUnitTest method testGetPileup.
@Test
public void testGetPileup() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
final Locatable loc = new SimpleInterval("chr1", 10, 10);
final int readLength = 3;
//this read doesn't overlap {@code loc}
final GATKRead read1 = ArtificialReadUtils.createArtificialRead(header, "read1", 0, 1, readLength);
read1.setBases(Utils.dupBytes((byte) 'A', readLength));
read1.setBaseQualities(Utils.dupBytes((byte) 30, readLength));
read1.setCigar("3M");
//this read overlaps {@code loc} with a Q30 'A'
final GATKRead read2 = ArtificialReadUtils.createArtificialRead(header, "read2", 0, 10, readLength);
read2.setBases(Utils.dupBytes((byte) 'A', readLength));
read2.setBaseQualities(Utils.dupBytes((byte) 30, readLength));
read2.setCigar("3M");
//this read overlaps {@code loc} with a Q20 'C' (due to the deletion)
final GATKRead read3 = ArtificialReadUtils.createArtificialRead(header, "read3", 0, 7, readLength);
read3.setBases(Utils.dupBytes((byte) 'C', readLength));
read3.setBaseQualities(Utils.dupBytes((byte) 20, readLength));
read3.setCigar("1M1D2M");
//this read doesn't overlap {@code loc} due to the deletion
final GATKRead read4 = ArtificialReadUtils.createArtificialRead(header, "read4", 0, 7, readLength);
read4.setBases(Utils.dupBytes((byte) 'C', readLength));
read4.setBaseQualities(Utils.dupBytes((byte) 20, readLength));
read4.setCigar("1M5D2M");
final ReadPileup pileup = GATKProtectedVariantContextUtils.getPileup(loc, Arrays.asList(read1, read2, read3, read4));
// the pileup should contain a Q30 'A' and a Q20 'C'
final int[] counts = pileup.getBaseCounts();
Assert.assertEquals(counts, new int[] { 1, 1, 0, 0 });
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class GenomeLocParserUnitTest method getFlankingGenomeLocs.
@DataProvider(name = "flankingGenomeLocs")
public Object[][] getFlankingGenomeLocs() {
int contigLength = 10000;
SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, contigLength);
GenomeLocParser parser = new GenomeLocParser(header.getSequenceDictionary());
new FlankingGenomeLocTestData("atStartBase1", parser, 1, "1:1", null, "1:2");
new FlankingGenomeLocTestData("atStartBase50", parser, 50, "1:1", null, "1:2-51");
new FlankingGenomeLocTestData("atStartRange50", parser, 50, "1:1-10", null, "1:11-60");
new FlankingGenomeLocTestData("atEndBase1", parser, 1, "1:" + contigLength, "1:" + (contigLength - 1), null);
new FlankingGenomeLocTestData("atEndBase50", parser, 50, "1:" + contigLength, String.format("1:%d-%d", contigLength - 50, contigLength - 1), null);
new FlankingGenomeLocTestData("atEndRange50", parser, 50, String.format("1:%d-%d", contigLength - 10, contigLength), String.format("1:%d-%d", contigLength - 60, contigLength - 11), null);
new FlankingGenomeLocTestData("nearStartBase1", parser, 1, "1:2", "1:1", "1:3");
new FlankingGenomeLocTestData("nearStartRange50", parser, 50, "1:21-30", "1:1-20", "1:31-80");
new FlankingGenomeLocTestData("nearEndBase1", parser, 1, "1:" + (contigLength - 1), "1:" + (contigLength - 2), "1:" + contigLength);
new FlankingGenomeLocTestData("nearEndRange50", parser, 50, String.format("1:%d-%d", contigLength - 30, contigLength - 21), String.format("1:%d-%d", contigLength - 80, contigLength - 31), String.format("1:%d-%d", contigLength - 20, contigLength));
new FlankingGenomeLocTestData("beyondStartBase1", parser, 1, "1:3", "1:2", "1:4");
new FlankingGenomeLocTestData("beyondStartRange50", parser, 50, "1:101-200", "1:51-100", "1:201-250");
new FlankingGenomeLocTestData("beyondEndBase1", parser, 1, "1:" + (contigLength - 3), "1:" + (contigLength - 4), "1:" + (contigLength - 2));
new FlankingGenomeLocTestData("beyondEndRange50", parser, 50, String.format("1:%d-%d", contigLength - 200, contigLength - 101), String.format("1:%d-%d", contigLength - 250, contigLength - 201), String.format("1:%d-%d", contigLength - 100, contigLength - 51));
new FlankingGenomeLocTestData("unmapped", parser, 50, "unmapped", null, null);
new FlankingGenomeLocTestData("fullContig", parser, 50, "1", null, null);
return FlankingGenomeLocTestData.getTests(FlankingGenomeLocTestData.class);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class GenomeLocParserUnitTest method testContigHasColon.
@Test
public void testContigHasColon() {
SAMFileHeader header = new SAMFileHeader();
header.setSortOrder(htsjdk.samtools.SAMFileHeader.SortOrder.coordinate);
SAMSequenceDictionary dict = new SAMSequenceDictionary();
SAMSequenceRecord rec = new SAMSequenceRecord("c:h:r1", 10);
rec.setSequenceLength(10);
dict.addSequence(rec);
header.setSequenceDictionary(dict);
final GenomeLocParser myGenomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
GenomeLoc loc = myGenomeLocParser.parseGenomeLoc("c:h:r1:4-5");
assertEquals(0, loc.getContigIndex());
assertEquals(loc.getStart(), 4);
assertEquals(loc.getStop(), 5);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class GenomeLocParserUnitTest method testParsingPositions.
@Test(dataProvider = "parseGenomeLoc")
public void testParsingPositions(final String string, final String contig, final int start) {
SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 10000000);
GenomeLocParser genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
final GenomeLoc loc = genomeLocParser.parseGenomeLoc(string);
Assert.assertEquals(loc.getContig(), contig);
Assert.assertEquals(loc.getStart(), start);
Assert.assertEquals(loc.getStop(), start);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReadPileupUnitTest method testNullConstructorParametersReads.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullConstructorParametersReads() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
ArtificialReadUtils.createArtificialRead(header, "read1", 0, 1, 10);
new ReadPileup(loc, null, Arrays.asList(1));
}
Aggregations