Skip to content

Needleman-Wunsch Algorithm for global alignment and local alignment

Notifications You must be signed in to change notification settings

bott0n/Needleman-Wunsch-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Needleman-Wunsch-Algorithm

Usage:

class ScoreParam:

    def __init__(self, gap, mismatch):
        self.gap = gap
        self.mismatch = mismatch
    def match(self, chr):
        if chr == 'A':
            return 3
        elif chr == 'C' or chr == 'T':
            return 2
        else:
            return 1
x = 'GAATTCAATACTCCACTTTCCATTCTGTTCAAAGGTCACGTATAGTCCTGGGAATACTCAGGGTTCTCACTTCATGGCTATGCAGGTATTTGTTCCCACA'
y = 'GAATTATACTCCACTTTCCAATGTGTAAAGGTCACTATATCCTGGCATAC'

local_align(x, y, score=ScoreParam(-4, -3))
# return 
# ('GAATTCAATACTCCACTTTCCAT-TC-TGTTCAAAGGTCACGTATAGTCCTGGG-AATAC', 
# GAATT--ATACTCCACTTTCCA-AT-GTG-T-AAAGGTCAC-TATA-TCCT-GGC-ATAC')
global_align(x, y, score=ScoreParam(-4, -3))
# return 
# ('GAATTCAATACTCCACTTTCCAT-TC-TGTTCAAAGGTCACGTATAGTCCTGGGAATACTCAGGGTTCTCACTTCATGGCTATGCAGGTATTTGTTCCCACA', 
# 'GAATT--ATACTCCACTTTCCA-AT-GTG-T-AAAGGT--C----A---C------TA-T-A------T--C--C-T-G----GC----A-----T---AC-')

Releases

No releases published

Packages

No packages published

Languages