ensembl-hive  2.8.1
align_nonident_regions_wrapper.pl
Go to the documentation of this file.
1 #!/usr/bin/env perl
2 # See the NOTICE file distributed with this work for additional information
3 # regarding copyright ownership.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 =head1 NAME
19 
20 align_nonident_regions_wrapper.pl - lsf wrapper for align_nonident_regions.pl
21 
22 =head1 SYNOPSIS
23 
24 align_nonident_regions_wrapper.pl [arguments]
25 
26 Required arguments:
27 
28  --dbname, db_name=NAME database name NAME
29  --host, --dbhost, --db_host=HOST database host HOST
30  --port, --dbport, --db_port=PORT database port PORT
31  --user, --dbuser, --db_user=USER database username USER
32  --pass, --dbpass, --db_pass=PASS database passwort PASS
33  --assembly=ASSEMBLY assembly version ASSEMBLY
34 
35  --altdbname=NAME alternative database NAME
36  --altassembly=ASSEMBLY alternative assembly version ASSEMBLY
37 
38 Optional arguments:
39 
40  --chromosomes, --chr=LIST only process LIST toplevel seq_regions
41  --bindir=DIR look for program binaries in DIR
42  --tmpfir=DIR use DIR for temporary files (useful for
43  re-runs after failure)
44 
45  --conffile, --conf=FILE read parameters from FILE
46  (default: conf/Conversion.ini)
47 
48  --logfile, --log=FILE log to FILE (default: *STDOUT)
49  --logpath=PATH write logfile to PATH (default: .)
50  --logappend, --log_append append to logfile (default: truncate)
51 
52  -v, --verbose=0|1 verbose logging (default: false)
53  -i, --interactive=0|1 run script interactively (default: true)
54  -n, --dry_run, --dry=0|1 don't write results to database
55  -h, --help, -? print help (this message)
56 
57 =head1 DESCRIPTION
58 
59 This script is a wrapper around align_nonident_regions.pl to run one toplevel seq_region
60 at a time via lsf. See documentation in align_nonident_regions.pl for details.
61 
62 =head1 RELATED FILES
63 
64 The whole process of creating a whole genome alignment between two assemblies
65 is done by a series of scripts. Please see
66 
67  ensembl/misc-scripts/assembly/README
68 
69 for a high-level description of this process, and POD in the individual scripts
70 for the details.
71 
72 
73 =head1 AUTHOR
74 
75 Patrick Meidl <meidl@ebi.ac.uk>, Ensembl core API team
76 
77 =head1 CONTACT
78 
79 Please post comments/questions to the Ensembl development list
80 <http://lists.ensembl.org/mailman/listinfo/dev>
81 
82 =cut
83 
84 use strict;
85 use warnings;
86 no warnings 'uninitialized';
87 
88 use FindBin qw($Bin);
89 use vars qw($SERVERROOT);
90 
91 BEGIN {
92  $SERVERROOT = "$Bin/../../..";
93  unshift(@INC, ".");
94  unshift(@INC, "$SERVERROOT/ensembl/modules");
95  unshift(@INC, "$SERVERROOT/bioperl-live");
96 }
97 
98 use Getopt::Long;
99 use Pod::Usage;
100 use Bio::EnsEMBL::Utils::ConversionSupport;
101 use AssemblyMapper::BlastzAligner;
102 
103 $| = 1;
104 
105 my $support = new Bio::EnsEMBL::Utils::ConversionSupport($SERVERROOT);
106 
107 # parse options
108 $support->parse_common_options(@_);
109 $support->parse_extra_options(
110  'assembly=s',
111  'althost=s',
112  'altport=i',
113  'altuser=s',
114  'altpass=s',
115  'altdbname=s',
116  'altassembly=s',
117  'bindir=s',
118  'tmpdir=s',
119  'chromosomes|chr=s@',
120 );
121 $support->allowed_params(
122  $support->get_common_params,
123  'assembly',
124  'althost',
125  'altport',
126  'altuser',
127  'altpass',
128  'altdbname',
129  'altassembly',
130  'bindir',
131  'tmpdir',
132  'chromosomes',
133 );
134 
135 if ($support->param('help') or $support->error) {
136  warn $support->error if $support->error;
137  pod2usage(1);
138 }
139 
140 $support->comma_to_list('chromosomes');
141 
142 # ask user to confirm parameters to proceed
143 $support->confirm_params;
144 
145 # get log filehandle and print heading and parameters to logfile
146 $support->init_log;
147 
148 $support->check_required_params(
149  'assembly',
150  'altdbname',
151  'altassembly'
152 );
153 
154 #####
155 # connect to database and get adaptors
156 #
157 my $R_dba = $support->get_database('ensembl');
158 
159 # loop over toplevel seq_regions
160 $support->log_stamped("Looping over toplevel seq_regions...\n");
161 
162 foreach my $chr ($support->sort_chromosomes($support->get_chrlength)) {
163 
164  $support->log_stamped("Toplevel seq_region $chr...\n", 1);
165 
166  # run align_nonident_regions.pl via lsf
167  my $options = $support->create_commandline_options({
168  'allowed_params' => 1,
169  'replace' => {
170  logfile => "align_nonident_regions.chr.$chr.log",
171  chromosomes => $chr,
172  interactive => 0,
173  },
174  });
175  $support->log("Running align_nonident_regions.pl via lsf...\n", 2);
176 
177  my $logpath = $support->param('logpath').'/lsf';
178  unless (-d $logpath) {
179  system("mkdir $logpath") == 0 or
180  $support->log_error("Can't create lsf log dir $logpath: $!\n");
181  }
182 
183  my $cmd = qq(bsub -o $logpath/align_nonident_regions.$chr.%J.out -e $logpath/align_nonident_regions.$chr.%J.err ./align_nonident_regions.pl $options
184  );
185 
186  system("$cmd") == 0
187  or $support->log_error("Error running align_nonident_regions.pl: $!i\n");
188 
189  $support->log_stamped("Done.\n", 2);
190 
191  $support->log_stamped("Done with toplevel seq_region $chr.\n", 1);
192 }
193 
194 $support->log_stamped("Done.\n");
195 
196 # finish logfile
197 $support->finish_log;
198 
199 
run
public run()