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

Annotation of /FigWebServices/webservices_nmpdr.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : redwards 1.1 #__perl__
2 :    
3 :     use strict;
4 :     use Carp;
5 :     use SOAP::Lite;
6 :     use SOAP::Transport::HTTP;
7 :     use Data::Dumper;
8 :    
9 :     SOAP::Transport::HTTP::CGI
10 :     -> dispatch_to('NMPDRWebServices')
11 :     -> handle;
12 :    
13 :     package NMPDRWebServices;
14 :    
15 :     use FIG;
16 :     use FIG_Config;
17 :     use Data::Dumper;
18 : redwards 1.2 use FFs;
19 :     use FF;
20 : redwards 1.1 use IPC::Open3;
21 :     use PinnedRegions;
22 :    
23 :    
24 :    
25 :    
26 :     =begin WSDL
27 :     _IN peg $string
28 :     _RETURN $string
29 :     _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]
30 :     =cut
31 :     sub external_calls {
32 :     my ($class, $arg) = @_;
33 :     return stdin_caller($class, "external_calls", $arg);
34 :     }
35 :    
36 :     =begin WSDL
37 :     _IN peg $string
38 :     _RETURN $string
39 :     _DOC Get the functional annotation of a given protein identifier. Input is a peg, output is a function
40 :     =cut
41 :     sub function_of {
42 :     my ($class, $arg) = @_;
43 :     my $fig=new FIG;
44 :     return scalar($fig->function_of($arg));
45 :     }
46 :    
47 :     =begin WSDL
48 :     _IN peg $string
49 :     _RETURN $string
50 :     _DOC Get the genome(s) that a given protein identifier refers to. Input is a peg, output is a single column table of genomes
51 :     =cut
52 :     sub genomes_of {
53 :     my ($class, $arg) = @_;
54 :     return stdin_caller($class, "genomes_of", $arg);
55 :     }
56 :    
57 :    
58 :     =begin WSDL
59 :     _IN genomeid $string
60 :     _RETURN $string
61 :     _DOC Get the genus and species of a genome identifier. Input is a genome ID, output is the genus and species of the genome
62 :     =cut
63 :     sub genus_species {
64 :     my ($class, $arg) = @_;
65 :     my $fig=new FIG;
66 :     return $fig->genus_species($arg);
67 :     }
68 :    
69 :    
70 :     =begin WSDL
71 :     _IN peg $string
72 :     _RETURN $string
73 :     _DOC Get the DNA sequence for a given protein identifier. Input is a peg, output is the DNA sequence in fasta format.
74 :     =cut
75 :     sub fid2dna {
76 :     my ($class, $arg) = @_;
77 :     return stdin_caller($class, "fid2dna", $arg);
78 :     }
79 :    
80 :    
81 :    
82 :     =begin WSDL
83 :     _IN genomeid $string
84 :     _RETURN $string
85 :     _DOC Get all the protein identifiers associated with a genome. Input is a genome id, output is a list of pegs in that genome
86 :     =cut
87 :     sub pegs_of {
88 :     my ($class, $arg) = @_;
89 :     my $fig = new FIG;
90 :     return (join ",", $fig->pegs_of($arg));
91 :     }
92 :    
93 :     =begin WSDL
94 :     _IN peg $string
95 :     _RETURN $string
96 :     _DOC Get the translation (protein sequence) of a peg. Input is a peg, output is the protein sequence
97 :     =cut
98 :     sub translation_of {
99 :     my ($class, $arg) = @_;
100 :     return stdin_caller($class, "translation_of", $arg);
101 :     }
102 :    
103 :     =begin WSDL
104 :     _IN peg $string
105 :     _RETURN $string
106 :     _DOC Get the translation (protein sequence) of a peg. Input is a peg, output is translation
107 :     =cut
108 :     sub get_translation {
109 :     my ($class, $arg1) = @_;
110 :     my $fig = new FIG;
111 :     my $result = $fig->get_translation($arg1);
112 :     return $result;
113 :     }
114 :    
115 :     =begin WSDL
116 :     _IN peg $string
117 :     _RETURN @string
118 :     _DOC Get the location of a peg on its contig. Input is a peg, output is list of loc on contig
119 :     =cut
120 :     sub feature_location {
121 :     my ($class, $arg1) = @_;
122 :     my $fig = new FIG;
123 :     my @result = ($fig->feature_location($arg1));
124 :     return @result;
125 :     }
126 :    
127 :     =begin WSDL
128 :     _IN peg $string
129 :     _RETURN $string
130 :     _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
131 :     =cut
132 :     sub aliases_of {
133 :     my ($class, $arg) = @_;
134 :     return stdin_caller($class, "aliases_of", $arg);
135 :     }
136 :    
137 :     =begin WSDL
138 :     _IN alias $string
139 :     _RETURN $string
140 :     _DOC Get the FIG ID (peg) for a given external identifier. Input is an identifier used by another database, output is our identifier
141 :     =cut
142 :     sub alias2fig {
143 :     my ($class, $arg) = @_;
144 :     return stdin_caller($class, "alias2fig", $arg);
145 :     }
146 :    
147 :    
148 :    
149 :    
150 :     =begin WSDL
151 :     _RETURN @string
152 :     _DOC Get the set of NMPDR genomes. Output is a comma separated list of genomes
153 :     =cut
154 :     sub nmpdr_genomes {
155 :     my $class = shift();
156 :     my $fig=new FIG;
157 :     my @genomes=$fig->genomes('Complete', undef, 'Bacteria');
158 :     @genomes=grep {$fig->is_NMPDR_genome($_)} @genomes;
159 :     return join(",", @genomes);
160 :     }
161 :    
162 :    
163 :     =begin WSDL
164 :     _IN pattern $string
165 :     _RETURN @string
166 :     _DOC Search the database. Input is a pattern to search for, output is tab separated list of pegs and roles
167 :     =cut
168 :     sub simple_search {
169 :     my ($class, $arg1)=@_;
170 :    
171 :     my $fig = new FIG;
172 :    
173 :     my ($pegs, $roles) = $fig->search_index($arg1);
174 :    
175 :     my (@result_list, $entry);
176 :    
177 :     for $entry (@$pegs) {
178 :     push (@result_list, (join("\t", @$entry)));
179 :     }
180 :    
181 :     # push (@result_list, (join("\t", @$roles)));
182 :     chomp @result_list;
183 :     my $return_value = join ("\n", @result_list);
184 :     return $return_value;
185 :     }
186 :    
187 :    
188 :    
189 :    
190 :    
191 :     ##### INTERNAL METHODS
192 :    
193 :     sub stdin_caller {
194 :     my ($class, $name, $arg) = @_;
195 :     my($rd, $wr, $err, $pid, $std_err, $return_value, @std_out);
196 :     if (!($pid = open3($wr, $rd, $err, "$FIG_Config::bin/$name")))
197 :     {
198 :     die "Cannot run open3 $name: $!";
199 :     }
200 :    
201 :     $wr->write($arg);
202 :     close($wr);
203 :    
204 :     @std_out= <$rd>;
205 :     close($rd);
206 :     waitpid $pid, 0;
207 :     $return_value = join ("", @std_out);
208 :     return $return_value;
209 :     }
210 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3