pub enum NumericValue {
U8(u8),
U16(u16),
U32(u32),
F32(u32),
}Expand description
Represents a numeric value in the context of the bcf-reader.
Variants§
U8(u8)
Represents an unsigned 8-bit integer value.
U16(u16)
Represents an unsigned 16-bit integer value.
U32(u32)
Represents an unsigned 32-bit integer value.
F32(u32)
Represents a 32-bit floating-point value. (Note that a u32 is used to hold the bits for the f32 value)
Implementations§
Source§impl NumericValue
impl NumericValue
Sourcepub fn int_val(&self) -> Option<u32>
pub fn int_val(&self) -> Option<u32>
Returns the integer value if the NumericValue is an unsigned integer and not missing.
§Examples
use bcf_reader::NumericValue;
let value = NumericValue::U8(42);
assert_eq!(value.int_val(), Some(42u32));
let missing_value = NumericValue::U8(0x80u8);
assert_eq!(missing_value.int_val(), None);Sourcepub fn float_val(&self) -> Option<f32>
pub fn float_val(&self) -> Option<f32>
Returns the floating-point value if the NumericValue is a 32-bit float and not missing.
§Examples
use bcf_reader::NumericValue;
let value = NumericValue::F32(3.14f32.to_bits());
assert_eq!(value.float_val(), Some(3.14f32));
let missing_value = NumericValue::F32(0x7F800001);
let missing_value2 = NumericValue::F32(0x7F800001);
assert_eq!(missing_value.float_val(), missing_value2.float_val());
dbg!(&missing_value);
assert_eq!(missing_value.float_val(), None);Sourcepub fn gt_val(&self) -> (bool, bool, bool, u32)
pub fn gt_val(&self) -> (bool, bool, bool, u32)
Returns a tuple representing the GT value.
The tuple contains the following elements:
noploidy: A boolean indicating if the ploidy is missing (for individuals with fewer ploids compared to individuals with the maximum ploidy).dot: A boolean indicating if the genotype call is a dot.phased: A boolean indicating if the allele is phased (the first allele of a call is always unphased).allele: The allele value (index).
§Examples
use bcf_reader::NumericValue;
let value = NumericValue::U8(3);
assert_eq!(value.gt_val(), (false, false, true, 0));
let value = NumericValue::U8(5);
assert_eq!(value.gt_val(), (false, false, true, 1));
let missing_value = NumericValue::U8(0);
assert_eq!(missing_value.gt_val(), (false, true, false, u32::MAX));Trait Implementations§
Source§impl Debug for NumericValue
impl Debug for NumericValue
Source§impl Default for NumericValue
impl Default for NumericValue
Source§impl From<u16> for NumericValue
impl From<u16> for NumericValue
Source§impl From<u32> for NumericValue
impl From<u32> for NumericValue
Source§impl From<u8> for NumericValue
impl From<u8> for NumericValue
Source§impl PartialEq for NumericValue
impl PartialEq for NumericValue
impl StructuralPartialEq for NumericValue
Auto Trait Implementations§
impl Freeze for NumericValue
impl RefUnwindSafe for NumericValue
impl Send for NumericValue
impl Sync for NumericValue
impl Unpin for NumericValue
impl UnwindSafe for NumericValue
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more