VariantEffectCounter { public List<VariantEffectCount> getVariantEffectCounts(Set<VariantEffect> variantEffects) { return variantEffectCounts.stream() .filter(variantEffectCount -> variantEffects.contains(variantEffectCount.getVariantType())) .collect(toList()); } VariantEffectCounter(List<String> sampleNames, List<VariantEvaluation> variantEvaluations); List<VariantEffectCount> getVariantEffectCounts(Set<VariantEffect> variantEffects);  }
@Test void singleSampleNoVariantSingleType() { VariantEffectCounter instance = new VariantEffectCounter(ImmutableList.of("Arthur"), ImmutableList.of()); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT)); System.out.println(result); assertThat(result, equalTo(ImmutableList.of(new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList .of(0))))); }
@Test void multiSampleNoVariantSingleType() { VariantEffectCounter instance = new VariantEffectCounter(ImmutableList.of("Arthur", "Ford"), ImmutableList.of()); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT)); System.out.println(result); assertThat(result, equalTo(ImmutableList.of(new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList .of(0,0))))); }
@Test void singleSampleSingleVariantSingleType() { VariantEvaluation missense = VariantEvaluation.builder(1, 12345, "A", "T") .variantEffect(VariantEffect.MISSENSE_VARIANT) .sampleGenotypes(ImmutableMap.of("Arthur", SampleGenotype.het())) .build(); VariantEffectCounter instance = new VariantEffectCounter(ImmutableList.of("Arthur"), ImmutableList.of(missense)); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT)); System.out.println(result); assertThat(result, equalTo(ImmutableList.of(new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList .of(1))))); }
@Test void multiSampleSingleVariantSingleType() { ImmutableMap<String, SampleGenotype> sampleGenotypes = ImmutableMap.of( "Arthur", SampleGenotype.het(), "Zaphod", SampleGenotype.homRef(), "Trillian", SampleGenotype.homAlt() ); VariantEvaluation missense = VariantEvaluation.builder(1, 12345, "A", "T") .variantEffect(VariantEffect.MISSENSE_VARIANT) .sampleGenotypes(sampleGenotypes) .build(); VariantEffectCounter instance = new VariantEffectCounter(sampleGenotypes.keySet() .asList(), ImmutableList.of(missense)); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT)); System.out.println(result); assertThat(result, equalTo(ImmutableList.of(new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList .of(1, 0, 1))))); }
@Test void multiSampleMultiVariantSingleType() { ImmutableMap<String, SampleGenotype> missenseOneSampleGenotypes = ImmutableMap.of( "Arthur", SampleGenotype.het(), "Zaphod", SampleGenotype.homRef(), "Trillian", SampleGenotype.homAlt() ); VariantEvaluation missenseOne = VariantEvaluation.builder(1, 12345, "A", "T") .variantEffect(VariantEffect.MISSENSE_VARIANT) .sampleGenotypes(missenseOneSampleGenotypes) .build(); ImmutableMap<String, SampleGenotype> missenseTwoSampleGenotypes = ImmutableMap.of( "Arthur", SampleGenotype.het(), "Zaphod", SampleGenotype.het(), "Trillian", SampleGenotype.homRef() ); VariantEvaluation missenseTwo = VariantEvaluation.builder(2, 54321, "C", "G") .variantEffect(VariantEffect.MISSENSE_VARIANT) .sampleGenotypes(missenseTwoSampleGenotypes) .build(); VariantEffectCounter instance = new VariantEffectCounter(missenseOneSampleGenotypes.keySet() .asList(), ImmutableList.of(missenseOne, missenseTwo)); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT)); System.out.println(result); assertThat(result, equalTo(ImmutableList.of(new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList .of(2, 1, 1))))); }
@Test void multiSampleMultiVariantMultiType() { ImmutableMap<String, SampleGenotype> missenseOneSampleGenotypes = ImmutableMap.of( "Arthur", SampleGenotype.het(), "Zaphod", SampleGenotype.homRef(), "Trillian", SampleGenotype.homAlt() ); VariantEvaluation missenseOne = VariantEvaluation.builder(1, 12345, "A", "T") .variantEffect(VariantEffect.MISSENSE_VARIANT) .sampleGenotypes(missenseOneSampleGenotypes) .build(); ImmutableMap<String, SampleGenotype> stopGainedSampleGenotypes = ImmutableMap.of( "Arthur", SampleGenotype.het(), "Zaphod", SampleGenotype.het(), "Trillian", SampleGenotype.homRef() ); VariantEvaluation stopGained = VariantEvaluation.builder(2, 54321, "C", "G") .variantEffect(VariantEffect.STOP_GAINED) .sampleGenotypes(stopGainedSampleGenotypes) .build(); VariantEffectCounter instance = new VariantEffectCounter(missenseOneSampleGenotypes.keySet() .asList(), ImmutableList.of(missenseOne, stopGained)); List<VariantEffectCount> result = instance.getVariantEffectCounts(EnumSet.of(VariantEffect.MISSENSE_VARIANT, VariantEffect.STOP_GAINED)); System.out.println(result); ImmutableList<VariantEffectCount> expected = ImmutableList.of( new VariantEffectCount(VariantEffect.STOP_GAINED, ImmutableList.of(1, 1, 0)), new VariantEffectCount(VariantEffect.MISSENSE_VARIANT, ImmutableList.of(1, 0, 1)) ); assertThat(result, equalTo(expected)); }