I have a file called protein.faa, its content is:
>WP_004066472.1 MULTISPECIES: NADH-quinone oxidoreductase subunit K [Thermococcus]
MIPLQFVTAFLMIFMGIYAFLYKRNLIKLILALNLI
LVLTSIVIGVCVLSLAMALTINAYRHYGTLDVNKLRRLRG
>WP_004066568.1 MULTISPECIES: DNA-directed RNA polymerase subunit P [Thermococcus]
MVEALYKCAKCGKEF
>WP_004066764.1 MULTISPECIES: Lrp/AsnC ligand binding domain-containing protein [Thermococcus]
MVTAFILMVTAAGKEREVMEKLLTYPEVKEAYVVYG
>WP_004067064.1 MULTISPECIES: hypothetical protein [Thermococcus]
MEITIEKFKPKVTRPFKRKNEYWVKL
PSAKELVDEYFSE
I want to rename only names after each > to filename+its order number, i.e.:
>protein_1 MULTISPECIES: NADH-quinone oxidoreductase subunit K [Thermococcus]
MIPLQFVTAFLMIFMGIYAFLYKRNLIKLILALNLI
LVLTSIVIGVCVLSLAMALTINAYRHYGTLDVNKLRRLRG
>protein_2 MULTISPECIES: DNA-directed RNA polymerase subunit P [Thermococcus]
MVEALYKCAKCGKEF
>protein_3 MULTISPECIES: Lrp/AsnC ligand binding domain-containing protein [Thermococcus]
MVTAFILMVTAAGKEREVMEKLLTYPEVKEAYVVYG
>protein_4 MULTISPECIES: hypothetical protein [Thermococcus]
MEITIEKFKPKVTRPFKRKNEYWVKL
PSAKELVDEYFSE
My code is
name="$(echo protein.faa | sed 's/....$//')"
sed "s/>.*/>${name}/" protein.faa
which allows me to get only
>protein
MIPLQFVTAFLMIFMGIYAFLYKRNLIKLILALNLI
LVLTSIVIGVCVLSLAMALTINAYRHYGTLDVNKLRRLRG
>protein
MVEALYKCAKCGKEF
>protein
MVTAFILMVTAAGKEREVMEKLLTYPEVKEAYVVYG
>protein
MEITIEKFKPKVTRPFKRKNEYWVKL
PSAKELVDEYFSE
How do I add order numbers and keep whatever goes after >protein_i?