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