This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to replace fasta header

Hi!

I have two files, ba.fasta and ba.header

ba.fasta                                                                               ba.header
>bas12                                                                                >seq1
MDNAVGYH..                                                                     MDNAVGYH..
>bas13                                                                                >seq2
MLSRTEQR..                                                                      MLSRTEQR..

So basically I wanted to replace the header of ba.fasta with that of ba.header while keeping the sequences

Any easy command for this please

Tnks in advance

linux header fasta
$ tail -n+1 *.fa
==> test1.fa <==
>bas12
MDNAVGYH
>bas13
MLSRTEQR
>seq
MLR

==> test2.fa <==
>seq1
MDNAVGYH
>seq2
MLSRTEQR

output:

$ seqkit --quiet replace -K  -p '(.*)' -r '{kv}' -k  <(paste <(seqkit seq -n test1.fa) <(seqkit seq -n test2.fa)| awk '$2!="" {print}') test1.fa
>seq1
MDNAVGYH
>seq2
MLSRTEQR
>seq
MLR

1 answer

awk '/^>/{printf(">seq%d\n",++N);next;} {print;}'

ba.fasta ba.header

Bol0453 >Bol.11 MKDIRGHTWQP... MKDIRGHTWQP... Bol0358 >Bol.75 MKSREVBTW.... MKSREVBTW....

What if situation is something like this. I want the header of file ba.header in the place of ba.fasta header.

linearize the fasta and use paste to merge the data.

First of all thank you for responding but I am not able to get you

Ok... I got it !!!

Log in to answer this question.