diff --git a/exomiser-core/CHANGELOG.md b/exomiser-core/CHANGELOG.md index a7378a9bd..8539843bf 100644 --- a/exomiser-core/CHANGELOG.md +++ b/exomiser-core/CHANGELOG.md @@ -2,11 +2,31 @@ ## 14.0.0 2023-MM-dd +This release **requires data version >= 2210** and **Java version >= 17** (the most recent LTS release). + +- Added new GeneBlacklistFilter [#457](https://github.com/exomiser/Exomiser/issues/457) - Enabled independent update of ClinVar data [#501](https://github.com/exomiser/Exomiser/issues/501) - Added new `ClinVarDao` and `ClinVarWhiteListReader` to take advantage of the independently upgradeable ClinVar data files. - The `VariantWhiteList` is now dynamically loaded from the ClinVar data provided in the clinvar.mv.db file - `VariantDataServiceImpl` now requires a `ClinVarDao` +- Fix for issue [#531](https://github.com/exomiser/Exomiser/issues/531) where the `priorityScoreFilter` and `regulatoryFeatureFilter` pass/fail counts were not displayed in the HTML. +- Fix for issue [#534](https://github.com/exomiser/Exomiser/issues/534) where variant frequency and/or pathogenicity annotations are missing in certain run configurations. +New APIs: +- New `AnalysisDurationFormatter` +- New `FilterResultsCounter` +- New `FilterResultCount` data class +- New `AnalysisResults.filterResultCounts` field +- New `FilterRunner.filterCounts()` and `FilterRunner.logFilterResult()` methods +- New `Filterable.failedFilter()` method +- New `AlleleData` class to encapsulate building AlleleProto.Frequency and AlleleProto.PathogenicityScore instances +- Added new `ClinVarDao` and `ClinVarWhiteListReader` to take advantage of the independently upgradeable ClinVar data files. +- +API breaking changes: + + +Other changes: +- Updated Spring Boot to version 3.1.0 ## 13.3.0 2023-10-17 diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/Analysis.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/Analysis.java index b1b852710..62b983f9c 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/Analysis.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/Analysis.java @@ -30,7 +30,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import de.charite.compbio.jannovar.mendel.SubModeOfInheritance; import org.monarchinitiative.exomiser.core.analysis.util.InheritanceModeOptions; @@ -75,7 +74,7 @@ private Analysis(Builder builder) { this.inheritanceModeOptions = builder.inheritanceModeOptions; this.frequencySources = Sets.immutableEnumSet(builder.frequencySources); this.pathogenicitySources = Sets.immutableEnumSet(builder.pathogenicitySources); - this.analysisSteps = ImmutableList.copyOf(builder.analysisSteps); + this.analysisSteps = List.copyOf(builder.analysisSteps); } public AnalysisMode getAnalysisMode() { @@ -101,8 +100,7 @@ public List getAnalysisSteps() { @JsonIgnore public PriorityType getMainPrioritiserType() { for (AnalysisStep analysisStep : analysisSteps) { - if (analysisStep instanceof Prioritiser) { - Prioritiser prioritiser = (Prioritiser) analysisStep; + if (analysisStep instanceof Prioritiser prioritiser) { //OMIM, if combined with other prioritisers isn't the main one. if (prioritiser.getPriorityType() != PriorityType.OMIM_PRIORITY) { return prioritiser.getPriorityType(); diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilder.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilder.java index a55655f3d..ce19f1a56 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilder.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilder.java @@ -161,6 +161,11 @@ public AnalysisBuilder addFrequencyFilter(float cutOff) { analysisSteps.add(new FrequencyFilter(cutOff)); return this; } + @Override + public AnalysisBuilder addGeneBlacklistFilter() { + analysisSteps.add(new GeneBlacklistFilter()); + return this; + } /** * Add a frequency filter using the maximum frequency for any defined mode of inheritance as the cut-off. Calling this diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisFactory.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisFactory.java index be251d3d0..246628f76 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisFactory.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisFactory.java @@ -63,14 +63,11 @@ public AnalysisRunner getAnalysisRunner(GenomeAssembly genomeAssembly, AnalysisM // below are package-private. GenomeAnalysisService genomeAnalysisService = genomeAnalysisServiceProvider.get(genomeAssembly); - switch (analysisMode) { - case FULL: - return new SimpleAnalysisRunner(genomeAnalysisService); - case PASS_ONLY: - default: - //this guy takes up the least RAM - return new PassOnlyAnalysisRunner(genomeAnalysisService); - } + return switch (analysisMode) { + case FULL -> new SimpleAnalysisRunner(genomeAnalysisService); + // PASS_ONLY takes up the least RAM + case PASS_ONLY -> new PassOnlyAnalysisRunner(genomeAnalysisService); + }; } public AnalysisBuilder getAnalysisBuilder() { diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParser.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParser.java index b083cfc93..0fbf15526 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParser.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParser.java @@ -20,7 +20,6 @@ package org.monarchinitiative.exomiser.core.analysis; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import de.charite.compbio.jannovar.annotation.VariantEffect; import de.charite.compbio.jannovar.mendel.ModeOfInheritance; @@ -62,7 +61,6 @@ import java.util.Map.Entry; import static java.nio.file.Files.newInputStream; -import static java.util.stream.Collectors.toList; /** * @since 7.0.0 @@ -363,8 +361,7 @@ private SubModeOfInheritance parseValueOfSubInheritanceMode(String value) { try { return SubModeOfInheritance.valueOf(value); } catch (IllegalArgumentException e) { - List permitted = Arrays.stream(SubModeOfInheritance.values()) - .collect(toList()); + List permitted = List.of(SubModeOfInheritance.values()); throw new AnalysisParserException(String.format("'%s' is not a valid mode of inheritance. Use one of: %s", value, permitted)); } } @@ -373,8 +370,7 @@ private ModeOfInheritance parseValueOfInheritanceMode(String value) { try { return ModeOfInheritance.valueOf(value); } catch (IllegalArgumentException e) { - List permitted = Arrays.stream(ModeOfInheritance.values()) - .collect(toList()); + List permitted = List.of(ModeOfInheritance.values()); throw new AnalysisParserException(String.format("'%s' is not a valid mode of inheritance. Use one of: %s", value, permitted)); } } @@ -434,6 +430,8 @@ private AnalysisBuilder addAnalysisStep(Entry entry, Map analysisMa return makePriorityScoreFilter(analysisStepOptions, analysisBuilder); case "regulatoryFeatureFilter": return analysisBuilder.addRegulatoryFeatureFilter(); + case "geneBlacklistFilter": + return makeGeneBlacklistFilter(analysisStepOptions, analysisBuilder); case "omimPrioritiser": return analysisBuilder.addOmimPrioritiser(); case "hiPhivePrioritiser": @@ -460,7 +458,7 @@ private AnalysisBuilder makeIntervalFilter(Map options, Analysis private List parseIntervalFilterOptions(Map options){ if (options.containsKey("interval")) { String interval = (String) options.get("interval"); - return ImmutableList.of(GeneticInterval.parseString(interval)); + return List.of(GeneticInterval.parseString(interval)); } if (options.containsKey("intervals")) { List intervalStrings = (List) options.get("intervals"); @@ -470,7 +468,7 @@ private List parseIntervalFilterOptions(Map o } if (options.containsKey("bed")) { String bedPath = (String) options.get("bed"); - return BedFiles.readChromosomalRegions(Paths.get(bedPath)).collect(toList()); + return BedFiles.readChromosomalRegions(Paths.get(bedPath)).toList(); } throw new AnalysisParserException("Interval filter requires a valid genetic interval e.g. {interval: 'chr10:122892600-122892700'} or bed file path {bed: /data/intervals.bed}", options); } @@ -568,6 +566,14 @@ private Set parseFrequencySources(Map> opt List sources = new ArrayList<>(); for (String source : frequencySources) { try { + // legacy long-form ESP names + if (source.startsWith("ESP")) { + source = switch (source) { + case "ESP_AFRICAN_AMERICAN" -> "ESP_AA"; + case "ESP_EUROPEAN_AMERICAN" -> "ESP_EA"; + default -> source; + }; + } FrequencySource frequencySource = FrequencySource.valueOf(source); sources.add(frequencySource); } catch (IllegalArgumentException ex) { @@ -633,6 +639,10 @@ private AnalysisBuilder makeInheritanceFilter(InheritanceModeOptions inheritance return analysisBuilder.addInheritanceFilter(); } + private AnalysisBuilder makeGeneBlacklistFilter(Map options, AnalysisBuilder analysisBuilder) { + return analysisBuilder.addGeneBlacklistFilter(); + } + private AnalysisBuilder makeHiPhivePrioritiser(Map options, AnalysisBuilder analysisBuilder) { HiPhiveOptions hiPhiveOptions = makeHiPhiveOptions(options); logger.debug("Made {}", hiPhiveOptions); diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilder.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilder.java index 16a10a173..7f3fb37e3 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilder.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilder.java @@ -115,7 +115,7 @@ protected Analysis buildGenomePreset() { .analysisMode(AnalysisMode.PASS_ONLY) .inheritanceModes(DEFAULT_INHERITANCE_MODE_OPTIONS) .frequencySources(DEFAULT_FREQUENCY_SOURCES) - .pathogenicitySources(EnumSet.of(REVEL, MVP, REMM)) + .pathogenicitySources(EnumSet.of(REVEL, MVP, REMM, SPLICE_AI)) .addHiPhivePrioritiser(HI_PHIVE_OPTIONS) .addPriorityScoreFilter(PriorityType.HIPHIVE_PRIORITY, 0.5f)// will remove a lot of the weak PPI hits .addFailedVariantFilter() @@ -132,7 +132,7 @@ protected Analysis buildExomePreset() { .analysisMode(AnalysisMode.PASS_ONLY) .inheritanceModes(DEFAULT_INHERITANCE_MODE_OPTIONS) .frequencySources(DEFAULT_FREQUENCY_SOURCES) - .pathogenicitySources(EnumSet.of(REVEL, MVP)) + .pathogenicitySources(EnumSet.of(REVEL, MVP, SPLICE_AI)) .addVariantEffectFilter(EnumSet.of( VariantEffect.FIVE_PRIME_UTR_EXON_VARIANT, VariantEffect.FIVE_PRIME_UTR_INTRON_VARIANT, diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilder.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilder.java index 6a3ef76ed..6d45a0f5a 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilder.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilder.java @@ -176,6 +176,12 @@ public AnalysisProtoBuilder addFrequencyFilter(float cutOff) { return this; } + @Override + public AnalysisProtoBuilder addGeneBlacklistFilter() { + builder.addSteps(stepBuilder().setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.newBuilder())); + return this; + } + /** * Add a frequency filter using the maximum frequency for any defined mode of inheritance as the cut-off. Calling this * method requires that the {@code inheritanceModes} method has already been called and supplied with a non-empty diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverter.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverter.java index 8545d92ba..b425263e3 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverter.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverter.java @@ -39,9 +39,9 @@ public AnalysisProto.Analysis toProto(Analysis analysis) { return AnalysisProto.Analysis.newBuilder() .setAnalysisMode(analysis.getAnalysisMode() == AnalysisMode.PASS_ONLY ? AnalysisProto.AnalysisMode.PASS_ONLY : AnalysisProto.AnalysisMode.FULL) .putAllInheritanceModes(analysis.getInheritanceModeOptions().getMaxFreqs().entrySet().stream().collect(Collectors.toMap(subModeOfInheritanceFloatEntry -> subModeOfInheritanceFloatEntry.getKey().toString(), Map.Entry::getValue))) - .addAllFrequencySources(analysis.getFrequencySources().stream().map(Objects::toString).collect(Collectors.toList())) - .addAllPathogenicitySources(analysis.getPathogenicitySources().stream().map(Objects::toString).collect(Collectors.toList())) - .addAllSteps(analysis.getAnalysisSteps().stream().map(analysisStepToProto()).filter(Objects::nonNull).collect(Collectors.toList())) + .addAllFrequencySources(analysis.getFrequencySources().stream().map(Objects::toString).toList()) + .addAllPathogenicitySources(analysis.getPathogenicitySources().stream().map(Objects::toString).toList()) + .addAllSteps(analysis.getAnalysisSteps().stream().map(analysisStepToProto()).filter(Objects::nonNull).toList()) .build(); } @@ -59,21 +59,18 @@ private Function analysisStepToProto() private AnalysisProto.AnalysisStep buildFilterProto(AnalysisStep analysisStep) { AnalysisProto.AnalysisStep.Builder stepBuilder = AnalysisProto.AnalysisStep.newBuilder(); - if (analysisStep instanceof VariantEffectFilter) { - VariantEffectFilter variantEffectFilter = (VariantEffectFilter) analysisStep; + if (analysisStep instanceof VariantEffectFilter variantEffectFilter) { return stepBuilder .setVariantEffectFilter(FiltersProto.VariantEffectFilter.newBuilder() - .addAllRemove(variantEffectFilter.getOffTargetVariantTypes().stream().map(Objects::toString).collect(Collectors.toList()))) + .addAllRemove(variantEffectFilter.getOffTargetVariantTypes().stream().map(Objects::toString).toList())) .build(); } - if (analysisStep instanceof FrequencyFilter) { - FrequencyFilter frequencyFilter = (FrequencyFilter) analysisStep; + if (analysisStep instanceof FrequencyFilter frequencyFilter) { return stepBuilder .setFrequencyFilter(FiltersProto.FrequencyFilter.newBuilder().setMaxFrequency(frequencyFilter.getMaxFreq())) .build(); } - if (analysisStep instanceof PathogenicityFilter) { - PathogenicityFilter pathogenicityFilter = (PathogenicityFilter) analysisStep; + if (analysisStep instanceof PathogenicityFilter pathogenicityFilter) { return stepBuilder .setPathogenicityFilter(FiltersProto.PathogenicityFilter.newBuilder().setKeepNonPathogenic(pathogenicityFilter.keepNonPathogenic())) .build(); @@ -88,25 +85,29 @@ private AnalysisProto.AnalysisStep buildFilterProto(AnalysisStep analysisStep) { .setKnownVariantFilter(FiltersProto.KnownVariantFilter.newBuilder()) .build(); } - if (analysisStep instanceof QualityFilter) { - QualityFilter qualityFilter = (QualityFilter) analysisStep; + if (analysisStep instanceof QualityFilter qualityFilter) { return stepBuilder .setQualityFilter(FiltersProto.QualityFilter.newBuilder().setMinQuality((float) qualityFilter.getMimimumQualityThreshold())) .build(); } - if (analysisStep instanceof IntervalFilter) { - IntervalFilter intervalFilter = (IntervalFilter) analysisStep; + if (analysisStep instanceof IntervalFilter intervalFilter) { return stepBuilder .setIntervalFilter(FiltersProto.IntervalFilter.newBuilder() - .addAllIntervals(intervalFilter.getChromosomalRegions().stream().map(region -> region.contigId() + ":" + region.start() + "-" + region.end()).collect(Collectors.toList()))) + .addAllIntervals(intervalFilter.getChromosomalRegions().stream().map(region -> region.contigId() + ":" + region.start() + "-" + region.end()).toList())) .build(); } - if (analysisStep instanceof GeneSymbolFilter) { - GeneSymbolFilter geneSymbolFilter = (GeneSymbolFilter) analysisStep; + if (analysisStep instanceof GeneSymbolFilter geneSymbolFilter) { return stepBuilder .setGenePanelFilter(FiltersProto.GenePanelFilter.newBuilder().addAllGeneSymbols(geneSymbolFilter.getGeneSymbols())) .build(); } + + if (analysisStep instanceof GeneBlacklistFilter geneBlacklistFilter) { + return stepBuilder + .setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.newBuilder()) + .build(); + } + if (analysisStep instanceof InheritanceFilter) { return stepBuilder .setInheritanceFilter(FiltersProto.InheritanceFilter.newBuilder().build()) @@ -115,8 +116,7 @@ private AnalysisProto.AnalysisStep buildFilterProto(AnalysisStep analysisStep) { if (analysisStep instanceof RegulatoryFeatureFilter) { return stepBuilder.setRegulatoryFeatureFilter(FiltersProto.RegulatoryFeatureFilter.newBuilder()).build(); } - if (analysisStep instanceof PriorityScoreFilter) { - PriorityScoreFilter priorityScoreFilter = (PriorityScoreFilter) analysisStep; + if (analysisStep instanceof PriorityScoreFilter priorityScoreFilter) { return stepBuilder .setPriorityScoreFilter(FiltersProto.PriorityScoreFilter.newBuilder() .setMinPriorityScore((float) priorityScoreFilter.getMinPriorityScore()) @@ -133,8 +133,7 @@ private AnalysisProto.AnalysisStep buildPrioritiserProto(AnalysisStep analysisSt .setOmimPrioritiser(PrioritisersProto.OmimPrioritiser.newBuilder()) .build(); } - if (analysisStep instanceof HiPhivePriority) { - HiPhivePriority hiPhivePriority = (HiPhivePriority) analysisStep; + if (analysisStep instanceof HiPhivePriority hiPhivePriority) { HiPhiveOptions hiPhiveOptions = hiPhivePriority.getOptions(); return stepBuilder .setHiPhivePrioritiser(PrioritisersProto.HiPhivePrioritiser.newBuilder() @@ -153,8 +152,7 @@ private AnalysisProto.AnalysisStep buildPrioritiserProto(AnalysisStep analysisSt .setPhivePrioritiser(PrioritisersProto.PhivePrioritiser.newBuilder()) .build(); } - if (analysisStep instanceof ExomeWalkerPriority) { - ExomeWalkerPriority exomeWalkerPriority = (ExomeWalkerPriority) analysisStep; + if (analysisStep instanceof ExomeWalkerPriority exomeWalkerPriority) { return stepBuilder .setExomeWalkerPrioritiser(PrioritisersProto.ExomeWalkerPrioritiser.newBuilder().addAllSeedGeneIds(exomeWalkerPriority.getSeedGenes())) .build(); diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisSampleValidator.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisSampleValidator.java index 9a03f2f18..0577079e3 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisSampleValidator.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisSampleValidator.java @@ -92,15 +92,12 @@ private static boolean isPathogenicityDependent(AnalysisStep analysisStep) { } private static boolean isHpoDependent(AnalysisStep analysisStep) { - if (analysisStep instanceof Prioritiser) { - Prioritiser prioritiser = (Prioritiser) analysisStep; + if (analysisStep instanceof Prioritiser prioritiser) { PriorityType priorityType = prioritiser.getPriorityType(); - switch (priorityType) { - case HIPHIVE_PRIORITY: - case PHENIX_PRIORITY: - case PHIVE_PRIORITY: - return true; - } + return switch (priorityType) { + case HIPHIVE_PRIORITY, PHENIX_PRIORITY, PHIVE_PRIORITY -> true; + case EXOMEWALKER_PRIORITY, OMIM_PRIORITY, NONE -> false; + }; } return false; } diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisStepChecker.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisStepChecker.java index 314b6a66e..8ae1e65a8 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisStepChecker.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/AnalysisStepChecker.java @@ -150,8 +150,7 @@ private Set getPrioritiserTypes(List analysisSteps) private void removePriorityScoreFiltersNotOfType(List analysisSteps, Set prioritiserTypes) { analysisSteps.removeIf(step -> { - if (step instanceof PriorityScoreFilter) { - PriorityScoreFilter filter = (PriorityScoreFilter) step; + if (step instanceof PriorityScoreFilter filter) { if (!prioritiserTypes.contains(filter.getPriorityType())) { logger.info("WARNING: Removing {} as the corresponding Prioritiser is not present. AnalysisSteps have been changed.", filter); return true; @@ -187,8 +186,7 @@ private void addPriorityScoreFilterNextToMatchingPrioritiser(PriorityScoreFilter for (int i = 0; i < analysisSteps.size(); i++) { AnalysisStep step = analysisSteps.get(i); - if (step instanceof Prioritiser) { - Prioritiser prioritiser = (Prioritiser) step; + if (step instanceof Prioritiser prioritiser) { if (prioritiser.getPriorityType() == priorityScoreFilter.getPriorityType()) { containsMatchingPrioritiser = true; positionOfMatchingPrioritiser = i; diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/FluentAnalysisBuilder.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/FluentAnalysisBuilder.java index be641a427..3c165730f 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/FluentAnalysisBuilder.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/FluentAnalysisBuilder.java @@ -83,6 +83,8 @@ interface FluentAnalysisBuilder { public FluentAnalysisBuilder addFrequencyFilter(float cutOff); + public FluentAnalysisBuilder addGeneBlacklistFilter(); + /** * Add a frequency filter using the maximum frequency for any defined mode of inheritance as the cut-off. Calling this * method requires that the {@code inheritanceModes} method has already been called and supplied with a non-empty diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/JobParser.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/JobParser.java index 468aba950..9a20ea45f 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/JobParser.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/JobParser.java @@ -46,7 +46,6 @@ import java.util.*; import java.util.Map.Entry; -import static java.util.stream.Collectors.toList; import static org.monarchinitiative.exomiser.core.model.pathogenicity.PathogenicitySource.valueOf; /** @@ -160,18 +159,20 @@ private SampleProto.Sample sampleFromProtoAnalysis(AnalysisProto.Analysis protoA } private Analysis parsePreset(JobProto.Job protoJob) { - switch (protoJob.getPreset()) { - case PHENOTYPE_ONLY: + return switch (protoJob.getPreset()) { + case PHENOTYPE_ONLY -> { logger.info("Running PHENOTYPE_ONLY preset"); - return analysisPresetBuilder.buildPhenotypeOnlyPreset(); - case GENOME: + yield analysisPresetBuilder.buildPhenotypeOnlyPreset(); + } + case GENOME -> { logger.info("Running GENOME preset"); - return analysisPresetBuilder.buildGenomePreset(); - case EXOME: - default: + yield analysisPresetBuilder.buildGenomePreset(); + } + default -> { logger.info("Running EXOME preset"); - return analysisPresetBuilder.buildExomePreset(); - } + yield analysisPresetBuilder.buildExomePreset(); + } + }; } private Analysis parseProtoAnalysis(AnalysisProto.Analysis protoAnalysis) { @@ -267,6 +268,8 @@ private void addAnalysisStep(AnalysisBuilder analysisBuilder, InheritanceModeOpt analysisBuilder.addPathogenicityFilter(keepNonPathogenic); } else if (protoAnalysisStep.hasInheritanceFilter()) { analysisBuilder.addInheritanceFilter(); + } else if (protoAnalysisStep.hasGeneBlacklistFilter()) { + analysisBuilder.addGeneBlacklistFilter(); } else if (protoAnalysisStep.hasPriorityScoreFilter()) { PriorityType priorityType = parsePriorityType(protoAnalysisStep.getPriorityScoreFilter()); float minPriorityScore = parseMinPriorityScore(protoAnalysisStep.getPriorityScoreFilter()); @@ -301,7 +304,7 @@ private List parseIntervalFilterOptions(FiltersProto.Interval } if (!intervalFilter.getBed().isEmpty()) { String bedPath = intervalFilter.getBed(); - return BedFiles.readChromosomalRegions(Paths.get(bedPath)).collect(toList()); + return BedFiles.readChromosomalRegions(Paths.get(bedPath)).toList(); } throw new IllegalArgumentException("Interval filter requires a valid genetic interval e.g. {interval: 'chr10:122892600-122892700'} or bed file path {bed: /data/intervals.bed}"); } diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/PassOnlyAnalysisRunner.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/PassOnlyAnalysisRunner.java index dbb6da690..f167f10f4 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/PassOnlyAnalysisRunner.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/analysis/PassOnlyAnalysisRunner.java @@ -89,7 +89,7 @@ private Predicate variantFailedFilters() { protected List getFinalVariantList(List variants) { return variants.stream() .filter(VariantEvaluation::passedFilters) - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactory.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactory.java index 7993b9d6a..7fec00fd3 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactory.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactory.java @@ -80,30 +80,24 @@ protected FilterReport makeFilterReport(Filter filter, AnalysisResults analys Filter baseFilter = unWrapVariantFilterDataProvider(filter); FilterType filterType = filter.getFilterType(); FilterResultCount filterResultCount = analysisResults.getFilterCount(filterType); - switch (filterType) { - case FAILED_VARIANT_FILTER: - return filterReport(filterResultCount, failedVariantFilterMessages((FailedVariantFilter) baseFilter)); - case VARIANT_EFFECT_FILTER: - return filterReport(filterResultCount, messages((VariantEffectFilter) baseFilter)); - case KNOWN_VARIANT_FILTER: - return filterReport(filterResultCount, messages((KnownVariantFilter) baseFilter, analysisResults.getVariantEvaluations())); - case FREQUENCY_FILTER: - return filterReport(filterResultCount, messages((FrequencyFilter) baseFilter)); - case QUALITY_FILTER: - return filterReport(filterResultCount, messages((QualityFilter) baseFilter)); - case PATHOGENICITY_FILTER: - return filterReport(filterResultCount, messages((PathogenicityFilter) baseFilter)); - case INTERVAL_FILTER: - return filterReport(filterResultCount, messages((IntervalFilter) baseFilter)); - case INHERITANCE_FILTER: - return filterReport(filterResultCount, messages((InheritanceFilter) baseFilter)); - case PRIORITY_SCORE_FILTER: - return filterReport(filterResultCount, messages((PriorityScoreFilter) baseFilter)); - case REGULATORY_FEATURE_FILTER: - return filterReport(filterResultCount, messages((RegulatoryFeatureFilter) baseFilter)); - default: - return filterReport(filterResultCount, List.of()); - } + return switch (filterType) { + case FAILED_VARIANT_FILTER -> + filterReport(filterResultCount, failedVariantFilterMessages((FailedVariantFilter) baseFilter)); + case VARIANT_EFFECT_FILTER -> filterReport(filterResultCount, messages((VariantEffectFilter) baseFilter)); + case KNOWN_VARIANT_FILTER -> + filterReport(filterResultCount, messages((KnownVariantFilter) baseFilter, analysisResults.getVariantEvaluations())); + case FREQUENCY_FILTER -> filterReport(filterResultCount, messages((FrequencyFilter) baseFilter)); + case QUALITY_FILTER -> filterReport(filterResultCount, messages((QualityFilter) baseFilter)); + case ENTREZ_GENE_ID_FILTER -> filterReport(filterResultCount, messages((GeneSymbolFilter) baseFilter)); + case PATHOGENICITY_FILTER -> filterReport(filterResultCount, messages((PathogenicityFilter) baseFilter)); + case INTERVAL_FILTER -> filterReport(filterResultCount, messages((IntervalFilter) baseFilter)); + case INHERITANCE_FILTER -> filterReport(filterResultCount, messages((InheritanceFilter) baseFilter)); + case BED_FILTER -> filterReport(filterResultCount, List.of()); + case PRIORITY_SCORE_FILTER -> filterReport(filterResultCount, messages((PriorityScoreFilter) baseFilter)); + case REGULATORY_FEATURE_FILTER -> + filterReport(filterResultCount, messages((RegulatoryFeatureFilter) baseFilter)); + case GENE_BLACKLIST_FILTER -> filterReport(filterResultCount, messages((GeneBlacklistFilter) baseFilter)); + }; } private FilterReport filterReport(FilterResultCount filterResultCount, List messages) { @@ -111,11 +105,7 @@ private FilterReport filterReport(FilterResultCount filterResultCount, List unWrapVariantFilterDataProvider(Filter filter) { - if (filter instanceof VariantFilterDataProvider) { - VariantFilterDataProvider decorator = (VariantFilterDataProvider) filter; - return decorator.getDecoratedFilter(); - } - return filter; + return filter instanceof VariantFilterDataProvider decorator ? decorator.getDecoratedFilter() : filter; } private List failedVariantFilterMessages(FailedVariantFilter baseFilter) { @@ -178,7 +168,7 @@ private List messages(QualityFilter qualityFilter) { private List messages(PathogenicityFilter pathogenicityFilter) { if (pathogenicityFilter.keepNonPathogenic()) { - return List.of("Retained all non-pathogenic variants of all types. Scoring was applied, but the filter passed all variants."); + return List.of("Retained all non-pathogenic variants of all types. Scoring was applied, but the filter passed all variants."); } return List.of("Retained all non-pathogenic missense variants"); } @@ -187,6 +177,14 @@ private List messages(RegulatoryFeatureFilter baseFilter) { return List.of("Variants found within a regulatory region or <= 20 Kb upstream of the nearest gene"); } + private List messages(GeneSymbolFilter baseFilter) { + return List.of(String.format("Removed variants in genes: %s", baseFilter.getGeneSymbols())); + } + + private List messages(GeneBlacklistFilter baseFilter) { + return List.of(String.format("Removed variants in blacklisted genes including pseudogenes, HLA genes, and others that have a high degree of variants called in healthy individuals: %s", baseFilter.getBlacklist().stream().sorted().toList())); + } + private List messages(IntervalFilter intervalFilter) { List chromosomalRegions = intervalFilter.getChromosomalRegions(); @@ -203,7 +201,7 @@ private List messages(IntervalFilter intervalFilter) { messages.add(formatRegion(chromosomalRegion)); } } else { - for (int i = 0; i < regionsToShow - 2 ; i++) { + for (int i = 0; i < regionsToShow - 2; i++) { ChromosomalRegion region = chromosomalRegions.get(i); messages.add(formatRegion(region)); } diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterType.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterType.java index 6f5b7b4e5..e4b572247 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterType.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/FilterType.java @@ -40,7 +40,8 @@ public enum FilterType { VARIANT_EFFECT_FILTER("var-effect", "Variant effect"), INHERITANCE_FILTER("inheritance", "Inheritance"), BED_FILTER("bed", "Gene panel target region (Bed)"), - PRIORITY_SCORE_FILTER("gene-priority", "Gene priority score"); + PRIORITY_SCORE_FILTER("gene-priority", "Gene priority score"), + GENE_BLACKLIST_FILTER("gene-blacklist", "Gene blacklist"); private final String vcfValue; private final String stringValue; diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilter.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilter.java new file mode 100644 index 000000000..b0c80f852 --- /dev/null +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilter.java @@ -0,0 +1,67 @@ + + + +package org.monarchinitiative.exomiser.core.filters; + +import org.monarchinitiative.exomiser.core.model.VariantEvaluation; + +import java.util.*; + +/** + * The GeneBlacklistFilter removes variants from the analysis which are assigned to a set of blacklisted genes. + *

Blacklisted genes are removed to reduce the noise level. These are 56 pseudogenes, HLA genes, + * and others that have a high degree of variants called in healthy individuals:

+ * + *

COL4A2-AS2, CRIPAK, FCGBP, GOLGA6L2, GOLGA8N, HLA-A, HLA-B, HLA-C, HLA-DMA, HLA-DMB, HLA-DOA, HLA-DOB, HLA-DPA1, + * HLA-DPB1, HLA-DPB2, HLA-DQA1, HLA-DQA2, HLA-DQB1, HLA-DQB1-AS1, HLA-DQB2, HLA-DRA, HLA-DRB1, HLA-DRB5, HLA-DRB6, + * HLA-E, HLA-F, HLA-F-AS1, HLA-G, HLA-H, HLA-J, HLA-L, KRTAP4-7, KRTAP4-8, KRTAP9-6, LILRA6, LILRB3, LINC02081, + * LRRC37A2, MUC12, MUC16, MUC17, MUC19, MUC2, MUC20, MUC21, MUC3A, MUC4, MUC6, PDE4DIP, PRAMEF2, PRAMEF9, SIRPA, TBC1D3I, + * UGT1A7, USP17L1

+ * + * @since 14.0.0 + */ +public class GeneBlacklistFilter implements VariantFilter { + + public static final FilterType filterType = FilterType.GENE_BLACKLIST_FILTER; + + private static final FilterResult PASS = FilterResult.pass(filterType); + private static final FilterResult FAIL = FilterResult.fail(filterType); + private static final Set BLACKLIST = Set.of("COL4A2-AS2", "CRIPAK", "FCGBP", "GOLGA6L2", "GOLGA8N", "HLA-A", + "HLA-B", "HLA-C", "HLA-DMA", "HLA-DMB", "HLA-DOA", "HLA-DOB", "HLA-DPA1", "HLA-DPB1", "HLA-DPB2", "HLA-DQA1", + "HLA-DQA2", "HLA-DQB1", "HLA-DQB1-AS1", "HLA-DQB2", "HLA-DRA", "HLA-DRB1", "HLA-DRB5", "HLA-DRB6", "HLA-E", + "HLA-F", "HLA-F-AS1", "HLA-G", "HLA-H", "HLA-J", "HLA-L", "KRTAP4-7", "KRTAP4-8", "KRTAP9-6", "LILRA6", + "LILRB3", "LINC02081", "LRRC37A2", "MUC12", "MUC16", "MUC17", "MUC19", "MUC2", "MUC20", "MUC21", "MUC3A", "MUC4", + "MUC6", "PDE4DIP", "PRAMEF2", "PRAMEF9", "SIRPA", "TBC1D3I", "UGT1A7", "USP17L1"); + + public Set getBlacklist() { + return BLACKLIST; + } + + @Override + public FilterType getFilterType() { + return filterType; + } + + @Override + public FilterResult runFilter(VariantEvaluation variantEvaluation) { + return BLACKLIST.contains(variantEvaluation.getGeneSymbol()) ? FAIL : PASS; + } + + @Override + public int hashCode() { + return Objects.hash(BLACKLIST, filterType); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof GeneBlacklistFilter geneBlacklistFilter) { + return Objects.equals(geneBlacklistFilter.getBlacklist(), this.getBlacklist()); + } + return false; + } + + @Override + public String toString() { + return "GeneBlacklistFilter{" + BLACKLIST + "}"; + } +} \ No newline at end of file diff --git a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/SimpleGeneFilterRunner.java b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/SimpleGeneFilterRunner.java index 37c8e087d..b9c3571be 100644 --- a/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/SimpleGeneFilterRunner.java +++ b/exomiser-core/src/main/java/org/monarchinitiative/exomiser/core/filters/SimpleGeneFilterRunner.java @@ -26,7 +26,6 @@ package org.monarchinitiative.exomiser.core.filters; import org.monarchinitiative.exomiser.core.model.Gene; -import org.monarchinitiative.exomiser.core.model.VariantEvaluation; import java.util.List; diff --git a/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/analysis.proto b/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/analysis.proto index 7f637078c..4afe63e3b 100644 --- a/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/analysis.proto +++ b/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/analysis.proto @@ -65,6 +65,7 @@ message AnalysisStep { PathogenicityFilter pathogenicity_filter = 8; KnownVariantFilter known_variant_filter = 9; InheritanceFilter inheritance_filter = 10; + GeneBlacklistFilter gene_blacklist_filter = 17; // prioritisers OmimPrioritiser omim_prioritiser = 11; HiPhivePrioritiser hi_phive_prioritiser = 12; diff --git a/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/filters.proto b/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/filters.proto index 10fab3769..e40802b59 100644 --- a/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/filters.proto +++ b/exomiser-core/src/main/proto/org/monarchinitiative/exomiser/api/v1/filters.proto @@ -54,6 +54,9 @@ message PathogenicityFilter { message InheritanceFilter { } +message GeneBlacklistFilter { +} + // Running the prioritiser followed by a priorityScoreFilter will remove genes // which are least likely to contribute to the phenotype defined in hpoIds, this will // dramatically reduce the time and memory required to analyse a genome. diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilderTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilderTest.java index 3a121c16d..fff64c97e 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilderTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisBuilderTest.java @@ -270,6 +270,7 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { EnumSet frequencySources = EnumSet.of(FrequencySource.ESP_AA, FrequencySource.EXAC_EAST_ASIAN); float frequencyCutOff = 2f; FrequencyFilter frequencyFilter = new FrequencyFilter(frequencyCutOff); + GeneBlacklistFilter geneBlacklistFilter = new GeneBlacklistFilter(); PhivePriority phivePrioritiser = priorityFactory.makePhivePrioritiser(); @@ -286,7 +287,8 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { .addPhivePrioritiser() .addPriorityScoreFilter(priorityType, minPriorityScore) .addRegulatoryFeatureFilter() - .addFrequencyFilter(frequencyCutOff); + .addFrequencyFilter(frequencyCutOff) + .addGeneBlacklistFilter(); Analysis analysis = analysisBuilder.build(); assertThat(analysis.getInheritanceModeOptions(), equalTo(InheritanceModeOptions.defaults())); @@ -297,8 +299,9 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { assertThat(analysis.getAnalysisSteps(), hasItem(frequencyFilter)); assertThat(analysis.getAnalysisSteps(), hasItem(phivePrioritiser)); assertThat(analysis.getAnalysisSteps(), hasItem(regulatoryFeatureFilter)); + assertThat(analysis.getAnalysisSteps(), hasItem(geneBlacklistFilter)); //check that the order of analysis steps is preserved - assertThat(analysis.getAnalysisSteps(), equalTo(Arrays.asList(phivePrioritiser, priorityScoreFilter, regulatoryFeatureFilter, frequencyFilter))); + assertThat(analysis.getAnalysisSteps(), equalTo(Arrays.asList(phivePrioritiser, priorityScoreFilter, regulatoryFeatureFilter, frequencyFilter, geneBlacklistFilter))); } @Test @@ -393,4 +396,12 @@ public void testCanAddFilterStep() { assertThat(analysisSteps(), equalTo(singletonList(filter))); } + + @Test + public void testCanAddGeneblacklistFilter() { + AnalysisStep blacklistfilter = new GeneBlacklistFilter(); + analysisBuilder.addAnalysisStep(blacklistfilter); + assertThat(analysisSteps(), equalTo(List.of(blacklistfilter))); + } + } \ No newline at end of file diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParserTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParserTest.java index 0ace16686..f75ad9c16 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParserTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisParserTest.java @@ -266,7 +266,7 @@ public void testParseAnalysisModeOfInheritanceAutosomalDominant() { + " AUTOSOMAL_DOMINANT: 1.0 \n" + "}\n" + " "); - Map options = ImmutableMap.of(SubModeOfInheritance.AUTOSOMAL_DOMINANT, 1.0f); + Map options = Map.of(SubModeOfInheritance.AUTOSOMAL_DOMINANT, 1.0f); assertThat(analysis.getInheritanceModeOptions(), equalTo(InheritanceModeOptions.of(options))); } @@ -281,7 +281,7 @@ public void testParseAnalysisModeOfInheritanceMultipleModes() { + "}\n" + " "); - Map options = ImmutableMap.of( + Map options = Map.of( SubModeOfInheritance.AUTOSOMAL_DOMINANT, 0.1f, SubModeOfInheritance.ANY, 0.1f ); @@ -355,7 +355,7 @@ public void testParseAnalysisStepIntervalFilterFromInterval() { @Test public void testParseAnalysisStepIntervalFilterFromList() { Analysis analysis = instance.parseAnalysis(addStepToAnalysis("intervalFilter: {intervals: ['chr10:122892600-122892700', 'chr10:122892900-122893000']}")); - List expectedIntervals = ImmutableList.of( + List expectedIntervals = List.of( new GeneticInterval(10, 122892600, 122892700), new GeneticInterval(10, 122892900, 122893000) ); @@ -490,6 +490,13 @@ public void testParseAnalysisStepInheritanceFilterUnrecognisedValue() { ); } + @Test + public void testParseAnalysisGeneBlacklistfilter(){ + Analysis analysis = instance.parseAnalysis(addStepToAnalysis("geneBlacklistFilter: {}")); + analysisSteps.add(new GeneBlacklistFilter()); + assertThat(analysis.getAnalysisSteps(), equalTo(analysisSteps)); + } + @Test public void testParseAnalysisStepInheritanceFilterDefinedMode() { Analysis analysis = instance.parseAnalysis(addStepToAnalysis("inheritanceFilter: {}")); diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilderTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilderTest.java index f83a2a813..12c428c95 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilderTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisPresetBuilderTest.java @@ -53,7 +53,7 @@ public void testBuildExomePreset() { assertThat(analysis.getAnalysisMode(), equalTo(AnalysisMode.PASS_ONLY)); assertThat(analysis.getInheritanceModeOptions(), equalTo(InheritanceModeOptions.defaults())); assertThat(analysis.getFrequencySources(), equalTo(FREQUENCY_SOURCES)); - assertThat(analysis.getPathogenicitySources(), equalTo(Set.of(REVEL, MVP))); + assertThat(analysis.getPathogenicitySources(), equalTo(Set.of(REVEL, MVP, SPLICE_AI))); assertThat(analysis.getAnalysisSteps().stream().map(AnalysisStep::getClass).collect(Collectors.toList()), equalTo(List.of( VariantEffectFilter.class, @@ -64,7 +64,6 @@ public void testBuildExomePreset() { OmimPriority.class, HiPhivePriority.class ))); - System.out.println(analysis.getAnalysisSteps()); } @Test @@ -73,7 +72,7 @@ public void testBuildGenomePreset() { assertThat(analysis.getAnalysisMode(), equalTo(AnalysisMode.PASS_ONLY)); assertThat(analysis.getInheritanceModeOptions(), equalTo(InheritanceModeOptions.defaults())); assertThat(analysis.getFrequencySources(), equalTo(FREQUENCY_SOURCES)); - assertThat(analysis.getPathogenicitySources(), equalTo(Set.of(REVEL, MVP, REMM))); + assertThat(analysis.getPathogenicitySources(), equalTo(Set.of(REVEL, MVP, REMM, SPLICE_AI))); assertThat(analysis.getAnalysisSteps().stream().map(AnalysisStep::getClass).collect(Collectors.toList()), equalTo(List.of( HiPhivePriority.class, diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilderTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilderTest.java index bc54b8035..46372ee91 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilderTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoBuilderTest.java @@ -68,6 +68,10 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { .setPhivePrioritiser(PrioritisersProto.PhivePrioritiser.getDefaultInstance()) .build(); + AnalysisProto.AnalysisStep blacklistFilter = AnalysisProto.AnalysisStep.newBuilder() + .setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.getDefaultInstance()) + .build(); + PriorityType priorityType = PriorityType.PHIVE_PRIORITY; float minPriorityScore = 0.501f; @@ -93,6 +97,7 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { .addPhivePrioritiser() .addPriorityScoreFilter(priorityType, minPriorityScore) .addRegulatoryFeatureFilter() + .addGeneBlacklistFilter() .addFrequencyFilter(frequencyCutOff) .addInheritanceFilter() .build(); @@ -119,6 +124,7 @@ public void testAnalysisBuilderCanBuildCompleteAnalysis() { phivePrioritiser, priorityScoreFilter, regulatoryFeatureFilter, + blacklistFilter, frequencyFilter, inheritanceFilter ))); diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverterTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverterTest.java index b6704ed03..80ec7723b 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverterTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisProtoConverterTest.java @@ -73,6 +73,7 @@ void testToProtoGlobalOptions() { @Test void testToProtoExomeAnalysisSteps() { Analysis analysis = Analysis.builder() + .addStep((new GeneBlacklistFilter())) .addStep(new FrequencyFilter(0.2f)) .addStep(new PathogenicityFilter(true)) .addStep(new InheritanceFilter()) @@ -81,6 +82,7 @@ void testToProtoExomeAnalysisSteps() { .build(); AnalysisProto.Analysis result = new AnalysisProtoConverter().toProto(analysis); AnalysisProto.Analysis expected = AnalysisProto.Analysis.newBuilder() + .addSteps(AnalysisProto.AnalysisStep.newBuilder().setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.newBuilder())) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setFrequencyFilter(FiltersProto.FrequencyFilter.newBuilder().setMaxFrequency(0.2f))) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setPathogenicityFilter(FiltersProto.PathogenicityFilter.newBuilder().setKeepNonPathogenic(true))) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setInheritanceFilter(FiltersProto.InheritanceFilter.newBuilder())) @@ -97,6 +99,7 @@ void testToProtoGenomeAnalysisSteps() { .addStep(new PriorityScoreFilter(PriorityType.HIPHIVE_PRIORITY, 0.501f)) .addStep(new FailedVariantFilter()) .addStep(new RegulatoryFeatureFilter()) + .addStep(new GeneBlacklistFilter()) .addStep(new FrequencyFilter(0.2f)) .addStep(new PathogenicityFilter(true)) .addStep(new InheritanceFilter()) @@ -108,6 +111,7 @@ void testToProtoGenomeAnalysisSteps() { .addSteps(AnalysisProto.AnalysisStep.newBuilder().setPriorityScoreFilter(FiltersProto.PriorityScoreFilter.newBuilder().setPriorityType("HIPHIVE_PRIORITY").setMinPriorityScore(0.501f))) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setFailedVariantFilter(FiltersProto.FailedVariantFilter.newBuilder())) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setRegulatoryFeatureFilter(FiltersProto.RegulatoryFeatureFilter.newBuilder())) + .addSteps(AnalysisProto.AnalysisStep.newBuilder().setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.newBuilder())) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setFrequencyFilter(FiltersProto.FrequencyFilter.newBuilder().setMaxFrequency(0.2f))) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setPathogenicityFilter(FiltersProto.PathogenicityFilter.newBuilder().setKeepNonPathogenic(true))) .addSteps(AnalysisProto.AnalysisStep.newBuilder().setInheritanceFilter(FiltersProto.InheritanceFilter.newBuilder())) diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisResultsTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisResultsTest.java index 8d40c5c99..de4d22cbc 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisResultsTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisResultsTest.java @@ -25,7 +25,6 @@ */ package org.monarchinitiative.exomiser.core.analysis; -import com.google.common.collect.ImmutableList; import de.charite.compbio.jannovar.mendel.ModeOfInheritance; import org.junit.jupiter.api.Test; import org.monarchinitiative.exomiser.core.analysis.sample.Sample; @@ -74,7 +73,7 @@ public void testSample() { @Test public void testCanSetAndGetSampleNames() { - List sampleNames = ImmutableList.of("David"); + List sampleNames = List.of("David"); AnalysisResults instance = AnalysisResults.builder() .sampleNames(sampleNames) @@ -116,7 +115,7 @@ public void testGetGeneScores() { .geneIdentifier(fgfr2Gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .combinedScore(1f) - .contributingVariants(ImmutableList.of(top)) + .contributingVariants(List.of(top)) .build(); VariantEvaluation bottom = TestFactory.variantBuilder(10, 23456, "A", "T").build(); @@ -124,7 +123,7 @@ public void testGetGeneScores() { .geneIdentifier(fgfr2Gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .combinedScore(0.50f) - .contributingVariants(ImmutableList.of(bottom)) + .contributingVariants(List.of(bottom)) .build(); fgfr2Gene.addGeneScore(first); @@ -136,20 +135,20 @@ public void testGetGeneScores() { .geneIdentifier(rbm8aGene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .combinedScore(0.75f) - .contributingVariants(ImmutableList.of(middle)) + .contributingVariants(List.of(middle)) .build(); rbm8aGene.addGeneScore(second); //no gene score for SHH Gene shhGene = TestFactory.newGeneSHH(); - List genes = ImmutableList.of(fgfr2Gene, rbm8aGene, shhGene); + List genes = List.of(fgfr2Gene, rbm8aGene, shhGene); AnalysisResults instance = AnalysisResults.builder() .genes(genes) .build(); - List expected = ImmutableList.of(first, second, third); + List expected = List.of(first, second, third); assertThat(instance.getGeneScores(), equalTo(expected)); } @@ -161,7 +160,7 @@ public void testGetGeneScoresForMode() { .geneIdentifier(fgfr2Gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .combinedScore(1f) - .contributingVariants(ImmutableList.of(top)) + .contributingVariants(List.of(top)) .build(); VariantEvaluation bottom = TestFactory.variantBuilder(10, 23456, "A", "T").build(); @@ -169,7 +168,7 @@ public void testGetGeneScoresForMode() { .geneIdentifier(fgfr2Gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .combinedScore(0.50f) - .contributingVariants(ImmutableList.of(bottom)) + .contributingVariants(List.of(bottom)) .build(); fgfr2Gene.addGeneScore(firstAD); @@ -181,21 +180,21 @@ public void testGetGeneScoresForMode() { .geneIdentifier(rbm8aGene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .combinedScore(0.75f) - .contributingVariants(ImmutableList.of(middle)) + .contributingVariants(List.of(middle)) .build(); rbm8aGene.addGeneScore(secondAD); //no gene score for SHH Gene shhGene = TestFactory.newGeneSHH(); - List genes = ImmutableList.of(fgfr2Gene, rbm8aGene, shhGene); + List genes = List.of(fgfr2Gene, rbm8aGene, shhGene); AnalysisResults instance = AnalysisResults.builder() .genes(genes) .build(); - assertThat(instance.getGeneScoresForMode(ModeOfInheritance.AUTOSOMAL_DOMINANT), equalTo(ImmutableList.of(firstAD, secondAD))); - assertThat(instance.getGeneScoresForMode(ModeOfInheritance.AUTOSOMAL_RECESSIVE), equalTo(ImmutableList.of(thirdAR))); + assertThat(instance.getGeneScoresForMode(ModeOfInheritance.AUTOSOMAL_DOMINANT), equalTo(List.of(firstAD, secondAD))); + assertThat(instance.getGeneScoresForMode(ModeOfInheritance.AUTOSOMAL_RECESSIVE), equalTo(List.of(thirdAR))); } @Test @@ -206,7 +205,7 @@ public void testCanReturnUnannotatedVariantEvaluations() { VariantEvaluation unAnnotatedVariantEvaluation = TestFactory.variantBuilder(7, 155604800, "C", "CTT").build(); - List allVariantEvaluations = ImmutableList.of(annotatedVariantEvaluation, unAnnotatedVariantEvaluation); + List allVariantEvaluations = List.of(annotatedVariantEvaluation, unAnnotatedVariantEvaluation); AnalysisResults instance = AnalysisResults.builder() .variantEvaluations(allVariantEvaluations) @@ -264,7 +263,7 @@ public void testNotEquals() { AnalysisResults instance = AnalysisResults.builder().sample(sample).build(); AnalysisResults other = AnalysisResults.builder() .sample(sample) - .sampleNames(ImmutableList.of("Fred", "Wilma")) + .sampleNames(List.of("Fred", "Wilma")) .build(); assertThat(instance, not(equalTo(other))); } diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisTest.java index 787d0eb1f..bbbffa755 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/AnalysisTest.java @@ -21,8 +21,6 @@ package org.monarchinitiative.exomiser.core.analysis; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import de.charite.compbio.jannovar.mendel.ModeOfInheritance; import de.charite.compbio.jannovar.mendel.SubModeOfInheritance; import org.junit.jupiter.api.Test; @@ -56,7 +54,7 @@ private List getAnalysisSteps() { GeneFilter inheritanceFilter = new InheritanceFilter(ModeOfInheritance.ANY); VariantFilter targetFilter = new PassAllVariantEffectsFilter(); - return Lists.newArrayList(geneIdFilter, noneTypePrioritiser, inheritanceFilter, targetFilter); + return List.of(geneIdFilter, noneTypePrioritiser, inheritanceFilter, targetFilter); } @Test @@ -74,7 +72,7 @@ public void canSetModeOfInheritanceDefaults() { @Test public void testCanMakeAnalysisWithInheritanceModesFromMap() { - Map inheritanceMap = ImmutableMap.of(SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, 2.0f); + Map inheritanceMap = Map.of(SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, 2.0f); Analysis instance = newBuilder() .inheritanceModeOptions(inheritanceMap) @@ -85,7 +83,7 @@ public void testCanMakeAnalysisWithInheritanceModesFromMap() { @Test public void testCanMakeAnalysisWithInheritanceModesFromInheritanceModeOptions() { - Map inheritanceMap = ImmutableMap.of(SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, 2.0f); + Map inheritanceMap = Map.of(SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, 2.0f); InheritanceModeOptions inheritanceModeOptions = InheritanceModeOptions.of(inheritanceMap); Analysis instance = newBuilder() diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/JobParserTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/JobParserTest.java index 79dae6e50..13dffce1e 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/JobParserTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/analysis/JobParserTest.java @@ -20,7 +20,6 @@ package org.monarchinitiative.exomiser.core.analysis; -import com.google.common.collect.ImmutableList; import de.charite.compbio.jannovar.annotation.VariantEffect; import de.charite.compbio.jannovar.mendel.ModeOfInheritance; import de.charite.compbio.jannovar.mendel.SubModeOfInheritance; @@ -407,7 +406,7 @@ public void testIntervalFilterFromList() { .build(); Analysis analysis = initialiseAnalysisWithStep(analysisStep); - List expectedIntervals = ImmutableList.of( + List expectedIntervals = List.of( new GeneticInterval(10, 122892600, 122892700), new GeneticInterval(10, 122892900, 122893000) ); @@ -456,6 +455,16 @@ public void testGenePanelFilter() { assertThat(analysis.getAnalysisSteps(), equalTo(List.of(new GeneSymbolFilter(new LinkedHashSet<>(Arrays.asList("FGFR1", "FGFR2")))))); } + @Test + public void testGeneBlacklistFilter() { + AnalysisProto.AnalysisStep analysisStep = AnalysisProto.AnalysisStep.newBuilder() + .setGeneBlacklistFilter(FiltersProto.GeneBlacklistFilter.newBuilder()) + .build(); + Analysis analysis = initialiseAnalysisWithStep(analysisStep); + + assertThat(analysis.getAnalysisSteps(), equalTo(List.of(new GeneBlacklistFilter()))); + } + @Test public void testVariantEffectFilterEmpty() { AnalysisProto.AnalysisStep analysisStep = AnalysisProto.AnalysisStep.newBuilder() @@ -526,7 +535,7 @@ void testKnownVariantFilter() { .build(); AnalysisProto.Analysis protoAnalysis = AnalysisProto.Analysis.newBuilder() - .addAllFrequencySources(ImmutableList.of("THOUSAND_GENOMES", "TOPMED")) + .addAllFrequencySources(List.of("THOUSAND_GENOMES", "TOPMED")) .addSteps(analysisStep) .build(); @@ -568,7 +577,7 @@ void testFrequencyFilterEmpty() { .build(); AnalysisProto.Analysis protoAnalysis = AnalysisProto.Analysis.newBuilder() - .addAllFrequencySources(ImmutableList.of("THOUSAND_GENOMES", "TOPMED")) + .addAllFrequencySources(List.of("THOUSAND_GENOMES", "TOPMED")) .putInheritanceModes("AUTOSOMAL_DOMINANT", 0.1f) .addSteps(analysisStep) .build(); @@ -587,7 +596,7 @@ void testFrequencyFilterInheritanceModesEmpty() { .build(); AnalysisProto.Analysis protoAnalysis = AnalysisProto.Analysis.newBuilder() - .addAllFrequencySources(ImmutableList.of("THOUSAND_GENOMES", "TOPMED")) + .addAllFrequencySources(List.of("THOUSAND_GENOMES", "TOPMED")) .addSteps(analysisStep) .build(); @@ -605,7 +614,7 @@ void testFrequencyFilterOverridesInheritanceModeFrequencyLarger() { .build(); AnalysisProto.Analysis protoAnalysis = AnalysisProto.Analysis.newBuilder() - .addAllFrequencySources(ImmutableList.of("THOUSAND_GENOMES", "TOPMED")) + .addAllFrequencySources(List.of("THOUSAND_GENOMES", "TOPMED")) .putInheritanceModes("AUTOSOMAL_DOMINANT", 0.1f) .addSteps(analysisStep) .build(); @@ -624,7 +633,7 @@ void testFrequencyFilterOverridesInheritanceModeFrequencySmaller() { .build(); AnalysisProto.Analysis protoAnalysis = AnalysisProto.Analysis.newBuilder() - .addAllFrequencySources(ImmutableList.of("THOUSAND_GENOMES", "TOPMED")) + .addAllFrequencySources(List.of("THOUSAND_GENOMES", "TOPMED")) .putInheritanceModes("AUTOSOMAL_DOMINANT", 0.1f) .addSteps(analysisStep) .build(); diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactoryTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactoryTest.java index a7b62685d..d365a9bdd 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactoryTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportFactoryTest.java @@ -25,7 +25,6 @@ */ package org.monarchinitiative.exomiser.core.filters; -import com.google.common.collect.ImmutableList; import de.charite.compbio.jannovar.annotation.VariantEffect; import de.charite.compbio.jannovar.mendel.ModeOfInheritance; import org.junit.jupiter.api.BeforeEach; @@ -157,7 +156,7 @@ public void testMakeDefaultGeneFilterReportContainsCorrectNumberOfPassedAndFaile public void testMakeTargetFilterReport() { VariantEffectFilter filter = new VariantEffectFilter(EnumSet.noneOf(VariantEffect.class)); - ImmutableList messages = ImmutableList.of(String.format("Removed variants with effects of type: %s", filter.getOffTargetVariantTypes())); + List messages = List.of(String.format("Removed variants with effects of type: %s", filter.getOffTargetVariantTypes())); FilterReport report = new FilterReport(filter.getFilterType(), 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -193,7 +192,7 @@ public void testMakeFrequencyFilterReport() { .of(FrequencySource.ESP_ALL, 100f), Frequency.of(FrequencySource.EXAC_OTHER, 100f))); variantEvaluations.add(mostCommonVariantEvalInTheWorld); - ImmutableList messages = ImmutableList.of("Variants filtered for maximum allele frequency of 0.00%"); + List messages = List.of("Variants filtered for maximum allele frequency of 0.00%"); FilterReport report = new FilterReport(filter.getFilterType(), 1, 1, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults(List.of(new FilterResultCount(filter.getFilterType(), 1, 1)))); @@ -236,7 +235,7 @@ public void testMakeQualityFilterReport() { Filter filter = new QualityFilter(100.0f); FilterType filterType = filter.getFilterType(); - ImmutableList messages = ImmutableList.of("Variants filtered for mimimum PHRED quality of 100.0"); + List messages = List.of("Variants filtered for mimimum PHRED quality of 100.0"); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -249,7 +248,7 @@ public void testMakePathogenicityFilterReportWhenRemovePathFilterCutOffIsTrue() Filter filter = new PathogenicityFilter(true); FilterType filterType = FilterType.PATHOGENICITY_FILTER; - ImmutableList messages = ImmutableList.of("Retained all non-pathogenic variants of all types. Scoring was applied, but the filter passed all variants."); + List messages = List.of("Retained all non-pathogenic variants of all types. Scoring was applied, but the filter passed all variants."); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -262,7 +261,7 @@ public void testMakePathogenicityFilterReportWhenRemovePathFilterCutOffIsNotSpec Filter filter = new PathogenicityFilter(false); FilterType filterType = FilterType.PATHOGENICITY_FILTER; - ImmutableList messages = ImmutableList.of("Retained all non-pathogenic missense variants"); + List messages = List.of("Retained all non-pathogenic missense variants"); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -276,7 +275,7 @@ public void testMakeIntervalFilterReport() { Filter filter = new IntervalFilter(interval); FilterType filterType = FilterType.INTERVAL_FILTER; - ImmutableList messages = ImmutableList.of("Restricted variants to interval:", "1:2-3"); + List messages = List.of("Restricted variants to interval:", "1:2-3"); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -297,7 +296,7 @@ public void testMakeIntervalFilterReportLotsOfIntervals() { Filter filter = new IntervalFilter(intervals); - ImmutableList messages = ImmutableList.of( + List messages = List.of( "Restricted variants to intervals:", "1:2-3", "2:2-3", @@ -317,7 +316,7 @@ public void testMakeInheritanceFilterReport() { Filter filter = new InheritanceFilter(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE); FilterType filterType = FilterType.INHERITANCE_FILTER; - ImmutableList messages = ImmutableList.of("Variants filtered for compatibility with AUTOSOMAL_DOMINANT, AUTOSOMAL_RECESSIVE inheritance."); + List messages = List.of("Variants filtered for compatibility with AUTOSOMAL_DOMINANT, AUTOSOMAL_RECESSIVE inheritance."); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); @@ -331,7 +330,7 @@ public void testMakePriorityScoreFilterReport() { Filter filter = new PriorityScoreFilter(PriorityType.PHIVE_PRIORITY, minimumPriorityScore); FilterType filterType = FilterType.PRIORITY_SCORE_FILTER; - ImmutableList messages = ImmutableList.of("Genes filtered for minimum PHIVE_PRIORITY score of 0.5"); + List messages = List.of("Genes filtered for minimum PHIVE_PRIORITY score of 0.5"); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportTest.java index da381a97d..6b98b35fe 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/FilterReportTest.java @@ -26,7 +26,6 @@ package org.monarchinitiative.exomiser.core.filters; -import com.google.common.collect.ImmutableList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,7 +51,7 @@ public class FilterReportTest { @BeforeEach public void setUp() { - instance = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, ImmutableList.of(MESSAGE)); + instance = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, List.of(MESSAGE)); } @Test @@ -92,7 +91,7 @@ public void testGetFailed() { @Test public void testHashCode() { - FilterReport other = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, ImmutableList.of(MESSAGE)); + FilterReport other = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, List.of(MESSAGE)); int expResult = other.hashCode(); assertThat(instance.hashCode(), equalTo(expResult)); @@ -124,7 +123,7 @@ public void testEqualsOtherFilterReportWithOtherPassFailIsFalse() { @Test public void testEqualsOtherFilterReport() { - FilterReport other = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, ImmutableList.of(MESSAGE)); + FilterReport other = new FilterReport(FilterType.FREQUENCY_FILTER, PASSED, FAILED, List.of(MESSAGE)); assertThat(instance.equals(other), is(true)); } @@ -142,9 +141,8 @@ public void testNotEqualsOtherFilterReportOfDifferentFilterType() { @Test public void testToString() { - String expResult = String.format("FilterReport for %s: pass:%d fail:%d %s", FilterType.FREQUENCY_FILTER, PASSED, FAILED, ImmutableList.of(MESSAGE)); + String expResult = String.format("FilterReport for %s: pass:%d fail:%d %s", FilterType.FREQUENCY_FILTER, PASSED, FAILED, List.of(MESSAGE)); assertThat(instance.toString(), equalTo(expResult)); - } } diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilterTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilterTest.java new file mode 100644 index 000000000..5e1ff663f --- /dev/null +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/GeneBlacklistFilterTest.java @@ -0,0 +1,56 @@ +package org.monarchinitiative.exomiser.core.filters; + +import org.junit.jupiter.api.Test; +import org.monarchinitiative.exomiser.core.genome.TestFactory; +import org.monarchinitiative.exomiser.core.model.VariantEvaluation; + + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.monarchinitiative.exomiser.core.filters.FilterType.GENE_BLACKLIST_FILTER; + +public class GeneBlacklistFilterTest { + + + private VariantEvaluation variantWithGeneSymbol(String geneSymbol) { + return TestFactory.variantBuilder(1,1,"A", "T").geneSymbol(geneSymbol).build(); + } + + @Test + public void testGetFilterType() { + GeneBlacklistFilter instance = new GeneBlacklistFilter(); + assertThat(instance.getFilterType(), equalTo(GENE_BLACKLIST_FILTER)); + } + + @Test + public void testFilterPassesWhenNoBlacklistedGeneInsideAnalysis() { + GeneBlacklistFilter instance = new GeneBlacklistFilter(); + FilterResult filterResult = instance.runFilter(variantWithGeneSymbol("DEF2")); + + FilterTestHelper.assertPassed(filterResult); + } + + @Test + public void testFilterFailsWhenBlacklistedGeneInsideAnalysis() { + VariantEvaluation failVariant = variantWithGeneSymbol("LINC02081"); + GeneBlacklistFilter instance = new GeneBlacklistFilter(); + FilterResult filterResult = instance.runFilter(failVariant); + + FilterTestHelper.assertFailed(filterResult); + } + @Test + public void testFilterPassesWhenNoGeneInsideAnalysis() { + VariantEvaluation emptyVariant = variantWithGeneSymbol(""); + GeneBlacklistFilter instance = new GeneBlacklistFilter(); + FilterResult filterResult = instance.runFilter(emptyVariant); + FilterTestHelper.assertPassed(filterResult); + } + + @Test + public void testEquals() { + GeneBlacklistFilter instance = new GeneBlacklistFilter(); + GeneBlacklistFilter instance2 = new GeneBlacklistFilter(); + + assertThat(instance, equalTo(instance2)); + } +} \ No newline at end of file diff --git a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/IntervalFilterTest.java b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/IntervalFilterTest.java index 0a1e9012f..959f2452b 100644 --- a/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/IntervalFilterTest.java +++ b/exomiser-core/src/test/java/org/monarchinitiative/exomiser/core/filters/IntervalFilterTest.java @@ -26,13 +26,14 @@ package org.monarchinitiative.exomiser.core.filters; -import com.google.common.collect.ImmutableList; import org.junit.jupiter.api.Test; import org.monarchinitiative.exomiser.core.genome.TestFactory; import org.monarchinitiative.exomiser.core.model.ChromosomalRegion; import org.monarchinitiative.exomiser.core.model.GeneticInterval; import org.monarchinitiative.exomiser.core.model.VariantEvaluation; +import java.util.List; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -92,7 +93,7 @@ public void multipleIntervals() { ChromosomalRegion interval3 = new GeneticInterval(3, 50, 60); ChromosomalRegion interval4 = new GeneticInterval(3, 51, 55); - IntervalFilter multiIntervalFilter = new IntervalFilter(ImmutableList.of(interval3, interval2, interval3, interval1, interval4)); + IntervalFilter multiIntervalFilter = new IntervalFilter(List.of(interval3, interval2, interval3, interval1, interval4)); FilterTestHelper.assertFailed(multiIntervalFilter.runFilter(TestFactory.variantBuilder(1, 19, "A", "T").build())); FilterTestHelper.assertPassed(multiIntervalFilter.runFilter(TestFactory.variantBuilder(1, 20, "A", "T").build())); @@ -103,12 +104,12 @@ public void multipleIntervals() { FilterTestHelper.assertFailed(multiIntervalFilter.runFilter(TestFactory.variantBuilder(2, 233, "A", "T").build())); - assertThat(multiIntervalFilter.getChromosomalRegions(), equalTo(ImmutableList.of(interval1, interval2, interval3, interval4))); + assertThat(multiIntervalFilter.getChromosomalRegions(), equalTo(List.of(interval1, interval2, interval3, interval4))); } @Test public void throwsExceptionWithEmptyInputList() { - assertThrows(IllegalStateException.class, () -> new IntervalFilter(ImmutableList.of())); + assertThrows(IllegalStateException.class, () -> new IntervalFilter(List.of())); } @Test