Skip to content

Commit

Permalink
fix: add Serialize to data::cdot::json representations (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil authored Jun 27, 2024
1 parent 7abaf40 commit 2de1b8a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/data/cdot/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ impl interface::Provider for Provider {
/// Data structures used for deserializing from cdot.
pub mod models {
use indexmap::IndexMap;
use serde::{Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, Serialize};

/// Container for a cDot data file.
#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Container {
pub transcripts: IndexMap<String, Transcript>,
pub cdot_version: String,
Expand All @@ -201,7 +201,7 @@ pub mod models {
}

/// Enum for representing the tags for transcripts.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Tag {
Basic,
EnsemblCanonical,
Expand All @@ -210,7 +210,7 @@ pub mod models {
RefSeqSelect,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Transcript {
/// Transcript biotype, e.g., `vec![BioType::ProteinCoding]` for BRCA1.
#[serde(default)]
Expand Down Expand Up @@ -240,7 +240,7 @@ pub mod models {
}

/// Representation of the strand.
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq, Eq)]
pub enum Strand {
#[serde(rename = "+")]
Plus,
Expand All @@ -249,11 +249,11 @@ pub mod models {
}

/// Representation of an exon in the JSON.
#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
struct ExonHelper(i32, i32, i32, i32, i32, Option<String>);

/// Representation of an exon after loading.
#[derive(Debug, Clone)]
#[derive(Serialize, Debug, Clone)]
pub struct Exon {
/// Start position on reference.
pub alt_start_i: i32,
Expand All @@ -270,7 +270,7 @@ pub mod models {
}

/// Representation of `transcripts.*.genome_builds` value.
#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct GenomeAlignment {
/// CDS end position.
#[serde(default)]
Expand All @@ -294,7 +294,7 @@ pub mod models {
}

/// Enum for representing the biotypes.
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq, Eq)]
pub enum BioType {
#[serde(rename = "3prime_overlapping_ncrna")]
ThreePrimeOverlappingNcRna,
Expand Down Expand Up @@ -452,7 +452,7 @@ pub mod models {
YRna,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Gene {
#[serde(default)]
#[serde(deserialize_with = "deserialize_gene_aliases")]
Expand Down Expand Up @@ -529,7 +529,7 @@ pub mod models {
}
}

#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Serialize)]
struct WrappedString(String);

fn deserialize_tag<'de, D>(deserializer: D) -> Result<Option<Vec<Tag>>, D::Error>
Expand Down

0 comments on commit 2de1b8a

Please sign in to comment.