#include "TextCollection.h"
#include "IndelQuery.h"
+#include "PssmQuery.h"
#include "incbwt/rlcsa.h"
#include <stdexcept>
#include <set>
#include <string>
+#include <cmath>
namespace SXSI
{
goto exact_pattern_matching; // Invalid format
IndelQuery iq(this);
- //std::cerr << "Pattern: " << tmp+1 << ", k = " << k << std::endl;
+// std::cerr << "RLCSAWrapper::Contains(): Pattern: " << tmp+1 << ", k = " << k << std::endl;
return iq.align(tmp+1, k);
}
+ /*************************************************************************
+ * Position Specific Scoring Matrix (PSSM) matching
+ * See PssmQuery.h for usage information.
+ */
+ if (strncmp((char const *)pattern, "PSSM ", 4) == 0)
+ {
+ // Parse threshold
+ double thr = std::atof((char const *)pattern + 5);
+ if (thr <= 0)
+ goto exact_pattern_matching; // Invalid format
+
+ // Find the start of the pattern (i.e. the second ' ')
+ uchar const * tmp = pattern + 5;
+ while (*tmp != ' ' && *tmp != 0) ++tmp;
+ if (*tmp != ' ' || tmp == pattern + 5)
+ goto exact_pattern_matching; // Invalid format
+
+ PssmQuery pq(this, std::log(thr));
+ //std::cerr << "Pattern: " << tmp+1 << ", log(threshold) = " << std::log(thr) << std::endl;
+ return pq.align(tmp+1, 0);
+ }
+
/*************************************************************************
* Exact pattern matching
*/
// Index from/to disk
RLCSAWrapper(FILE *file, char const *filename)
: rlcsa(new CSA::RLCSA(std::string(filename)))
- { /* NOP */ }
+ {
+ // Init the edit distance look-up tables
+ MyersEditDistanceIncremental::initMyersFourRussians();
+ }
void Save(FILE *file, char const *filename) const
{
// Saving type info:
if (std::fwrite(&type, 1, 1, file) != 1)
throw std::runtime_error("RLCSAWrapper::Save(): file write error (type flag).");
+ fflush(file);
this->rlcsa->writeTo(std::string(filename));
}