This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Modify Fasta header

Hello

I have a fasta file with sequence headers written as

>0|quiver|1..2075|-
>0|quiver|2210..3058|-
>0|quiver|3112..4169|-

and so on till around 1000 sequences. I want to modify these as

>1|quiver_1|1..2075|-
>2|quiver_2|2210..3058|-
>3|quiver_3|3112..4169|-

and so on. Please help

sequence fasta

1 answer

awk -F '|' '/>/ {i++;printf(">%d|%s_%d|%s|%s\n",i,$2,i,$3,$4,$5);next;} {print;}' input.fa

Thanks for your help!

I also have one more query, please solve it.

can I modify the following headers

>gi|392981410|ref|NC_018080|pseudocap|273_483_2027_+
>gi|392981410|ref|NC_018080|pseudocap|273_2056_3159_+

so on

to

>protein 1 [Pseudomonas aeruginosa 19BR]
>protien 2 [Pseudomonas aeruginosa 19BR]

so on

thanks!

ask this as a new question + show us what you have already tried.

Log in to answer this question.