# convert tRNA coordinates Result to Fasta format

I believe many of the experts here have gone through this issue,

I have run tRNAscan-SE on my genome to predict all the tRNAs, and have successfully gotten all the tRNA coordinates like start, end and type all arranged in a table.

My question is how can I convert this result to fasta format as long I have all the details about the tRNA ready?

Is there any tool that I can use to get the fasta sequences of the regions described in my table from the original genome?

Sequence                tRNA    Bounds  tRNA    Anti    Intron Bounds   Inf
Name            tRNA #  Begin   End     Type    Codon   Begin   End     Score   Note
--------        ------  -----   ------  ----    -----   -----   ----    ------  ------
NW_011590950.1  1       36704   36632   Ala     AGC     0       0       40.8    pseudo

• Could you provide the table you are referring? Having some sample data will help us to answer your questions. Do you have the reference genome? Many thanks! BTW, what have you tried? Perhaps manually finding the sequence or something else?
– llrs
Oct 10 '18 at 10:06
• I have uploaded the table, unfortunately, the data I'm working on doesn't have a reference. Oct 10 '18 at 10:33
• finding these results just by running tRNAscan on my genome, the table above is my Results, in fact, I need a fasta format has all the tRNA sequence to implemented in another tool Oct 10 '18 at 10:35
• You provided a picture, could you provide text that could be used to copy and paste to make it easier for people to use the information?
– llrs
Oct 10 '18 at 11:05
• I did upload a copy from the data but, when past here doesn't arrange accordingly Oct 11 '18 at 6:22

You can select “Output BED format” on the tRNAscan-SE server:

Given the output BED format and your input reference in FASTA format, you can easily generate a FASTA file of tRNA sequences via bedtools getfasta:

bedtools getfasta -name -s -fo ‹output.fasta› -fi ‹reference.fasta› -bed ‹tRNAscan-SE-output.bed›

• thank you for the respond, but I'm running it locally, and the output options are Secondary, statistics, and shown table. but currently, I have submitted the job to their server, let's wait and see :) Oct 14 '18 at 6:48

You can do this using the tools from the exonerate package. I assume you have all the sequences shown in your table in a single, multifasta file. If so, first create a single file per sequence using fastaexplode:

fastaexplode reference.fa


This will create one file for each sequence in reference.fa. Now, you can read through the results table, and extract the sequences:

tmpFile=$$(mktemp) awk -F"\t" '{ if(NR>3){ printf "%s %s ", 1, 2; if(4>3){ print 3, 4-3 } else{ print 4,3-4,"-" } } }' file | while read name num start len rev; do fastasubseq "$$name".fa $$start$$len > $$num.fa if [[ ! -z$$rev ]]; then
fastarevcomp $$num.fa >$$tmpFile &&
mv $$tmpFile$$num.fa
fi
done


I would suggest you go with Konrad's approach, however, that looks much cleaner and simpler.