Open main menu

Biolecture.org β

Changes

Minsu Kim/python/Rosalind

2,160 bytes removed, 21:57, 12 December 2017
no edit summary
<p><a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem7">[7]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem8">[8]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem9">[9]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem10">[10]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem11">[11]</a> &nbsp; <a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind / problem12">[12]</a></p>
 
<h2>function</h2>
 
<p>def patterncount(text, pattern):<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</p>
 
<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 0</p>
 
<h1>rosalind transcript basic</h1>
 
<p>f = open(&#39;rosalind_rna.txt&#39;)<br />
a = f.readline()<br />
f.close</p>
 
<p>text = list(a)</p>
 
<p>for i in range(0,len(text)):<br />
&nbsp; &nbsp; if text[i] == &#39;T&#39;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;U&#39;<br />
a = &#39;&#39;.join(text)</p>
 
<p>print(a)</p>
 
<p>f = open(&#39;rosalind_revc2.txt&#39;,&#39;r&#39;)<br />
b = f.readline()<br />
f.close</p>
 
<p>b = b[::-1]<br />
text = list(b)</p>
 
<p>for i in range(0,len(text)):<br />
&nbsp; &nbsp; if text[i] == &#39;A&#39;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;T&#39;<br />
&nbsp; &nbsp; elif text[i] == &#39;G&#39;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;C&#39;<br />
&nbsp; &nbsp; elif text[i] == &#39;C&#39;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;G&#39;<br />
&nbsp; &nbsp; elif text[i] == &#39;T&#39;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;A&#39;<br />
&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 />
Anonymous user