use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class SATagBuilderUnitTests method testSetReadsAsSupplementalNo.
@Test
public static void testSetReadsAsSupplementalNo() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
GATKRead primarySup = ArtificialReadUtils.createArtificialRead(header, "read1", 1, 10000, new byte[] {}, new byte[] {}, "4M");
primarySup.setMappingQuality(100);
primarySup.setAttribute("NM", 20);
primarySup.setIsReverseStrand(true);
GATKRead secondarySup = ArtificialReadUtils.createArtificialRead(header, "read1", 2, 10001, new byte[] {}, new byte[] {}, "4S");
secondarySup.setMappingQuality(200);
List<GATKRead> sups = new ArrayList<>();
sups.add(secondarySup);
SATagBuilder.setReadsAsSupplemental(primarySup, sups);
Assert.assertEquals(primarySup.getAttributeAsString("SA"), "3,10001,+,4S,200,*;");
Assert.assertEquals(primarySup.isSupplementaryAlignment(), false);
Assert.assertEquals(secondarySup.getAttributeAsString("SA"), "2,10000,-,4M,100,20;");
Assert.assertEquals(secondarySup.isSupplementaryAlignment(), true);
GATKRead tertiarySup = ArtificialReadUtils.createArtificialRead(header, "read1", 3, 10003, new byte[] {}, new byte[] {}, "4D");
tertiarySup.setMappingQuality(200);
primarySup.clearAttribute("SA");
secondarySup.clearAttribute("SA");
sups.add(tertiarySup);
SATagBuilder.setReadsAsSupplemental(primarySup, sups);
Assert.assertEquals(sups.size(), 2);
Assert.assertEquals(sups.get(0).getAttributeAsString("SA"), "2,10000,-,4M,100,20;4,10003,+,4D,200,*;");
Assert.assertTrue(sups.get(1).getAttributeAsString("SA").startsWith("2,10000,-,4M,100,20;"));
Assert.assertTrue(primarySup.getAttributeAsString("SA").contains("4,10003,+,4D,200,*;"));
Assert.assertTrue(primarySup.getAttributeAsString("SA").contains("3,10001,+,4S,200,*;"));
GATKRead unmappedSup = ArtificialReadUtils.createArtificialUnmappedRead(header, new byte[] {}, new byte[] {});
primarySup.clearAttribute("SA");
sups.clear();
sups.add(unmappedSup);
SATagBuilder.setReadsAsSupplemental(primarySup, sups);
Assert.assertEquals(primarySup.getAttributeAsString("SA"), "*,0,+,*,0,*;");
Assert.assertEquals(sups.get(0).getAttributeAsString("SA"), "2,10000,-,4M,100,20;");
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class SATagBuilderUnitTests method testRemoveTagFunctionality.
@Test
public static void testRemoveTagFunctionality() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
GATKRead testRead = ArtificialReadUtils.createArtificialRead(header, "read1", 1, 10002, new byte[] {}, new byte[] {}, "4M");
final String attributeVal = "2,10000,+,4M,100,20;4,10003,+,4D,200,0;2,10000,-,4M,100,20;";
testRead.setAttribute("SA", attributeVal);
SATagBuilder builder = new SATagBuilder(testRead);
// Testing that unrelated reads are not removed from the list
GATKRead unRelatedRead = ArtificialReadUtils.createArtificialRead(header, "read3", 3, 1000, new byte[] {}, new byte[] {}, "4D");
builder.removeTag(unRelatedRead).setSATag();
Assert.assertEquals(testRead.getAttributeAsString("SA"), attributeVal);
// Testing that ALL instances of a particular tag get removed
GATKRead relatedRead = ArtificialReadUtils.createArtificialRead(header, "read1", 1, 10000, new byte[] {}, new byte[] {}, "4M");
builder.removeTag(relatedRead).setSATag();
Assert.assertEquals(testRead.getAttributeAsString("SA"), "4,10003,+,4D,200,0;");
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class NGSPlatformUnitTest method testReadWithoutRG.
@Test
public void testReadWithoutRG() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "myRead", 0, 1, 10);
Assert.assertEquals(NGSPlatform.fromRead(read, header), NGSPlatform.UNKNOWN);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class NGSPlatformUnitTest method testPLFromReadWithRGButNoPL.
@Test()
public void testPLFromReadWithRGButNoPL() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final String rgID = "ID";
final SAMReadGroupRecord rg = new SAMReadGroupRecord(rgID);
header.addReadGroup(rg);
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "myRead", 0, 1, 10);
read.setAttribute("RG", rgID);
Assert.assertEquals(NGSPlatform.fromRead(read, header), NGSPlatform.UNKNOWN);
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class IntervalUtilsUnitTest method testIntervalFileToListNegativeOneLength.
// TODO - remove once a corrected version of the exome interval list is released.
@Test(dataProvider = "negativeOneLengthIntervalTestData")
public void testIntervalFileToListNegativeOneLength(GenomeLocParser genomeLocParser, String contig, int intervalStart, int intervalEnd) throws Exception {
final SAMFileHeader picardFileHeader = new SAMFileHeader();
picardFileHeader.addSequence(genomeLocParser.getContigInfo("1"));
final IntervalList picardIntervals = new IntervalList(picardFileHeader);
// Need one good interval or else a UserException.MalformedFile( is thrown if no intervals
picardIntervals.add(new Interval(contig, 1, 2, true, "dummyname0"));
picardIntervals.add(new Interval(contig, intervalStart, intervalEnd, true, "dummyname1"));
final File picardIntervalFile = createTempFile("testIntervalFileToListNegativeOneLength", ".intervals");
picardIntervals.write(picardIntervalFile);
IntervalUtils.intervalFileToList(genomeLocParser, picardIntervalFile.getAbsolutePath());
}
Aggregations