Adding special character in fasta headers
2
0
Entering edit mode
9.8 years ago
vahapel ▴ 210

Dear all,

I want to add a special character "/1" to eacf of fasta header (at the end of fasta header) in a 8.5 GB fasta file. I used following command;

perl -p -e 's/^(>.*)$/$1-New_Header_info/g' input.fasta > output.fasta

This code is ok when we put any character in place of "New_Header_info", unfortunately when I typing "/1", i could not get the result.

Is there any solution for this ?

Thanks for all reply,

sequencing • 3.4k views
ADD COMMENT
1
Entering edit mode
9.8 years ago
Ram 44k

Pretty sure bioawk can help you :)

bioawk -c fastx '{ print $name"\1\n"$seq; }' <inFile.fasta

If you face an error with \1, try \\1 - this is just in case awk recognizes \1 as a capture pattern - this may also be the reason you face the problem in your code.

ADD COMMENT
1
Entering edit mode

Dear RamRS, thank you introducing "bioawk" to me!. It looks like very useful for my project

ADD REPLY
0
Entering edit mode

You're welcome. It changed my life too :)

ADD REPLY
1
Entering edit mode
9.8 years ago
iraun 6.2k

Try this:

perl -p -e 's/^(>.*)$/$1\/1/g' input.fasta
ADD COMMENT
1
Entering edit mode

Dear airan,

Your code works perfectly, thank you for your support!

ADD REPLY
0
Entering edit mode

Glad to help :).

ADD REPLY

Login before adding your answer.

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