Skip to content

Commit

Permalink
feat: set the default sequence when there is only a single sequence i…
Browse files Browse the repository at this point in the history
…n the reference genomes

closes #454
  • Loading branch information
fengelniederhammer committed Jul 18, 2024
1 parent 287bb8b commit 0ae4022
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/silo/preprocessing/preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Preprocessor {
Database preprocess();

private:
void finalizeConfig();
void validateConfig();

static std::string makeNonNullKey(const std::string& field);
Expand Down
13 changes: 12 additions & 1 deletion src/silo/preprocessing/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Preprocessor::Preprocessor(
}

Database Preprocessor::preprocess() {
validateConfig();
finalizeConfig();

SPDLOG_INFO(
"preprocessing - creating intermediate results directory '{}'",
Expand Down Expand Up @@ -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() &&
Expand Down

0 comments on commit 0ae4022

Please sign in to comment.