This repository has been archived by the owner on Oct 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathz_batch.pl
135 lines (112 loc) · 3.13 KB
/
z_batch.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
use Getopt::Long;
use FindBin;
use YAML::Syck;
use Path::Tiny;
use Time::Duration;
use AlignDB::IntSpan;
use AlignDB::Stopwatch;
#----------------------------------------------------------#
# GetOpt section
#----------------------------------------------------------#
=head1 NAME
z_batch.pl - bz.pl, lpcna.pl and amp.pl
=head1 SYNOPSIS
perl z_batch.pl -dt t/S288C -dq t/RM11 -dw . -p 4 -r 1
perl z_batch.pl -dt t/S288C -dq t/RM11 -dw . -p 4 -r 2-4
=cut
GetOptions(
'help|?' => sub { Getopt::Long::HelpMessage(0) },
'dir_target|dt=s' => \my $dir_target,
'dir_query|dq=s' => \my $dir_query,
'dir_working|dw=s' => \( my $dir_working = '.' ),
'parallel|p=i' => \( my $parallel = 1 ),
'run|r=s' => \( my $task = 1 ),
'clean' => \( my $clean ),
) or Getopt::Long::HelpMessage(1);
my @tasks;
{
$task =~ s/\"\'//s;
if ( AlignDB::IntSpan->valid($task) ) {
my $set = AlignDB::IntSpan->new($task);
@tasks = $set->elements;
}
else {
@tasks = grep {/\d/} split /\s/, $task;
}
}
#----------------------------------------------------------#
# init
#----------------------------------------------------------#
my $ldir;
{
my $t_base = path($dir_target)->basename;
$t_base =~ s/\..+?$//;
my $q_base = path($dir_query)->basename;
$q_base =~ s/\..+?$//;
my $tq = "${t_base}vs${q_base}";
$ldir = path( $dir_working, $tq );
$ldir = $ldir->absolute->stringify;
if ( $clean and path($ldir)->exists ) {
path($ldir)->remove_tree;
}
}
#----------------------------------------------------------#
# dispatch table
#----------------------------------------------------------#
my $dispatch = {
1 => "perl $FindBin::Bin/bz.pl"
. " -s set01"
. " -dt $dir_target"
. " -dq $dir_query"
. " -dl $ldir"
. " --parallel $parallel",
2 => "perl $FindBin::Bin/bz.pl"
. " -s set01 --noaxt"
. " -dt $dir_target"
. " -dq $dir_query"
. " -dl $ldir"
. " --parallel $parallel",
3 => "perl $FindBin::Bin/lpcna.pl"
. " -dt $dir_target"
. " -dq $dir_query"
. " -dl $ldir"
. " --parallel $parallel",
4 => "perl $FindBin::Bin/amp.pl" . " -syn"
. " -dt $dir_target"
. " -dq $dir_query"
. " -dl $ldir"
. " --parallel $parallel",
};
#----------------------------#
# Run
#----------------------------#
# use the dispatch template to generate $cmd
for my $step (@tasks) {
my $cmd = $dispatch->{$step};
next unless $cmd;
if ( $step == 1 or $step == 2 ) {
path($ldir)->remove_tree;
path($ldir)->mkpath;
}
my $start_time = time;
print "\n", "=" x 30, "\n";
print "Processing Step $step\n";
exec_cmd($cmd);
print "Finish Step $step\n";
print "Runtime ", duration( time - $start_time ), ".\n";
print "=" x 30, "\n";
}
print "\n";
exit;
sub exec_cmd {
my $cmd = shift;
print "\n", "-" x 12, "CMD", "-" x 15, "\n";
print $cmd , "\n";
print "-" x 30, "\n";
system $cmd;
}
__END__