Coverage for src/python/ensembl/vep/config/sections/catalogue/show.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-18 14:41 +0000

1# See the NOTICE file distributed with this work for additional information 

2# regarding copyright ownership. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14"""Options for listing what the catalogue and fact registry contain.""" 

15 

16from __future__ import annotations 

17 

18from pathlib import Path 

19from typing import ClassVar 

20 

21from attrs import define, field 

22 

23from ensembl.vep.config.option_spec import option 

24from ensembl.vep.config.report import REPORT_FORMATS 

25from ensembl.vep.config.sections.base import ConfigSection 

26 

27__all__ = ["CatalogueShowConfig"] 

28 

29SUBJECTS = ("terms", "facts") 

30"""What can be listed: the catalogue's SO terms, or the fact registry behind them.""" 

31 

32SORT_KEYS = ("name", "impact", "cost_tier") 

33"""Every order any subject can be listed in. 

34 

35``name`` applies to both. ``impact`` is a term's property and ``cost_tier`` a fact's, so asking for 

36one on the other subject falls back to that subject's natural order rather than failing. 

37""" 

38 

39 

40@define(frozen=True, kw_only=True, auto_attribs=True) 

41class CatalogueShowConfig(ConfigSection): 

42 """What to list, and how to render it. 

43 

44 Attributes: 

45 subject (str): Whether to list the catalogue's terms or the registered facts. 

46 select (str | None): Show only the term or fact with this name, or None for all of them. 

47 In graph mode it keeps that node and whatever it connects to directly. 

48 graph (bool): Draw the subject as a graph. Use ``--output_format`` to set the file format, 

49 which defaults to svg when ``--graph`` is given. 

50 Unselected SVG terms are embedded in a linked HTML catalogue. 

51 output_format (str | None): Output format. If ``--graph`` is given, must be a valid graph format. 

52 sort (str | None): Row order, or None for the subject's natural order -- catalogue rank for 

53 terms, cost tier for facts. 

54 output_file (Path | None): Where to write, or None for stdout. 

55 """ 

56 

57 section_name: ClassVar[str] = "catalogue_show" 

58 

59 subject: str = field(default="terms", metadata=option("what to list", choices=SUBJECTS)) 

60 select: str | None = field(default=None, metadata=option("show only this term or fact")) 

61 graph: bool = field(default=False, metadata=option("draw as a diagram")) 

62 output_format: str | None = field( 

63 default=None, 

64 metadata=option("report format (default: markdown, svg with --graph)", choices=REPORT_FORMATS), 

65 ) 

66 sort: str | None = field(default=None, metadata=option("row order", choices=SORT_KEYS)) 

67 output_file: Path | None = field(default=None, metadata=option("write output here"))