This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython Code to Convert DNA FASTA file to Protein FASTA file

Hello, I am trying to translate a DNA FASTA file to Protein FASTA file using biopython. I am trying to translate about 5,000 gene extractions, so anything which requires copy and pasting will not work. I need the output as a FASTA file. I have seen previous threads which are similar, but those are outdated and do not work with later versions of Biopython. Please reply with the code on how to do this.

biopython

As Mensur Dlakic mentioned, you need to put some effort to get help.

This is just a sample code:

>>> from Bio.Seq import Seq
>>> coding_dna = Seq("ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG")
>>> coding_dna.translate()
Seq('MAIVMGR*KGAR*')

But, this will not solve your issue, it is just the beginning. Please, follow the documentation here:

http://biopython.org/DIST/docs/tutorial/Tutorial.html

Section 3.8 translation.

Cheers

Note to OP - you'll need to ensure you are using an appropriate translation table.

Try to put some effort on this task. A simple google search will give you the answer

1 answer

This is not a code-providing service. If you are expecting to lay out your needs and someone will give you a code for it, you are in a wrong place. There are places where you can get what you asked for if you pay.

If you show some effort:

  • what code did you run?
  • what modifications did you make?
  • what were the errors?

Then it will be more likely that someone will help you.

By the way, DNA translation into protein is one of the most trivial transformations in bioinformatics. There are many programs out there, though possibly non-pythonic, that will do that operation. All of this is easy to find by Googling.

Log in to answer this question.