| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: Remote.pm,v 1.10 2004/03/04 23:23:38 kclark Exp $ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Bio::PrimerDesigner::Remote; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Bio::PrimerDesigner::Remote - A class for remote access to Bio::PrimerDesigner |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Bio::PrimerDesigner::Remote; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Interface to the server-side binaries. Passes the primer design |
|
16
|
|
|
|
|
|
|
paramaters to a remote CGI, which uses a server-side installation of |
|
17
|
|
|
|
|
|
|
Bio::PrimerDesigner to process the request. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
888
|
use HTTP::Request; |
|
|
1
|
|
|
|
|
14798
|
|
|
|
1
|
|
|
|
|
27
|
|
|
24
|
1
|
|
|
1
|
|
563
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
17283
|
|
|
|
1
|
|
|
|
|
32
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use base 'Class::Base'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
532
|
|
|
26
|
1
|
|
|
1
|
|
811
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
4
|
use vars '$VERSION'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
335
|
|
|
29
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
sub CGI_request { |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 CGI_request |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Passes arguments to the URL of the remote Bio::PrimerDesigner CGI and |
|
39
|
|
|
|
|
|
|
returns the raw output for further processing by local design classes. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
2
|
|
|
2
|
1
|
1640
|
my $self = shift; |
|
45
|
2
|
100
|
|
|
|
12
|
my $url = shift or return $self->error('No URL specified'); |
|
46
|
1
|
50
|
|
|
|
5
|
$url = 'http://' . $url unless $url =~ m{https?://}; |
|
47
|
1
|
50
|
|
|
|
6
|
my $args = shift or return $self->error('No config file'); |
|
48
|
1
|
|
|
|
|
2
|
my $program = $args->{'program'}; |
|
49
|
1
|
|
|
|
|
5
|
my $ua = LWP::UserAgent->new; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# Is the remote server able to process our request? |
|
53
|
|
|
|
|
|
|
# |
|
54
|
1
|
50
|
|
|
|
2032
|
unless ( $self->check( $url, $ua, $program ) ) { |
|
55
|
1
|
|
|
|
|
59
|
return $self->error("$url did not return expected result"); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
my $request = HTTP::Request->new('POST', $url); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# |
|
61
|
|
|
|
|
|
|
# string-ify the config hash to pass to the CGI |
|
62
|
|
|
|
|
|
|
# |
|
63
|
0
|
|
|
|
|
0
|
my @content = (); |
|
64
|
0
|
|
|
|
|
0
|
@content = map {"$_=" . $args->{$_}} keys %$args; |
|
|
0
|
|
|
|
|
0
|
|
|
65
|
0
|
|
|
|
|
0
|
my $content = join "#", @content; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$request->content( "config=$content" ); |
|
68
|
0
|
|
|
|
|
0
|
my $response = $ua->request( $request ); |
|
69
|
0
|
|
|
|
|
0
|
my $output = $response->content; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
0
|
return $self->error("Some sort of HTTP error") |
|
|
|
|
0
|
|
|
|
|
|
72
|
|
|
|
|
|
|
unless $ua && $request && $response; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
return map { $_ . "\n" } split "\n", $output; |
|
|
0
|
|
|
|
|
0
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
|
78
|
|
|
|
|
|
|
sub check { |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 check |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Tests the URL to make sure the host is live and the CGI returns the |
|
85
|
|
|
|
|
|
|
expected results. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
90
|
1
|
|
|
|
|
1
|
my ($url, $ua, $program) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
2
|
my $content = "check=" . $program; |
|
93
|
1
|
|
|
|
|
6
|
my $request = HTTP::Request->new( 'POST', $url ); |
|
94
|
1
|
|
|
|
|
5936
|
$request->content( $content ); |
|
95
|
1
|
|
|
|
|
27
|
my $response = $ua->request( $request ); |
|
96
|
1
|
|
|
|
|
127437182
|
my $output = $response->content; |
|
97
|
|
|
|
|
|
|
|
|
98
|
1
|
50
|
|
|
|
16
|
return $self->error("No reponse from host $url") |
|
99
|
|
|
|
|
|
|
unless $response; |
|
100
|
|
|
|
|
|
|
|
|
101
|
1
|
50
|
|
|
|
4
|
return $self->error("Incorrect response from host $url") |
|
102
|
|
|
|
|
|
|
unless $response->content =~ /$program OK/m; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return 1; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=pod |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright (C) 2003-2008 Sheldon McKay Emckays@cshl.eduE, |
|
116
|
|
|
|
|
|
|
Ken Y. Clark Ekclark@cpan.orgE. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 LICENSE |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
121
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
122
|
|
|
|
|
|
|
the Free Software Foundation; version 2. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but |
|
125
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
126
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
127
|
|
|
|
|
|
|
General Public License for more details. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
130
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
|
131
|
|
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
132
|
|
|
|
|
|
|
USA. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Bio::PrimerDesigner, primer_designer.cgi. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |