Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI development #28

Merged
merged 22 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/deploy/build_aarch64-apple-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ echo "linker = \"aarch64-apple-darwin22-gcc\"" >> .cargo/config.toml
export CC="aarch64-apple-darwin22-gcc"
export CXX="aarch64-apple-darwin22-g++"

RUSTFLAGS='-L /osxcross/SDK/MacOSX13.0.sdk/usr/lib' cargo build --release --target aarch64-apple-darwin
RUSTFLAGS='-L /osxcross/SDK/MacOSX13.0.sdk/usr/lib' cargo build --all-features --release --target aarch64-apple-darwin

## gather the stuff to distribute
target=sablast-candidate-aarch64-apple-darwin
Expand All @@ -45,7 +45,7 @@ cp LICENSE-APACHE $path/
cp LICENSE-MIT $path/
cd /io/tmp
tar -zcvf $target.tar.gz $target
sha256sum $target.tar.gz > $target".sha256sum"
sha256sum $target.tar.gz > $target".tar.gz.sha256sum"
mv $target.tar.gz /io/
mv $target".sha256sum" /io/
mv $target".tar.gz.sha256sum" /io/
cd /io/
6 changes: 3 additions & 3 deletions .github/deploy/build_x86_64-apple-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ echo "linker = \"x86_64-apple-darwin22-gcc\"" >> .cargo/config.toml
export CC="x86_64-apple-darwin22-gcc"
export CXX="x86_64-apple-darwin22-g++"

RUSTFLAGS='-L /osxcross/SDK/MacOSX13.0.sdk/usr/lib' cargo build --release --target x86_64-apple-darwin
RUSTFLAGS='-L /osxcross/SDK/MacOSX13.0.sdk/usr/lib' cargo build --all-features --release --target x86_64-apple-darwin

## gather the stuff to distribute
target=sablast-candidate-x86_64-apple-darwin
Expand All @@ -45,7 +45,7 @@ cp LICENSE-APACHE $path/
cp LICENSE-MIT $path/
cd /io/tmp
tar -zcvf $target.tar.gz $target
sha256sum $target.tar.gz > $target".sha256sum"
sha256sum $target.tar.gz > $target".tar.gz.sha256sum"
mv $target.tar.gz /io/
mv $target".sha256sum" /io/
mv $target".tar.gz.sha256sum" /io/
cd /io/
5 changes: 1 addition & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ jobs:
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}

- name: Build binary
run: cargo build --verbose
run: cargo build --features cli --verbose

- name: Run unit and integration tests
run: cargo test --no-fail-fast --verbose

- name: Run documenation examples as tests
run: cargo test --doc --verbose
1 change: 1 addition & 0 deletions .github/workflows/build_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
ARCHIVE_TYPES: tar.gz
ARCHIVE_NAME: sablast-candidate-x86_64-unknown-linux-musl
RUSTTARGET: x86_64-unknown-linux-musl
EXTRA_FEATURES: "cli"
EXTRA_FILES: "COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md"
TOOLCHAIN_VERSION: stable-2024-09-05
UPLOAD_MODE: none
Expand Down
32 changes: 22 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sablast"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
rust-version = "1.77.0"
authors = ["Tommi Mäklin <[email protected]>"]
Expand All @@ -12,24 +12,36 @@ license = "MIT OR Apache-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
cli = ["dep:needletail", "dep:clap", "dep:rayon", "dep:log", "dep:stderrlog"]

[[bin]]
name = "sablast"
path = "src/cli/main.rs"
required-features = ["cli"]

[dependencies]
## core
# TODO Re-enable reading compressed sequences in needletail
# This requires resolving the libllzma linker issue in build_artifacts.yml
needletail = { version = "0.5.1", default-features = false }
rayon = "1"
sbwt = "0.3.1"

## cli
clap = { version = "4", features = ["derive"] }
clap = { version = "4", features = ["derive"], optional = true}

### io
#### TODO Re-enable reading compressed sequences in needletail
tmaklin marked this conversation as resolved.
Show resolved Hide resolved
##### This requires resolving the libllzma linker issue in build_artifacts.yml
needletail = { version = "0.5.1", default-features = false, optional = true }

### logging
log = { version = "0.4.20", optional = true }
stderrlog = { version = "0.6.0", optional = true }

### threading
rayon = { version = "1", optional = true }

## docs
embed-doc-image="0.1.4"

## logging
log = "0.4.20"
stderrlog = "0.6.0"

[dev-dependencies]
## tests
assert_approx_eq = "1"
Expand Down
90 changes: 51 additions & 39 deletions src/cli.rs → src/cli/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,125 +16,137 @@ use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(version)]
#[command(propagate_version = true)]
#[cfg(feature = "cli")]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
}

#[derive(Subcommand)]
#[cfg(feature = "cli")]
pub enum Commands {
// Build SBWT index
Build {
// Input fasta or fastq sequence file(s)
#[arg(group = "input", required = true)]
seq_files: Vec<String>,

// Outputs
// Outputs
#[arg(short = 'o', long = "output-prefix", required = false, help_heading = "Output")]
output_prefix: Option<String>,

// Build parameters
// // k-mer size
// Build parameters
// // k-mer size
#[arg(short = 'k', default_value_t = 31, help_heading = "Build options")]
kmer_size: usize,
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
prefix_precalc: usize,
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
dedup_batches: bool,

// Resources
// // Threads
// // Threads
#[arg(short = 't', long = "threads", default_value_t = 1)]
num_threads: usize,
// // Memory in GB
// // Memory in GB
#[arg(short = 'm', long = "mem-gb", default_value_t = 4, help_heading = "Build options")]
mem_gb: usize,
// // Temporary directory
// // Temporary directory
#[arg(long = "temp-dir", required = false, help_heading = "Build options")]
temp_dir: Option<String>,

// Verbosity
// Verbosity
#[arg(long = "verbose", default_value_t = false)]
verbose: bool,
},

// Find indexed k-mers in a query
Find {
// Input fasta or fastq query file(s)
// Input fasta or fastq query file(s)
#[arg(group = "input", required = true)]
query_files: Vec<String>,

// Reference
// // Sequence file
// Reference
// // Sequence file
#[arg(short = 'r', long = "reference", group = "reference", help_heading = "Input")]
ref_file: Option<String>,
// // ... or a prebuilt index
// // ... or a prebuilt index
#[arg(short = 'i', long = "index", group = "reference", help_heading = "Input")]
index_prefix: Option<String>,

// Resources
// // Threads
// Parameters
// // Upper bound for random match probability
#[arg(long = "max-error-prob", default_value_t = 0.0000001, help_heading = "Algorithm")]
max_error_prob: f64,

// Resources
// // Threads
#[arg(short = 't', long = "threads", default_value_t = 1)]
num_threads: usize,

// Build parameters
// // k-mer size
// Build parameters
// // k-mer size
#[arg(short = 'k', default_value_t = 31, help_heading = "Build options")]
kmer_size: usize,
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
prefix_precalc: usize,
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
dedup_batches: bool,
// // Memory in GB
// // Memory in GB
#[arg(short = 'm', long = "mem-gb", default_value_t = 4, help_heading = "Build options")]
mem_gb: usize,
// // Temporary directory
// // Temporary directory
#[arg(long = "temp-dir", required = false, help_heading = "Build options")]
temp_dir: Option<String>,


// Verbosity
// Verbosity
#[arg(long = "verbose", default_value_t = false)]
verbose: bool,
},

// Map a query or queries to a reference and return the alignment
Map {
// Input fasta or fastq query file(s)
// Input fasta or fastq query file(s)
#[arg(group = "input", required = true)]
query_files: Vec<String>,

// Reference fasta
// Reference fasta
#[arg(short = 'r', long = "reference", required = true, help_heading = "Input")]
ref_file: String,

// Resources
// // Threads
// Parameters
// // Upper bound for random match probability
#[arg(long = "max-error-prob", default_value_t = 0.0000001, help_heading = "Algorithm")]
max_error_prob: f64,

// Resources
// // Threads
#[arg(short = 't', long = "threads", default_value_t = 1)]
num_threads: usize,

// Build parameters
// // k-mer size
// Build parameters
// // k-mer size
#[arg(short = 'k', default_value_t = 31, help_heading = "Build options")]
kmer_size: usize,
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
// // prefix precalc
#[arg(short = 'p', long = "prefix-precalc", default_value_t = 8, help_heading = "Build options")]
prefix_precalc: usize,
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
// // deduplicate k-mer batches
#[arg(short = 'd', long = "dedup-batches", default_value_t = false, help_heading = "Build options")]
dedup_batches: bool,
// // Memory in GB
// // Memory in GB
#[arg(short = 'm', long = "mem-gb", default_value_t = 4, help_heading = "Build options")]
mem_gb: usize,
// // Temporary directory
// // Temporary directory
#[arg(long = "temp-dir", required = false, help_heading = "Build options")]
temp_dir: Option<String>,

// Verbosity
// Verbosity
#[arg(long = "verbose", default_value_t = false)]
verbose: bool,
},
Expand Down
Loading
Loading