blib/lib/NBI/Test.pl untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 26 CC 4 SCAR 30.0
CC
4
Cov
0%
execute_slurm
20.0
CRAP 20.0
1  
2 sub execute_slurm {
3 my ($name, $command, $threads, $memory) = shift;
4  
5 $command =~ s/\"/\\\"/g;
6 my $slurm_cmd = qq(sbatch --job-name=$name --nodes=1 --ntasks-per-node=$threads --mem=${memory}GB --wrap="$command");
7 my $output = `$slurm_cmd`;
8
9 if ($? == -1) {
10 print STDERR "ERROR executing $command:\nFailed to execute command: $!";
11 return undef;
12 } elsif ($? & 127) {
13 print STDERR "ERROR executing $command:\nCommand died with signal " . ($? & 127);
14 } else {
15 my $exit_code = $? >> 8;
16 print "Command exited with code $exit_code\n";
17 print "Output:\n$output\n";
18 return undef;
19 }
20 # Return JOBID if successful
21 if ($output =~ /Submitted batch job (\d+)/i) {
22 return $1;
23 } else {
24 return undef;
25 }
26 }
27  
28 for my $file (@list_of_files) {
29 my $command = qq(annotate -i $file -o $outdir -t $threads);
30 my $job_id = execute_slurm('annotate', $command, $threads, $memory_gb);
31 }