#!/perl/bin/perl use strict; use warnings; use Bio::DB::GenBank; use Bio::DB::Query::GenBank; =head1 NAME querydb.pl - query the GenBank database =head1 SYNOPSIS querydb.pl =head1 DESCRIPTION querydb.pl looks up a specific query string in the GenBank database to retrieve the desired sequences. The program then displays the sequence ids and lengths =head1 AUTHOR Based on an example from the BioPerl Howto page =cut my $seq_obj; my $stream_obj; my $query = "Arabidopsis[ORGN] AND topoisomerase[TITL] and 0:3000[SLEN]"; print "Looking up $query in GenBank"; $stream_obj = query_db($query); print "ID", "\t\t", "Length", "\n"; print "----------", "\t", "------", "\n"; while ($seq_obj = $stream_obj->next_seq) { printf("%-10s\t%d\n", $seq_obj->display_id, $seq_obj->length); } exit(0); # The query_db function # This takes the query string and looks up the sequence information # It returns the resulting stream object obtained from the query. sub query_db { my ($query) = @_; my $query_obj; my $gb_obj; my $stream_obj; $query_obj = Bio::DB::Query::GenBank->new(-db => 'nucleotide', -query => $query ); $gb_obj = Bio::DB::GenBank->new; $stream_obj = $gb_obj->get_Stream_by_query($query_obj); return $stream_obj; }