Practical Bioinformatics Mark Voorhies 6/3/2013 Mark Voorhies Practical Bioinformatics
Needleman-Wunsch with g=0 A G C G G T A G A G C G G A Mark Voorhies Practical Bioinformatics
Needleman-Wunsch with g=0 A G C G G T A G A def n w f i l l ( seq1 , seq2 , s , e ) : G # m[ i ] [ j ] = best s c o r e f o r subalignment # of seq1 [ : i ] , seq2 [ : j ] C m = [ [ ] ] G G A Mark Voorhies Practical Bioinformatics
Needleman-Wunsch with g=0 A G C G G T A 0 -1 -2 -3 -4 -5 -6 -7 G -1 # Top l e f t c o r n e r A -2 m[ − 1]. append (0) # F i l l f i r s t row as l e a d i n g gaps G -3 f o r j i n range ( l e n ( seq2 ) ) : m[ − 1]. append (m[ 0 ] [ j ]+e ) C -4 # F i l l f i r s t column as l e a d i n g gaps i range ( l e n ( seq1 ) ) : f o r i n G -5 m. append ( [m[ i ] [ 0 ] + e ] ) G -6 A -7 Mark Voorhies Practical Bioinformatics
Needleman-Wunsch with g=0 A G C G G T A 0 -1 -2 -3 -4 -5 -6 -7 -1 -2 -3 -4 -5 G -1 f o r i i n range ( l e n ( seq1 ) ) : -1 0 f o r j i n range ( l e n ( seq2 ) ) : A -2 0 -1 -1 -2 -3 -4 -3 # Score f o r a l i g n i n g seq1 [ i ] with seq2 [ j ] match = m[ i ] [ j ]+ s [ seq1 [ i ] ] [ seq2 [ j ] ] -1 -2 -3 # Score f o r a l i g n i n g seq1 [ i ] with a gap G -3 -1 1 0 0 hgap = m[ i +1][ j ]+e # Score f o r a l i g n i n g seq2 [ i ] with a gap 2 1 0 -1 -2 C -4 -2 0 vgap = m[ i ] [ j +1]+e G -5 -3 -1 1 3 2 1 0 best = max( match , vgap , hgap ) m[ − 1]. append ( best ) -4 -2 2 4 3 2 G -6 0 A -7 -5 -3 -1 1 3 3 4 Mark Voorhies Practical Bioinformatics
Needleman-Wunsch with g=0 # S t a r t at bottom r i g h t c o r n e r curpos = ( l e n ( seq1 ) , l e n ( seq2 ) ) a l i g n e d 1 = ”” a l i g n e d 2 = ”” A G C G G T A e x i t F l a g = F a l s e 0 -1 -2 -3 -4 -5 -6 -7 f o r i i n range ( l e n ( seq1)+ l e n ( seq2 ) ) : p l i s t = p [ curpos [ 0 ] ] [ curpos [ 1 ] ] -1 -2 -3 -4 -5 G -1 -1 0 i f ( p l i s t i s None ) : e x i t F l a g = True -1 -1 -2 -3 -4 -3 A -2 0 break nextpos = p l i s t [ 0 ] -1 -2 -3 # Check f o r vgap G -3 -1 1 0 0 i f ( nextpos [ 0 ] == curpos [ 0 ] ) : a l i g n e d 1 = ” − ”+a l i g n e d 1 C 2 1 0 -1 -2 -4 -2 0 e l s e : a l i g n e d 1 = seq1 [ nextpos [ 0 ] ] + a l i g n e d 1 -3 -1 1 3 2 1 0 G -5 # Check f o r hgap i f ( nextpos [ 1 ] == curpos [ 1 ] ) : G -4 -2 2 4 3 2 -6 0 a l i g n e d 2 = ” − ”+a l i g n e d 2 e l s e : A -5 -3 -1 1 3 3 4 -7 a l i g n e d 2 = seq2 [ nextpos [ 1 ] ] + a l i g n e d 2 curpos = nextpos i f ( e x i t F l a g == F a l s e ) : ”WARNING: Unexpected e x i t from traceback ” p r i n t Mark Voorhies Practical Bioinformatics
Change of Coordinates http://xkcd.com/123/ Mark Voorhies Practical Bioinformatics
Phase-specific gene expression in Histoplasma capsulatum Diane Inglis Mark Voorhies Practical Bioinformatics
Phase-specific gene expression in
Phase-specific gene expression in Histoplasma capsulatum Diane Inglis Mark Voorhies Practical Bioinformatics
Recommend
More recommend