





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






with open('rosalind_dna.txt', 'r') as file: file_content = file.read() a = 0 t = 0 g = 0 c = 0 for char in file_content: if char == "A": a += 1 elif char == "T": t += 1 elif char == "G": g += 1 elif char == "C": c += 1 print(a, c, g, t)
with open('rosalind_revc.txt', 'r') as file: file_content0 = file.read() file_content = list(file_content0) i = 0 for char in file_content: if char == "A": file_content[i] = "T" elif char == "T": file_content[i] = "A" elif char == "G": file_content[i] = "C" elif char == "C": file_content[i] = "G" i += 1 i = 0 for char in file_content: print(file_content[len(file_content) - i - 1], end="") i += 1
with open('rosalind_subs.txt', 'r') as file: xd = 0 for line in file: if xd == 0: file_content0 = line xd = 5 else: sample = line file_content = list(file_content0) i = 0 locations = [] for char in file_content:
if char == sample[0]: s = 0 flag = True for char in sample: if char == file_content[i + s]: s += 1 if s == len(sample): locations += [1 + i] continue else: flag = False break i += 1 i = 0 for object in locations: print(object, end=" ") i += 1
The 20 commonly occurring amino acids are abbreviated by using 20 letters from the English alphabet (all letters except for B, J, O, U, X, and Z). Protein strings are constructed from these 20 symbols. Henceforth, the term genetic string will incorporate protein strings along with DNA strings and RNA strings. The RNA codon table dictates the details regarding the encoding of specific codons into the amino acid alphabet.
i = 0 content = [] count = len(file_content) / 3 while i < count: x = i * 3 content += [file_content[x] + file_content[x + 1] + file_content[x + 2]] i += 1 code = [] stop = False for codons in content: for codon in codon_table: if codon[0] == codons: if codon[1] == 'Stop': stop = True break else: code += codon[1] break elif codon[2] == codons: code += codon[3] break if stop == True: break for object in code: print(object, end="")
After identifying the exons and introns of an RNA string, we only need to delete the introns and concatenate the exons to form a new string ready for translation.
strings are given in FASTA format.
solution will exist for the dataset provided.)
file_path = "rosalind_splc.txt" lines = [] with open(file_path, 'r') as file: for line in file: lines.append(line.strip()) dna_string = "" introns = [] flag = 0 i = 0 for line in lines: if line[0] == ">": flag += 1 elif flag == 1: dna_string += line
else: introns.append(line) i += 1 dna_string = list(dna_string) i = 0 coordinates = [] flag = False for dna in dna_string: for intron in introns: if dna == intron[0]: flag = False s = 0 for char in intron: if i + s >= len(dna_string): break elif char == dna_string[i + s]: s += 1 if s == len(intron): flag = True coordinates.insert(len(coordinates) , [i , s]) break else: break if flag == True: flag = False break i += 1 for coordinate in coordinates: x = 0 while x < coordinate[1]: dna_string[coordinate[0] + x] = "" x += 1 clean_dna = [] for dna in dna_string: if dna != "": clean_dna.append(dna) i = 0 for char in clean_dna: if char == "T": clean_dna[i] = "U" i += 1 data = """ UUU F CUU L AUU I GUU V UUC F CUC L AUC I GUC V UUA L CUA L AUA I GUA V UUG L CUG L AUG M GUG V UCU S CCU P ACU T GCU A UCC S CCC P ACC T GCC A UCA S CCA P ACA T GCA A UCG S CCG P ACG T GCG A UAU Y CAU H AAU N GAU D UAC Y CAC H AAC N GAC D UAA Stop CAA Q AAA K GAA E