ppALIGN API documentation
src/firstmoment.hpp
00001 /****************************************************************************** 00002 Copyright 2009 Stefan Wolfsheimer & Gregory Nuel. 00003 00004 This file is part of ppALIGN 00005 00006 ppALIGN is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 ppALIGN is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with ppALIGN; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 *******************************************************************************/ 00020 // changelog: 00021 // 10-14-2009 sw: development towards a more modular structure 00022 // (class ModuleFirstMoment) 00023 // 11-20-2009 sw: adjusted for the new version 00024 // 12-??-2009 sw: deep changes, implementation of the pair HMM 00025 // 01-23-2010 sw: bugfix for local alignment and the pair HMM 00026 00027 #ifndef _FIRST_MOMENT_HPP_ 00028 #define _FIRST_MOMENT_HPP_ 00029 00030 #include "partitionworkspace.hpp" 00031 00064 template<typename TYPE, int N=1> 00065 struct DynCellMoments 00066 { 00068 TYPE M[N]; 00069 00071 TYPE I[N]; 00072 00074 TYPE D[N]; 00075 }; 00076 00077 00083 class DriverFirstMoment : public PartitionDriverBase 00084 { 00085 public: 00086 00095 DriverFirstMoment(const ScoreMatrix & score, 00096 int gap_open, 00097 int gap_extension); 00098 00103 virtual bool NeedForward() { return true; } 00104 00108 virtual void OnForward(long i, 00109 const PartitionWorkspace::RowInfo & last_row, 00110 const PartitionWorkspace::RowInfo & curr_row, 00111 const PartitionWorkspace::const_iterator last, 00112 const PartitionWorkspace::const_iterator curr); 00113 00117 virtual void BeforeComputation() ; 00118 virtual void AfterComputation() ; 00120 00125 double FirstMoment(); 00126 00127 00128 private: 00129 int gap_open,gap_extension; 00130 int minus_alpha,minus_beta; 00131 00132 const ScoreMatrix & mat; 00133 00134 double first_moment; 00135 00138 std::vector<DynCellMoments<xdouble> > forward_ws[2]; 00139 std::vector<DynCellMoments<xdouble> >::iterator curr_for_itr; 00140 std::vector<DynCellMoments<xdouble> >::iterator last_for_itr; 00141 00143 xdouble Z1_forward; 00144 }; 00145 00146 00147 00148 #endif