in reply to Re^2: comparing two fasta files
in thread comparing two fasta files
Hi Nemo2, I was absent. You already have had some solutions. This is the way I used, using BioPerl.
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 (<STDIN>) { 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;
|
|---|