Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Chouaref
Snakemake_ATAC_2020
Commits
c7001b9f
Commit
c7001b9f
authored
Nov 13, 2020
by
WJH58
Browse files
add scripts necessary for shark
parent
3f384cd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
ATAC-seq_pipeline/slurm-cluster-status.py
0 → 100755
View file @
c7001b9f
#!/usr/bin/env python3
import
argparse
import
subprocess
import
time
STATE_MAP
=
{
"BOOT_FAIL"
:
"failed"
,
"CANCELLED"
:
"failed"
,
"COMPLETED"
:
"success"
,
"CONFIGURING"
:
"running"
,
"COMPLETING"
:
"running"
,
"DEADLINE"
:
"failed"
,
"FAILED"
:
"failed"
,
"NODE_FAIL"
:
"failed"
,
"OUT_OF_MEMORY"
:
"failed"
,
"PENDING"
:
"running"
,
"PREEMPTED"
:
"failed"
,
"RUNNING"
:
"running"
,
"RESIZING"
:
"running"
,
"SUSPENDED"
:
"running"
,
"TIMEOUT"
:
"failed"
}
def
fetch_status
(
batch_id
,
attempts
:
int
=
3
,
wait_time_seconds
:
float
=
3
):
"""fetch the status for the batch id"""
sacct_args
=
[
"sacct"
,
"-j"
,
batch_id
,
"-o"
,
"State"
,
"--parsable2"
,
"--noheader"
]
for
_
in
range
(
attempts
):
output
=
subprocess
.
check_output
(
sacct_args
).
decode
(
"utf-8"
).
strip
()
if
output
:
break
time
.
sleep
(
wait_time_seconds
)
else
:
raise
TimeoutError
(
f
"Failed to get state for job id:
{
batch_id
}
."
)
# The first output is the state of the overall job
# See
# https://stackoverflow.com/questions/52447602/slurm-sacct-shows-batch-and-extern-job-names
# for details
job_status
=
output
.
split
(
"
\n
"
)[
0
]
# If the job was cancelled manually, it will say by who, e.g "CANCELLED by 12345"
# We only care that it was cancelled
if
job_status
.
startswith
(
"CANCELLED by"
):
return
"CANCELLED"
# Otherwise, return the status
try
:
return
STATE_MAP
[
job_status
]
except
KeyError
:
raise
NotImplementedError
(
f
"Encountered unknown status
{
job_status
}
"
f
"when parsing output:
\n
{
output
}
"
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"batch_id"
,
type
=
str
)
args
=
parser
.
parse_args
()
status
=
fetch_status
(
args
.
batch_id
)
print
(
status
)
ATAC-seq_pipeline/slurm_minisnakemake.sh
0 → 100644
View file @
c7001b9f
#! /bin/bash
#SBATCH --job-name=mini_snakemake
#SBATCH --mail-type=ALL
#SBATCH --mail-user j.chouaref@lumc.nl
#SBATCH -t 48:00:00
#SBATCH --mem=60000
echo
Start
time
:
`
date
`
snakemake
-p
\
--snakefile
Snakefile
\
--latency-wait
60
\
--wait-for-files
\
--rerun-incomplete
\
--use-conda
\
--cluster
"sbatch --parsable --partition=all --mem=60g --ntasks=1 --cpus-per-task=8 --time=60:00:00 --hint=multithread"
\
--cluster-status
"./slurm-cluster-status.py"
\
--jobs
30
echo
End
time
:
`
date
`
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment