about summary refs log tree commit diff
path: root/uploader/genotypes/types.py
blob: 4403f3d83e4e6d82135e321d6719e2e316147835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""The datatypes this package will use."""
from typing import Sequence, Optional
from dataclasses import field, dataclass


@dataclass
class DotGenoFields:# Still necessary??
    """Custom .geno file format values"""
    name: str
    mat: str
    pat: str
    het: str
    type: Optional[str] = None
    unk: Optional[str] = None


@dataclass(frozen=True)
class FieldsIdentity:
    """Data type for identity of the fields."""
    marker: str
    chromosome: str
    genetic_distance: str # cM
    physical_distance: str # Mb
    samples: Sequence[str]


@dataclass
class LineError:
    """An error in a specific line of the genotype file."""
    row_header: str
    column_header: str
    message: str
    line: Sequence[str]


@dataclass(frozen=True)
class TransposedLineDetails:
    """Data type for processed line details"""
    line_content: Sequence[str]
    geno_symbols: Sequence[str]
    line_header: str
    errors: Sequence[LineError]
    is_markers_line: bool = False


@dataclass(frozen=True)
class UntransposedLineDetails:
    """Data type for processed line details"""
    line_content: Sequence[str]
    geno_symbols: Sequence[str]
    line_header: str
    errors: Sequence[LineError]
    marker: Optional[str] = None


@dataclass(frozen=True)
class FileStats:# pylint: disable=[too-many-instance-attributes]
    """Custom file statistics."""
    total_lines: int
    data_lines: int
    geno_symbols: Sequence[str]

    comment_lines: int = 0
    blank_lines: int = 0
    dot_geno_lines: int = 0
    dot_geno_fields: Optional[DotGenoFields] = None
    samples_list: Sequence[str] = field(default_factory=tuple)
    markers_list: Sequence[str] = field(default_factory=tuple)
    errors: Sequence[LineError] = field(default_factory=tuple)
    description: str = ""