Sleipnir
src/seekevaluate.h
00001 /*****************************************************************************
00002 * This file is provided under the Creative Commons Attribution 3.0 license.
00003 *
00004 * You are free to share, copy, distribute, transmit, or adapt this work
00005 * PROVIDED THAT you attribute the work to the authors listed below.
00006 * For more information, please see the following web page:
00007 * http://creativecommons.org/licenses/by/3.0/
00008 *
00009 * This file is a component of the Sleipnir library for functional genomics,
00010 * authored by:
00011 * Curtis Huttenhower (chuttenh@princeton.edu)
00012 * Mark Schroeder
00013 * Maria D. Chikina
00014 * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
00015 *
00016 * If you use this library, the included executable tools, or any related
00017 * code in your work, please cite the following publication:
00018 * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
00019 * Olga G. Troyanskaya.
00020 * "The Sleipnir library for computational functional genomics"
00021 *****************************************************************************/
00022 #ifndef SEEKEVALUATE_H
00023 #define SEEKEVALUATE_H
00024 
00025 #include "seekbasic.h"
00026 #include "seekmap.h"
00027 
00028 namespace Sleipnir {
00029 
00030 struct AResult{
00031     utype i;
00032     utype f;
00033     bool operator<(const AResult& val) const{
00034         /*if(f<=val.f){
00035             return false;
00036         }else{
00037             return true;
00038         }*/
00039         if(f < val.f){
00040             return false;
00041         }else if(f > val.f){
00042             return true;
00043         }else if(i < val.i){
00044             return false;
00045         }else{
00046             return true;
00047         }
00048     }
00049 };
00050 
00051 struct Ascending{
00052     bool operator()( const AResult& lx, const AResult& rx ) const {
00053         return lx.f < rx.f;
00054     }
00055 };
00056 
00057 
00058 
00059 struct AResultFloat{
00060     utype i;
00061     float f;
00062     bool operator<(const AResultFloat& val) const{
00063         /*if(f<=val.f){
00064             return false;
00065         }else{
00066             return true;
00067         }*/
00068         if(f < val.f){
00069             return false;
00070         }else if(f > val.f){
00071             return true;
00072         }else if(i < val.i){
00073             return false;
00074         }else{
00075             return true;
00076         }
00077     }
00078 };
00079 
00080 struct AscendingFloat{
00081     bool operator()( const AResultFloat& lx, const AResultFloat& rx ) const {
00082         return lx.f < rx.f;
00083     }
00084 };
00085 
00096 class CSeekPerformanceMeasure{
00097 public:
00110     static bool SortRankVector(const vector<utype> &rank,
00111         const CSeekIntIntMap &mapG, vector<AResult> &a,
00112         const utype top = 0);
00113 
00137     /* designed specifically for a CSeekDataset */
00138     /* mask: the query genes which are not included in RBP calcualtion */
00139     static bool RankBiasedPrecision(const float &rate,
00140         const vector<utype> &rank, float &rbp,
00141         const vector<char> &mask, const vector<char> &gold,
00142         const CSeekIntIntMap &mapG, vector<AResult> *sing,
00143         /* optional */
00144         const utype top = 0);
00145 
00156     static bool AveragePrecision(
00157         const vector<utype> &rank, float &ap,
00158         const vector<char> &mask, const vector<char> &gold,
00159         const CSeekIntIntMap &mapG, vector<AResult> *ar);
00160 
00161 };
00162 
00163 
00164 }
00165 #endif