#[non_exhaustive]pub struct InputMods<S: TagState + Args + FromArgMatches + Default> {
pub tag: S,
pub mod_strand: Option<RestrictModCalledStrand>,
pub mod_prob_filter: ThresholdState,
pub trim_read_ends_mod: usize,
pub base_qual_filter_mod: u8,
pub mod_region: Option<GenomicRegion>,
pub region_bed3: Option<Bed3<i32, u64>>,
}Expand description
This struct contains the options input to our modification-data functions with restrictions on data received.
If you want to build this, use InputModsBuilder.
In CLI mode, clap populates this struct.
This and the InputBam struct are used to set almost all input options
to many of our functions that process BAM/modBAM files.
§Examples
Please look at the documentation of InputBam to see a fully-worked
example to set up inputs to perform a calculation.
Following example uses many fields and is for a RequiredTag variant.
You can omit some of them depending on your use case. mod_region must
can be converted to region_bed3 using GenomicRegion::try_to_bed3
with a suitable BAM header before this struct can be used with most of
our functions. We do not force this in the builder route as we may not
want to do this for some reason.
use nanalogue_core::{InputModsBuilder, Error, RequiredTag, ThresholdState};
use std::str::FromStr;
let input_options = InputModsBuilder::default()
.tag(RequiredTag::from_str("m")?)
.mod_strand("bc".into())
.mod_prob_filter(ThresholdState::GtEq(0))
.trim_read_ends_mod(10)
.base_qual_filter_mod(10)
.mod_region("chr3:4000-5000".into())
.build()?;
A RequiredTag variant that sets region_bed3 instead of mod_region.
If mod_region is set, then a downstream function must parse a BAM file,
and then convert mod_region into region_bed3 using the header.
If the user is confident that they know the index number of a contig,
then they can directly set region_bed3. In the example below, the user
knows chr3 corresponds to 4, so they set the region directly.
use bedrs::prelude::Bed3;
use nanalogue_core::{InputModsBuilder, Error, RequiredTag, ThresholdState};
use std::str::FromStr;
let input_options = InputModsBuilder::<RequiredTag>::default()
.tag(RequiredTag::from_str("m")?)
.mod_strand("bc".into())
.mod_prob_filter(ThresholdState::GtEq(0))
.trim_read_ends_mod(10)
.base_qual_filter_mod(10)
.region_bed3(Bed3::<i32, u64>::new(4, 4000, 5000))
.build()?;
Setting both region_bed3 and mod_region should result in an error,
even if they both refer to the same region. This is because setting both
can result in an undefined state, so we do not allow this.
use bedrs::prelude::Bed3;
use nanalogue_core::{InputModsBuilder, Error, RequiredTag, ThresholdState};
use std::str::FromStr;
let input_options = InputModsBuilder::<RequiredTag>::default()
.mod_prob_filter(ThresholdState::GtEq(0))
.region_bed3(Bed3::<i32, u64>::new(4, 4000, 5000))
.mod_region("chr3:4000-5000".into())
.build()?;
Following example is for an OptionalTag variant with the tag omitted,
and many other fields omitted as well, which take on a default value.
use nanalogue_core::{InputModsBuilder, Error, OptionalTag, ThresholdState};
use std::str::FromStr;
let input_options = InputModsBuilder::<OptionalTag>::default()
.mod_prob_filter(ThresholdState::GtEq(0))
.build()?;
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tag: Smodified tag
mod_strand: Option<RestrictModCalledStrand>modified strand, set this to bc or bc_comp, meaning
on basecalled strand or its complement. Some technologies
like PacBio or ONT duplex can call mod data on both a strand
and its complementary DNA and store it in the record corresponding
to the strand, so you can use this filter to select only for
mod data on a strand or its complement. Please note that this
filter is different from selecting for forward or reverse
aligned reads using the BAM flags.
mod_prob_filter: ThresholdStateFilter to reject mods before analysis. Specify as low,high where both are fractions to reject modifications where the probabilities (p) are in this range e.g. “0.4,0.6” rejects 0.4 <= p <= 0.6. You can use this to reject ‘weak’ modification calls before analysis i.e. those with probabilities close to 0.5. NOTE: (1) Whether this filtration is applied or not, mods < 0.5 are considered unmodified and >= 0.5 are considered modified by our program. (2) mod probabilities are stored as a number from 0-255 in the modBAM format, so we internally convert 0.0-1.0 to 0-255. Default: reject nothing.
trim_read_ends_mod: usizeFilter this many bp at the start and end of a read before any mod operations. Please note that the units here are bp and not units of base being queried.
base_qual_filter_mod: u8Exclude bases whose base quality is below this threshold before any mod operation, defaults to 0 i.e. unused. NOTE: (1) This step is only applied before modification operations, and not before any other operations. (2) No offsets such as +33 are needed here. (3) Modifications on reads where base quality information is not available are all rejected if this is non-zero.
mod_region: Option<GenomicRegion>Only keep modification data from this region
region_bed3: Option<Bed3<i32, u64>>Only keep modification data from this region. We do not expose this to the user, but infer it from the other options set by the user. We cannot populate this directly at the time of CLI parsing, as we need to look at the BAM header to convert a contig name into a numeric contig id.
Implementations§
Source§impl InputMods<RequiredTag>
can return tag without encasing in an option in the RequiredTag variant
impl InputMods<RequiredTag>
can return tag without encasing in an option in the RequiredTag variant
Sourcepub fn required_tag(&self) -> ModChar
pub fn required_tag(&self) -> ModChar
retrieves tag
Trait Implementations§
Source§impl<S: TagState + Args + FromArgMatches + Default> Args for InputMods<S>
impl<S: TagState + Args + FromArgMatches + Default> Args for InputMods<S>
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl<S: TagState + Args + FromArgMatches + Default> Default for InputMods<S>
Implements defaults for InputMods
impl<S: TagState + Args + FromArgMatches + Default> Default for InputMods<S>
Implements defaults for InputMods
Source§impl<'de, S> Deserialize<'de> for InputMods<S>
impl<'de, S> Deserialize<'de> for InputMods<S>
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<S: TagState + Args + FromArgMatches + Default> FromArgMatches for InputMods<S>
impl<S: TagState + Args + FromArgMatches + Default> FromArgMatches for InputMods<S>
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl<S: TagState + Args + FromArgMatches + Default> InputModOptions for InputMods<S>
impl<S: TagState + Args + FromArgMatches + Default> InputModOptions for InputMods<S>
Source§fn mod_strand(&self) -> Option<RestrictModCalledStrand>
fn mod_strand(&self) -> Option<RestrictModCalledStrand>
Source§fn mod_prob_filter(&self) -> ThresholdState
fn mod_prob_filter(&self) -> ThresholdState
Source§fn trim_read_ends_mod(&self) -> usize
fn trim_read_ends_mod(&self) -> usize
Source§fn base_qual_filter_mod(&self) -> u8
fn base_qual_filter_mod(&self) -> u8
Source§impl<S: TagState + Args + FromArgMatches + Default> InputRegionOptions for InputMods<S>
impl<S: TagState + Args + FromArgMatches + Default> InputRegionOptions for InputMods<S>
Source§fn region_filter_genomic_string(&self) -> Option<GenomicRegion>
fn region_filter_genomic_string(&self) -> Option<GenomicRegion>
Source§fn is_full_overlap(&self) -> bool
fn is_full_overlap(&self) -> bool
Source§fn convert_region_to_bed3(&mut self, header: HeaderView) -> Result<(), Error>
fn convert_region_to_bed3(&mut self, header: HeaderView) -> Result<(), Error>
Auto Trait Implementations§
impl<S> Freeze for InputMods<S>where
S: Freeze,
impl<S> RefUnwindSafe for InputMods<S>where
S: RefUnwindSafe,
impl<S> Send for InputMods<S>where
S: Send,
impl<S> Sync for InputMods<S>where
S: Sync,
impl<S> Unpin for InputMods<S>where
S: Unpin,
impl<S> UnwindSafe for InputMods<S>where
S: UnwindSafe,
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.