This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Replace header of fasta file according to another file

Hi

I have a file T.fasta as:

>AAAA
GVNCLPQWERTYI
>BBBB
HJKSDRTYPALVNM
>CCCC
TRHJPKFLMVNCTEGH

and another file.txt with two columns: One column with header of the T.fasta file and a second column with the new name like:

CCCC     C_pr3
BBBB     B_pr2
AAAA     A_pr1

Now I want to replace the header of T.fa with the second column of the second file if first column of second file match with the header of T.fa.

The deisred output should look like this:

>A_pr1
GVNCLPQWERTYI
>B_pr2
HJKSDRTYPALVNM
>C_pr3
TRHJPKFLMVNCTEGH

**My both file are not sorted accordingly.

fasta

0 answers

No answers yet.

Log in to answer this question.