Search in sources :

Example 1 with ReferenceFileSource

use of org.broadinstitute.hellbender.engine.ReferenceFileSource in project gatk by broadinstitute.

the class AnnotateTargetsIntegrationTest method checkOutputFileContent.

private void checkOutputFileContent(final File outputFile, final boolean mustHaveGCContent, final boolean mustHaveRepeats) throws IOException {
    try (final TargetTableReader outputReader = new TargetTableReader(outputFile);
        final TargetTableReader inputReader = new TargetTableReader(TARGET_FILE);
        final ReferenceFileSource reference = new ReferenceFileSource(REFERENCE)) {
        final SAMSequenceDictionary dictionary = reference.getSequenceDictionary();
        Target outputTarget;
        Target inputTarget;
        do {
            outputTarget = outputReader.readRecord();
            inputTarget = inputReader.readRecord();
            if (outputTarget == inputTarget) {
                Assert.assertNull(outputTarget);
                break;
            }
            Assert.assertNotNull(outputTarget, "too few targets in output");
            Assert.assertNotNull(inputTarget, "too many targets in output");
            Assert.assertEquals(outputTarget.getName(), inputTarget.getName());
            Assert.assertEquals(outputTarget.getInterval(), inputTarget.getInterval());
            final TargetAnnotationCollection annotations = outputTarget.getAnnotations();
            if (mustHaveGCContent) {
                Assert.assertTrue(annotations.hasAnnotation(TargetAnnotation.GC_CONTENT));
                checkOutputGCContent(reference, outputTarget.getInterval(), annotations.getDouble(TargetAnnotation.GC_CONTENT));
            } else {
                Assert.assertFalse(annotations.hasAnnotation(TargetAnnotation.GC_CONTENT));
            }
        } while (true);
    }
}
Also used : SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) ReferenceFileSource(org.broadinstitute.hellbender.engine.ReferenceFileSource)

Example 2 with ReferenceFileSource

use of org.broadinstitute.hellbender.engine.ReferenceFileSource in project gatk by broadinstitute.

the class BAQUnitTest method testBAQOverwritesExistingTagWithNull.

@Test
public void testBAQOverwritesExistingTagWithNull() {
    final File referenceFile = new File(hg19_chr1_1M_Reference);
    final ReferenceDataSource rds = new ReferenceFileSource(referenceFile);
    // create a read with a single base off the end of the contig, which cannot be BAQed
    final GATKRead read = ArtificialReadUtils.createArtificialRead(createHeader(), "foo", 0, rds.getSequenceDictionary().getSequence("1").getSequenceLength() + 1, 1);
    read.setBases(new byte[] { (byte) 'A' });
    read.setBaseQualities(new byte[] { (byte) 20 });
    read.setCigar("1M");
    read.setAttribute("BQ", "A");
    // try to BAQ and tell it to RECALCULATE AND ADD_TAG
    final BAQ baq = new BAQ(1.0e-3, 0.1, 7, (byte) 4);
    baq.baqRead(read, rds, BAQ.CalculationMode.RECALCULATE, BAQ.QualityMode.ADD_TAG);
    // did we remove the existing tag?
    Assert.assertFalse(read.hasAttribute("BQ"));
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ReferenceDataSource(org.broadinstitute.hellbender.engine.ReferenceDataSource) File(java.io.File) ReferenceFileSource(org.broadinstitute.hellbender.engine.ReferenceFileSource) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 3 with ReferenceFileSource

use of org.broadinstitute.hellbender.engine.ReferenceFileSource in project gatk by broadinstitute.

the class ReferenceBasesUnitTest method test.

@Test
public void test() {
    final File refFasta = new File(b37_reference_20_21);
    final ReferenceDataSource refDataSource = new ReferenceFileSource(refFasta);
    final ReferenceContext ref = new ReferenceContext(refDataSource, new SimpleInterval("20", 10_000_000, 10_000_200));
    final VariantContext vc = new VariantContextBuilder("source", "20", 10_000_100, 10_000_100, Collections.singleton(Allele.create((byte) 'A', true))).make();
    final String refBases = (String) new ReferenceBases().annotate(ref, vc, null).get(ReferenceBases.REFERENCE_BASES_KEY);
    Assert.assertEquals(refBases, "ACTGCATCCCTTGCATTTCC");
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) ReferenceDataSource(org.broadinstitute.hellbender.engine.ReferenceDataSource) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) File(java.io.File) ReferenceFileSource(org.broadinstitute.hellbender.engine.ReferenceFileSource) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 4 with ReferenceFileSource

use of org.broadinstitute.hellbender.engine.ReferenceFileSource in project gatk-protected by broadinstitute.

the class ReferenceBasesUnitTest method test.

@Test
public void test() {
    final File refFasta = new File(b37_reference_20_21);
    final ReferenceDataSource refDataSource = new ReferenceFileSource(refFasta);
    final ReferenceContext ref = new ReferenceContext(refDataSource, new SimpleInterval("20", 10_000_000, 10_000_200));
    final VariantContext vc = new VariantContextBuilder("source", "20", 10_000_100, 10_000_100, Collections.singleton(Allele.create((byte) 'A', true))).make();
    final String refBases = (String) new ReferenceBases().annotate(ref, vc, null).get(ReferenceBases.REFERENCE_BASES_KEY);
    Assert.assertEquals(refBases, "ACTGCATCCCTTGCATTTCC");
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) ReferenceDataSource(org.broadinstitute.hellbender.engine.ReferenceDataSource) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) File(java.io.File) ReferenceFileSource(org.broadinstitute.hellbender.engine.ReferenceFileSource) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 5 with ReferenceFileSource

use of org.broadinstitute.hellbender.engine.ReferenceFileSource in project gatk-protected by broadinstitute.

the class AnnotateTargetsIntegrationTest method checkOutputFileContent.

private void checkOutputFileContent(final File outputFile, final boolean mustHaveGCContent, final boolean mustHaveRepeats) throws IOException {
    try (final TargetTableReader outputReader = new TargetTableReader(outputFile);
        final TargetTableReader inputReader = new TargetTableReader(TARGET_FILE);
        final ReferenceFileSource reference = new ReferenceFileSource(REFERENCE)) {
        final SAMSequenceDictionary dictionary = reference.getSequenceDictionary();
        Target outputTarget;
        Target inputTarget;
        do {
            outputTarget = outputReader.readRecord();
            inputTarget = inputReader.readRecord();
            if (outputTarget == inputTarget) {
                Assert.assertNull(outputTarget);
                break;
            }
            Assert.assertNotNull(outputTarget, "too few targets in output");
            Assert.assertNotNull(inputTarget, "too many targets in output");
            Assert.assertEquals(outputTarget.getName(), inputTarget.getName());
            Assert.assertEquals(outputTarget.getInterval(), inputTarget.getInterval());
            final TargetAnnotationCollection annotations = outputTarget.getAnnotations();
            if (mustHaveGCContent) {
                Assert.assertTrue(annotations.hasAnnotation(TargetAnnotation.GC_CONTENT));
                checkOutputGCContent(reference, outputTarget.getInterval(), annotations.getDouble(TargetAnnotation.GC_CONTENT));
            } else {
                Assert.assertFalse(annotations.hasAnnotation(TargetAnnotation.GC_CONTENT));
            }
        } while (true);
    }
}
Also used : SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) ReferenceFileSource(org.broadinstitute.hellbender.engine.ReferenceFileSource)

Aggregations

ReferenceFileSource (org.broadinstitute.hellbender.engine.ReferenceFileSource)5 File (java.io.File)3 ReferenceDataSource (org.broadinstitute.hellbender.engine.ReferenceDataSource)3 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)3 Test (org.testng.annotations.Test)3 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)2 ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)2 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)2 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)1