Commit f77b6a30 authored by Carsten Kemena's avatar Carsten Kemena

allow mismatches in words

parent d2fb1494
#include "RadiantDB.hpp"
#include <bitset>
using namespace std;
namespace fs = boost::filesystem;
......@@ -52,6 +53,25 @@ RadiantDB::build(const fs::path &inPath, bool forward, const fs::path &outPath)
fout.close();*/
}
short
char_diff(SuffixType val1, SuffixType val2)
{
SuffixType val = val1^val2;
short counter = 0;
for (short i=0; i< 10; ++i)
{
for (short j=0; j<3; ++j)
{
short n = i*3+j;
if (val & (1<<n))
{
++counter;
break;
}
}
}
return counter;
}
short
RadiantDB::getDomID(const PrefixType &prefix, const CodedSuffix &suffix, bool &position) const
......@@ -72,6 +92,7 @@ RadiantDB::getDomID(const PrefixType &prefix, const CodedSuffix &suffix, bool &p
else
{
auto tmp = it2->accession;
auto x = it2->suffix.suffix;
if (it2 != it->second.begin())
{
--it2;
......@@ -79,11 +100,22 @@ RadiantDB::getDomID(const PrefixType &prefix, const CodedSuffix &suffix, bool &p
{
position = it2->suffix.position;
return tmp;
//assignment.emplace(l-(multiplyer*j), std::pair<unsigned short, bool>(tmp, +it2->suffix.position));
}
else
{
short threshold = 2;
auto diff1 = char_diff(x, suffix.suffix);
auto diff2 = char_diff(it2->suffix.suffix, suffix.suffix);
if ((diff1 < diff2) && (diff1 <= threshold))
return tmp;
else
if (diff2 <= threshold)
return it2->accession;
}
}
}
}
}
return 0;
}
......
......@@ -92,7 +92,7 @@ cleanSuffixe(D &db)
auto currIt = nextIt++;
while (nextIt != endIt)
{
if (((currIt->second==0) && (prevIt->second==0)) || ((currIt->second == prevIt->second) && (currIt->second == nextIt->second)) || ((currIt->second != prevIt->second) && (currIt->second != nextIt->second) && (prevIt->second != nextIt->second)))
if (((currIt->second==0) && (prevIt->second==0)) || ((currIt->second == prevIt->second) && (currIt->second == nextIt->second))) //|| ((currIt->second != prevIt->second) && (currIt->second != nextIt->second) && (prevIt->second != nextIt->second)))
currIt = db.erase(currIt);
else
{
......@@ -103,7 +103,7 @@ cleanSuffixe(D &db)
}
}
/*
// remove first/last suffix if differnt from next/previous
if (db.size() > 1)
{
......@@ -124,7 +124,7 @@ cleanSuffixe(D &db)
// if only one element left its most liklely not very useful and can be removed
if (db.size() == 1)
db.clear();
*/
// test cleaning
if (db.size() > 1)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment