Coverage for src/python/ensembl/vep/corpus/exporter/manifest.py: 100%

20 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"""The manifest written beside an exported corpus.""" 

15 

16from __future__ import annotations 

17 

18import json 

19 

20from attrs import asdict, frozen 

21 

22__all__ = ["CorpusManifest"] 

23 

24 

25@frozen(kw_only=True, auto_attribs=True) 

26class CorpusManifest: 

27 """Describe an exported corpus. 

28 

29 Attributes: 

30 kind (str): Which corpus kind was written. 

31 spec (dict[str, object]): Complete registered construction specification. 

32 fuzz (int | None): Compatibility fuzz count for synthetic corpora. 

33 step (int | None): Compatibility sweep step for synthetic corpora. 

34 seeds (dict[str, dict[str, int]]): The seeds each written corpus was built from, per kind. 

35 parameters (str): The spec's parameter hash. 

36 chromosomes (tuple[str, ...]): Sequence region names written. 

37 transcripts (int): Transcripts written. 

38 variants (int): Distinct variants written. 

39 overlaps (int): Overlaps the corpus pairs those variants into. 

40 identity (str): A hash of the corpus files. 

41 files (tuple[str, ...]): The file names written beside this manifest. 

42 """ 

43 

44 kind: str 

45 spec: dict[str, object] 

46 fuzz: int | None 

47 step: int | None 

48 seeds: dict[str, dict[str, int]] 

49 parameters: str 

50 chromosomes: tuple[str, ...] 

51 transcripts: int 

52 variants: int 

53 overlaps: int 

54 identity: str 

55 files: tuple[str, ...] 

56 

57 def to_json(self) -> str: 

58 """Return the manifest as indented JSON.""" 

59 return json.dumps(asdict(self), indent=2) + "\n"