Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVA-3455 - Job specific to variantLoad #194

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ public class BeanNames {
public static final String ACCESSION_IMPORT_STEP = "accession-import-step";

public static final String AGGREGATED_VCF_JOB = "aggregated-vcf-job";
public static final String AGGREGATED_VARIANT_LOAD_VCF_JOB = "aggregated-variant-load-vcf-job";
tcezard marked this conversation as resolved.
Show resolved Hide resolved
public static final String ANNOTATE_VARIANTS_JOB = "annotate-variants-job";
public static final String INIT_DATABASE_JOB = "init-database-job";
public static final String GENOTYPED_VCF_JOB = "genotyped-vcf-job";
public static final String GENOTYPED_VARIANT_LOAD_VCF_JOB = "genotyped-variant-load-vcf-job";
public static final String CALCULATE_STATISTICS_JOB = "calculate-statistics-job";
public static final String DROP_STUDY_JOB = "drop-study-job";
public static final String ACCESSION_IMPORT_JOB = "accession-import-job";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2015-2017 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.batch.core.job.builder.FlowJobBuilder;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.job.flow.Flow;
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.flows.AnnotationFlowOptionalConfiguration;
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.LoadFileStepConfiguration;
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.LoadVariantsStepConfiguration;
import uk.ac.ebi.eva.pipeline.parameters.NewJobIncrementer;
import uk.ac.ebi.eva.pipeline.parameters.validation.job.VariantLoadVcfJobParametersValidator;

import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.*;

/**
* Complete pipeline workflow for aggregated VCF. Aggregated statistics are provided in the VCF instead of the
* genotypes.
* <p>
* load --> (optionalAnnotationFlow: variantsAnnotGenerateInput --> (annotationCreate --> annotationLoad))
apriltuesday marked this conversation as resolved.
Show resolved Hide resolved
* <p>
* Steps in () are optional
*/
@Configuration
@EnableBatchProcessing
@Import({LoadVariantsStepConfiguration.class, LoadFileStepConfiguration.class, AnnotationFlowOptionalConfiguration.class})
tcezard marked this conversation as resolved.
Show resolved Hide resolved
public class AggregatedVariantLoadVcfJobConfiguration {

private static final Logger logger = LoggerFactory.getLogger(AggregatedVariantLoadVcfJobConfiguration.class);

@Autowired
@Qualifier(VEP_ANNOTATION_OPTIONAL_FLOW)
private Flow annotationFlowOptional;
tcezard marked this conversation as resolved.
Show resolved Hide resolved

@Autowired
@Qualifier(LOAD_VARIANTS_STEP)
private Step variantLoaderStep;

@Autowired
@Qualifier(LOAD_FILE_STEP)
private Step loadFileStep;

@Bean(AGGREGATED_VARIANT_LOAD_VCF_JOB)
@Scope("prototype")
public Job aggregatedVcfJob(JobBuilderFactory jobBuilderFactory) {
logger.debug("Building '" + AGGREGATED_VARIANT_LOAD_VCF_JOB + "'");

JobBuilder jobBuilder = jobBuilderFactory
.get(AGGREGATED_VARIANT_LOAD_VCF_JOB)
.incrementer(new NewJobIncrementer())
.validator(new VariantLoadVcfJobParametersValidator());
FlowJobBuilder builder = jobBuilder
.flow(variantLoaderStep)
.next(loadFileStep)
.end();

return builder.build();
}
}
apriltuesday marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2015-2017 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.batch.core.job.builder.FlowJobBuilder;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.job.flow.Flow;
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.flows.ParallelStatisticsAndAnnotationFlowConfiguration;
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.LoadFileStepConfiguration;
import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.LoadVariantsStepConfiguration;
import uk.ac.ebi.eva.pipeline.parameters.NewJobIncrementer;
import uk.ac.ebi.eva.pipeline.parameters.validation.job.GenotypedVcfJobParametersValidator;
import uk.ac.ebi.eva.pipeline.parameters.validation.job.VariantLoadVcfJobParametersValidator;

import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.*;

/**
* Variant load pipeline workflow:
* <p>
* |--> (optionalStatisticsFlow: statsCreate --> statsLoad)
* transform ---> load -+
* |--> (optionalAnnotationFlow: variantsAnnotGenerateInput --> (annotationCreate --> annotationLoad))
* <p>
* Steps in () are optional
*/
@Configuration
@EnableBatchProcessing
@Import({LoadVariantsStepConfiguration.class, LoadFileStepConfiguration.class, ParallelStatisticsAndAnnotationFlowConfiguration.class})
public class GenotypedVariantLoadVcfJobConfiguration {

private static final Logger logger = LoggerFactory.getLogger(GenotypedVariantLoadVcfJobConfiguration.class);

@Autowired
@Qualifier(PARALLEL_STATISTICS_AND_ANNOTATION)
private Flow parallelStatisticsAndAnnotation;

@Autowired
@Qualifier(LOAD_VARIANTS_STEP)
private Step variantLoaderStep;

@Autowired
@Qualifier(LOAD_FILE_STEP)
private Step loadFileStep;

@Bean(GENOTYPED_VARIANT_LOAD_VCF_JOB)
@Scope("prototype")
public Job genotypedVcfJob(JobBuilderFactory jobBuilderFactory) {
logger.debug("Building '" + GENOTYPED_VARIANT_LOAD_VCF_JOB + "'");

JobBuilder jobBuilder = jobBuilderFactory
.get(GENOTYPED_VARIANT_LOAD_VCF_JOB)
.incrementer(new NewJobIncrementer())
.validator(new VariantLoadVcfJobParametersValidator());
FlowJobBuilder builder = jobBuilder
.flow(variantLoaderStep)
.next(loadFileStep)
.end();

return builder.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2017 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.parameters.validation.job;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.batch.core.job.CompositeJobParametersValidator;
import org.springframework.batch.core.job.DefaultJobParametersValidator;
import uk.ac.ebi.eva.pipeline.configuration.jobs.GenotypedVariantLoadVcfJobConfiguration;
import uk.ac.ebi.eva.pipeline.configuration.jobs.AggregatedVcfJobConfiguration;
import uk.ac.ebi.eva.pipeline.parameters.validation.step.*;

import java.util.ArrayList;
import java.util.List;

/**
* Validates the job parameters necessary to execute an {@link GenotypedVariantLoadVcfJobConfiguration}
* or an {@link AggregatedVcfJobConfiguration}
*/
public class VariantLoadVcfJobParametersValidator extends DefaultJobParametersValidator {

@Override
public void validate(JobParameters parameters) throws JobParametersInvalidException {
compositeJobParametersValidator(parameters).validate(parameters);
}

private CompositeJobParametersValidator compositeJobParametersValidator(JobParameters jobParameters) {
List<JobParametersValidator> jobParametersValidators = new ArrayList<>();

jobParametersValidators.add(new LoadVariantsStepParametersValidator());
jobParametersValidators.add(new LoadFileStepParametersValidator());

CompositeJobParametersValidator compositeJobParametersValidator = new CompositeJobParametersValidator();
compositeJobParametersValidator.setValidators(jobParametersValidators);
return compositeJobParametersValidator;
}

}
Loading