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

I am a newbi for linux stuff... I would like to modify the header of fasta file. My header is like: >100123_00010T gene=100123_00010 And, I would like to have headers like "100123_00010"

Would you give me some advise to get that result?

fastfile modification

This is a frequently asked question on biostars with many answers.

$ cut -d ' ' -f1 your_file.fa
>100123_00010T
AAA

will most likely suffice.

If you remove the leading > then the file will no longer be in fasta format.

cat test.fa| awk '{if(/^>/){print $1}else {print $0}}'

For a fasta you could just do awk '{print $1}' test.fa

Here are some other options. It's good to try a search first when you have questions.

1 answer

obligatory seqkit answer

seqkit replace -p ".+gene=(.+)" -r "\$1" input.fa -o output.fa

Log in to answer this question.