Search in sources :

Example 41 with SAMReadGroupRecord

use of htsjdk.samtools.SAMReadGroupRecord 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 42 with SAMReadGroupRecord

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

the class ReadUtilsUnitTest method testReadGroupOperations.

@Test(dataProvider = "ReadsWithReadGroupData")
public void testReadGroupOperations(final GATKRead read, final SAMFileHeader header, final String expectedReadGroupID) {
    final SAMReadGroupRecord readGroup = ReadUtils.getSAMReadGroupRecord(read, header);
    Assert.assertEquals(readGroup.getId(), expectedReadGroupID, "Wrong read group returned from ReadUtils.getSAMReadGroupRecord()");
    Assert.assertEquals(ReadUtils.getPlatform(read, header), readGroup.getPlatform(), "Wrong platform returned from ReadUtils.getPlatform()");
    Assert.assertEquals(ReadUtils.getPlatformUnit(read, header), readGroup.getPlatformUnit(), "Wrong platform unit returned from ReadUtils.getPlatformUnit()");
    Assert.assertEquals(ReadUtils.getLibrary(read, header), readGroup.getLibrary(), "Wrong library returned from ReadUtils.getLibrary()");
    Assert.assertEquals(ReadUtils.getSampleName(read, header), readGroup.getSample(), "Wrong sample name returned from ReadUtils.getSampleName()");
}
Also used : SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 43 with SAMReadGroupRecord

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

the class ReadUtilsUnitTest method testGetSamplesFromHeaderNoSamples.

@Test
public void testGetSamplesFromHeaderNoSamples() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(5, 1, 100);
    header.setReadGroups(Arrays.asList(new SAMReadGroupRecord("ReadGroup1")));
    Assert.assertEquals(header.getReadGroups().size(), 1);
    Assert.assertNull(header.getReadGroups().get(0).getSample());
    Assert.assertTrue(ReadUtils.getSamplesFromHeader(header).isEmpty(), "Non-empty Set returned from ReadUtils.getSamplesFromHeader() for a header with no samples");
}
Also used : SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) SAMFileHeader(htsjdk.samtools.SAMFileHeader) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 44 with SAMReadGroupRecord

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

the class ReadUtilsUnitTest method testGetSamplesFromHeader.

@Test
public void testGetSamplesFromHeader() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(5, 1, 100);
    final List<SAMReadGroupRecord> readGroups = new ArrayList<>();
    for (int i = 1; i <= 5; ++i) {
        SAMReadGroupRecord readGroup = new SAMReadGroupRecord("ReadGroup" + i);
        readGroup.setSample("Sample" + i);
        readGroups.add(readGroup);
    }
    header.setReadGroups(readGroups);
    final Set<String> samples = ReadUtils.getSamplesFromHeader(header);
    Assert.assertEquals(samples.size(), 5, "Wrong number of samples returned from ReadUtils.getSamplesFromHeader()");
    for (int i = 1; i <= 5; ++i) {
        Assert.assertTrue(samples.contains("Sample" + i), "Missing Sample" + i + " in samples returned from ReadUtils.getSamplesFromHeader()");
    }
}
Also used : SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) SAMFileHeader(htsjdk.samtools.SAMFileHeader) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 45 with SAMReadGroupRecord

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

the class CycleCovariateUnitTest method init.

@BeforeClass
public void init() {
    RAC = new RecalibrationArgumentCollection();
    covariate = new CycleCovariate(RAC);
    illuminaReadGroup = new SAMReadGroupRecord("MY.ID");
    illuminaReadGroup.setPlatform("illumina");
}
Also used : RecalibrationArgumentCollection(org.broadinstitute.hellbender.utils.recalibration.RecalibrationArgumentCollection) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

SAMReadGroupRecord (htsjdk.samtools.SAMReadGroupRecord)81 SAMFileHeader (htsjdk.samtools.SAMFileHeader)48 SAMRecord (htsjdk.samtools.SAMRecord)33 Test (org.testng.annotations.Test)31 SamReader (htsjdk.samtools.SamReader)29 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)26 File (java.io.File)23 ArrayList (java.util.ArrayList)22 SAMRecordIterator (htsjdk.samtools.SAMRecordIterator)20 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)20 HashMap (java.util.HashMap)18 CigarElement (htsjdk.samtools.CigarElement)17 Cigar (htsjdk.samtools.Cigar)16 HashSet (java.util.HashSet)16 SAMFileWriter (htsjdk.samtools.SAMFileWriter)15 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)15 CigarOperator (htsjdk.samtools.CigarOperator)14 IOException (java.io.IOException)14 SAMSequenceDictionaryProgress (com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress)13 List (java.util.List)12