use annonars::{
clinvar_genes, clinvar_minimal, clinvar_sv, common, cons, db_utils, dbsnp, freqs, functional,
genes, gnomad_mtdna, gnomad_nuclear, gnomad_sv, helixmtdb, regions, server, tsv,
};
use anyhow::Error;
use clap::{command, Args, Parser, Subcommand};
#[derive(Debug, Clone, Parser)]
#[command(
author,
version,
about = "RocksDB-based genome annotations",
long_about = "Genome annotation stored in RocksDB."
)]
struct Cli {
#[command(flatten)]
common: common::cli::Args,
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand, Clone)]
enum Commands {
Gene(Gene),
Tsv(Tsv),
Cons(Cons),
ClinvarGenes(ClinvarGenes),
ClinvarMinimal(ClinvarMinimal),
ClinvarSv(ClinvarSv),
Freqs(Freqs),
Functional(Functional),
Dbsnp(Dbsnp),
Helixmtdb(Helixmtdb),
GnomadMtdna(GnomadMtdna),
GnomadNuclear(GnomadNuclear),
GnomadSv(GnomadSv),
Regions(Regions),
DbUtils(DbUtils),
RunServer(server::Args),
}
#[derive(Debug, Args, Clone)]
struct Gene {
#[command(subcommand)]
command: GeneCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum GeneCommands {
Import(Box<genes::cli::import::Args>),
Query(Box<genes::cli::query::Args>),
}
#[derive(Debug, Args, Clone)]
struct Tsv {
#[command(subcommand)]
command: TsvCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum TsvCommands {
Import(tsv::cli::import::Args),
Query(tsv::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct ClinvarGenes {
#[command(subcommand)]
command: ClinvarGeneCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum ClinvarGeneCommands {
Import(clinvar_genes::cli::import::Args),
Query(clinvar_genes::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct ClinvarMinimal {
#[command(subcommand)]
command: ClinvarMinimalCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum ClinvarMinimalCommands {
Import(clinvar_minimal::cli::import::Args),
Query(clinvar_minimal::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct ClinvarSv {
#[command(subcommand)]
command: ClinvarSvCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum ClinvarSvCommands {
Import(clinvar_sv::cli::import::Args),
Query(clinvar_sv::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Cons {
#[command(subcommand)]
command: ConsCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum ConsCommands {
Import(cons::cli::import::Args),
Query(cons::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Dbsnp {
#[command(subcommand)]
command: DbsnpCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum DbsnpCommands {
Import(dbsnp::cli::import::Args),
Query(dbsnp::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Freqs {
#[command(subcommand)]
command: FreqsCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum FreqsCommands {
Import(freqs::cli::import::Args),
Query(freqs::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Functional {
#[command(subcommand)]
command: FunctionalCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum FunctionalCommands {
Import(functional::cli::import::Args),
Query(functional::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Helixmtdb {
#[command(subcommand)]
command: HelixmtdbCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum HelixmtdbCommands {
Import(helixmtdb::cli::import::Args),
Query(helixmtdb::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct GnomadMtdna {
#[command(subcommand)]
command: GnomadMtdnaCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum GnomadMtdnaCommands {
Import(gnomad_mtdna::cli::import::Args),
Query(gnomad_mtdna::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct GnomadNuclear {
#[command(subcommand)]
command: GnomadNuclearCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum GnomadNuclearCommands {
Import(gnomad_nuclear::cli::import::Args),
Query(gnomad_nuclear::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct GnomadSv {
#[command(subcommand)]
command: GnomadSvCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum GnomadSvCommands {
Import(gnomad_sv::cli::import::Args),
Query(gnomad_sv::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct Regions {
#[command(subcommand)]
command: RegionsCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum RegionsCommands {
Import(regions::cli::import::Args),
Query(regions::cli::query::Args),
}
#[derive(Debug, Args, Clone)]
struct DbUtils {
#[command(subcommand)]
command: DbUtilsCommands,
}
#[derive(Debug, Subcommand, Clone)]
enum DbUtilsCommands {
Copy(db_utils::cli::copy::Args),
DumpMeta(db_utils::cli::dump_meta::Args),
}
pub fn main() -> Result<(), anyhow::Error> {
let cli = Cli::parse();
let collector = tracing_subscriber::fmt()
.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::with_default(collector, || {
match &cli.command {
Commands::Gene(args) => match &args.command {
GeneCommands::Import(args) => genes::cli::import::run(&cli.common, args)?,
GeneCommands::Query(args) => genes::cli::query::run(&cli.common, args)?,
},
Commands::Tsv(args) => match &args.command {
TsvCommands::Import(args) => tsv::cli::import::run(&cli.common, args)?,
TsvCommands::Query(args) => tsv::cli::query::run(&cli.common, args)?,
},
Commands::ClinvarGenes(args) => match &args.command {
ClinvarGeneCommands::Import(args) => {
clinvar_genes::cli::import::run(&cli.common, args)?
}
ClinvarGeneCommands::Query(args) => {
clinvar_genes::cli::query::run(&cli.common, args)?
}
},
Commands::ClinvarMinimal(args) => match &args.command {
ClinvarMinimalCommands::Import(args) => {
clinvar_minimal::cli::import::run(&cli.common, args)?
}
ClinvarMinimalCommands::Query(args) => {
clinvar_minimal::cli::query::run(&cli.common, args)?
}
},
Commands::ClinvarSv(args) => match &args.command {
ClinvarSvCommands::Import(args) => clinvar_sv::cli::import::run(&cli.common, args)?,
ClinvarSvCommands::Query(args) => clinvar_sv::cli::query::run(&cli.common, args)?,
},
Commands::Cons(args) => match &args.command {
ConsCommands::Import(args) => cons::cli::import::run(&cli.common, args)?,
ConsCommands::Query(args) => cons::cli::query::run(&cli.common, args)?,
},
Commands::Dbsnp(args) => match &args.command {
DbsnpCommands::Import(args) => dbsnp::cli::import::run(&cli.common, args)?,
DbsnpCommands::Query(args) => dbsnp::cli::query::run(&cli.common, args)?,
},
Commands::Freqs(args) => match &args.command {
FreqsCommands::Import(args) => freqs::cli::import::run(&cli.common, args)?,
FreqsCommands::Query(args) => freqs::cli::query::run(&cli.common, args)?,
},
Commands::Functional(args) => match &args.command {
FunctionalCommands::Import(args) => {
functional::cli::import::run(&cli.common, args)?
}
FunctionalCommands::Query(args) => functional::cli::query::run(&cli.common, args)?,
},
Commands::Helixmtdb(args) => match &args.command {
HelixmtdbCommands::Import(args) => helixmtdb::cli::import::run(&cli.common, args)?,
HelixmtdbCommands::Query(args) => helixmtdb::cli::query::run(&cli.common, args)?,
},
Commands::GnomadMtdna(args) => match &args.command {
GnomadMtdnaCommands::Import(args) => {
gnomad_mtdna::cli::import::run(&cli.common, args)?
}
GnomadMtdnaCommands::Query(args) => {
gnomad_mtdna::cli::query::run(&cli.common, args)?
}
},
Commands::GnomadNuclear(args) => match &args.command {
GnomadNuclearCommands::Import(args) => {
gnomad_nuclear::cli::import::run(&cli.common, args)?
}
GnomadNuclearCommands::Query(args) => {
gnomad_nuclear::cli::query::run(&cli.common, args)?
}
},
Commands::GnomadSv(args) => match &args.command {
GnomadSvCommands::Import(args) => gnomad_sv::cli::import::run(&cli.common, args)?,
GnomadSvCommands::Query(args) => gnomad_sv::cli::query::run(&cli.common, args)?,
},
Commands::Regions(args) => match &args.command {
RegionsCommands::Import(args) => regions::cli::import::run(&cli.common, args)?,
RegionsCommands::Query(args) => regions::cli::query::run(&cli.common, args)?,
},
Commands::DbUtils(args) => match &args.command {
DbUtilsCommands::Copy(args) => db_utils::cli::copy::run(&cli.common, args)?,
DbUtilsCommands::DumpMeta(args) => {
db_utils::cli::dump_meta::run(&cli.common, args)?
}
},
Commands::RunServer(args) => server::run(&cli.common, args)?,
}
Ok::<(), Error>(())
})?;
tracing::info!("All done! Have a nice day.");
Ok(())
}