Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python, the following script gives the following output: my_seqfile = open(\"

ID: 3603281 • Letter: I

Question

In python, the following script gives the following output:
my_seqfile = open("/home/jorvis1/e_coli_k12_dh10b.faa")
seq_contents = my_seqfile.read()
seq_count = seq_contents.count(">gi")
print("There were " + str(seq_count) + " sequences within the file.")

The next question is: Make a copy of your solution from #4 and instead write a function called fasta_sequence_count which does this functionality. It should accept a file name as an argument and return the number of sequence entries found within it.

I know I need to define a function to include the functionality above, but I'm stuck.

>>> seq seq my_s eqfile = open ("/home/jorvisl/e. Coll_k12-dh10b.faa") contents my seqfile . read() count = seq contents.count (">gi") - There were 4126 sequences within the file.

Explanation / Answer

def fasta_sequence_count(filename): my_seqfile = open(filename) seq_contents = my_seqfile.read() seq_count = seq_contents.count(">gi") return seq_count print("There were " + str(fasta_sequence_count("/home/jorvis1/e_coli_k12_dh10b.faa")) + " sequences within the file.")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote