ncbi 0.2.0-beta

Rust data structures for NCBI APIs
Documentation
//! Sequence Analysis Results (other than alignments)
//!
//! Adapted from ["seqres.asn"](https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqres/seqres.asn)

use crate::seqloc::SeqLoc;
use serde::{Deserialize, Serialize};

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum SeqGraphChoice {
    Real(RealGraph),
    Int(IntGraph),
    Byte(ByteGraph),
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
/// For values mapped by residue or range to sequence
pub struct SeqGraph {
    pub title: Option<String>,
    pub comment: Option<String>,
    /// region this applies to
    pub loc: SeqLoc,
    /// title for x-axis
    pub title_x: Option<String>,
    /// title for y-axis
    pub title_y: Option<String>,
    pub comp: Option<i64>,
    /// for scaling values
    ///
    /// `display = (a * value ) + b`
    pub a: Option<f64>,
    pub b: Option<f64>,

    /// number of values in graph
    pub numval: u64,

    pub graph: SeqGraphChoice,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Graph<T> {
    /// top of graph
    pub max: T,

    /// bottom of graph
    pub min: T,

    /// value to draw axis on
    pub axis: T,

    pub values: Vec<T>,
}

pub type RealGraph = Graph<f64>;

pub type IntGraph = Graph<u64>;

/// integer from 0-255
pub type ByteGraph = Graph<u8>;