Dummy.pm 3.26 KB
Newer Older
Jessica Severin's avatar
Jessica Severin committed
1 2 3 4
=pod 

=head1 NAME

5
    Bio::EnsEMBL::Hive::RunnableDB::Dummy
Jessica Severin's avatar
Jessica Severin committed
6 7 8

=head1 SYNOPSIS

9
    standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::Dummy -input_id "{}"
Leo Gordon's avatar
Leo Gordon committed
10

11
    standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::Dummy -input_id "{take_time=>3}"
Leo Gordon's avatar
Leo Gordon committed
12

13
    standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::Dummy -input_id "{take_time=>'rand(3)+1'}"
Jessica Severin's avatar
Jessica Severin committed
14 15 16

=head1 DESCRIPTION

17 18
    A job of 'Bio::EnsEMBL::Hive::RunnableDB::Dummy' analysis does not do any work by itself,
    but it benefits from the side-effects that are associated with having an analysis.
Leo Gordon's avatar
Leo Gordon committed
19

20 21
    For example, if a dataflow rule is linked to the analysis then
    every job that is created or flown into this analysis will be dataflown further according to this rule.
Jessica Severin's avatar
Jessica Severin committed
22

23 24
    param('take_time'):     How much time to spend sleeping (floating point seconds);
                            can be given by a runtime-evaluated formula; useful for testing.
25

26 27
=head1 LICENSE

28
    Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
29 30 31 32 33 34 35 36 37 38

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and limitations under the License.

Jessica Severin's avatar
Jessica Severin committed
39 40
=head1 CONTACT

41
    Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
Jessica Severin's avatar
Jessica Severin committed
42 43 44

=cut

Leo Gordon's avatar
Leo Gordon committed
45

Jessica Severin's avatar
Jessica Severin committed
46 47 48
package Bio::EnsEMBL::Hive::RunnableDB::Dummy;

use strict;
49 50 51
use warnings;
use Time::HiRes ('usleep');

Leo Gordon's avatar
Leo Gordon committed
52
use base ('Bio::EnsEMBL::Hive::Process');
Jessica Severin's avatar
Jessica Severin committed
53

54

55 56 57 58
sub strict_hash_format { # allow this Runnable to parse parameters in its own way (don't complain)
    return 0;
}

59 60 61 62 63 64 65 66 67 68 69 70 71 72
=head2 param_defaults

    Description : Implements param_defaults() interface method of Bio::EnsEMBL::Hive::Process that defines module defaults for parameters.

=cut

sub param_defaults {

    return {
        'take_time' => 0,   # how much time run() method will spend in sleeping state
    };
}


Leo Gordon's avatar
Leo Gordon committed
73
=head2 fetch_input
Jessica Severin's avatar
Jessica Severin committed
74

Leo Gordon's avatar
Leo Gordon committed
75 76
    Description : Implements fetch_input() interface method of Bio::EnsEMBL::Hive::Process that is used to read in parameters and load data.
                  Here we simply override this method so that nothing is done.
Jessica Severin's avatar
Jessica Severin committed
77

Leo Gordon's avatar
Leo Gordon committed
78
=cut
Jessica Severin's avatar
Jessica Severin committed
79 80 81 82

sub fetch_input {
}

Leo Gordon's avatar
Leo Gordon committed
83 84
=head2 run

Leo Gordon's avatar
Leo Gordon committed
85
    Description : Implements run() interface method of Bio::EnsEMBL::Hive::Process that is used to perform the main bulk of the job (minus input and output).
86
                  Since this Runnable is a Dummy, it does nothing. But it can also optionally sleep for param('take_time') seconds.
Leo Gordon's avatar
Leo Gordon committed
87 88 89 90

=cut

sub run {
91 92
    my $self = shift @_;

93 94 95 96 97 98
    my $take_time = eval $self->param('take_time');
    if($take_time) {
        print "Sleeping for '$take_time' seconds...\n";
        usleep( $take_time*1000000 );
        print "Done.\n";
    }
Jessica Severin's avatar
Jessica Severin committed
99 100
}

Leo Gordon's avatar
Leo Gordon committed
101 102
=head2 write_output

Leo Gordon's avatar
Leo Gordon committed
103 104
    Description : Implements write_output() interface method of Bio::EnsEMBL::Hive::Process that is used to deal with job's output after the execution.
                  Here we simply override this method so that nothing is done.
Leo Gordon's avatar
Leo Gordon committed
105 106 107

=cut

Jessica Severin's avatar
Jessica Severin committed
108 109 110 111
sub write_output {
}

1;