This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Merge Fasta Header With Description Using Perl :

I have a fasta file that contains sequences like so :

>PT_TAC_1
ATGCATGCATGC

>PT_TAC_2
ATGCATCGATCG

Following BLASTx, i obtained blast results in tabular format. The Sequence ID is in one column and the corresponding description is in the other, like so :

ID          Description
PT_TAC_1   Some_unique_description

How do i merge the description so as to result in a fasta file containing :

>PT_TAC_1_some_unique_description
ATGCATGCATGC
perl blast fasta

had a look at BioPerl? It's much more safe to parse Blast output with it than using using your home-brewed scripts.

As I keep saying...please preview questions as you type them, to help with correct formatting. This is especially important with FASTA format because the ">" does not display in the question unless formatted properly (with 4 leading spaces). Thanks.

1 answer

You could first parse your blastx results and build a hash where the keys are your fasta IDs (PT_TAC_1 for instance) and values your unique_description.

Then open the fasta file, read it line by line and modify headers on the fly with the help of the hash built above, while writing to a new file.

Log in to answer this question.