|
1
|
|
|
""" |
|
2
|
|
|
Common argument processing and arguments for Typer. |
|
3
|
|
|
""" |
|
4
|
|
|
from typing import Optional, TypeVar |
|
5
|
|
|
|
|
6
|
|
|
from mandos.model.hits import HitFrame |
|
7
|
|
|
|
|
8
|
|
|
from mandos.entry._arg_utils import Arg, Opt, ArgUtils |
|
9
|
|
|
from mandos.entry.searchers import InputFrame |
|
10
|
|
|
from mandos.model.settings import MANDOS_SETTINGS |
|
11
|
|
|
from mandos.model.utils.setup import MandosLogging, MANDOS_SETUP |
|
12
|
|
|
|
|
13
|
|
|
T = TypeVar("T", covariant=True) |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class CommonArgs: |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
output_formats = r""" |
|
19
|
|
|
The filename extension must be one of: .feather; .snappy/.parquet; or |
|
20
|
|
|
.csv, .tsv, .tab (with optional .gz/.bz2/.zip/.xz). |
|
21
|
|
|
Feather (.feather) and Parquet (.snappy) are recommended. |
|
22
|
|
|
If only a filename suffix is provided, only sets the format and suffix. |
|
23
|
|
|
If no suffix is provided, interprets that path as a directory and uses Feather. |
|
24
|
|
|
Will fail if the file exists, unless `--replace` is passed. |
|
25
|
|
|
""" |
|
26
|
|
|
|
|
27
|
|
|
input_formats = r""" |
|
28
|
|
|
The filename extension must be one of: .feather; .snappy/.parquet; |
|
29
|
|
|
.csv, .tsv, .tab (with optional .gz/.bz2/.zip/.xz); .xlsx; or .ods. |
|
30
|
|
|
Feather (.feather) and Parquet (.snappy) are recommended. |
|
31
|
|
|
(.json, .h5, .xls, and others may be accepted but are discouraged.) |
|
32
|
|
|
""" |
|
33
|
|
|
|
|
34
|
|
|
replace: bool = Opt.flag( |
|
35
|
|
|
r""" |
|
36
|
|
|
Replace output file(s) if they exist. |
|
37
|
|
|
""" |
|
38
|
|
|
) |
|
39
|
|
|
|
|
40
|
|
|
skip: bool = Opt.flag( |
|
41
|
|
|
""" |
|
42
|
|
|
Skip any search if the output file exists. |
|
43
|
|
|
|
|
44
|
|
|
See also: ``--replace``. |
|
45
|
|
|
""" |
|
46
|
|
|
) |
|
47
|
|
|
|
|
48
|
|
|
exclude = Opt.val( |
|
49
|
|
|
r""" |
|
50
|
|
|
Regex for input filenames to ignore. |
|
51
|
|
|
|
|
52
|
|
|
Uses the PyPi package 'regex'. |
|
53
|
|
|
""" |
|
54
|
|
|
) |
|
55
|
|
|
|
|
56
|
|
|
stderr: bool = Opt.val( |
|
57
|
|
|
rf""" |
|
58
|
|
|
How much logging output to show.. |
|
59
|
|
|
|
|
60
|
|
|
Can be, from least to most verbose: {", ".join(MANDOS_SETUP.LEVELS)} |
|
61
|
|
|
(Aliases: {MANDOS_SETUP.ALIASES}.) |
|
62
|
|
|
""", |
|
63
|
|
|
"--stderr", |
|
64
|
|
|
default=MandosLogging.DEFAULT_LEVEL, |
|
65
|
|
|
) |
|
66
|
|
|
|
|
67
|
|
|
yes: bool = Opt.flag( |
|
68
|
|
|
r""" |
|
69
|
|
|
Answer yes to all prompts (non-interactive). |
|
70
|
|
|
""", |
|
71
|
|
|
) |
|
72
|
|
|
|
|
73
|
|
|
in_compound_table = Arg.in_file( |
|
74
|
|
|
rf""" |
|
75
|
|
|
The path to the file listing compounds. |
|
76
|
|
|
|
|
77
|
|
|
{input_formats} |
|
78
|
|
|
|
|
79
|
|
|
Must contain a column called 'inchikey'. If provided, a 'compound_id' column |
|
80
|
|
|
will be copied in the results to facilitate lookups. |
|
81
|
|
|
Some searches and commands require a full structure via either "inchi" or "smiles" |
|
82
|
|
|
as a column. These will only be used as needed. |
|
83
|
|
|
|
|
84
|
|
|
{ArgUtils.df_description(InputFrame)} |
|
85
|
|
|
""" |
|
86
|
|
|
) |
|
87
|
|
|
|
|
88
|
|
|
in_annotations_file = Arg.in_file( |
|
89
|
|
|
rf""" |
|
90
|
|
|
The path to a file output by ``:concat`` or ``:search``. |
|
91
|
|
|
""" |
|
|
|
|
|
|
92
|
|
|
) |
|
93
|
|
|
|
|
94
|
|
|
out_annotations_file = Opt.out_file( |
|
95
|
|
|
rf""" |
|
96
|
|
|
Output file containing annotations. |
|
97
|
|
|
|
|
98
|
|
|
{output_formats} |
|
99
|
|
|
|
|
100
|
|
|
{ArgUtils.df_description(HitFrame)} |
|
101
|
|
|
|
|
102
|
|
|
Various columns specific to each search will also be output. |
|
103
|
|
|
For example, a taxon name or evidence level. |
|
104
|
|
|
|
|
105
|
|
|
[default: <input-path>/{...}{MANDOS_SETTINGS.default_table_suffix}] |
|
106
|
|
|
""" |
|
107
|
|
|
) |
|
108
|
|
|
|
|
109
|
|
|
out_misc_dir = Opt.val( |
|
110
|
|
|
rf""" |
|
111
|
|
|
Choose the output directory. |
|
112
|
|
|
|
|
113
|
|
|
You can set alongside ``--to``. |
|
114
|
|
|
If ``--to`` is set to a relative path, this value is prepended. |
|
115
|
|
|
|
|
116
|
|
|
[default: none] |
|
117
|
|
|
""", |
|
|
|
|
|
|
118
|
|
|
"--dir", |
|
119
|
|
|
) |
|
120
|
|
|
|
|
121
|
|
|
taxa = Opt.val( |
|
122
|
|
|
r""" |
|
123
|
|
|
The IDs and/or names of UniProt taxa, comma-separated. |
|
124
|
|
|
|
|
125
|
|
|
IDs are preferred because they are always unambiguous. |
|
126
|
|
|
Taxon scientific names, common names, and mnemonics can be used for vertebrate species. |
|
127
|
|
|
To find more, explore the hierarchy under: |
|
128
|
|
|
|
|
129
|
|
|
- https://www.uniprot.org/taxonomy/131567 (cellular species) |
|
130
|
|
|
|
|
131
|
|
|
- https://www.uniprot.org/taxonomy/10239 (viral species) |
|
132
|
|
|
|
|
133
|
|
|
[default: 7742] (Euteleostomi) |
|
134
|
|
|
""", |
|
135
|
|
|
"--taxa", |
|
136
|
|
|
"7742", |
|
137
|
|
|
show_default=False, |
|
138
|
|
|
) |
|
139
|
|
|
|
|
140
|
|
|
in_cache: bool = Opt.flag( |
|
141
|
|
|
r""" |
|
142
|
|
|
Do not download any data, and fail if needed data is not cached. |
|
143
|
|
|
""", |
|
144
|
|
|
"--in-cache", |
|
145
|
|
|
hidden=True, |
|
146
|
|
|
) |
|
147
|
|
|
|
|
148
|
|
|
as_of: Optional[str] = Opt.val( |
|
149
|
|
|
f""" |
|
150
|
|
|
Restrict to data that was cached as of some date and time. |
|
151
|
|
|
|
|
152
|
|
|
This option can be useful for reproducibility. |
|
153
|
|
|
Note that this should imply that underlying data sources (such as of deposition or publication) |
|
|
|
|
|
|
154
|
|
|
are restricted by this datetime, but that is not checked. |
|
155
|
|
|
|
|
156
|
|
|
Examples: |
|
157
|
|
|
|
|
158
|
|
|
- --as-of 2021-10-11T14:12:13Z |
|
159
|
|
|
|
|
160
|
|
|
- --as-of 2021-10-11T14:12:13+14:00 |
|
161
|
|
|
|
|
162
|
|
|
- --as-of "2021-10-11 14:12:13,496,915+14:00" |
|
163
|
|
|
|
|
164
|
|
|
- --as-of "2021-10-11 14:12:13-8:00 [America/Los_Angeles]" |
|
165
|
|
|
|
|
166
|
|
|
The supported syntax is ``YYYY-mm-dd'T':hh:MM:ss(iii[.iii][.iii)Z``. |
|
167
|
|
|
You can use a space instead of 'T' and ',' as a thousands separator. |
|
168
|
|
|
A UTC offset is required, even with an IANA zone in brackets. |
|
169
|
|
|
""" |
|
|
|
|
|
|
170
|
|
|
) |
|
171
|
|
|
|
|
172
|
|
|
log = Opt.out_path( |
|
173
|
|
|
r""" |
|
174
|
|
|
Log to a file as well as stderr. |
|
175
|
|
|
|
|
176
|
|
|
The suffix can be .log, .log.gz, .log.zip, .json, .json.gz, or .json.gz. |
|
177
|
|
|
Prefix the path with :LEVEL: to control the level for this file (e.g. ``:INFO:out.log``). |
|
178
|
|
|
""", |
|
179
|
|
|
) |
|
180
|
|
|
|
|
181
|
|
|
no_setup: bool = Opt.flag( |
|
182
|
|
|
r"Skip setup, such as configuring logging.", |
|
183
|
|
|
"--no-setup", |
|
184
|
|
|
hidden=True, |
|
185
|
|
|
) |
|
186
|
|
|
|
|
187
|
|
|
|
|
188
|
|
|
__all__ = ["CommonArgs"] |
|
189
|
|
|
|
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.