(I know this question is old, but it is so rare different things of html and js that I do not resist...)
#!/usr/bin/perl
use strict;
sub ler_fasta { my $file=shift;
local $/="'>'"; # separador de registo= '>'
my %val;
open(FASTA, "fasta.txt") or die "Nao foi possivel abrir o arquivo: $!";
while( <FASTA>) { chomp;
if(/(.+)\n(.+)/){ $val{$1}=$2 }
}
return \%val
}
This way the values are associated with the identifier (Ex: print $val->{Pvivax_1}
)
use Data::Dumper; print Dumper( ler_fasta("fasta.txt"))
gives
$VAR1 = { 'Pvivax_2' => 'TTGGCCC',
'Pvivax_1' => 'AAGGTTT'
};
(we lack a more formal specification of the format and the intended but) how relates the header to the content?
– JJoao