~ubuntu-branches/ubuntu/lucid/bioperl/lucid

« back to all changes in this revision

Viewing changes to Bio/DB/QueryI.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: QueryI.pm,v 1.2 2003/06/04 08:36:37 heikki Exp $
 
2
#
 
3
# BioPerl module for Bio::DB::QueryI.pm
 
4
#
 
5
# Cared for by Lincoln Stein <lstein@cshl.org>
 
6
#
 
7
# Copyright Lincoln Stein
 
8
#
 
9
# You may distribute this module under the same terms as perl itself
 
10
#
 
11
# POD documentation - main docs before the code
 
12
#
 
13
 
 
14
=head1 NAME
 
15
 
 
16
Bio::DB::QueryI - Object Interface to queryable sequence databases
 
17
 
 
18
=head1 SYNOPSIS
 
19
 
 
20
   # using Bio::DB::Query::GenBank as an example
 
21
   my $query_string = 'Oryza[Organism] AND EST[Keyword]';
 
22
   my $query = Bio::DB::Query::GenBank->new(-db=>'nucleotide',
 
23
                                            -query=>$query_string);
 
24
   my $count = $query->count;
 
25
   my @ids   = $query->ids;
 
26
 
 
27
   # get a genbank database handle
 
28
   $gb = new Bio::DB::GenBank;
 
29
   my $stream = $db->get_Stream_by_query($query);
 
30
   while (my $seq = $stream->next_seq) {
 
31
      ...
 
32
   }
 
33
 
 
34
   # initialize the list yourself
 
35
   my $query = Bio::DB::Query::GenBank->new(-ids=>['X1012','CA12345']);
 
36
 
 
37
=head1 DESCRIPTION
 
38
 
 
39
This interface provides facilities for managing sequence queries such
 
40
as those offered by Entrez.  A query object is created by calling
 
41
new() with a database-specific argument list. From the query object
 
42
you can either obtain the list of IDs returned by the query, or a
 
43
count of entries that would be returned.  You can pass the query
 
44
object to a Bio::DB::RandomAccessI object to return the entries
 
45
themselves as a list or a stream.
 
46
 
 
47
=head1 FEEDBACK
 
48
 
 
49
=head2 Mailing Lists
 
50
 
 
51
User feedback is an integral part of the
 
52
evolution of this and other Bioperl modules. Send
 
53
your comments and suggestions preferably to one
 
54
of the Bioperl mailing lists. Your participation
 
55
is much appreciated.
 
56
 
 
57
  bioperl-l@bioperl.org              - General discussion
 
58
  http://bioperl.org/MailList.shtml  - About the mailing lists
 
59
 
 
60
=head2 Reporting Bugs
 
61
 
 
62
Report bugs to the Bioperl bug tracking system to
 
63
help us keep track the bugs and their resolution.
 
64
Bug reports can be submitted via email or the
 
65
web:
 
66
 
 
67
  bioperl-bugs@bio.perl.org
 
68
  http://bugzilla.bioperl.org/
 
69
 
 
70
=head1 AUTHOR - Lincoln Stein
 
71
 
 
72
Email lstein@cshl.org
 
73
 
 
74
=head1 APPENDIX
 
75
 
 
76
The rest of the documentation details each of the
 
77
object methods. Internal methods are usually
 
78
preceded with a _
 
79
 
 
80
=cut
 
81
 
 
82
# Let the code begin...
 
83
 
 
84
package Bio::DB::QueryI;
 
85
use strict;
 
86
use Bio::Root::RootI;
 
87
 
 
88
use vars qw(@ISA);
 
89
 
 
90
@ISA = qw(Bio::Root::RootI);
 
91
 
 
92
=head2 new
 
93
 
 
94
 Title   : new
 
95
 Usage   : $db = Bio::DB::QueryI->new(@args);
 
96
 Function: constructor
 
97
 Returns : QueryI object
 
98
 Args    : -query       a query string
 
99
           -ids         a list of ids as an arrayref
 
100
 
 
101
Create new QueryI object.  You may initialize with either a query
 
102
string or with a list of ids.  If both ids and a query are provided,
 
103
the former takes precedence.
 
104
 
 
105
Subclasses may recognize additional arguments.
 
106
 
 
107
=cut
 
108
 
 
109
=head2 count
 
110
 
 
111
 Title   : count
 
112
 Usage   : $count = $db->count;
 
113
 Function: return count of number of entries retrieved by query
 
114
 Returns : integer
 
115
 Args    : none
 
116
 
 
117
Returns the number of entries that are matched by the query.
 
118
 
 
119
=cut
 
120
 
 
121
sub count   {
 
122
  my $self = shift;
 
123
  my @ids  = $self->ids;
 
124
  scalar @ids;
 
125
}
 
126
 
 
127
=head2 ids
 
128
 
 
129
 Title   : ids
 
130
 Usage   : @ids = $db->ids([@ids])
 
131
 Function: get/set matching ids
 
132
 Returns : array of sequence ids
 
133
 Args    : (optional) array ref with new set of ids
 
134
 
 
135
=cut
 
136
 
 
137
sub ids     {
 
138
  my $self = shift;
 
139
  $self->throw_not_implemented;
 
140
}
 
141
 
 
142
=head2 query
 
143
 
 
144
 Title   : query
 
145
 Usage   : $query = $db->query([$query])
 
146
 Function: get/set query string
 
147
 Returns : string
 
148
 Args    : (optional) new query string
 
149
 
 
150
=cut
 
151
 
 
152
sub query   {
 
153
  my $self = shift;
 
154
  $self->throw_not_implemented;
 
155
}
 
156
 
 
157
1;