-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_parser.py
More file actions
66 lines (60 loc) · 1.44 KB
/
Copy pathcli_parser.py
File metadata and controls
66 lines (60 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from argparse import ArgumentParser
from pathlib import Path
import subprocess
DESCRIPTION = (
"A command-line interface for running Snakemake workflows that generate "
"tetranucleotide and trinucleotide frequency profiles, codon usage statistics, "
"and RSCU plots."
)
parser = ArgumentParser(description=DESCRIPTION)
parser.add_argument(
"reads",
type=Path,
nargs="+",
help="input FASTQ files (max 2)",
)
parser.add_argument(
"-r",
"--references",
type=Path,
nargs="+",
required=True,
help="reference FASTA files",
)
parser.add_argument(
"-w",
"--workdir",
type=Path,
default=Path("."),
help="output directory for workflow files (default: current directory)",
)
parser.add_argument(
"-t",
"--threads",
type=int,
default=1,
help="number of threads to use (default: 1)",
)
args = parser.parse_args()
if len(args.reads) > 2:
parser.error("You can provide at most 2 FASTQ files.")
config = {
"reads": [str(f.resolve()) for f in args.reads],
"references": [str(f.resolve()) for f in args.references],
"scripts_dir": str(Path("scripts").resolve()),
}
command = [
"snakemake",
"-s",
"Workflow.smk",
"--directory",
str(args.workdir.resolve()),
"-c",
str(args.threads),
"--config",
f"config={config}",
]
try:
subprocess.run(command)
except subprocess.CalledProcessError as e:
print("Snakemake failed with error:", e.stderr)