From 0ae40221e66382ac330748c3eefe916de5e26975 Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Tue, 16 Jul 2024 22:16:45 +0200 Subject: [PATCH] feat: set the default sequence when there is only a single sequence in the reference genomes closes #454 --- include/silo/preprocessing/preprocessor.h | 1 + src/silo/preprocessing/preprocessor.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/silo/preprocessing/preprocessor.h b/include/silo/preprocessing/preprocessor.h index 3bce03cde..446bb6666 100644 --- a/include/silo/preprocessing/preprocessor.h +++ b/include/silo/preprocessing/preprocessor.h @@ -43,6 +43,7 @@ class Preprocessor { Database preprocess(); private: + void finalizeConfig(); void validateConfig(); static std::string makeNonNullKey(const std::string& field); diff --git a/src/silo/preprocessing/preprocessor.cpp b/src/silo/preprocessing/preprocessor.cpp index 74a963fb6..fca68c830 100644 --- a/src/silo/preprocessing/preprocessor.cpp +++ b/src/silo/preprocessing/preprocessor.cpp @@ -63,7 +63,7 @@ Preprocessor::Preprocessor( } Database Preprocessor::preprocess() { - validateConfig(); + finalizeConfig(); SPDLOG_INFO( "preprocessing - creating intermediate results directory '{}'", @@ -128,6 +128,17 @@ Database Preprocessor::preprocess() { ); } +void Preprocessor::finalizeConfig() { + if (nuc_sequences.size() == 1 && !database_config.default_nucleotide_sequence.has_value()) { + database_config.default_nucleotide_sequence = nuc_sequences.at(0); + } + if (aa_sequences.size() == 1 && !database_config.default_amino_acid_sequence.has_value()) { + database_config.default_amino_acid_sequence = aa_sequences.at(0); + } + + validateConfig(); +} + void Preprocessor::validateConfig() { const bool default_nucleotide_sequence_is_not_in_reference = database_config.default_nucleotide_sequence.has_value() &&