pub struct Conf { /* private fields */ }
Expand description
Represents a configuration for a flowcell.
Implementations§
Source§impl Conf
impl Conf
Sourcepub fn from_file(toml_path: impl AsRef<Path>) -> Conf
pub fn from_file(toml_path: impl AsRef<Path>) -> Conf
Constructs a new Conf
instance by parsing a TOML file.
This function takes a TOML file path (toml_path
) and reads its contents
using std::fs::read_to_string
. The contents of the TOML file are then
passed to the Conf::new
function to create a new Conf
instance.
§Arguments
toml_path
- The path to the TOML file to be parsed.
§Panics
This function panics if the TOML file cannot be read or if parsing the TOML
content into a Conf
instance fails.
§Examples
use std::path::Path;
let toml_path = Path::new("config.toml");
let conf = Conf::from_file(toml_path);
Sourcepub fn get_conditions<T: AsRef<str> + Debug>(
&self,
channel: usize,
barcode: Option<T>,
) -> Result<(bool, &dyn Condition), String>
pub fn get_conditions<T: AsRef<str> + Debug>( &self, channel: usize, barcode: Option<T>, ) -> Result<(bool, &dyn Condition), String>
Get the condition for a given channel or barcode from the Conf TOML
The barcode should be passed as an optional &str
parameter. If barcoding
is not being done and the barcode is not provided, the channel
will be used instead.
§Arguments
channel
- The channel number for the resultbarcode
- Optional barcode classification from basecalling
§Returns
Ok
- A tuple(bool, &dyn Condition)
representing the control flag and the conditionErr
- AString
containing an error message if the channel/barcode combination does not find aRegion
or aBarcode
§Errors
This function will return an error if both the region (channel) and barcode were not found in the configuration.
Sourcepub fn get_targets(&self, channel: usize, barcode: Option<&str>) -> &Targets
pub fn get_targets(&self, channel: usize, barcode: Option<&str>) -> &Targets
Get the targets associated with a specific channel and barcode (if provided) from the configuration.
This function looks up the given channel
and barcode
(optional) in the configuration and returns the corresponding targets.
If the combination of channel
and barcode
is not found in the configuration, or if the condition associated with the
combination does not have targets, this function will return a reference to the default targets.
§Arguments
channel
: The channel number for the result.barcode
: The optional barcode classification from basecalling. IfSome
, it will be override thechannel
to find the targets.
§Returns
A reference to the Targets
associated with the given channel
and barcode
combination.
If the combination is not found, the function returns a reference to the default targets.
Sourcepub fn make_decision<T: ToString>(
&self,
channel: usize,
barcode: Option<&str>,
contig: &str,
strand: T,
coord: usize,
) -> bool
pub fn make_decision<T: ToString>( &self, channel: usize, barcode: Option<&str>, contig: &str, strand: T, coord: usize, ) -> bool
Make a decision based on the provided inputs for the specified channel and barcode (if provided).
Todo: Write unit tests/integration tests for this function.
This function takes several parameters, including channel
, barcode
, contig
, strand
, and coord
,
and determines whether the given coordinates are considered “on target” or not based on the configuration.
§Arguments
channel
: The channel number associated with the decision-making process.barcode
: The optional barcode classification from basecalling. IfSome
, it will be used along with thechannel
to find the relevant targets.contig
: The name of the contig where the coordinates are located.strand
: The strand information. This can be any type that implements theToString
trait, such as aString
or&str
.coord
: The coordinate position to check against the targets.
§Returns
A boolean value indicating whether the given contig
, strand
, and coord
are considered “on target” or not based on the configuration.
If the combination of channel
and barcode
is not found in the configuration, the function will use the default targets.
§Example
let channel = 1;
let barcode = Some("barcode01");
let contig = "chr1";
let strand = "+";
let coord = 1000;
let decision = conf.make_decision(channel, barcode, contig, strand, coord);
println!("Decision: {}", decision);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Conf
impl RefUnwindSafe for Conf
impl Send for Conf
impl Sync for Conf
impl Unpin for Conf
impl UnwindSafe for Conf
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> 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 more