Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extraction of a portion of a fasta header chayan Bioinformatics 4 01-04-2015 11:50 PM
Add count numbers to headers in a fasta file Giorgio C Bioinformatics 7 07-08-2013 03:06 AM
fasta header polijana Bioinformatics 2 03-31-2013 03:01 PM
Add header to SAM file gormleymp Bioinformatics 9 11-14-2012 03:24 AM
Lower case characters in FASTa reference sequence foxyg Bioinformatics 5 09-08-2010 01:08 PM

Thread Tools
Old 01-13-2015, 06:12 AM   #1
Location: NJ

Join Date: Oct 2012
Posts: 97
Default 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.

Zapages is offline   Reply With Quote
Old 01-13-2015, 08:01 AM   #2
Junior Member
Location: Massachusetts

Join Date: Feb 2009
Posts: 1

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.
ajk is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 07:36 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO