This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Protein sequence to Nucleotide sequence

Hello All,

I have file1 with protein sequence and another file with its respective decoded nucl codon sequence, is there any one liner which looks for aa single letter in file2 - change the protein sequence to the nucleotide sequence and save it as a file 3.

For eg:

File1.fasta

MFLILLISLPTAFAVIGDLKCTTVSINDVDTGVPSIST.....................

File2.txt (tab file)

M ATG

F TTT

.. ...

Expected output

file3.fasta

ATGTTTTGATACTTT....................

linux awk codon sed perl

2 answers

backtranseq http://emboss.sourceforge.net/apps/release/6.3/emboss/apps/backtranseq.html

backtranseq reads a protein sequence and writes the nucleic acid sequence it is most likely to have come from.

This is not very efficient, but it does work (notice, these files do not have headers)..

cat file.aa
MFLILLI

cat file.map
M       AAA
F       TTT
L       CCC
I       GGG

for x in $(fold -w 1 file.aa); do awk -v x="$x" 'BEGIN{FS="\t"}{if($1==x){printf $2}}' file.map; done
AAATTTCCCGGGCCCCCCGGG

But surely you are aware that it's impossible to go from aa sequence back to the original nt sequence? E.g. six different codons encode Leucine..

Log in to answer this question.