Another way of getting rid of the newlines would be to lose all of them with the second split, passing the fields out in an anonymous array, and then map out the key and sequence using shift and join.
use strict;
use warnings;
use Data::Dumper;
my %hash =
map { ( shift @$_, join q{}, @$_ ) }
map { [ split m{\n} ] }
map { split m{\n(?=>)} }
do { local $/; <DATA> };
print Data::Dumper->Dumpxs( [ \ %hash ], [ qw{ *hash } ] );
__DATA__
>SEQ1
-----I--RL--AAIDVDG-NLT----------D--R--D-RL-ISTKA-IESIRS--A-
-E-K--------K-GLT-VSL----LS------GN-V----I-PVV---YA-L------K
IF---------------L-----GINGPVF------------------------------
>SEQ2
-MKI----KA--ISIDIDG-TIT------YPN-R-------MIHEK--A-LEAIRR--A-
-E-S--------L-GIP-IML----VT------GN-T----V-QFA---EA-A------S
IL---------------I-----G----TS-----------------GP-VV--------
>SEQ3
--KI----KA--ISIDIDG-TIT------YPN-R-------MIHEK--A-LEAIRR--A-
-E-S--------L-GIP-IML----VT------GN-T----V-QFA---EA-A------S
IL---------------I-----G----TS-----------------GP-VV--------
---AE--D------GG---A---------------------------------------I
The output.
%hash = (
'>SEQ1' => '-----I--RL--AAIDVDG-NLT----------D--R--D-RL-ISTK
+A-IESIRS--A--E-K--------K-GLT-VSL----LS------GN-V----I-PVV---YA-L----
+--KIF---------------L-----GINGPVF------------------------------',
'>SEQ3' => '--KI----KA--ISIDIDG-TIT------YPN-R-------MIHEK--
+A-LEAIRR--A--E-S--------L-GIP-IML----VT------GN-T----V-QFA---EA-A----
+--SIL---------------I-----G----TS-----------------GP-VV-----------AE-
+-D------GG---A---------------------------------------I',
'>SEQ2' => '-MKI----KA--ISIDIDG-TIT------YPN-R-------MIHEK--
+A-LEAIRR--A--E-S--------L-GIP-IML----VT------GN-T----V-QFA---EA-A----
+--SIL---------------I-----G----TS-----------------GP-VV--------'
);
I hope this is of interest.
|