Changes

From Biolecture.org

Minsu Kim/python

3,901 bytes removed, 18:27, 12 December 2017
Replaced content with "<p>here is my coding source</p> <p>I don't know how ipynb files upload..so just upload code and image without the ipynb files.</p> <hr /> <h2> </h2> <p>..."
<h2>&nbsp;</h2>
<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 href= 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;"http:<br />&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;U&#39;<br />a = &#39;&#39;biolecture.join(text)<org/p> <p>print(a)</p> <p>f = open(&#39;rosalind_revc2.txt&#39;,&#39;r&#39;)<br />b = findex.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] =php?title= &#39;G&#39;:<br Minsu_Kim/>&nbsp; &nbsp; &nbsp; &nbsp; text[i] = &#39;C&#39;<br python />&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 = open(&#39;rosalind_gc.txt&#39;,&#39;r&#39;)<br />seq_list = dict()<br />for line in f_fa:<br />&nbsp; &nbsp; if line.startswith(&#39;&gt;&#39;):<br />&nbsp; &nbsp; &nbsp; &nbsp; name = line.strip(&#39;&gt;&#39;).strip()<br />&nbsp; &nbsp; &nbsp; &nbsp; seq_list[name] = &#39;&#39;<br />&nbsp; &nbsp; else:<br />&nbsp; &nbsp; &nbsp; &nbsp; seq_list[name]= line.strip()<br />f_fa.close()</p> <p>seq_CG = dict()<br />for k in seq_list:<br />&nbsp; &nbsp; count = 0<br />&nbsp; &nbsp; s = seq_list[k]<br />&nbsp; &nbsp; s = list(s)<br />&nbsp; &nbsp; for i in range(0,len(s)):<br />&nbsp; &nbsp; &nbsp; &nbsp; if s[i] == &#39;C&#39; or s[i] == &#39;G&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count = count + 1<br />&nbsp; &nbsp; p = count / len(s)<br />&nbsp; &nbsp; seq_CG[k] = p</p> <p>inverse = [(value, key) for key, value in seq_CG.items()]<br />max(inverse)</p> <p>import matplotlib.pyplot as plt</p> <p>seq_list = []<br />f_fa = open(&#39;Ecoli_genome.fasta&#39;, &#39;r&#39;)<br />for line in f_fa:<img alt="" src="/ckfinder/userfiles/images/e_coli%20gc%20content.jpg" style="float:right; height:400px; width:400pxBasics" />Python basics<br /a>&nbsp; &nbsp; if not line.startswith(&#39;&gt;&#39;):<br />&nbsp; &nbsp; &nbsp; &nbsp; seq_list.append(line.strip())<br />tmp_seq = &#39;&#39;.join(seq_list)</p> <p>count_G = 0<br />count_C = 0<br />count_list = []<br />for tmp_n in tmp_seq:<br />&nbsp; &nbsp; if tmp_n == &#39;G&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; count_G += 1<br />&nbsp; &nbsp; if tmp_n == &#39;C&#39;:<br />&nbsp; &nbsp; &nbsp; &nbsp; count_C += 1<br />&nbsp; &nbsp; count_list.append(count_G-count_C)</p> <p>pos_list = range(0,len(tmp_seq))</p> <p>fig = plt.figure(figsize = (10,6))<br />ax1 = fig.add_subplot(1,1,1)<br />ax1.plot(pos_list, count_list, &#39;b-&#39;)<br />ax1.grid()<br />plt.show()<br />f_fa.close()</p>
<p>&nbsp;</p>
<p>&nbsp;<a href="http://biolecture.org/index.php?title=Minsu_Kim/python/Rosalind">Rosalind</a></p>
Anonymous user

Navigation menu