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

View of /FigWebServices/webservices_nmpdr.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Wed Aug 18 20:04:41 2010 UTC (9 years, 2 months ago) by redwards
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.1: +2 -2 lines
Changing FigFams/FigFam to FFs/FF

#__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 FFs;
use FF;
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