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

« back to all changes in this revision

Viewing changes to Bio/DB/DBFetch.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
1
#
2
 
# $Id: DBFetch.pm,v 1.3.2.1 2002/03/13 16:37:05 jason Exp $
 
2
# $Id: DBFetch.pm,v 1.8 2002/12/22 22:02:13 lstein Exp $
3
3
#
4
 
# BioPerl module for Bio::DB::EMBL
 
4
# BioPerl module for Bio::DB::DBFetch
5
5
#
6
6
# Cared for by Heikki Lehvaslaiho <Heikki@ebi.ac.uk>
7
7
#
50
50
or the web:
51
51
 
52
52
  bioperl-bugs@bio.perl.org
53
 
  http://bio.perl.org/bioperl-bugs/
 
53
  http://bugzilla.bioperl.org/
54
54
 
55
55
=head1 AUTHOR - Heikki Lehvaslaiho
56
56
 
73
73
$MODVERSION = '0.1';
74
74
use HTTP::Request::Common;
75
75
use Bio::DB::WebDBSeqI;
76
 
use Bio::Root::Root;
77
 
@ISA = qw(Bio::DB::WebDBSeqI Bio::Root::Root);
 
76
 
 
77
@ISA = qw(Bio::DB::WebDBSeqI);
78
78
 
79
79
# the new way to make modules a little more lightweight
80
80
 
118
118
    } else {
119
119
        $uid = $uids;
120
120
    }
121
 
    $self->debug("\n$url$format_string&id=$uid\n");
 
121
 
122
122
    return GET $url. $format_string. '&id='. $uid;
123
123
}
124
124
 
136
136
 
137
137
=cut
138
138
 
139
 
# don't need to do anything
140
 
 
 
139
# remove occasional blank lines at top of web output
141
140
sub postprocess_data {
142
 
    my ($self, %args) = @_;
 
141
  my ($self, %args) = @_;
 
142
  if ($args{type} eq 'string') {
 
143
    ${$args{location}} =~ s/^\s+//;  # get rid of leading whitespace
 
144
  }
 
145
  elsif ($args{type} eq 'file') {
 
146
    open F,$args{location} or $self->throw("Cannot open $args{location}: $!");
 
147
    my @data = <F>;
 
148
    for (@data) {
 
149
      last unless /^\s+$/;
 
150
      shift @data;
 
151
    }
 
152
    open F,">$args{location}" or $self->throw("Cannot write to $args{location}: $!");
 
153
    print F @data;
 
154
    close F;
 
155
  }
143
156
}
144
157
 
145
158
=head2 default_format
159
172
 
160
173
=head1 Bio::DB::DBFetch specific routines
161
174
 
162
 
=head2 get_Stream_by_batch
 
175
=head2 get_Stream_by_id
163
176
 
164
 
  Title   : get_Stream_by_batch
165
 
  Usage   : $seq = $db->get_Stream_by_batch($ref);
 
177
  Title   : get_Stream_by_id
 
178
  Usage   : $seq = $db->get_Stream_by_id($ref);
166
179
  Function: Retrieves Seq objects from the server 'en masse', rather than one
167
180
            at a time.  For large numbers of sequences, this is far superior
168
181
            than get_Stream_by_[id/acc]().
171
184
  Args    : $ref : either an array reference, a filename, or a filehandle
172
185
            from which to get the list of unique ids/accession numbers.
173
186
 
 
187
NOTE: for backward compatibility, this method is also called
 
188
get_Stream_by_batch.
 
189
 
174
190
=cut
175
191
 
176
 
sub get_Stream_by_batch {
 
192
sub get_Stream_by_id {
177
193
    my ($self, $ids) = @_;
178
 
    return $self->get_seq_stream('-uids' => $ids, '-mode' => 'single');
 
194
    return $self->get_seq_stream('-uids' => $ids, '-mode' => 'batch');
179
195
}
180
196
 
181
197
=head2 get_Seq_by_version