pub struct ModChar(/* private fields */);Expand description
Our struct to hold a modification tag.
The BAM file format uses the syntax base+mod_code in its ML tag
to show which modification is represented e.g. C+m, A+a, T+T, …
This can be a letter or a number e.g. T+472232 represents BrdU as that is its CheBI code.
As we rely on a fibertools-rs data structure to store mod information (BaseMod),
which uses a char datatype to represent the mod code, representing a one letter
mod code is easy, but numbers need to be converted to char first.
Fortunately, rust’s char datatype is almost equivalent to u32, so we just
convert numbers to char before storing.
NOTE: the above conversion has some problems e.g. A+a is equivalent to A+97 etc.
(as 97 is the ascii code of a),
and the rust char datatype does not allow a set of u32s somewhere between 55000
and 59000. We have chosen to live with this problem. I think the probability of
having a DNA modification with a CheBI code overlapping with ASCII values or
within this narrow range of values near 59000 is very small.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModChar
impl<'de> Deserialize<'de> for ModChar
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 FromStr for ModChar
impl FromStr for ModChar
Source§fn from_str(mod_type: &str) -> Result<Self, Self::Err>
fn from_str(mod_type: &str) -> Result<Self, Self::Err>
process the modification type from a string, returning the first character if it is a letter, or converting it to a character if the first character is a number
use nanalogue_core::ModChar;
use std::str::FromStr;
// Single letter modification codes
let mod_char = ModChar::from_str("m")?;
assert_eq!(mod_char.val(), 'm');// CheBI code for BrdU (5-bromo-2'-deoxyuridine)
let mod_char = ModChar::from_str("472232")?;// Small numeric codes
let mod_char = ModChar::from_str("123")?;// Invalid: starts with special character
let mod_char = ModChar::from_str("@123")?;Source§impl Ord for ModChar
impl Ord for ModChar
Source§impl PartialOrd for ModChar
impl PartialOrd for ModChar
impl Copy for ModChar
impl Eq for ModChar
impl StructuralPartialEq for ModChar
Auto Trait Implementations§
impl Freeze for ModChar
impl RefUnwindSafe for ModChar
impl Send for ModChar
impl Sync for ModChar
impl Unpin for ModChar
impl UnwindSafe for ModChar
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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.