148
149
my $self = shift;
150
151
my $name = shift;
151
if ($name =~ /[^\w\s]/) {
152
$self->warn (" contains non-word characters, setting to default
154
$self->{'_sp'} = "Homo sapiens";
157
152
$self->{'_sp'} = $name;
160
154
return $self->{'_sp'}|| "Homo sapiens";
192
186
=head2 get_request
194
Title : get_web_request
195
Usage : my $cut = $db->get_web_request();
189
Usage : my $cut = $db->get_request();
196
190
Purpose: To query remote CUT with a species name
197
191
Returns: a new codon usage table object
198
192
Args : species name(mandatory), genetic code id(optional)
225
219
$self->debug (" reply from query is \n $content");
226
220
##### if no matches, assign defaults - or can throw here? ######
227
221
if ($content =~ /not found/i) {
228
$self->warn ("organism not found -selecting human as default");
229
$self->sp("Homo sapiens");
222
$self->warn("organism not found -selecting human [9606] as default");
230
224
$self->_db("gbpri");
236
my @names = $content =~ /(species)/g;
228
my @names = $content =~ /species=([^"]+)/g;
237
229
### get 1st species data from report ####
238
my ($sp, $db) = $content =~ /species=(.*)\+\[(\w+)\]"/;
230
my @dbs = $content =~ /\[([^\]]+)\]:\s+\d+/g;
241
231
## warn if more than 1 matching species ##
242
232
## if multiple species retrieved, choose first one by default ##
233
$self->throw("No names returned for $nameparts") unless @names;
244
$self->warn ("too many species - not a unique species id - selecting $sp ");
235
$self->warn ("too many species - not a unique species id\n".
236
"selecting $names[0] using database [$dbs[0]]");
246
238
### now assign species and database value
239
$self->sp($names[0]);
252
244
######## now get codon table , all defaults established now
254
246
##construct URL##
255
$nameparts = join "+", $self->sp =~ /(\w+)/g;
247
$nameparts = $self->sp;
256
249
my $CT_url = $self->url . "/codon/cgi-bin/showcodon.cgi?species="
257
. $nameparts . "+%5B" . $self->_db . "%5D&aa=" . $self->gc . "&style=GCG";
250
. $nameparts . "&aa=" . $self->gc . "&style=GCG";
251
$self->debug("URL : $CT_url\n");
259
252
## retrieve data in html##
260
my $rq2 = HTTP::Request->new(GET=>$CT_url);
253
my $rq2 = HTTP::Request->new(GET => $CT_url);
261
254
$reply = $self->request($rq2);
262
255
if ($reply->is_error) {
263
256
$self->throw($reply->as_string()."\nError getting for url $CT_url!\n");