Dummy.pm 3.41 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-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Matthieu Muffato's avatar
Matthieu Muffato committed
29
    Copyright [2016-2018] EMBL-European Bioinformatics Institute
30 31 32 33 34 35 36 37 38 39

    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
40 41
=head1 CONTACT

42
    Please subscribe to the Hive mailing list:  http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users  to discuss Hive-related questions or to be notified of our updates
Jessica Severin's avatar
Jessica Severin committed
43 44 45

=cut

Leo Gordon's avatar
Leo Gordon committed
46

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

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

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

55

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

60 61 62 63 64 65 66 67 68 69 70 71 72 73
=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
74
=head2 fetch_input
Jessica Severin's avatar
Jessica Severin committed
75

Leo Gordon's avatar
Leo Gordon committed
76 77
    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
78

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

sub fetch_input {
}

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

Leo Gordon's avatar
Leo Gordon committed
86
    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).
87
                  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
88 89 90 91

=cut

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

94 95 96 97 98 99
    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
100 101
}

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

Leo Gordon's avatar
Leo Gordon committed
104 105
    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
106 107 108

=cut

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

1;