[Bio] / FigKernelPackages / ACHserver.pm Repository:
ViewVC logotype

View of /FigKernelPackages/ACHserver.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Fri Jun 19 17:30:02 2009 UTC (10 years, 5 months ago) by olson
Branch: MAIN
Changes since 1.3: +4 -0 lines
server fixes

package ACHserver;

#
# This is a SAS Component
#

use LWP::UserAgent;
use Data::Dumper;
use YAML;

use strict;

sub new
{
    my($class, $server_url) = @_;

    $server_url = "http://servers.nmpdr.org/ach/server.cgi" unless $server_url;

    #$server_url = "http://bio-macpro-2.mcs.anl.gov/~disz/FIG/ach_server.cgi" unless $server_url;
    #$server_url = "http://bio-macpro-1.mcs.anl.gov/ross-proj/FIG/co_occurs_server.cgi" unless $server_url;

    my $self = {
        server_url => $server_url,
        ua => LWP::UserAgent->new(),
    };
    return bless $self, $class;
}

sub equiv_precise {
        my ($self, @args) = @_;
        return $self->run_query("equiv_precise", @args);
}
sub equiv_sequence {
        my ($self, @args) = @_;
        return $self->run_query("equiv_sequence", @args);
}


sub run_query
{
    my($self, $function, @args ) = @_;

	    my $arg_string = Dump(@args);
            my $form = [function => $function,
                        args => "$arg_string"];

            my $res = $self->{ua}->post($self->{server_url}, $form);
            if ($res->is_success)
            {
		my $rc;
		eval {
		    $rc = Load($res->content);
		};
		if ($@)
		{
		    die "Bad YAML parse $@ on input\n" .  $res->content;
		}
            }
            else
            {
                die "error on post " . $res->status_line . " " . $res->content;
            }
}


1;




MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3