Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Serialize to data::cdot::json representations #176

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
/// 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 @@
}

/// 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 @@
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 @@
}

/// 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 @@
}

/// 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 @@
}

/// 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 @@
}

/// 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 @@
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 @@
}
}

#[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 Expand Up @@ -847,11 +847,11 @@
cigar: exon.cigar.clone(),
tx_aseq: None,
alt_aseq: None,
tx_exon_set_id: std::i32::MAX,

Check warning on line 850 in src/data/cdot/json.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of a legacy numeric constant

warning: usage of a legacy numeric constant --> src/data/cdot/json.rs:850:37 | 850 | tx_exon_set_id: std::i32::MAX, | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 850 | tx_exon_set_id: i32::MAX, | ~~~~~~~~
alt_exon_set_id: std::i32::MAX,

Check warning on line 851 in src/data/cdot/json.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of a legacy numeric constant

warning: usage of a legacy numeric constant --> src/data/cdot/json.rs:851:38 | 851 | alt_exon_set_id: std::i32::MAX, | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 851 | alt_exon_set_id: i32::MAX, | ~~~~~~~~
tx_exon_id: std::i32::MAX,

Check warning on line 852 in src/data/cdot/json.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of a legacy numeric constant

warning: usage of a legacy numeric constant --> src/data/cdot/json.rs:852:33 | 852 | tx_exon_id: std::i32::MAX, | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 852 | tx_exon_id: i32::MAX, | ~~~~~~~~
alt_exon_id: std::i32::MAX,

Check warning on line 853 in src/data/cdot/json.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of a legacy numeric constant

warning: usage of a legacy numeric constant --> src/data/cdot/json.rs:853:34 | 853 | alt_exon_id: std::i32::MAX, | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 853 | alt_exon_id: i32::MAX, | ~~~~~~~~
exon_aln_id: std::i32::MAX,

Check warning on line 854 in src/data/cdot/json.rs

View workflow job for this annotation

GitHub Actions / clippy

usage of a legacy numeric constant

warning: usage of a legacy numeric constant --> src/data/cdot/json.rs:854:34 | 854 | exon_aln_id: std::i32::MAX, | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 854 | exon_aln_id: i32::MAX, | ~~~~~~~~
})
.collect())
} else {
Expand Down
Loading