use std::path::PathBuf;
use anyhow::{Context, Result};
use clap::Args;
use crate::db::Database;
use crate::io::vcf::VcfReader;
use crate::output::Format;
#[derive(Clone, Debug, clap::ValueEnum)]
pub enum AnnotateFilter {
All,
Clinical,
Rare,
}
#[derive(Args)]
pub struct AnnotateArgs {
pub input: PathBuf,
#[arg(short, long)]
pub output: Option<PathBuf>,
#[arg(short, long, default_value = "human")]
pub format: Format,
#[arg(long, default_value = "all")]
pub filter: AnnotateFilter,
#[arg(long)]
pub report: Option<PathBuf>,
}
impl AnnotateArgs {
pub async fn run(self) -> Result<()> {
let db = Database::open()
.context("Failed to open variant database. Run `genome db install` first.")?;
let mut reader = VcfReader::open(&self.input)
.await
.context("Failed to open input VCF file")?;
let mut count = 0u64;
let mut annotated = 0u64;
while let Some(record) = reader.next_record().await? {
count += 1;
let annotation = db.annotate_vcf_record(&record)?;
if annotation.is_some() {
annotated += 1;
}
}
eprintln!("Processed {count} variants, {annotated} annotated.");
Ok(())
}
}