Is there a way to change only the header of a fasta file?
2
0
Entering edit mode
2.9 years ago
Riku ▴ 80

Dear All,

I would like to change the header of the fasta file as follows, but I don't know how. The actual file is so long that I need a command. Could you tell me the command to change only the header.

Before

>TRINITY_DN22056_c0_g1_i1 len=300 path=[0:0-299] GTCCATTTGACTGATTCCCATTCCAAAAAAAACCACTCAACCAGGACTGACGCATAAAACCGTCAAATCGACGACGCAGGATAAGGTTCGATTATGACTTGTTACGGTCTCAAAGGCGCGTTTTTACACAATTATG >TRINITY_DN30979_c0_g1_i1 len=300 path=[0:0-299] TGACGAATGAGAACAAGGGCACGCAGTTCGTTTTATGTCAATTGAACTGCTGGTCACTAACCAGAATTCGTATTCCCGTTGGACGTCAATTTGCATAAAAAATGTAAAAGAGAAAATACGATCATAAAAAGTGGAAA

After

>AbTRINITY_DN22056_c0_g1_i1 len=300 path=[0:0-299] GTCCATTTGACTGATTCCCATTCCAAAAAAAACCACTCAACCAGGACTGACGCATAAAACCGTCAAATCGTACGACGCAGGATAAGGTTCGATTATGACTTGTTACGGTCTCAAAGGCGCGTTTTTACACAATTATG >AbTRINITY_DN30979_c0_g1_i1 len=300 path=[0:0-299] TGACGAATGAGAACAAGGGCACGCAGTTCGTTTTATGTCAATTGAACTGCTGGTCACTAACCAGAATTCGTATTCCCGTTGGACGTCAATTTGCATAAAAAATGTAAAAGAGAAAATACGATCATAAAAAGTGGAAA

This question may not exactly be a bioinformatics question. If this was inappropriate, I apologize. Thank you for your help.

awk seqkit fasta • 1.3k views
ADD COMMENT
1
Entering edit mode

A simple Linux command can do it:

sed 's/>/>Ab/' your.fasta > your.new.fasta

or modify in place:

sed -i 's/>/>Ab/' your.fasta
ADD REPLY
0
Entering edit mode
ADD REPLY
0
Entering edit mode

Good point, thanks.

ADD REPLY
4
Entering edit mode
2.9 years ago
sed 's/^>/>Ab/'
ADD COMMENT
0
Entering edit mode

So simple! I've learned a lot. Thank you very much!

ADD REPLY
0
Entering edit mode
2.9 years ago
$ bioawk -c fastx '{print ">Ab"$name;print $seq}' test.fa
ADD COMMENT

Login before adding your answer.

Traffic: 5487 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