include/algo/align/nw/mm_aligner.hpp

Go to the documentation of this file.
00001 #ifndef ALGO___MM_ALIGNER__HPP
00002 #define ALGO___MM_ALIGNER__HPP
00003 
00004 /* $Id: mm_aligner.hpp 103491 2007-05-04 17:18:18Z kazimird $
00005 * ===========================================================================
00006 *
00007 *                            PUBLIC DOMAIN NOTICE                          
00008 *               National Center for Biotechnology Information
00009 *                                                                          
00010 *  This software/database is a "United States Government Work" under the   
00011 *  terms of the United States Copyright Act.  It was written as part of    
00012 *  the author's official duties as a United States Government employee and 
00013 *  thus cannot be copyrighted.  This software/database is freely available 
00014 *  to the public for use. The National Library of Medicine and the U.S.    
00015 *  Government have not placed any restriction on its use or reproduction.  
00016 *                                                                          
00017 *  Although all reasonable efforts have been taken to ensure the accuracy  
00018 *  and reliability of the software and data, the NLM and the U.S.          
00019 *  Government do not and cannot warrant the performance or results that    
00020 *  may be obtained by using this software or data. The NLM and the U.S.    
00021 *  Government disclaim all warranties, express or implied, including       
00022 *  warranties of performance, merchantability or fitness for any particular
00023 *  purpose.                                                                
00024 *                                                                          
00025 *  Please cite the author in any work or product based on this material.   
00026 *
00027 * ===========================================================================
00028 *
00029 * Author:  Yuri Kapustin
00030 *
00031 * File Description:
00032 *   CMMAligner class definition
00033 *
00034 *   CMMAligner encapsulates the Hirschberg's divide-and-conquer
00035 *   algorithm (also credited to Myers and Miller) featuring
00036 *   affine gap penalty model and running in linear space
00037 *
00038 *   E.W. Myers and W. Miller
00039 *   Optimal alignment in linear space
00040 *   Comp. Appl. Biosciences, 4:11-17, 1988 
00041 *
00042 */
00043 
00044 #include "nw_aligner.hpp"
00045 #include <list>
00046 #include <corelib/ncbithr.hpp>
00047 
00048 
00049 /** @addtogroup AlgoAlignMM
00050  *
00051  * @{
00052  */
00053 
00054 
00055 BEGIN_NCBI_SCOPE
00056 
00057 struct SCoordRect; // auxiliary structure, see below
00058 
00059 
00060 class  CMMAligner: public CNWAligner
00061 {
00062 public:
00063 
00064     CMMAligner();
00065 
00066     CMMAligner(const char* seq1, size_t len1,
00067                const char* seq2, size_t len2,
00068                const SNCBIPackedScoreMatrix* scoremat = 0);
00069 
00070     CMMAligner(const string& seq1,
00071                const string& seq2,
00072                const SNCBIPackedScoreMatrix* scoremat = 0);
00073 
00074     virtual ~CMMAligner() {}
00075 
00076 protected:
00077 
00078     list<ETranscriptSymbol>  m_TransList;
00079 
00080     virtual TScore   x_Run();
00081     
00082     void x_DoSubmatrix(const SCoordRect& submatr,
00083                    list<ETranscriptSymbol>::iterator translist_pos,
00084                    bool left_top, bool right_bottom);
00085 
00086     void x_RunTop(const SCoordRect& rect,
00087              vector<TScore>& vE, vector<TScore>& vF, vector<TScore>& vG,
00088              vector<unsigned char>& trace, bool lt) const;
00089 
00090     void x_RunBtm(const SCoordRect& rect,
00091              vector<TScore>& vE, vector<TScore>& vF, vector<TScore>& vG,
00092              vector<unsigned char>& trace, bool rb) const;
00093 
00094     TScore x_RunTerm(const SCoordRect& rect,
00095                      bool left_top, bool right_bottom,
00096                      list<ETranscriptSymbol>& subpath);
00097     
00098     enum ETransitionType {
00099         eII = 0,  eDI,   eGI,
00100         eID,      eDD,   eGD,
00101         eIG,      eDG,   eGG
00102     };
00103     TScore x_FindBestJ( const vector<TScore>& vEtop,
00104                         const vector<TScore>& vFtop,
00105                         const vector<TScore>& vGtop,
00106                         const vector<TScore>& vEbtm,
00107                         const vector<TScore>& vFbtm,
00108                         const vector<TScore>& vGbtm,
00109                         size_t& pos,
00110                         ETransitionType& trans_type ) const;
00111     
00112     size_t x_ExtendSubpath(vector<unsigned char>::const_iterator trace_it,
00113                            bool direction,
00114                            list<ETranscriptSymbol>& subpath) const;
00115 
00116     virtual bool x_CheckMemoryLimit();
00117 
00118     friend class CThreadRunOnTop;
00119     friend class CThreadDoSM;
00120 
00121 };
00122 
00123 // auxiliary structure
00124     
00125 struct  SCoordRect {
00126     size_t i1, j1, i2, j2;
00127     SCoordRect() {};
00128     SCoordRect(size_t l, size_t t, size_t r, size_t b):
00129         i1(l), j1(t), i2(r), j2(b) {}
00130     unsigned int GetArea() {
00131         return (i2 - i1 + 1)*(j2 - j1 + 1);
00132     }
00133 };
00134 
00135 
00136 END_NCBI_SCOPE
00137 
00138 
00139 /* @} */
00140 
00141 #endif  /* ALGO___MM_ALIGNER__HPP */
00142 
00143 

Generated on Sun Dec 6 21:55:28 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:20:32 2009 by modify_doxy.py rev. 173732