This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is it possible to delete part of the header string?

Hi, all.

I would like to remove "locus=" and "gene=" from headers of fasta as following. I used tr, but the other strings disappeared, too.

Before;

>3R5.1a wormpep=CE24758 gene=WBGene00007065 locus=pot-3 insdc=CAA21777.2 product="POT1PC domain-containing protein"
>2RSSE.1a wormpep=CE32785 gene=WBGene00007064 locus=rga-9 insdc=CCD61138.1 product="Rho-GAP domain-containing protein"
>2L52.1a wormpep=CE32090 gene=WBGene00007063 insdc=CCD61130.1

After;

>3R5.1a wormpep=CE24758 WBGene00007065 pot-3 insdc=CAA21777.2 product="POT1PC domain-containing protein"
>2RSSE.1a wormpep=CE32785 WBGene00007064 rga-9 insdc=CCD61138.1 product="Rho-GAP domain-containing protein"
>2L52.1a wormpep=CE32090 WBGene00007063 insdc=CCD61130.1

Is there a way to delete only a specific string in a non delimited string? Could you please give me some help.

Thank you very much for your help!

bash linux fasta

2 answers

sed -e 's/locus=//g' -e 's/gene=//g' your.fa > new.fa 

It's a simplest answer! I can remove it because of you.

Thank you very much for your quick answer!

$ seqkit replace -p 'gene=|locus=' -r "" file.fa
$ awk '/^>/ {gsub(/gene=|locus=/,"",$0)}1' file.fa

I can do the same thing with "seqkit" and "awk". I'm good to know other way, too.

Thank you very much!

Log in to answer this question.