use clap::Args;
mod convert;
mod split;
mod squeeze;
mod subsample;
mod subset;
pub use convert::*;
pub use split::*;
pub use squeeze::*;
pub use subsample::*;
pub use subset::*;
#[derive(Args, Debug)]
pub struct ReorderRowsArgs {
pub data_file: Box<str>,
#[arg(short, long, required = true)]
pub row_file: Box<str>,
#[arg(short, long, required = true)]
pub output: Box<str>,
#[arg(long = "no-zip", default_value_t = true, action = clap::ArgAction::SetFalse)]
pub zip: bool,
}
#[derive(Args, Debug)]
pub struct SubsetColumnsArgs {
pub data_file: Box<str>,
#[arg(short = 'i', long, value_delimiter = ',')]
pub column_indices: Option<Vec<usize>>,
#[arg(short = 'f', long)]
pub name_file: Option<Box<str>>,
#[arg(short = 'd', long, default_value = "@")]
pub delimiter: char,
#[arg(long, default_value_t = true)]
pub allow_prefix: bool,
#[arg(long, default_value_t = false)]
pub exact_names: bool,
#[arg(long, default_value_t = false)]
pub do_squeeze: bool,
#[arg(long, default_value_t = 1)]
pub row_nnz_cutoff: usize,
#[arg(long, default_value_t = 1)]
pub column_nnz_cutoff: usize,
#[arg(short, long, required = true)]
pub output: Box<str>,
#[arg(long = "no-zip", default_value_t = true, action = clap::ArgAction::SetFalse)]
pub zip: bool,
}
#[derive(Args, Debug)]
pub struct SubsetRowsArgs {
pub data_file: Box<str>,
#[arg(short = 'i', long, value_delimiter = ',')]
pub row_indices: Option<Vec<usize>>,
#[arg(short = 'f', long)]
pub name_file: Option<Box<str>>,
#[arg(short = 'd', long, default_value = "@")]
pub delimiter: char,
#[arg(long, default_value_t = true)]
pub allow_prefix: bool,
#[arg(long, default_value_t = false)]
pub exact_names: bool,
#[arg(long, default_value_t = false)]
pub do_squeeze: bool,
#[arg(long, default_value_t = 1)]
pub row_nnz_cutoff: usize,
#[arg(long, default_value_t = 1)]
pub column_nnz_cutoff: usize,
#[arg(short, long, required = true)]
pub output: Box<str>,
#[arg(long = "no-zip", default_value_t = true, action = clap::ArgAction::SetFalse)]
pub zip: bool,
}
#[derive(Args, Debug)]
#[command(about)]
pub struct RunSqueezeArgs {
#[arg(required = true, value_delimiter = ',')]
pub data_files: Vec<Box<str>>,
#[arg(short, long, default_value = "0")]
pub row_nnz_cutoff: usize,
#[arg(short, long, default_value = "0")]
pub column_nnz_cutoff: usize,
#[arg(long)]
pub block_size: Option<usize>,
#[arg(
long = "no-preload",
alias = "no-preload-data",
default_value_t = true,
action = clap::ArgAction::SetFalse,
help = "Skip preloading; stream reads instead (preloading is the default)",
long_help = "Skip preloading column data into memory before squeezing.\n\
Preloading (the default) is faster but costs 12 bytes per\n\
non-zero, and is skipped automatically over the\n\
LEGUME_PRELOAD_BUDGET_BYTES budget."
)]
pub preload: bool,
#[arg(
long,
default_value_t = false,
help = "Show ASCII histogram of row/column nnz distributions",
long_help = "Display log1p-transformed ASCII histograms.\n\
They cover row and column non-zero counts, before squeezing.\n\
Use them to pick appropriate cutoff values."
)]
pub show_histogram: bool,
#[arg(
long,
help = "Output file prefix for saving histogram data",
long_help = "Save histogram data to {prefix}.row_nnz.txt and {prefix}.col_nnz.txt files.\n\
Each file contains nnz counts that can be used for further analysis."
)]
pub save_histogram: Option<Box<str>>,
#[arg(
long,
default_value_t = false,
help = "Preview mode - show histograms without squeezing",
long_help = "Only display histograms and statistics without actually performing the squeeze operation.\n\
Useful for determining appropriate cutoff values."
)]
pub dry_run: bool,
#[arg(
short,
long,
default_value_t = false,
help = "Interactive mode - ask for confirmation after showing histogram",
long_help = "Show histogram and prompt user to proceed, adjust cutoffs, or cancel.\n\
Automatically enables --show-histogram."
)]
pub interactive: bool,
#[arg(
long,
default_value_t = false,
help = "Apply the suggested (histogram trough) nnz cutoff headlessly (no prompt)",
long_help = "Resolve row and column cutoffs automatically, then squeeze.\n\
The cutoffs sit at the trough of the log(1+nnz) histogram. No prompt is shown.\n\
\n\
Explicit --row-nnz-cutoff and --column-nnz-cutoff still win,\n\
per dimension. So you can pin one axis and auto the other.\n\
Combine with --dry-run to preview the cutoffs without writing."
)]
pub auto_cutoff: bool,
#[arg(
short,
long,
help = "Output file for squeezed data",
long_help = "Save squeezed data to a new file instead of modifying in-place.\n\
With multiple inputs,\n\
all files will be squeezed and merged into {output}.{backend}.\n\
If not specified,\n\
modifies files in-place (requires confirmation in interactive mode)."
)]
pub output: Option<Box<str>>,
#[arg(long = "no-zip", default_value_t = true, action = clap::ArgAction::SetFalse)]
pub zip: bool,
#[arg(
long,
value_enum,
default_value = "common",
help = "Row alignment strategy when merging multiple files",
long_help = "How to align rows across files after squeezing:\n\
- common: Keep only rows present in ALL files (intersection)\n\
- union: Keep rows present in ANY file (union, fills missing with zeros)"
)]
pub row_align: RowAlignMode,
}
#[derive(clap::ValueEnum, Clone, Debug, PartialEq)]
#[clap(rename_all = "lowercase")]
pub enum RowAlignMode {
Common,
Union,
}