Modify fasta file header
1
0
Entering edit mode
12 months ago
hellokwmin • 0

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 • 809 views
ADD COMMENT
0
Entering edit mode

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.

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

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
12 months ago

obligatory seqkit answer

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

Login before adding your answer.

Traffic: 1592 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6