Changes
Created page with "<h2>function</h2> <p>def patterncount(text, pattern):<br /> count=0<br /> for i in range(0,len(text)):<br /> if(text[i:le..."
<h2>function</h2>
<p>def patterncount(text, pattern):<br />
count=0<br />
for i in range(0,len(text)):<br />
if(text[i:len(pattern)+i]==pattern):<br />
count += 1<br />
return count</p>
<p>def complementing(sequence):<br />
sequence = sequence[::-1]<br />
text = list(sequence)<br />
for i in range(0,len(text)):<br />
if text[i] == 'A':<br />
text[i] = 'T'<br />
elif text[i] == 'G':<br />
text[i] = 'C'<br />
elif text[i] == 'C':<br />
text[i] = 'G'<br />
elif text[i] == 'T':<br />
text[i] = 'A'<br />
<br />
s = ''.join(text)<br />
print(s)<br />
return 0</p>
<h1>rosalind transcript basic</h1>
<p>f = open('rosalind_rna.txt')<br />
a = f.readline()<br />
f.close</p>
<p>text = list(a)</p>
<p>for i in range(0,len(text)):<br />
if text[i] == 'T':<br />
text[i] = 'U'<br />
a = ''.join(text)</p>
<p>print(a)</p>
<p>f = open('rosalind_revc2.txt','r')<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 />
if text[i] == 'A':<br />
text[i] = 'T'<br />
elif text[i] == 'G':<br />
text[i] = 'C'<br />
elif text[i] == 'C':<br />
text[i] = 'G'<br />
elif text[i] == 'T':<br />
text[i] = 'A'<br />
<br />
b = ''.join(text)</p>
<p>print(b)</p>
<h2>Computing CG Content</h2>
<p>f_fa = open('rosalind_gc.txt','r')<br />
seq_list = dict()<br />
for line in f_fa:<br />
if line.startswith('>'):<br />
name = line.strip('>').strip()<br />
seq_list[name] = ''<br />
else:<br />
seq_list[name]= line.strip()<br />
f_fa.close()</p>
<p>seq_CG = dict()<br />
for k in seq_list:<br />
count = 0<br />
s = seq_list[k]<br />
s = list(s)<br />
for i in range(0,len(s)):<br />
if s[i] == 'C' or s[i] == 'G':<br />
count = count + 1<br />
p = count / len(s)<br />
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('Ecoli_genome.fasta', 'r')<br />
for line in f_fa:<img alt="" src="/ckfinder/userfiles/images/e_coli%20gc%20content.jpg" style="float:right" /><br />
if not line.startswith('>'):<br />
seq_list.append(line.strip())<br />
tmp_seq = ''.join(seq_list)</p>
<p>count_G = 0<br />
count_C = 0<br />
count_list = []<br />
for tmp_n in tmp_seq:<br />
if tmp_n == 'G':<br />
count_G += 1<br />
if tmp_n == 'C':<br />
count_C += 1<br />
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, 'b-')<br />
ax1.grid()<br />
plt.show()<br />
f_fa.close()</p>
<p> </p>
<p>def patterncount(text, pattern):<br />
count=0<br />
for i in range(0,len(text)):<br />
if(text[i:len(pattern)+i]==pattern):<br />
count += 1<br />
return count</p>
<p>def complementing(sequence):<br />
sequence = sequence[::-1]<br />
text = list(sequence)<br />
for i in range(0,len(text)):<br />
if text[i] == 'A':<br />
text[i] = 'T'<br />
elif text[i] == 'G':<br />
text[i] = 'C'<br />
elif text[i] == 'C':<br />
text[i] = 'G'<br />
elif text[i] == 'T':<br />
text[i] = 'A'<br />
<br />
s = ''.join(text)<br />
print(s)<br />
return 0</p>
<h1>rosalind transcript basic</h1>
<p>f = open('rosalind_rna.txt')<br />
a = f.readline()<br />
f.close</p>
<p>text = list(a)</p>
<p>for i in range(0,len(text)):<br />
if text[i] == 'T':<br />
text[i] = 'U'<br />
a = ''.join(text)</p>
<p>print(a)</p>
<p>f = open('rosalind_revc2.txt','r')<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 />
if text[i] == 'A':<br />
text[i] = 'T'<br />
elif text[i] == 'G':<br />
text[i] = 'C'<br />
elif text[i] == 'C':<br />
text[i] = 'G'<br />
elif text[i] == 'T':<br />
text[i] = 'A'<br />
<br />
b = ''.join(text)</p>
<p>print(b)</p>
<h2>Computing CG Content</h2>
<p>f_fa = open('rosalind_gc.txt','r')<br />
seq_list = dict()<br />
for line in f_fa:<br />
if line.startswith('>'):<br />
name = line.strip('>').strip()<br />
seq_list[name] = ''<br />
else:<br />
seq_list[name]= line.strip()<br />
f_fa.close()</p>
<p>seq_CG = dict()<br />
for k in seq_list:<br />
count = 0<br />
s = seq_list[k]<br />
s = list(s)<br />
for i in range(0,len(s)):<br />
if s[i] == 'C' or s[i] == 'G':<br />
count = count + 1<br />
p = count / len(s)<br />
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('Ecoli_genome.fasta', 'r')<br />
for line in f_fa:<img alt="" src="/ckfinder/userfiles/images/e_coli%20gc%20content.jpg" style="float:right" /><br />
if not line.startswith('>'):<br />
seq_list.append(line.strip())<br />
tmp_seq = ''.join(seq_list)</p>
<p>count_G = 0<br />
count_C = 0<br />
count_list = []<br />
for tmp_n in tmp_seq:<br />
if tmp_n == 'G':<br />
count_G += 1<br />
if tmp_n == 'C':<br />
count_C += 1<br />
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, 'b-')<br />
ax1.grid()<br />
plt.show()<br />
f_fa.close()</p>
<p> </p>