use serde_json::{Value, json}; use crate::tracks::{bam::BamTrack, bed::BedTrack, genes::GenesTrack, variants::VariantsTrack}; pub mod bam; pub mod bed; pub mod genes; pub mod variants; /// Supported IGV track variants for session JSON. #[derive(Debug)] pub enum Track { /// BAM alignment track. Bam(BamTrack), /// Gene annotation track (GFF3). Genes(GenesTrack), /// Variant track (VCF). Variants(VariantsTrack), /// BED annotation track. Bed(BedTrack), } impl Track { /// Serialize the track variant to a JSON object suitable for igv.js. pub fn to_json(&self) -> Value { match self { Track::Bam(bam) => json!(bam), Track::Genes(genes) => json!(genes), Track::Variants(variants) => json!(variants), Track::Bed(bed) => json!(bed), } } /// Set the track display order. pub fn order(&mut self, order: i16) { match self { Track::Bam(track) => track.order = order, Track::Genes(track) => track.order = order, Track::Variants(track) => track.order = order, Track::Bed(track) => track.order = order, } } }