Open main menu

Biolecture.org β

Changes

Minsu Kim/python/Rosalind

956 bytes added, 13:33, 13 December 2017
no edit summary
<h4>I solve the problem relative related&nbsp;to the bioinformatics in web site : rosalind</h4>
<ph1>&nbsp;Problem</ph1>
<h4><a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / function"p>basic function</a>problem</h4p>
<h4p><a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / b1">[1]</a>&nbsp;&nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / b2">[12]</a>&nbsp; &nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / b3">[3]</a></h4p>
<h2p>functionrelated with bioinformatics</h2p>
<p>def patterncount(text, pattern)<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem1">[1]<br /a>&nbsp; &nbsp; count<a href=0"http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem2">[2]<br /a>&nbsp; &nbsp; for i in range(0,len(text))<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem3">[3]<br /a>&nbsp; &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind /problem4">[4]</a> &nbsp; &nbsp; if(text<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind /problem5">[i:len(pattern)+i5]==pattern):<br /a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count +<a href="http://biolecture.org/index.php?title= 1Minsu_Kim/python/Rosalind /problem6">[6]<br /a>&nbsp; &nbsp; return count</p>
<p>def complementing(sequence):<br />&nbsp; &nbsp; sequence a href= sequence["http::-1]<br />&nbsp; &nbsp; text /biolecture.org/index.php?title= list(sequence)<br Minsu_Kim/python/>&nbsp; &nbsp; for i in range(0,len(text)):<br Rosalind /problem7">&nbsp; &nbsp; &nbsp; &nbsp; if text[i7] == &#39;A&#39;:<br /a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;T&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp; elif text[i] =a href= &#39;G&#39;"http:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] /biolecture.org/index.php?title= &#39;C&#39;<br Minsu_Kim/python/Rosalind /problem8">&nbsp; &nbsp; &nbsp; &nbsp; elif text[i8] == &#39;C&#39;:<br /a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;G&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp; elif text[i] a href== &#39;T&#39;"http:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;A&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br biolecture.org/>&nbsp; &nbsp; s index.php?title= &#39;&#39;.join(text)<br Minsu_Kim/>&nbsp; &nbsp; print(s)<br python/>&nbsp; &nbsp; return 0<Rosalind /pproblem9"<h1>rosalind transcript basic[9]</h1> <pa>f = open(&#39nbsp;rosalind_rna.txt&#39;)<br />a href= f"http://biolecture.readline()<br org/>findex.close<php?title=Minsu_Kim/p> <p>text = list(a)<python/p> <p>for i in range(0,len(text)):<br Rosalind /problem10">&nbsp; &nbsp; if text[i10] == &#39;T&#39;:<br /a>&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;U&#39;<br />a href= &#39;&#39;.join(text)</p> <p>print(a)<"http:/p> <p>f = open(&#39;rosalind_revc2.txt&#39;,&#39;r&#39;)<br />b = fbiolecture.readline()<br org/>findex.close</p> <p>b php?title= b[::-1]<br Minsu_Kim/>text = list(b)<python/p> <p>for i in range(0,len(text)):<br Rosalind /problem11">&nbsp; &nbsp; if text[i11] == &#39;A&#39;:<br /a>&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;T&#39;<br />&nbsp; &nbsp; elif text[i] =a href= &#39;G&#39;"http:<br />&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;C&#39;<br />&nbsp; &nbsp; elif text[i] biolecture.org/index.php?title== &#39;C&#39;:<br Minsu_Kim/>&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;G&#39;<br python/>&nbsp; &nbsp; elif text[i] == &#39;T&#39;:<br Rosalind /problem12">&nbsp; &nbsp; &nbsp; &nbsp; text[i12] = &#39;A&#39;<br /a>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />b = &#39;&#39;.join(text)</p> <p>print(b)</p>
<h2>Computing CG Content</h2>
<p>f_fa f&nbsp;= open(&#39;rosalind_gc.txt&#39;,&#39;r&#39;)<br />
seq_list = dict()<br />
for line in f_fa:<br />
&nbsp; &nbsp; else:<br />
&nbsp; &nbsp; &nbsp; &nbsp; seq_list[name]= line.strip()<br />
f_faf.close()</p>
<p>seq_CG = dict()<br />
<p>&nbsp;</p>
 
<h2>Dynamic Program</h2>
 
<p>def maxvalue(a,b,c):<br />
&nbsp; &nbsp; a=a+5<br />
&nbsp; &nbsp; b=b-6<br />
&nbsp; &nbsp; c=c-6<br />
&nbsp; &nbsp; return max(a,b,c)<br />
def maxvalue2(a,b,c):<br />
&nbsp; &nbsp; a=a-2<br />
&nbsp; &nbsp; b=b-6<br />
&nbsp; &nbsp; c=c-6<br />
&nbsp; &nbsp; return max(a,b,c)</p>
 
<p>def compare(a,b):<br />
&nbsp; &nbsp; import numpy as np<br />
&nbsp; &nbsp; scoring = np.zeros([len(a)+1,len(b)+1])<br />
&nbsp; &nbsp; for i in range(0,len(a)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; scoring[i,0]=-6*i<br />
&nbsp; &nbsp; for j in range(0,len(b)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; scoring[0,j]=-6*j</p>
 
<p>&nbsp; &nbsp; for row in range(1,len(a)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; for column in range(1,len(b)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if b[column-1]==a[row-1]:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scoring[row,column] = maxvalue(scoring[row-1,column-1],scoring[row-1,column],scoring[row,column-1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if b[column-1]!=a[row-1]:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scoring[row,column] = maxvalue2(scoring[row-1,column-1],scoring[row-1,column],scoring[row,column-1])<br />
&nbsp; &nbsp; print(scoring)</p>
 
<p>&nbsp; &nbsp; list=[]<br />
&nbsp; &nbsp; for row in range(1,len(a)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; for column in range(1,len(b)+1):<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new=scoring[row,column]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list.append(new)<br />
&nbsp; &nbsp; mxv=max(list)<br />
&nbsp; &nbsp; print(mxv)</p>
 
<p><img alt="" src="/ckfinder/userfiles/images/bandicam%202017-12-12%2019-14-32-803.jpg" style="height:530px; width:640px" /></p>
Anonymous user