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
71
72
73
74
75
76
77
78
79
80
//! Interpreting variants as drug resistance.
//!
//! Everything above this module is about keeping data straight. This is
//! the one module that says what the data *means*: it takes variant calls
//! against HXB2, works out which amino acids each codon of protease,
//! reverse transcriptase, integrase and capsid holds, and scores them
//! against a vendored Stanford HIVdb algorithm.
//!
//! # The three parts
//!
//! - [`ruleset`] reads a vendored algorithm. The file is derived from
//! Stanford's ASI2 XML, which is committed beside it and pinned by
//! checksum; see `crates/ligase-core/rulesets/README.md`.
//! - [`codon`] turns a reference and a VCF into the amino acids present at
//! each position of each protein. This is where mixtures and coverage
//! are decided.
//! - [`score`] evaluates those amino acids against the algorithm.
//!
//! # Why nothing here reaches the network
//!
//! Stanford runs a web service that does this interpretation. Calling it
//! would make a result depend on the day it was asked for, which no cache
//! key can see and no bundle can reproduce. The algorithm is vendored
//! instead, version and date and checksum and all, so a run from 2026
//! and a rerun in 2030 agree or explain themselves.
pub use ;
pub use ;
pub use ;
use Path;
use crateLoadError;
/// Interpret one sample's calls and write the report.
///
/// This is the whole of what a `resistance` step does: read the
/// reference and the calls into amino acids, score them against a
/// vendored algorithm, and write the result.
///
/// # Arguments
///
/// - `reference` — the FASTA the variants were called against. Codons
/// cannot be named without it: a VCF holds only the positions that
/// differ, and two of the three bases of a codon are usually not among
/// them.
/// - `variants` — the calls.
/// - `alignment` — the BAM they were called from, for coverage. Without
/// it the report says, in a note, that it is treating every uncalled
/// position as reference.
/// - `algorithm` — which vendored algorithm to use, e.g. `HIVDB_9.8`.
/// - `mixture` — the fraction an allele must reach to count as present.
/// - `depth` — the depth a position must reach to count as read.
///
/// # Errors
///
/// If a file cannot be read, the algorithm is not one this engine ships,
/// or a score falls outside the algorithm's own ranges.