-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
478 additions
and
11 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
endToEndTests/test/invalidQueries/insertionsInvalidColumn.json
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,17 @@ | ||
{ | ||
"testCaseName": "The insertions action with an invalid column", | ||
"query": { | ||
"action": { | ||
"type": "Insertions", | ||
"column": "insertionsThatAreNotThere", | ||
"sequenceName": "anything" | ||
}, | ||
"filterExpression": { | ||
"type": "True" | ||
} | ||
}, | ||
"expectedError": { | ||
"error": "Bad request", | ||
"message": "The column 'insertionsThatAreNotThere' does not exist." | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
endToEndTests/test/invalidQueries/insertionsInvalidSequence.json
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,17 @@ | ||
{ | ||
"testCaseName": "The insertions action with an invalid sequence", | ||
"query": { | ||
"action": { | ||
"type": "Insertions", | ||
"column": "insertions", | ||
"sequenceName": "S" | ||
}, | ||
"filterExpression": { | ||
"type": "True" | ||
} | ||
}, | ||
"expectedError": { | ||
"error": "Bad request", | ||
"message": "The column 'insertions' does not contain the sequence 'S'" | ||
} | ||
} |
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,23 @@ | ||
{ | ||
"testCaseName": "The insertions action and insertions contains filter", | ||
"query": { | ||
"action": { | ||
"type": "Insertions", | ||
"column": "insertions" | ||
}, | ||
"filterExpression": { | ||
"type": "InsertionContains", | ||
"column": "insertions", | ||
"position": 22339, | ||
"value": ".*C.*G.*" | ||
} | ||
}, | ||
"expectedQueryResult": [ | ||
{ | ||
"count": 1, | ||
"insertions": "GCTGGT", | ||
"position": "22340", | ||
"sequenceName": "" | ||
} | ||
] | ||
} |
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,38 @@ | ||
{ | ||
"testCaseName": "The insertions action", | ||
"query": { | ||
"action": { | ||
"type": "Insertions", | ||
"column": "insertions" | ||
}, | ||
"filterExpression": { | ||
"type": "True" | ||
} | ||
}, | ||
"expectedQueryResult": [ | ||
{ | ||
"count": 1, | ||
"insertions": "TAT", | ||
"position": "5960", | ||
"sequenceName": "" | ||
}, | ||
{ | ||
"count": 1, | ||
"insertions": "CAGAA", | ||
"position": "22205", | ||
"sequenceName": "" | ||
}, | ||
{ | ||
"count": 1, | ||
"insertions": "GCTGGT", | ||
"position": "22340", | ||
"sequenceName": "" | ||
}, | ||
{ | ||
"count": 17, | ||
"insertions": "CCC", | ||
"position": "25702", | ||
"sequenceName": "" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,4 +1,64 @@ | ||
#ifndef SILO_INSERTIONS_H | ||
#define SILO_INSERTIONS_H | ||
|
||
#include "silo/query_engine/actions/action.h" | ||
#include "silo/storage/column/insertion_index.h" | ||
|
||
namespace silo::query_engine { | ||
|
||
struct QueryResultEntry; | ||
|
||
namespace actions { | ||
|
||
template <typename Symbol> | ||
class InsertionAggregation : public Action { | ||
static constexpr std::string_view POSITION_FIELD_NAME = "position"; | ||
static constexpr std::string_view INSERTION_FIELD_NAME = "insertions"; | ||
static constexpr std::string_view SEQUENCE_FIELD_NAME = "sequenceName"; | ||
static constexpr std::string_view COUNT_FIELD_NAME = "count"; | ||
|
||
std::string column_name; | ||
std::vector<std::string> sequence_names; | ||
|
||
struct PrefilteredBitmaps { | ||
std::vector<std::pair< | ||
const OperatorResult&, | ||
const silo::storage::column::insertion::InsertionIndex<Symbol>&>> | ||
bitmaps; | ||
std::vector<std::pair< | ||
const OperatorResult&, | ||
const silo::storage::column::insertion::InsertionIndex<Symbol>&>> | ||
full_bitmaps; | ||
}; | ||
|
||
void addAggregatedInsertionsToInsertionCounts( | ||
std::vector<QueryResultEntry>& output, | ||
const std::string& sequence_name, | ||
const PrefilteredBitmaps& prefiltered_bitmaps | ||
) const; | ||
|
||
std::unordered_map<std::string, InsertionAggregation<Symbol>::PrefilteredBitmaps> | ||
validateFieldsAndPreFilterBitmaps( | ||
const Database& database, | ||
std::vector<OperatorResult>& bitmap_filter | ||
) const; | ||
|
||
public: | ||
InsertionAggregation(std::string column, std::vector<std::string>&& sequence_names); | ||
|
||
void validateOrderByFields(const Database& database) const override; | ||
|
||
[[nodiscard]] QueryResult execute( | ||
const Database& database, | ||
std::vector<OperatorResult> bitmap_filter | ||
) const override; | ||
}; | ||
|
||
template <typename Symbol> | ||
// NOLINTNEXTLINE(readability-identifier-naming) | ||
void from_json(const nlohmann::json& json, std::unique_ptr<InsertionAggregation<Symbol>>& action); | ||
|
||
} // namespace actions | ||
} // namespace silo::query_engine | ||
|
||
#endif // SILO_INSERTIONS_H |
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
Oops, something went wrong.