From 5a91653136abbf43ec0dfeb0d95af2d28b01fbd2 Mon Sep 17 00:00:00 2001 From: nkumar2 Date: Thu, 8 Aug 2024 12:39:53 +0100 Subject: [PATCH] refactor code - update names --- .../eva/pipeline/configuration/BeanNames.java | 10 ++--- ...a => VariantStatsReaderConfiguration.java} | 18 ++++----- ...a => VariantStatsWriterConfiguration.java} | 12 +++--- ...ateAndLoadStatisticsJobConfiguration.java} | 26 ++++++------- ...teAndLoadStatisticsStepConfiguration.java} | 38 +++++++++---------- ...> VariantStatsProcessorConfiguration.java} | 12 +++--- ...cessor.java => VariantStatsProcessor.java} | 10 ++--- ...antReader.java => VariantStatsReader.java} | 14 +++---- ...antWriter.java => VariantStatsWriter.java} | 6 +-- ...> CalculateAndLoadStatisticsStepTest.java} | 14 +++---- 10 files changed, 80 insertions(+), 80 deletions(-) rename src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/{StatsVariantsReaderConfiguration.java => VariantStatsReaderConfiguration.java} (75%) rename src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/{StatsVariantsWriterConfiguration.java => VariantStatsWriterConfiguration.java} (73%) rename src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/{PopulationStatisticsJobConfigurationNew.java => CalculateAndLoadStatisticsJobConfiguration.java} (74%) rename src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/{CalculateStatisticsStepConfigurationNew.java => CalculateAndLoadStatisticsStepConfiguration.java} (59%) rename src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/{StatsVariantsProcessorConfiguration.java => VariantStatsProcessorConfiguration.java} (74%) rename src/main/java/uk/ac/ebi/eva/pipeline/io/processors/{StatsVariantProcessor.java => VariantStatsProcessor.java} (96%) rename src/main/java/uk/ac/ebi/eva/pipeline/io/readers/{StatsVariantReader.java => VariantStatsReader.java} (89%) rename src/main/java/uk/ac/ebi/eva/pipeline/io/writers/{StatsVariantWriter.java => VariantStatsWriter.java} (91%) rename src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/{CalculateStatisticsStepTestNew.java => CalculateAndLoadStatisticsStepTest.java} (89%) diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/BeanNames.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/BeanNames.java index 14e876e7..dcacd048 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/BeanNames.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/BeanNames.java @@ -26,12 +26,12 @@ public class BeanNames { public static final String VARIANT_ANNOTATION_READER = "variant-annotation-reader"; public static final String VARIANT_READER = "variant-reader"; public static final String ACCESSION_REPORT_READER = "accession-report-reader"; - public static final String STATS_VARIANTS_READER = "stats-variants-reader"; + public static final String VARIANT_STATS_READER = "variant-stats-reader"; public static final String VEP_ANNOTATION_PROCESSOR = "vep-annotation-processor"; public static final String ANNOTATION_PARSER_PROCESSOR = "annotation-parser-processor"; public static final String ANNOTATION_COMPOSITE_PROCESSOR = "annotation-composite-processor"; - public static final String STATS_VARIANTS_PROCESSOR = "stats-variants-processor"; + public static final String VARIANT_STATS_PROCESSOR = "variant-stats-processor"; public static final String GENE_WRITER = "gene-writer"; public static final String ANNOTATION_WRITER = "annotation-writer"; @@ -39,7 +39,7 @@ public class BeanNames { public static final String COMPOSITE_ANNOTATION_VARIANT_WRITER = "composite-annotation-variant-writer"; public static final String VARIANT_WRITER = "variant-writer"; public static final String ACCESSION_IMPORTER = "accession-importer"; - public static final String STATS_VARIANTS_WRITER = "stats-variants-writer"; + public static final String VARIANT_STATS_WRITER = "variant-stats-writer"; public static final String ANNOTATION_SKIP_STEP_DECIDER = "annotation-skip-step-decider"; public static final String STATISTICS_SKIP_STEP_DECIDER = "statistics-skip-step-decider"; @@ -63,7 +63,7 @@ public class BeanNames { public static final String DROP_FILES_BY_STUDY_STEP = "drop-files-by-study-step"; public static final String LOAD_ANNOTATION_METADATA_STEP = "annotation-metadata-step"; public static final String ACCESSION_IMPORT_STEP = "accession-import-step"; - public static final String CALCULATE_STATISTICS_STEP_NEW = "calculate-statistics-step-new"; + public static final String CALCULATE_AND_LOAD_STATISTICS_STEP = "calculate-load-statistics-step"; public static final String AGGREGATED_VCF_JOB = "aggregated-vcf-job"; public static final String ANNOTATE_VARIANTS_JOB = "annotate-variants-job"; @@ -73,5 +73,5 @@ public class BeanNames { 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"; - public static final String CALCULATE_STATISTICS_JOB_NEW = "calculate-statistics-job-new"; + public static final String CALCULATE_AND_LOAD_STATISTICS_JOB = "calculate-load-statistics-job"; } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/StatsVariantsReaderConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/VariantStatsReaderConfiguration.java similarity index 75% rename from src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/StatsVariantsReaderConfiguration.java rename to src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/VariantStatsReaderConfiguration.java index 512a686c..5ef46b40 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/StatsVariantsReaderConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/VariantStatsReaderConfiguration.java @@ -21,23 +21,23 @@ 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.StatsVariantReader; +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.STATS_VARIANTS_READER; +import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_READER; @Configuration -public class StatsVariantsReaderConfiguration { +public class VariantStatsReaderConfiguration { - @Bean(STATS_VARIANTS_READER) + @Bean(VARIANT_STATS_READER) @StepScope - public ItemStreamReader statsVariantsReader(DatabaseParameters databaseParameters, - MongoTemplate mongoTemplate, - InputParameters inputParameters, - ChunkSizeParameters chunkSizeParameters) { + public ItemStreamReader variantStatsReader(DatabaseParameters databaseParameters, + MongoTemplate mongoTemplate, + InputParameters inputParameters, + ChunkSizeParameters chunkSizeParameters) { - return new StatsVariantReader(databaseParameters, mongoTemplate, inputParameters.getStudyId(), chunkSizeParameters.getChunkSize()); + return new VariantStatsReader(databaseParameters, mongoTemplate, inputParameters.getStudyId(), chunkSizeParameters.getChunkSize()); } } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/StatsVariantsWriterConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/VariantStatsWriterConfiguration.java similarity index 73% rename from src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/StatsVariantsWriterConfiguration.java rename to src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/VariantStatsWriterConfiguration.java index cc8ff0fe..84fb2390 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/StatsVariantsWriterConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/VariantStatsWriterConfiguration.java @@ -21,17 +21,17 @@ 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.StatsVariantWriter; +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.STATS_VARIANTS_WRITER; +import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_WRITER; @Configuration -public class StatsVariantsWriterConfiguration { +public class VariantStatsWriterConfiguration { - @Bean(STATS_VARIANTS_WRITER) + @Bean(VARIANT_STATS_WRITER) @StepScope - public ItemWriter statsVariantsWriter(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate) { - return new StatsVariantWriter(databaseParameters, mongoTemplate); + public ItemWriter variantStatsWriter(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate) { + return new VariantStatsWriter(databaseParameters, mongoTemplate); } } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/PopulationStatisticsJobConfigurationNew.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/CalculateAndLoadStatisticsJobConfiguration.java similarity index 74% rename from src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/PopulationStatisticsJobConfigurationNew.java rename to src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/CalculateAndLoadStatisticsJobConfiguration.java index 32308b01..ea85cefc 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/PopulationStatisticsJobConfigurationNew.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/CalculateAndLoadStatisticsJobConfiguration.java @@ -27,11 +27,11 @@ 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.CalculateStatisticsStepConfigurationNew; +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_STATISTICS_JOB_NEW; -import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.CALCULATE_STATISTICS_STEP_NEW; +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 @@ -40,24 +40,24 @@ */ @Configuration @EnableBatchProcessing -@Import({CalculateStatisticsStepConfigurationNew.class}) -public class PopulationStatisticsJobConfigurationNew { +@Import({CalculateAndLoadStatisticsStepConfiguration.class}) +public class CalculateAndLoadStatisticsJobConfiguration { - private static final Logger logger = LoggerFactory.getLogger(PopulationStatisticsJobConfigurationNew.class); + private static final Logger logger = LoggerFactory.getLogger(CalculateAndLoadStatisticsJobConfiguration.class); @Autowired - @Qualifier(CALCULATE_STATISTICS_STEP_NEW) - private Step calculateStatisticsStepNew; + @Qualifier(CALCULATE_AND_LOAD_STATISTICS_STEP) + private Step calculateAndLoadStatisticsStep; - @Bean(CALCULATE_STATISTICS_JOB_NEW) + @Bean(CALCULATE_AND_LOAD_STATISTICS_JOB) @Scope("prototype") - public Job calculateStatisticsJob(JobBuilderFactory jobBuilderFactory) { - logger.debug("Building '" + CALCULATE_STATISTICS_JOB_NEW + "'"); + public Job calculateAndLoadStatisticsJob(JobBuilderFactory jobBuilderFactory) { + logger.debug("Building '" + CALCULATE_AND_LOAD_STATISTICS_JOB + "'"); return jobBuilderFactory - .get(CALCULATE_STATISTICS_JOB_NEW) + .get(CALCULATE_AND_LOAD_STATISTICS_JOB) .incrementer(new NewJobIncrementer()) - .start(calculateStatisticsStepNew) + .start(calculateAndLoadStatisticsStep) .build(); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepConfigurationNew.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepConfiguration.java similarity index 59% rename from src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepConfigurationNew.java rename to src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepConfiguration.java index 0410b522..3aaa813e 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepConfigurationNew.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepConfiguration.java @@ -29,34 +29,34 @@ 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.StatsVariantsReaderConfiguration; -import uk.ac.ebi.eva.pipeline.configuration.io.writers.StatsVariantsWriterConfiguration; -import uk.ac.ebi.eva.pipeline.configuration.jobs.steps.processors.StatsVariantsProcessorConfiguration; +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_STATISTICS_STEP_NEW; -import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.STATS_VARIANTS_PROCESSOR; -import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.STATS_VARIANTS_READER; -import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.STATS_VARIANTS_WRITER; +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({StatsVariantsReaderConfiguration.class, StatsVariantsWriterConfiguration.class, - StatsVariantsProcessorConfiguration.class, ChunkSizeCompletionPolicyConfiguration.class}) -public class CalculateStatisticsStepConfigurationNew { +@Import({VariantStatsReaderConfiguration.class, VariantStatsWriterConfiguration.class, + VariantStatsProcessorConfiguration.class, ChunkSizeCompletionPolicyConfiguration.class}) +public class CalculateAndLoadStatisticsStepConfiguration { - @Bean(CALCULATE_STATISTICS_STEP_NEW) - public Step calculateStatisticsStep( - @Qualifier(STATS_VARIANTS_READER) ItemStreamReader variantReader, - @Qualifier(STATS_VARIANTS_PROCESSOR) ItemProcessor variantProcessor, - @Qualifier(STATS_VARIANTS_WRITER) ItemWriter variantWriter, + @Bean(CALCULATE_AND_LOAD_STATISTICS_STEP) + public Step calculateAndLoadStatisticsStep( + @Qualifier(VARIANT_STATS_READER) ItemStreamReader variantStatsReader, + @Qualifier(VARIANT_STATS_PROCESSOR) ItemProcessor variantStatsProcessor, + @Qualifier(VARIANT_STATS_WRITER) ItemWriter variantStatsWriter, StepBuilderFactory stepBuilderFactory, SimpleCompletionPolicy chunkSizeCompletionPolicy) { - TaskletStep step = stepBuilderFactory.get(CALCULATE_STATISTICS_STEP_NEW) + TaskletStep step = stepBuilderFactory.get(CALCULATE_AND_LOAD_STATISTICS_STEP) .chunk(chunkSizeCompletionPolicy) - .reader(variantReader) - .processor(variantProcessor) - .writer(variantWriter) + .reader(variantStatsReader) + .processor(variantStatsProcessor) + .writer(variantStatsWriter) .build(); return step; } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/StatsVariantsProcessorConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/VariantStatsProcessorConfiguration.java similarity index 74% rename from src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/StatsVariantsProcessorConfiguration.java rename to src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/VariantStatsProcessorConfiguration.java index 09e946de..23b1b92f 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/StatsVariantsProcessorConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/VariantStatsProcessorConfiguration.java @@ -20,16 +20,16 @@ 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.StatsVariantProcessor; +import uk.ac.ebi.eva.pipeline.io.processors.VariantStatsProcessor; -import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.STATS_VARIANTS_PROCESSOR; +import static uk.ac.ebi.eva.pipeline.configuration.BeanNames.VARIANT_STATS_PROCESSOR; @Configuration -public class StatsVariantsProcessorConfiguration { +public class VariantStatsProcessorConfiguration { - @Bean(STATS_VARIANTS_PROCESSOR) + @Bean(VARIANT_STATS_PROCESSOR) @StepScope - public ItemProcessor statsVariantsReader() { - return new StatsVariantProcessor(); + public ItemProcessor variantStatsProcessor() { + return new VariantStatsProcessor(); } } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/processors/StatsVariantProcessor.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/processors/VariantStatsProcessor.java similarity index 96% rename from src/main/java/uk/ac/ebi/eva/pipeline/io/processors/StatsVariantProcessor.java rename to src/main/java/uk/ac/ebi/eva/pipeline/io/processors/VariantStatsProcessor.java index 4e45c10a..6e510345 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/processors/StatsVariantProcessor.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/processors/VariantStatsProcessor.java @@ -9,7 +9,7 @@ import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantStatsMongo; -import uk.ac.ebi.eva.pipeline.io.readers.StatsVariantReader; +import uk.ac.ebi.eva.pipeline.io.readers.VariantStatsReader; import java.util.Arrays; import java.util.Comparator; @@ -21,8 +21,8 @@ import java.util.Set; import java.util.stream.Collectors; -public class StatsVariantProcessor implements ItemProcessor { - private static final Logger logger = LoggerFactory.getLogger(StatsVariantProcessor.class); +public class VariantStatsProcessor implements ItemProcessor { + private static final Logger logger = LoggerFactory.getLogger(VariantStatsProcessor.class); private static final String GENOTYPE_COUNTS_MAP = "genotypeCountsMap"; private static final String ALLELE_COUNTS_MAP = "alleleCountsMap"; private static final String MISSING_GENOTYPE = "missingGenotype"; @@ -30,12 +30,12 @@ public class StatsVariantProcessor implements ItemProcessor MISSING_GENOTYPE_ALLELE_REPRESENTATIONS = Arrays.asList(".", "-1"); - public StatsVariantProcessor() { + public VariantStatsProcessor() { } @Override public VariantDocument process(VariantDocument variant) { - Map filesIdNumberOfSamplesMap = StatsVariantReader.getFilesIdAndNumberOfSamplesMap(); + Map filesIdNumberOfSamplesMap = VariantStatsReader.getFilesIdAndNumberOfSamplesMap(); String variantRef = variant.getReference(); String variantAlt = variant.getAlternate(); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/StatsVariantReader.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantStatsReader.java similarity index 89% rename from src/main/java/uk/ac/ebi/eva/pipeline/io/readers/StatsVariantReader.java rename to src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantStatsReader.java index b71c63d3..c130fb7f 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/StatsVariantReader.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantStatsReader.java @@ -28,8 +28,8 @@ import static com.mongodb.client.model.Projections.fields; import static java.util.Arrays.asList; -public class StatsVariantReader implements ItemStreamReader { - private static final Logger logger = LoggerFactory.getLogger(StatsVariantReader.class); +public class VariantStatsReader implements ItemStreamReader { + private static final Logger logger = LoggerFactory.getLogger(VariantStatsReader.class); private DatabaseParameters databaseParameters; private MongoTemplate mongoTemplate; @@ -40,7 +40,7 @@ public class StatsVariantReader implements ItemStreamReader { private static Map filesIdNumberOfSamplesMap = new HashMap<>(); - public StatsVariantReader(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate, String studyId, int chunkSize) { + public VariantStatsReader(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate, String studyId, int chunkSize) { this.databaseParameters = databaseParameters; this.mongoTemplate = mongoTemplate; this.studyId = studyId; @@ -50,10 +50,10 @@ public StatsVariantReader(DatabaseParameters databaseParameters, MongoTemplate m @Override public VariantDocument read() { Document nextElement = cursor.tryNext(); - return (nextElement != null) ? getStatsVariant(nextElement) : null; + return (nextElement != null) ? getVariant(nextElement) : null; } - private VariantDocument getStatsVariant(Document variantDocument) { + private VariantDocument getVariant(Document variantDocument) { return converter.read(VariantDocument.class, new BasicDBObject(variantDocument)); } @@ -74,11 +74,11 @@ private MongoCursor initializeCursor() { Bson query = Filters.elemMatch(VariantDocument.FILES_FIELD, Filters.eq(VariantSourceEntryMongo.STUDYID_FIELD, studyId)); logger.info("Issuing find: {}", query); - FindIterable statsVariantDocuments = getStatsVariants(query); + FindIterable statsVariantDocuments = getVariants(query); return statsVariantDocuments.iterator(); } - private FindIterable getStatsVariants(Bson query) { + private FindIterable getVariants(Bson query) { return mongoTemplate.getCollection(databaseParameters.getCollectionVariantsName()) .find(query) .noCursorTimeout(true) diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/StatsVariantWriter.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantStatsWriter.java similarity index 91% rename from src/main/java/uk/ac/ebi/eva/pipeline/io/writers/StatsVariantWriter.java rename to src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantStatsWriter.java index 50c0fea6..6752dc6b 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/StatsVariantWriter.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantStatsWriter.java @@ -13,12 +13,12 @@ import java.util.List; -public class StatsVariantWriter implements ItemWriter { - private static final Logger logger = LoggerFactory.getLogger(StatsVariantWriter.class); +public class VariantStatsWriter implements ItemWriter { + private static final Logger logger = LoggerFactory.getLogger(VariantStatsWriter.class); private DatabaseParameters databaseParameters; private MongoTemplate mongoTemplate; - public StatsVariantWriter(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate) { + public VariantStatsWriter(DatabaseParameters databaseParameters, MongoTemplate mongoTemplate) { this.databaseParameters = databaseParameters; this.mongoTemplate = mongoTemplate; } diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepTestNew.java b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepTest.java similarity index 89% rename from src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepTestNew.java rename to src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepTest.java index 5e2b36ec..f44291f4 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateStatisticsStepTestNew.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/CalculateAndLoadStatisticsStepTest.java @@ -31,7 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner; import uk.ac.ebi.eva.pipeline.configuration.BeanNames; import uk.ac.ebi.eva.pipeline.configuration.MongoConfiguration; -import uk.ac.ebi.eva.pipeline.configuration.jobs.PopulationStatisticsJobConfigurationNew; +import uk.ac.ebi.eva.pipeline.configuration.jobs.CalculateAndLoadStatisticsJobConfiguration; import uk.ac.ebi.eva.test.configuration.BatchTestConfiguration; import uk.ac.ebi.eva.test.configuration.TemporaryRuleConfiguration; import uk.ac.ebi.eva.test.rules.PipelineTemporaryFolderRule; @@ -46,20 +46,20 @@ import static uk.ac.ebi.eva.test.utils.TestFileUtils.getResourceUrl; /** - * Test for {@link CalculateStatisticsStepConfigurationNew} + * Test for {@link CalculateAndLoadStatisticsStepConfiguration} */ @RunWith(SpringRunner.class) @TestPropertySource({"classpath:test-stats.properties"}) -@ContextConfiguration(classes = {PopulationStatisticsJobConfigurationNew.class, BatchTestConfiguration.class, +@ContextConfiguration(classes = {CalculateAndLoadStatisticsJobConfiguration.class, BatchTestConfiguration.class, TemporaryRuleConfiguration.class, MongoConfiguration.class}) -public class CalculateStatisticsStepTestNew { +public class CalculateAndLoadStatisticsStepTest { private static final String MONGO_DUMP = "/dump/VariantStatsConfigurationTest_vl"; private static final String COLLECTION_VARIANTS_NAME = "variants"; private static final String COLLECTION_FILES_NAME = "files"; - private static final String DATABASE_NAME = "calculate_stats_test_db_new"; + private static final String DATABASE_NAME = "calculate_load_stats_test_db"; private static final String STUDY_ID = "1"; @@ -85,7 +85,7 @@ public void cleanUp() { } @Test - public void statisticsGeneratorStepShouldCalculateStats() { + public void calculateAndLoadStatisticsStepShouldCalculateAndLoadStats() { JobParameters jobParameters = new EvaJobParameterBuilder() .collectionFilesName(COLLECTION_FILES_NAME) .collectionVariantsName(COLLECTION_VARIANTS_NAME) @@ -94,7 +94,7 @@ public void statisticsGeneratorStepShouldCalculateStats() { .chunkSize("100") .toJobParameters(); - JobExecution jobExecution = jobLauncherTestUtils.launchStep(BeanNames.CALCULATE_STATISTICS_STEP_NEW, jobParameters); + JobExecution jobExecution = jobLauncherTestUtils.launchStep(BeanNames.CALCULATE_AND_LOAD_STATISTICS_STEP, jobParameters); // check job completed successfully assertCompleted(jobExecution);