|
6 | 6 | # The full license is in the file LICENSE, distributed with this software. |
7 | 7 | # ----------------------------------------------------------------------------- |
8 | 8 |
|
9 | | -from unittest import main |
10 | | -from qiita_client import ArtifactInfo |
11 | | -from qiita_client.testing import PluginTestCase |
| 9 | +from json import dumps |
12 | 10 | from os import remove |
13 | 11 | from os.path import exists, isdir, join |
| 12 | +from shutil import copyfile, rmtree |
14 | 13 | from tempfile import mkdtemp |
15 | | -from shutil import rmtree, copyfile |
16 | | -from json import dumps |
| 14 | +from unittest import main |
| 15 | + |
| 16 | +from qiita_client import ArtifactInfo |
| 17 | +from qiita_client.testing import PluginTestCase |
17 | 18 |
|
18 | 19 | from qp_pacbio import plugin |
19 | 20 | from qp_pacbio.qp_pacbio import pacbio_processing |
20 | 21 |
|
| 22 | +# Keep these in sync with your generator defaults |
| 23 | +CONDA_ENV = "qp_pacbio_2025.9" |
| 24 | +STEP1_NPROCS = 16 |
| 25 | +STEP1_WALL = 1000 |
| 26 | +STEP1_MEM_GB = 300 # generator uses 300G for step-1 |
| 27 | +NODE_COUNT = 1 |
| 28 | +PARTITION = "qiita" |
21 | 29 |
|
| 30 | +# Exact expected Step-1 script matching your template. |
| 31 | +# Escape ${...} -> ${{...}} and awk braces -> '{{print $1}}' etc. |
22 | 32 | STEP_1_EXP = ( |
23 | 33 | "#!/bin/bash\n" |
24 | | - "#SBATCH -J s1-my-job-id\n" |
25 | | - "#SBATCH -N 1\n" |
26 | | - "#SBATCH -n 32\n" |
27 | | - "#SBATCH --time 1000\n" |
28 | | - "#SBATCH --mem 300G\n" |
29 | | - "#SBATCH -o {out_dir}/step-1/logs/%x-%A.out\n" |
30 | | - "#SBATCH -e {out_dir}/step-1/logs/%x-%A.err\n" |
31 | | - "#SBATCH --array 1:2%16\n" |
32 | | - "\n" |
33 | | - "conda activate qp_pacbio_2025.9\n" |
| 34 | + "#SBATCH -J s1-{job_id}\n" |
| 35 | + f"#SBATCH -p {PARTITION}\n" |
| 36 | + f"#SBATCH -N {NODE_COUNT}\n" |
| 37 | + f"#SBATCH -n {STEP1_NPROCS}\n" |
| 38 | + f"#SBATCH --time {STEP1_WALL}\n" |
| 39 | + f"#SBATCH --mem {STEP1_MEM_GB}G\n" |
| 40 | + "#SBATCH -o {out_dir}/step-1/logs/%x-%A_%a.out\n" |
| 41 | + "#SBATCH -e {out_dir}/step-1/logs/%x-%A_%a.out\n" |
| 42 | + "#SBATCH --array 1-{njobs}%16\n" |
| 43 | + "source ~/.bashrc\n" |
| 44 | + f"conda activate {CONDA_ENV}\n" |
34 | 45 | "\n" |
35 | 46 | "cd {out_dir}/step-1\n" |
36 | 47 | "step=${{SLURM_ARRAY_TASK_ID}}\n" |
37 | | - "input=$(head -n $step {out_dir}/file_list.txt | tail -n 1)\n" |
38 | | - "fn=`basename ${{input}}`\n" |
39 | | - "hifiasm_meta -t 60 -o {out_dir}/step-1/${{fn}} ${{input}}" |
| 48 | + "input=$(head -n $step {out_dir}/sample_list.txt | tail -n 1)\n" |
| 49 | + "\n" |
| 50 | + "sample_name=`echo $input | awk '{{print $1}}'`\n" |
| 51 | + "filename=`echo $input | awk '{{print $2}}'`\n" |
| 52 | + "\n" |
| 53 | + "fn=`basename ${{filename}}`\n" |
| 54 | + "\n" |
| 55 | + f"hifiasm_meta -t {STEP1_NPROCS} -o " |
| 56 | + "{out_dir}/step-1/${{sample_name}} ${{filename}}" |
40 | 57 | ) |
41 | 58 |
|
42 | 59 |
|
@@ -110,14 +127,18 @@ def test_pacbio_processing(self): |
110 | 127 | with open(f"{out_dir}/sample_list.txt", "r") as f: |
111 | 128 | obs_lines = f.readlines() |
112 | 129 | self.assertEqual(2, len(obs_lines)) |
113 | | - |
| 130 | + njobs = len(obs_lines) |
114 | 131 | # testing step-1 |
115 | 132 | with open(f"{out_dir}/step-1/step-1.slurm", "r") as f: |
116 | 133 | # removing \n |
117 | 134 | obs_lines = [ln.replace("\n", "") for ln in f.readlines()] |
118 | 135 |
|
119 | 136 | self.assertCountEqual( |
120 | | - STEP_1_EXP.format(out_dir=out_dir).split("\n"), |
| 137 | + STEP_1_EXP.format( |
| 138 | + out_dir=out_dir, |
| 139 | + job_id=job_id, |
| 140 | + njobs=njobs, |
| 141 | + ).split("\n"), |
121 | 142 | obs_lines, |
122 | 143 | ) |
123 | 144 |
|
|
0 commit comments