/**
   * Assert that two variant contexts are actually equal
   *
   * @param actual
   * @param expected
   */
  public static void assertEquals(final VariantContext actual, final VariantContext expected) {
    Assert.assertNotNull(actual, "VariantContext expected not null");
    Assert.assertEquals(actual.getChr(), expected.getChr(), "chr");
    Assert.assertEquals(actual.getStart(), expected.getStart(), "start");
    Assert.assertEquals(actual.getEnd(), expected.getEnd(), "end");
    Assert.assertEquals(actual.getID(), expected.getID(), "id");
    Assert.assertEquals(
        actual.getAlleles(), expected.getAlleles(), "alleles for " + expected + " vs " + actual);

    assertAttributesEquals(actual.getAttributes(), expected.getAttributes());
    Assert.assertEquals(
        actual.filtersWereApplied(), expected.filtersWereApplied(), "filtersWereApplied");
    Assert.assertEquals(actual.isFiltered(), expected.isFiltered(), "isFiltered");
    VariantBaseTest.assertEqualsSet(actual.getFilters(), expected.getFilters(), "filters");
    VariantBaseTest.assertEqualsDoubleSmart(
        actual.getPhredScaledQual(), expected.getPhredScaledQual());

    Assert.assertEquals(actual.hasGenotypes(), expected.hasGenotypes(), "hasGenotypes");
    if (expected.hasGenotypes()) {
      VariantBaseTest.assertEqualsSet(
          actual.getSampleNames(), expected.getSampleNames(), "sample names set");
      Assert.assertEquals(
          actual.getSampleNamesOrderedByName(),
          expected.getSampleNamesOrderedByName(),
          "sample names");
      final Set<String> samples = expected.getSampleNames();
      for (final String sample : samples) {
        assertEquals(actual.getGenotype(sample), expected.getGenotype(sample));
      }
    }
  }
Esempio n. 2
0
  private VariantContext getDbsnp(String rsID) {
    if (dbsnpIterator == null) {

      if (dbsnp == null)
        throw new UserException.BadInput(
            "No dbSNP rod was provided, but one is needed to decipher the correct indel alleles from the HapMap records");

      RMDTrackBuilder builder =
          new RMDTrackBuilder(
              getToolkit().getReferenceDataSource().getReference().getSequenceDictionary(),
              getToolkit().getGenomeLocParser(),
              getToolkit().getArguments().unsafe,
              getToolkit().getArguments().disableAutoIndexCreationAndLockingWhenReadingRods,
              null);
      dbsnpIterator =
          builder
              .createInstanceOfTrack(VCFCodec.class, new File(dbsnp.dbsnp.getSource()))
              .getIterator();
      // Note that we should really use some sort of seekable iterator here so that the search
      // doesn't take forever
      // (but it's complicated because the hapmap location doesn't match the dbsnp location, so we
      // don't know where to seek to)
    }

    while (dbsnpIterator.hasNext()) {
      GATKFeature feature = dbsnpIterator.next();
      VariantContext vc = (VariantContext) feature.getUnderlyingObject();
      if (vc.getID().equals(rsID)) return vc;
    }

    return null;
  }