LocARNA-1.9.2
src/LocARNA/confusion_matrix.hh
00001 #ifndef LOCARNA_CONFUSION_MATRIX
00002 #define LOCARNA_CONFUSION_MATRIX
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007 
00008 #include <cstddef>
00009 #include <cassert>
00010 #include <string>
00011 
00012 #include "base_pair_filter.hh"
00013 
00014 namespace LocARNA {
00015     class RnaStructure;
00016 
00035     class ConfusionMatrix {
00036     public:
00047         ConfusionMatrix(const std::string &ref,
00048                         const std::string &pred,
00049                         const bool slide,
00050                         const bool conflict,
00051                         const BasePairFilter::Filter &filter =
00052                             BasePairFilter::BPMinLoopSize(3));
00053 
00064         ConfusionMatrix(const RnaStructure &ref,
00065                         const RnaStructure &pred,
00066                         const bool slide,
00067                         const bool conflict,
00068                         const BasePairFilter::Filter &filter =
00069                             BasePairFilter::BPMinLoopSize(3));
00070 
00081         size_t
00082         tp() const {
00083             return tp_;
00084         }
00085 
00094         size_t
00095         tn() const {
00096             return tn_;
00097         }
00098 
00107         size_t
00108         fp() const {
00109             return fp_;
00110         }
00111 
00120         size_t
00121         fn() const {
00122             return fn_;
00123         }
00124 
00132         double
00133         ppv() const;
00134 
00142         double
00143         sens() const;
00144 
00150         double
00151         spec() const;
00152 
00160         double
00161         f1_score() const;
00162 
00169         double
00170         mcc() const;
00171 
00172     protected:
00184         size_t
00185         count_common_bps(const RnaStructure &s1, const RnaStructure &s2);
00186 
00195         size_t
00196         count_tps(const RnaStructure &pred, const RnaStructure &ref);
00197 
00209         size_t
00210         count_conflicting_base_pairs(const RnaStructure &s1,
00211                                      const RnaStructure &s2);
00218         size_t
00219         count_potential_base_pairs(size_t length);
00220 
00227         size_t
00228         count_base_pairs(const RnaStructure &s);
00229 
00230     private:
00240         void
00241         compute_confusion_matrix(const RnaStructure &ref,
00242                                  const RnaStructure &pred);
00243 
00244         bool slide_;
00245         bool conflict_;
00246         const BasePairFilter::Filter &filter_;
00247 
00248         size_t tp_; 
00249         size_t tn_; 
00250         size_t fp_; 
00251         size_t fn_; 
00252     };
00253 
00254 } // end namespace LocARNA
00255 
00256 #endif // LOCARNA_CONFUSION_MATRIX
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends