### Question:
AlleleMatcher { public Collection<GenotypeMatch> matchGenotypes(VariantContext obsVC, VariantContext dbVC) { List<GenotypeMatch> result = new ArrayList<>(); Collection<VariantDescription> obsVars = ctxToVariants(obsVC); Collection<VariantDescription> dbVars = ctxToVariants(dbVC); int i = 1; for (VariantDescription obsVar : obsVars) { int j = 1; for (VariantDescription dbVar : dbVars) { if (dbVar.equals(obsVar)) result.add(new GenotypeMatch(i, j, obsVC, dbVC, true)); j += 1; } i += 1; } return result; } AlleleMatcher(String pathFasta); Collection<GenotypeMatch> matchGenotypes(VariantContext obsVC, VariantContext dbVC); Collection<GenotypeMatch> positionOverlaps(VariantContext obsVC, VariantContext dbVC);  }### Answer:
@Test public void testMatchSingle() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcSingle, vcSingle); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcSingle, first.getObsVC()); Assert.assertSame(vcSingle, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); }
@Test public void testMatchSingleToMultiple() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcSingle, vcMultiple); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcSingle, first.getObsVC()); Assert.assertSame(vcMultiple, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(2, first.getDbAllele()); }
@Test public void testMatchMultipleToSingle() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcMultiple, vcSingle); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcMultiple, first.getObsVC()); Assert.assertSame(vcSingle, first.getDBVC()); Assert.assertEquals(2, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); }
@Test public void testMatchMultipleToMultiple() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcMultiple, vcMultiple); assertEquals(2, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcMultiple, first.getObsVC()); Assert.assertSame(vcMultiple, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); GenotypeMatch second = (GenotypeMatch) matches.toArray()[1]; Assert.assertSame(vcMultiple, second.getObsVC()); Assert.assertSame(vcMultiple, second.getDBVC()); Assert.assertEquals(2, second.getObservedAllele()); Assert.assertEquals(2, second.getDbAllele()); }