Debian Codegraph @

hmmer/profmark/pmark-master.pl

raw
1 #! /usr/bin/perl -w
2
3 # The top level script that runs a pmark benchmark.
4 #
5 # Usage:
6 # ./pmark-master.pl <top_builddir> <top_srcdir> <resultdir> <nproc> <benchmark prefix> <benchmark script>
7 #
8 # <top_builddir>: Top level directory for finding executables to
9 # be benchmarked. This is passed on to the <benchmark script>
10 # without modification. How the script uses it will depend
11 # on where the executables are expected to be found, relative
12 # to this top level directory. For example, for HMMER3 benchmarks,
13 # we might pass ~/releases/hmmer-release/build-icc or
14 # ~/releases/hmmer-3.0xx/build-icc for testing a release candidate
15 # or an existing release.
16 #
17 # <top_srcdir>: Top level directory for finding scripts or data files.
18 # This too will simply be passed on to the <benchmark script>
19 # without modification. For example, for HMMER benchmarks, we
20 # might pass ~/releases/hmmer-release/ or ~/releases/hmmer-3.0xx.
21 # For installed packages like BLAST, it's likely that <top_srcdir>
22 # would be the same as <top_builddir>, because we will not have
23 # multiple build directories.
24 #
25 # <resultdir>: A directory for holding all <nproc> temporary files
26 # created by the benchmark. This name should be short and unique;
27 # it will also be used to construct job names on the cluster, as
28 # <resultdir.$i>.
29 #
30 # <nproc>: how many processes to parallelize over in our cluster.
31 #
32 # <benchmark prefix>: The script will look for files <prefix>.tbl,
33 # <prefix>.msa, and <prefix>.fa, defining a PMARK benchmark set.
34 #
35 # <benchmark script>: This script is executed on each of <nproc>
36 # processes, on an appropriately constructed subset of the
37 # benchmark queries.
38 #
39 # It must take the following arguments:
40 # <top_builddir> <top_srcdir> <resultdir> <tblfile> <msafile> <fafile> <outfile>
41 #
42 # Examples of HMMER3 benchmark:
43 # ./pmark-master.pl ~/releases/hmmer-release/build-icc ~/releases/hmmer-release h3-results 100 pmark ./pmark-h3
44 # ./pmark-master.pl ~/releases/hmmer-release/build-icc ~/releases/hmmer-release h2-results-ls 100 pmark ./pmark-h2-ls
45 # ./pmark-master.pl ~/releases/hmmer-release/build-icc ~/releases/hmmer-release h2-results-fs 100 pmark ./pmark-h2-fs
46 #
47
48 $top_builddir = shift;
49 $top_srcdir = shift;
50 $resultdir = shift;
51 $ncpu = shift;
52 $benchmark_pfx = shift;
53 $pmark_script = shift;
54
55 $tbl = "$benchmark_pfx.tbl";
56 $msafile = "$benchmark_pfx.msa";
57 $fafile = "$benchmark_pfx.fa";
58
59 if (-e $resultdir) { die("$resultdir exists");}
60 system("mkdir $resultdir");
61
62 # Suck in the master table
63 open(BENCHMARK_TBL, $tbl) || die;
64 $n = 0;
65 $pid = 0;
66 $nseq = 0;
67 while (<BENCHMARK_TBL>)
68 {
69 ($msaname[$n], $pid, $L, $nseq) = split;
70 $alen{$msaname[$n]} = $L;
71 $n++;
72 }
73 close BENCHMARK_TBL;
74
75 # Sort it by alen - this helps load balance.
76 sub by_alen { $alen{$b} <=> $alen{$a} }
77 @sorted_msaname = sort by_alen @msaname;
78
79 # Create <ncpu> subtables.
80 for ($i = 0; $i < $n; $i++)
81 {
82 $subtbl[$i % $ncpu] .= $sorted_msaname[$i];
83 $subtbl[$i % $ncpu] .= "\n";
84 }
85
86 # Output the <ncpu> subtables
87 for ($i = 0; $i < $ncpu; $i++)
88 {
89 open(SUBTBL, ">$resultdir/tbl.$i") || die ("Failed to create $resultdir/tbl.$i");
90 print SUBTBL $subtbl[$i];
91 close SUBTBL;
92 }
93
94 # Write a slurm array script
95 #
96 open(SLURMSCRIPT, ">$resultdir.sh") || die("failed to create slurm script");
97 print SLURMSCRIPT <<EOF;
98 #!/bin/bash
99 #SBATCH -t 6-00:00
100 #SBATCH --mem 4000
101 #SBATCH -p eddy
102 #SBATCH -c 1
103 #SBATCH -N 1
104 #SBATCH -o $resultdir/tbl.%a.slurm
105 $pmark_script $top_builddir $top_srcdir $resultdir $resultdir/tbl.\${SLURM_ARRAY_TASK_ID} $msafile $fafile $resultdir/tbl.\${SLURM_ARRAY_TASK_ID}.out
106 EOF
107
108
109 # Submit the job array
110 $maxi = $ncpu-1;
111 system("sbatch --array=0-$maxi $resultdir.sh");
112
113