-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchpycli.sh
More file actions
executable file
·139 lines (112 loc) · 2.54 KB
/
touchpycli.sh
File metadata and controls
executable file
·139 lines (112 loc) · 2.54 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
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/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
from dataclasses import dataclass
import argparse
import gzip
import logging
import numpy as np
import polars as pl
import shutil
import subprocess
import sys
# =============================================================================
# logger
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] %(levelname)s -- %(message)s",
datefmt="%H:%M:%S",
)
logger = logging.getLogger(__name__)
# =============================================================================
# CLI args
# =============================================================================
@dataclass
class Args:
infile: Path
outdir: Path
def collect_args() -> Args:
"""Argument parsing"""
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 = collect_args()
# func
funca(args)
# =============================================================================
if __name__ == "__main__":
sys.exit(main())
EOF
}
template >"${filename}.py"