Open main menu

Biolecture.org β

Changes

Minsu Kim/python/Rosalind

1,264 bytes added, 13:33, 13 December 2017
no edit summary
<h2h4>functionI solve the problem related&nbsp;to the bioinformatics in web site : rosalind</h2h4>
<ph1>def patterncount(text, pattern):Problem<br />&nbsp; &nbsp; count=0<br />&nbsp; &nbsp; for i in range(0,len(text)):<br />&nbsp; &nbsp; &nbsp; &nbsp; if(text[i:len(pattern)+i]==pattern):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count += 1<br />&nbsp; &nbsp; return count</ph1>
<p>def complementing(sequence):<br />&nbsp; &nbsp; sequence = sequence[::-1]<br />&nbsp; &nbsp; text = list(sequence)<br />&nbsp; &nbsp; for i in range(0,len(text)):<br />&nbsp; &nbsp; &nbsp; &nbsp; if text[i] == &#39;A&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;T&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp; elif text[i] == &#39;G&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;C&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp; elif text[i] == &#39;C&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;G&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp; elif text[i] == &#39;T&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;A&#39;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; s = &#39;&#39;.join(text)<br />&nbsp; &nbsp; print(s)<br />&nbsp; &nbsp; return 0basic problem</p>
<h1p>rosalind transcript basic<a href="http:/h1/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">[2]</a>&nbsp; &nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / b3">[3]</a></p>
<p>f = open(&#39;rosalind_rna.txt&#39;)<br />a = f.readline()<br />f.closerelated with bioinformatics</p>
<p>text <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem1">[1]</a>&nbsp; &nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem2">[2]</a>&nbsp; &nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem3">[3]</a>&nbsp; &nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind /problem4">[4]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind /problem5">[5]</a> &nbsp; <a href="http://biolecture.org/index.php?title= list(Minsu_Kim/python/Rosalind /problem6">[6]</a)></p>
<p>for i in range(0,len(text))<a href="http:<br //biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem7">&nbsp; &nbsp; if text[i7] == &#39;T&#39;:<br /a>&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;U&#39;<br />a href= &#39;&#39;.join(text)<"http:/p> <p>print(a)</p> <p>f = open(&#39;rosalind_revc2biolecture.txt&#39;,&#39;r&#39;)<br org/>b index.php?title= f.readline()<br Minsu_Kim/python/>f.close<Rosalind /p> <pproblem8">b = b[::-18]<br /a>text = list(b)</p> <p>for i in range(0,len(text)):<br />&nbsp; &nbsp; if text[i] <a href="http://biolecture.org/index.php?title= &#39;A&#39;:<br Minsu_Kim/python/Rosalind /problem9">&nbsp; &nbsp; &nbsp; &nbsp; text[i9] = &#39;T&#39;<br /a>&nbsp; &nbsp; elif text[i] <a href="http://biolecture.org/index.php?title= &#39;G&#39;:<br Minsu_Kim/python/Rosalind /problem10">&nbsp; &nbsp; &nbsp; &nbsp; text[i10] = &#39;C&#39;<br /a>&nbsp; &nbsp; elif text[i] <a href="http://biolecture.org/index.php?title= &#39;C&#39;:<br Minsu_Kim/python/Rosalind /problem11">&nbsp; &nbsp; &nbsp; &nbsp; text[i11] = &#39;G&#39;<br /a>&nbsp; &nbsp; elif text[i] <a href== &#39;T&#39;"http:<br />&nbsp; &nbsp; &nbsp; &nbsp; text[i] /biolecture.org/index.php?title= &#39;A&#39;<br Minsu_Kim/python/>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br Rosalind /problem12">b = &#39;&#39;.join(text)[12]</p> <pa>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