#[non_exhaustive]pub enum ThresholdState {
GtEq(u8),
InvertGtEqLtEq(OrdPair<u8>),
Both((u8, OrdPair<u8>)),
}Expand description
Types of thresholds on modification level that can be applied to modification data. Two possible use cases: (1) to specify that reading mod data should be restricted to bases at least this level of modified, or (2) to specify that only bases in this range should be regarded as modified. Values are 0 to 255 below as that’s how they are stored in a modBAM file and this struct is expected to be used in contexts dealing directly with this data.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
GtEq(u8)
modification probability >= this value, values are 0 to 255
InvertGtEqLtEq(OrdPair<u8>)
modification probability not within this range. We expect this to be used to filter out modification calls around 0.5 i.e. ones with the most uncertainty, although users of this crate are free to set this to an interval not including 0.5
Both((u8, OrdPair<u8>))
modification probability >= first value, and mod prob not within the second range i.e. the ‘and’ combination of the two possibilities above
Implementations§
Source§impl ThresholdState
impl ThresholdState
Sourcepub fn from_str_ordpair_fraction(value: &str) -> Result<ThresholdState, Error>
pub fn from_str_ordpair_fraction(value: &str) -> Result<ThresholdState, Error>
Converts a pair of fractions e.g. “0.4,0.6” into a ThresholdState::InvertGtEqLtEq, and
an empty string to the all-permitted ThresholdState::GtEq(0).
Used to set up a filter to reject mod calls whose probabilities lie in a band. This can be used to reject low-quality calls for example which lie around 0.5.
We’ve elected to not write a std::str::FromStr implementation for ThresholdState
as the enum is quite complex, generating it from a string is not very user friendly.
§Errors
String not empty and not in the format of low,high where low and high are numbers from 0 to 1, both included
§Examples
Simple example
use nanalogue_core::ThresholdState;
let a = ThresholdState::from_str_ordpair_fraction("0.4,0.6")?;
assert_eq!(a, ThresholdState::InvertGtEqLtEq((102u8, 153u8).try_into()?));Empty string should generate no filter
use nanalogue_core::ThresholdState;
let a = ThresholdState::from_str_ordpair_fraction("")?;
assert_eq!(a, ThresholdState::GtEq(0));Trait Implementations§
Source§impl Clone for ThresholdState
impl Clone for ThresholdState
Source§fn clone(&self) -> ThresholdState
fn clone(&self) -> ThresholdState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Contains<u8> for ThresholdState
Check if a given u8 is within the interval covered
impl Contains<u8> for ThresholdState
Check if a given u8 is within the interval covered
Example 1:
use nanalogue_core::{Error, OrdPair, ThresholdState, Contains};
let b = ThresholdState::GtEq(100);
assert!(b.contains(&101));
assert!(b.contains(&100));
assert!(!b.contains(&99));
assert!(!b.contains(&0));Example 2:
let b = ThresholdState::InvertGtEqLtEq(OrdPair::new(200, 220).expect("no error"));
assert!(b.contains(&0));
assert!(b.contains(&100));
assert!(!b.contains(&200));
assert!(!b.contains(&210));
assert!(!b.contains(&220));
assert!(b.contains(&250));Example 3:
let b = ThresholdState::Both((100, OrdPair::new(200, 220).expect("no error")));
assert!(!b.contains(&0));
assert!(!b.contains(&99));
assert!(b.contains(&100));
assert!(b.contains(&101));
assert!(!b.contains(&200));
assert!(!b.contains(&210));
assert!(!b.contains(&220));
assert!(b.contains(&250));Source§impl Debug for ThresholdState
impl Debug for ThresholdState
Source§impl Default for ThresholdState
default threshold is >= 0 i.e. all mods are allowed
impl Default for ThresholdState
default threshold is >= 0 i.e. all mods are allowed
Source§impl<'de> Deserialize<'de> for ThresholdState
impl<'de> Deserialize<'de> for ThresholdState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ThresholdState
Displays thresholds but using floating point numbers between 0 and 1
impl Display for ThresholdState
Displays thresholds but using floating point numbers between 0 and 1
Example 1:
use nanalogue_core::{ThresholdState, OrdPair};
let b = ThresholdState::GtEq(100);
assert_eq!("probabilities >= 0.3922", format!("{}", b));Example 2:
let b = ThresholdState::InvertGtEqLtEq(OrdPair::new(200, 220).expect("no error"));
assert_eq!("probabilities < 0.7843 or > 0.8627", format!("{}", b));Example 3:
let b = ThresholdState::Both((100, OrdPair::new(200, 220).expect("no error")));
assert_eq!("probabilities >= 0.3922 and (probabilities < 0.7843 or > 0.8627)", format!("{}", b));Source§impl From<OrdPair<F32Bw0and1>> for ThresholdState
Converts from OrdPair<F32Bw0and1> to ThresholdState::InvertGtEqLtEq
impl From<OrdPair<F32Bw0and1>> for ThresholdState
Converts from OrdPair<F32Bw0and1> to ThresholdState::InvertGtEqLtEq
Example
use nanalogue_core::{F32Bw0and1, OrdPair, ThresholdState};
use std::str::FromStr;
let b: ThresholdState = OrdPair::<F32Bw0and1>::from_str("0.4,0.6")?.into();
assert_eq!(b, ThresholdState::InvertGtEqLtEq(OrdPair::<u8>::new(102u8, 153u8)?));Source§fn from(value: OrdPair<F32Bw0and1>) -> Self
fn from(value: OrdPair<F32Bw0and1>) -> Self
Source§impl PartialEq for ThresholdState
impl PartialEq for ThresholdState
Source§impl Serialize for ThresholdState
impl Serialize for ThresholdState
impl Copy for ThresholdState
impl StructuralPartialEq for ThresholdState
Auto Trait Implementations§
impl Freeze for ThresholdState
impl RefUnwindSafe for ThresholdState
impl Send for ThresholdState
impl Sync for ThresholdState
impl Unpin for ThresholdState
impl UnwindSafe for ThresholdState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.