00001 #ifndef FMWSCA_CPP 00002 #define FMWSCA_CPP 00003 00004 //-------------------------------------------------------------------- 00005 // 00006 // This file is part of PEACE. 00007 // 00008 // PEACE is free software: you can redistribute it and/or modify it 00009 // under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // PEACE is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with PEACE. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 // Miami University makes no representations or warranties about the 00022 // suitability of the software, either express or implied, including 00023 // but not limited to the implied warranties of merchantability, 00024 // fitness for a particular purpose, or non-infringement. Miami 00025 // University shall not be liable for any damages suffered by licensee 00026 // as a result of using, result of using, modifying or distributing 00027 // this software or its derivatives. 00028 // 00029 // By using or copying this Software, Licensee agrees to abide by the 00030 // intellectual property laws, and all other applicable laws of the 00031 // U.S., and the terms of GNU General Public License (version 3). 00032 // 00033 // Authors: Dhananjai M. Rao raodm@muohio.edu 00034 // 00035 //--------------------------------------------------------------------- 00036 00037 #include "FMWSCA.h" 00038 00039 // The static instance variables for command line arguments. 00040 bool FMWSCA::caseSensitive = false; 00041 00042 // The common set of arguments for all FW EST analyzers 00043 arg_parser::arg_record FMWSCA::argsList[] = { 00044 {"--case", "Make comparisons of BP case sensitive", 00045 &FMWSCA::caseSensitive, arg_parser::BOOLEAN}, 00046 {NULL, NULL, NULL, arg_parser::BOOLEAN} 00047 }; 00048 00049 FMWSCA::FMWSCA(const int refESTidx, const std::string& outputFile) 00050 : FWAnalyzer(std::string("fmwsca"), refESTidx, outputFile) { 00051 // Nothing else to be done for now. 00052 } 00053 00054 FMWSCA::~FMWSCA() { 00055 // Nothing else to be done for now. 00056 } 00057 00058 void 00059 FMWSCA::showArguments(std::ostream& os) { 00060 FWAnalyzer::showArguments(os); 00061 // Use a arg parser object to conveniently display common options. 00062 arg_parser ap(FMWSCA::argsList); 00063 os << ap; 00064 } 00065 00066 bool 00067 FMWSCA::parseArguments(int& argc, char **argv) { 00068 arg_parser ap(FMWSCA::argsList); 00069 ap.check_args(argc, argv, false); 00070 // Now let the base class do processing and return the result. 00071 return FWAnalyzer::parseArguments(argc, argv); 00072 } 00073 00074 float 00075 FMWSCA::getMetric(const std::string& refFrame, 00076 const std::string& otherFrame, const int wordSize) { 00077 const int LastWordPos = (int) refFrame.length() - wordSize; 00078 int matchCount = 0; 00079 for(int wordPos = 0; (wordPos < LastWordPos); wordPos++) { 00080 const std::string word = refFrame.substr(wordPos, wordSize); 00081 int searchPos = 0; 00082 do { 00083 if ((searchPos = (int) otherFrame.find(word, searchPos)) != -1) { 00084 matchCount++; 00085 searchPos++; 00086 } 00087 } while (searchPos != -1); 00088 } 00089 00090 return ((float) matchCount) / (LastWordPos * LastWordPos); 00091 } 00092 00093 #endif