-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchpycli.sh
More file actions
executable file
·126 lines (101 loc) · 2.16 KB
/
touchpycli.sh
File metadata and controls
executable file
·126 lines (101 loc) · 2.16 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/bash
filename=$1
if [[ $# -eq 0 ]]; then
>&2 echo "Error: no arguments provided"
>&2 echo "USAGE: $(basename $0) [NEW_FILE_NAME]"
exit 1
fi
touch "${filename}.py"
chmod +x "${filename}.py"
template() {
cat <<'EOF'
#!/usr/bin/env python3
"""
Description
Input:
...
Output:
...
Purpose:
...
Prerequisites:
...
\033[1m\033[31mWARNING:\033[0m
...
"""
# TODO:
# - [ ]
from Bio import SeqIO
from itertools import combinations
from pathlib import Path
from typing import TextIO, NamedTuple
import argparse
import gzip
import logging
import numpy as np
import polars as pl
import shutil
import subprocess
import sys
# =================================================================
# CLI args
# =================================================================
class Args(NamedTuple):
infile: Path
outdir: Path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"-i",
"--infile",
type=Path,
metavar="FILE",
required=True,
help="Path to input [Required]",
)
parser.add_argument(
"-o",
"--outdir",
type=Path,
required=False,
default=".",
metavar="DIR",
help="Output target directory [Optional][Default: cwd]",
)
args = Args(**vars(parser.parse_args()))
return args
# =============================================================
# Core func.
# =============================================================
def funca(args):
"""Description
---
Args:
arg1 (dtype): description
Returns:
dtype: description
"""
# stuff
print("Hello world")
# =============================================================
def main() -> None:
"""Workflow:
---
main
├── args
└── func
│
"""
# get args
args = parse_args()
# func
funca(args)
# =============================================================
if __name__ == "__main__":
sys.exit(main())
EOF
}
template >"${filename}.py"