Skip to main content

rsomics_call/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, PartialEq, Eq)]
4pub enum CallError {
5    #[error("invalid allele: {0}")]
6    InvalidAllele(String),
7
8    #[error("ploidy must be greater than zero")]
9    InvalidPloidy,
10
11    #[error("ploidy input {path}: {message}")]
12    PloidyInput { path: String, message: String },
13
14    #[error("ploidy input {path} line {line}: {message}")]
15    PloidyRecord {
16        path: String,
17        line: u64,
18        message: String,
19    },
20
21    #[error("ploidy definition has no sex named {0}")]
22    UnknownPloidySex(String),
23
24    #[error("ploidy sample assignment count does not match the selected samples")]
25    PloidySampleCountMismatch,
26
27    #[error("allele and genotype likelihood dimensions are inconsistent")]
28    InvalidLikelihoodDimensions,
29
30    #[error("dependency correlation must be finite and between zero and one")]
31    InvalidDependencyCorrelation,
32
33    #[error("minimum base quality cannot exceed maximum base quality")]
34    InvalidSnpQualityRange,
35
36    #[error("at least one sample is required")]
37    InvalidSampleCount,
38
39    #[error("sample index {index} is outside the configured sample count {count}")]
40    InvalidSampleIndex { index: usize, count: usize },
41
42    #[error("invalid sample name: {0}")]
43    InvalidSampleName(String),
44
45    #[error("sample selection contains a duplicate name: {0}")]
46    DuplicateSampleSelection(String),
47
48    #[error("selected sample is absent from the input: {0}")]
49    MissingSelectedSample(String),
50
51    #[error("call sample input {path}: {message}")]
52    CallSampleInput { path: String, message: String },
53
54    #[error("call sample input {path} line {line}: {message}")]
55    CallSampleRecord {
56        path: String,
57        line: u64,
58        message: String,
59    },
60
61    #[error("likelihood reader configuration must be completed before reading records")]
62    LateLikelihoodReaderConfiguration,
63
64    #[error("alignment source ID {0} is duplicated")]
65    DuplicateAlignmentSource(u32),
66
67    #[error("alignment source ID {0} is unknown")]
68    UnknownAlignmentSource(u32),
69
70    #[error("at least one alignment input is required")]
71    MissingAlignmentInputs,
72
73    #[error("alignment input {path}: {message}")]
74    AlignmentInput { path: String, message: String },
75
76    #[error("reference dictionary in alignment input {0} differs from the first input")]
77    ReferenceDictionaryMismatch(String),
78
79    #[error("invalid region {region}: {message}")]
80    InvalidRegion { region: String, message: String },
81
82    #[error("at least one region is required")]
83    MissingRegions,
84
85    #[error("region input {path}: {message}")]
86    RegionInput { path: String, message: String },
87
88    #[error("region input {path} line {line}: {message}")]
89    RegionRecord {
90        path: String,
91        line: u64,
92        message: String,
93    },
94
95    #[error("target input {path}: {message}")]
96    TargetInput { path: String, message: String },
97
98    #[error("target input {path} line {line}: {message}")]
99    TargetRecord {
100        path: String,
101        line: u64,
102        message: String,
103    },
104
105    #[error("reference input {path}: {message}")]
106    ReferenceInput { path: String, message: String },
107
108    #[error("a FASTA reference is required for {0}")]
109    MissingLikelihoodReference(&'static str),
110
111    #[error("invalid BAQ configuration: {0}")]
112    InvalidBaqConfiguration(&'static str),
113
114    #[error(transparent)]
115    Pileup(#[from] rsomics_pileup::PileupError),
116
117    #[error("invalid or duplicate read-group ID: {0}")]
118    InvalidReadGroup(String),
119
120    #[error("BAM RG field is not a valid Z string")]
121    InvalidReadGroupField,
122
123    #[error("pileup column has an invalid reference coordinate")]
124    InvalidPileupCoordinate,
125
126    #[error("SNP evidence exceeds the supported count range")]
127    SnpEvidenceOverflow,
128
129    #[error("invalid indel likelihood configuration")]
130    InvalidIndelConfig,
131
132    #[error("invalid indel configuration: {0}")]
133    InvalidIndelConfiguration(&'static str),
134
135    #[error("invalid indel site summary")]
136    InvalidIndelSummary,
137
138    #[error("invalid likelihood annotations")]
139    InvalidLikelihoodAnnotations,
140
141    #[error("indel evidence exceeds the supported count range")]
142    IndelEvidenceOverflow,
143
144    #[error("reference data required for indel likelihoods is invalid")]
145    InvalidIndelReference,
146
147    #[error("indel realignment failed")]
148    IndelRealignment,
149
150    #[error("multiallelic mutation rate must be finite and between zero and one")]
151    InvalidMutationRate,
152
153    #[error("consensus reference probability threshold must be finite and between zero and one")]
154    InvalidConsensusThreshold,
155
156    #[error("the consensus caller requires observed compatible likelihoods")]
157    UnsupportedConsensusLikelihoods,
158
159    #[error("the multiallelic caller requires diploid input likelihoods")]
160    UnsupportedLikelihoodPloidy,
161
162    #[error("the caller ploidy count differs from the likelihood sample count")]
163    CallerPloidyCountMismatch,
164
165    #[error("the caller group count differs from the likelihood sample count")]
166    CallerGroupCountMismatch,
167
168    #[error("caller group indices must be contiguous and nonempty")]
169    InvalidCallerGroups,
170
171    #[error("sample groups require the multiallelic calling model")]
172    UnsupportedCallerGroups,
173
174    #[error("the prior chromosome count is outside the cohort ploidy range")]
175    InvalidPriorChromosomeCount,
176
177    #[error("prior allele counts are inconsistent with the site alleles or total")]
178    InvalidPriorAlleleCounts,
179
180    #[error("gVCF depth thresholds must be strictly increasing")]
181    InvalidGvcfThresholds,
182
183    #[error("gVCF input sites are not in reference and coordinate order")]
184    InvalidGvcfOrder,
185
186    #[error("gVCF block sites have different sample counts")]
187    GvcfSampleCountMismatch,
188
189    #[error("present gVCF block likelihoods must contain three diploid values per sample")]
190    InvalidGvcfLikelihoods,
191
192    #[error("gVCF blocks require the multiallelic calling model")]
193    UnsupportedGvcfModel,
194
195    #[error("gVCF input requires a FORMAT/DP definition")]
196    MissingGvcfDepth,
197
198    #[error("called allele count exceeds the supported range")]
199    CalledAlleleCountOverflow,
200
201    #[error("invalid likelihood VCF/BCF: {0}")]
202    InvalidLikelihoodVariant(String),
203
204    #[error("likelihood VCF/BCF input: {0}")]
205    LikelihoodVariantInput(String),
206
207    #[error("likelihood VCF/BCF record {record}: {message}")]
208    LikelihoodVariantRecord { record: u64, message: String },
209
210    #[error("likelihood call record {record}: {source}")]
211    LikelihoodCallRecord { record: u64, source: Box<CallError> },
212
213    #[error("variant VCF/BCF output: {0}")]
214    VariantOutput(String),
215}
216
217pub type Result<T> = std::result::Result<T, CallError>;