rsomics_vcf_expr/lib.rs
1//! bcftools-style VCF filter-expression parser and per-sample evaluator.
2//!
3//! Implements the subset of the bcftools filter language needed for
4//! `rsomics-vcf-setgt -t q` and `rsomics-vcf-filter -i/-e`:
5//!
6//! **Supported field references**
7//! - `FMT/<TAG>` / `FORMAT/<TAG>` — per-sample FORMAT field (numeric)
8//! - `INFO/<TAG>` — site-level INFO field (numeric or string)
9//! - `QUAL` — site-level QUAL column (numeric)
10//! - `FILTER` — site-level FILTER string
11//! - `GT` — per-sample genotype with special string values:
12//! `"."`, `"hom"`, `"het"`, `"ref"`, `"alt"`, `"miss"` / `"missing"`
13//!
14//! **Operators**
15//! - Comparison: `<` `<=` `>` `>=` `==` `!=`
16//! - Logical: `&&` `||`
17//! - Parentheses for grouping
18//!
19//! **Scoped out** (exits with error if used):
20//! - Regex operators `~` `!~`
21//! - Array-index syntax `TAG[0]`
22//! - Aggregation functions `N_PASS()`, `F_PASS()`, `SMPL_MAX()`, etc.
23//! - Arithmetic `+` `-` `*` `/` `%`
24//! - Special fields `N_MISSING`, `F_MISSING`, `N_ALT`, `AC`, `AN`, `AF`
25//!
26//! ## Origin
27//!
28//! Independent Rust implementation based on the MIT-licensed bcftools source
29//! (filter.c, develop branch) and the VCF 4.3 format specification.
30//! Consulted: <https://github.com/samtools/bcftools>
31//! License: MIT OR Apache-2.0
32//! Upstream credit: bcftools <https://github.com/samtools/bcftools> (MIT)
33
34pub mod eval;
35pub mod parse;
36
37pub use eval::{EvalContext, EvalError, SampleResult, eval_expr};
38pub use parse::{Expr, ParseError, parse_expr};