pub struct Variant {
pub chrom: String,
pub position: u64,
pub id: Option<String>,
pub ref_allele: Vec<u8>,
pub alt_alleles: Vec<Vec<u8>>,
pub quality: Option<f64>,
pub filter: VariantFilter,
}Expand description
A genomic variant (VCF-style representation).
Position is 1-based following VCF convention.
Fields§
§chrom: String§position: u641-based position (VCF convention).
id: Option<String>Optional identifier (e.g. rs12345).
ref_allele: Vec<u8>Reference allele.
alt_alleles: Vec<Vec<u8>>Alternate alleles.
quality: Option<f64>Phred-scaled quality score.
filter: VariantFilterFilter status.
Implementations§
Source§impl Variant
impl Variant
Sourcepub fn new(
chrom: impl Into<String>,
position: u64,
ref_allele: Vec<u8>,
alt_alleles: Vec<Vec<u8>>,
) -> Result<Self>
pub fn new( chrom: impl Into<String>, position: u64, ref_allele: Vec<u8>, alt_alleles: Vec<Vec<u8>>, ) -> Result<Self>
Create a new variant with minimal fields.
Validates that reference and alternate alleles are non-empty.
Sourcepub fn variant_type(&self) -> VariantType
pub fn variant_type(&self) -> VariantType
Infer the variant type from the first alternate allele.
Sourcepub fn is_transition(&self) -> bool
pub fn is_transition(&self) -> bool
Whether this SNV is a transition (A↔G or C↔T).
Returns false for non-SNV variants.
Sourcepub fn is_transversion(&self) -> bool
pub fn is_transversion(&self) -> bool
Whether this SNV is a transversion (complement of transition for SNVs).
Returns false for non-SNV variants.
Sourcepub fn to_genomic_interval(&self) -> GenomicInterval
pub fn to_genomic_interval(&self) -> GenomicInterval
Convert the 1-based VCF position to a 0-based GenomicInterval.
The interval spans the reference allele.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Variant
impl RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl UnsafeUnpin for Variant
impl UnwindSafe for Variant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more