Bio-KBase

 view release on metacpan or  search on metacpan

lib/Bio/KBase/GenomeAnnotation/Service.pm  view on Meta::CPAN

package Bio::KBase::GenomeAnnotation::Service;

use Data::Dumper;
use Moose;

extends 'RPC::Any::Server::JSONRPC::PSGI';

has 'instance_dispatch' => (is => 'ro', isa => 'HashRef');
has 'user_auth' => (is => 'ro', isa => 'UserAuth');
has 'valid_methods' => (is => 'ro', isa => 'HashRef', lazy => 1,
			builder => '_build_valid_methods');

our $CallContext;

our %return_counts = (
        'genomeTO_to_reconstructionTO' => 1,
        'genomeTO_to_feature_data' => 1,
        'reconstructionTO_to_roles' => 1,
        'reconstructionTO_to_subsystems' => 1,
        'annotate_genome' => 1,
        'call_RNAs' => 1,
        'call_CDSs' => 1,
        'find_close_neighbors' => 1,
        'assign_functions_to_CDSs' => 1,
        'annotate_proteins' => 1,
);

sub _build_valid_methods
{
    my($self) = @_;
    my $methods = {
        'genomeTO_to_reconstructionTO' => 1,
        'genomeTO_to_feature_data' => 1,
        'reconstructionTO_to_roles' => 1,
        'reconstructionTO_to_subsystems' => 1,
        'annotate_genome' => 1,
        'call_RNAs' => 1,
        'call_CDSs' => 1,
        'find_close_neighbors' => 1,
        'assign_functions_to_CDSs' => 1,
        'annotate_proteins' => 1,
    };
    return $methods;
}

sub call_method {
    my ($self, $data, $method_info) = @_;
    my ($module, $method) = @$method_info{qw(module method)};
    
    my $ctx = Bio::KBase::GenomeAnnotation::ServiceContext->new(client_ip => $self->_plack_req->address);
    
    my $args = $data->{arguments};

        # Service GenomeAnnotation does not require authentication.
        
    my $new_isa = $self->get_package_isa($module);
    no strict 'refs';
    local @{"${module}::ISA"} = @$new_isa;
    local $CallContext = $ctx;
    my @result;
    {
	my $err;
	eval {
	    @result = $module->$method(@{ $data->{arguments} });
	};
	if ($@)
	{
	    #
	    # Reraise the string version of the exception because
	    # the RPC lib can't handle exception objects (yet).



( run in 0.664 second using v1.01-cache-2.11-cpan-5837b0d9d2c )