I changed the code in a way that prints the entire header. The thing that happens is that, if your id is long and you need to have the entire information by printing $id you may lose the informative part from any space onward.
#!/usr/bin/perl use strict; use Bio::DB::Fasta; my $database; my $fasta_library; my %records; open IDFILE, "NBS_LRR_IDs.txt" or die $!; open OUTPUT, ">NC_003070_NBS-LRR.faa" or die $!; # name of the library file - (here it is hardcoded) $fasta_library = 'NC_003070_all_chr.faa'; # creates the database of the library, based on the file $database = Bio::DB::Fasta->new("$fasta_library") or die "Failed to cr +eate Fasta DP object on fasta library\n"; # now, it parses the file with the fasta headers you want to get while (<IDFILE>) { my ($id) = (/^>*(\S+)/); # capture the id string (without the i +nitial ">") my $header = $database->header($id); #print "$header\n"; print ">$header\n", $database->seq( $id ), "\n"; print OUTPUT ">$header\n", $database->seq( $id ), "\n"; } exit;
In reply to Re^4: comparing two fasta files
by sesemin
in thread comparing two fasta files
by nemo2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |