Passed
Push — main ( 83a9fb...fa90c4 )
by Douglas
03:43
created

MiscCommands.detail_search()   A

Complexity

Conditions 1

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nop 5
dl 0
loc 33
rs 9.6
c 0
b 0
f 0
1
"""
2
Command-line interface for mandos.
3
"""
4
5
from __future__ import annotations
6
7
import os
8
from pathlib import Path
9
from typing import Optional
10
11
import typer
0 ignored issues
show
introduced by
Unable to import 'typer'
Loading history...
12
from pocketutils.core.exceptions import XValueError
0 ignored issues
show
introduced by
Unable to import 'pocketutils.core.exceptions'
Loading history...
13
from typeddfs import FileFormat
0 ignored issues
show
introduced by
Unable to import 'typeddfs'
Loading history...
14
from typeddfs.cli_help import DfCliHelp
0 ignored issues
show
introduced by
Unable to import 'typeddfs.cli_help'
Loading history...
15
from typeddfs.utils import Utils as TypedDfsUtils
0 ignored issues
show
introduced by
Unable to import 'typeddfs.utils'
Loading history...
16
17
from mandos.analysis.filtration import Filtration
18
from mandos.analysis.reification import Reifier
19
from mandos.entry._arg_utils import Arg, ArgUtils, EntryUtils, Opt
20
from mandos.entry._common_args import CommonArgs
21
from mandos.entry._common_args import CommonArgs as Ca
0 ignored issues
show
Unused Code introduced by
The import CommonArgs was already done on line 20. You should be able to
remove this line.
Loading history...
22
from mandos.entry.docs import Documenter
23
from mandos.entry.fillers import CompoundIdFiller, IdMatchDf
24
from mandos.entry.multi_searches import MultiSearch, SearchConfigDf
25
from mandos.entry.searchers import InputCompoundsDf
26
from mandos.model.apis.g2p_api import CachingG2pApi
27
from mandos.model.hit_dfs import HitDf
28
from mandos.model.settings import SETTINGS, Globals
29
from mandos.model.taxonomy import TaxonomyDf
30
from mandos.model.taxonomy_caches import TaxonomyFactories
31
from mandos.model.utils.setup import MANDOS_SETUP, logger
32
33
DEF_SUFFIX = SETTINGS.table_suffix
34
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...
35
36
37
class _InsertedCommandListSingleton:
38
    commands = None
39
40
41
class MiscCommands:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
42
    @staticmethod
43
    def init(
44
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
45
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
46
    ):
47
        """
48
        Initializes mandos, creating directories, etc.
49
        """
50
        MANDOS_SETUP(log, stderr)
51
        Globals.mandos_path.mkdir(exist_ok=True, parents=True)
52
        typer.echo(f"Mandos home dir is {Globals.mandos_path}")
53
        if Globals.settings_path.exists():
54
            typer.echo(f"Settings found at {Globals.settings_path}")
55
        else:
56
            typer.echo("No settings file found")
57
        typer.echo(f"Log level for stderr is level {logger.current_stderr_log_level}")
58
59
    @staticmethod
60
    def list_settings(
61
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
62
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
63
    ):
64
        r"""
65
        Write the settings to stdout.
66
        """
67
        MANDOS_SETUP(log, stderr)
68
        defaults = SETTINGS.defaults()
69
        width = max((len(k) + 2 + len(v) + 1 for k, v in SETTINGS.items()))
0 ignored issues
show
Bug introduced by
The Instance of Settings does not seem to have a member named items.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
70
        for k, v in SETTINGS.as_dict():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
Bug introduced by
SETTINGS.as_dict does not seem to be callable.
Loading history...
71
            msg = f"{k} = {v}".ljust(width)
72
            if v != defaults[k]:
73
                msg += f" (default: {defaults[k]})"
74
            typer.echo(msg)
75
76
    @staticmethod
77
    def document(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
best-practice introduced by
Too many arguments (11/5)
Loading history...
78
        to: Path = Opt.out_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
79
            r"""
80
            The path to write command documentation to.
81
82
            The filename can end with .txt with optional compression (e.g. .txt.gz)
83
            for formatted text output alongside --format.
84
85
            Can can also use any table format: .feather; .snappy/.parquet;
86
            or .csv, .tsv, .tab, .json, .flexwf (with optional .gz/.bz2/.zip/.xz).
87
88
            [default: "commands-level<level>.txt"]
89
            """
90
        ),
91
        style: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
92
            rf"""
93
            The format for formatted text output.
94
95
            This is ignored if --to is not a .txt file (or .txt.gz, etc.).
96
            The choices are: "table", "document", {", ".join(TypedDfsUtils.table_formats())}.
97
98
            "table" is a special style that saves in any machine-readable table format, such
99
            as Feather or Parquet (determined by --to).
100
101
            "document" is a special style that emits non-table-like flat text.
102
            """,
103
            "--style",
104
            default="table",
105
        ),
106
        width: int = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
107
            r"""
108
            Max number of characters for a cell.
109
110
            After that, the text is wrapped.
111
            Only applies when writing formatted text (.txt, etc.).
112
113
            [default: 40 if level > 1; 100 otherwise]
114
            """,
115
            default=None,
116
            show_default=False,
117
        ),
118
        level: int = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
119
            r"""
120
            The amount of detail to output.
121
122
            - 1 : show a 1-line description
123
124
            - 2 : Show a 1-line description, plus parameter names
125
126
            - 3 : Show the full description, plus parameter names, types, and 1-line descriptions
127
128
            - 4 : Show the full description, plus parameter names types, and full descriptions
129
130
            - 5 : Same as 4, but enable --hidden and --common
131
            """,
132
            default=4,
133
            min=1,
134
            max=5,
135
        ),
136
        main_only: bool = Opt.flag(r"Only include main commands."),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
137
        search_only: bool = Opt.flag(r"Only include search commands."),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
138
        hidden: bool = Opt.flag(r"Show hidden commands."),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
139
        common: bool = Opt.flag(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
140
            r"""
141
            Show common arguments and options.
142
143
            Normally --log, --quiet, and --verbose are excluded,
144
            along with path, --key, --to, --as-of for searches,
145
            and the hidden flags for searches --check and --no-setup.
146
            """
147
        ),
148
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
149
        log: Optional[Path] = Ca.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
150
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
151
    ):
152
        r"""
153
        Write documentation on commands to a file.
154
        """
155
        MANDOS_SETUP(log, stderr)
156
        if level == 5:
157
            hidden = common = True
158
        if width is None and level == 1:
159
            width = 100
160
        elif width is None:
161
            width = 40
162
        if width == 0:
163
            width = 9223372036854775807
164
        default = f"commands-level{level}.txt"
165
        to = EntryUtils.adjust_filename(to, default, replace=replace)
166
        doc = Documenter(
167
            level=level,
168
            main=main_only,
169
            search=search_only,
170
            hidden=hidden,
171
            common=common,
172
            width=width,
173
        )
174
        doc.document(_InsertedCommandListSingleton.commands, to, style)
175
176
    @staticmethod
177
    def search(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
best-practice introduced by
Too many arguments (7/5)
Loading history...
178
        path: Path = Ca.in_compound_table,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
179
        config: Path = Opt.in_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
180
            r"""
181
            TOML config file. See the docs.
182
            """,
183
            default=...,
184
        ),
185
        to: Path = Ca.out_wildcard,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
186
        log: Optional[Path] = Ca.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
187
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
188
        replace: bool = Opt.flag(r"""Overwrite files if they exist."""),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
189
        check: bool = Opt.flag("Check and write docs file only; do not run"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
190
    ) -> None:
191
        r"""
192
        Run multiple searches.
193
        """
194
        MANDOS_SETUP(log, stderr)
195
        default = "search-" + Globals.start_timestamp_filesys
196
        # TODO: , suffixes=FileFormat.from_path
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
197
        out_dir, suffix = EntryUtils.adjust_dir_name(to, default)
198
        logger.notice(f"Will write {suffix} to {out_dir}{os.sep}")
199
        config_fmt = FileFormat.from_path(config)
200
        if config_fmt is not FileFormat.toml:
201
            logger.caution(f"Config format is {config_fmt}, not toml; trying anyway")
202
        config = SearchConfigDf.read_file(config)
203
        search = MultiSearch(config, path, out_dir, suffix, replace, log)
204
        if not check:
205
            search.run()
206
207
    @staticmethod
208
    def serve(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "db" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
209
        port: int = Opt.val(r"Port to serve on", default=1540),
0 ignored issues
show
Unused Code introduced by
The argument port seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
210
        db: str = Opt.val("Name of the MySQL database", default="mandos"),
0 ignored issues
show
Unused Code introduced by
The argument db seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
211
        log: Optional[Path] = Ca.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
212
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
213
    ) -> None:
214
        r"""
215
        Start a REST server.
216
217
        The connection information is stored in your global settings file.
218
        """
219
        MANDOS_SETUP(log, stderr)
220
221
    @staticmethod
222
    def export_db(
0 ignored issues
show
best-practice introduced by
Too many arguments (9/5)
Loading history...
Coding Style Naming introduced by
Argument name "db" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
223
        path: Path = Ca.in_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument path seems to be unused.
Loading history...
224
        db: str = Opt.val(r"Name of the MySQL database", default="mandos"),
0 ignored issues
show
Unused Code introduced by
The argument db seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
225
        host: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument host seems to be unused.
Loading history...
226
            r"Database hostname (ignored if ``--socket`` is passed", default="127.0.0.1"
227
        ),
228
        socket: Optional[str] = Opt.val("Path to a Unix socket (if set, ``--host`` is ignored)"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument socket seems to be unused.
Loading history...
229
        user: Optional[str] = Opt.val("Database username (empty if not set)"),
0 ignored issues
show
Unused Code introduced by
The argument user seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
230
        password: Optional[str] = Opt.val("Database password (empty if not set)"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument password seems to be unused.
Loading history...
231
        as_of: Optional[str] = CommonArgs.as_of,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument as_of seems to be unused.
Loading history...
232
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
233
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
234
    ) -> None:
235
        r"""
236
        Export to a relational database.
237
238
        Saves data from Mandos search commands to a database for serving via REST.
239
240
        See also: ``:serve``.
241
        """
242
        MANDOS_SETUP(log, stderr)
243
244
    @staticmethod
245
    def init_db(
0 ignored issues
show
best-practice introduced by
Too many arguments (9/5)
Loading history...
Coding Style Naming introduced by
Argument name "db" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
246
        db: str = Opt.val(r"Name of the MySQL database", default="mandos"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument db seems to be unused.
Loading history...
247
        host: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument host seems to be unused.
Loading history...
248
            r"Database hostname (ignored if ``--socket`` is passed", default="127.0.0.1"
249
        ),
250
        socket: Optional[str] = Opt.val("Path to a Unix socket (if set, ``--host`` is ignored)"),
0 ignored issues
show
Unused Code introduced by
The argument socket seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
251
        user: Optional[str] = Opt.val("Database username (empty if not set)"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument user seems to be unused.
Loading history...
252
        password: Optional[str] = Opt.val("Database password (empty if not set)"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument password seems to be unused.
Loading history...
253
        overwrite: bool = Opt.flag(r"Delete the database if it exists"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument overwrite seems to be unused.
Loading history...
254
        yes: bool = Ca.yes,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument yes seems to be unused.
Loading history...
255
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
256
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
257
    ) -> None:
258
        r"""
259
        Initialize an empty database.
260
        """
261
        MANDOS_SETUP(log, stderr)
262
263
    @staticmethod
264
    def fill(
0 ignored issues
show
best-practice introduced by
Too many arguments (7/5)
Loading history...
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
265
        path: Path = Arg.in_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
266
            rf"""
267
            {DfCliHelp.help(InputCompoundsDf).get_short_text(nl=nl)}
268
            """,
269
        ),
270
        to: Path = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
271
            rf"""
272
            {DfCliHelp.help(IdMatchDf).get_short_text(nl=nl)}
273
274
            [default: <path>-ids-<start-time>{DEF_SUFFIX}]
275
            """
276
        ),
277
        no_pubchem: bool = Opt.flag("Do not use PubChem.", "--no-pubchem"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
278
        no_chembl: bool = Opt.flag("Do not use ChEMBL.", "--no-chembl"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
279
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
280
        log: Optional[Path] = Ca.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
281
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
282
    ) -> None:
283
        r"""
284
        Fill in missing IDs from existing compound data.
285
286
        The idea is to find a ChEMBL ID, a PubChem ID, and parent-compound InChI/InChI Key.
287
        Useful to check compound/ID associations before running a search.
288
289
        To be filled, each row must should have a non-null value for
290
        "inchikey", "chembl_id", and/or "pubchem_id".
291
        "inchi" will be used but not to match to PubChem and ChEMBL.
292
293
        No existing columns will be dropped or modified.
294
        Any conflicting column will be renamed to 'origin_<column>'.
295
        E.g. 'inchikey' will be renamed to 'origin_inchikey'.
296
        (Do not include a column beginning with 'origin_').
297
298
        Final columns (assuming --no-chembl and --no-pubchem) will include:
299
        inchikey, inchi, pubchem_id, chembl_id, pubchem_inch, chembl_inchi,
300
        pubchem_inchikey, and chembl_inchikey.
301
        The "inchikey" and "inchikey" columns will be the "best" available:
302
        chembl (preferred), then pubchem, then your source inchikey column.
303
        In cases where PubChem and ChEMBL differ, an error will be logged.
304
        You can always check the columns "origin_inchikey" (yours),
305
        chembl_inchikey, and pubchem_inchikey.
306
307
        The steps are:
308
309
        - If "chembl_id" or "pubchem_id" is non-null, uses that to find an InChI Key (for each).
310
311
        - Otherwise, if only "inchikey" is non-null, uses it to find ChEMBL and PubChem records.
312
313
        - Log an error if the inchikeys or inchis differ between PubChem and ChEMBL.
314
315
        - Set the final "inchi" and "inchikey" to the best choice,
316
          falling back to the input inchi and inchikey if they are missing.
317
        """
318
        MANDOS_SETUP(log, stderr)
319
        default = str(Path(path).with_suffix("")) + "-filled" + "".join(path.suffixes)
320
        to = EntryUtils.adjust_filename(to, default, replace=replace)
321
        df = IdMatchDf.read_file(path)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
322
        df = CompoundIdFiller(chembl=not no_chembl, pubchem=not no_pubchem).fill(df)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
323
        df.write_file(to)
324
325
    @staticmethod
326
    def cache_data(
327
        path: Path = Ca.in_compound_table,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
328
        no_pubchem: bool = Opt.flag(r"Do not download data from PubChem", "--no-pubchem"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
329
        no_chembl: bool = Opt.flag(r"Do not fetch IDs from ChEMBL", "--no_chembl"),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
330
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
331
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
332
    ) -> None:
333
        r"""
334
        Fetch and cache compound data.
335
336
        Useful to freeze data before running a search.
337
        """
338
        MANDOS_SETUP(log, stderr)
339
        logger.error(f"Not implemented fully yet.")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
340
        df = IdMatchDf.read_file(path)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
341
        df = CompoundIdFiller(chembl=not no_chembl, pubchem=not no_pubchem).fill(df)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
342
        logger.notice(f"Done caching.")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
343
344
    @staticmethod
345
    def export_taxa(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
best-practice introduced by
Too many arguments (7/5)
Loading history...
346
        taxa: str = Ca.taxa,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
347
        forbid: str = Ca.ban_taxa,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
348
        to: Path = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
349
            rf"""
350
            {DfCliHelp.help(TaxonomyDf).get_short_text(nl=nl)}
351
352
            [default: ./<taxa>-<datetime>{DEF_SUFFIX}]
353
            """
354
        ),
355
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
356
        in_cache: bool = CommonArgs.in_cache,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
357
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
358
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
359
    ):
360
        """
361
        Export a taxonomic tree to a table.
362
363
        Writes a taxonomy of given taxa and their descendants to a table.
364
        """
365
        MANDOS_SETUP(log, stderr)
366
        concat = taxa + "-" + forbid
367
        taxa = ArgUtils.parse_taxa(taxa)
368
        ancestors = ArgUtils.parse_taxa_ids(ancestors)
0 ignored issues
show
Bug introduced by
The variable ancestors was used before it was assigned.
Loading history...
369
        forbid = ArgUtils.parse_taxa(forbid)
370
        default = concat + "-" + Globals.start_timestamp_filesys + DEF_SUFFIX
371
        to = EntryUtils.adjust_filename(to, default, replace=replace)
372
        my_tax = TaxonomyFactories.get_smart_taxonomy(
373
            allow=taxa, forbid=forbid, ancestors=ancestors, local_only=in_cache
374
        )
375
        my_tax = my_tax.to_df()
376
        my_tax.write_file(to, mkdirs=True)
377
378
    @staticmethod
379
    def cache_taxa(
380
        taxa: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
381
            r"""
382
            Either "all" or a comma-separated list of UniProt taxon IDs.
383
384
            Can also be "vertebrata", "cellular", or "viral" for those specific taxa.
385
            "all" is only valid when --replace is passed;
386
            this will regenerate all taxonomy files that are found in the cache.
387
            """,
388
            default="",
389
        ),
390
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
391
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
392
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
393
    ) -> None:
394
        """
395
        Prep a new taxonomy file for use in mandos.
396
397
        With --replace set, will delete any existing file.
398
        This can be useful to make sure your cached taxonomy is up-to-date before running.
399
400
        Downloads and converts a tab-separated file from UniProt.
401
        (To find manually, follow the ``All lower taxonomy nodes`` link and click ``Download``.)
402
        Then applies fixes and reduces the file size, creating a new file alongside.
403
        Puts both the raw data and fixed data in the cache under ``~/.mandos/taxonomy/``.
404
        """
405
        MANDOS_SETUP(log, stderr)
406
        if taxa == "all" and not replace:
407
            raise XValueError(f"Use --replace with 'all'")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
408
        # we're good to go:
409
        factory = TaxonomyFactories.main()
410
        if taxa == "all":
411
            taxa = TaxonomyFactories.list_cached_files().keys()
412
        else:
413
            taxa = ArgUtils.parse_taxa_ids(taxa)
414
        factory.rebuild(taxa, replace=replace)
415
416
    @staticmethod
417
    def cache_g2p(
418
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
419
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
420
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
421
    ) -> None:
422
        """
423
        Caches GuideToPharmacology data.
424
425
        With --replace set, will overwrite existing cached data.
426
        Data will generally be stored under``~/.mandos/g2p/``.
427
        """
428
        MANDOS_SETUP(log, stderr)
429
        api = CachingG2pApi(SETTINGS.g2p_cache_path)
430
        api.download(force=replace)
431
432
    @staticmethod
433
    def cache_clear(
434
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
435
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
436
        yes: bool = CommonArgs.yes,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
437
    ) -> None:
438
        """
439
        Deletes all cached data.
440
        """
441
        MANDOS_SETUP(log, stderr)
442
        typer.echo(f"Will recursively delete all of these paths:")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
443
        for p in SETTINGS.all_cache_paths:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "p" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
444
            typer.echo(f"    {p}")
445
        if not yes:
446
            typer.confirm("Delete?", abort=True)
447
        for p in SETTINGS.all_cache_paths:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "p" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
448
            p.unlink(missing_ok=True)
449
        logger.notice("Deleted all cached data")
450
451
    @staticmethod
452
    def concat(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
453
        path: Path = Arg.in_dir(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
454
            rf"""
455
            Directory containing results from a mandos search.
456
457
            {DfCliHelp.list_formats().get_short_text()}
458
            """
459
        ),
460
        to: Optional[Path] = Ca.out_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
461
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
462
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
463
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
464
    ) -> None:
465
        r"""
466
        Concatenate Mandos annotation files into one.
467
468
        Note that ``:search`` automatically performs this;
469
        this is needed only if you want to combine results from multiple independent searches.
470
        """
471
        MANDOS_SETUP(log, stderr)
472
        default = path / ("concat" + DEF_SUFFIX)
473
        to = EntryUtils.adjust_filename(to, default, replace)
474
        for found in path.iterdir():
0 ignored issues
show
Unused Code introduced by
The variable found seems to be unused.
Loading history...
475
            pass
476
477
    @staticmethod
478
    def filter(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "by" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
best-practice introduced by
Too many arguments (6/5)
Loading history...
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
479
        path: Path = Ca.out_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
480
        by: Optional[Path] = Arg.in_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
481
            r"""
482
            Path to a file containing filters.
483
484
            See the docs for more info.
485
            """
486
        ),
487
        to: Optional[Path] = Ca.out_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
488
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
489
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
490
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
491
    ) -> None:
492
        """
493
        Filters by simple expressions.
494
        """
495
        MANDOS_SETUP(log, stderr)
496
        default = str(path) + "-filter-" + by.stem + DEF_SUFFIX
497
        to = EntryUtils.adjust_filename(to, default, replace)
498
        df = HitDf.read_file(path)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
499
        Filtration.from_file(by).apply(df).write_file(to)
500
501
    @staticmethod
502
    def export_state(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
503
        path: Path = Ca.in_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
504
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
505
            """
506
            Path to the output file.
507
508
            Valid formats and filename suffixes are .nt and .txt with an optional .gz, .zip, or .xz.
509
            If only a filename suffix is provided, will use that suffix with the default directory.
510
            If no suffix is provided, will interpret the path as a directory and use the default filename.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/100).

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

Loading history...
511
            Will fail if the file exists and ``--replace`` is not set.
512
513
            [default: <path>-statements.nt]
514
        """
515
        ),
516
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
517
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
518
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
519
    ) -> None:
520
        """
521
        Output simple N-triples statements.
522
523
        Each statement is of this form, where the InChI Key refers to the input data:
524
525
        `"InChI Key" "predicate" "object" .`
526
        """
527
        MANDOS_SETUP(log, stderr)
528
        default = f"{path}-statements.nt"
529
        to = EntryUtils.adjust_filename(to, default, replace)
530
        hits = HitDf.read_file(path).to_hits()
531
        with to.open() as f:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
532
            for hit in hits:
533
                f.write(hit.to_triple.n_triples)
534
535
    @staticmethod
536
    def export_reify(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
537
        path: Path = Ca.in_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
538
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
539
            r"""
540
            Path to the output file.
541
542
            The filename suffix should be either .nt (N-triples) or .ttl (Turtle),
543
            with an optional .gz, .zip, or .xz.
544
            If only a filename suffix is provided, will use that suffix with the default directory.
545
            If no suffix is provided, will interpret the path as a directory but use the default filename.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/100).

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

Loading history...
546
            Will fail if the file exists and ``--replace`` is not set.
547
548
            [default: <path>-reified.nt]
549
            """
550
        ),
551
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
552
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
553
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
554
    ) -> None:
555
        """
556
        Outputs reified semantic triples.
557
        """
558
        MANDOS_SETUP(log, stderr)
559
        default = f"{path}-reified.nt"
560
        to = EntryUtils.adjust_filename(to, default, replace)
561
        hits = HitDf.read_file(path).to_hits()
562
        with to.open() as f:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
563
            for triple in Reifier().reify(hits):
564
                f.write(triple.n_triples)
565
566
    @staticmethod
567
    def export_copy(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
568
        path: Path = Ca.in_annotations_file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
569
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
570
            rf"""
571
            Path to the output file.
572
573
            {DfCliHelp.list_formats().get_short_text()}
574
575
            [default: <path.parent>/export{DEF_SUFFIX}]
576
            """
577
        ),
578
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
579
        log: Optional[Path] = CommonArgs.log,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
580
        stderr: str = CommonArgs.stderr,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
581
    ) -> None:
582
        """
583
        Copies and/or converts annotation files.
584
585
        Example: ``:export:copy --to .snappy`` to highly compress a data set.
586
        """
587
        MANDOS_SETUP(log, stderr)
588
        default = path.parent / DEF_SUFFIX
589
        to = EntryUtils.adjust_filename(to, default, replace)
590
        df = HitDf.read_file(path)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\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...
591
        df.write_file(to)
592
593
594
__all__ = ["MiscCommands"]
595