From 8eadb12fff2aa0b4e35abf64452164bdc9929fee Mon Sep 17 00:00:00 2001 From: Daniel DW Kim Date: Mon, 10 Feb 2025 15:13:03 +0900 Subject: [PATCH] config module init --- path.cfg | 5 +-- src/main.rs | 3 ++ src/modules/config.rs | 5 +++ src/modules/mod.rs | 3 +- src/util/arg_parser.rs | 81 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 src/modules/config.rs diff --git a/path.cfg b/path.cfg index dd711ee..2e2a049 100644 --- a/path.cfg +++ b/path.cfg @@ -1,7 +1,8 @@ mmseqs=mmseqs foldseek=foldseek +foldmason=foldmason mafft=mafft mafft-linsi=mafft-linsi -foldmason=foldmason iqtree=iqtree -#fasttree=fasttree \ No newline at end of file +#fasttree= +#raxml= \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c367a8c..b857fbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,9 @@ fn run(args: &parser::Args, bin: &var::BinaryPaths, test: bool) -> Result<(), Bo Some(parser::Commands::EasySearch { .. }) => { workflow::easy_search::run(args, bin).unwrap_or_else(|e| err::error(err::ERR_GENERAL, Some(e.to_string()))); } + Some(parser::Commands::Config { .. }) => { + modules::config::run(args, bin).unwrap_or_else(|e| err::error(err::ERR_GENERAL, Some(e.to_string()))); + }, /* Some(_) => { err::error(err::ERR_MODULE_NOT_IMPLEMENTED, std::env::args().nth(1)); } */ diff --git a/src/modules/config.rs b/src/modules/config.rs new file mode 100644 index 0000000..7815fe3 --- /dev/null +++ b/src/modules/config.rs @@ -0,0 +1,5 @@ +use crate::util::arg_parser::Args; + +pub fn run(args: &Args, bin: &crate::envs::variables::BinaryPaths) -> Result<(), Box> { + Ok(()) +} \ No newline at end of file diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 4d3c15b..23c1bd7 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -4,4 +4,5 @@ pub mod cluster; pub mod search; pub mod profile; pub mod tree; -pub mod genetree; \ No newline at end of file +pub mod genetree; +pub mod config; \ No newline at end of file diff --git a/src/util/arg_parser.rs b/src/util/arg_parser.rs index f3ffc19..c9b71f0 100644 --- a/src/util/arg_parser.rs +++ b/src/util/arg_parser.rs @@ -362,6 +362,43 @@ pub enum Commands { #[arg(short='v', long, default_value="3")] verbosity: u8, }, + /// Runtime environment configuration + #[clap(arg_required_else_help = true, allow_hyphen_values = true)] + Config { + /// Show current environment + #[arg(short='s', long)] + show: bool, + /// Check dependencies + #[arg(short='c', long)] + check: bool, + /// Set mmseqs binary path + #[arg(long)] + set_mmseqs: Option, + /// Set foldseek binary path + #[arg(long)] + set_foldseek: Option, + /// Set foldmason binary path + #[arg(long)] + set_foldmason: Option, + /// Set mafft binary path + #[arg(long)] + set_mafft: Option, + /// Set mafft-linsi binary path + #[arg(long)] + set_mafft_linsi: Option, + /// Set iqtree binary path + #[arg(long)] + set_iqtree: Option, + /// Set fasttree binary path + #[arg(long)] + set_fasttree: Option, + /// Set raxml binary path + #[arg(long)] + set_raxml: Option, + /// Verbosity (0: quiet, 1: +errors, 2: +warnings, 3: +info, 4: +debug) + #[arg(short='v', long, default_value="3")] + verbosity: u8, + }, } #[derive(Default)] @@ -419,6 +456,17 @@ pub struct Args { pub genetree_realign: Option, pub genetree_aligner: Option, pub genetree_aligner_options: Option>, + + pub config_show: Option, + pub config_check: Option, + pub config_set_mmseqs: Option, + pub config_set_foldseek: Option, + pub config_set_foldmason: Option, + pub config_set_mafft: Option, + pub config_set_mafft_linsi: Option, + pub config_set_iqtree: Option, + pub config_set_fasttree: Option, + pub config_set_raxml: Option, } fn own(path: &PathBuf) -> String { path.clone().to_string_lossy().into_owned() } impl Args { @@ -433,6 +481,7 @@ impl Args { Some(GeneTree { verbosity, .. }) => *verbosity, Some(EasyCore { verbosity, .. }) => *verbosity, Some(EasySearch { verbosity, .. }) => *verbosity, + Some(Config { verbosity, .. }) => *verbosity, _ => 3, }; let threads = match &args.command { @@ -641,6 +690,37 @@ impl Args { Some(GeneTree { threshold, .. }) => Some(*threshold), _ => None, }; + let config_show = match &args.command { + Some(Config { show, .. }) => Some(*show), _ => None, + }; + let config_check = match &args.command { + Some(Config { check, .. }) => Some(*check), _ => None, + }; + let config_set_mmseqs = match &args.command { + Some(Config { set_mmseqs, .. }) => match set_mmseqs { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_foldseek = match &args.command { + Some(Config { set_foldseek, .. }) => match set_foldseek { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_foldmason = match &args.command { + Some(Config { set_foldmason, .. }) => match set_foldmason { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_mafft = match &args.command { + Some(Config { set_mafft, .. }) => match set_mafft { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_mafft_linsi = match &args.command { + Some(Config { set_mafft_linsi, .. }) => match set_mafft_linsi { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_iqtree = match &args.command { + Some(Config { set_iqtree, .. }) => match set_iqtree { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_fasttree = match &args.command { + Some(Config { set_fasttree, .. }) => match set_fasttree { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + let config_set_raxml = match &args.command { + Some(Config { set_raxml, .. }) => match set_raxml { Some(p) => Some(own(p)), _ => None }, _ => None, + }; + Args { command: args.command, version: args.version, threads, verbosity, createdb_input, createdb_output, createdb_model, createdb_keep, createdb_overwrite, createdb_max_len, createdb_gpu, createdb_use_python, createdb_use_foldseek, createdb_afdb_lookup, createdb_afdb_local, @@ -649,6 +729,7 @@ impl Args { cluster_input, cluster_output, cluster_tmp, cluster_keep_cluster_db, cluster_cluster_options, tree_db, tree_input, tree_output, tree_aligner, tree_tree_builder, tree_aligner_options, tree_tree_options, tree_threshold, genetree_input, genetree_names, genetree_tree_builder, genetree_tree_options, genetree_realign, genetree_aligner, genetree_aligner_options, genetree_threshold, + config_show, config_check, config_set_mmseqs, config_set_foldseek, config_set_foldmason, config_set_mafft, config_set_mafft_linsi, config_set_iqtree, config_set_fasttree, config_set_raxml, } } } \ No newline at end of file