Struct Conf

Source
pub struct Conf { /* private fields */ }
Expand description

Represents a configuration for a flowcell.

Implementations§

Source§

impl Conf

Source

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);
Source

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 result
  • barcode - Optional barcode classification from basecalling
§Returns
  • Ok - A tuple (bool, &dyn Condition) representing the control flag and the condition
  • Err - A String containing an error message if the channel/barcode combination does not find a Region or a Barcode
§Errors

This function will return an error if both the region (channel) and barcode were not found in the configuration.

Source

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. If Some, it will be override the channel 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.

Source

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. If Some, it will be used along with the channel 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 the ToString trait, such as a String 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§

Source§

impl Debug for Conf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,