Question: I need to create a code in python that generates the reverse complement of a FASTA file that has 2 separate DNA sequences in it.

I need to create a code in python that generates the reverse complement of a FASTA file that has 2 separate DNA sequences in it. The assignment is:

"Assignment Requirements

Write a Python script that:

Opens a file, whose filename is specified by the user as a command-line argument. That is, if the name of your Python script is programname and the name of the file is filename, then the script should be run by typing the following at the Unix command line: programname filename

Reads the contents of the file, assuming it is a FASTA file of DNA sequences.

Prints (to standard output) the name and reverse-complemented sequence of every DNA sequence in the file, in FASTA format (80 characters/line)."

I was able to find code that could generate a reverse complement of a sequence, but how would I do this with an entire FASTA file that includes headers that start with ">"

>>> def rc (my_sequence):

... my_dictionary = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}

... return "".join([my_dictionary[base] for base in reversed(my_sequence)])

>>> print rc("CATGCCGGAATT")

output: AATTCCGGCATG

I have no experience coding in python, so I could really use some help. Thanks!

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!