-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix: nucleotide symbol equals with dot #341
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,72 @@ | ||
#include <nlohmann/json.hpp> | ||
|
||
#include "silo/test/query_fixture.test.h" | ||
|
||
using silo::ReferenceGenomes; | ||
using silo::config::DatabaseConfig; | ||
using silo::config::ValueType; | ||
using silo::test::QueryTestData; | ||
using silo::test::QueryTestScenario; | ||
|
||
#include <boost/uuid/uuid_generators.hpp> | ||
#include <boost/uuid/uuid_io.hpp> | ||
|
||
using boost::uuids::random_generator; | ||
|
||
nlohmann::json createDataWithNucleotideSequence(const std::string& nucleotideSequence) { | ||
random_generator generator; | ||
const auto request_id = generator(); | ||
|
||
return { | ||
{"metadata", {{"primaryKey", "id_" + to_string(request_id)}}}, | ||
{"alignedNucleotideSequences", {{"segment1", nucleotideSequence}}}, | ||
{"unalignedNucleotideSequences", {{"segment1", nullptr}}}, | ||
{"alignedAminoAcidSequences", {{"gene1", nullptr}}} | ||
}; | ||
} | ||
const nlohmann::json DATA_SAME_AS_REFERENCE = createDataWithNucleotideSequence("ATGCN"); | ||
const nlohmann::json DATA_WITH_ALL_N = createDataWithNucleotideSequence("NNNNN"); | ||
const nlohmann::json DATA_WITH_ALL_MUTATED = createDataWithNucleotideSequence("CATTT"); | ||
|
||
const auto DATABASE_CONFIG = | ||
DatabaseConfig{"segment1", {"dummy name", {{"primaryKey", ValueType::STRING}}, "primaryKey"}}; | ||
|
||
const auto REFERENCE_GENOMES = ReferenceGenomes{ | ||
{{"segment1", "ATGCN"}}, | ||
{{"gene1", "M*"}}, | ||
}; | ||
|
||
const QueryTestData TEST_DATA{ | ||
{DATA_SAME_AS_REFERENCE, DATA_SAME_AS_REFERENCE, DATA_WITH_ALL_N, DATA_WITH_ALL_MUTATED}, | ||
DATABASE_CONFIG, | ||
REFERENCE_GENOMES | ||
}; | ||
|
||
nlohmann::json createNucleotideSymbolEqualsQuery(const std::string& symbol, int position) { | ||
return { | ||
{"action", {{"type", "Aggregated"}}}, | ||
{"filterExpression", | ||
{{"type", "NucleotideEquals"}, | ||
{"position", position}, | ||
{"symbol", symbol}, | ||
{"sequenceName", "segment1"}}} | ||
}; | ||
} | ||
|
||
const QueryTestScenario NUCLEOTIDE_EQUALS_WITH_SYMBOL = { | ||
"nucleotideEqualsWithSymbol", | ||
createNucleotideSymbolEqualsQuery("C", 1), | ||
{{{"count", 1}}} | ||
}; | ||
|
||
const QueryTestScenario NUCLEOTIDE_EQUALS_WITH_DOT_RETURNS_REFERENCE = { | ||
"nucleotideEqualsWithDot", | ||
createNucleotideSymbolEqualsQuery(".", 1), | ||
{{{"count", 2}}} | ||
}; | ||
|
||
QUERY_TEST( | ||
NucleotideSymbolEquals, | ||
TEST_DATA, | ||
::testing::Values(NUCLEOTIDE_EQUALS_WITH_SYMBOL, NUCLEOTIDE_EQUALS_WITH_DOT_RETURNS_REFERENCE) | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, it worked as the tests suggested, just the test was wrong 😄