Question: My program is not passing the given tests: Program: #!/usr/bin/env python Translate first open-reading frame of an RNA sequence. import re import argparse from Bio.Seq

My program is not passing the given tests:

Program: #!/usr/bin/env python """Translate first open-reading frame of an RNA sequence.""" import re import argparse from Bio.Seq import Seq from Bio import SeqIO def get_args(): """Return parsed command-line arguments.""" parser = argparse.ArgumentParser( description="Translate first open-reading frame of an RNA sequence", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('filename', metavar='FASTA', help='Provide name and path to FASTA file to process.', type=str) parser.add_argument('-p', '--pattern', help='Provide a regex pattern for filtering FASTA entries', default='^\d{1}\D*$') return(parser.parse_args()) def find_first_orf(rna): """Return first open-reading frame of RNA sequence as a Bio.Seq object. Must start with AUG Must end with UAA, UAG, or UGA Must have even multiple of 3 RNA bases between """ try: orf = re.search('AUG[AUCG]{3,}?(UAA|UAG|UGA)', str(rna)).group() except AttributeError: # if no match found, orf should be empty orf = "" return(Seq(orf)) def translate_first_orf(dna): """Translates the first open-reading frame of a DNA sequence. Assumes input sequences is a Bio.Seq object. """ # transcribe the DNA rna = dna.transcribe() # find the first ORF orf = find_first_orf(rna) # translate said ORF translated_orf = orf.translate() return(str(translated_orf)) if __name__ == "__main__": args = get_args() for record in SeqIO.parse(args.filename, "fasta"): if re.match(args.pattern, record.id): print(record.id, translate_first_orf(record.seq), sep="\t")

Tests that must pass:

#!user/bin/env python3 """Test behavior of translate_first_orf.py""" from translate_first_orf import find_first_orf from translate_first_orf import translate_first_orf from Bio.Seq import Seq def test_short_orf(): """Identify short ORF""" assert find_first_orf("AUGCCCUAG") == "AUGCCCUAG", "expect three codon ORF" def test_orf_in_orf(): """Identify first ORF when two present""" assert find_first_orf("AUGCUGUAACUGUAG") == "AUGCUGUAA", "expect first complete ORF" def test_missing_stop_codon(): """Identify no ORF when missing stop codon""" assert find_first_orf("AUGCUG") == "", "expect no ORF in AUGCUG - lacks stop codon" def test_out_of_frame_stop(): """Identify no ORF when stop codon is out of frame""" assert find_first_orf("AUGAUAA") == "", "expect no ORF in AUGAUAA - stop codon out of frame" def test_dna_sequence(): """Identify protein sequence within DNA""" assert translate_first_orf(Seq("AAATGCCCTAG")) == "MP*", "expect MP protein within sequence" Tests that are failing: 

FAILED test_translate_first_orf.py::test_short_orf - AssertionError: expect three codon ORF

FAILED test_translate_first_orf.py::test_orf_in_orf - AssertionError: expect first complete ORF

FAILED test_translate_first_orf.py::test_dna_sequence - AssertionError: expect MP protein within sequence

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!