Skip to content

Commit 8ff26f2

Browse files
committed
Support finding taxonomy db paths from other prefilter databases
1 parent 8ff7279 commit 8ff26f2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/prefiltering/QueryMatcherTaxonomyHook.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
#include "NcbiTaxonomy.h"
66
#include "MappingReader.h"
77
#include "DBReader.h"
8-
#include "PrefilteringIndexReader.h"
98
#include "TaxonomyExpression.h"
109

1110
class QueryMatcherTaxonomyHook : public QueryMatcherHook {
1211
public:
1312
QueryMatcherTaxonomyHook(std::string targetPath, DBReader<unsigned int>* targetReader, const std::string& expressionString)
1413
: targetReader(targetReader), dbFrom(0) {
15-
std::string targetName = PrefilteringIndexReader::dbPathWithoutIndex(targetPath);
14+
std::string targetName = dbPathWithoutIndex(targetPath);
1615
taxonomy = NcbiTaxonomy::openTaxonomy(targetName);
1716
taxonomyMapping = new MappingReader(targetName);
1817
expression = new TaxonomyExpression(expressionString, *taxonomy);
@@ -44,6 +43,23 @@ class QueryMatcherTaxonomyHook : public QueryMatcherHook {
4443
return writePos;
4544
}
4645

46+
static std::string dbPathWithoutIndex(const std::string& dbname) {
47+
static const std::vector<std::string> suffices = {
48+
"_ss.idx",
49+
"_ss.linidx",
50+
"_ss",
51+
".idx",
52+
".linidx"
53+
};
54+
for (size_t i = 0; i < suffices.size(); ++i) {
55+
size_t lastpos = dbname.rfind(suffices[i]);
56+
if (lastpos != std::string::npos && dbname.size() - lastpos == suffices[i].length()){
57+
return dbname.substr(0, lastpos);
58+
}
59+
}
60+
return dbname;
61+
}
62+
4763
NcbiTaxonomy* taxonomy;
4864
MappingReader* taxonomyMapping;
4965
DBReader<unsigned int>* targetReader;

0 commit comments

Comments
 (0)