Passed
Push — main ( da77b5...65730f )
by Douglas
02:28
created

mandos.entry.utils._common_args   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 160
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 46
dl 0
loc 160
rs 10
c 0
b 0
f 0
wmc 0
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
0 ignored issues
show
introduced by
Unable to import 'pocketutils.misc.fancy_loguru'
Loading history...
8
from typeddfs.cli_help import DfCliHelp
0 ignored issues
show
introduced by
Unable to import 'typeddfs.cli_help'
Loading history...
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)
0 ignored issues
show
Coding Style Naming introduced by
Class name "T" doesn't conform to PascalCase naming style ('[^\\W\\da-z][^\\W_]+$' pattern)

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.

Loading history...
16
DEF_SUFFIX = SETTINGS.table_suffix
17
nl = "\n\n"
0 ignored issues
show
Coding Style Naming introduced by
Constant name "nl" doesn't conform to UPPER_CASE naming style ('([^\\W\\da-z][^\\Wa-z]*|__.*__)$' pattern)

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.

Loading history...
18
19
20
class CommonArgs:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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)}
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (102/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
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
        """
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
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
        """
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
156
    )
157
158
159
__all__ = ["CommonArgs"]
160