00001 #ifndef LENGTH_FILTER_H 00002 #define LENGTH_FILTER_H 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 "arg_parser.h" 00038 #include "Filter.h" 00039 00040 // Forward declarations to keep compiler fast and happy 00041 class ClusterMaker; 00042 00043 /** A simple filter to filter out reads shorter than a given length. 00044 00045 <p>This class provides a simple filter that can be used to filter 00046 out ESTs that are shorter than a given number of nucleotides. 00047 This filter can be enabled by specifying its name, namely \c 00048 lengthFilter, in the filter chain (that is specified as the 00049 command line argument to PEACE). If this filter is specified then 00050 the lengthFilterSize command line argument is used to determine 00051 the threshold length value (ESTs shorter than this value will be 00052 filtered out).</p> 00053 00054 <p>This filter creates an dummy cluster with the meta name "Short 00055 ESTs (filtered by LengthFilter)" and adds any ESTs filtered out by 00056 this EST to that cluster.</p> 00057 00058 <p>This class has been developed by extending the Filter base 00059 class and implementing the necessary API methods specified by the 00060 base class. This enables the LengthFilter to be used in the 00061 FilterChain along with other filters to filter out ESTs. In 00062 addition, note that this class cannot be directly 00063 instantiated. Instead, the FilterFactory::create() method must be 00064 used to obtain an instance of this class.</p> 00065 */ 00066 class LengthFilter : public Filter { 00067 friend class FilterFactory; 00068 public: 00069 /** Display valid command line arguments for this filter. 00070 00071 This method must be used to display all valid command line 00072 options that are supported by this filter. This method 00073 overrides the corresponding method in the base class API. This 00074 method is typically used in the main() method when displaying 00075 usage information. 00076 00077 \param[out] os The output stream to which the valid command 00078 line arguments must be written. 00079 */ 00080 virtual void showArguments(std::ostream& os); 00081 00082 /** Process command line arguments. 00083 00084 This method is used to process command line arguments specific 00085 to this filter. This method is typically used from the main 00086 method just after the filter has been instantiated. This 00087 method consumes all valid command line arguments. If the 00088 command line arguments were valid and successfully processed, 00089 then this method returns \c true. 00090 00091 \param[in,out] argc The number of command line arguments to be 00092 processed. This value is updated when valid command line 00093 arguments are consumed by the filter. 00094 00095 \param[in,out] argv The array of command line arguments. The 00096 number of entries in this array are modified and updated when 00097 valid arguments are consumed by the filter. 00098 00099 \return This method returns \c true if the command line 00100 arguments were successfully processed. Otherwise this method 00101 returns \c false. 00102 */ 00103 virtual bool parseArguments(int& argc, char **argv); 00104 00105 /** Method to begin filter analysis (if any). 00106 00107 This method is invoked just before commencement of filtration. 00108 This method adds a new dummy cluster using the ClusterMaker 00109 API methods. The dummy cluster is used to classify ESTs that 00110 were filtered out by this filter. 00111 00112 \return This method returns zero to indicate that 00113 initialization was completed successfully. On errors (that is 00114 a cluster could not be created) then this method returns a 00115 non-zero error code. 00116 */ 00117 virtual int initialize(); 00118 00119 /** Method to indicate completion of filter analysis. 00120 00121 This method is invoked after all the filteration operations 00122 have been successfully completed. Currently method this 00123 method does not have any specific tasks to perform. 00124 */ 00125 virtual void finalize() {} 00126 00127 /** The destructor. 00128 00129 The destructor for the filter. The destructor currently has no 00130 specific tasks to perform as this filter does not use any 00131 dynamic memory. 00132 */ 00133 virtual ~LengthFilter() {} 00134 00135 protected: 00136 /** The default constructor. 00137 00138 The constructor has been made protected to ensure that this 00139 class is never directly instantiated. Instead an instance 00140 should be created via a suitable call to the FilterFactory API 00141 method(s). 00142 00143 \param[in] clusterMaker The cluster maker class that is being 00144 used for analysis. This parameter is simply passed onto the 00145 base class for its use. It is used the initialize method to 00146 create a dummy cluster for use by this filter. 00147 */ 00148 LengthFilter(ClusterMaker *clusterMaker); 00149 00150 /** Apply filter rules to determine if this EST should be filtered 00151 out. 00152 00153 This method is invoked from the applyFilter() method to 00154 perform the actual filtering. The filtering is performed on 00155 the given EST in the following manner: 00156 00157 <ol> 00158 00159 <li>This method first obtains the specified EST from the list 00160 of ESTs.</li> 00161 00162 <li>If the nucleotide sequence of this EST is shorter than \c 00163 minESTLength then this method filters out this EST and returns 00164 the ID of the cluster to which this EST must be added. The ID 00165 of the cluster is determined in the LengthFilter::initialize() 00166 method.</li> 00167 00168 </ol> 00169 00170 \return This method returns -1 if the est must be subject to 00171 further filteration or core EST analyis and clustering. If 00172 the specified est is to be filtered out, then this method 00173 returns a non-zero integer value. This value is used to place 00174 the EST into an artifically created cluster to help users 00175 identify such clusters. 00176 */ 00177 virtual int runFilter(const int otherEST); 00178 00179 private: 00180 /** Variable to track the ID of the cluster to which short ESTs 00181 must be added. 00182 00183 This instance variable is used to track the ID of the cluster 00184 to which short ESTs must be added by this filter. This value 00185 is set in the LengthFilter::initialize() method. 00186 */ 00187 int clusterID; 00188 00189 /** The set of arguments specific to this filter. 00190 00191 This instance variable contains a static list of arguments 00192 that are specific only to this filter class. This argument 00193 list is statically defined and shared by all instances of this 00194 class. 00195 00196 \note Use of static arguments and parameters renders this 00197 filter class not to be MT-safe. 00198 */ 00199 static arg_parser::arg_record argsList[]; 00200 00201 /** The minmum length threshold for ESTs to be used by this 00202 filter. 00203 00204 This instance variable contains the length of the shortest EST 00205 that must be permitted through by this filter. All ESTs 00206 shorter than this length will be filtered out. The default 00207 length is 50. However, this value can be overridden by using 00208 the \c --minESTLen command line argument. 00209 */ 00210 static int minESTLen; 00211 00212 /** A dummy operator= 00213 00214 The operator=() is supressed for this class as it has constant 00215 members whose value is set when the object is created. These 00216 values cannot be changed during the lifetime of this object. 00217 00218 \param[in] src The source object from where data is to be 00219 copied. Currently this value is ignored. 00220 00221 \return Reference to this. 00222 */ 00223 LengthFilter& operator=(const LengthFilter& src); 00224 }; 00225 00226 #endif
1.6.1