This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Adding special character in fasta headers

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

2 answers

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.

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

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

Try this:

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

Dear airan,

Your code works perfectly, thank you for your support!

Glad to help :).

Log in to answer this question.