-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVA-3571 New stats calculator (#196)
* Added new stats calculator
- Loading branch information
Showing
16 changed files
with
771 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...java/uk/ac/ebi/eva/pipeline/configuration/io/readers/VariantStatsReaderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 EMBL - European Bioinformatics Institute | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.ac.ebi.eva.pipeline.configuration.io.readers; | ||
|
||
import org.springframework.batch.core.configuration.annotation.StepScope; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; | ||
import uk.ac.ebi.eva.pipeline.io.readers.VariantStatsReader; | ||
import uk.ac.ebi.eva.pipeline.parameters.ChunkSizeParameters; | ||
import uk.ac.ebi.eva.pipeline.parameters.DatabaseParameters; | ||
import uk.ac.ebi.eva.pipeline.parameters.InputParameters; | ||
|
||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_READER; | ||
|
||
@Configuration | ||
public class VariantStatsReaderConfiguration { | ||
|
||
@Bean(VARIANT_STATS_READER) | ||
@StepScope | ||
public ItemStreamReader<VariantDocument> variantStatsReader(DatabaseParameters databaseParameters, | ||
MongoTemplate mongoTemplate, | ||
InputParameters inputParameters, | ||
ChunkSizeParameters chunkSizeParameters) { | ||
|
||
return new VariantStatsReader(databaseParameters, mongoTemplate, inputParameters.getStudyId(), chunkSizeParameters.getChunkSize()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...java/uk/ac/ebi/eva/pipeline/configuration/io/writers/VariantStatsWriterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2024 EMBL - European Bioinformatics Institute | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.ac.ebi.eva.pipeline.configuration.io.writers; | ||
|
||
import org.springframework.batch.core.configuration.annotation.StepScope; | ||
import org.springframework.batch.item.ItemWriter; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; | ||
import uk.ac.ebi.eva.pipeline.io.writers.VariantStatsWriter; | ||
import uk.ac.ebi.eva.pipeline.parameters.DatabaseParameters; | ||
|
||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_WRITER; | ||
|
||
@Configuration | ||
public class VariantStatsWriterConfiguration { | ||
|
||
@Bean(VARIANT_STATS_WRITER) | ||
@StepScope | ||
public ItemWriter<VariantDocument> variantStatsWriter(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate) { | ||
return new VariantStatsWriter(databaseParameters, mongoTemplate); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...uk/ac/ebi/eva/pipeline/configuration/jobs/CalculateAndLoadStatisticsJobConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2024 EMBL - European Bioinformatics Institute | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.ac.ebi.eva.pipeline.configuration.jobs; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.Scope; | ||
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.CalculateAndLoadStatisticsStepConfiguration; | ||
import uk.ac.ebi.eva.pipeline.parameters.NewJobIncrementer; | ||
|
||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.CALCULATE_AND_LOAD_STATISTICS_JOB; | ||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.CALCULATE_AND_LOAD_STATISTICS_STEP; | ||
|
||
/** | ||
* Configuration to run a full Statistics job: variantStatsFlow: statsCreate --> statsLoad | ||
* <p> | ||
* TODO add a new PopulationStatisticsJobParametersValidator | ||
*/ | ||
@Configuration | ||
@EnableBatchProcessing | ||
@Import({CalculateAndLoadStatisticsStepConfiguration.class}) | ||
public class CalculateAndLoadStatisticsJobConfiguration { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(CalculateAndLoadStatisticsJobConfiguration.class); | ||
|
||
@Autowired | ||
@Qualifier(CALCULATE_AND_LOAD_STATISTICS_STEP) | ||
private Step calculateAndLoadStatisticsStep; | ||
|
||
@Bean(CALCULATE_AND_LOAD_STATISTICS_JOB) | ||
@Scope("prototype") | ||
public Job calculateAndLoadStatisticsJob(JobBuilderFactory jobBuilderFactory) { | ||
logger.debug("Building '" + CALCULATE_AND_LOAD_STATISTICS_JOB + "'"); | ||
|
||
return jobBuilderFactory | ||
.get(CALCULATE_AND_LOAD_STATISTICS_JOB) | ||
.incrementer(new NewJobIncrementer()) | ||
.start(calculateAndLoadStatisticsStep) | ||
.build(); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...bi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2024 EMBL - European Bioinformatics Institute | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.ac.ebi.eva.pipeline.configuration.jobs.steps; | ||
|
||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; | ||
import org.springframework.batch.core.step.tasklet.TaskletStep; | ||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.batch.item.ItemWriter; | ||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; | ||
import uk.ac.ebi.eva.pipeline.configuration.ChunkSizeCompletionPolicyConfiguration; | ||
import uk.ac.ebi.eva.pipeline.configuration.io.readers.VariantStatsReaderConfiguration; | ||
import uk.ac.ebi.eva.pipeline.configuration.io.writers.VariantStatsWriterConfiguration; | ||
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.processors.VariantStatsProcessorConfiguration; | ||
|
||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.CALCULATE_AND_LOAD_STATISTICS_STEP; | ||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_PROCESSOR; | ||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_READER; | ||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_WRITER; | ||
|
||
|
||
@Configuration | ||
@EnableBatchProcessing | ||
@Import({VariantStatsReaderConfiguration.class, VariantStatsWriterConfiguration.class, | ||
VariantStatsProcessorConfiguration.class, ChunkSizeCompletionPolicyConfiguration.class}) | ||
public class CalculateAndLoadStatisticsStepConfiguration { | ||
|
||
@Bean(CALCULATE_AND_LOAD_STATISTICS_STEP) | ||
public Step calculateAndLoadStatisticsStep( | ||
@Qualifier(VARIANT_STATS_READER) ItemStreamReader<VariantDocument> variantStatsReader, | ||
@Qualifier(VARIANT_STATS_PROCESSOR) ItemProcessor<VariantDocument, VariantDocument> variantStatsProcessor, | ||
@Qualifier(VARIANT_STATS_WRITER) ItemWriter<VariantDocument> variantStatsWriter, | ||
StepBuilderFactory stepBuilderFactory, | ||
SimpleCompletionPolicy chunkSizeCompletionPolicy) { | ||
TaskletStep step = stepBuilderFactory.get(CALCULATE_AND_LOAD_STATISTICS_STEP) | ||
.<VariantDocument, VariantDocument>chunk(chunkSizeCompletionPolicy) | ||
.reader(variantStatsReader) | ||
.processor(variantStatsProcessor) | ||
.writer(variantStatsWriter) | ||
.build(); | ||
return step; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../eva/pipeline/configuration/jobs/steps/processors/VariantStatsProcessorConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2024 EMBL - European Bioinformatics Institute | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.ac.ebi.eva.pipeline.configuration.jobs.steps.processors; | ||
|
||
import org.springframework.batch.core.configuration.annotation.StepScope; | ||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; | ||
import uk.ac.ebi.eva.pipeline.io.processors.VariantStatsProcessor; | ||
|
||
import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_PROCESSOR; | ||
|
||
@Configuration | ||
public class VariantStatsProcessorConfiguration { | ||
|
||
@Bean(VARIANT_STATS_PROCESSOR) | ||
@StepScope | ||
public ItemProcessor<VariantDocument, VariantDocument> variantStatsProcessor() { | ||
return new VariantStatsProcessor(); | ||
} | ||
} |
Oops, something went wrong.