ࡱ> KMJ5@ bjbj22 %0XX,,,,,X4,hyyy+++++++$x-R/p+yyyyy++k'k'k'yB+k'y+k'k'}'V9*@* 0,"Ry*(++0,* :0 &H:0**&:0*yyk'yyyyy++hU'hPython Language Input/Output Redirection Functions Strings Example 1: Write a Python program that accepts as an input two strings and finds the maximal alignment score if no internal gaps are allowed and the score of match is 1 and the score of mismatch is 0. The gaps at the beginning and the end of the short sequence are allowed and will be counted as mismatches. The program prints the best alignment. You can assume that length (first sequence) >= length (second sequence) Solution: #function definition #function calculates the alignment score of seq1 and seq2 def scoreAlign (seq1, seq2): i=0 sum=0 length=len(seq1) while i ? ( ) = > ? q r s t   3 4 6 hp#\ h\ haj\ hG\ h o\ h#0\h h \ h \ hQ\ h\; \h\; h\; 5\hQhQ5 hb5 haj5 hJ5 h9Y 5 h\; 5 hg5 hKo5 h5>* hQ5>* hQ53)3;<GH  > ? \ h v  ! " ( ) >  & F$a$> ? m       + 2 4 5 6 H O [ i  `gd#0gd o6 > ? @ B H   3 I J T W Z i j k v ~ ()H\]^=IJ5ļw!h 0J5CJOJQJ^JaJ'hShS0J5CJOJQJ^JaJ hS\ hV\ hV5\hVhV5\ h\hh\ h^\hy0rhy0r5>*\hy0r5>*\ hy0r\ hQ\ hJ\ hG\ haj\ h;\ h \*   % 3 H J T W Y j k  ^`gdG ^`gdaj`gd#0 )GH]^=JZmzq*Ggd#gdV5p̼wdQd@!h 0J5CJOJQJ^JaJ$h hP0JCJOJQJ^JaJ$h h 0JCJOJQJ^JaJ!h 0J5CJOJQJ^JaJ'hPhP0J5CJOJQJ^JaJh@*-0JCJOJQJ^JaJh#0JCJOJQJ^JaJh 0JCJOJQJ^JaJ!hS0J5CJOJQJ^JaJ!h#0J5CJOJQJ^JaJ!h,0J5CJOJQJ^JaJGS{ c}~d6@dngdqgd$79gd bc|~,LUZcʺwfRA+A+*h`iGh`iG0J56CJOJQJ^JaJ!h`iG0J5CJOJQJ^JaJ'h`iGh`iG0J5CJOJQJ^JaJ!hTJ0J5CJOJQJ^JaJhP0JCJOJQJ^JaJ h$79h$79CJOJQJ^JaJh$79CJOJQJ^JaJ'h$79h$790J5CJOJQJ^JaJh$790JCJOJQJ^JaJ$h$79h$790JCJOJQJ^JaJ!h 0J5CJOJQJ^JaJ!h$790J5CJOJQJ^JaJcdz6?@nopʶ}v}lgbZPK h^\hVhV5\hVhV\ hV\ hS\hSh 5\ h5\ h 5\ hS5\hShq5\hqh \hqhq\ hqhqCJOJQJ^JaJ'hqhq0J5CJOJQJ^JaJh^0JCJOJQJ^JaJh`iG0JCJOJQJ^JaJ*h`iGh 0J56CJOJQJ^JaJnopzgd  #1h;0/ =!"#$%h@h Normal$ *$1$A$a$+B*CJOJPJQJ^J_HaJmH sH tHDA@D Default Paragraph FontViV  Table Normal :V 44 la (k(No List 2O2 WW8Num1z0OJQJ2O2 WW8Num1z1OJQJ2O2 WW8Num1z2OJQJ2O!2 WW8Num2z0OJQJ2O12 WW8Num2z1OJQJ2OA2 WW8Num2z2OJQJJOQJ WW-Default Paragraph Font6B@b6 Body Text x(/@ar( List^JJOJ Caption1 xx $6CJ]^JaJ.O. Index $^JNg@N SHTML TypewriterCJOJPJQJ^JaJ.X@. SEmphasis6]e@ $79HTML Preformatted: 2( Px 4 #\'*.25@9*$CJOJQJ^JaJtH 0)3;<GH>?\hv!"()>?m  +2456HO[i%3HJTWYjk)GH]^=JZmzq   * G S {   c } ~   d  6 @ d n o p z 0 0p 0p 0p0p0p0p000p0 00p0p00000 00p0 00 0p0 0 00 00 000 00 0 00000 00(0 00 0 00 0p0 0p0 0p000000000000000000000000000000000000 0 0 000 00 00(0 0 00 0(080 0(0 0 0 0(0@0 0 000000000000000000000p0p00 00000000000!"(?)GH^mzq    c  6 o O90DDO90O90DDO90O90O90O90DX@dO90O90O90 DhhdO90 O90 O90O90O90O90O90O90DeO90O90M900M90O90O90DO90O90O90O90ӡO90O90Oy0O90  Gn 8@̙0(  H c $̙ ?CMde DMfit},-<=fgJKNO=FhkmxEHQXZ`syz!+NXr}~! + d n   ! ( 2 : ; E [ c d n   s v   : = L U q z ~    ' * < ? @ C F X j m ",`nt~?Bpt~)-HNx~6;PU\akp'*kpHLZ`mrzr~  * / G L S X {  c i  ' d n   6 ; @ C d i 333333333333333333333333333333333333333333333333333333333333333333333323;<Fq?d)? ,36IkJj)Gz * { d d n   yana^`OJQJ^`OJQJ^`^`^`^`^`^`^`^`^`WW8Num1WW8Num2vbHc)(7:b\; 9Y ;p#,@*-#0$79`iGTJ^aj n oKoy0r{rQ#P Jq SgGT4^ VG@  ~~  P@UnknownGz Times New Roman5Symbol3& z Arial?5 z Courier New;Wingdings5& zaTahomaBAhEF+Mf-< < %24 3L(?CSCI 131  Python Language yanayana   Oh+'0 $ @ L X dpxCSCI 131 Python LanguageSCI yana31yanyanNormal1yanal145aMicrosoft Word 10.0@@`{B @,E@9< ՜.+,0  hp   rutgers A CSCI 131 Python Language Title  "#$%&'()*+,-./0123456789;<=>?@ACDEFGHILRoot Entry F08NData 1Table!R0WordDocument%0SummaryInformation(:DocumentSummaryInformation8BCompObjj  FMicrosoft Word Document MSWordDocWord.Document.89q