Skip to content

Commit

Permalink
Added support for restarting jobs (#129)
Browse files Browse the repository at this point in the history
charles-cowart authored Feb 26, 2024

Verified

This commit was signed with the committer’s verified signature.
evenyag Yingwen
1 parent 00ef0aa commit cbca685
Showing 3 changed files with 66 additions and 0 deletions.
36 changes: 36 additions & 0 deletions sequence_processing_pipeline/ConvertJob.py
Original file line number Diff line number Diff line change
@@ -174,3 +174,39 @@ def parse_logs(self):
msgs.append(line)

return msgs

@staticmethod
def parse_job_script(job_script_path):
# Returns run-directory and sample-sheet path from a job-script.

if not exists(job_script_path):
raise ValueError(f"'{job_script_path}' is not a valid path")

with open(job_script_path, 'r') as f:
lines = f.readlines()
lines = [x.strip() for x in lines]

# As this code creates this file, we can expect it to be of a certain
# format.
if lines[0] != '#!/bin/bash':
raise ValueError(f"'{job_script_path}' is not a valid path")

result = {}

m = re.match('^cd (.*)$', lines[12])

if m:
result['run_directory'] = m.group(1)
else:
raise ValueError("could not detect run_directory in "
f"'{job_script_path}'")

m = re.match('^bcl-convert --sample-sheet "(.*?)" ', lines[14])

if m:
result['sample_sheet_path'] = m.group(1)
else:
raise ValueError("could not detect sample-sheet path in "
f"'{job_script_path}'")

return result
15 changes: 15 additions & 0 deletions sequence_processing_pipeline/tests/data/sample-convertjob.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#SBATCH --job-name 3f6b1fe3-1f5d-4fec-af47-31a2e35fef91_ConvertJob
#SBATCH -p qiita
#SBATCH -N 1
#SBATCH -n 16
#SBATCH --time 180
#SBATCH --mail-type=ALL
#SBATCH --mail-user [email protected]
#SBATCH --mem-per-cpu 12gb
set -x
date
hostname
cd /sequencing/igm_runs/210820_A00953_0380_BHJ53TDSX2
module load bclconvert_3.7.5
bcl-convert --sample-sheet "/qmounts/qiita_data/working_dir/3f6b1fe3-1f5d-4fec-af47-31a2e35fef91/2024-02-08_U19_Wisconsin_15445_reruns_NovaSeq_nonNA.csv" --output-directory /qmounts/qiita_data/working_dir/3f6b1fe3-1f5d-4fec-af47-31a2e35fef91/ConvertJob --bcl-input-directory . --bcl-num-decompression-threads 16 --bcl-num-conversion-threads 16 --bcl-num-compression-threads 16 --bcl-num-parallel-tiles 16 --bcl-sampleproject-subdirectories true --force
15 changes: 15 additions & 0 deletions sequence_processing_pipeline/tests/test_ConvertJob.py
Original file line number Diff line number Diff line change
@@ -980,6 +980,21 @@ def test_audit(self):
obs = job.audit(self.sample_ids + ['not-a-sample', 'BLANK1'])
self.assertListEqual(obs, ['BLANK1', 'not-a-sample'])

def test_parse_sample_sheet(self):
js_path = self.base_path('sample-convertjob.sh')
obs = ConvertJob.parse_job_script(js_path)

exp = {
'run_directory': ('/sequencing/igm_runs/210820_A00953_0380_'
'BHJ53TDSX2'),
'sample_sheet_path': ('/qmounts/qiita_data/working_dir/'
'3f6b1fe3-1f5d-4fec-af47-31a2e35fef91/'
'2024-02-08_U19_Wisconsin_15445_reruns'
'_NovaSeq_nonNA.csv')
}

self.assertDictEqual(obs, exp)


SCRIPT_EXP = ''.join([
'#!/bin/bash\n',

0 comments on commit cbca685

Please sign in to comment.