init_pipeline.pl 3.5 KB
Newer Older
Leo Gordon's avatar
Leo Gordon committed
1
#!/usr/bin/env perl
2
3
4
5
#
# A generic loader of hive pipelines.
#
# Because all of the functionality is hidden in Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf
6
7
# you can create pipelines by calling the right methods of HiveGeneric_conf directly,
# so this script is just a commandline wrapper that can conveniently find modules by their filename.
8
9

use strict;
Leo Gordon's avatar
Leo Gordon committed
10
use warnings;
11

12
13
sub usage {
    my $retvalue = shift @_;
14

15
16
17
18
19
20
21
22
23
24
25
26
    if(`which perldoc`) {
        system('perldoc', $0);
    } else {
        foreach my $line (<DATA>) {
            if($line!~s/\=\w+\s?//) {
                $line = "\t$line";
            }
            print $line;
        }
    }
    exit($retvalue);
}
27

28
29
sub module_from_file {
    my $filename = shift @_;
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    if(my $package_line = `grep ^package $filename`) {
        if($package_line=~/^package\s+((?:\w|::)+)\s*;/) {
            return $1;
        } else {
            warn "Package line format unrecognized:\n$package_line\n";
            usage(1);
        }
    } else {
        warn "Could not find the package definition line in '$filename'\n";
        usage(1);
    }
}

sub process_options_and_run_module {
    my $config_module = shift @_;

    eval "require $config_module;";

    my $self = $config_module->new();

    $self->process_options();
    $self->run();
}

sub main {
    my $file_or_module = shift @ARGV || usage(0);

    if( $file_or_module=~/^(\w|::)+$/ ) {

        process_options_and_run_module( $file_or_module );
        
    } elsif(-r $file_or_module) {

        process_options_and_run_module( module_from_file( $file_or_module ) );

    } else {
        warn "The first parameter '$file_or_module' neither seems to be a valid module in PERL5LIB nor a valid readable file\n";
        usage(1);
    }
}

main();

__DATA__

=pod

=head1 NAME

    init_pipeline.pl

=head1 SYNOPSIS

84
    init_pipeline.pl <config_module_or_filename> [-help | [ [-analysis_topup | -job_topup] <options_for_this_particular_pipeline>]
85
86
87

=head1 DESCRIPTION

Leo Gordon's avatar
Leo Gordon committed
88
    init_pipeline.pl is a generic script that is used to create+setup=initialize eHive pipelines from PipeConfig configuration modules.
89
90
91

=head1 USAGE EXAMPLES

Leo Gordon's avatar
Leo Gordon committed
92
93
        # get this help message:
    init_pipeline.pl
94

Leo Gordon's avatar
Leo Gordon committed
95
96
        # initialize a generic eHive pipeline:
    init_pipeline.pl Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf -password <yourpassword>
97

Leo Gordon's avatar
Leo Gordon committed
98
99
100
        # see what command line options are available when initializing long multiplication example pipeline
        #   (assuming your current directory is ensembl-hive/modules/Bio/EnsEMBL/Hive) :
    init_pipeline.pl PipeConfig/LongMult_conf -help
101

Leo Gordon's avatar
Leo Gordon committed
102
103
104
        # initialize the long multiplicaton pipeline by supplying not only mandatory but also optional data:
        #   (assuming your current directory is ensembl-hive/modules/Bio/EnsEMBL/Hive/PipeConfig) :
    init_pipeline.pl LongMult_conf -password <yourpassword> -first_mult 375857335 -second_mult 1111333355556666 
105
106
107

=head1 OPTIONS

108
    -help           :   get automatically generated list of options that can be set/changed when initializing a particular pipeline
109

110
111
112
113
    -analysis_topup :   a special initialization mode when (1) pipeline_create_commands are switched off and (2) only newly defined analyses are added to the database
                        This mode is only useful in the process of putting together a new pipeline.

    -job_topup      :   another special initialization mode when only jobs are created - no other structural changes to the pipeline are acted upon.
114
115
116
117
118
119

=head1 CONTACT

    Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.

=cut
120