3 # $Id: extract_feature_seq.PLS,v 1.5 2006-07-04 22:23:29 mauricio Exp $
4 # Author Jason Stajich <jason@bioperl.org>
8 extract_feature_seq - extract the corresponding sequence for a specified feature type
12 extract_feature_seq.PLS -i file --format genbank --feature=CDS -o output.fa
16 This script will extract the sequence for all the features you specify.
22 User feedback is an integral part of the evolution of this and other
23 Bioperl modules. Send your comments and suggestions preferably to
24 the Bioperl mailing list. Your participation is much appreciated.
26 bioperl-l@bioperl.org - General discussion
27 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
31 Report bugs to the Bioperl bug tracking system to help us keep track
32 of the bugs and their resolution. Bug reports can be submitted via
35 http://bugzilla.open-bio.org/
39 Jason Stajich E<lt>jason-at-bioperl-dot-orgE<gt>
46 my ($input,$format,$featuretype,$output);
49 'i|input:s' => \$input,
50 'format:s' => \$format,
51 'feature:s' => \$featuretype,
52 'o|output:s'=> \$output);
54 $input || shift if @ARGV;
56 my $in = new Bio::SeqIO(-file => $input,
60 $out = new Bio::SeqIO(-file => ">$output");
62 $out = new Bio::SeqIO(); # use STDOUT for output
66 while( my $seq = $in->next_seq ) {
67 foreach my $f ( grep { $_->primary_tag =~ /$featuretype/i }
68 $seq->get_SeqFeatures ) {
69 my $s = $f->spliced_seq;
70 if( $featuretype =~ /gene|CDS/ ) {
71 $s->display_id($f->has_tag('gene') ? join(',',sort $f->each_tag_value('gene')) :
72 $f->has_tag('label') ? join(',',$f->each_tag_value('label')):
75 $s->display_id(sprintf("%s_%s_%d",