Search in sources :

Example 81 with SAMFileHeader

use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.

the class BaseQualitySumPerAlleleBySampleUnitTest method testUsableRead.

@Test
public void testUsableRead() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(5, 1, 10000);
    final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "myRead", 0, 1, 76);
    read.setMappingQuality(60);
    Assert.assertTrue(BaseQualitySumPerAlleleBySample.isUsableRead(read));
    read.setMappingQuality(0);
    Assert.assertFalse(BaseQualitySumPerAlleleBySample.isUsableRead(read));
    read.setMappingQuality(QualityUtils.MAPPING_QUALITY_UNAVAILABLE);
    Assert.assertFalse(BaseQualitySumPerAlleleBySample.isUsableRead(read));
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Test(org.testng.annotations.Test)

Example 82 with SAMFileHeader

use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.

the class ReadUtilsUnitTest method readsWithReadGroupData.

@DataProvider(name = "ReadsWithReadGroupData")
public Object[][] readsWithReadGroupData() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(2, 1, 1000000);
    final SAMReadGroupRecord readGroup = new SAMReadGroupRecord("FOO");
    readGroup.setPlatform("FOOPLATFORM");
    readGroup.setPlatformUnit("FOOPLATFORMUNIT");
    readGroup.setLibrary("FOOLIBRARY");
    readGroup.setSample("FOOSAMPLE");
    header.addReadGroup(readGroup);
    final GATKRead googleBackedRead = new GoogleGenomicsReadToGATKReadAdapter(ArtificialReadUtils.createArtificialGoogleGenomicsRead("google", "1", 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    googleBackedRead.setReadGroup("FOO");
    final GATKRead samBackedRead = new SAMRecordToGATKReadAdapter(ArtificialReadUtils.createArtificialSAMRecord(header, "sam", header.getSequenceIndex("1"), 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    samBackedRead.setReadGroup("FOO");
    return new Object[][] { { googleBackedRead, header, "FOO" }, { samBackedRead, header, "FOO" } };
}
Also used : SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) SAMFileHeader(htsjdk.samtools.SAMFileHeader) DataProvider(org.testng.annotations.DataProvider)

Example 83 with SAMFileHeader

use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.

the class ReadUtilsUnitTest method testReadWithNsRefIndexInDeletion.

@Test
public void testReadWithNsRefIndexInDeletion() throws FileNotFoundException {
    final IndexedFastaSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(exampleReference));
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(seq.getSequenceDictionary());
    final int readLength = 76;
    final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "myRead", 0, 8975, readLength);
    read.setBases(Utils.dupBytes((byte) 'A', readLength));
    read.setBaseQualities(Utils.dupBytes((byte) 30, readLength));
    read.setCigar("3M414N1D73M");
    final int result = ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, 9392, ReadUtils.ClippingTail.LEFT_TAIL);
    Assert.assertEquals(result, 2);
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) SAMFileHeader(htsjdk.samtools.SAMFileHeader) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 84 with SAMFileHeader

use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.

the class ReadUtilsUnitTest method testGetSamplesFromHeaderNoReadGroups.

@Test
public void testGetSamplesFromHeaderNoReadGroups() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(5, 1, 100);
    Assert.assertTrue(header.getReadGroups().isEmpty());
    Assert.assertTrue(ReadUtils.getSamplesFromHeader(header).isEmpty(), "Non-empty Set returned from ReadUtils.getSamplesFromHeader() for a header with no read groups");
}
Also used : SAMFileHeader(htsjdk.samtools.SAMFileHeader) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 85 with SAMFileHeader

use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.

the class ReadUtilsUnitTest method referenceIndexTestData.

@DataProvider(name = "ReferenceIndexTestData")
public Object[][] referenceIndexTestData() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(2, 1, 1000000);
    final GATKRead googleBackedRead = new GoogleGenomicsReadToGATKReadAdapter(ArtificialReadUtils.createArtificialGoogleGenomicsRead("google", "2", 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    googleBackedRead.setMatePosition("1", 1);
    final GATKRead samBackedRead = new SAMRecordToGATKReadAdapter(ArtificialReadUtils.createArtificialSAMRecord(header, "sam", header.getSequenceIndex("2"), 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    samBackedRead.setMatePosition("1", 5);
    final GATKRead unmappedGoogleBackedRead = new GoogleGenomicsReadToGATKReadAdapter(ArtificialReadUtils.createArtificialGoogleGenomicsRead("google", "1", 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    unmappedGoogleBackedRead.setIsUnmapped();
    unmappedGoogleBackedRead.setMateIsUnmapped();
    final GATKRead unmappedSamBackedRead = new SAMRecordToGATKReadAdapter(ArtificialReadUtils.createArtificialSAMRecord(header, "sam", header.getSequenceIndex("1"), 5, new byte[] { 'A', 'C', 'G', 'T' }, new byte[] { 1, 2, 3, 4 }, "4M"));
    unmappedSamBackedRead.setIsUnmapped();
    unmappedSamBackedRead.setMateIsUnmapped();
    return new Object[][] { { googleBackedRead, header, 1, 0 }, { samBackedRead, header, 1, 0 }, { unmappedGoogleBackedRead, header, -1, -1 }, { unmappedSamBackedRead, header, -1, -1 } };
}
Also used : SAMFileHeader(htsjdk.samtools.SAMFileHeader) DataProvider(org.testng.annotations.DataProvider)

Aggregations

SAMFileHeader (htsjdk.samtools.SAMFileHeader)148 Test (org.testng.annotations.Test)89 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)85 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)71 File (java.io.File)23 SAMReadGroupRecord (htsjdk.samtools.SAMReadGroupRecord)22 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)17 DataProvider (org.testng.annotations.DataProvider)17 java.util (java.util)15 UserException (org.broadinstitute.hellbender.exceptions.UserException)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 Collectors (java.util.stream.Collectors)12 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)12 SAMRecord (htsjdk.samtools.SAMRecord)11 Locatable (htsjdk.samtools.util.Locatable)11 BeforeClass (org.testng.annotations.BeforeClass)11 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)10 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)10 ReadPileup (org.broadinstitute.hellbender.utils.pileup.ReadPileup)10