tweak_pipeline.pl 5.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#!/usr/bin/env perl

use strict;
use warnings;

    # Finding out own path in order to reference own components (including own modules):
use Cwd            ();
use File::Basename ();
BEGIN {
    $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) );
    unshift @INC, $ENV{'EHIVE_ROOT_DIR'}.'/modules';
}


use Getopt::Long qw(:config pass_through no_auto_abbrev);
use Pod::Usage;

use Bio::EnsEMBL::Hive::HivePipeline;
use Bio::EnsEMBL::Hive::Utils ('script_usage', 'load_file_or_module');


main();


sub main {

    my $self    = {};
    my $tweaks  = [];

    GetOptions(
            # connection parameters
        'url=s'                 => \$self->{'url'},
        'reg_conf|reg_file=s'   => \$self->{'reg_conf'},
        'reg_type=s'            => \$self->{'reg_type'},
        'reg_alias|reg_name=s'  => \$self->{'reg_alias'},
        'nosqlvc=i'             => \$self->{'nosqlvc'},     # using "=i" instead of "!" for consistency with scripts where it is a propagated option

        'tweak|SET=s@'          => \$tweaks,
39 40
        'DELETE=s'              => sub { my ($opt_name, $opt_value) = @_; push @$tweaks, $opt_value.'#'; },
        'SHOW=s'                => sub { my ($opt_name, $opt_value) = @_; push @$tweaks, $opt_value.'?'; },
41 42

        'h|help'                => \$self->{'help'},
43 44 45 46 47
    ) or die "Error in command line arguments\n";

    if (@ARGV) {
        die "ERROR: There are invalid arguments on the command-line: ". join(" ", @ARGV). "\n";
    }
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

    if($self->{'help'}) {
        pod2usage({-exitvalue => 0, -verbose => 2});
    }

    my $pipeline;

    if($self->{'url'} or $self->{'reg_alias'}) {
        $pipeline = Bio::EnsEMBL::Hive::HivePipeline->new(
            -url                            => $self->{'url'},
            -reg_conf                       => $self->{'reg_conf'},
            -reg_type                       => $self->{'reg_type'},
            -reg_alias                      => $self->{'reg_alias'},
            -no_sql_schema_version_check    => $self->{'nosqlvc'},
        );

    } else {
        pod2usage({-exitvalue => 0, -verbose => 2});

    }

    if(@$tweaks) {
70 71 72 73
        my $need_write = $pipeline->apply_tweaks( $tweaks );
        if ($need_write) {
            $pipeline->save_collections();
        }
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    }

}


__DATA__

=pod

=head1 NAME

    tweak_pipeline.pl

=head1 SYNOPSIS

    ./tweak_pipeline.pl [ -url mysql://user:pass@server:port/dbname | -reg_conf <reg_conf_file> -reg_alias <reg_alias> ] -tweak 'analysis[mafft%].analysis_capacity=undef'

=head1 DESCRIPTION

    This is a script to "tweak" attributes or parameters of an existing Hive pipeline.

=head1 OPTIONS

B<--url>

    url defining where hive database is located

B<--reg_conf>

    path to a Registry configuration file

105 106 107 108
B<--reg_type>

    Registry type of the Hive DBAdaptor

109 110 111 112
B<--reg_alias>

    species/alias name for the Hive DBAdaptor

113 114 115 116
B<--nosqlvc>

    "No SQL Version Check" - set this to one if you want to force working with a database created by a potentially schema-incompatible API (0 by default)

117 118 119 120
B<--tweak>

    An assignment command that performs one individual "tweak". You can "tweak" global/analysis parameters, analysis attributes and resource classes:

Brandon Walts's avatar
Brandon Walts committed
121 122
        -tweak 'pipeline.param[take_time]=20'                   # override a value of a pipeline-wide parameter; can also create a non-existent parameter
        -tweak 'analysis[take_b_apart].param[base]=10'          # override a value of an analysis-wide parameter; can also create a non-existent parameter
123 124 125 126 127 128 129
        -tweak 'analysis[add_together].analysis_capacity=undef' # override a value of an analysis attribute
        -tweak 'analysis[add_together].batch_size=15'           # override a value of an analysis_stats attribute
        -tweak 'analysis[part_multiply].resource_class=urgent'  # set the resource class of an analysis (whether a resource class with this name existed or not)
        -tweak 'resource_class[urgent].LSF=-q yesteryear'       # update or create a new resource description

    If multiple "tweaks" are requested, they will be performed in the given order.

Brandon Walts's avatar
Brandon Walts committed
130 131 132 133 134 135 136 137
B<--DELETE>

    Shortcut to delete a parameter

B<--SHOW>

    Shortcut to show a parameter value

138 139
=head1 LICENSE

140
    Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
nwillhoft's avatar
nwillhoft committed
141
    Copyright [2016-2021] EMBL-European Bioinformatics Institute
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

    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.

=head1 CONTACT

    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

=cut