#[cfg(all(
feature = "jemalloc",
not(target_env = "msvc"),
not(feature = "dhat-heap")
))]
use tikv_jemallocator::Jemalloc;
#[cfg(all(
feature = "jemalloc",
not(target_env = "msvc"),
not(feature = "dhat-heap")
))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
#[cfg(all(feature = "dhat-heap", not(feature = "jemalloc")))]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
use clap::{Args, Parser, Subcommand};
use mehari::db::create;
#[cfg(feature = "server")]
use mehari::server;
use mehari::{annotate, common, db, verify};
#[derive(Debug, Parser)]
#[command(
author,
version,
about = "VCF variant effect prediction and annotation"
)]
struct Cli {
#[command(flatten)]
common: common::Args,
#[command(subcommand)]
command: Commands,
}
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Subcommand)]
enum Commands {
Db(Db),
Annotate(Annotate),
#[cfg(feature = "server")]
Server(Server),
Verify(Verify),
Postprocess(Postprocess),
}
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Db {
#[command(subcommand)]
command: DbCommands,
}
#[derive(Debug, Subcommand)]
enum DbCommands {
Create(create::cli::Args),
Check(db::check::Args),
Dump(db::dump::Args),
Merge(db::merge::Args),
Subset(db::subset::Args),
}
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Annotate {
#[command(subcommand)]
command: AnnotateCommands,
}
#[derive(Debug, Subcommand)]
enum AnnotateCommands {
Seqvars(annotate::seqvars::Args),
Strucvars(annotate::strucvars::Args),
}
#[cfg(feature = "server")]
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Server {
#[command(subcommand)]
command: ServerCommands,
}
#[cfg(feature = "server")]
#[derive(Debug, Subcommand)]
enum ServerCommands {
Run(server::run::Args),
Schema(server::schema::Args),
}
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Verify {
#[command(subcommand)]
command: VerifyCommands,
}
#[derive(Debug, Subcommand)]
enum VerifyCommands {
Seqvars(verify::seqvars::Args),
}
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Postprocess {
#[command(subcommand)]
command: PostprocessCommands,
}
#[derive(Debug, Subcommand)]
enum PostprocessCommands {
Proteome(mehari::postprocess::proteome::Args),
VarfishSeqvars(mehari::postprocess::varfish::Args),
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();
let cli = Cli::parse();
let collector = tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_target(false)
.with_max_level(match cli.common.verbose.log_level() {
Some(level) => match level {
log::Level::Error => tracing::Level::ERROR,
log::Level::Warn => tracing::Level::WARN,
log::Level::Info => tracing::Level::INFO,
log::Level::Debug => tracing::Level::DEBUG,
log::Level::Trace => tracing::Level::TRACE,
},
None => tracing::Level::INFO,
})
.compact()
.finish();
tracing::subscriber::set_global_default(collector)?;
tracing::info!("Mehari startup -- letting the dromedary off the leash...");
match &cli.command {
Commands::Db(db) => match &db.command {
DbCommands::Create(args) => db::create::run(&cli.common, args)?,
DbCommands::Check(args) => db::check::run(&cli.common, args)?,
DbCommands::Dump(args) => db::dump::run(&cli.common, args)?,
DbCommands::Subset(args) => db::subset::run(&cli.common, args)?,
DbCommands::Merge(args) => db::merge::run(&cli.common, args)?,
},
Commands::Annotate(annotate) => match &annotate.command {
AnnotateCommands::Seqvars(args) => annotate::seqvars::run(&cli.common, args).await?,
AnnotateCommands::Strucvars(args) => {
annotate::strucvars::run(&cli.common, args).await?
}
},
#[cfg(feature = "server")]
Commands::Server(server) => match &server.command {
ServerCommands::Run(args) => server::run::run(&cli.common, args).await?,
ServerCommands::Schema(args) => server::schema::run(&cli.common, args)?,
},
Commands::Verify(verify) => match &verify.command {
VerifyCommands::Seqvars(args) => verify::seqvars::run(&cli.common, args)?,
},
Commands::Postprocess(postprocess) => match &postprocess.command {
PostprocessCommands::Proteome(args) => {
mehari::postprocess::proteome::run(&cli.common, args).await?
}
PostprocessCommands::VarfishSeqvars(args) => {
mehari::postprocess::varfish::run(&cli.common, args).await?
}
},
}
tracing::info!("... the dromedary is back in the stable.");
tracing::info!("All done. Have a nice day!");
Ok(())
}