00001 #ifndef LC_FILTER_H 00002 #define LC_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 /** \typedef std::pair<int, SMList> DummyESTInfo 00044 00045 \brief Shortcut typedef for std::pair<int, int> 00046 00047 This typedef is a shortcut for referring to a pair of integers 00048 that hold information about dummy ESTs created, used, and finally 00049 removed by this filter. The pair of information is used as 00050 follows: 00051 00052 <ol> 00053 00054 <li>The first entry is an \c int that indicates the index of the 00055 dummy EST in the global EST list. </li> 00056 00057 <li>The second entry is another integer hat contains the ID of the 00058 cluster to which other ESTs that are sufficiently close to the 00059 dummy EST must be added.</li> 00060 00061 </ol> 00062 */ 00063 typedef std::pair<int, int> DummyESTInfo; 00064 00065 /** A filter to weed out reads with Low Complexity (LC) sections. 00066 00067 <p>This class provides a filter that can be used to filter out 00068 ESTs that contain regions of Low Complexity (LC) reads in them. 00069 This filter is needed When clustering FASTA data (that contains 00070 low complexity reads) because the LC sections provide a "false" 00071 relationships between ESTs giving raise to very large clusters. 00072 These large clusters are created because transitive relationships 00073 are established between ESTs due to low complexity reads.</p> 00074 00075 <p>In order to avoid super-clusters that get formed due to low 00076 complexity reads, PEACE adds dummy ESTs (such as: one with all \c 00077 "AAAAA...." and another with all \c "CCCCCC...") based on the 00078 pattern ESTs specified by the user. The length of the dummy ESTs 00079 are twice the length of the largest window used for analysis. The 00080 ESTs are subjected to the same analysis and ESTs that are 00081 sufficiently similar to the dummy entries are filtered out.</p> 00082 00083 <p>This filter creates several dummy clusters (one per pattern 00084 sepcified) with the meta name "Low Complexity ESTs (filtered by 00085 LCFilter Pattern AA)" and adds any ESTs filtered out by this EST 00086 to the appropriate cluster.</p> 00087 00088 <p>This class has been developed by extending the Filter base 00089 class and implementing the necessary API methods specified by the 00090 base class. This enables the LCFilter to be used in the 00091 FilterChain along with other filters to filter out ESTs. In 00092 addition, note that this class cannot be directly 00093 instantiated. Instead, the FilterFactory::create() method must be 00094 used to obtain an instance of this class.</p> 00095 */ 00096 class LCFilter : public Filter { 00097 friend class FilterFactory; 00098 public: 00099 /** Display valid command line arguments for this filter. 00100 00101 This method must be used to display all valid command line 00102 options that are supported by this filter. This method 00103 overrides the corresponding method in the base class API. This 00104 method is typically used in the main() method when displaying 00105 usage information. 00106 00107 \param[out] os The output stream to which the valid command 00108 line arguments must be written. 00109 */ 00110 virtual void showArguments(std::ostream& os); 00111 00112 /** Process command line arguments. 00113 00114 This method is used to process command line arguments specific 00115 to this filter. This method is typically used from the main 00116 method just after the filter has been instantiated. This 00117 method consumes all valid command line arguments. If the 00118 command line arguments were valid and successfully processed, 00119 then this method returns \c true. 00120 00121 \param[in,out] argc The number of command line arguments to be 00122 processed. This value is updated when valid command line 00123 arguments are consumed by the filter. 00124 00125 \param[in,out] argv The array of command line arguments. The 00126 number of entries in this array are modified and updated when 00127 valid arguments are consumed by the filter. 00128 00129 \return This method returns \c true if the command line 00130 arguments were successfully processed. Otherwise this method 00131 returns \c false. 00132 */ 00133 virtual bool parseArguments(int& argc, char **argv); 00134 00135 /** Method to begin filter analysis (if any). 00136 00137 This method is invoked just before commencement of filtration. 00138 This method creates a set of dummy ESTs and corresponding 00139 dummy clusters for filtering out entries with low complexity 00140 regions. It uses the patternList to add dummy ESTs. 00141 00142 \return This method returns zero to indicate that 00143 initialization was completed successfully. On errors (that is 00144 a dummy EST could not be created) then this method returns a 00145 non-zero error code. 00146 */ 00147 virtual int initialize(); 00148 00149 /** Method to indicate completion of filter analysis. 00150 00151 This method is invoked after all the filteration operations 00152 have been successfully completed. This method removes all the 00153 dummy ESTs that were created and added by this 00154 filter. 00155 */ 00156 virtual void finalize(); 00157 00158 /** The destructor. 00159 00160 The destructor for the filter. The destructor currently has no 00161 specific tasks to perform as this filter does not use any 00162 dynamic memory. 00163 */ 00164 virtual ~LCFilter() {} 00165 00166 protected: 00167 /** The default constructor. 00168 00169 The constructor has been made protected to ensure that this 00170 class is never directly instantiated. Instead an instance 00171 should be created via a suitable call to the FilterFactory API 00172 method(s). 00173 00174 \param[in] clusterMaker The cluster maker class that is being 00175 used for analysis. This parameter is simply passed onto the 00176 base class for its use. It is used the initialize method to 00177 create a dummy cluster for use by this filter. 00178 */ 00179 LCFilter(ClusterMaker *clusterMaker); 00180 00181 /** Apply filter rules to determine if a given EST should be 00182 filtered out. 00183 00184 This method is invoked from the applyFilter() method to 00185 perform the actual filtering. The filtering is performed on 00186 the given EST in the following manner: 00187 00188 <ol> 00189 00190 <li>This method obtains the analyzer from the cluster maker 00191 and sets the given estIdx as the reference EST for 00192 analysis.</li> 00193 00194 <li>For each dummy EST in \c dummyESTList this method performs 00195 the following tasks: 00196 00197 <ol> 00198 00199 <li>It uses the analyzer (in the \c clusterMaker) to compute a 00200 metric between the dummy EST and the given \c estIdx.</li> 00201 00202 <li>If the metric indicates that the two ESTs are closely 00203 related (based on the threshold specified by the user) then 00204 the EST is filtered out and added to the corresponding dummy 00205 cluster.</li> 00206 00207 </ol> 00208 00209 </li> 00210 00211 </ol> 00212 00213 \param[in] estIdx The index of the EST to be tested and 00214 filtered by this method. 00215 00216 \return This method returns -1 if the est must be subject to 00217 further filteration or core EST analyis and clustering. If 00218 the specified est is to be filtered out, then this method 00219 returns a non-zero integer value. This value is used to place 00220 the EST into an artifically created cluster to help users 00221 identify such clusters. 00222 */ 00223 virtual int runFilter(const int estIdx); 00224 00225 /** Add a dummy entry with given sequence and length to the list 00226 of ESTs. 00227 00228 This method is invoked from the initialize method to add a 00229 dummy EST. Typically two dummy ESTs (one all \c "AAAAA..." 00230 and another one with all \c "CCCC....") are added. This is 00231 00232 \note This method approriately adds an entry to the \c 00233 dummyESTList. 00234 00235 \param[in] fastaID The fasta ID to be assigned to the dummy 00236 EST. This FASTA ID is not really useful is included for 00237 completeness. 00238 00239 \param[in] seq The nucleotide sequences to be repeated in 00240 order to generate the complete FASTA sequence for the dummy 00241 EST. This sequence must be at least one character in 00242 length. Only valid nucleotide base pairs must be 00243 00244 \param[in] length The minimum length of the generated 00245 sequence. Note that if the length and the pattern in the 00246 squence are not integral multiples of each other, then this 00247 method may generate slightly longer ESTs. 00248 */ 00249 virtual void addDummyEntry(const std::string& fastaID, 00250 const std::string& seq, 00251 const int length); 00252 00253 private: 00254 /** A list containing information about dummy ESTs. 00255 00256 This list is used to hold the core information about dummy 00257 ESTs created, used, and (finally) removed by this filter. For 00258 each pattern specified by the user (as a command line 00259 argument), a dummy EST is added (to the global list of ESTs) 00260 and this list maintains information about them. Entries are 00261 added to this list in the initialize() method. The entries are 00262 used on the runFilter() method. The finalize() method clears 00263 out the dummy ESTs and the entries in this list. 00264 */ 00265 std::vector<DummyESTInfo> dummyESTList; 00266 00267 /** The set of arguments specific to this filter. 00268 00269 This instance variable contains a static list of arguments 00270 that are specific only to this filter class. This argument 00271 list is statically defined and shared by all instances of this 00272 class. 00273 00274 \note Use of static arguments and parameters renders this 00275 filter class not to be MT-safe. 00276 */ 00277 static arg_parser::arg_record argsList[]; 00278 00279 /** The list of patterns to be used for generating dummy ESTs. 00280 00281 This variable is used to refer to the set of patterns that 00282 must be used to generate the dummy ESTs for identifying low 00283 complexity regions. The list is in the form "A,C,AG,TC" -- 00284 that is it contains a comma separated list of patterns. The 00285 patterns are repeated to generate dummy entries. The pattern 00286 can eb set via the \c --lcPatterns command line argument. 00287 */ 00288 static char* patternList; 00289 00290 /** The default pattern used by this filter. 00291 00292 This constant defines the default pattern that is used by this 00293 filter to generate dummy ESTs for identifying low complexity 00294 regions. The current default pattern is "A,C". This causes 00295 two dummy ESTs (one with all \c AAAAA... and another EST with 00296 all \c CCCC...) to be created and used for filtering. 00297 */ 00298 static char DefaultPatternList[]; 00299 00300 /** The filter's similarity/distance threshold metric. 00301 00302 This variable is used to contain the similarity/distance 00303 metric to be used as the threshold value. This value is 00304 compared with the metric provided by the ESTAnalyzer to 00305 determine if a given EST contains a low complexity 00306 section. This value is an important metric. This value is set 00307 via the \c --lcThreshold command line argument. 00308 */ 00309 static int threshold; 00310 00311 /** A dummy operator= 00312 00313 The operator=() is supressed for this class as it has constant 00314 members whose value is set when the object is created. These 00315 values cannot be changed during the lifetime of this object. 00316 00317 \param[in] src The source object from where data is to be 00318 copied. Currently this value is ignored. 00319 00320 \return Reference to this. 00321 */ 00322 LCFilter& operator=(const LCFilter& src); 00323 }; 00324 00325 #endif
1.6.1