genome-sh 0.1.0

The jq of genomics. Fast, local, human-readable variant analysis.
use std::path::PathBuf;

use anyhow::{Context, Result};
use clap::Args;

use crate::db::Database;
use crate::output::Format;
use crate::variant::comparison::VariantComparison;

#[derive(Args)]
pub struct CompareArgs {
    /// First VCF file.
    pub file_a: PathBuf,

    /// Second VCF file.
    pub file_b: PathBuf,

    /// Output format.
    #[arg(short, long, default_value = "human")]
    pub format: Format,

    /// Only show clinically significant differences.
    #[arg(long)]
    pub clinical: bool,

    /// Estimate genetic relatedness (kinship).
    #[arg(long)]
    pub kinship: bool,

    /// Generate an HTML report.
    #[arg(long)]
    pub report: Option<PathBuf>,
}

impl CompareArgs {
    pub async fn run(self) -> Result<()> {
        let db = Database::open()
            .context("Failed to open variant database. Run `genome db install` first.")?;

        let comparison = VariantComparison::run(
            &self.file_a,
            &self.file_b,
            &db,
            self.kinship,
            self.clinical,
        )
        .await?;

        comparison.print(self.format)?;

        Ok(())
    }
}