use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testToolHasDefaultRequiredArgsPositive.
@Test(dataProvider = "testDefaultFilters")
public void testToolHasDefaultRequiredArgsPositive(final String[] args) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadGroupReadFilter()))));
clp.parseArguments(nullMessageStream, args);
SAMFileHeader samHeader = createHeaderWithReadGroups();
ReadFilter rf = instantiateFilter(clp, samHeader);
final GATKRead read = simpleGoodRead(samHeader);
// make sure the test read actually has this read group
Assert.assertEquals(read.getReadGroup(), readgroupName);
Assert.assertTrue(rf.test(read));
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class BreakpointClustererUnitTest method simpleEvidence.
@DataProvider(name = "simpleEvidenceClusters")
public Object[][] simpleEvidence() {
final SAMFileHeader artificialSamHeader = ArtificialReadUtils.createArtificialSamHeaderWithGroups(2, 1, 1000000, 1);
final List<BreakpointEvidence> evidenceList = new ArrayList<>(5);
final ReadMetadata readMetadata = new ReadMetadata(new HashSet<Integer>(), artificialSamHeader, new ReadMetadata.ReadGroupFragmentStatistics(350, 40, 40), 1, 100, 10, 30);
final BreakpointEvidence splitEvidence1 = new BreakpointEvidence.SplitRead(ArtificialReadUtils.createArtificialRead(artificialSamHeader, "1", "1", 1000, ArtificialReadUtils.createRandomReadBases(151, false), ArtificialReadUtils.createRandomReadQuals(151), "100M50S"), readMetadata, false);
evidenceList.add(splitEvidence1);
final BreakpointEvidence splitEvidence2 = new BreakpointEvidence.SplitRead(ArtificialReadUtils.createArtificialRead(artificialSamHeader, "1", "1", 1010, ArtificialReadUtils.createRandomReadBases(151, false), ArtificialReadUtils.createRandomReadQuals(151), "90M60S"), readMetadata, false);
evidenceList.add(splitEvidence2);
final List<GATKRead> pair1 = ArtificialReadUtils.createPair(artificialSamHeader, "pair1", 151, 1250, 500000, true, false);
evidenceList.add(new BreakpointEvidence.WeirdTemplateSize(pair1.get(0), readMetadata));
final List<GATKRead> pair2 = ArtificialReadUtils.createPair(artificialSamHeader, "pair1", 151, 1255, 500000, true, false);
evidenceList.add(new BreakpointEvidence.WeirdTemplateSize(pair2.get(0), readMetadata));
final List<GATKRead> pair3 = ArtificialReadUtils.createPair(artificialSamHeader, "pair1", 151, 1350, 500000, true, false);
evidenceList.add(new BreakpointEvidence.WeirdTemplateSize(pair3.get(0), readMetadata));
return new Object[][] { { readMetadata, evidenceList } };
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class BreakpointEvidenceTest method restOfFragmentSizeTest.
@Test(groups = "spark")
void restOfFragmentSizeTest() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeaderWithGroups(1, 1, 10000000, 1);
final String groupName = header.getReadGroups().get(0).getReadGroupId();
final int readSize = 151;
final ReadMetadata.ReadGroupFragmentStatistics groupStats = new ReadMetadata.ReadGroupFragmentStatistics(401, 175, 20);
final ReadMetadata readMetadata = new ReadMetadata(Collections.emptySet(), header, groupStats, 1, 1L, 1L, 1);
final String templateName = "xyzzy";
final int readStart = 1010101;
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, templateName, 0, readStart, readSize);
read.setIsPaired(false);
read.setIsReverseStrand(true);
read.setReadGroup(groupName);
final BreakpointEvidence evidence1 = new BreakpointEvidence(read, readMetadata);
final int uncertainty = (readMetadata.getStatistics(groupName).getMedianFragmentSize() - readSize) / 2;
final int evidenceLocus = readStart - uncertainty;
final BreakpointEvidence evidence2 = new BreakpointEvidence(read, readMetadata, evidenceLocus, uncertainty);
Assert.assertEquals(evidence1.getLocation().getContig(), 0);
Assert.assertEquals(evidence1.getLocation().getStart(), evidenceLocus - uncertainty);
Assert.assertEquals(evidence1.getLocation().getEnd(), evidenceLocus + uncertainty);
Assert.assertEquals(evidence1.getLocation().getLength(), 2 * uncertainty);
Assert.assertEquals(evidence1.getTemplateName(), templateName);
Assert.assertEquals(evidence1.getTemplateEnd(), BreakpointEvidence.TemplateEnd.UNPAIRED);
Assert.assertEquals(evidence1.toString(), evidence2.toString());
read.setIsReverseStrand(false);
final BreakpointEvidence evidence3 = new BreakpointEvidence(read, readMetadata);
final BreakpointEvidence evidence4 = new BreakpointEvidence(read, readMetadata, readStart + readSize + uncertainty, uncertainty);
Assert.assertEquals(evidence3.toString(), evidence4.toString());
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class SATagBuilderUnitTests method testAddTag.
@Test
public void testAddTag() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
GATKRead read = ArtificialReadUtils.createArtificialRead("40M");
read.setAttribute("SA", "2,500,+,3S2=1X2=2S,60,1;");
SATagBuilder builder = new SATagBuilder(read);
GATKRead read1 = ArtificialReadUtils.createArtificialRead(header, "read1", 1, 10000, new byte[] {}, new byte[] {}, "4M");
read1.setIsSupplementaryAlignment(true);
GATKRead read2 = ArtificialReadUtils.createArtificialRead(header, "read2", 2, 10001, new byte[] {}, new byte[] {}, "4S");
read2.setIsSupplementaryAlignment(true);
SATagBuilder read2builder = new SATagBuilder(read2);
GATKRead read3 = ArtificialReadUtils.createArtificialRead(header, "read3", 3, 10003, new byte[] {}, new byte[] {}, "4D");
read3.setIsSupplementaryAlignment(false);
builder.addTag(read1).addTag(read3).addTag(read2builder).setSATag();
Assert.assertEquals(read.getAttributeAsString("SA"), "4,10003,+,4D,0,*;2,500,+,3S2=1X2=2S,60,1;2,10000,+,4M,0,*;3,10001,+,4S,0,*;");
}
use of htsjdk.samtools.SAMFileHeader in project gatk by broadinstitute.
the class SATagBuilderUnitTests method testGetArtificalReadsBasedOnSATag.
@Test
public void testGetArtificalReadsBasedOnSATag() {
// setup the record
final SAMFileHeader header = new SAMFileHeader();
header.addSequence(new SAMSequenceRecord("1", 1000));
header.addSequence(new SAMSequenceRecord("2", 1000));
GATKRead read = ArtificialReadUtils.createArtificialRead(header, "name", "2", 1, "AAAAAAAAAA".getBytes(), "##########".getBytes());
read.setIsFirstOfPair();
read.setCigar(TextCigarCodec.decode("10M"));
read.setMatePosition("2", 1);
//spec says first 'SA' record will be the primary record
read.setIsSupplementaryAlignment(true);
SATagBuilder builder = new SATagBuilder(read);
// check no alignments if no SA tag */
Assert.assertEquals(builder.getArtificialReadsBasedOnSATag(header).size(), 0);
// Tests that parsing existing tags works properly
read.setAttribute("SA", "2,500,+,3S2=1X2=2S,60,1;" + "1,191,-,8M2S,60,0;");
builder = new SATagBuilder(read);
List<GATKRead> suppl = builder.getArtificialReadsBasedOnSATag(header);
Assert.assertNotNull(suppl);
Assert.assertEquals(suppl.size(), 2);
for (final GATKRead other : suppl) {
Assert.assertFalse(other.isUnmapped());
Assert.assertTrue(other.isPaired());
Assert.assertFalse(other.mateIsUnmapped());
Assert.assertEquals(other.getMateContig(), read.getMateContig());
Assert.assertEquals(other.getName(), read.getName());
}
GATKRead other = suppl.get(0);
//1st of suppl and 'record' is supplementary
Assert.assertFalse(other.isSupplementaryAlignment());
Assert.assertEquals(other.getContig(), "2");
Assert.assertEquals(other.getStart(), 500);
Assert.assertEquals(other.getMappingQuality(), 60);
Assert.assertEquals((int) other.getAttributeAsInteger("NM"), 1);
Assert.assertEquals(other.getCigar().toString(), "3S2=1X2=2S");
other = suppl.get(1);
Assert.assertTrue(other.isSupplementaryAlignment());
Assert.assertEquals(other.getContig(), "1");
Assert.assertEquals(other.getStart(), 191);
Assert.assertTrue(other.isReverseStrand());
Assert.assertEquals(other.getMappingQuality(), 60);
Assert.assertEquals((int) other.getAttributeAsInteger("NM"), 0);
Assert.assertEquals(other.getCigar().toString(), "8M2S");
}
Aggregations