-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbagel4_conf_2_json.pl
executable file
·63 lines (44 loc) · 1.56 KB
/
bagel4_conf_2_json.pl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env perl
# Convert the bagel4.conf to json
# depends on MOODS
use strict ;
use warnings ;
use lib "/data/bagel4/lib" ;
use bagel4_functions ;
use lib "/data/molgentools/lib";
use anne_files ;
use anne_misc ;
use File::Basename;
# ---------------------------------------------------------- parameters -------------------------------------------------------------------------
my $sessiondir = '.';
my $program_dir = dirname($0) ;
my $fna_file ;
my $outfile = 'promoterscan.table' ;
my $usage = "option:
-s sessiondir [default=$sessiondir]
Conver the bagel4.conf to bagel4.conf.json
e.g. /data/bagel4/bagel4_conf_2_json.pl -s /tmp/BAGEL4WRAPPER/test
" ;
my %conf = bagel4_functions::read_conf("$program_dir/bagel4.conf") ;
&parseparam() ;
# ---------------------------------------------------------- main -------------------------------------------------------------------------
my @fields ;
foreach my $key (keys %conf) {
my $c = '"';
if (anne_misc::is_numeric($conf{$key})) { $c = ''; }
push @fields, "\t\"$key\": $c$conf{$key}$c";
}
my @json = '{"bagel4_conf": {';
push @json, join ",\n", @fields ;
push @json, "}}";
anne_files::write_lines("$sessiondir/bagel4.conf.json",@json);
# ---------------------------------------------------------- functions -------------------------------------------------------------------------
sub parseparam {
my $var ;
my @arg = @ARGV ;
while(@arg) {
$var = shift(@arg) ;
die $usage if ($var eq '-h' or $var eq '--help') ;
$sessiondir = shift(@arg) if($var eq '-s') ;
}
}