diff --git a/exomiser-cli/src/main/java/org/monarchinitiative/exomiser/cli/Main.java b/exomiser-cli/src/main/java/org/monarchinitiative/exomiser/cli/Main.java index 77093bbd6..06e473863 100644 --- a/exomiser-cli/src/main/java/org/monarchinitiative/exomiser/cli/Main.java +++ b/exomiser-cli/src/main/java/org/monarchinitiative/exomiser/cli/Main.java @@ -1,7 +1,7 @@ /* * The Exomiser - A tool to annotate and prioritize genomic variants * - * Copyright (c) 2016-2020 Queen Mary University of London. + * Copyright (c) 2016-2021 Queen Mary University of London. * Copyright (c) 2012-2016 Charité Universitätsmedizin Berlin and Genome Research Ltd. * * This program is free software: you can redistribute it and/or modify @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import java.util.Locale; @@ -33,7 +34,7 @@ * * @author Jules Jacobsen */ -@SpringBootApplication +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class Main { private static final Logger logger = LoggerFactory.getLogger(Main.class); diff --git a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/AbstractGenomeProperties.java b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/AbstractGenomeProperties.java index e58609e80..9511c3d77 100644 --- a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/AbstractGenomeProperties.java +++ b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/AbstractGenomeProperties.java @@ -51,6 +51,10 @@ public abstract class AbstractGenomeProperties implements GenomeProperties { // datastore private String testPathogenicityScorePath = ""; + protected AbstractGenomeProperties(GenomeAssembly assembly) { + this.assembly = assembly; + } + @Override public Path getDataDirectory() { return dataDirectory; @@ -61,10 +65,6 @@ public void setDataDirectory(String dataDirectory) { this.dataDirectory = Paths.get(dataDirectory); } - public AbstractGenomeProperties(GenomeAssembly assembly) { - this.assembly = assembly; - } - public GenomeAssembly getAssembly() { return assembly; } diff --git a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeProperties.java b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeProperties.java index 1c15e108b..773e914fc 100644 --- a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeProperties.java +++ b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeProperties.java @@ -26,7 +26,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; /** * @author Jules Jacobsen @@ -44,17 +43,20 @@ public Hg19GenomeProperties() { // the default configuration is contained in the application.properties shipped in the jar's classpath // this can be overridden by the user in their own application.properties. - @Primary @Bean @ConfigurationProperties("exomiser.hg19.genome.datasource") public DataSourceProperties hg19genomeDataSourceProperties() { return new DataSourceProperties(); } - @Primary - @Bean(name = "hg19genomeDataSource") + @Bean @ConfigurationProperties("exomiser.hg19.genome.datasource.hikari") + public HikariDataSource hg19genomeDataSource(DataSourceProperties hg19genomeDataSourceProperties) { + return hg19genomeDataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); + } + + @Override public HikariDataSource genomeDataSource() { - return hg19genomeDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); + return hg19genomeDataSource(hg19genomeDataSourceProperties()); } } diff --git a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeProperties.java b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeProperties.java index 46762d9e7..6c419c108 100644 --- a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeProperties.java +++ b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeProperties.java @@ -44,10 +44,14 @@ public DataSourceProperties hg38genomeDataSourceProperties() { return new DataSourceProperties(); } - @Bean(name = "hg38genomeDataSource") + @Bean @ConfigurationProperties("exomiser.hg38.genome.datasource.hikari") - public HikariDataSource genomeDataSource() { - return hg38genomeDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); + public HikariDataSource hg38genomeDataSource(DataSourceProperties hg38genomeDataSourceProperties) { + return hg38genomeDataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); } + @Override + public HikariDataSource genomeDataSource() { + return hg38genomeDataSource(hg38genomeDataSourceProperties()); + } } diff --git a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PhenotypeProperties.java b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PhenotypeProperties.java index 06c7f9dd3..9feff4ce4 100644 --- a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PhenotypeProperties.java +++ b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PhenotypeProperties.java @@ -1,7 +1,7 @@ /* * The Exomiser - A tool to annotate and prioritize genomic variants * - * Copyright (c) 2016-2019 Queen Mary University of London. + * Copyright (c) 2016-2021 Queen Mary University of London. * Copyright (c) 2012-2016 Charité Universitätsmedizin Berlin and Genome Research Ltd. * * This program is free software: you can redistribute it and/or modify @@ -48,10 +48,10 @@ public DataSourceProperties phenotypeDataSourceProperties() { return new DataSourceProperties(); } - @Bean(name = "phenotypeDataSource") + @Bean @ConfigurationProperties("exomiser.phenotype.datasource.hikari") - public HikariDataSource phenotypeDataSource() { - return phenotypeDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); + public HikariDataSource phenotypeDataSource(DataSourceProperties phenotypeDataSourceProperties) { + return phenotypeDataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); } //Random walk matrix for hiPhive and exomeWalker diff --git a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/ExomiserAutoConfigurationTest.java b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/ExomiserAutoConfigurationTest.java index 6580e7e99..c89e2ebc3 100644 --- a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/ExomiserAutoConfigurationTest.java +++ b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/ExomiserAutoConfigurationTest.java @@ -20,7 +20,6 @@ package org.monarchinitiative.exomiser.autoconfigure; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.monarchinitiative.exomiser.core.Exomiser; import org.monarchinitiative.exomiser.core.genome.GenomeAnalysisServiceProvider; @@ -43,7 +42,6 @@ public class ExomiserAutoConfigurationTest extends AbstractAutoConfigurationTest // n.b there are issues with the @PreDestroy shutdown hooks for classes in the GenomeAnalysisServiceConfigurer using the MVStore // so all the relevant beans are being tested in one go - @Disabled("File lock exception when run as part of full test suite") @Test public void testAutoConfiguration() { load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg19.data-version=1710", "exomiser.hg38.data-version=1710", "exomiser.phenotype.data-version=1710"); @@ -59,6 +57,36 @@ public void testAutoConfiguration() { assertThat(phenotypeMatchService, instanceOf(PhenotypeMatchService.class)); } + @Test + public void testHg19OnlyAutoConfiguration() { + load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg19.data-version=1710", "exomiser.phenotype.data-version=1710"); + Exomiser exomiser = (Exomiser) context.getBean("exomiser"); + assertThat(exomiser, instanceOf(Exomiser.class)); + + GenomeAnalysisServiceProvider genomeAnalysisServiceProvider = (GenomeAnalysisServiceProvider) context.getBean("genomeAnalysisServiceProvider"); + assertThat(genomeAnalysisServiceProvider, instanceOf(GenomeAnalysisServiceProvider.class)); + assertThat(genomeAnalysisServiceProvider.hasServiceFor(GenomeAssembly.HG19), is(true)); + assertThat(genomeAnalysisServiceProvider.hasServiceFor(GenomeAssembly.HG38), is(false)); + + PhenotypeMatchService phenotypeMatchService = (PhenotypeMatchService) context.getBean("phenotypeMatchService"); + assertThat(phenotypeMatchService, instanceOf(PhenotypeMatchService.class)); + } + + @Test + public void testHg38OnlyAutoConfiguration() { + load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg38.data-version=1710", "exomiser.phenotype.data-version=1710"); + Exomiser exomiser = (Exomiser) context.getBean("exomiser"); + assertThat(exomiser, instanceOf(Exomiser.class)); + + GenomeAnalysisServiceProvider genomeAnalysisServiceProvider = (GenomeAnalysisServiceProvider) context.getBean("genomeAnalysisServiceProvider"); + assertThat(genomeAnalysisServiceProvider, instanceOf(GenomeAnalysisServiceProvider.class)); + assertThat(genomeAnalysisServiceProvider.hasServiceFor(GenomeAssembly.HG19), is(false)); + assertThat(genomeAnalysisServiceProvider.hasServiceFor(GenomeAssembly.HG38), is(true)); + + PhenotypeMatchService phenotypeMatchService = (PhenotypeMatchService) context.getBean("phenotypeMatchService"); + assertThat(phenotypeMatchService, instanceOf(PhenotypeMatchService.class)); + } + @Configuration @ImportAutoConfiguration(value = ExomiserAutoConfiguration.class) protected static class EmptyConfiguration { diff --git a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeAnalysisServiceAutoConfigurationTest.java b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeAnalysisServiceAutoConfigurationTest.java index 083422025..81dfcc3a1 100644 --- a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeAnalysisServiceAutoConfigurationTest.java +++ b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg19GenomeAnalysisServiceAutoConfigurationTest.java @@ -39,11 +39,11 @@ public class Hg19GenomeAnalysisServiceAutoConfigurationTest extends AbstractAutoConfigurationTest { @Test - public synchronized void genomeAnalysisService() throws Exception { + public void genomeAnalysisService() throws Exception { - load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg19.data-version=1710", "exomiser.hg19.local-frequency-path=../local/local_freq.tsv.gz"); + load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg19.data-version=1710"); - GenomeAnalysisService genomeAnalysisService = (GenomeAnalysisService) this.context.getBean("hg19genomeAnalysisService"); + GenomeAnalysisService genomeAnalysisService = (GenomeAnalysisService) context.getBean("hg19genomeAnalysisService"); assertThat(genomeAnalysisService.getGenomeAssembly(), equalTo(GenomeAssembly.HG19)); assertThat(context.getBean("hg19jannovarData"), instanceOf(JannovarData.class)); @@ -60,7 +60,7 @@ public synchronized void genomeAnalysisService() throws Exception { } @Test - public synchronized void genomeAnalysisServiceWithOptionalTestPathDao() throws Exception { + public void genomeAnalysisServiceWithOptionalTestPathDao() throws Exception { String testPathogenicitySourcePath = TEST_DATA.resolve("remm/remmData.tsv.gz").toAbsolutePath().toString(); load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg19.data-version=1710", "exomiser.hg19.test-pathogenicity-score-path=" + testPathogenicitySourcePath); diff --git a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeAnalysisServiceAutoConfigurationTest.java b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeAnalysisServiceAutoConfigurationTest.java index f85e130b4..20b79213a 100644 --- a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeAnalysisServiceAutoConfigurationTest.java +++ b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/Hg38GenomeAnalysisServiceAutoConfigurationTest.java @@ -43,7 +43,7 @@ public void genomeAnalysisService() throws Exception { load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg38.data-version=1710"); - GenomeAnalysisService genomeAnalysisService = (GenomeAnalysisService) this.context.getBean("hg38genomeAnalysisService"); + GenomeAnalysisService genomeAnalysisService = (GenomeAnalysisService) context.getBean("hg38genomeAnalysisService"); assertThat(genomeAnalysisService.getGenomeAssembly(), equalTo(GenomeAssembly.HG38)); assertThat(context.getBean("hg38jannovarData"), instanceOf(JannovarData.class)); @@ -61,6 +61,7 @@ public void genomeAnalysisService() throws Exception { @Test public void genomeAnalysisServiceWithOptionalTestPathDao() throws Exception { + String testPathogenicitySourcePath = TEST_DATA.resolve("remm/remmData.tsv.gz").toAbsolutePath().toString(); load(EmptyConfiguration.class, TEST_DATA_ENV, "exomiser.hg38.data-version=1710", "exomiser.hg38.test-pathogenicity-score-path=" + testPathogenicitySourcePath); diff --git a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PrioritiserAutoConfigurationTest.java b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PrioritiserAutoConfigurationTest.java index 855ffeb12..896f211e7 100644 --- a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PrioritiserAutoConfigurationTest.java +++ b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/phenotype/PrioritiserAutoConfigurationTest.java @@ -1,7 +1,7 @@ /* * The Exomiser - A tool to annotate and prioritize genomic variants * - * Copyright (c) 2016-2020 Queen Mary University of London. + * Copyright (c) 2016-2021 Queen Mary University of London. * Copyright (c) 2012-2016 Charité Universitätsmedizin Berlin and Genome Research Ltd. * * This program is free software: you can redistribute it and/or modify @@ -20,7 +20,6 @@ package org.monarchinitiative.exomiser.autoconfigure.phenotype; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.monarchinitiative.exomiser.autoconfigure.AbstractAutoConfigurationTest; import org.monarchinitiative.exomiser.autoconfigure.DataDirectoryAutoConfiguration; @@ -59,11 +58,9 @@ public void onlyLoadsWhenPhenotypeDataVersionIsPresent() { assertThat(context.getBean("phenotypeDataDirectory"), not(nullValue())); } - //this works in prod, but fails to autowire the phenotypeDataSource in test, despite being able to load the dataSource. - @Disabled @Test public void canDefinePhenotypeDataDirectory() { - Path definedDir = TEST_DATA.resolve("user-defined"); + Path definedDir = TEST_DATA.resolve("1710_phenotype"); load(EmptyConfiguration.class, TEST_DATA_ENV, DATA_VERSION, "exomiser.phenotype.data-directory=" + definedDir); Path phenotypeDataDirectory = (Path) this.context.getBean("phenotypeDataDirectory"); assertThat(phenotypeDataDirectory, equalTo(definedDir));