This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to edit the fasta headers?

Hi, pls, let me know how can i edit the fasta file header.

>LR99555.1 Avo, chromosome: 1 

I want this header like this.

>LR99555.1
linux

A low-tech way of doing this is to open the file in any text editor and simply delete the part you don't need. This is not advised if you have a large number of sequences.

2 answers

cut -d ' ' -f 1 < in.fa

hi, thanks for the reply, what is -f here?

according to the manual (man cut):

 -f list
         The list specifies fields, separated in the input by the field
         delimiter character (see the -d option).  Output fields are
         separated by a single occurrence of the field delimiter character.

Meaning that it keeps everything before the first space delimiter and removes the rest.

$ awk '/^>/ {print $1} !/>/' test.fa
$ sed '/^>/ s/\s.*//g' input.fa

Log in to answer this question.