use std::path::{Path, PathBuf};
use super::{AvaStrategy, DEFAULT_AVA_NUM_READS};
use crate::Platform;
pub struct Builder {
num_reads: usize,
num_bases: usize,
remove_internal: bool,
max_overhang_ratio: f32,
tmpdir: PathBuf,
threads: usize,
seed: Option<u64>,
platform: Platform,
}
impl Default for Builder {
fn default() -> Self {
let tmpdir = std::env::temp_dir();
Self {
num_reads: DEFAULT_AVA_NUM_READS,
num_bases: 0,
remove_internal: false,
max_overhang_ratio: 0.2,
tmpdir,
threads: 1,
seed: None,
platform: Platform::default(),
}
}
}
impl Builder {
pub fn new() -> Self {
Self::default()
}
pub fn num_reads(mut self, num_reads: usize) -> Self {
self.num_reads = num_reads;
self
}
pub fn remove_internal(mut self, do_filt: bool, ratio: f32) -> Self {
self.remove_internal = do_filt;
if do_filt {
self.max_overhang_ratio = ratio;
}
self
}
pub fn tmpdir<P: AsRef<Path>>(mut self, tmpdir: P) -> Self {
self.tmpdir = tmpdir.as_ref().to_path_buf();
self
}
pub fn threads(mut self, threads: usize) -> Self {
self.threads = threads;
self
}
pub fn seed(mut self, seed: Option<u64>) -> Self {
self.seed = seed;
self
}
pub fn platform(mut self, platform: Platform) -> Self {
self.platform = platform;
self
}
pub fn build<P: AsRef<Path>>(self, input: P) -> AvaStrategy {
AvaStrategy {
input: input.as_ref().to_path_buf(),
num_reads: self.num_reads,
num_bases: self.num_bases,
remove_internal: self.remove_internal,
max_overhang_ratio: self.max_overhang_ratio,
tmpdir: self.tmpdir,
threads: self.threads,
seed: self.seed,
platform: self.platform,
}
}
}