SEQanswers (
-   Bioinformatics (
-   -   How to add characters to start of fasta header (

Zapages 01-13-2015 07:12 AM

How to add characters to start of fasta header
Hi Everyone,

I have small question. How do we add characters to a start of a fasta header?

I know we can add it to the end of Fasta header using this.


perl -p -e 's/^(>.*)$/$1-New_Header_info/g' input.fasta > output.fasta
Although I could use Galaxy, but I am trying to avoid it for this and learn a bit of perl at the same time. :)

Thank you in advance. :)


ajk 01-13-2015 09:01 AM

You're almost all the way there: just move the $1 to the end of the replacement string. Also, it'll be a little easier if you take the greater than (>) out of the match.


perl -p -e 's/^>(.*)/>New_Header_Info $1/' input.fasta > output.fasta
For this, you really don't need the /g at the end since you're matching the whole line and, because the .* is greedy, the $ at the end of the match string is unnecessary as well.

All times are GMT -8. The time now is 05:34 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.