Docsity

Bioinformatics Algorithms: Solving Biological Problems, Schemes and Mind Maps of Chinese

Toggle sidebar
bg1
CME 4425 – Fall 2023
HW2: yaman efe gümüş
You will use ROSALIND web page to do this homework. It is a free resource page to make
exercises for Bioinformatics courses. You should follow these steps to complete your
homework.
1. Register ROSALIND via this page http://rosalind.info/
2. Login with your username and password.
3. Click “Problem” section from tab menu, then choose a view style (e.g. list view).
4. Solve at least one problem from each topic listed below:
Counting DNA Nucleotides (DNA)
Transcribing DNA into RNA (RNA)
Complementing a Strand of DNA (REVC)
Finding a Motif in DNA (SUBS)
Translating RNA into Protein (PROT)
RNA Splicing (SPLC)
5. Paste the real question (that is asked by the system in your session), your answer to
asked question, and your code for each problem, e.g.:
Asked Question (by the system) :
My Answer :
My Code :
You will need to do coding for each question, therefore:
- Read the example question and understand necessary input and output formats.
- Implement your solution with your preferred programming language.
- Request a real question from the ROSALIND system.
You will have maximum 5 minutes to reply each question. If your answer is wrong, you can
request a new question from the same topic. If you do not follow this specific question
order, you can not proceed to the next question.
6. Save your work in a “YourStudentID.docx/.pdf” file and upload to the Sakai/Hw2 until
Oct 31, 2023, 23:55 pm.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Bioinformatics Algorithms: Solving Biological Problems and more Schemes and Mind Maps Chinese in PDF only on Docsity!

CME 4425 – Fall 2023

HW2: yaman efe gümüş

You will use ROSALIND web page to do this homework. It is a free resource page to make

exercises for Bioinformatics courses. You should follow these steps to complete your

homework.

1. Register ROSALIND via this page http://rosalind.info/

2. Login with your username and password.

3. Click “Problem” section from tab menu, then choose a view style (e.g. list view).

4. Solve at least one problem from each topic listed below:

Counting DNA Nucleotides (DNA)

Transcribing DNA into RNA (RNA)

Complementing a Strand of DNA (REVC)

Finding a Motif in DNA (SUBS)

Translating RNA into Protein (PROT)

RNA Splicing (SPLC)

5. Paste the real question (that is asked by the system in your session), your answer to

asked question, and your code for each problem, e.g.:

Asked Question (by the system) :

My Answer :

My Code :

You will need to do coding for each question, therefore:

- Read the example question and understand necessary input and output formats.

- Implement your solution with your preferred programming language.

- Request a real question from the ROSALIND system.

You will have maximum 5 minutes to reply each question. If your answer is wrong, you can

request a new question from the same topic. If you do not follow this specific question

order, you can not proceed to the next question.

6. Save your work in a “YourStudentID.docx/.pdf” file and upload to the Sakai/Hw2 until

Oct 31, 2023, 23:55 pm.

Counting DNA Nucleotides (DNA)

Asked Question (by the system) :

A string is simply an ordered collection of symbols selected from some alphabet and

formed into a word; the length of a string is the number of symbols that it contains.

An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', 'G',

and 'T') is "ATGCTTCAGAAAGGTCTTACG."

Given: A DNA string s

of length at most 1000 nt.

Return: Four integers (separated by spaces) counting the respective number of times that

the symbols 'A', 'C', 'G', and 'T' occur in s

My Answer :

My Code :

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)

Transcribing DNA into RNA (RNA)

Asked Question (by the system) :

An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'.

Given a DNA string t� corresponding to a coding strand, its transcribed RNA string u� is

formed by replacing all occurrences of 'T' in t� with 'U' in u�.

Given: A DNA string t� having length at most 1000 nt.

Return: The transcribed RNA string of t�.

My Answer :

GCACAUUAUCACGCAUUAGACUCGAGCCACGGGCCUCUCAGUGGCUCUCGUCCUG

AACGUGGGAAGGCACUUCGGAGGCUGGGAUAACUGAAUCUCGAAGCGAUUUGUGG

UGGCUUUAGAACCAAGAAGUUGGCGUUCGGGCUAUCAUACGCAGAAUCCAGUACA

ACCAGACGACAGACACAUAUCUUAGUUGUAUUGCCGGUCAAAUAAACGUAGCCCGA

CACUAAAUUGUUAACACUCUCAUGUACCUGGAAUGUUGGAGAUACAAAGGACGGUU

GUGUUGGAUGAUUUAGGGACCUCCGCACCUCUUCAAAUCAUAAAAGAAAGGCCGG

CUGAUUCGACUUAAAUCAAGAGGUAAGCGUUUCCAUCGGUUCUGGCUCCGGGUAU

AAAAUAGUACUUUCGCCGGAUUCAACGAUUGCAGCUUGUCAACAACAUCCUGUGAG

CAUCCUACAUUGUAUUGAGUAGGGUCUGUUUAGCCGCCAAUUUAAAUGACUACGU

CCAGAGGAUAAUCAUAUACACCCAGGGACUGUUAUUGGACUAUUUUCGGUCCGGG

CCCUACUACAAAACGAUAUAUGUGACAGGCAGGGUUAGGGGUGUCUACCAGUUAC

My Code :

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

Finding a Motif in DNA (SUBS)

Asked Question (by the system) :

Given two strings s� and t�, t� is a substring of s� if t� is contained as a contiguous

collection of symbols in s� (as a result, t� must be no longer than s�).

The position of a symbol in a string is the total number of symbols found to its left,

including itself (e.g., the positions of all occurrences of 'U' in

"AUGCUUCAGAAAGGUCUUACG" are 2, 5, 6, 15, 17, and 18). The symbol at

position i� of s� is denoted by s[i]�[�].

A substring of s� can be represented as s[j:k]�[�:�], where j� and k� represent the

starting and ending positions of the substring in s�; for example, if s� =

"AUGCUUCAGAAAGGUCUUACG", then s[2:5]�[2:5] = "UGCU".

The location of a substring s[j:k]�[�:�] is its beginning position j�; note that t� will

have multiple locations in s� if it occurs more than once as a substring of s� (see the

Sample below).

Given: Two DNA strings s� and t� (each of length at most 1 kbp).

Return: All locations of t� as a substring of s�.

My Answer :

My Code :

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

Translating RNA into Protein (PROT)

Asked Question (by the system) :

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.

Given: An RNA string s� corresponding to a strand of mRNA (of length at most 10 kbp).

Return: The protein string encoded by s�.

My Answer :

MESGGKICPCDTTTIASEVVSKHSTKLNQMIDTCYIDKPNRQTRISKLIGNQSLDRAVCQAI

SSRGGGSYYTNGVGMSWLKIYSRSGSIETSRGIFMSFISIATRANLEDLYSRNTRVARALH

EQTGTDALRLLYLATLDPVREVRIIVSHSRTWVASIKNMLQTWGGDGASNVPWLVAYSGT

REDITLLPIAELQRVDVPFVHTGCLDFPMSAYCTKEHDVKVTRQCVIRVTRPWAGTMCIDL

GNLQLRDISTKIRTKTGELGFPFSAHLIGECLVRSFPDPPRVHPDLGQLRPIAFAVSGHGP

EKPVLAYPRSSVAVVNDVISPEMSAWDIAFSALKSTCGARSDHDHTPSRIETASLTKMHQ

VKRETGPVTNAHQQSGSGGVPWKSTTRWLFLIEICVLMATSELCKSSLRVSTEVLVACD

GYAAWVVIGILPSDNQSVKASVSGRHGHTWPRSRRTTATIYMRGCAAKWSGTLQPSPP

GDVVWWDIGNRLRLLCGFPSEYNRGASFRIDIKLPPSIPIGGCLVVGFSRLAFQHYTSIRL

GRVMNAFHGESRFSPRREHGMLVVPFYLLIATIAVTSRSGILAVFTRPQEILTLRWSRLTF

SNTPKYSLTDSDLRLQPLQTKQPNSWRGNTFMISRYRYSLCANIDSSKCPSLRTCIQHEQ

TRVAPHVHRRWLSLLTRAKDISAALEFSVHNSCSVGTPTSCMRTLTSWANPSSRALVVP

DAPDAFMLCVTVCLIQPVANGLLLLCPIPFCKRCPTSRNRGFHFYELISICRAWIETIKPVR

AQRRSPRPPIAIPELSKKNCTRGIGNAELRLYQSPTTMITCFIYGGCDRWHINYGLPPTVR

RIMLNSGGSYSICCRGRMMSDDASAGLGFPVFCCWPNNIRFASRAGSWIWSTSHGREH

SVMFFGTVQIRDLYRKRPLFFSRYPWLACITTTICVLQPAQRQHSSLCYFPWLTSEGCKV

SLWVINLHRAVFRLNTIPNLYTTVLYPGKCDTPVSRQCILCGSTVSRIKNAWSRCSSPSAR

LYRKQSSTLTSPSAFPIKEPSLIGLRLVVVIMATRSSTGAAANERREYTVRSGCGVAHTVR

RVYRYETTRHKTARGFSSVLYARMMDSSSRHRCITDEGARCKHVTDHALLCRCDNLRTL

THATMYCERWRTTSNDAACDLLAAKCLAAGIPWQTTSPHKDDSLDHCSGRQGETDRVY

YVATFRAGIFIRTTSLTQYEHVPCLSSFVSTLSCIVWRAYLIGRSQCVVDEATICSPSAPFV

SAVVFGTPESLPVLVQRGLVYAGSLFYEGWLDPVHSFSKTCISADKEVIPGGGGLTYAAR

NTGLLVVQEVHISMACPYKESFMSSSKSAALTLVGPARGPSRMFSIKVSRHRLGLNLRRG

LPRYSPHDSGVIGPTCVAKLDQGRFKARPPIELSVLFPLVGSALPGQVTALALTSYDIQLT

QRGDTADGPTASDARAMNLGHTHWELKTADDRMNEPMENQSVNTLALCDDTQIITRMIH

EVMVTHRETGRLADEPYNFYNSGVRFITQQKCPDASVRSCQFKCRLSSRHTYPAMKTCR

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="")

RNA Splicing (SPLC)

Asked Question (by the system) :

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.

Given: A DNA string s� (of length at most 1 kbp) and a collection of substrings of s� acting as introns. All

strings are given in FASTA format.

Return: A protein string resulting from transcribing and translating the exons of s�. (Note: Only one

solution will exist for the dataset provided.)

My Answer :

MTPFACNCPTPNRVQIFVRPQESPRSSVRAAILAPPIAVISRTIDKVDYPEESSLLLCVILPE

STRSSGSITKGFILPEVEGPQTHLLGRPMVSDYSLHFQHPDGVPGQYTYCCDRDTIARDA

HQFYQFHMGCSITTAGFGVKGYPPYYILLRSSTADHPL

My Code :

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