use strict; use Bio::DB::Fasta; my $database; my $fasta_library; my %records; # name of the library file - (here it is hardcoded) $fasta_library = 'Poptr1_FilteredModels_transcripts.fa'; # creates the database of the library, based on the file $database = Bio::DB::Fasta->new("$fasta_library"); # now, it parses the file with the fasta headers you want to get while () { chomp (my $seq_id = $_); my $record = $database->get_Seq_by_id("$seq_id"); # incorporates the header and sequence to the hash # key = header ; value = sequence $records{$seq_id} = $record->seq(); } # print all the key-value pairs ( for (sort keys (%records)) { print ">$_\n$records{$_}\n"; } exit;