This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Rename fasta file header with name available in the text file

Hi, I am trying to change the fasta header with a given list. I have a fasta file which looks like-

>P1212_1 M04I6TDD
GACGAACGCTGGCGGCGTGCTTAACACATGCAAGTCGAACGAGAGGAGAAGGAAGCTTGCCTCTTTCAAATCT
>P1213_2 M04JTWVX 
GATAAACGCTGGCGGCGCACATAAGACATGCAAGTCGAACGAACTTAACCATTAGTTTACTATTGGAGCGGTTAGTG

And I have another file in text format (tab delimited), which looks like -

P1212  SHA1111
P1213  SHA2222
P1214  SHA3333

I want to rename the header of above fasta file according to corresponding name, the output file looks like-

>SHA1111_1 M04I6TDD 
GACGAACGCTGGCGGCGTGCTTAACACATGCAAGTCGAACGAGAGGAGAAGGAAGCTTGCCTCTTTCAAATCT
>SHA2222_2 M04JTWVX 
GATAAACGCTGGCGGCGCACATAAGACATGCAAGTCGAACGAACTTAACCATTAGTTTACTATTGGAGCGGTTAGTG

I am trying to use scripts mentioned here Renaming fasta headers according to a matching name list , but the output file is not correct. I'm so grateful for helping. Regards.

fasta

Hello shashank.gupta!

Questions similar to yours can already be found at:

The question you looked at contains three different solutions which look all valid to me, if you have a problem with one of the solutions, please post a comment there. Please explain the problem you are having with the headers better. Stating, "something is wrong" does not help.

We have closed your question to allow us to keep similar content in the same thread.

If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.