Merge branch 'master' into topic/simple_image_upload
[sgn.git] / cgi-bin / downloads / perlcyc.pl
blob472026f3e6ad6db51057d67948c74dc44260195d
2 use strict;
3 use CXGN::Page;
4 use CXGN::Page::FormattingHelpers qw | info_section_html |;
5 my $p = CXGN::Page->new();
7 $p->header("PerlCyc.pm", "PerlCyc.pm");
9 print info_section_html (title=>"Description", contents=> <<HTML );
12 PerlCyc is a Perl interface for <a href="http://bioinformatics.ai.sri.com/ptools/">Pathway Tools software</a>. It allows internal Pathay Tools Lisp functions to be accessed through Perl. <br /><br />
14 For a description of what the individual functions do, please
15 refer to the Pathway Tools documentation at http://bioinformat-
16 ics.ai.sri.com/ptools .
17 <br /><br />
18 In general, the Lisp function name has to be converted to something
19 compatible with Perl: Dashes have to be replaced by underlines, and
20 question marks with underline p (_p).
21 <br /><br />
22 Note that the optional parameters of all functions
23 are not supported in perlcyc, except for all_pathways() which can
24 use the optional arguments :all T to get the base pathways only (no
25 super-pathways).
27 HTML
29 print info_section_html (title=>"Installation", contents=> <<HTML );
31 Installation is standard as for any Perl module. If you downloaded the
32 compressed tar file, uncompress and untar the file with the following
33 commands:
34 <pre>
35 gzip < perlcyc.tar.gz | tar xvf -
36 </pre>
37 This will create a directory called perlcyc in your current directory.
38 To install the program, type
39 <pre>
40 make
41 make install
42 </pre>
43 The program should now be available in all your Perl programs. "make
44 install" may require root access or access through sudo. For the latter
45 case, type
46 <pre>
47 sudo make install
48 </pre>
49 You will be prompted for your password.
51 HTML
53 print info_section_html (title=>"Limitations", contents=><<HTML);
55 Perlcyc does not implement the GFP objects in Perl, rather it just
56 sends snippets of code to Pathway-Tools through a socket connection.
57 Only one such connection can be openend at any given time. Because the
58 objects are not implemented in Perl, only object references are supported.
60 HTML
62 print info_section_html (title=>"Supported functions", contents=><<HTML);
65 Object functions:
67 <pre>
68 new
69 Parameters: The knowledge base name. Required!
70 </pre>
71 GFP functions: More information on these functions can be found at:
72 http://www.ai.sri.com/~gfp/spec/paper/node63.html
73 <pre>
74 get_slot_values
75 get_slot_value
76 get_class_all_instances
77 instance_all_instance_of_p
78 member_slot_value_p
79 fequal
80 current_kb
81 put_slot_values
82 put_slot_value
83 add_slot_value
84 replace_slot_value
85 remove_slot_value
86 coercible_to_frame_p
87 class_all_type_of_p
88 get_instance_direct_types
89 get_instance_all_types
90 get_frame_slots
91 put_instance_types
92 save_kb
93 revert_kb
94 </pre>
95 Pathway-tools functions: More information on these functions can be
96 found at: http://bioinformatics.ai.sri.com/ptools/ptools-fns.html
97 <pre>
98 select_organism
99 all_pathways
100 all_orgs
101 all_rxns
102 genes_of_reaction
103 substrates_of_reaction
104 enzymes_of_reaction
105 reaction_reactants_and_products
106 get_predecessors
107 get_successors
108 genes_of_pathway
109 enzymes_of_pathway
110 compounds_of_pathway
111 substrates_of_pathway
112 transcription_factor_p
113 all_cofactors
114 all_modulators
115 monomers_of_protein
116 components_of_protein
117 genes_of_protein
118 reactions_of_enzyme
119 enzyme_p
120 transport_p
121 containers_of
122 modified_forms
123 modified_containers
124 top_containers
125 reactions_of_protein
126 regulon_of_protein
127 transcription_units_of_protein
128 regulator_proteins_of_transcription_unit
129 enzymes_of_gene
130 all_products_of_gene
131 reactions_of_gene
132 pathways_of_gene
133 chromosome_of_gene
134 transcription_unit_of_gene
135 transcription_unit_promoter
136 transcription_unit_genes
137 transcription_unit_binding_sites
138 transcription_unit_transcription_factors
139 transcription_unit_terminators
140 all_transported_chemicals
141 reactions_of_compound
142 full_enzyme_name
143 enzyme_activity_name
144 find_indexed_frame
145 create-instance
146 create-class
147 create-frame
149 pwys-of-organism-in-meta
150 enzymes-of-organism-in-meta
151 lower-taxa-or-species-p org-frame
152 get-class-all-subs
153 </pre>
154 added 5/2008 per Suzanne\'s request:
155 <pre>
156 genes-regulating-gene
157 genes-regulated-by-gene
158 terminators-affecting-gene
159 transcription-unit-mrna-binding-sites
160 transcription-unit-activators
161 transcription-unit-inhibitors
162 containing-tus
163 direct-activators
164 direct-inhibitors
165 </pre>
166 not supported:
167 <pre>
168 get_frames_matching_value (why not?)
169 </pre>
170 Internal functions:
171 <pre>
172 parselisp
173 send_query
174 retrieve_results
175 wrap_query
176 call_func
177 debug
178 debug_on
179 debug_off
180 </pre>
181 Deprecated functions
182 <pre>
183 parse_lisp_list
184 </pre>
186 HTML
188 print info_section_html(title=>"Requirements", contents=> <<HTML );
190 To use the Perl module, you also need the socket_server.lisp program.
191 In Pathway Tools version 8.0 or later, the server program can be
192 started with the command line option "-api". On earlier versions, the
193 server daemon needs to be loaded manually, as follows: start Pathway-
194 Tools with the -lisp option, at the prompt, type: (load
195 "/path/to/socket_server.lisp"), then start the socket_server by typing
196 (start_external_access_daemon :verbose? t). The server is now ready to
197 accept connections and queries.
199 HTML
201 print info_section_html (title=>"Download", contents=> <<HTML );
203 Download [<a href="ftp://ftp.sgn.cornell.edu/programs/perlcyc/">FTP</a>]
205 HTML
207 print info_section_html(title=>"Documentation", contents=> <<HTML );
209 <pre>
210 perlcyc is a Perl interface for Pathway Tools software.
212 "use perlcyc;"
214 "my \$cyc = perlcyc -> new("ARA");" "my \@pathways = \$cyc -> all_path-
215 ways();"
217 VERSION
218 Version 1.21 (May 2008).
220 VERSION HISTORY
222 Version History
224 0.1 March, 2002
225 [Lukas Mueller] initial version
227 0.3 April 22, 2002
228 [Danny Yoo] Added better list parsing
230 0.9 [Lukas Mueller]
231 Added more functions
233 1.0 August 28, 2002 [Lukas Mueller]
234 Added pod documentation and eliminated some bugs.
236 1.1 June 6, 2003
237 [Thomas Yan] Fixed some minor bugs.
239 1.2 December 7, 2006 [Lukas Mueller]
240 Added three functions: create-frame, create-class, and cre-
241 ate-instance.
243 1.21 May 7, 2008 [Lukas Mueller]
244 Added three functions that are new in PT v. 12:
245 pwys-of-organism-in-meta
246 enzymes-of-organism-in-meta
247 lower-taxa-or-species-p org-frame
249 other new functions:
250 get-class-all-subs
252 genes-regulating-gene
253 genes-regulated-by-gene
254 terminators-affecting-gene
255 transcription-unit-mrna-binding-sites
256 transcription-unit-activators
257 transcription-unit-inhibitors
258 containing-tus
259 direct-activators
260 direct-inhibitors
264 </pre>
266 HTML
268 print info_section_html (title=>"Examples", contents=> <<HTML );
270 Change product type for all genes that are in a pathway to "Enzyme"
272 <pre>
273 use perlcyc;
275 my \$cyc = perlcyc -> new ("ARA");
276 my \@pathways = \$cyc -> all_pathways();
278 foreach my $p (\@pathways) {
279 my \@genes = \$cyc -> genes_of_pathway(\$p);
280 foreach my \$g (\@genes) {
281 \$cyc -> put_slot_value (\$g, "Product-Types", "Enzyme");
284 </pre>
285 Load a file containing two columns with accession and a comment into
286 the comment field of the corresponding accession:
287 <pre>
288 use perlcyc;
289 use strict;
291 my \$file = shift;
293 my \$added=0;
294 my \$recs =0;
296 open (F, "<\$file") || die "Can't open file\\n";
298 print STDERR "Connecting to AraCyc...\\n";
299 my \$cyc = perlcyc -> new("ARA");
301 print STDERR "Getting Gene Information...\\n";
302 my \@genes = \$cyc -> get_class_all_instances("|Genes|");
304 my %genes;
306 print STDERR "Getting common names...\\n";
307 foreach my \$g (\@genes) {
308 my \$cname = \$cyc -> get_slot_value(\$g, "common-name");
309 \$genes{\$cname}=\$g;
312 print STDERR "Processing file...\\n";
313 while (&lt;F&gt;) {
314 my (\$locus, \$location, \@rest) = split /\\t/;
315 \$recs++;
316 if (exists \$genes{\$locus}) {
317 my \$product = \$cyc -> get_slot_value(\$genes{\$locus}, "product");
318 if (\$product) {
319 \$cyc -> add_slot_value(\$product, "comment", "\"\\nTargetP location: \$location\\n\"");
320 #print STDERR "Added to description of frame \$product\n";
321 \$added++;
326 close (F);
328 print STDERR "Done. Added \$added descriptions. Total lines in file: \$recs. \\n";
329 </pre>
330 Add a locus link to the TAIR locus page for each gene in the database
331 <pre>
332 use strict;
333 use perlcyc;
335 my \$added =0;
336 my \$genesprocessed=0;
338 print "Connecting to AraCyc...\\n";
339 my \$cyc = perlcyc -> new ("ARA");
341 print "Getting Gene Information...\\n";
342 my \@genes = \$cyc -> get_class_all_instances ("|Genes|");
344 print "Adding TAIR links...\\n";
345 foreach my \$g (\@genes) {
346 \$genesprocessed++;
347 my \$common_name = \$cyc -> get_slot_value(\$g, "common-name");
348 if (\$common_name &amp;&amp; (\$common_name ne "NIL")) {
349 \$cyc -> put_slot_value (\$g, "dblinks", "(TAIR \"\$common_name\")");
350 \$added++;
352 if ((!\$genesprocessed ==0) &amp;&amp; (\$genesprocessed % 1000 == 0)) { print "\$genesprocessed ";}
355 print "Done. Processed \$genesprocessed genes and added \$added links. Thanks!\\n";
356 \$cyc -> close();
357 </pre>
359 HTML
361 print info_section_html(title=>"Troubleshooting", contents=> <<HTML );
363 If your program terminates with the following error message: "connect:
364 No such file or directory at perlcyc.pm line 166." then the
365 lisp_server.lisp module in Pathway Tools is not running. Refer to
366 http://aracyc.stanford.edu for more information on how to run the
367 server program.
369 Please send bug reports and comments to LAM87\@cornell.edu
371 HTML
373 print info_section_html(title=>"License", contents=> <<HTML );
375 <pre>
376 According to the MIT License:<br />
377 http://www.open-source.org/licenses/mit-license.php
378 <br /><br />
379 Copyright (c) 2002-2008 by Lukas Mueller, TAIR, BTI
380 <br /><br />
381 Permission is hereby granted, free of charge, to any person obtaining a
382 copy of this software and associated documentation files (the "Soft-
383 ware"), to deal in the Software without restriction, including without
384 limitation the rights to use, copy, modify, merge, publish, distribute,
385 sublicense, and/or sell copies of the Software, and to permit persons
386 to whom the Software is furnished to do so, subject to the following
387 conditions:
388 <br /><br />
389 The above copyright notice and this permission notice shall be included
390 in all copies or substantial portions of the Software.
391 <br /><br />
392 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
393 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER-
394 CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
395 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
396 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
397 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT-
398 WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
399 <br /><br />
401 ACKNOWLEDGEMENTS
402 Many thanks to Suzanne Paley, Danny Yoo and Thomas Yan.
405 </pre>
407 HTML
410 $p->footer();