line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HPC::Runner::GnuParallel; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
22559
|
use DateTime; |
|
1
|
|
|
|
|
127909
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
977
|
use DateTime::Format::Duration; |
|
1
|
|
|
|
|
6097
|
|
|
1
|
|
|
|
|
47
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
920
|
use Moose; |
|
1
|
|
|
|
|
469156
|
|
|
1
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
#extends 'HPC::Runner'; |
12
|
|
|
|
|
|
|
#extends 'HPC::Runner::MCE'; |
13
|
|
|
|
|
|
|
extends qw(HPC::Runner HPC::Runner::MCE); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#with 'MooseX::Getopt'; |
16
|
|
|
|
|
|
|
with 'MooseX::Getopt::Usage'; |
17
|
|
|
|
|
|
|
with 'MooseX::Getopt::Usage::Role::Man'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=encoding utf-8 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
HPC::Runner::GnuParallel - Run arbitrary bash commands using GNU parallel. Can be used on its own or as a part of HPC::Runner::Slurm. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Main; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Moose; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
extends 'HPC::Runner::GnuParallel'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Main->new_with_options()->go; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Run straight as : |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
cat stuff.cmd | parallelparser.pl | parallel --joblog `pwd`/runtasks.log --gnu -N 1 -q gnuparallelrunner.pl --command `echo {}` --outdir `pwd`/gnulogs/ --seq {#} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Where stuff.cmd is a file with the commands you need run. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Or as a part or HPC::Runner::Slurm distro. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
HPC::Runner::GnuParallel is a part of a suite of tools to make HPC easy. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 Attributes |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 using_gnuparallel |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Indicate whether or not to use gnu parallel |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'using_gnuparallel' => ( |
60
|
|
|
|
|
|
|
is => 'rw', |
61
|
|
|
|
|
|
|
isa => 'Bool', |
62
|
|
|
|
|
|
|
default => 1, |
63
|
|
|
|
|
|
|
required => 0, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 infile |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
disable infile and read directly from the stream |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has '+infile' => ( |
73
|
|
|
|
|
|
|
required => 0, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has 'command' => ( |
77
|
|
|
|
|
|
|
required => 1, |
78
|
|
|
|
|
|
|
isa => 'Str', |
79
|
|
|
|
|
|
|
is => 'rw', |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has 'seq' => ( |
84
|
|
|
|
|
|
|
is => 'rw', |
85
|
|
|
|
|
|
|
isa => 'Int', |
86
|
|
|
|
|
|
|
default => 1, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 go |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Initialize MCE things and use HPC::Runner to parse and exec commands |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub go{ |
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $dt1 = DateTime->now(); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->logname('gnuparallel'); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->prepend_logfile("MAIN_"); |
103
|
0
|
|
|
|
|
|
$self->log($self->init_log); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$self->parse_file_gnuparallel; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$DB::single=2; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $dt2 = DateTime->now(); |
110
|
0
|
|
|
|
|
|
my $duration = $dt2 - $dt1; |
111
|
0
|
|
|
|
|
|
my $format = DateTime::Format::Duration->new( |
112
|
|
|
|
|
|
|
pattern => '%Y years, %m months, %e days, %H hours, %M minutes, %S seconds' |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->log->info("Total execution time ".$format->format_duration($duration)); |
116
|
0
|
|
|
|
|
|
return; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 parse_file_gnuparallel |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Parse the file of commands and send each command off to the queue. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub parse_file_gnuparallel{ |
126
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$self->cmd($self->command); |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
$DB::single=2; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$self->counter($self->seq); |
133
|
0
|
|
|
|
|
|
$self->run_command_mce; |
134
|
0
|
|
|
|
|
|
$self->clear_cmd; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 Acknowledgements |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Before version 0.05 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This module was originally developed at and for Weill Cornell Medical |
148
|
|
|
|
|
|
|
College in Qatar within ITS Advanced Computing Team. With approval from |
149
|
|
|
|
|
|
|
WCMC-Q, this information was generalized and put on github, for which |
150
|
|
|
|
|
|
|
the authors would like to express their gratitude. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
As of version 0.05: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This modules continuing development is supported by NYU Abu Dhabi in the Center for Genomics and Systems Biology. |
155
|
|
|
|
|
|
|
With approval from NYUAD, this information was generalized and put on bitbucket, for which |
156
|
|
|
|
|
|
|
the authors would like to express their gratitude. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Jillian Rowe E<lt>jillian.e.rowe@gmail.comE<gt> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2015- Weill Cornell Medical College in Qatar |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
169
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |