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
81
82
83
84
85
86
87
88
89
90
91
92
//! Functions for calculating the score of a given alignment in a pHMM.
use crate::alignment::{
AlignmentStates,
phmm::{DomainPhmm, GlobalPhmm, LocalPhmm, PhmmError, PhmmNumber, SemiLocalPhmm},
};
use std::ops::Range;
impl<T: PhmmNumber, const S: usize> GlobalPhmm<T, S> {
/// Get the score for a particular alignment.
///
/// This is designed to give the exact same score as [`viterbi`] when the
/// best `alignment` is passed, performing all arithmetic operations in the
/// same order so as not to change the floating point error.
///
/// ## Errors
///
/// The CIGAR string must consume the entire model and sequence, and the
/// only supported operations are M, =, X, I, and D.
///
/// [`viterbi`]: GlobalPhmm::viterbi
pub fn score_from_path<Q: AsRef<[u8]>>(&self, seq: Q, alignment: &AlignmentStates) -> Result<T, PhmmError> {
self.visit_params(seq, alignment, |_| {})
}
}
impl<T: PhmmNumber, const S: usize> LocalPhmm<T, S> {
/// Get the best score for a particular alignment.
///
/// The score may be infinite if no paths have a nonzero probability. This
/// is designed to give the exact same score as [`viterbi`] when the best
/// `path` is passed, performing all arithmetic operations in the same order
/// so as not to change the floating point error.
///
/// ## Errors
///
/// The CIGAR string must consume the entire model and sequence, and the
/// only supported operations are M, =, X, I, and D. If `path` does not
/// correspond to a valid path through a [`LocalPhmm`], then
/// [`PhmmError::InvalidPath`] is returned.
///
/// [`viterbi`]: LocalPhmm::viterbi
pub fn score_from_path<Q: AsRef<[u8]>>(
&self, seq: Q, alignment: &AlignmentStates, ref_range: Range<usize>,
) -> Result<T, PhmmError> {
self.visit_params(seq, alignment, ref_range, |_| {})
}
}
impl<T: PhmmNumber, const S: usize> DomainPhmm<T, S> {
/// Get the best score for a particular alignment.
///
/// The score may be infinite if no paths have a nonzero probability. This
/// is designed to give the exact same score as [`viterbi`] when the best
/// `path` is passed, performing all arithmetic operations in the same order
/// so as not to change the floating point error.
///
/// ## Errors
///
/// The CIGAR string must consume the entire model and sequence, and the
/// only supported operations are M, =, X, I, and D. If `path` does not
/// correspond to a valid path through a [`DomainPhmm`], then
/// [`PhmmError::InvalidPath`] is returned.
///
/// [`viterbi`]: DomainPhmm::viterbi
pub fn score_from_path<Q: AsRef<[u8]>>(&self, seq: Q, alignment: &AlignmentStates) -> Result<T, PhmmError> {
self.visit_params(seq, alignment, |_| {})
}
}
impl<T: PhmmNumber, const S: usize> SemiLocalPhmm<T, S> {
/// Get the best score for a particular path. The score may be infinite if
/// no paths have a nonzero probability.
///
/// This is designed to give the exact same score as [`viterbi`] when the
/// best `path` is passed, performing all arithmetic operations in the same
/// order so as not to change the floating point error.
///
/// ## Errors
///
/// The CIGAR string must consume the entire model and sequence, and the
/// only supported operations are M, =, X, I, and D. If `path` does not
/// correspond to a valid path through a [`LocalPhmm`], then
/// [`PhmmError::InvalidPath`] is returned.
///
/// [`viterbi`]: LocalPhmm::viterbi
pub fn score_from_path<Q: AsRef<[u8]>>(
&self, seq: Q, alignment: &AlignmentStates, ref_range: Range<usize>,
) -> Result<T, PhmmError> {
self.visit_params(seq, alignment, ref_range, |_| {})
}
}