diff --git a/kr2r/src/args.rs b/kr2r/src/args.rs index 1fd7f8c..308a451 100644 --- a/kr2r/src/args.rs +++ b/kr2r/src/args.rs @@ -19,11 +19,11 @@ pub struct Build { /// Kraken 2 hash table filename #[clap(short = 'H', required = true)] - pub hashtable_filename: PathBuf, + pub hashtable_filename: Option, /// Kraken 2 options filename #[clap(short = 'o', required = true)] - pub options_filename: PathBuf, + pub options_filename: Option, /// 包含原始配置 #[clap(flatten)] @@ -43,7 +43,7 @@ pub struct Build { pub struct Taxo { /// Kraken 2 taxonomy filename #[clap(short = 't', required = true)] - pub taxonomy_filename: PathBuf, + pub taxonomy_filename: Option, /// Sequence ID to taxon map filename #[clap(short = 'm', required = true)] diff --git a/kr2r/src/bin/build_db.rs b/kr2r/src/bin/build_db.rs index 328a5a2..6862751 100644 --- a/kr2r/src/bin/build_db.rs +++ b/kr2r/src/bin/build_db.rs @@ -32,9 +32,13 @@ fn main() -> Result<(), Box> { let id_to_taxon_map = read_id_to_taxon_map(&args.taxo.id_to_taxon_map_filename)?; + let taxonomy_filename = args + .taxo + .taxonomy_filename + .unwrap_or(args.build.source.join("taxo.k2d")); let taxonomy = generate_taxonomy( &args.taxo.ncbi_taxonomy_directory, - &args.taxo.taxonomy_filename, + &taxonomy_filename, &id_to_taxon_map, )?; @@ -46,8 +50,12 @@ fn main() -> Result<(), Box> { let capacity = args.required_capacity as usize; + let hashtable_filename = args + .build + .hashtable_filename + .unwrap_or(args.build.source.clone().join("hash.k2d")); let hash_config = HashConfig::::new(capacity, value_bits, 0, 0, 0); - let mut chtm = CHTableMut::new(args.build.hashtable_filename, hash_config, 0, capacity)?; + let mut chtm = CHTableMut::new(hashtable_filename, hash_config, 0, capacity)?; let source: PathBuf = args.build.source.clone(); let fna_files = if source.is_file() { @@ -75,7 +83,11 @@ fn main() -> Result<(), Box> { println!("build db took: {:?}", duration); let idx_opts = IndexOptions::from_meros(meros); - idx_opts.write_to_file(args.build.options_filename)?; + let options_filename = args + .build + .options_filename + .unwrap_or(source.join("opts.k2d")); + idx_opts.write_to_file(options_filename)?; Ok(()) } diff --git a/kr2r/src/bin/build_k2_db.rs b/kr2r/src/bin/build_k2_db.rs index a24c2ac..8502c36 100644 --- a/kr2r/src/bin/build_k2_db.rs +++ b/kr2r/src/bin/build_k2_db.rs @@ -30,7 +30,7 @@ pub struct Args { #[clap(long)] pub chunk_dir: PathBuf, - /// chunk size 1-4(GB) [1073741824-4294967295] + /// chunk size 1-4(GB) [1073741824-4294967295] default: 1GB #[clap(long, value_parser = clap::value_parser!(u64).range(ONEGB..U32MAXPLUS), default_value_t = ONEGB)] pub chunk_size: u64, } @@ -41,9 +41,14 @@ pub fn run(args: Args, required_capacity: usize) -> Result<(), Box Result<(), Box Result<(), Box