source: trunk/GDE/MUSCLE/src/nwrec.cpp

Last change on this file was 10390, checked in by aboeckma, 11 years ago

added muscle sourcles amd makefile

File size: 2.4 KB
Line 
1/***
2Needleman-Wunch recursions
3
4Notation: i,j are prefix lengths so are in
5ranges i = [0,|A|] and j = [0,|B|].
6
7Profile positions are in ranges [0,|A|-1]
8and [0,|B|-1] so prefix length i corresponds
9to position (i-1) in the profile, and similarly
10for j.
11
12Terminal gap scoring
13--------------------
14Terminal gaps are scored as with open [close]
15penalties only at the left [right] terminal,
16as follows:
17
18      0  i
19          |  |
20        A XXXXX...
21        B ---XX...
22
23          i |A|-1
24          |  |
25        A ...XXXXX
26        B ...XX---
27
28In these examples, open / close penalty at position
29i is  included, but close / open penalty at |A|-1 /
300 is not included.
31
32This is implemented by setting the open [close]
33penalty to zero in the first [last] position of
34each profile.
35
36Consider adding a column to a sub-alignment. After the
37column is added, there are i letters from A and j letters
38from B.
39
40The column starts a left-terminal gap if:
41        Delete with i=1, j=0 or
42        Insert with i=0, j=1.
43
44The column ends a left-terminal gap if:
45        Match following Delete with j=1, or
46        Match following Insert with i=1.
47
48The column starts a right-terminal gap if:
49        Delete following a Match and i=|A|, or
50        Insert following a Match and j=|B|.
51
52The column ends a right-terminal gap if:
53        Match with i=|A|, j=|B| following Delete or Insert.
54       
55RECURSION RELATIONS
56===================
57
58         i-1
59          |
60DD      A ..X X
61        B ..- -
62
63MD      A ..X X
64        B ..X -
65
66D(i,j) = max
67                        D(i-1,j) + e
68                        M(i-1,j) + goA(i-1)
69Valid for:
70        i = [1,|A|-1]
71        j = [1,|B|]
72
73I(i,j) By symmetry with D(i,j).
74
75       i-2
76        | i-1
77                | |
78MM      A ..X X
79        B ..X X
80
81DM      A ..X X
82        B ..- X
83
84IM  A ..- X
85        B ..X X
86            | |
87                | j-1
88           j-2
89
90M(i,j) = L(i-1,j-1) + max
91                        M(i-1,j-1)
92                        D(i-1,j-1) + gcA(i-2)
93                        I(i-1,j-1) + gcB(j-2)
94Valid for:
95        i = [2,|A|]
96        j = [2,|B|]
97
98Equivalently:
99
100M(i+1,j+1) = L(i,j) + max
101                        M(i,j)
102                        D(i,j) + gcA(i-1)
103                        I(i,j) + gcB(j-1)
104
105Valid for:
106        i = [1,|A|-1]
107        j = [1,|B|-1]
108
109Boundary conditions
110===================
111
112A XXXX
113B ----
114        D(0,0) = -infinity
115
116        D(i,0) = ie
117                i = [1,|A|]
118
119        D(0,j) = -infinity
120                j = [0,|B|]
121
122I(0,0), I(0,j) and I(i,0) by symmetry with D.
123
124        M(0,0) = 0
125        M(i,0) = -infinity, i > 0
126        M(0,j) = -infinity, j > 0
127
128A X
129B -
130        D(1,0) = e
131        D(1,j) = -infinity, j = [1,|B|]
132                (assuming no I-D allowed).
133
134        D(0,1) = -infinity
135        D(1,1) = -infinity
136        D(i,1) = max.
137***/
Note: See TracBrowser for help on using the repository browser.