id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > orf
prev  |  next  |  chance

An Open Reading Frame (ORF) is a sequence of codons that starts with ATG and ends with either TAA, TAG, or TGA (whichever comes first). Because an ORF is a sequence of codons, its length is divisible by 3, i.e., if you read the DNA sequence by eye, you should focus on codons (substrings of length 3) and should step by 3 every time so you never look at overlapping codons. For this reason, it matters whether you start at index 0, or 1, or 2. Write a function orf(dna,rf) that returns a list of ORFs (i.e. of strings) inside dna. The parameter rf (which stands for "reading frame") will always be 0, 1, or 2, and tells you which index to start your search. Note that, if you are in an orf (i.e. have already seen an ATG), then seeing another ATG doesn't change anything. Therefore, it would be a good idea to introduce a boolean variable inORF, and set it to True to keep track of when you are in an ORF as you are reading through the string dna. You may assume dna ends with a stop codon. Your if-statements can then refer to the variable inORF. Note that the first several examples below are too small to be realistic, but are there to help you understand what the problem is asking, and the meaning of rf. Please read through those first few examples to be sure you understand. In order to count as an ORF, a substring needs to start with atg and needs to end with one of the stop codons. Be careful with the end of a string. See Example 4.


orf('atggatgaccatcagtaa', 0) → ['atggatgaccatcagtaa']
orf('atggatgaccatcaggtaa', 1) → ['atgaccatcaggtaa']
orf('cgatggatgaccatcagtag', 2) → ['atggatgaccatcagtag']

...Save, Compile, Run (ctrl-enter)

def orf(dna,rf):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy