forked from Molmed/sisyphus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aeacus-stats.pl
executable file
·180 lines (137 loc) · 4.58 KB
/
aeacus-stats.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/perl -w
use FindBin; # Find the script location
use lib "$FindBin::Bin/lib";# Add the script libdir to libs
use Molmed::Sisyphus::Libpath;
use strict;
use Getopt::Long;
use Pod::Usage;
use Cwd qw(abs_path cwd);
use File::Basename;
use Molmed::Sisyphus::Uppmax::SlurmJob;
use Molmed::Sisyphus::Common;
=pod
=head1 NAME
aeacus.pl - Post process a runfolder at UPPMAX
=head1 SYNOPSIS
aeacus.pl -help|-man
aeacus.pl -runfolder <runfolder> [-debug]
=head1 OPTIONS
=over 4
=item -h|-help
prints out a brief help text.
=item -m|-man
Opens the manpage.
=item -runfolder
The runfolder to process.
=item -debug
Print debugging information
=back
The rest of the configuration is read from RUNFOLDER/sisyphus.yml. See example included in the sisyphus directory.
=head1 DESCRIPTION
aeacus.pl submits postprocessing batchjobs to the cluster at UPPMAX. Which jobs to submit is
determined from the sisyphus.yml configuration file.
aeacus.pl is normally started remotely as the last step performed by sisyphus.pl
The postprocessing includes the following steps:
=over 4
=item Fastq statistics collection
=back
=cut
my $rfPath = undef;
our $debug = 0;
my ($help,$man) = (0,0);
umask(007);
GetOptions('help|?'=>\$help,
'man'=>\$man,
'runfolder=s' => \$rfPath,
'debug' => \$debug,
) or pod2usage(-verbose => 0);
pod2usage(-verbose => 1) if ($help);
pod2usage(-verbose => 2) if ($man);
unless(defined $rfPath && -e $rfPath){
print STDERR "Runfolder not specified or does not exist\n";
pod2usage(-verbose => 1);
exit;
}
# Pass debug to scripts with this flag
my $debugFlag='';
if($debug){
$debugFlag = '-debug';
}
my $sisyphus = Molmed::Sisyphus::Common->new(PATH=>$rfPath, DEBUG=>$debug);
$rfPath = $sisyphus->PATH;
my $rfName = basename($rfPath);
my $rfRoot = dirname($rfPath);
my $sampleSheet = $sisyphus->readSampleSheet();
my $excludedTiles = $sisyphus->excludedTiles();
# Set short name for use in jobnames
my $rfShort = join('-', @{[split(/_/, $rfName)]}[0,3]);
# Set some defaults
my $uProj = 'a2009002';
my $uQos = undef;
my $aPath = "/proj/$uProj";
my $oPath = "/proj/$uProj/private/nobackup/OUTBOX";
my $scriptDir = "$rfPath/slurmscripts";
my $skipLanes = [];
my $email = undef;
# Read the sisyphus configuration and override the defaults
my $config = $sisyphus->readConfig();
if(defined $config->{UPPNEX_PROJECT}){
$uProj = $config->{UPPNEX_PROJECT};
}
if(defined $config->{UPPNEX_QOS}){
$uQos = $config->{UPPNEX_QOS};
}
if(defined $config->{OUTBOX_PATH}){
$oPath = $config->{OUTBOX_PATH};
}
if(defined $config->{ARCHIVE_PATH}){
$aPath = $config->{ARCHIVE_PATH};
}
if(defined $config->{SKIP_LANES}){
$skipLanes = $config->{SKIP_LANES};
}
if(defined $config->{MAIL}){
$email = $config->{MAIL};
}
# Strip trailing slashes from paths
$oPath =~ s:/*$::;
$aPath =~ s:/*$::;
# Fastq statistics
# One per lane
my %ffJobs;
my $numLanes = $sisyphus->laneCount();
unless(-e $scriptDir){
$sisyphus->mkpath($scriptDir) or die "Failed to create scriptdir '$scriptDir': $!";
}
open(my $jidFh, '>', "$rfPath/slurmscripts/ffJobs") or die $!;
for(my $i=1; $i<=$numLanes; $i++){
# Create a slurm job handler
my $ffJob =
Molmed::Sisyphus::Uppmax::SlurmJob->new(
DEBUG=>$debug, # bool
SCRIPTDIR=>$scriptDir, # Directory for writing the script
EXECDIR=>$rfPath, # Directory from which to run the script
NAME=>"FF_$i-$rfShort",# Name of job, also used in script name
PROJECT=>$uProj, # project for resource allocation
TIME=>"1-00:00:00", # Maximum runtime, formatted as d-hh:mm:ss
QOS=>$uQos, # High priority
PARTITION=>'core', # core or node (or devel));
MAIL_USER=>$email,
MAIL_TYPE=>'FAIL'
);
$ffJob->addCommand("$FindBin::Bin/fastqStats.pl -runfolder $rfPath -lane $i $debugFlag", "fastqStats.pl on lane $i FAILED");
$ffJobs{$i} = $ffJob;
print STDERR "Submitting FF_$i-$rfShort\t";
$ffJob->submit();
print STDERR $ffJob->jobId(), "\n";
print $jidFh "$i\t" . $ffJob->jobId() . "\n";
# Make sure to get the script md5 into the sisyphus cache,
# otherwise any old checksum from a failed run might fail the
# archiving
my $scriptFile = $ffJob->scriptFile();
print STDERR "$scriptFile\n";
$sisyphus->saveMd5($scriptFile, $sisyphus->getMd5($scriptFile, -noCache=>1));
}
close($jidFh);
$sisyphus->saveMd5("$rfPath/slurmscripts/ffJobs", $sisyphus->getMd5("$rfPath/slurmscripts/ffJobs", -noCache=>1));
print STDERR "fastqStats started\n";