Skip to content

Commit

Permalink
Merge pull request #146 from GenSpectrum/testsPosIndex
Browse files Browse the repository at this point in the history
fix: test cases verifying that the positions index for mutation distribution are now 1-indexed
  • Loading branch information
Taepper authored Jul 4, 2023
2 parents 76e0823 + fdf972a commit 69fdc2b
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 0 deletions.
17 changes: 17 additions & 0 deletions endToEndTests/test/invalidQueries/sequencePos0Filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"testCaseName": "Filtering for the position 0",
"query": {
"action": {
"type": "Aggregated"
},
"filterExpression": {
"position": 0,
"symbol": "-",
"type": "NucleotideEquals"
}
},
"expectedError": {
"error": "Bad request",
"message": "The field 'position' in a NucleotideEquals expression needs to be an unsigned integer greater than 0"
}
}
18 changes: 18 additions & 0 deletions endToEndTests/test/queries/sequenceEndFilter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"testCaseName": "Filtering for the last genome position",
"query": {
"action": {
"type": "Aggregated"
},
"filterExpression": {
"position": 29903,
"symbol": "-",
"type": "NucleotideEquals"
}
},
"expectedQueryResult": [
{
"count": 45
}
]
}
216 changes: 216 additions & 0 deletions endToEndTests/test/queries/sequenceStartEndMutations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"testCaseName": "Getting a mutation distribution that contains the first and last genome position",
"query": {
"action": {
"type": "Mutations",
"minProportion": 1
},
"filterExpression": {
"children": [
{
"position": 1,
"symbol": "-",
"type": "NucleotideEquals"
},
{
"position": 29903,
"symbol": "-",
"type": "NucleotideEquals"
}
],
"type": "And"
}
},
"expectedQueryResult": [
{
"count": 42,
"position": "A1-",
"proportion": 1
},
{
"count": 42,
"position": "C3037T",
"proportion": 1
},
{
"count": 42,
"position": "C14408T",
"proportion": 1
},
{
"count": 40,
"position": "A23403G",
"proportion": 1
},
{
"count": 42,
"position": "C29870-",
"proportion": 1
},
{
"count": 42,
"position": "A29871-",
"proportion": 1
},
{
"count": 42,
"position": "A29872-",
"proportion": 1
},
{
"count": 42,
"position": "A29873-",
"proportion": 1
},
{
"count": 42,
"position": "A29874-",
"proportion": 1
},
{
"count": 42,
"position": "A29875-",
"proportion": 1
},
{
"count": 42,
"position": "A29876-",
"proportion": 1
},
{
"count": 42,
"position": "A29877-",
"proportion": 1
},
{
"count": 42,
"position": "A29878-",
"proportion": 1
},
{
"count": 42,
"position": "A29879-",
"proportion": 1
},
{
"count": 42,
"position": "A29880-",
"proportion": 1
},
{
"count": 42,
"position": "A29881-",
"proportion": 1
},
{
"count": 42,
"position": "A29882-",
"proportion": 1
},
{
"count": 42,
"position": "A29883-",
"proportion": 1
},
{
"count": 42,
"position": "A29884-",
"proportion": 1
},
{
"count": 42,
"position": "A29885-",
"proportion": 1
},
{
"count": 42,
"position": "A29886-",
"proportion": 1
},
{
"count": 42,
"position": "A29887-",
"proportion": 1
},
{
"count": 42,
"position": "A29888-",
"proportion": 1
},
{
"count": 42,
"position": "A29889-",
"proportion": 1
},
{
"count": 42,
"position": "A29890-",
"proportion": 1
},
{
"count": 42,
"position": "A29891-",
"proportion": 1
},
{
"count": 42,
"position": "A29892-",
"proportion": 1
},
{
"count": 42,
"position": "A29893-",
"proportion": 1
},
{
"count": 42,
"position": "A29894-",
"proportion": 1
},
{
"count": 42,
"position": "A29895-",
"proportion": 1
},
{
"count": 42,
"position": "A29896-",
"proportion": 1
},
{
"count": 42,
"position": "A29897-",
"proportion": 1
},
{
"count": 42,
"position": "A29898-",
"proportion": 1
},
{
"count": 42,
"position": "A29899-",
"proportion": 1
},
{
"count": 42,
"position": "A29900-",
"proportion": 1
},
{
"count": 42,
"position": "A29901-",
"proportion": 1
},
{
"count": 42,
"position": "A29902-",
"proportion": 1
},
{
"count": 42,
"position": "A29903-",
"proportion": 1
}
]
}
18 changes: 18 additions & 0 deletions endToEndTests/test/queries/sequenceStartFilter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"testCaseName": "Filtering for the first genome position",
"query": {
"action": {
"type": "Aggregated"
},
"filterExpression": {
"position": 1,
"symbol": "-",
"type": "NucleotideEquals"
}
},
"expectedQueryResult": [
{
"count": 45
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ std::unique_ptr<silo::query_engine::operators::Operator> NucleotideSymbolEquals:
const silo::DatabasePartition& database_partition,
Expression::AmbiguityMode mode
) const {
if (position >= database.reference_genome->genome_segments[0].size()) {
throw QueryParseException(
"NucleotideEquals position is out of bounds '" + std::to_string(position + 1) + "' > '" +
std::to_string(database.reference_genome->genome_segments[0].size()) + "'"
);
}
NUCLEOTIDE_SYMBOL nucleotide_symbol;
if (value == '.') {
const char character = database.reference_genome->genome_segments[0].at(position);
Expand Down
1 change: 1 addition & 0 deletions src/silo/storage/pango_lineage_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <filesystem>
#include <fstream>
#include <iterator>
#include <sstream>

#include <spdlog/spdlog.h>
#include <nlohmann/json.hpp>
Expand Down

0 comments on commit 69fdc2b

Please sign in to comment.