Changeset 265


Ignore:
Timestamp:
Apr 11, 2005, 5:46:00 PM (16 years ago)
Author:
Peter
Message:

doc added and some changes of variable names

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Alignment.cc

    r261 r265  
    1111namespace alignment {
    1212
    13   double NeedlemanWunsch(const gslapi::matrix& dot_matrix,
     13  double NeedlemanWunsch(const gslapi::matrix& s,
    1414                         std::vector<std::pair<size_t, size_t> >& path,
    15                          const double mismatch)
     15                         const double gap)
    1616  {
    17     gslapi::matrix s(dot_matrix.rows()+1,dot_matrix.columns()+1);
     17    gslapi::matrix s(s.rows()+1,s.columns()+1);
    1818    // Init upper and left border of matrix
    1919    for (size_t i=1; i<s.rows(); i++)
    20       s(i,0)=-i*mismatch;
     20      s(i,0)=-i*gap;
    2121    for (size_t i=1; i<s.columns(); i++)
    22       s(0,i)=-i*mismatch;
     22      s(0,i)=-i*gap;
    2323    // choice(i,j) tells us how we came to s(i,j). 1 is diagonal, 2
    2424    // vertical, and 3 horizontal,
     
    2828    for (size_t i=1; i<s.rows(); i++)
    2929      for (size_t j=1; j<s.columns(); j++){
    30         if (s(i-1,j-1) + dot_matrix(i-1,j-1) > s(i-1,j)-mismatch &&
    31             s(i-1,j-1) + dot_matrix(i-1,j-1) > s(i,j-1)-mismatch){
    32           s(i,j)=s(i-1,j-1) + dot_matrix(i-1,j-1);
     30        if (s(i-1,j-1) + s(i-1,j-1) > s(i-1,j)-gap &&
     31            s(i-1,j-1) + s(i-1,j-1) > s(i,j-1)-gap){
     32          s(i,j)=s(i-1,j-1) + s(i-1,j-1);
    3333          choice(i,j)=1;
    3434        }
    3535        else if (s(i-1,j) > s(i,j-1)){
    36           s(i,j)=s(i-1,j)-mismatch;
     36          s(i,j)=s(i-1,j)-gap;
    3737          choice(i,j)=2;
    3838        }
    3939        else{
    40           s(i,j)=s(i,j-1)-mismatch;
     40          s(i,j)=s(i,j-1)-gap;
    4141          choice(i,j)=3;
    4242        }
  • trunk/src/Alignment.h

    r256 r265  
    2323
    2424  ///
    25   /// Function calculating the score for the best aligning of two
    26   /// sequences. In the dot_matrix \a A, elament \f$ A_{ij} \f$ is
    27   /// score how well element i in the first sequence match to element
    28   /// j in the other sequence. In the aligning the elements from the
    29   /// two sequences are matched or a gap is added in one of the
    30   /// sequences. The latter is penalized with \a gap, which means if
    31   /// \a gap is large there will be no gaps in the best aligning (if
    32   /// the sequences have the same length). \a path contains what
    33   /// elements in \A that is used in the best path. In case of
    34   /// degeneracy only one path is returned.
     25  /// Function performing alignment following the Needleman-Wunch
     26  /// algorithm. The algorithm starts from the dot-matrix, \a s, where
     27  /// \f$ s_{ij} \f$ describes how well element \f$ i \f$ in the first
     28  /// sequence match to element \f$ j \f$ in the second sequence. A
     29  /// path through this matrix corresponds to an alignment of the two
     30  /// sequences, in which a diagonal step over a matrix element
     31  /// corresponds to a match between the corresponding sequnce
     32  /// elements and a vertical or a horizontal step corresponds to
     33  /// inserting a gap in one of the sequnces. The function maximizes
     34  /// \f$ \sum s_{ij}-n \f$ \a gap, where the first sum goes over all
     35  /// matches and the second term is a penalty term for inserting \f$
     36  /// n \f$ gaps. Default is to have the \a gap cost set to zero. The
     37  /// vector \a path contains information about which elements that
     38  /// were matched. If the first element in the first sequence was
     39  /// matched to the first element in the second sequence, the last
     40  /// element in \a path is pair(0,0).
    3541  ///
    36   /// @return score from the best aligning
     42  /// @return the global maximum alignment score.
    3743  ///
    38   double NeedlemanWunsch(const gslapi::matrix& A,
     44  double NeedlemanWunsch(const gslapi::matrix& s,
    3945                         std::vector<std::pair<size_t, size_t> >& path,
    4046                         const double gap);
Note: See TracChangeset for help on using the changeset viewer.