Skip to content

Commit

Permalink
refactor: replace linked-hash-map by indexmap (#111) (#112)
Browse files Browse the repository at this point in the history
Release-As: 0.8.2
  • Loading branch information
holtgrewe committed Jun 8, 2023
1 parent 1a040e7 commit f6d3ab4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ chrono = "0.4"
enum-map = "2.4"
flate2 = "1.0"
lazy_static = "1.4"
linked-hash-map = { version = "0.5", features = ["serde", "serde_impl"] }
log = "0.4"
md-5 = "0.10"
nom = "7.1"
Expand All @@ -29,18 +28,19 @@ quick_cache = "0.3"
regex = "1.7"
rustc-hash = "1.1"
seqrepo = { version = "0.5" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
indexmap = { version = "1.9.3", features = ["serde"] }

[dev-dependencies]
anyhow = "1.0"
criterion = "0.5"
csv = "1.2"
env_logger = "0.10"
pretty_assertions = "1.3"
rstest = "0.17"
test-log = "0.2"
criterion = "0.5"
anyhow = "1.0"

[[bench]]
name = "translate_cds"
Expand Down
16 changes: 8 additions & 8 deletions src/data/cdot/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{

use bio::data_structures::interval_tree::ArrayBackedIntervalTree;
use chrono::NaiveDateTime;
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use seqrepo::{Interface as SeqRepoInterface, SeqRepo};

/// Configurationf or the `data::cdot::Provider`.
Expand Down Expand Up @@ -105,7 +105,7 @@ impl ProviderInterface for Provider {
fn get_assembly_map(
&self,
assembly: crate::static_data::Assembly,
) -> linked_hash_map::LinkedHashMap<String, String> {
) -> indexmap::IndexMap<String, String> {
self.inner.get_assembly_map(assembly)
}

Expand Down Expand Up @@ -187,16 +187,16 @@ impl ProviderInterface for Provider {

/// Data structures used for deserializing from cdot.
pub mod models {
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use serde::{Deserialize, Deserializer};

/// Container for a cDot data file.
#[derive(Deserialize, Debug, Clone)]
pub struct Container {
pub transcripts: LinkedHashMap<String, Transcript>,
pub transcripts: IndexMap<String, Transcript>,
pub cdot_version: String,
pub genome_builds: Vec<String>,
pub genes: LinkedHashMap<String, Gene>,
pub genes: IndexMap<String, Gene>,
}

/// Enum for representing the tags for transcripts.
Expand All @@ -221,7 +221,7 @@ pub mod models {
/// `"ENSG00000012048"` for BRCA1.
pub gene_version: String,
/// Alignments to the different genome builds.
pub genome_builds: LinkedHashMap<String, GenomeAlignment>,
pub genome_builds: IndexMap<String, GenomeAlignment>,
/// HGNC identifier, e.g. `"1100"` for BRCA1 which is `HGNC:1100`.
#[serde(default)]
pub hgnc: Option<String>,
Expand Down Expand Up @@ -709,8 +709,8 @@ impl TxProvider {
REQUIRED_VERSION
}

fn get_assembly_map(&self, assembly: Assembly) -> LinkedHashMap<String, String> {
LinkedHashMap::from_iter(
fn get_assembly_map(&self, assembly: Assembly) -> IndexMap<String, String> {
IndexMap::from_iter(
ASSEMBLY_INFOS[assembly]
.sequences
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/data/interface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Definition of the interface for accessing the transcript database.
use chrono::NaiveDateTime;
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;

use crate::data::error::Error;
use crate::static_data::Assembly;
Expand Down Expand Up @@ -193,7 +193,7 @@ pub trait Provider {
/// # Arguments
///
/// * `assembly` - The assembly to build the map for.
fn get_assembly_map(&self, assembly: Assembly) -> LinkedHashMap<String, String>;
fn get_assembly_map(&self, assembly: Assembly) -> IndexMap<String, String>;

/// Returns the basic information about the gene.
///
Expand Down
6 changes: 3 additions & 3 deletions src/data/uta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! C.f. https://github.com/biocommons/uta
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use postgres::{Client, NoTls, Row};
use quick_cache::sync::Cache;
use std::fmt::Debug;
Expand Down Expand Up @@ -243,8 +243,8 @@ impl ProviderInterface for Provider {
&self.schema_version
}

fn get_assembly_map(&self, assembly: Assembly) -> LinkedHashMap<String, String> {
LinkedHashMap::from_iter(
fn get_assembly_map(&self, assembly: Assembly) -> IndexMap<String, String> {
IndexMap::from_iter(
ASSEMBLY_INFOS[assembly]
.sequences
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/data/uta_sr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ProviderInterface for Provider {
fn get_assembly_map(
&self,
assembly: crate::static_data::Assembly,
) -> linked_hash_map::LinkedHashMap<String, String> {
) -> indexmap::IndexMap<String, String> {
self.inner.get_assembly_map(assembly)
}

Expand Down
2 changes: 1 addition & 1 deletion src/mapper/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ mod test {
fn get_assembly_map(
&self,
_assembly: crate::static_data::Assembly,
) -> linked_hash_map::LinkedHashMap<String, String> {
) -> indexmap::IndexMap<String, String> {
panic!("for test use only");
}

Expand Down

0 comments on commit f6d3ab4

Please sign in to comment.