Question: Adding special character in fasta headers
0
gravatar for vahapel
4.3 years ago by
vahapel160
Turkey
vahapel160 wrote:

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 • 1.7k views
ADD COMMENTlink modified 4.3 years ago by RamRS21k • written 4.3 years ago by vahapel160
1
gravatar for RamRS
4.3 years ago by
RamRS21k
Houston, TX
RamRS21k wrote:

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 COMMENTlink modified 4.3 years ago • written 4.3 years ago by RamRS21k
1

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

ADD REPLYlink written 4.3 years ago by vahapel160

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

ADD REPLYlink written 4.3 years ago by RamRS21k
1
gravatar for iraun
4.3 years ago by
iraun3.5k
Norway
iraun3.5k wrote:

Try this:

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

 

ADD COMMENTlink modified 4.3 years ago • written 4.3 years ago by iraun3.5k
1

Dear airan,

Your code works perfectly, thank you for your support !

ADD REPLYlink written 4.3 years ago by vahapel160

Glad to help :).

ADD REPLYlink written 4.3 years ago by iraun3.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1778 users visited in the last hour