|
1
|
|
|
""" |
|
2
|
|
|
Common argument processing and arguments for Typer. |
|
3
|
|
|
""" |
|
4
|
|
|
import os |
|
5
|
|
|
from typing import Optional, TypeVar |
|
6
|
|
|
|
|
7
|
|
|
from pocketutils.misc.fancy_loguru import FancyLoguruDefaults |
|
|
|
|
|
|
8
|
|
|
from typeddfs.cli_help import DfCliHelp |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
from mandos.entry.tools.searchers import InputCompoundsDf |
|
11
|
|
|
from mandos.entry.utils._arg_utils import Arg, Opt |
|
12
|
|
|
from mandos.model.hit_dfs import HitDf |
|
13
|
|
|
from mandos.model.settings import SETTINGS |
|
14
|
|
|
|
|
15
|
|
|
T = TypeVar("T", covariant=True) |
|
|
|
|
|
|
16
|
|
|
DEF_SUFFIX = SETTINGS.table_suffix |
|
17
|
|
|
nl = "\n\n" |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
class CommonArgs: |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
replace: bool = Opt.flag( |
|
23
|
|
|
r""" |
|
24
|
|
|
Replace output file(s) if they exist. |
|
25
|
|
|
""" |
|
26
|
|
|
) |
|
27
|
|
|
|
|
28
|
|
|
skip: bool = Opt.flag( |
|
29
|
|
|
""" |
|
30
|
|
|
Skip output file(s) that exist. |
|
31
|
|
|
""" |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
|
|
exclude = Opt.val( |
|
35
|
|
|
r""" |
|
36
|
|
|
Regex for input filenames to ignore. |
|
37
|
|
|
""" |
|
38
|
|
|
) |
|
39
|
|
|
|
|
40
|
|
|
yes: bool = Opt.flag( |
|
41
|
|
|
r""" |
|
42
|
|
|
Auto-answer yes to all prompts. |
|
43
|
|
|
""", |
|
44
|
|
|
) |
|
45
|
|
|
|
|
46
|
|
|
stderr: bool = Opt.val( |
|
47
|
|
|
rf""" |
|
48
|
|
|
How much logging output to show. |
|
49
|
|
|
|
|
50
|
|
|
Choices, from least to most verbose: {", ".join(FancyLoguruDefaults.levels_extended)} |
|
51
|
|
|
(Aliases: {FancyLoguruDefaults.aliases}.) |
|
52
|
|
|
""", |
|
53
|
|
|
"--stderr", |
|
54
|
|
|
default=FancyLoguruDefaults.level, |
|
55
|
|
|
) |
|
56
|
|
|
|
|
57
|
|
|
log = Opt.val( |
|
58
|
|
|
rf""" |
|
59
|
|
|
Log to a file (along with stderr). |
|
60
|
|
|
|
|
61
|
|
|
The suffix can be .log, .log.gz, .log.zip, .json, .json.gz, or .json.gz. |
|
62
|
|
|
Prefix with :LEVEL: to control the level for this file (e.g. ":INFO:out.log"). |
|
63
|
|
|
The level can be, from least to most verbose: {", ".join(FancyLoguruDefaults.levels_extended)} |
|
|
|
|
|
|
64
|
|
|
(Aliases: {FancyLoguruDefaults.aliases}.) |
|
65
|
|
|
""", |
|
66
|
|
|
) |
|
67
|
|
|
|
|
68
|
|
|
in_compound_table = Arg.in_file( |
|
69
|
|
|
rf""" |
|
70
|
|
|
{DfCliHelp.help(InputCompoundsDf).get_short_text(nl=nl)} |
|
71
|
|
|
|
|
72
|
|
|
If provided, "compound_id" |
|
73
|
|
|
will be copied in the results to facilitate lookups. |
|
74
|
|
|
Some commands require "inchi" or "smiles". |
|
75
|
|
|
""", |
|
76
|
|
|
) |
|
77
|
|
|
|
|
78
|
|
|
in_annotations_file = Arg.in_file( |
|
79
|
|
|
rf""" |
|
80
|
|
|
A file from ``:concat`` or ``:search``. |
|
81
|
|
|
""" |
|
|
|
|
|
|
82
|
|
|
) |
|
83
|
|
|
|
|
84
|
|
|
out_annotations_file = Opt.out_file( |
|
85
|
|
|
rf""" |
|
86
|
|
|
Output file containing annotations. |
|
87
|
|
|
|
|
88
|
|
|
{DfCliHelp.help(HitDf).get_short_text(nl=nl)} |
|
89
|
|
|
|
|
90
|
|
|
[default: <input-path>/{...}{SETTINGS.table_suffix}] |
|
91
|
|
|
""" |
|
92
|
|
|
) |
|
93
|
|
|
|
|
94
|
|
|
out_wildcard = Opt.val( |
|
95
|
|
|
rf""" |
|
96
|
|
|
The output directory. |
|
97
|
|
|
|
|
98
|
|
|
Use "<path>{os.sep}*<suffix>" to set the output format. |
|
99
|
|
|
(e.g. "output/*.csv.gz"). |
|
100
|
|
|
Permitted suffixes: {DfCliHelp.list_formats().get_short_text()} |
|
101
|
|
|
""" |
|
102
|
|
|
) |
|
103
|
|
|
|
|
104
|
|
|
taxa = Opt.val( |
|
105
|
|
|
r""" |
|
106
|
|
|
UniProt ancestor taxa, comma-separated. |
|
107
|
|
|
|
|
108
|
|
|
Scientific names, common names, and mnemonics can be used for vertebrate species. |
|
109
|
|
|
IDs are preferred. To exclude a subtree, prefix with '-'. |
|
110
|
|
|
If including multiple non-vertebrate taxa, consider including the common ancestor |
|
111
|
|
|
by appending ":ancestor" with its ID to improve performance. |
|
112
|
|
|
These aliases are accepted: "all", "viral", "cellular". |
|
113
|
|
|
Case-insensitive. |
|
114
|
|
|
|
|
115
|
|
|
Examples: |
|
116
|
|
|
|
|
117
|
|
|
- mammalia,-rodentia,-homo sapiens (mammals except rodents and humans) |
|
118
|
|
|
|
|
119
|
|
|
- cyanobacteria,fibrobacteres,acidobacteria:2 |
|
120
|
|
|
(various bacteria, specifying the ancestor (all bacteria)) |
|
121
|
|
|
|
|
122
|
|
|
[default: 7742] (euteleostomi) |
|
123
|
|
|
""", |
|
124
|
|
|
"7742", |
|
125
|
|
|
show_default=False, |
|
126
|
|
|
) |
|
127
|
|
|
|
|
128
|
|
|
in_cache: bool = Opt.flag( |
|
129
|
|
|
r""" |
|
130
|
|
|
Never download; fail if needed data is not cached. |
|
131
|
|
|
""", |
|
132
|
|
|
"--in-cache", |
|
133
|
|
|
hidden=True, |
|
134
|
|
|
) |
|
135
|
|
|
|
|
136
|
|
|
as_of: Optional[str] = Opt.val( |
|
137
|
|
|
f""" |
|
138
|
|
|
Restrict to data cached before some datetime. |
|
139
|
|
|
|
|
140
|
|
|
Can be useful for reproducibility. |
|
141
|
|
|
|
|
142
|
|
|
Examples: |
|
143
|
|
|
|
|
144
|
|
|
- --as-of 2021-10-11T14:12:13Z |
|
145
|
|
|
|
|
146
|
|
|
- --as-of 2021-10-11T14:12:13+14:00 |
|
147
|
|
|
|
|
148
|
|
|
- --as-of "2021-10-11 14:12:13,496,915+14:00" |
|
149
|
|
|
|
|
150
|
|
|
- --as-of "2021-10-11 14:12:13-8:00 [America/Los_Angeles]" |
|
151
|
|
|
|
|
152
|
|
|
The supported syntax is "YYYY-mm-dd'T':hh:MM:ss(iii[.iii][.iii)Z". |
|
153
|
|
|
You can use a space instead of 'T' and ',' as a thousands separator. |
|
154
|
|
|
If provided, the IANA zone (e.g. "America/Los_Angeles") is only for documentation. |
|
155
|
|
|
""" |
|
|
|
|
|
|
156
|
|
|
) |
|
157
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
__all__ = ["CommonArgs"] |
|
160
|
|
|
|