in reply to Re: replace FASTA sequence headers
in thread replace FASTA sequence headers

lines such as
%head_seqs = @headers_seqs;
make no sense.

It makes perfect sense.    Copying values between lists, arrays and hashes is a normal idiom in Perl.

if ($line =~ /$key/) { $line =~ s/$key/$headers{$key}/; last; }

Your $key values may contain regular expression meta-characters so you should use quotemeta on them.

Your loop exits on the first match but not necessarily the correct match.    You should anchor the patterns.

Replies are listed 'Best First'.
Re^3: replace FASTA sequence headers
by Anonymous Monk on Jun 10, 2012 at 21:34 UTC

    Thanks for your replies jwkrahn.

    Actually, EACH of my values in the hash of new / old headers have # character in them, some of them have other special characters such as _ etc

    I was under the impression that because my keys are all letter/number strings, that there should not be any problem with having special characters in the values, BUT not in the keys themselves

    Am I missing something here about needing "quotemeta" for the hash's values as well?

    I hope I am explaining the header pairs properly

    Here is an example below:

    cluster14621 \t Helitron#element_1

      Am I missing something here about needing "quotemeta" for the hash's values as well?

      I was suggesting quotemeta not because of the hash, but because of their use in a regular expression.