concordia-library/concordia/tm_matches.hpp

132 lines
3.4 KiB
C++
Raw Permalink Normal View History

#ifndef TM_MATCHES_HDR
#define TM_MATCHES_HDR
#include <string>
#include <vector>
#include <map>
#include "concordia/common/config.hpp"
#include "concordia/interval.hpp"
#include <boost/ptr_container/ptr_map.hpp>
/*!
Class used within Anubis search algorithm to store partial results.
2015-05-01 14:52:53 +02:00
Holds information about mutual overlay of the pattern and found
example.
*/
class TmMatches {
public:
2015-05-01 14:52:53 +02:00
/*!
Constructor.
*/
TmMatches();
2015-05-01 14:52:53 +02:00
/*!
Constructor setting basic information.
\param exampleId id of found example
\param exampleSize size of the found example
\param patternSize size of the searched pattern
*/
TmMatches(const SUFFIX_MARKER_TYPE exampleId,
const SUFFIX_MARKER_TYPE exampleSize,
const SUFFIX_MARKER_TYPE patternSize);
/*! Destructor.
*/
virtual ~TmMatches();
2015-05-01 14:52:53 +02:00
/*!
Getter for score of the mutual overlay.
\returns score
*/
double getScore() const {
return _score;
}
2015-05-01 14:52:53 +02:00
/*!
Getter for the list of overlays of the example.
\returns example overlays list
*/
std::vector<Interval> getExampleIntervals() const {
return _exampleMatchedRegions;
}
2015-05-01 14:52:53 +02:00
/*!
Getter for the list of overlays of the pattern.
\returns pattern overlays list
*/
std::vector<Interval> getPatternIntervals() const {
return _patternMatchedRegions;
}
2015-05-01 14:52:53 +02:00
/*!
Getter for example id.
\returns example id
*/
SUFFIX_MARKER_TYPE getExampleId() const {
return _exampleId;
}
2015-05-01 14:52:53 +02:00
/*!
Calculates mutual overlay score in the scale [0,1].
Uses generalized Jaccard index for the computation.
Score 1 - perfect score - is assigned when the whole pattern
and the whole example are covered. Result of the computation
is stored in the score field, use getScore() to retrieve it.
*/
void calculateSimpleScore();
2015-05-01 14:52:53 +02:00
/*!
Calculates mutual overlay score in the scale [0,1].
Takes into account the number and the length of the
fragments (the fewer fragments, the better).
Score 1 - perfect score - is assigned when the whole pattern
and the whole example are covered with only one fragment.
Result of the computation is stored in the score field,
use getScore() to retrieve it.
*/
void calculateScore();
2015-05-01 14:52:53 +02:00
/*!
Adds information about covering of example. If the new
fragment intersects with any previous fragment, it is
not added.
\param start start of the example overlay fragment
\param end end of the example overlay fragment
*/
void addExampleInterval(int start, int end);
2015-05-01 14:52:53 +02:00
/*!
Adds information about covering of pattern. If the new
fragment intersects with any previous fragment, it is
not added.
\param start start of the pattern overlay fragment
\param end end of the pattern overlay fragment
*/
void addPatternInterval(int start, int end);
private:
bool _alreadyIntersects(const std::vector<Interval> & intervalList,
int start, int end);
SUFFIX_MARKER_TYPE _exampleId;
std::vector<Interval> _exampleMatchedRegions;
std::vector<Interval> _patternMatchedRegions;
SUFFIX_MARKER_TYPE _patternSize;
SUFFIX_MARKER_TYPE _exampleSize;
double _score;
};
typedef boost::ptr_map<SUFFIX_MARKER_TYPE, TmMatches> TmMatchesMap;
typedef TmMatchesMap::iterator TmMatchesMapIterator;
#endif