Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 318 lines (245 sloc) 8.198 kb
93b680c This is a variation of the setup_initial module in which we extract t…
olivier authored
1 #
2 # BioPerl module for Bio::Pipeline::InputCreate::setup_initial
3 #
fe99cd6 adding FEEDBACK:Support section to pod
maj authored
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
93b680c This is a variation of the setup_initial module in which we extract t…
olivier authored
6 # Cared for by Shawn Hoon <shawnh@fugu-sg.org>
7 #
8 #
9 # You may distribute this module under the same terms as perl itself
10 #
11 # POD documentation - main docs before the code
12 #
13
14 =head1 NAME
15
16 Bio::Pipeline::InputCreate::setup_initial
17
18 =head1 SYNOPSIS
19
20 use Bio::Pipeline::InputCreate::setup_inital;
21
22 my $inc = Bio::Pipeline::InputCreate::setup_initial->new('-protein_ioh'=>1,
23 '-dna_ioh'=>2);
24 $inc->run();
25
26
27 =head1 DESCRIPTION
28
29 The setup initial analysis takes in an array of ids and iohandler ids
30 and creates inputs and jobs. Each input to the analysis is an array of
31 input ids. Each array of input ids are associated with a given
32 IOHandler. It has two modes of operation. It may either create one
33 input per job or multiple inputs per job.
34
35 For example in an xml snippet:
36
37 1 <analysis id="1">
38 2 <data_monger>
39 3 <initial/>
40 4 <input>
41 5 <name>gene1</name>
42 6 <iohandler>1</iohandler>
43 7 </input>
44 8 <input>
45 9 <name>gene2</name>
46 10 <iohandler>2</iohandler>
47 11 </input>
48 12 <input_create>
49 13 <module>setup_initial</module>
50 14 <rank>1</rank>
51 15 <argument>
52 16 <tag>group</tag>
53 17 <value>1</value>
54 18 </argument>
55 19 <argument>
56 20 <tag>gene2</tag>
57 21 <value>4</value>
58 22 </argument>
59 23 <argument>
60 24 <tag>gene1</tag>
61 25 <value>3</value>
62 26 </argument>
63 27 </input_create>
64 28 </data_monger>
65 29 <input_iohandler id="1"/>
66 30 <input_iohandler id="2"/>
67 31 </analysis>
68
69 This specifies that there are two inputs (line 4-11) to the
70 InputCreate job that uses the setup_initial module. Each input has its
71 own iohandler which would return an array of input ids (line 6 and
72 line 10). For example in this case gene1 may belong to genes from a
73 human database and gene2 may belong to gene from a fugu database.
74
75 Within the input_create arguments (line 12-27), we next specify how to
76 map the input ids to its corresponding iohandler. In other words,
77 given the gene input ids, how does one fetch the actual gene object?
78 So for this case, input ids from gene1 are fetched using iohandler_id
79 3 (line 25) and input ids from gene2 are fetched using iohandler_id 4
80 (line 21)
81
82 We also specify that the inputs are grouped (line 15-18) meaning that
83 each pair of inputs ids (assuming that the number of input ids are
84 equal for gene1 and gene2) are passed to one job. So what you get:
85
86 gene1_id-> fetched using iohandler id 3 ----> a single job of the next analysis
87 gene2_id-> fetched using iohandler id 4
88
89 If the group argument is not specified, the jobs are created as such:
90
91 gene1_id-> fetched using iohandler id 3 ----> a job of the next analysis
92 gene2_id-> fetched using iohandler id 4 ----> a job of the next analysis
93
94 Currently it is assumed that the inputs are mapped based on object
95 type to the inputs of the runnables.
96
97 =head1 FEEDBACK
98
99 =head2 Mailing Lists
100
101 User feedback is an integral part of the evolution of this and other
102 Bioperl modules. Send your comments and suggestions preferably to one
103 of the Bioperl mailing lists. Your participation is much appreciated.
104
105 bioperl-l@bioperl.org - General discussion
106 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
107
fe99cd6 adding FEEDBACK:Support section to pod
maj authored
108 =head2 Support
109
110 Please direct usage questions or support issues to the mailing list:
111
112 L<bioperl-l@bioperl.org>
113
114 rather than to the module maintainer directly. Many experienced and
115 reponsive experts will be able look at the problem and quickly
116 address it. Please include a thorough description of the problem
117 with code and data examples if at all possible.
118
93b680c This is a variation of the setup_initial module in which we extract t…
olivier authored
119 =head2 Reporting Bugs
120
121 Report bugs to the Bioperl bug tracking system to help us keep track
122 the bugs and their resolution. Bug reports can be submitted via email
123 or the web:
124
125 bioperl-bugs@bio.perl.org
126 http://bugzilla.open-bio.org/
127
128 =head1 AUTHOR - Shawn Hoon
129
130 Email shawnh@fugu-sg.org
131
132 =head1 APPENDIX
133
134 The rest of the documentation details each of the object methods. Internal metho
135 ds are usually preceded with a _
136
137 =cut
138
139 package Bio::Pipeline::InputCreate::setup_initial_seq_region;
140
141 use vars qw(@ISA);
142
143 use strict;
144 use Bio::Pipeline::InputCreate;
145 use Bio::Pipeline::DataType;
146
147 @ISA = qw(Bio::Pipeline::InputCreate);
148
149 sub _initialize {
150 my ($self,@args) = @_;
151 $self->SUPER::_initialize(@args);
152 my ($group,$test) = $self->_rearrange([qw(GROUP TEST)],@args);
153 $self->group($group) if $group;
154 $self->test($test) if $test;
155
156 #from here on, assume all parameters are for iohandler mapping
157 $#args > 0 || $self->throw("Need iohandlers to setup initial jobs");
158 my %ioh = @args;
159
160
161 @ioh{ map { lc $_} keys %ioh} = values %ioh; # lowercase keys
162
163 $self->iohandler_map(\%ioh);
164
165
166 }
167
168 =head2 iohandler_map
169
170 Title : iohandler_map
171 Usage : $self->iohandler_map()
172 Function: get/sets of the iohandler map hash
173 Returns :
174 Args :
175
176 =cut
177
178 sub iohandler_map {
179 my ($self,$arg) = @_;
180 if($arg){
181 $self->{'_iohandler_map'} = $arg;
182 }
183 return $self->{'_iohandler_map'};
184 }
185
186 =head2 test
187
188 Title : test
189 Usage : $self->test()
190 Function: get/set from test argument
191 Returns :
192 Args :
193
194 =cut
195
196 sub test {
197 my ($self,$arg) = @_;
198 if($arg){
199 $self->{'_test'} = $arg;
200 }
201 return $self->{'_test'};
202 }
203
204 =head2 group
205
206 Title : group
207 Usage : $self->group()
208 Function: get/set from group argument
209 Returns :
210 Args :
211
212 =cut
213
214 sub group {
215 my ($self,$arg) = @_;
216 if($arg){
217 $self->{'_group'} = $arg;
218 }
219 return $self->{'_group'};
220 }
221
222 =head2 datatypes
223
224 Title : datatypes
225 Usage : $self->datatypes()
226 Function: get/sets of the datatypes
227 Returns :
228 Args :
229
230 =cut
231
232 sub datatypes {
233 my ($self) = @_;
234 my $dt = Bio::Pipeline::DataType->new('-object_type'=>'',
235 '-name'=>'ids',
236 '-reftype'=>'ARRAY');
237
238 my %dts;
239 $dts{input} = $dt;
240 return %dts;
241 }
242
243 =head2 run
244
245 Title : run
246 Usage : $self->run()
247 Function: run the input create
248 Returns :
249 Args :
250
251 =cut
252
253 sub run {
254 my ($self,$next_anal,$input) = @_;
255
256 (ref($input) eq "HASH") || $self->throw("Expecting a hash reference");
257 my $ioh_map = $self->iohandler_map;
258 if($self->group){
259 $self->_create_by_group($next_anal,$input,$ioh_map);
260 }
261 else {
262 $self->_create_single($next_anal,$input,$ioh_map);
263 }
264 }
265
266 sub _create_single {
267 my ($self,$next_anal,$input,$ioh_map) = @_;
268 my $count = 1;
269 foreach my $key (keys %{$input}){
270 my $ioh = $ioh_map->{$key};
271 if(!$input->{$key}){
272 $self->throw("Iohandler map for $key does not have inputs");
273 }
274 my @input;
275 if(ref $input->{$key} eq "ARRAY"){
276 @input = @{$input->{$key}};
277 }
278 else {
279 push @input, $input->{$key};
280 }
281 foreach my $in(@input){
282 my $in2 = $in->dbID;
283
284 my $input1 = $self->create_input($in2,$ioh);
285
286 my $job = $self->create_job($next_anal,[$input1]);
287
288 $self->dbadaptor->get_JobAdaptor->store($job);
289 if($self->test()){
290 last if ($count == $self->test);
291 }
292 $count++;
293 }
294 }
295 }
296
297 sub _create_by_group {
298 my ($self,$next_anal,$input,$ioh_map) = @_;
299 my ($first_key) = keys %$input;
300 my $count = 1;
301 for my $i(0..scalar(@{$input->{$first_key}})){
302 my @input;
303 foreach my $key(keys %{$input}){
304 my $ioh = $ioh_map->{$key};
305 my $in = $input->{$key}->[$i];
306 push @input,$self->create_input($in,$ioh);
307 }
308 my $job = $self->create_job($next_anal,\@input);
309 $self->dbadaptor->get_JobAdaptor->store($job);
310 if($self->test()){
311 last if ($count == $self->test);
312 }
313 $count++;
314 }
315 }
316
317 1;
Something went wrong with that request. Please try again.