Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move Pise modules over to bioperl-pise

svn path=/bioperl-pise/trunk/; revision=15348
  • Loading branch information...
commit b2c081e530428abb8867333a50fb3769f1dc7dd4 0 parents
cjfields authored
1,027 Bio/Tools/Run/PiseApplication.pm
... ... @@ -0,0 +1,1027 @@
  1 +# $Id$
  2 +#
  3 +# BioPerl modules for Pise
  4 +#
  5 +# Cared for by Catherine Letondal <letondal@pasteur.fr>
  6 +#
  7 +# For copyright and disclaimer see below.
  8 +#
  9 +# POD documentation - main docs before the code
  10 +
  11 +=head1 NAME
  12 +
  13 +Bio::Tools::Run::PiseApplication - A class manage Pise programs information, configuring parameters and submit jobs.
  14 +
  15 +=head1 SYNOPSIS
  16 +
  17 + use Bio::Tools::Run::AnalysisFactory::Pise;
  18 +
  19 + # Build a Pise factory
  20 + my $factory = Bio::Tools::Run::AnalysisFactory::Pise->new();
  21 +
  22 + # Then create an application object (Pise::Run::Tools::PiseApplication):
  23 + my $program = $factory->program('genscan');
  24 +
  25 + # Set parameters
  26 + $program->seq($ARGV[0]);
  27 +
  28 + # Next, run the program
  29 + # (notice that you can set some parameters at run time)
  30 + my $job = $program->run(-parameter_file => "Arabidopsis.smat");
  31 +
  32 + # Test for submission errors:
  33 + if ($job->error) {
  34 + print "Job submission error (",$job->jobid,"):\n";
  35 + print $job->error_message,"\n";
  36 + exit;
  37 + }
  38 +
  39 + # Get results
  40 + print STDERR $job->content('genscan.out');
  41 + # or:
  42 + my $result_file = $job->save('genscan.out');
  43 +
  44 +
  45 +=head1 DESCRIPTION
  46 +
  47 +A class to manage Pise programs information, configuring parameters
  48 +and submit jobs. It is the super-class of all the
  49 +Bio::Tools::Run::PiseApplication::program classes.
  50 +
  51 +This class is preferably created through the
  52 +Bio::Tools::Run::AnalysisFactory::Pise factory:
  53 +
  54 + my $factory = Bio::Tools::Run::AnalysisFactory::Pise->new();
  55 + my $program = $factory->program('mfold');
  56 +
  57 +By submitting a job, you create a Bio::Tools::Run::PiseJob instance with
  58 +the parameters you have just set. Bio::Tools::Run::PiseJob class handles
  59 +a specific job state and results.
  60 +
  61 + my $factory = Bio::Tools::Run::AnalysisFactory::Pise->new(
  62 + -email => 'me@myhome');
  63 + my $program = $factory->program('water',
  64 + -sequencea => $seqa,
  65 + -seqall => $seqb);
  66 +
  67 + # run: submit and waits for completion
  68 + my $job = $program->run();
  69 +
  70 + # for long jobs
  71 + my $job = $program->submit(); # only submit the request
  72 + my $jobid = $job->jobid;
  73 + # later, from another script
  74 + my $job = Bio::Tools::Run::PiseJob->fromUrl($jobid);
  75 + if ($job->terminated) {
  76 + print $job->stdout;
  77 + }
  78 +
  79 +
  80 +=head2 Pise parameters setting.
  81 +
  82 +The @params list should contain a list of -parameter =E<gt> value pairs.
  83 +
  84 + my @params = (-query => $file, -protein_db => "genpept");
  85 + my $program = $factory->program('blast2', @params);
  86 +
  87 +or directly :
  88 +
  89 + my $program = $factory->program('blast2', query => $file, protein_db => "genpept");
  90 +
  91 +Each program parameter is described in the documentation of the
  92 +corresponding Bio::Tools::Run::PiseApplication::program documentation.
  93 +
  94 +You can change parameters at any time by calling the corresponding
  95 +method, e.g, changing the parameter E in blast2:
  96 +
  97 + my $program = $factory->program('blast2', -protein_db => "genpept");
  98 + $program->query($seq);
  99 + $program->Expect($value);
  100 +
  101 +Parameter of Pise type "Sequence" and "InFile" may be given as string,
  102 +filename, or filehandle. Parameter of type "Sequence" may also be given as Bio::Seq or Bio::SimpleAlign objects.
  103 +
  104 +=head2 Job output
  105 +
  106 +See Bio::Tools::Run::PiseJob for how to fetch results and chain programs.
  107 +
  108 +=head2 Location and email parameters
  109 +
  110 +Email can be set at factory creation.
  111 +
  112 +The location parameter stands for the actual CGI location. There are default
  113 +values for most of Pise programs.
  114 +
  115 +You can either set location at:
  116 +
  117 +=over 3
  118 +
  119 +=item 1 factory creation
  120 +
  121 + my $factory = Bio::Tools::Run::AnalysisFactory::Pise->new(
  122 + -location = 'http://somewhere/Pise/cgi-bin',
  123 + -email => 'me@myhome');
  124 +
  125 +=item 2 program creation
  126 +
  127 + my $program = $factory->program('water',
  128 + -location = 'http://somewhere/Pise/cgi-bin/water.pl'
  129 + );
  130 +
  131 +=item 3 any time before running:
  132 +
  133 + $program->location('http://somewhere/Pise/cgi-bin/water.pl');
  134 + $program->run();
  135 +
  136 +=item 4 when running:
  137 +
  138 + $job = $program->run(-location => 'http://somewhere/Pise/cgi-bin/water.pl');
  139 +
  140 +=back
  141 +
  142 +=head1 FEEDBACK
  143 +
  144 +=head2 Mailing Lists
  145 +
  146 +User feedback is an integral part of the evolution of this and other
  147 +Bioperl modules. Send your comments and suggestions preferably to
  148 +the Bioperl mailing list. Your participation is much appreciated.
  149 +
  150 + bioperl-l@bioperl.org - General discussion
  151 + http://bioperl.org/wiki/Mailing_lists - About the mailing lists
  152 +
  153 +=head2 Reporting Bugs
  154 +
  155 +Report bugs to the Bioperl bug tracking system to help us keep track
  156 +of the bugs and their resolution. Bug reports can be submitted via the
  157 +web:
  158 +
  159 + http://bugzilla.open-bio.org/
  160 +
  161 +=head1 AUTHOR
  162 +
  163 +Catherine Letondal (letondal@pasteur.fr)
  164 +
  165 +=head1 COPYRIGHT
  166 +
  167 +Copyright (C) 2003 Institut Pasteur & Catherine Letondal.
  168 +All Rights Reserved.
  169 +
  170 +This module is free software; you can redistribute it and/or modify
  171 +it under the same terms as Perl itself.
  172 +
  173 +=head1 DISCLAIMER
  174 +
  175 +This software is provided "as is" without warranty of any kind.
  176 +
  177 +=head1 SEE ALSO
  178 +
  179 +Bio::Tools::Run::AnalysisFactory::Pise
  180 +Bio::Tools::Run::PiseJob
  181 +
  182 +=cut
  183 +
  184 +#'
  185 +
  186 +package Bio::Tools::Run::PiseApplication;
  187 +
  188 +use vars qw($AUTOLOAD $DEFAULT_PISE_EMAIL @ISA);
  189 +use strict;
  190 +use Bio::Root::Root;
  191 +use Bio::Tools::Run::PiseJob;
  192 +
  193 +@ISA = qw(Bio::Root::Root);
  194 +$DEFAULT_PISE_EMAIL = 'pise-bioapi@pasteur.fr';
  195 +
  196 +=head2 new
  197 +
  198 + Title : new()
  199 + Usage : my $program = Bio::Tools::Run::PiseApplication->new($location,
  200 + $email);
  201 + Function: Creates a Bio::Tools::Run::PiseApplication::program object,
  202 + where program stands for any
  203 + of the Pise programs.
  204 + This method should not be used directly, but rather by
  205 + a Bio::Tools::Run::AnalysisFactory::Pise instance.
  206 + Example :
  207 + Returns : An instance of Bio::Tools::Run::PiseApplication::program.
  208 +
  209 +=cut
  210 +
  211 +sub new {
  212 + my ($class, $location, $email, $verbose) = @_;
  213 +
  214 + my $self = $class->SUPER::new;
  215 + if (! defined $location) {
  216 + $self->throw(ref($self) . ": You must provide a Pise CGI url (-location).");
  217 + }
  218 + $self->{LOCATION} = $location;
  219 + if (defined $email) {
  220 + $self->{EMAIL} = $email;
  221 + } else {
  222 + $self->{EMAIL} = $DEFAULT_PISE_EMAIL;
  223 + }
  224 + if (defined $verbose) {
  225 + $self->{VERBOSE} = $verbose;
  226 + } else {
  227 + $self->{VERBOSE} = 0;
  228 + }
  229 + $self->{RESULTS_TYPE} = "url";
  230 + return $self;
  231 +}
  232 +
  233 +=head2 location
  234 +
  235 + Title : location
  236 + Usage : my $location = $program->location;
  237 + Function: Called from Bio::Tools::Run::PiseJob to get/set program/Pise
  238 + configuration informations from the
  239 + Bio::Tools::Run::PiseApplication::program class.
  240 + Example :
  241 + Returns : A string containing the url of the Pise server CGI.
  242 +
  243 +=cut
  244 +
  245 +sub location {
  246 + my $self = shift;
  247 + if (@_) { $self->{LOCATION} = shift ; }
  248 + return $self->{LOCATION} ;
  249 +}
  250 +
  251 +=head2 email
  252 +
  253 + Title : email()
  254 + Usage : my $email = $program->email();
  255 + Function: Called from Bio::Tools::Run::PiseJob to get/set program/Pise
  256 + configuration informations from the
  257 + Bio::Tools::Run::PiseApplication::program class.
  258 + Example :
  259 + Returns : A string containing the user email for submissions.
  260 +
  261 +=cut
  262 +
  263 +sub email {
  264 + my $self = shift;
  265 + if (@_) { $self->{EMAIL} = shift ; }
  266 + return $self->{EMAIL} ;
  267 +}
  268 +
  269 +=head2 verbose
  270 +
  271 + Title : verbose()
  272 + Usage : $program->verbose(1);
  273 + Function: Ask the object to tells more.
  274 + Example :
  275 + Returns : Actual value.
  276 +
  277 +=cut
  278 +
  279 +sub verbose {
  280 + my $self = shift;
  281 + if (@_) { $self->{VERBOSE} = shift ; }
  282 + return $self->{VERBOSE} ;
  283 +}
  284 +
  285 +=head2 param_type
  286 +
  287 + Title : param_type()
  288 + Usage : my $type = $program->param_type($param);
  289 + Function: Tells the Pise parameter type of $param (e.g: Sequence,
  290 + String, Excl, ...).
  291 + Example :
  292 + Returns : A string containing the Pise parameter type.
  293 +
  294 +=cut
  295 +
  296 +sub param_type {
  297 + my $self = shift;
  298 + my $param = shift;
  299 + my $type;
  300 + if ($param =~ /_data$/) {
  301 + my $p;
  302 + ($p = $param) =~ s/_data//;
  303 + $type = $self->type($p) ;
  304 +# print STDERR "param: $param => $p type=$type\n" if ($self->{DEBUG});
  305 + } else {
  306 + $type = $self->type($param) ;
  307 + }
  308 + return $type;
  309 +}
  310 +
  311 +=head2 run
  312 +
  313 + Title : run()
  314 + Usage : $program->run();
  315 + $program->run(10);
  316 + Function: Submit the job and waits for completion. You may provide an
  317 + interval for completion checking.
  318 + Example :
  319 + Returns : The instance of Bio::Tools::Run::Pisejob that has been run.
  320 +
  321 +=cut
  322 +
  323 +sub run {
  324 + my ($self, @args) = @_;
  325 +
  326 + my ($location) =
  327 + $self->_rearrange([qw(LOCATION )],
  328 + @args);
  329 + if (defined $location) {
  330 + $self->{LOCATION} = $location;
  331 + }
  332 +
  333 + my ($interval) =
  334 + $self->_rearrange([qw(INTERVAL )],
  335 + @args);
  336 + if (! defined $interval) {
  337 + $interval = 10;
  338 + }
  339 +
  340 + foreach my $param ($self->parameters_order) {
  341 + my $param_name = $param;
  342 + $param_name =~ tr/a-z/A-Z/;
  343 + my ($value) =
  344 + $self->_rearrange([$param_name],
  345 + @args);
  346 + if ($value) {
  347 + print STDERR "run: setting $param to $value\n" if $self->{VERBOSE};
  348 + $self->$param($value);
  349 + }
  350 + }
  351 +
  352 + my $pisejob = $self->submit;
  353 + if (! defined $pisejob) {
  354 + $self->throw(ref($self) . "::run: no job created");
  355 + }
  356 + if ($pisejob->error) {
  357 + print STDERR ref($self) . "::run: error while submitting:", $pisejob->error_message,"\n" if $self->{VERBOSE};
  358 + return $pisejob;
  359 + }
  360 +
  361 + my $jobid = $pisejob->jobid();
  362 +
  363 + if ( ! ($pisejob->terminated) ) {
  364 + $pisejob->results_type($self->{RESULTS_TYPE});
  365 + }
  366 + while ( ! ($pisejob->terminated) ) {
  367 + print STDERR ref($self), "::run: waiting for completion...($jobid)\n" if $self->{VERBOSE};
  368 + sleep $interval;
  369 + last if ($pisejob->error);
  370 + }
  371 +
  372 + $self->{_LASTJOBID} = $jobid;
  373 + return $pisejob;
  374 +}
  375 +
  376 +=head2 submit
  377 +
  378 + Title : submit()
  379 + Usage : $program->submit();
  380 + Function: Submit the job.
  381 + Example :
  382 + Returns : The instance of Bio::Tools::Run::Pisejob that has been run.
  383 +
  384 +=cut
  385 +
  386 +sub submit {
  387 + my ($self, @args) = @_;
  388 +
  389 + my ($location) =
  390 + $self->_rearrange([qw(LOCATION )],
  391 + @args);
  392 + if (defined $location) {
  393 + $self->{LOCATION} = $location;
  394 + }
  395 +
  396 + foreach my $param ($self->parameters_order) {
  397 + my $param_name = $param;
  398 + $param_name =~ tr/a-z/A-Z/;
  399 + my ($value) =
  400 + $self->_rearrange([$param_name],
  401 + @args);
  402 + if ($value) {
  403 + print STDERR "submit: setting $param to $value\n" if $self->{VERBOSE};
  404 + $self->$param($value);
  405 + }
  406 + }
  407 +
  408 + my $pisejob = Bio::Tools::Run::PiseJob->new($self, $self->{VERBOSE});
  409 +
  410 + if (! defined $pisejob) {
  411 + $self->throw(ref($self) . "::submit: no job created");
  412 + }
  413 + if ($pisejob->error) {
  414 + return $pisejob;
  415 + }
  416 + if ( ! ($pisejob->terminated) ) {
  417 + $pisejob->results_type($self->{RESULTS_TYPE});
  418 + }
  419 + my $jobid = $pisejob->jobid();
  420 + $self->{_LASTJOBID} = $jobid;
  421 +
  422 + print STDERR ref($self), "::submit: job running, url: $jobid\n" if $self->{VERBOSE};
  423 +
  424 + return $pisejob;
  425 +}
  426 +
  427 +=head2 results_type
  428 +
  429 + Title : results_type()
  430 + Usage : $program->results_type($type);
  431 + Function: Enables to change result delivery from one email per file
  432 + to url notification or attached files. $type is either: url,
  433 + attachment, email. This information will be provided to the job
  434 + when detached and submitted through the run method.
  435 + Example :
  436 + Returns :
  437 +
  438 +=cut
  439 +
  440 +sub results_type {
  441 + my ($self, $type) = @_;
  442 + $self->{RESULTS_TYPE} = $type;
  443 + print STDERR ref($self), "::results_type: results type changed to: $type\n" if $self->{VERBOSE};
  444 +}
  445 +
  446 +
  447 +=head2 paraminfo
  448 +
  449 + Title : paraminfo()
  450 + Usage : $program->paraminfo();
  451 + Function: Displays parameters and prompts.
  452 + Example :
  453 + Returns :
  454 +
  455 +=cut
  456 +
  457 +sub paraminfo {
  458 + my $self = shift;
  459 + my $prompt;
  460 + foreach my $param ($self->parameters) {
  461 + $prompt = $self->prompt($param);
  462 + if ($prompt) {
  463 + print "$param\t\t$prompt\n";
  464 + }
  465 + }
  466 + return;
  467 +}
  468 +
  469 +=head2 _init_params
  470 +
  471 + Title : _init_params
  472 + Usage : $self->_init_params(@params);
  473 + Function: Internal. To be called from Pise::program::new method after
  474 + all the data structures have been initialized.
  475 + Example :
  476 + Returns :
  477 +
  478 +=cut
  479 +
  480 +sub _init_params {
  481 + my $self = shift;
  482 + my @params = @_;
  483 +
  484 + my ($param, $value);
  485 + while (@params) {
  486 + $param = shift @params;
  487 + $value = shift @params;
  488 + next if( $param =~ /^-/ ); # don't want named parameters
  489 + print STDERR "init_params $param to $value\n" if $self->{VERBOSE};
  490 + $self->$param($value);
  491 + }
  492 +}
  493 +
  494 +=head2 _OK_FIELD
  495 +
  496 + Title : _OK_FIELD()
  497 + Usage : if ($self->_OK_FIELD($param)) ...
  498 + Function: Checks if $param is a known parameter for the specific program.
  499 + Example :
  500 + Returns : TRUE/FALSE
  501 +
  502 +=cut
  503 +
  504 +sub _OK_FIELD {
  505 + my ($self, $param) = @_;
  506 + print STDERR "_OK_FIELD: $param\n" if $self->{DEBUG};
  507 + if (grep /^$param$/, $self->parameters) {
  508 + return 1;
  509 + }
  510 + if ($param =~ /(\w+)_data$/) {
  511 + $param = $1;
  512 + my $type = $self->param_type($param);
  513 + if ($type eq "InFile" || $type eq "Sequence") {
  514 + return 1;
  515 + }
  516 + }
  517 +
  518 +}
  519 +
  520 +sub AUTOLOAD {
  521 + my $self = shift;
  522 + my $param = $AUTOLOAD;
  523 + $param =~ s/.*:://;
  524 +
  525 + #print STDERR "AUTOLOAD: $param\n";
  526 + $self->throw("Unallowed parameter or unknown procedure: $param !") unless $self->_OK_FIELD($param);
  527 + $self->{$param} = shift if @_;
  528 + print STDERR ref($self), "::$param: $param set to: ",$self->{$param}, "\n" if $self->{DEBUG};
  529 + return $self->{$param};
  530 +}
  531 +
  532 +#
  533 +# from here on, all the methods are accessors to Pise data structures.
  534 +#
  535 +
  536 +sub parameters {
  537 + my $self = shift;
  538 + return ($self->parameters_order);
  539 +}
  540 +
  541 +sub command {
  542 + my $self = shift;
  543 + return $self->{COMMAND} ;
  544 +}
  545 +
  546 +sub program {
  547 + my $self = shift;
  548 + return ( $self->command ) ;
  549 +}
  550 +
  551 +sub version {
  552 + my $self = shift;
  553 + return $self->{VERSION} ;
  554 +}
  555 +
  556 +sub title {
  557 + my $self = shift;
  558 + if (@_) { $self->{TITLE} = shift ; }
  559 + return $self->{TITLE} ;
  560 +}
  561 +
  562 +sub description {
  563 + my $self = shift;
  564 + if (@_) { $self->{DESCRIPTION} = shift ; }
  565 + return $self->{DESCRIPTION} ;
  566 +}
  567 +
  568 +sub authors {
  569 + my $self = shift;
  570 + if (@_) { $self->{AUTHORS} = shift ; }
  571 + return $self->{AUTHORS} ;
  572 +}
  573 +
  574 +sub doclink {
  575 + my $self = shift;
  576 + if (@_) { $self->{DOCLINK} = shift ; }
  577 + return $self->{DOCLINK} ;
  578 +}
  579 +
  580 +sub reference {
  581 + my $self = shift;
  582 + return @{ $self->{REFERENCE} };
  583 +}
  584 +
  585 +sub seqinput {
  586 + my $self = shift;
  587 + if (@_) { $self->{SEQINPUT} = shift ; }
  588 + return $self->{SEQINPUT} ;
  589 +}
  590 +
  591 +sub seqtype {
  592 + my $self = shift;
  593 + if (@_) { $self->{SEQTYPE} = shift ; }
  594 + return $self->{SEQTYPE} ;
  595 +}
  596 +
  597 +sub top_parameters {
  598 + my $self = shift;
  599 + return @{ $self->{TOP_PARAMETERS} };
  600 +}
  601 +
  602 +sub parameters_order {
  603 + my $self = shift;
  604 + return @{ $self->{PARAMETERS_ORDER} };
  605 +}
  606 +
  607 +sub by_group_parameters {
  608 + my $self = shift;
  609 + return @{ $self->{BY_GROUP_PARAMETERS} };
  610 +}
  611 +
  612 +sub type {
  613 + my $self = shift;
  614 + if (@_) {
  615 + my $param = shift;
  616 + if (@_) { $self->{TYPE}{$param} = shift ; }
  617 + return $self->{TYPE}{$param};
  618 + } else {
  619 + return %{ $self->{TYPE} };
  620 + }
  621 +}
  622 +
  623 +sub format {
  624 + my $self = shift;
  625 + if (@_) {
  626 + my $param = shift;
  627 + if (@_) {
  628 + my $language = shift;
  629 + if (@_) { $self->{FORMAT}{$param}{$language} = shift ; }
  630 + return $self->{FORMAT}{$param}{$language};
  631 + } else {
  632 + if (defined $self->{FORMAT}{$param}) {
  633 + return %{ $self->{FORMAT}{$param} };
  634 + } else {
  635 + return $self->{FORMAT}{$param};
  636 + }
  637 + }
  638 + } else {
  639 + return %{ $self->{FORMAT} };
  640 + }
  641 +}
  642 +
  643 +sub filenames {
  644 + my $self = shift;
  645 + if (@_) {
  646 + my $param = shift;
  647 + if (@_) { $self->{FILENAMES}{$param} = shift ; }
  648 + return $self->{FILENAMES}{$param};
  649 + } else {
  650 + return %{ $self->{FILENAMES} };
  651 + }
  652 +}
  653 +
  654 +sub seqfmt {
  655 + my $self = shift;
  656 + if (@_) {
  657 + my $param = shift;
  658 + if (@_) { $self->{SEQFMT}{$param} = shift ; }
  659 + return @{ $self->{SEQFMT}{$param} };
  660 + } else {
  661 + return %{ $self->{SEQFMT} };
  662 + }
  663 +}
  664 +
  665 +sub size {
  666 + my $self = shift;
  667 + if (@_) {
  668 + my $param = shift;
  669 + if (@_) { $self->{SIZE}{$param} = shift ; }
  670 + return $self->{SIZE}{$param};
  671 + } else {
  672 + return %{ $self->{SIZE} };
  673 + }
  674 +}
  675 +
  676 +sub group {
  677 + my $self = shift;
  678 + if (@_) {
  679 + my $param = shift;
  680 + if (@_) { $self->{GROUP}{$param} = shift ; }
  681 + return $self->{GROUP}{$param};
  682 + } else {
  683 + return %{ $self->{GROUP} };
  684 + }
  685 +}
  686 +
  687 +sub ishidden {
  688 + my $self = shift;
  689 + if (@_) {
  690 + my $param = shift;
  691 + if (@_) { $self->{ISHIDDEN}{$param} = shift ; }
  692 + return $self->{ISHIDDEN}{$param};
  693 + } else {
  694 + return %{ $self->{ISHIDDEN} };
  695 + }
  696 +}
  697 +
  698 +sub iscommand {
  699 + my $self = shift;
  700 + if (@_) {
  701 + my $param = shift;
  702 + if (@_) { $self->{ISCOMMAND}{$param} = shift ; }
  703 + return $self->{ISCOMMAND}{$param};
  704 + } else {
  705 + return %{ $self->{ISCOMMAND} };
  706 + }
  707 +}
  708 +
  709 +sub ismandatory {
  710 + my $self = shift;
  711 + if (@_) {
  712 + my $param = shift;
  713 + if (@_) { $self->{ISMANDATORY}{$param} = shift ; }
  714 + return $self->{ISMANDATORY}{$param};
  715 + } else {
  716 + return %{ $self->{ISMANDATORY} };
  717 + }
  718 +}
  719 +
  720 +sub isstandout {
  721 + my $self = shift;
  722 + if (@_) {
  723 + my $param = shift;
  724 + if (@_) { $self->{ISSTANDOUT}{$param} = shift ; }
  725 + return $self->{ISSTANDOUT}{$param};
  726 + } else {
  727 + return %{ $self->{ISSTANDOUT} };
  728 + }
  729 +}
  730 +
  731 +sub _interface_standout {
  732 + my $self = shift;
  733 + if (@_) { $self->{_INTERFACE_STANDOUT} = shift ; }
  734 + return $self->{_INTERFACE_STANDOUT};
  735 +}
  736 +
  737 +sub _standout_file {
  738 + my $self = shift;
  739 + if (@_) { $self->{_STANDOUT_FILE} = shift ; }
  740 + return $self->{_STANDOUT_FILE};
  741 +}
  742 +
  743 +sub prompt {
  744 + my $self = shift;
  745 + if (@_) {
  746 + my $param = shift;
  747 + if (@_) { $self->{PROMPT}{$param} = shift ; }
  748 + return $self->{PROMPT}{$param};
  749 + } else {
  750 + return %{ $self->{PROMPT} };
  751 + }
  752 +}
  753 +
  754 +sub vlist {
  755 + my $self = shift;
  756 + if (@_) {
  757 + my $param = shift;
  758 + if (@_) { $self->{VLIST}{$param} = shift ; }
  759 + return @{ $self->{VLIST}{$param} };
  760 + } else {
  761 + return %{ $self->{VLIST} };
  762 + }
  763 +}
  764 +
  765 +sub flist {
  766 + my $self = shift;
  767 + if (@_) {
  768 + my $param = shift;
  769 + if (@_) {
  770 + my $value = shift;
  771 + if (@_) { $self->{FLIST}{$param}{$value} = shift ; }
  772 + return $self->{FLIST}{$param}{$value};
  773 + } else {
  774 + if (defined $self->{FLIST}{$param}) {
  775 + return %{ $self->{FLIST}{$param} };
  776 + } else {
  777 + return $self->{FLIST}{$param} ;
  778 + }
  779 + }
  780 + } else {
  781 + return %{ $self->{FLIST} };
  782 + }
  783 +}
  784 +
  785 +sub separator {
  786 + my $self = shift;
  787 + if (@_) {
  788 + my $param = shift;
  789 + if (@_) { $self->{SEPARATOR}{$param} = shift ; }
  790 + return $self->{SEPARATOR}{$param};
  791 + } else {
  792 + return %{ $self->{SEPARATOR} };
  793 + }
  794 +}
  795 +
  796 +sub vdef {
  797 + my $self = shift;
  798 + if (@_) {
  799 + my $param = shift;
  800 + if (@_) { $self->{VDEF}{$param} = shift ; }
  801 + # may be a list (List type parameters)
  802 + # must be casted by user
  803 + return $self->{VDEF}{$param};
  804 + } else {
  805 + return %{ $self->{VDEF} };
  806 + }
  807 +}
  808 +
  809 +sub precond {
  810 + my $self = shift;
  811 + if (@_) {
  812 + my $param = shift;
  813 + if (@_) {
  814 + my $language = shift;
  815 + if (@_) { $self->{PRECOND}{$param}{$language} = shift ; }
  816 + return $self->{PRECOND}{$param}{$language};
  817 + } else {
  818 + if (defined $self->{PRECOND}{$param}) {
  819 + return %{ $self->{PRECOND}{$param} };
  820 + } else {
  821 + return $self->{PRECOND}{$param} ;
  822 + }
  823 + }
  824 + } else {
  825 + return %{ $self->{PRECOND} };
  826 + }
  827 +}
  828 +
  829 +sub ctrl {
  830 + my $self = shift;
  831 + if (@_) {
  832 + my $param = shift;
  833 + if (@_) {
  834 + my $language = shift;
  835 + if (@_) {
  836 + my $test = shift;
  837 + if (@_) {
  838 + $self->{CTRL}{$param}{$language}{$test} = shift ;
  839 + }
  840 + return $self->{CTRL}{$param}{$language}{$test};
  841 + } else {
  842 + if (defined $self->{CTRL}{$param}{$language}) {
  843 + return %{ $self->{CTRL}{$param}{$language} };
  844 + } else {
  845 + return $self->{CTRL}{$param}{$language};
  846 + }
  847 + }
  848 + } else {
  849 + if (defined $self->{CTRL}{$param}) {
  850 + return %{ $self->{CTRL}{$param} };
  851 + } else {
  852 + return $self->{CTRL}{$param};
  853 + }
  854 + }
  855 + } else {
  856 + return %{ $self->{CTRL} };
  857 + }
  858 +}
  859 +
  860 +sub pipeout {
  861 + my $self = shift;
  862 + if (@_) {
  863 + my $param = shift;
  864 + if (@_) {
  865 + my $test = shift;
  866 + if (@_) { $self->{PIPEOUT}{$param}{$test} = shift ; }
  867 + return $self->{PIPEOUT}{$param}{$test} ;
  868 + } else {
  869 + if (defined $self->{PIPEOUT}{$param}) {
  870 + return %{ $self->{PIPEOUT}{$param} };
  871 + } else {
  872 + return $self->{PIPEOUT}{$param};
  873 + }
  874 + }
  875 + } else {
  876 + return %{ $self->{PIPEOUT} };
  877 + }
  878 +}
  879 +
  880 +sub withpipeout {
  881 + my $self = shift;
  882 + if (@_) {
  883 + my $param = shift;
  884 + if (@_) {
  885 + my $test = shift;
  886 + if (@_) { $self->{WITHPIPEOUT}{$param}{$test} = shift ; }
  887 + return @{ $self->{WITHPIPEOUT}{$param}{$test} };
  888 + } else {
  889 + if (defined $self->{WITHPIPEOUT}{$param}) {
  890 + return %{ $self->{WITHPIPEOUT}{$param} };
  891 + } else {
  892 + return $self->{WITHPIPEOUT}{$param} ;
  893 + }
  894 + }
  895 + } else {
  896 + return %{ $self->{WITHPIPEOUT} };
  897 + }
  898 +}
  899 +
  900 +sub pipein {
  901 + my $self = shift;
  902 + if (@_) {
  903 + my $param = shift;
  904 + if (@_) {
  905 + my $type = shift;
  906 + if (@_) { $self->{PIPEIN}{$param}{$type} = shift ; }
  907 + return $self->{PIPEIN}{$param}{$type} ;
  908 + } else {
  909 + if (defined $self->{PIPEIN}{$param}) {
  910 + return %{ $self->{PIPEIN}{$param} };
  911 + } else {
  912 + return $self->{PIPEIN}{$param};
  913 + }
  914 + }
  915 + } else {
  916 + return %{ $self->{PIPEIN} };
  917 + }
  918 +}
  919 +
  920 +sub withpipein {
  921 + my $self = shift;
  922 + if (@_) {
  923 + my $param = shift;
  924 + if (@_) {
  925 + my $type = shift;
  926 + if (@_) { $self->{WITHPIPEIN}{$param}{$type} = shift ; }
  927 + return @{ $self->{WITHPIPEIN}{$param}{$type} };
  928 + } else {
  929 + if (defined $self->{WITHPIPEIN}{$param}) {
  930 + return %{ $self->{WITHPIPEIN}{$param} };
  931 + } else {
  932 + return $self->{WITHPIPEIN}{$param} ;
  933 + }
  934 + }
  935 + } else {
  936 + return %{ $self->{WITHPIPEIN} };
  937 + }
  938 +}
  939 +
  940 +sub isclean {
  941 + my $self = shift;
  942 + if (@_) {
  943 + my $param = shift;
  944 + if (@_) { $self->{ISCLEAN}{$param} = shift ; }
  945 + return $self->{ISCLEAN}{$param};
  946 + } else {
  947 + return %{ $self->{ISCLEAN} };
  948 + }
  949 +}
  950 +
  951 +sub issimple {
  952 + my $self = shift;
  953 + if (@_) {
  954 + my $param = shift;
  955 + if (@_) { $self->{ISSIMPLE}{$param} = shift ; }
  956 + return $self->{ISSIMPLE}{$param};
  957 + } else {
  958 + return %{ $self->{ISSIMPLE} };
  959 + }
  960 +}
  961 +
  962 +sub paramfile {
  963 + my $self = shift;
  964 + if (@_) {
  965 + my $param = shift;
  966 + if (@_) { $self->{PARAMFILE}{$param} = shift ; }
  967 + return $self->{PARAMFILE}{$param};
  968 + } else {
  969 + return %{ $self->{PARAMFILE} };
  970 + }
  971 +}
  972 +
  973 +sub comment {
  974 + my $self = shift;
  975 + if (@_) {
  976 + my $param = shift;
  977 + if (@_) {
  978 + $self->{COMMENT}{$param} = [ @{$_[0]} ] ;
  979 + }
  980 + if (defined $self->{COMMENT}{$param} ) {
  981 + return @{ $self->{COMMENT}{$param} };
  982 + } else {
  983 + return $self->{COMMENT}{$param}
  984 + }
  985 + } else {
  986 + return %{ $self->{COMMENT} };
  987 + }
  988 +}
  989 +
  990 +
  991 +sub scalemin {
  992 + my $self = shift;
  993 + if (@_) {
  994 + my $param = shift;
  995 + if (@_) { $self->{SCALEMIN}{$param} = shift ; }
  996 + return $self->{SCALEMIN}{$param};
  997 + } else {
  998 + return %{ $self->{SCALEMIN} };
  999 + }
  1000 +}
  1001 +
  1002 +sub scalemax {
  1003 + my $self = shift;
  1004 + if (@_) {
  1005 + my $param = shift;
  1006 + if (@_) { $self->{SCALEMAX}{$param} = shift ; }
  1007 + return $self->{SCALEMAX}{$param};
  1008 + } else {
  1009 + return %{ $self->{SCALEMAX} };
  1010 + }
  1011 +}
  1012 +
  1013 +sub scaleinc {
  1014 + my $self = shift;
  1015 + if (@_) {
  1016 + my $param = shift;
  1017 + if (@_) { $self->{SCALEINC}{$param} = shift ; }
  1018 + return $self->{SCALEINC}{$param};
  1019 + } else {
  1020 + return %{ $self->{SCALEINC} };
  1021 + }
  1022 +}
  1023 +
  1024 +
  1025 +1;
  1026 +
  1027 +
1,220 Bio/Tools/Run/PiseJob.pm
... ... @@ -0,0 +1,1220 @@
  1 +# $Id$
  2 +# BioPerl modules for Pise
  3 +#
  4 +# Cared for by Catherine Letondal <letondal@pasteur.fr>
  5 +#
  6 +# For copyright and disclaimer see below.
  7 +#
  8 +# POD documentation - main docs before the code
  9 +
  10 +=head1 NAME
  11 +
  12 +Bio::Tools::Run::PiseJob - A class to manage Pise jobs.
  13 +
  14 +=head1 SYNOPSIS
  15 +
  16 + use Bio::Tools::Run::AnalysisFactory::Pise;
  17 +
  18 + # Build a Pise factory
  19 + my $factory = Bio::Tools::Run::AnalysisFactory::Pise->new();
  20 +
  21 + # Then create an application object (Pise::Run::Tools::PiseApplication):
  22 + my $program = $factory->program('genscan');
  23 +
  24 + # Set parameters
  25 + $program->seq($ARGV[0]);
  26 +
  27 + # Next, run the program
  28 + # (notice that you can set some parameters at run time)
  29 + my $job = $program->run(-parameter_file => "Arabidopsis.smat");
  30 +
  31 + my $job = $program->run(-seq => $ARGV[0]);
  32 +
  33 + # Test for submission errors:
  34 + if ($job->error) {
  35 + print "Job submission error (",$job->jobid,"):\n";
  36 + print $job->error_message,"\n";
  37 + exit;
  38 + }
  39 +
  40 + # Get results
  41 + print STDERR $job->content('genscan.out');
  42 + # or:
  43 + my $result_file = $job->save('genscan.out');
  44 +
  45 +
  46 +=head1 DESCRIPTION
  47 +
  48 +Bio::Tools::Run::PiseJob class handles a specific job state and results.
  49 +A Bio::Tools::Run::PiseJob instance should be created by a subclass of
  50 +Bio::Tools::Run::PiseApplication class, e.g
  51 +Bio::Tools::Run::PiseApplication::genscan or
  52 +Bio::Tools::Run::PiseApplication::dnapars, ... (see
  53 +Bio::Tools::Run::PiseApplication class) :
  54 +
  55 + my $job = Bio::Tools::Run::PiseJob->new($self, $self->{VERBOSE});
  56 +
  57 +This class may also be used as a mean to get informations
  58 +about a running job, or to get results after a long computation:
  59 +
  60 + my $job = Bio::Factory::Pise->job($url);
  61 + print $job->content('infile.aln');
  62 +
  63 +Once the job is created, you can get results:
  64 +
  65 + foreach my $result ($job->get_results) {
  66 + print $job->content($result);
  67 + $job->save($result, "myfile"); # $job->save($result) keeps the name
  68 + print $job->stdout; # print job standard output
  69 + print $job->stderr; # print job standard error
  70 + }
  71 +
  72 +You can feed a result file as a filehandle to a bioperl parser :
  73 +
  74 + my $parser = Bio::Tools:Genscan->new (-fh => $job->fh('genscan.out'));
  75 + my $parser = Bio::Tools:BPlite->new (-fh => $job->fh('blast2.txt'));
  76 +
  77 +... or to another pise job:
  78 +
  79 + my $neighbor = $factory->program ('neighbor',
  80 + -infile => $job->fh('outfile'));
  81 +
  82 +You can lookup up for a type of result that could be piped to another
  83 +Pise program:
  84 +
  85 + my $matrix = $job->lookup_piped_file('phylip_dist');
  86 +
  87 +returns the url of the just calculated Phylip distances matrix file,
  88 +produced by e.g DNADIST or PROTDIST.
  89 +
  90 +All the available pipe types may be obtained by:
  91 +
  92 + $job->lookup_piped_files;
  93 +
  94 +=head1 FEEDBACK
  95 +
  96 +=head2 Mailing Lists
  97 +
  98 +User feedback is an integral part of the evolution of this and other
  99 +Bioperl modules. Send your comments and suggestions preferably to
  100 +the Bioperl mailing list. Your participation is much appreciated.
  101 +
  102 + bioperl-l@bioperl.org - General discussion
  103 + http://bioperl.org/wiki/Mailing_lists - About the mailing lists
  104 +
  105 +=head2 Reporting Bugs
  106 +
  107 +Report bugs to the Bioperl bug tracking system to help us keep track
  108 +of the bugs and their resolution. Bug reports can be submitted via the
  109 +web:
  110 +
  111 + http://bugzilla.open-bio.org/
  112 +
  113 +=head1 AUTHOR
  114 +
  115 +Catherine Letondal (letondal@pasteur.fr)
  116 +
  117 +=head1 COPYRIGHT
  118 +
  119 +Copyright (C) 2003 Institut Pasteur & Catherine Letondal.
  120 +All Rights Reserved.
  121 +
  122 +This module is free software; you can redistribute it and/or modify
  123 +it under the same terms as Perl itself.
  124 +
  125 +=head1 DISCLAIMER
  126 +
  127 +This software is provided "as is" without warranty of any kind.
  128 +
  129 +=head1 SEE ALSO
  130 +
  131 +Bio::Tools::Run::AnalysisFactory::Pise
  132 +Bio::Tools::Run::PiseApplication
  133 +
  134 +=cut
  135 +
  136 +#'
  137 +
  138 +package Bio::Tools::Run::PiseJob;
  139 +
  140 +use strict;
  141 +use Bio::Root::Root;
  142 +use Bio::AlignIO;
  143 +use Bio::Tools::Run::PiseJobParser;
  144 +use XML::Parser::PerlSAX;
  145 +use LWP::UserAgent;
  146 +use HTTP::Request::Common;
  147 +use POSIX;
  148 +use Bio::Root::Version;
  149 +
  150 +use base qw(Bio::Root::Root);
  151 +
  152 +our $VERSION = ${Bio::Root::Version::VERSION};
  153 +
  154 +=head2 new
  155 +
  156 + Title : new()
  157 + Usage : $job = Bio::Tools::Run::PiseJob->new($application, $verbose);
  158 + Function: Creates a Bio::Tools::Run::PiseJob ob