Skip to content

Commit

Permalink
config module init
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Feb 10, 2025
1 parent 50b0e25 commit 8eadb12
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 3 deletions.
5 changes: 3 additions & 2 deletions path.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mmseqs=mmseqs
foldseek=foldseek
foldmason=foldmason
mafft=mafft
mafft-linsi=mafft-linsi
foldmason=foldmason
iqtree=iqtree
#fasttree=fasttree
#fasttree=
#raxml=
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
} */
Expand Down
5 changes: 5 additions & 0 deletions src/modules/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::util::arg_parser::Args;

pub fn run(args: &Args, bin: &crate::envs::variables::BinaryPaths) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
3 changes: 2 additions & 1 deletion src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pub mod cluster;
pub mod search;
pub mod profile;
pub mod tree;
pub mod genetree;
pub mod genetree;
pub mod config;
81 changes: 81 additions & 0 deletions src/util/arg_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
/// Set foldseek binary path
#[arg(long)]
set_foldseek: Option<PathBuf>,
/// Set foldmason binary path
#[arg(long)]
set_foldmason: Option<PathBuf>,
/// Set mafft binary path
#[arg(long)]
set_mafft: Option<PathBuf>,
/// Set mafft-linsi binary path
#[arg(long)]
set_mafft_linsi: Option<PathBuf>,
/// Set iqtree binary path
#[arg(long)]
set_iqtree: Option<PathBuf>,
/// Set fasttree binary path
#[arg(long)]
set_fasttree: Option<PathBuf>,
/// Set raxml binary path
#[arg(long)]
set_raxml: Option<PathBuf>,
/// Verbosity (0: quiet, 1: +errors, 2: +warnings, 3: +info, 4: +debug)
#[arg(short='v', long, default_value="3")]
verbosity: u8,
},
}

#[derive(Default)]
Expand Down Expand Up @@ -419,6 +456,17 @@ pub struct Args {
pub genetree_realign: Option<bool>,
pub genetree_aligner: Option<String>,
pub genetree_aligner_options: Option<Option<String>>,

pub config_show: Option<bool>,
pub config_check: Option<bool>,
pub config_set_mmseqs: Option<String>,
pub config_set_foldseek: Option<String>,
pub config_set_foldmason: Option<String>,
pub config_set_mafft: Option<String>,
pub config_set_mafft_linsi: Option<String>,
pub config_set_iqtree: Option<String>,
pub config_set_fasttree: Option<String>,
pub config_set_raxml: Option<String>,
}
fn own(path: &PathBuf) -> String { path.clone().to_string_lossy().into_owned() }
impl Args {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
}
}

0 comments on commit 8eadb12

Please sign in to comment.