#!/usr/bin/perl -w
#从已知文件中获得指定id行的序列,注意:display_id是显示the LOCUS name of a Genbank entry, the (/S+) following the > character in a Fasta file, the ID from a SwissProt file等等。
use strict;
use Bio::Seq;
use Bio::SeqIO;
open(IDGIN, "idfilename") or die "Cannot open file";
chomp(my @id = <IDGIN>);
my $seqioin = Bio::SeqIO->new(-file =>"inputfilename", -alphabet => 'protein');
my $seqioout = Bio::SeqIO->new(-file =>'>outputfilename', -format => 'fasta');
while( my $seqioobj = $seqioin->next_seq()) {
foreach my $id(@id){
if($seqioobj -> display_id eq $id){
$seqioout -> write_seq($seqioobj);
}
}
}
close IDGIN;