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);
}
}
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"));
}
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");
}
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");
}
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);
}
}
Aggregations