00001 #ifndef LENGTH_FILTER_CPP 00002 #define LENGTH_FILTER_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 "LengthFilter.h" 00038 #include "ClusterMaker.h" 00039 #include "EST.h" 00040 00041 // Define the static parameters 00042 int LengthFilter::minESTLen = 50; 00043 00044 // The set of arguments for this class. 00045 arg_parser::arg_record LengthFilter::argsList[] = { 00046 {"--minESTLen", "Minimum EST length to be permitted by this filter", 00047 &LengthFilter::minESTLen, arg_parser::INTEGER}, 00048 {NULL, NULL, NULL, arg_parser::BOOLEAN} 00049 }; 00050 00051 LengthFilter::LengthFilter(ClusterMaker *clusterMaker) : 00052 Filter("lengthFilter", clusterMaker) { 00053 // Initialize instance variables. 00054 clusterID = -1; 00055 } 00056 00057 void 00058 LengthFilter::showArguments(std::ostream& os) { 00059 // Use a arg parser object to conveniently display common options. 00060 arg_parser ap(LengthFilter::argsList); 00061 os << ap; 00062 } 00063 00064 bool 00065 LengthFilter::parseArguments(int& argc, char **argv) { 00066 // Let's process parameters now. 00067 arg_parser ap(LengthFilter::argsList); 00068 ap.check_args(argc, argv, false); 00069 // Ensure values are valid. 00070 if (minESTLen < 1) { 00071 std::cerr << filterName 00072 << ": Minimum EST length is too small " 00073 << "(use --minESTLen option)\n"; 00074 return false; 00075 } 00076 // Everything went well 00077 return true; 00078 } 00079 00080 int 00081 LengthFilter::initialize() { 00082 ASSERT ( clusterMaker != NULL ); 00083 // Add a dummy cluster for this filter with a suitable name. 00084 clusterID = clusterMaker->addDummyCluster("Cluster with short ESTs " 00085 "(filtered out by LengthFilter)"); 00086 return 0; 00087 } 00088 00089 int 00090 LengthFilter::runFilter(const int estIndex) { 00091 ASSERT ( clusterID != -1 ); 00092 ASSERT ((estIndex >= 0) && (estIndex < EST::getESTCount())); 00093 // Check the length of the specified EST 00094 const char *seq = EST::getEST(estIndex)->getSequence(); 00095 if ((int) strlen(seq) < minESTLen) { 00096 // This EST is too short. Filter it out. 00097 return clusterID; 00098 } 00099 // Let this EST through the filter 00100 return -1; 00101 } 00102 00103 #endif
1.6.1