[Bio] / FigWebServices / webservices_nmpdr.cgi Repository:
ViewVC logotype

View of /FigWebServices/webservices_nmpdr.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Fri Jun 6 05:03:52 2008 UTC (11 years, 8 months ago) by redwards
Branch: MAIN
CVS Tags: rast_rel_2009_05_18, rast_rel_2008_12_18, rast_2008_0924, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, mgrast_rel_2008_0625, rast_rel_2008_10_09, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, mgrast_rel_2008_1110, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, rast_rel_2009_03_26, rast_rel_2008_11_24, rast_rel_2008_08_07
nmpdr web services version

#__perl__

use strict;
use Carp;
use SOAP::Lite;
use SOAP::Transport::HTTP;
use Data::Dumper;

SOAP::Transport::HTTP::CGI   
-> dispatch_to('NMPDRWebServices')     
-> handle;

package NMPDRWebServices;

use FIG;
use FIG_Config;
use Data::Dumper;
use FigFams;
use FigFam;
use IPC::Open3;
use PinnedRegions;




=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the annotations for a peg from all other known sources. Input is a peg, output is two column table of [peg, other function]
=cut
sub external_calls {
	my ($class, $arg) = @_;
	return stdin_caller($class, "external_calls", $arg);
}

=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the functional annotation of a given protein identifier. Input is a peg, output is a function
=cut
sub function_of {
	my ($class, $arg) = @_;
	my $fig=new FIG;
	return scalar($fig->function_of($arg));
}

=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the genome(s) that a given protein identifier refers to. Input is a peg, output is a single column table of genomes
=cut
sub genomes_of {
	my ($class, $arg) = @_;
	return stdin_caller($class, "genomes_of", $arg);
}


=begin WSDL
_IN genomeid $string
_RETURN $string
_DOC Get the genus and species of a genome identifier. Input is a genome ID, output is the genus and species of the genome
=cut
sub genus_species {
	my ($class, $arg) = @_;
	my $fig=new FIG;
	return $fig->genus_species($arg);
}


=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the DNA sequence for a given protein identifier. Input is a peg, output is the DNA sequence in fasta format.
=cut
sub fid2dna {
	my ($class, $arg) = @_;
	return stdin_caller($class, "fid2dna", $arg);
}



=begin WSDL
_IN genomeid $string
_RETURN $string
_DOC Get all the protein identifiers associated with a genome. Input is a genome id, output is a list of pegs in that genome
=cut
sub pegs_of {
	my ($class, $arg) = @_;
	my $fig = new FIG;
	return (join ",", $fig->pegs_of($arg));
}

=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the translation (protein sequence) of a peg. Input is a peg, output is the protein sequence
=cut
sub translation_of {
	my ($class, $arg) = @_;
	return stdin_caller($class, "translation_of", $arg);
}

=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the translation (protein sequence) of a peg. Input is a peg, output is translation
=cut
sub get_translation {
	my ($class, $arg1) = @_;
	my $fig = new FIG;
	my $result = $fig->get_translation($arg1);
	return $result;
}

=begin WSDL
_IN peg $string
_RETURN @string
_DOC Get the location of a peg on its contig. Input is a peg, output is list of loc on contig
=cut
sub feature_location {
	my ($class, $arg1) = @_;
	my $fig = new FIG;
	my @result = ($fig->feature_location($arg1));
	return @result;
}

=begin WSDL
_IN peg $string
_RETURN $string
_DOC Get the aliases of a peg. These are the identifiers that other databases use. Input is a peg, output is tab separated string of aliases
=cut
sub aliases_of {
	my ($class, $arg) = @_;
	return stdin_caller($class, "aliases_of", $arg);
}

=begin WSDL
_IN alias $string
_RETURN $string
_DOC Get the FIG ID (peg) for a given external identifier. Input is an identifier used by another database, output is our identifier
=cut
sub alias2fig {
	my ($class, $arg) = @_;
	return stdin_caller($class, "alias2fig", $arg);
}




=begin WSDL
_RETURN @string
_DOC Get the set of NMPDR genomes. Output is a comma separated list of genomes
=cut
sub nmpdr_genomes {
	my $class = shift();
	my $fig=new FIG;
	my @genomes=$fig->genomes('Complete', undef, 'Bacteria');
	@genomes=grep {$fig->is_NMPDR_genome($_)} @genomes;
	return join(",", @genomes);
}


=begin WSDL
_IN pattern $string
_RETURN @string
_DOC Search the database. Input is a pattern to search for, output is tab separated list of pegs and roles
=cut
sub simple_search {
	my ($class, $arg1)=@_;
	
	my $fig = new FIG;
	
	my ($pegs, $roles) =  $fig->search_index($arg1);
	
	my (@result_list, $entry);
	
	for $entry (@$pegs) {
		push (@result_list, (join("\t", @$entry)));
	}
	
	# push (@result_list, (join("\t", @$roles)));
	chomp @result_list;
	my $return_value = join ("\n", @result_list);
	return $return_value;
}        





##### INTERNAL METHODS

sub stdin_caller {
	my ($class, $name, $arg) = @_;
	my($rd, $wr, $err, $pid, $std_err, $return_value, @std_out);
	if (!($pid = open3($wr, $rd, $err, "$FIG_Config::bin/$name")))
	{
		die "Cannot run open3 $name: $!";
	}
	
	$wr->write($arg);
	close($wr);
	
	@std_out= <$rd>;
	close($rd);
	waitpid $pid, 0;
	$return_value = join ("", @std_out); 
	return $return_value;
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3