Smith-Waterman 算法(不含回溯)

1.基本算法(摘自维基百科):

1.1空位权值恒定模型算法

空位权值恒定模型算法

1.2通用算法

通用模型算法

其中H(i,j)是最终的得分矩阵。F(i,j)和E(i,j)矩阵分别用来存储在两条比对序列上开辟空位延伸比对的消耗(cost)。o代表第一个空位的罚分值,e代表延伸时的罚分值。
(原文内容:In (3) and (4), o denotes the gap opening penalty, while e represents the gap extension penalty. The matrices F(i, j) and E(i, j) contain the trace of opening and extending a gap, respectively. F(i, j) stores the cost for opening a gap and extending a gap on sequence x, while E(i, j) stores the cost for opening a gap and extending a gap on sequence y)

2.举例说明:

比对序列为:A = TGTTACGG,B = GGTTGACTA

2.1确定置换矩阵和空位罚分办法

置换矩阵s(ai,bj)= {+3,ai==bj }
           {-3,ai!=bj }

即碱基匹配时分数+3,不匹配时分数-3

空位罚分Wk=(k-1)+2

即第一个空位得分-2,随后得分递增减1,即连续两个空位得分-3,连续三个空位得分-4...

2.2创建矩阵并初始化

需要创建的矩阵有H(得分矩阵),E(B序列空位延伸罚分矩阵),F(A序列空位延伸罚分矩阵)。

在初始化时一般会在H矩阵的最左上方空位赋一个初值(8),右侧值和下侧值为拓展空位罚分的数值。

(H矩阵初始化)

              (Matrix H)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |8 |6 |5 |4 |3 |2 |1 |0 |0 |
    G    |6 |x |x |x |x |x |x |x |x |
    G    |5 |x |x |x |x |x |x |x |x |
    T    |4 |x |x |x |x |x |x |x |x |
    T    |3 |x |x |x |x |x |x |x |x |
    G    |2 |x |x |x |x |x |x |x |x |
    A    |1 |x |x |x |x |x |x |x |x |
    C    |0 |x |x |x |x |x |x |x |x |
    T    |0 |x |x |x |x |x |x |x |x |
    A    |0 |x |x |x |x |x |x |x |x |
    
   (B)

(E矩阵初始化)

              (Matrix E)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |  |  |  |  |  |  |  |  |  |
    G    |  |0 |0 |0 |0 |0 |0 |0 |0 |
    G    |  |x |x |x |x |x |x |x |x |
    T    |  |x |x |x |x |x |x |x |x |
    T    |  |x |x |x |x |x |x |x |x |
    G    |  |x |x |x |x |x |x |x |x |
    A    |  |x |x |x |x |x |x |x |x |
    C    |  |x |x |x |x |x |x |x |x |
    T    |  |x |x |x |x |x |x |x |x |
    A    |  |x |x |x |x |x |x |x |x |
    
   (B)

(F矩阵初始化)

              (Matrix F)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |  |  |  |  |  |  |  |  |  |    
    G    |  |0 |x |x |x |x |x |x |x |
    G    |  |0 |x |x |x |x |x |x |x |
    T    |  |0 |x |x |x |x |x |x |x |
    T    |  |0 |x |x |x |x |x |x |x |
    G    |  |0 |x |x |x |x |x |x |x |
    A    |  |0 |x |x |x |x |x |x |x |
    C    |  |0 |x |x |x |x |x |x |x |
    T    |  |0 |x |x |x |x |x |x |x |
    A    |  |0 |x |x |x |x |x |x |x |
    
   (B)

2.3打分

由通用算法的计算式知:
E(0,1)=max(H(0,0)-2=8-2,E(0,0)-1=0-1)=6
E(1,1)=max(H(1,0)-2=6-2,E(1,0)-1=0-1)=4
F(1,0)=max(H(0,0)-2=8-2,F(0,0)-1=0-1)=6
F(1,1)=max(H(0,1)-2=6-2,F(0,1)-1=0-1)=4
H(1,1)=max(0,H(0,0)=8-3,E(1,1),F(1,1))=5
......

第一轮打分后:

(H矩阵)

              (Matrix H)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |8 |6 |5 |4 |3 |2 |1 |0 |0 |
    G    |6 |5 |9 |x |x |x |x |x |x |
    G    |5 |3 |x |x |x |x |x |x |x |
    T    |4 |x |x |x |x |x |x |x |x |
    T    |3 |x |x |x |x |x |x |x |x |
    G    |2 |x |x |x |x |x |x |x |x |
    A    |1 |x |x |x |x |x |x |x |x |
    C    |0 |x |x |x |x |x |x |x |x |
    T    |0 |x |x |x |x |x |x |x |x |
    A    |0 |x |x |x |x |x |x |x |x |
    
   (B)

(E矩阵)

              (Matrix E)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |  |  |  |  |  |  |  |  |  |  
    G    |  |0 |0 |0 |0 |0 |0 |0 |0 |
    G    |  |6 |4 |3 |2 |1 |0 |0 |0 |
    T    |  |5 |3 |7 |x |x |x |x |x |
    T    |  |4 |x |x |x |x |x |x |x |
    G    |  |3 |x |x |x |x |x |x |x |
    A    |  |2 |x |x |x |x |x |x |x |
    C    |  |1 |x |x |x |x |x |x |x |
    T    |  |0 |x |x |x |x |x |x |x |
    A    |  |0 |x |x |x |x |x |x |x |
    
   (B)

(F矩阵)

              (Matrix F)
         |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
    G    |0 |6 |5 |4 |3 |2 |1 |0 |
    G    |0 |4 |3 |x |x |x |x |x |
    T    |0 |3 |2 |x |x |x |x |x |
    T    |0 |2 |x |x |x |x |x |x |
    G    |0 |1 |x |x |x |x |x |x |
    A    |0 |0 |x |x |x |x |x |x |
    C    |0 |0 |x |x |x |x |x |x |
    T    |0 |0 |x |x |x |x |x |x |
    A    |0 |0 |x |x |x |x |x |x |
    
   (B)

继续计算直到完整填充......

(H矩阵)

              (Matrix H)
            |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
         |8 |6 |5 |4 |3 |2 |1 |0 |0 |
    G    |6 |5 |9 |7 |6 |5 |4 |4 |3 |
    G    |5 |3 |8 |6 |5 |4 |3 |7 |7 |
    T    |4 |8 |6 |11|9 |9 |8 |7 |6 |
    T    |3 |7 |x |x |x |x |x |x |x |
    G    |2 |5 |x |x |x |x |x |x |x |
    A    |1 |4 |x |x |x |x |x |x |x |
    C    |0 |3 |x |x |x |x |x |x |x |
    T    |0 |3 |x |x |x |x |x |x |x |
    A    |0 |x |x |x |x |x |x |x |x |
    
   (B)

(E矩阵)

              (Matrix E)
         |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
    G    |0 |0 |0 |0 |0 |0 |0 |0 |
    G    |6 |4 |3 |2 |1 |0 |0 |0 |
    T    |5 |3 |7 |5 |4 |3 |2 |2 |
    T    |4 |2 |6 |4 |3 |2 |1 |5 |
    G    |3 |6 |x |x |x |x |x |x |
    A    |2 |5 |x |x |x |x |x |x |
    C    |1 |4 |x |x |x |x |x |x |
    T    |0 |3 |x |x |x |x |x |x |
    A    |0 |2 |x |x |x |x |x |x |
         |0 |1 |x |x |x |x |x |x |
    
   (B)

(F矩阵)

              (Matrix F)
         |T |G |T |T |A |C |G |G |   (A)
   ------------------------------------------
    G    |0 |6 |5 |4 |3 |2 |1 |0 |0 |
    G    |0 |4 |3 |7 |6 |5 |4 |3 |2 |
    T    |0 |3 |2 |6 |5 |4 |3 |2 |5 |
    T    |0 |2 |6 |5 |7 |9 |8 |7 |6 |
    G    |0 |1 |x |x |x |x |x |x |x |
    A    |0 |0 |x |x |x |x |x |x |x |
    C    |0 |0 |x |x |x |x |x |x |x |
    T    |0 |0 |x |x |x |x |x |x |x |
    A    |0 |0 |x |x |x |x |x |x |x |
    
   (B)

这里不再计算,留给读者自己验证……


参考资料:

1.Optimized and Portable FPGA-Based Systolic Cell Architecture for Smith–Waterman-Based DNA Sequence Alignment

2.Wiki-en

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,080评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,422评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,630评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,554评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,662评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,856评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,014评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,752评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,212评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,541评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,687评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,347评论 4 331
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,973评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,777评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,006评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,406评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,576评论 2 349

推荐阅读更多精彩内容