Passed
Push — main ( 9813db...5006f2 )
by Douglas
01:43
created

mandos.commands.MiscCommands.cache_taxa()   F

Complexity

Conditions 15

Size

Total Lines 53
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 15
eloc 33
nop 5
dl 0
loc 53
rs 2.9998
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like mandos.commands.MiscCommands.cache_taxa() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
"""
2
Command-line interface for mandos.
3
"""
4
5
from __future__ import annotations
6
7
from pathlib import Path
8
from typing import Optional, List
9
10
import typer
0 ignored issues
show
introduced by
Unable to import 'typer'
Loading history...
11
from mandos.entries.searcher import InputFrame
12
13
from mandos import logger, MANDOS_SETUP
14
from mandos.analysis.io_defns import SimilarityDfLongForm
15
from mandos.analysis.concordance import ConcordanceCalculation
16
from mandos.analysis.distances import MatrixCalculation
17
from mandos.analysis.filtration import Filtration
18
from mandos.analysis.enrichment import EnrichmentCalculation, RealAlg, BoolAlg
19
from mandos.analysis.io_defns import ScoreDf
20
from mandos.analysis.prepping import MatrixPrep
21
from mandos.analysis.reification import Reifier
22
from mandos.entries.common_args import Arg, CommonArgs
23
from mandos.entries.common_args import CommonArgs as Ca
0 ignored issues
show
Unused Code introduced by
The import CommonArgs was already done on line 22. You should be able to
remove this line.
Loading history...
24
from mandos.entries.common_args import Opt
25
from mandos.entries.multi_searches import MultiSearch
26
from mandos.entries.filler import CompoundIdFiller, IdMatchFrame
27
from mandos.model import MandosResources
28
from mandos.model.utils import MiscUtils
29
from mandos.model.apis.g2p_api import CachingG2pApi
30
from mandos.model.hits import HitFrame
31
from mandos.model.settings import MANDOS_SETTINGS
32
from mandos.model.taxonomy_caches import TaxonomyFactories
33
from mandos.analysis.projection import UMAP
34
35
set_up = MANDOS_SETUP
36
DEF_SUFFIX = MANDOS_SETTINGS.default_table_suffix
37
38
if UMAP is None:
39
    _umap_params = {}
40
else:
41
    _umap_params = {
42
        k: v
43
        for k, v in UMAP().get_params(deep=False).items()
44
        if k not in {"random_state", "metric"}
45
    }
46
47
48
class MiscCommands:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
best-practice introduced by
Too many public methods (25/20)
Loading history...
49
    @staticmethod
50
    def search(
0 ignored issues
show
best-practice introduced by
Too many arguments (6/5)
Loading history...
51
        path: Path = Ca.compounds,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
52
        config: Path = Arg.in_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
53
            r"""
54
            TOML config file. See docs.
55
            """
56
        ),
57
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
58
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
59
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
60
        out_dir: Path = Ca.out_dir,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
61
    ) -> None:
62
        """
63
        Run multiple searches.
64
        """
65
        set_up(log, quiet, verbose)
66
        MultiSearch.build(path, out_dir, config).run()
67
68
    @staticmethod
69
    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...
70
        port: int = Opt.val(r"Port to serve on", default=1540),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument port seems to be unused.
Loading history...
71
        db: str = Opt.val("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...
72
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
73
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
74
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
75
    ) -> None:
76
        r"""
77
        Start a REST server.
78
79
        The connection information is stored in your global settings file.
80
        """
81
        set_up(log, quiet, verbose)
82
83
    @staticmethod
84
    def export_db(
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...
best-practice introduced by
Too many arguments (10/5)
Loading history...
85
        path: Path = Ca.file_input,
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...
86
        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...
87
        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...
88
            r"Database hostname (ignored if ``--socket`` is passed", default="127.0.0.1"
89
        ),
90
        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...
91
        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...
92
        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...
93
        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...
94
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
95
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
96
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
97
    ) -> None:
98
        r"""
99
        Export to a relational database.
100
101
        Saves data from Mandos search commands to a database for serving via REST.
102
103
        See also: ``:serve``.
104
        """
105
        set_up(log, quiet, verbose)
106
107
    @staticmethod
108
    def fill(
0 ignored issues
show
best-practice introduced by
Too many arguments (8/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...
109
        path: Path = Ca.compounds_to_fill,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
110
        to: Path = Ca.id_table_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
111
        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...
112
        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...
113
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
114
        log: Optional[Path] = Ca.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
115
        quiet: bool = Ca.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
116
        verbose: bool = Ca.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
117
    ) -> None:
118
        r"""
119
        Fill in missing IDs from existing compound data.
120
121
        The idea is to find a ChEMBL ID, a PubChem ID, and parent-compound InChI/InChI Key.
122
        Useful to check compound/ID associations before running a search.
123
124
        To be filled, each row must should have a non-null value for
125
        "inchikey", "chembl_id", and/or "pubchem_id".
126
        "inchi" will be used but not to match to PubChem and ChEMBL.
127
128
        No existing columns will be dropped or modified.
129
        Any conflicting column will be renamed to 'origin_<column>'.
130
        E.g. 'inchikey' will be renamed to 'origin_inchikey'.
131
        (Do not include a column beginning with 'origin_').
132
133
        Final columns (assuming --no-chembl and --no-pubchem) will include:
134
        inchikey, inchi, pubchem_id, chembl_id, pubchem_inch, chembl_inchi,
135
        pubchem_inchikey, and chembl_inchikey.
136
        The "inchikey" and "inchikey" columns will be the "best" available:
137
        chembl (preferred), then pubchem, then your source inchikey column.
138
        In cases where PubChem and ChEMBL differ, an error will be logged.
139
        You can always check the columns "origin_inchikey" (yours),
140
        chembl_inchikey, and pubchem_inchikey.
141
142
        The steps are:
143
144
        - If "chembl_id" or "pubchem_id" is non-null, uses that to find an InChI Key (for each).
145
146
        - Otherwise, if only "inchikey" is non-null, uses it to find ChEMBL and PubChem records.
147
148
        - Log an error if the inchikeys or inchis differ between PubChem and ChEMBL.
149
150
        - Set the final "inchi" and "inchikey" to the best choice,
151
          falling back to the input inchi and inchikey if they are missing.
152
        """
153
        set_up(log, quiet, verbose)
154
        default = str(Path(path).with_suffix("")) + "-filled" + "".join(path.suffixes)
155
        to = MiscUtils.adjust_filename(to, default, replace)
156
        df = IdMatchFrame.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...
157
        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...
158
        df.write_file(to)
159
160
    @staticmethod
161
    def cache_data(
0 ignored issues
show
best-practice introduced by
Too many arguments (6/5)
Loading history...
162
        path: Path = Ca.compounds,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
163
        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...
164
        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...
165
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
166
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
167
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
168
    ) -> None:
169
        r"""
170
        Fetch and cache compound data.
171
172
        Useful to freeze data before running a search.
173
        """
174
        set_up(log, quiet, verbose)
175
        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...
176
        df = IdMatchFrame.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...
177
        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...
178
        logger.notice(f"Done caching.")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
179
180
    @staticmethod
181
    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 (8/5)
Loading history...
182
        taxa: str = Ca.taxa,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
183
        forbid: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
184
            r"""Exclude descendents of these taxa IDs or names (comma-separated).""", default=""
185
        ),
186
        to: Path = typer.Option(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
187
            None,
188
            help=rf"""
189
            Where to export.
190
191
            {Ca.output_formats}
192
193
            [default: ./<taxa>-<datetime>.{DEF_SUFFIX}]
194
            """,
195
        ),
196
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
197
        in_cache: bool = CommonArgs.in_cache,
0 ignored issues
show
Unused Code introduced by
The argument in_cache seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
198
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
199
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
200
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
201
    ):
202
        """
203
        Export a taxonomic tree to a table.
204
205
        Writes a taxonomy of given taxa and their descendants to a table.
206
        """
207
        set_up(log, quiet, verbose)
208
        concat = taxa + "-" + forbid
209
        taxa = Ca.parse_taxa(taxa)
210
        forbid = Ca.parse_taxa(forbid)
211
        default = concat + "-" + MandosResources.start_timestamp_filesys + DEF_SUFFIX
212
        to = MiscUtils.adjust_filename(to, default, replace)
213
        my_tax = TaxonomyFactories.get_smart_taxonomy(taxa, forbid)
214
        my_tax = my_tax.to_df()
215
        to.parent.mkdir(exist_ok=True, parents=True)
216
        my_tax.write_file(to)
217
218
    @staticmethod
219
    def cache_taxa(
220
        taxa: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
221
            r"""
222
            Either "vertebrata", "all", or a comma-separated list of UniProt taxon IDs.
223
224
            "all" is only valid when --replace is passed;
225
            this will regenerate all taxonomy files that are found in the cache.
226
            """,
227
            default="",
228
        ),
229
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
230
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
231
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
232
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
233
    ) -> None:
234
        """
235
        Prep a new taxonomy file for use in mandos.
236
237
        With --replace set, will delete any existing file.
238
        This can be useful to make sure your cached taxonomy is up-to-date before running.
239
240
        Downloads and converts a tab-separated file from UniProt.
241
        (To find manually, follow the ``All lower taxonomy nodes`` link and click ``Download``.)
242
        Then applies fixes and reduces the file size, creating a new file alongside.
243
        Puts both the raw data and fixed data in the cache under ``~/.mandos/taxonomy/``.
244
        """
245
        if taxa == "":
246
            logger.info("No taxa were specified. No data downloaded.")
247
            return
248
        if (
249
            taxa not in ["all", "vertebrata"]
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
250
            and not taxa.replace(",", "").replace(" ", "").isdigit()
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
251
        ):
252
            raise ValueError(f"Use either 'all', 'vertebrata', or a UniProt taxon ID")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
253
        if taxa == "all" and not replace:
254
            raise ValueError(f"Use --replace with taxon 'all'")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
255
        set_up(log, quiet, verbose)
256
        factory = TaxonomyFactories.from_uniprot()
257
        if taxa == "all" and replace:
258
            listed = TaxonomyFactories.list_cached_files()
259
            for p in listed.values():
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...
260
                p.unlink()
261
            factory.rebuild_vertebrata()
262
            for t in listed.keys():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "t" 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...
263
                factory.load_dl(t)
264
        elif taxa == "vertebrata" and (replace or not factory.resolve_path(7742).exists()):
265
            factory.rebuild_vertebrata()
266
        elif taxa == "vertebrata":
267
            factory.load_vertebrate(7742)  # should usually do nothing
268
        else:
269
            for taxon in [int(t.strip()) for t in taxa.split(",")]:
270
                factory.delete_exact(taxon)
271
272
    @staticmethod
273
    def cache_d2p(
274
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
275
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
276
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
277
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
278
    ) -> None:
279
        """
280
        Caches GuideToPharmacology data.
281
282
        With --replace set, will overwrite existing cached data.
283
        Data will generally be stored under``~/.mandos/g2p/``.
284
        """
285
        set_up(log, quiet, verbose)
286
        api = CachingG2pApi(MANDOS_SETTINGS.g2p_cache_path)
287
        api.download(force=replace)
288
289
    @staticmethod
290
    def cache_clear(
291
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
292
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
293
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
294
        yes: bool = CommonArgs.yes,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
295
    ) -> None:
296
        """
297
        Deletes all cached data.
298
        """
299
        set_up(log, quiet, verbose)
300
        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...
301
        for p in MANDOS_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...
302
            typer.echo(f"    {p}")
303
        if not yes:
304
            typer.confirm("Delete?", abort=True)
305
        for p in MANDOS_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...
306
            p.unlink(missing_ok=True)
307
        logger.notice("Deleted all cached data")
308
309
    @staticmethod
310
    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...
best-practice introduced by
Too many arguments (6/5)
Loading history...
311
        path: Path = Ca.input_dir,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
312
        to: Optional[Path] = Ca.to_single,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
313
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
314
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
315
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
316
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
317
    ) -> None:
318
        r"""
319
        Concatenate Mandos annotation files into one.
320
321
        Note that ``:search`` automatically performs this;
322
        this is needed only if you want to combine results from multiple independent searches.
323
        """
324
        set_up(log, quiet, verbose)
325
        default = path / ("concat" + DEF_SUFFIX)
326
        to = MiscUtils.adjust_filename(to, default, replace)
327
        for found in path.iterdir():
0 ignored issues
show
Unused Code introduced by
The variable found seems to be unused.
Loading history...
328
            pass
329
330
    @staticmethod
331
    def filter(
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...
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...
332
        path: Path = Ca.to_single,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
333
        by: Optional[Path] = Arg.in_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
334
            r"""
335
            Path to a TOML (.toml) file containing filters.
336
337
            The file contains a list of ``mandos.filter`` keys,
338
            each containing an expression on a single column.
339
            This is only meant for simple, quick-and-dirty filtration.
340
341
            See the docs for more info.
342
            """
343
        ),
344
        to: Optional[Path] = Ca.to_single,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
345
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
346
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
347
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
348
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
349
    ) -> None:
350
        """
351
        Filters by simple expressions.
352
        """
353
        set_up(log, quiet, verbose)
354
        default = str(path) + "-filter-" + by.stem + DEF_SUFFIX
355
        to = MiscUtils.adjust_filename(to, default, replace)
356
        df = HitFrame.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...
357
        Filtration.from_file(by).apply(df).write_file(to)
358
359
    @staticmethod
360
    def export_state(
0 ignored issues
show
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...
361
        path: Path = Ca.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
362
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
363
            """
364
            Path to the output file.
365
366
            Valid formats and filename suffixes are .nt and .txt with an optional .gz, .zip, or .xz.
367
            If only a filename suffix is provided, will use that suffix with the default directory.
368
            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...
369
            Will fail if the file exists and ``--replace`` is not set.
370
371
            [default: <path>-statements.nt]
372
        """
373
        ),
374
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
375
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
376
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
377
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
378
    ) -> None:
379
        """
380
        Output simple N-triples statements.
381
382
        Each statement is of this form, where the InChI Key refers to the input data:
383
384
        `"InChI Key" "predicate" "object" .`
385
        """
386
        set_up(log, quiet, verbose)
387
        default = f"{path}-statements.nt"
388
        to = MiscUtils.adjust_filename(to, default, replace)
389
        hits = HitFrame.read_file(path).to_hits()
390
        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...
391
            for hit in hits:
392
                f.write(hit.to_triple.n_triples)
393
394
    @staticmethod
395
    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...
best-practice introduced by
Too many arguments (6/5)
Loading history...
396
        path: Path = Ca.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
397
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
398
            r"""
399
            Path to the output file.
400
401
            The filename suffix should be either .nt (N-triples) or .ttl (Turtle),
402
            with an optional .gz, .zip, or .xz.
403
            If only a filename suffix is provided, will use that suffix with the default directory.
404
            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...
405
            Will fail if the file exists and ``--replace`` is not set.
406
407
            [default: <path>-reified.nt]
408
            """
409
        ),
410
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
411
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
412
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
413
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
414
    ) -> None:
415
        """
416
        Outputs reified semantic triples.
417
        """
418
        set_up(log, quiet, verbose)
419
        default = f"{path}-reified.nt"
420
        to = MiscUtils.adjust_filename(to, default, replace)
421
        hits = HitFrame.read_file(path).to_hits()
422
        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...
423
            for triple in Reifier().reify(hits):
424
                f.write(triple.n_triples)
425
426
    @staticmethod
427
    def export_copy(
0 ignored issues
show
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...
428
        path: Path = Ca.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
429
        to: Optional[Path] = Opt.out_path(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
430
            rf"""
431
            Path to the output file.
432
433
            {Ca.output_formats}
434
435
            [default: <path.parent>/export{DEF_SUFFIX}]
436
        """
437
        ),
438
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
439
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
440
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
441
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
442
    ) -> None:
443
        """
444
        Copies and/or converts annotation files.
445
446
        Example: ``:export:copy --to .snappy`` to highly compress a data set.
447
        """
448
        set_up(log, quiet, verbose)
449
        default = path.parent / DEF_SUFFIX
450
        to = MiscUtils.adjust_filename(to, default, replace)
451
        df = HitFrame.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...
452
        df.write_file(to)
453
454
    @staticmethod
455
    def calc_analysis(
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 (10/5)
Loading history...
456
        path: Path = Ca.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
457
        phi: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
458
        scores: Path = Ca.alpha_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
459
        seed: int = Ca.seed,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
460
        samples: int = Ca.boot,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
461
        to: Optional[Path] = Ca.misc_out_dir,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
462
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
463
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
464
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
465
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
466
    ) -> None:
467
        """
468
        Shorthand for multiple calculations and plots.
469
470
        Generates n-triple statements and reified n-triples.
471
        Calculates correlation and enrichment using ``scores``,
472
        psi matrices (one per variable), and concordance between psi and tau matrices (tau).
473
        Plots UMAP of psi variables, enrichment bar plots, correlation violin plots,
474
        phi-vs-psi scatter and line plots, and phi-vs-psi (tau) violin plots.
475
        """
476
477
    @staticmethod
478
    def calc_score(
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 (12/5)
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (16/15).
Loading history...
Coding Style Naming introduced by
Argument name "on" 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.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
480
        scores: Path = Ca.alpha_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
481
        bool_alg: Optional[str] = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
482
            rf"""
483
            Algorithm to use for scores starting with 'is_'.
484
485
            Allowed values: {Ca.list(BoolAlg)}
486
            """,
487
            default="alpha",
488
        ),
489
        real_alg: Optional[str] = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
490
            rf"""
491
            Algorithm to use for scores starting with 'score_'.
492
493
            Allowed values: {Ca.list(RealAlg)}
494
            """,
495
            default="weighted",
496
        ),
497
        on: bool = Ca.on,
0 ignored issues
show
Unused Code introduced by
The argument on seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
498
        boot: int = Ca.boot,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
499
        seed: int = Ca.seed,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
500
        to: Optional[Path] = Ca.alpha_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
501
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
502
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
503
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
504
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
505
    ) -> None:
506
        """
507
        Compare annotations to user-supplied values.
508
509
        Calculates correlation between provided scores and object/predicate pairs.
510
        For booleans, compares annotations for hits and non-hits.
511
        See the docs for more info.
512
        """
513
        set_up(log, quiet, verbose)
514
        default = f"{path}-{scores.name}{DEF_SUFFIX}"
515
        to = MiscUtils.adjust_filename(to, default, replace)
516
        hits = HitFrame.read_file(path)
517
        scores = ScoreDf.read_file(scores)
518
        calculator = EnrichmentCalculation(bool_alg, real_alg, boot, seed)
519
        df = calculator.calculate(hits, scores)
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...
520
        df.write_file(to)
521
522
    @staticmethod
523
    def calc_psi(
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...
524
        path: Path = Ca.file_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
525
        algorithm: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
526
            r"""
527
            The algorithm for calculating similarity between annotation sets.
528
529
            Currently, only "j" (J') is supported. Refer to the docs for the equation.
530
            """,
531
            default="j",
532
        ),
533
        to: Path = Ca.output_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
534
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
535
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
536
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
537
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
538
    ) -> None:
539
        r"""
540
        Calculate a similarity matrix from annotations.
541
542
        The data are output as a dataframe (CSV by default), where rows and columns correspond
543
        to compounds, and the cell i,j is the overlap J' in annotations between compounds i and j.
544
        """
545
        set_up(log, quiet, verbose)
546
        default = path.parent / (algorithm + DEF_SUFFIX)
547
        to = MiscUtils.adjust_filename(to, default, replace)
548
        hits = HitFrame.read_file(path).to_hits()
549
        calculator = MatrixCalculation.create(algorithm)
550
        matrix = calculator.calc_all(hits)
551
        matrix.write_file(to)
552
553
    @staticmethod
554
    def calc_ecfp(
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 (9/5)
Loading history...
555
        path: Path = CommonArgs.compounds,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
556
        radius: int = Opt.val(r"""Radius of the ECFP fingerprint.""", default=4),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
557
        n_bits: int = Opt.val(r"""Number of bits.""", default=2048),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
558
        psi: bool = Opt.flag(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
559
            r"""Use "psi" as the type in the resulting matrix instead of "phi"."""
560
        ),
561
        to: Path = Ca.output_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
562
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
563
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
564
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
565
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
566
    ) -> None:
567
        r"""
568
        Compute a similarity matrix from ECFP fingerprints.
569
570
        Requires rdkit to be installed.
571
572
        This is a bit faster than computing using a search and then calculating with ``:calc:psi``.
573
        Values range from 0 (no overlap) to 1 (identical).
574
        The type will be "phi" -- in contrast to using :calc:phi.
575
        See ``:calc:phi`` for more info.
576
        This is most useful for comparing a phenotypic phi against pure structural similarity.
577
        """
578
        set_up(log, quiet, verbose)
579
        name = f"ecfp{radius}-n{n_bits}"
580
        default = path.parent / (name + DEF_SUFFIX)
581
        to = MiscUtils.adjust_filename(to, default, replace)
582
        df = InputFrame.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...
583
        kind = "psi" if psi else "phi"
584
        short = MatrixPrep.ecfp_matrix(df, radius, n_bits)
585
        long_form = MatrixPrep(kind, False, False, False).create({name: short})
586
        long_form.write_file(to)
587
588
    @staticmethod
589
    def calc_tau(
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 (10/5)
Loading history...
590
        phi: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
591
        psi: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
592
        algorithm: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
593
            r"""
594
            The algorithm for calculating concordance.
595
596
            Currently, only "tau" is supported.
597
            This calculation is a modified Kendall’s  τ-a, where disconcordant ignores ties.
598
            See the docs for more info.
599
            """,
600
            default="tau",
601
        ),
602
        seed: int = Ca.seed,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
603
        samples: int = Ca.boot,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
604
        to: Optional[Path] = Opt.out_file(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
605
            rf"""
606
            The path to a table for output.
607
608
            {Ca.output_formats}
609
610
            [default: <input-path.parent>/<algorithm>-concordance.{DEF_SUFFIX}]
611
            """,
612
        ),
613
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
614
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
615
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
616
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
617
    ) -> None:
618
        r"""
619
        Calculate correlation between matrices.
620
621
        Values are calculated over bootstrap, outputting a table.
622
623
        Phi is typically a phenotypic matrix, and psi a matrix from Mandos.
624
        This command is designed to calculate the similarity between compound annotations
625
        (from Mandos) and some user-input compound–compound similarity matrix.
626
        (For example, vectors from a high-content cell screen.
627
        See ``:calc:correlation`` or ``:calc:enrichment`` if you have a single variable,
628
        such as a hit or lead-like score.
629
        """
630
        set_up(log, quiet, verbose)
631
        default = phi.parent / f"{psi.stem}-{algorithm}{DEF_SUFFIX}"
632
        to = MiscUtils.adjust_filename(to, default, replace)
633
        phi = SimilarityDfLongForm.read_file(phi)
634
        psi = SimilarityDfLongForm.read_file(psi)
635
        calculator = ConcordanceCalculation.create(algorithm, phi, psi, samples, seed)
636
        concordance = calculator.calc_all(phi, psi)
637
        concordance.write_file(to)
638
639
    @staticmethod
640
    def calc_project(
0 ignored issues
show
best-practice introduced by
Too many arguments (9/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...
641
        psi_matrix: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument psi_matrix seems to be unused.
Loading history...
642
        algorithm: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
643
            r"""
644
            Projection algorithm.
645
646
            Currently only "umap" is supported.
647
            """,
648
            default="umap",
649
        ),
650
        seed: str = Opt.val(
0 ignored issues
show
Unused Code introduced by
The argument seed seems to be unused.
Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
651
            r"""
652
            Random seed (integer or 'none').
653
654
            Setting to 'none' may increase performance.
655
            """,
656
            default=0,
657
        ),
658
        params: 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 params seems to be unused.
Loading history...
659
            rf"""
660
            Parameters fed to the algorithm.
661
662
            This is a comma-separated list of key=value pairs.
663
            For example: ``n_neighbors=4,n_components=12,min_dist=0.8``
664
            Supports all UMAP parameters except random_state and metric:
665
666
            {Ca.definition_list(_umap_params) if UMAP else "<list is unavailable>"}
667
            """,
668
            default="",
669
        ),
670
        to: Optional[Path] = Ca.project_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument to seems to be unused.
Loading history...
671
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument replace seems to be unused.
Loading history...
672
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument log seems to be unused.
Loading history...
673
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument quiet seems to be unused.
Loading history...
674
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument verbose seems to be unused.
Loading history...
675
    ) -> None:
676
        r"""
677
        Calculate compound UMAP from psi matrices.
678
679
        The input should probably be calculated from ``:calc:matrix``.
680
        Saves a table of the UMAP coordinates.
681
        """
682
        if algorithm == "umap" and UMAP is None:
683
            raise ImportError(f"UMAP is not available")
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
684
685
    @staticmethod
686
    def format_phi(
0 ignored issues
show
best-practice introduced by
Too many arguments (10/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...
687
        matrices: List[Path] = Ca.input_matrix_short_form,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
688
        kind: str = Ca.var_type,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
689
        to: Path = Ca.output_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
690
        replace: bool = Ca.replace,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
691
        normalize: bool = Opt.flag(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
692
            r"""Rescale values to between 0 and 1 by (v-min) / (max-min). (Performed after negation.)"""
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (104/100).

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

Loading history...
693
        ),
694
        log10: bool = Opt.val(r"""Rescales values by log10. (Performed after normalization.)"""),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
695
        invert: bool = Opt.val(r"""Multiplies the values by -1. (Performed first.)"""),
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
696
        log: Optional[Path] = CommonArgs.log_path,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
697
        quiet: bool = CommonArgs.quiet,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
698
        verbose: bool = CommonArgs.verbose,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
699
    ):
700
        r"""
701
        Convert phi matrices to one long-form matrix.
702
703
        The keys will be derived from the filenames.
704
        """
705
        set_up(log, quiet, verbose)
706
        default = "."
707
        if to is None:
708
            try:
709
                default = next(iter({mx.parent for mx in matrices}))
710
            except StopIteration:
711
                logger.warning(f"Outputting to {default}")
712
        to = MiscUtils.adjust_filename(to, default, replace)
713
        long_form = MatrixPrep(kind, normalize, log10, invert).from_files(matrices)
714
        long_form.write_file(to)
715
716
    @staticmethod
717
    def plot_project(
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...
718
        umap_df: Path = Ca.project_input,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
719
        style: Optional[Path] = Ca.style_for_compounds,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
720
        color_col: Optional[str] = Ca.color_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
721
        marker_col: Optional[str] = Ca.marker_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
722
        to: Optional[Path] = Ca.plot_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
723
    ) -> None:
724
        r"""
725
        Plot UMAP, etc. of compounds from psi matrices.
726
727
        Will plot one variable (psi) per column.
728
        """
729
730
    @staticmethod
731
    def plot_score(
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...
Coding Style Naming introduced by
Argument name "ci" 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...
732
        path: Path = Ca.input_correlation,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
733
        kind: str = Ca.plot_kind,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
734
        style: Optional[Path] = Ca.style_for_pairs,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
735
        color_col: Optional[str] = Ca.color_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
736
        marker_col: Optional[str] = Ca.marker_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
737
        ci: float = Ca.ci,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
738
        to: Optional[Path] = Ca.plot_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
739
    ) -> None:
740
        r"""
741
        Plot correlation to scores.
742
743
        Visualizes the correlation between predicate/object pairs and user-supplied scores.
744
        Will output one figure (file) per scoring function.
745
        Will plot (psi, score-fn) pairs over a grid,
746
        one row per scoring function and column per psi.
747
        """
748
749
    @staticmethod
750
    def plot_phi_psi(
0 ignored issues
show
Coding Style Naming introduced by
Argument name "ci" 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...
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 (9/5)
Loading history...
751
        path: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
752
        join: Optional[bool] = Opt.flag(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
753
            r"""
754
            Pool all psi variables into a single column with multiple plots.
755
            """
756
        ),
757
        kind: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
758
            r"""
759
            Either 'points', 'lines', or 'points+lines'.
760
761
            - points: Scatter plots of (phi, psi) values.
762
763
            - lines: Plot a linear interpolation.
764
765
            - ci: Plot a linear interpolation with a confidence band.
766
767
            - points+lines: Both 'points' and 'lines'.
768
            """,
769
            "--type",
770
        ),
771
        ci: float = Ca.ci,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
772
        sort_by: str = Opt.val(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
773
            r"""
774
            Which axis to sort by: 'phi'/'x' or 'psi'/'y'.
775
776
            Sorting by psi values (y-axis) makes it easier to compare psi variables,
777
            while sorting by phi values (x-axis) makes it easier to compare phi variables.
778
            """,
779
            default="psi",
780
        ),
781
        style: Optional[Path] = Ca.style_for_psi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
782
        color_col: Optional[str] = Ca.color_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
783
        marker_col: Optional[str] = Ca.marker_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
784
        to: Optional[Path] = Ca.plot_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
785
    ) -> None:
786
        r"""
787
        Plot line plots of phi against psi.
788
789
        Plots scatter plots of (phi, psi) values, sorted by phi values.
790
        All plots are log/log (all similarity values should be scaled from 0 to 1).
791
792
        For each unique phi matrix and psi matrix, flattens the matrices and plots
793
        the flattened (n choose 2 - n) pairs of each jointly, phi mapped to the y-axis
794
        and psi mapped to the x-axis.
795
796
        Without --split:
797
798
        Will show values for all psi variables together.
799
        If ``--color`` is not set, will choose a palette.
800
        Works best with ``--type lines``.
801
802
        With --split:
803
804
        Will plot each (phi, psi) pair over a grid, one plot per cell:
805
        One row per phi and one column per psi.
806
        """
807
808
    @staticmethod
809
    def plot_tau(
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 (6/5)
Loading history...
810
        path: Path = Ca.input_matrix,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
811
        split: bool = Opt.flag(
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
812
            r"""
813
            Split each violin into phi #1 on the left and phi #2 on the right.
814
815
            Useful to compare two phi variables. Requires exactly 2.
816
            """
817
        ),
818
        style: Optional[Path] = Ca.style_for_psi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
819
        color_col: Optional[str] = Ca.color_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
820
        marker_col: Optional[str] = Ca.marker_col,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
821
        to: Optional[Path] = Ca.plot_to,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
822
    ) -> None:
823
        r"""
824
        Plot violin plots from tau values.
825
826
        The input data should be generated by ``:calc:phi-vs-psi.tau``.
827
828
        Will plot each (phi, psi) pair over a grid, one row per phi and one column per psi
829
        (unless ``--split`` is set).
830
        """
831
832
833
__all__ = ["MiscCommands"]
834