Search in sources :

Example 21 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class TargetUnitTest method testEquals.

@Test()
public void testEquals() {
    final Target subject1 = new Target("my-name");
    final Target subject1bis = new Target("my-name", new SimpleInterval("1", 1, 2));
    final Target subject1tris = new Target("my-name", new SimpleInterval("2", 1, 2));
    final Target subject2 = new Target("other-name");
    Assert.assertTrue(subject1.equals(subject1bis));
    Assert.assertTrue(subject1.equals(subject1tris));
    Assert.assertTrue(subject1bis.equals(subject1));
    Assert.assertTrue(subject1bis.equals(subject1tris));
    Assert.assertTrue(subject1tris.equals(subject1));
    Assert.assertTrue(subject1tris.equals(subject1bis));
    Assert.assertTrue(subject1.equals(subject1));
    Assert.assertTrue(subject1bis.equals(subject1bis));
    Assert.assertTrue(subject1tris.equals(subject1tris));
    Assert.assertTrue(subject2.equals(subject2));
    Assert.assertFalse(subject1.equals(null));
    Assert.assertFalse(subject1.equals(subject2));
    Assert.assertFalse(subject2.equals(subject1));
    Assert.assertFalse(subject1bis.equals(subject2));
    Assert.assertFalse(subject2.equals(subject1bis));
    Assert.assertFalse(subject1tris.equals(subject2));
    Assert.assertFalse(subject2.equals(subject1tris));
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Test(org.testng.annotations.Test)

Example 22 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class TargetUnitTest method testGetStartWithInterval.

@Test()
public void testGetStartWithInterval() {
    final Target subject = new Target("my-name", new SimpleInterval("1", 1, 2));
    Assert.assertEquals(subject.getStart(), 1);
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Test(org.testng.annotations.Test)

Example 23 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class TargetUnitTest method testGetContigWithInterval.

@Test()
public void testGetContigWithInterval() {
    final Target subject = new Target("my-name", new SimpleInterval("1", 1, 2));
    Assert.assertEquals(subject.getContig(), "1");
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Test(org.testng.annotations.Test)

Example 24 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval 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 25 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class VariantAnnotatorEngineUnitTest method testCoverageAnnotationOnDbSnpSite.

@Test
public void testCoverageAnnotationOnDbSnpSite() throws Exception {
    final List<String> annotationGroupsToUse = Collections.emptyList();
    //good one
    final List<String> annotationsToUse = Arrays.asList(Coverage.class.getSimpleName());
    final List<String> annotationsToExclude = Collections.emptyList();
    final String path = publicTestDir + "Homo_sapiens_assembly19.dbsnp135.chr1_1M.exome_intervals.vcf";
    final FeatureInput<VariantContext> dbSNPBinding = new FeatureInput<>(path, "dbsnp", Collections.emptyMap());
    final List<FeatureInput<VariantContext>> features = Collections.emptyList();
    final VariantAnnotatorEngine vae = VariantAnnotatorEngine.ofSelectedMinusExcluded(annotationGroupsToUse, annotationsToUse, annotationsToExclude, dbSNPBinding, features);
    final Set<VCFHeaderLine> vcfAnnotationDescriptions = vae.getVCFAnnotationDescriptions();
    Assert.assertTrue(vcfAnnotationDescriptions.contains(VCFStandardHeaderLines.getInfoLine(VCFConstants.DBSNP_KEY)));
    final int alt = 5;
    final int ref = 3;
    final SimpleInterval loc = new SimpleInterval("1", 69428, 69428);
    final VariantContext vcRS = new FeatureDataSource<VariantContext>(path, null, 0, VariantContext.class).query(loc).next();
    final Allele refAllele = vcRS.getReference();
    final Allele altAllele = vcRS.getAlternateAllele(0);
    final VariantContext vcToAnnotate = makeVC(refAllele, altAllele, loc);
    final ReadLikelihoods<Allele> likelihoods = makeReadLikelihoods(ref, alt, refAllele, altAllele, loc.getContig(), loc.getStart() - 5);
    final FeatureContext featureContext = when(mock(FeatureContext.class).getValues(dbSNPBinding, loc.getStart())).thenReturn(Arrays.<VariantContext>asList(vcRS)).getMock();
    final VariantContext resultVC = vae.annotateContext(vcToAnnotate, featureContext, null, likelihoods, a -> true);
    Assert.assertEquals(resultVC.getCommonInfo().getAttribute(VCFConstants.DEPTH_KEY), String.valueOf(ref + alt));
    Assert.assertEquals(resultVC.getID(), vcRS.getID());
}
Also used : FeatureContext(org.broadinstitute.hellbender.engine.FeatureContext) FeatureInput(org.broadinstitute.hellbender.engine.FeatureInput) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)545 Test (org.testng.annotations.Test)287 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)202 File (java.io.File)102 ArrayList (java.util.ArrayList)66 DataProvider (org.testng.annotations.DataProvider)64 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)60 Collectors (java.util.stream.Collectors)53 java.util (java.util)41 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)40 AllelicCount (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount)40 UserException (org.broadinstitute.hellbender.exceptions.UserException)39 VariantContext (htsjdk.variant.variantcontext.VariantContext)36 IntStream (java.util.stream.IntStream)34 Target (org.broadinstitute.hellbender.tools.exome.Target)34 IOException (java.io.IOException)32 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)28 Assert (org.testng.Assert)27 Locatable (htsjdk.samtools.util.Locatable)26 List (java.util.List)26