Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Satoru KUMA
MPEG129-m52280
Commits
5ee70f9b
Commit
5ee70f9b
authored
May 30, 2018
by
David Flynn
Browse files
cfg: add support for batch job configuration
parent
91ffc4a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/gen-cfg.pl
View file @
5ee70f9b
...
@@ -2,8 +2,10 @@
...
@@ -2,8 +2,10 @@
use
Digest::
MD5
;
use
Digest::
MD5
;
use
File::
Path
qw(make_path)
;
use
File::
Path
qw(make_path)
;
use
File::
Basename
qw(basename)
;
use
Getopt::
Long
;
use
Getopt::
Long
;
use
List::
MoreUtils
;
use
List::
MoreUtils
;
use
Module::Load::
Conditional
qw(can_load)
;
use
Pod::
Usage
;
use
Pod::
Usage
;
use
YAML
;
use
YAML
;
use
strict
;
use
strict
;
...
@@ -41,6 +43,15 @@ to effectively remove a sequence from being used in an experiment.
...
@@ -41,6 +43,15 @@ to effectively remove a sequence from being used in an experiment.
It may be useful to disable this option when generating config files when
It may be useful to disable this option when generating config files when
the source location of the input data is not known.
the source location of the input data is not known.
=item B<--batch-template>=script.tt
Generate a script from the template script.tt. The output is written to
the current working directory.
=item B<--experiment-name>=name
A generic name that may be referenced by a batch template for any purpose.
=back
=back
=head1 Config specification files
=head1 Config specification files
...
@@ -55,12 +66,16 @@ the source location of the input data is not known.
...
@@ -55,12 +66,16 @@ the source location of the input data is not known.
my
$do_help
=
'';
my
$do_help
=
'';
my
$output_src_glob_sh
=
0
;
my
$output_src_glob_sh
=
0
;
my
$skip_sequences_without_src
=
1
;
my
$skip_sequences_without_src
=
1
;
my
$experiment_name
=
'';
my
$batch_template
=
'';
my
$prefix
=
'
.
';
my
$prefix
=
'
.
';
GetOptions
(
GetOptions
(
'
help
'
=>
\
$do_help
,
'
help
'
=>
\
$do_help
,
'
prefix=s
'
=>
\
$prefix
,
'
prefix=s
'
=>
\
$prefix
,
'
output-src-glob-sh!
'
=>
\
$output_src_glob_sh
,
'
output-src-glob-sh!
'
=>
\
$output_src_glob_sh
,
'
skip-sequences-without-src!
'
=>
\
$skip_sequences_without_src
,
'
skip-sequences-without-src!
'
=>
\
$skip_sequences_without_src
,
'
batch-template=s
'
=>
\
$batch_template
,
'
experiment-name=s
'
=>
\
$experiment_name
,
);
);
##
##
...
@@ -117,6 +132,27 @@ foreach my $cat_name (sort keys %{$cfg->{categories}}) {
...
@@ -117,6 +132,27 @@ foreach my $cat_name (sort keys %{$cfg->{categories}}) {
}
}
}
}
##
# write out batch-job configuration
#
if
(
$batch_template
)
{
can_load
(
modules
=>
{'
Template
'
=>
undef
})
||
die
$
Module::Load::Conditional::
ERROR
;
my
$output
=
basename
(
$batch_template
,'
.tt
');
my
$vars
=
{
jobs
=>
\
@jobs
,
experiment_name
=>
$experiment_name
,
};
my
$tt
=
Template
->
new
({
RELATIVE
=>
1
,
# allow relative paths as $batch_template
ABSOLUTE
=>
1
,
# allow absolute paths too
})
||
die
"
$Template
::ERROR
\n
";
$tt
->
process
(
$batch_template
,
$vars
,
$output
)
||
die
$tt
->
error
(),
"
\n
";
}
sub
genSeqVariants
{
sub
genSeqVariants
{
my
(
$cat
,
$cat_name
,
$cat_seq
,
$seq_name
,
$gop
,
$seq
)
=
@_
;
my
(
$cat
,
$cat_name
,
$cat_seq
,
$seq_name
,
$gop
,
$seq
)
=
@_
;
...
@@ -250,7 +286,7 @@ sub merge {
...
@@ -250,7 +286,7 @@ sub merge {
##
##
# overwrite existing scalar
# overwrite existing scalar
unless
(
ref
$src
)
{
unless
(
ref
$src
)
{
$$dst
=
$
$src
;
$$dst
=
$src
;
return
;
return
;
}
}
...
@@ -297,6 +333,7 @@ sub variants_from_node {
...
@@ -297,6 +333,7 @@ sub variants_from_node {
grep
{
ref
$_
eq
'
HASH
'}
grep
{
ref
$_
eq
'
HASH
'}
map
{
values
%
$_
}
map
{
values
%
$_
}
grep
{
ref
$_
eq
'
HASH
'}
grep
{
ref
$_
eq
'
HASH
'}
map
{
ref
$_
eq
'
ARRAY
'
?
@
$_
:
$_
}
@
{
$node
};
@
{
$node
};
}
}
...
@@ -407,7 +444,7 @@ sub write_cfg {
...
@@ -407,7 +444,7 @@ sub write_cfg {
# format config in memory
# format config in memory
my
$new_cfg
=
"";
my
$new_cfg
=
"";
open
my
$fd
,
"
>
",
\
$new_cfg
;
open
my
$fd
,
"
>
:encoding(utf8)
",
\
$new_cfg
;
print_cfg
(
$fd
,
$flags
);
print_cfg
(
$fd
,
$flags
);
close
$fd
;
close
$fd
;
...
@@ -417,14 +454,14 @@ sub write_cfg {
...
@@ -417,14 +454,14 @@ sub write_cfg {
my
$md5_old
=
Digest::
MD5
->
new
;
my
$md5_old
=
Digest::
MD5
->
new
;
if
(
-
f
$filename
)
{
if
(
-
f
$filename
)
{
open
$fd
,
"
<
",
$filename
;
open
$fd
,
"
<
:encoding(utf8)
",
$filename
;
$md5_old
->
addfile
(
$fd
);
$md5_old
->
addfile
(
$fd
);
close
$fd
;
close
$fd
;
}
}
if
(
$md5_new
->
digest
ne
$md5_old
->
digest
)
{
if
(
$md5_new
->
digest
ne
$md5_old
->
digest
)
{
print
"
writing
$filename
\n
";
print
"
writing
$filename
\n
";
open
$fd
,
"
>
",
$filename
;
open
$fd
,
"
>
:bytes
",
$filename
;
print
$fd
$new_cfg
;
print
$fd
$new_cfg
;
close
$fd
;
close
$fd
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment