Skip to content

Commit

Permalink
start of CLI stuff.
Browse files Browse the repository at this point in the history
not doing anything yet
  • Loading branch information
brentp committed Aug 17, 2023
1 parent 73f78b8 commit e2bdcfa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bin/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod command;
pub mod demux;
pub mod trimmer;
58 changes: 58 additions & 0 deletions src/bin/commands/trimmer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use crate::commands::command::Command;
use anyhow::Result;
use clap::Parser;
use log::info;
use std::fs;
use std::path::PathBuf;

/// Trimming and overlap correction of paired-end reads
#[derive(Parser, Debug)]
#[command(version)]
pub(crate) struct Trimmer {
/// Level of compression to use to compress outputs.
#[clap(long, short = 'c', default_value = "5")]
compression_level: usize,

/// Minimum difference in base-quality for one read to correct an overlapping
/// base from the other read.
#[clap(long, short = 'd', default_value = "15")]
overlap_min_bq_delta: usize,

/// Minimum pair overlap length to attempt correction.
#[clap(long, short = 'l', default_value = "50")]
overlap_min_len: usize,

/// Maximum error-rate allowed in the overlap.
#[clap(long, short = 'e', default_value = "0.02")]
overlap_max_error_rate: f64,

/// The output directory into which to FASTQs.
#[clap(long, short = 'o', required = true)]
output: PathBuf,

/// Fastq file for Read1 and Read2
#[clap(required = true, num_args = 2)]
fastqs: PathBuf,
}

impl Trimmer {
fn prepare(&self) -> Result<()> {
if !self.output.exists() {
info!("Output directory {:#?} didn't exist, creating it.", self.output);
fs::create_dir_all(&self.output)?;
}
// see here for pooled writer: https://docs.rs/pooled-writer/0.3.0/pooled_writer/
//
// and https://github.com/fulcrumgenomics/fqtk/blob/ae91e90ecc86826fc632837bb982798a7e6b6f7a/src/bin/commands/demux.rs#L804
// and https://github.com/fulcrumgenomics/fqtk/blob/ae91e90ecc86826fc632837bb982798a7e6b6f7a/src/bin/commands/demux.rs#L850-L851
// for reader
Ok(())
}
}

impl Command for Trimmer {
fn execute(&self) -> Result<()> {
self.prepare()?;
Ok(())
}
}
3 changes: 2 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod commands;
use anyhow::Result;
use clap::Parser;
use commands::command::Command;
use commands::demux::Demux;
use commands::{demux::Demux, trimmer::Trimmer};
use enum_dispatch::enum_dispatch;
use env_logger::Env;

Expand All @@ -23,6 +23,7 @@ struct Args {
#[command(version)]
enum Subcommand {
Demux(Demux),
Trimmer(Trimmer),
}

fn main() -> Result<()> {
Expand Down

0 comments on commit e2bdcfa

Please sign in to comment.