diff --git a/Cargo.toml b/Cargo.toml index b9e0868..f168510 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" authors = ["Manuel Holtgrewe "] description = "Port of biocommons/hgvs to Rust" license = "Apache-2.0" -homepage = "https://github.com/bihealth/seqrepo-rs" +homepage = "https://github.com/bihealth/hgvs-rs" readme = "README.md" rust-version = "1.64.0" @@ -27,7 +27,7 @@ postgres = { version = "0.19", features = ["with-chrono-0_4"] } quick_cache = "0.3" regex = "1.7" rustc-hash = "1.1" -seqrepo = { version = "0.5" } +seqrepo = { version = "0.6" } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } thiserror = "1.0" diff --git a/src/data/cdot/json.rs b/src/data/cdot/json.rs index 8264356..12ae1f8 100644 --- a/src/data/cdot/json.rs +++ b/src/data/cdot/json.rs @@ -2,13 +2,13 @@ //! //! https://github.com/SACGF/cdot -use std::{collections::HashMap, path::PathBuf, rc::Rc, time::Instant}; +use std::{collections::HashMap, path::PathBuf, sync::Arc, time::Instant}; use crate::{ data::error::Error, data::interface::{ - GeneInfoRecord, Provider as ProviderInterface, TxExonsRecord, TxForRegionRecord, - TxIdentityInfo, TxInfoRecord, TxMappingOptionsRecord, TxSimilarityRecord, + self, GeneInfoRecord, TxExonsRecord, TxForRegionRecord, TxIdentityInfo, TxInfoRecord, + TxMappingOptionsRecord, TxSimilarityRecord, }, static_data::{Assembly, ASSEMBLY_INFOS}, }; @@ -16,7 +16,7 @@ use crate::{ use bio::data_structures::interval_tree::ArrayBackedIntervalTree; use chrono::NaiveDateTime; use indexmap::IndexMap; -use seqrepo::{Interface as SeqRepoInterface, SeqRepo}; +use seqrepo::{self, SeqRepo}; /// Configurationf or the `data::cdot::Provider`. #[derive(Debug, PartialEq, Clone)] @@ -42,7 +42,7 @@ pub struct Config { /// `exon_aln_id`. pub struct Provider { inner: TxProvider, - seqrepo: Rc, + seqrepo: Arc, } impl Provider { @@ -70,14 +70,14 @@ impl Provider { .collect::>() .as_ref(), )?, - seqrepo: Rc::new(SeqRepo::new(path, &instance)?), + seqrepo: Arc::new(SeqRepo::new(path, &instance)?), }) } /// Create a new provider allowing to inject a seqrepo. pub fn with_seqrepo( config: Config, - seqrepo: Rc, + seqrepo: Arc, ) -> Result { Ok(Self { inner: TxProvider::with_config( @@ -93,7 +93,7 @@ impl Provider { } } -impl ProviderInterface for Provider { +impl interface::Provider for Provider { fn data_version(&self) -> &str { self.inner.data_version() } @@ -699,7 +699,7 @@ pub static REQUIRED_VERSION: &str = "1.1"; /// The alignment method returned for all cdot transcripts. pub static NCBI_ALN_METHOD: &str = "splign"; -/// Implementation for `ProviderInterface`. +/// Implementation for `interface::Provider`. impl TxProvider { fn data_version(&self) -> &str { REQUIRED_VERSION @@ -1024,12 +1024,12 @@ impl TxProvider { #[cfg(test)] pub mod test_helpers { use anyhow::Error; - use std::rc::Rc; + use std::sync::Arc; use crate::data::uta_sr::test_helpers::build_writing_sr; use super::{Config, Provider}; - use seqrepo::{CacheReadingSeqRepo, Interface as SeqRepoInterface}; + use seqrepo; pub fn build_provider() -> Result { let sr_cache_mode = std::env::var("TEST_SEQREPO_CACHE_MODE") @@ -1040,8 +1040,8 @@ pub mod test_helpers { log::debug!("building provider..."); let seqrepo = if sr_cache_mode == "read" { log::debug!("reading provider..."); - let seqrepo: Rc = - Rc::new(CacheReadingSeqRepo::new(sr_cache_path)?); + let seqrepo: Arc = + Arc::new(seqrepo::CacheReadingSeqRepo::new(sr_cache_path)?); log::debug!("construction done..."); seqrepo } else if sr_cache_mode == "write" { @@ -1066,8 +1066,9 @@ pub mod test_helpers { #[cfg(test)] pub mod tests { use anyhow::Error; - use std::rc::Rc; + use std::str::FromStr; + use std::sync::Arc; use chrono::NaiveDateTime; use pretty_assertions::assert_eq; @@ -1076,13 +1077,19 @@ pub mod tests { use super::models::{gap_to_cigar, Container}; use super::test_helpers::build_provider; use crate::data::interface::{ - GeneInfoRecord, Provider as ProviderInterface, TxExonsRecord, TxForRegionRecord, - TxInfoRecord, TxMappingOptionsRecord, TxSimilarityRecord, + GeneInfoRecord, Provider, TxExonsRecord, TxForRegionRecord, TxInfoRecord, + TxMappingOptionsRecord, TxSimilarityRecord, }; - use crate::mapper::assembly::{Config as AssemblyMapperConfig, Mapper}; + use crate::mapper::assembly::{self, Mapper}; use crate::parser::HgvsVariant; use crate::static_data::Assembly; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + #[test] fn deserialize_brca1() -> Result<(), Error> { let json = std::fs::read_to_string( @@ -2152,8 +2159,8 @@ pub mod tests { } fn build_mapper_37(normalize: bool) -> Result { - let provider = Rc::new(build_provider()?); - let config = AssemblyMapperConfig { + let provider = Arc::new(build_provider()?); + let config = assembly::Config { assembly: Assembly::Grch37, normalize, ..Default::default() diff --git a/src/data/uta.rs b/src/data/uta.rs index d40ae19..e9d7657 100644 --- a/src/data/uta.rs +++ b/src/data/uta.rs @@ -12,9 +12,9 @@ use crate::sequences::seq_md5; use crate::static_data::{Assembly, ASSEMBLY_INFOS}; use crate::data::{ - error::Error, interface::GeneInfoRecord, interface::Provider as ProviderInterface, - interface::TxExonsRecord, interface::TxForRegionRecord, interface::TxIdentityInfo, - interface::TxInfoRecord, interface::TxMappingOptionsRecord, interface::TxSimilarityRecord, + error::Error, interface, interface::GeneInfoRecord, interface::TxExonsRecord, + interface::TxForRegionRecord, interface::TxIdentityInfo, interface::TxInfoRecord, + interface::TxMappingOptionsRecord, interface::TxSimilarityRecord, }; /// Configuration for the `data::uta::Provider`. @@ -234,7 +234,7 @@ impl Provider { } } -impl ProviderInterface for Provider { +impl interface::Provider for Provider { fn data_version(&self) -> &str { &self.config.db_schema } @@ -604,11 +604,17 @@ impl ProviderInterface for Provider { #[cfg(test)] mod test { - use crate::{data::interface::Provider as ProviderInterface, static_data::Assembly}; + use crate::{data::interface::Provider as InterfaceProvider, static_data::Assembly}; use anyhow::Error; use super::{Config, Provider}; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + fn get_config() -> Config { Config { db_url: std::env::var("TEST_UTA_DATABASE_URL") diff --git a/src/data/uta_sr.rs b/src/data/uta_sr.rs index b2787ba..f12fcea 100644 --- a/src/data/uta_sr.rs +++ b/src/data/uta_sr.rs @@ -5,15 +5,15 @@ //! * https://github.com/bihealth/seqrepo-rs use std::path::PathBuf; -use std::rc::Rc; +use std::sync::Arc; -use crate::data::uta::{Config as UtaConfig, Provider as UtaProvider}; +use crate::data::uta; use crate::data::{ - error::Error, interface::GeneInfoRecord, interface::Provider as ProviderInterface, - interface::TxExonsRecord, interface::TxForRegionRecord, interface::TxIdentityInfo, - interface::TxInfoRecord, interface::TxMappingOptionsRecord, interface::TxSimilarityRecord, + error::Error, interface, interface::GeneInfoRecord, interface::TxExonsRecord, + interface::TxForRegionRecord, interface::TxIdentityInfo, interface::TxInfoRecord, + interface::TxMappingOptionsRecord, interface::TxSimilarityRecord, }; -use seqrepo::{AliasOrSeqId, Interface as SeqRepoInterface, SeqRepo}; +use seqrepo::{self, AliasOrSeqId, SeqRepo}; /// Configuration for the `data::uta_sr::Provider`. #[derive(Debug, PartialEq, Clone)] @@ -33,8 +33,8 @@ pub struct Config { /// Transcripts from a UTA Postgres database, sequences comes from a SeqRepo. This makes /// genome contig information available in contrast to `data::uta::Provider`. pub struct Provider { - inner: UtaProvider, - seqrepo: Rc, + inner: uta::Provider, + seqrepo: Arc, } impl Provider { @@ -58,21 +58,21 @@ impl Provider { .to_string(); Ok(Self { - inner: UtaProvider::with_config(&UtaConfig { + inner: uta::Provider::with_config(&uta::Config { db_url: config.db_url.clone(), db_schema: config.db_schema, })?, - seqrepo: Rc::new(SeqRepo::new(path, &instance)?), + seqrepo: Arc::new(SeqRepo::new(path, &instance)?), }) } /// Create a new provider allowing to inject a seqrepo. pub fn with_seqrepo( config: Config, - seqrepo: Rc, + seqrepo: Arc, ) -> Result { Ok(Self { - inner: UtaProvider::with_config(&UtaConfig { + inner: uta::Provider::with_config(&uta::Config { db_url: config.db_url.clone(), db_schema: config.db_schema, })?, @@ -81,7 +81,7 @@ impl Provider { } } -impl ProviderInterface for Provider { +impl interface::Provider for Provider { fn data_version(&self) -> &str { self.inner.data_version() } @@ -174,18 +174,23 @@ impl ProviderInterface for Provider { #[cfg(test)] pub mod test_helpers { use anyhow::Error; - use std::{path::PathBuf, rc::Rc}; + use seqrepo::{CacheReadingSeqRepo, CacheWritingSeqRepo, SeqRepo}; + use std::{path::PathBuf, sync::Arc}; - use seqrepo::{ - CacheReadingSeqRepo, CacheWritingSeqRepo, Interface as SeqRepoInterface, SeqRepo, - }; + use crate::data::interface; - use super::{Config, Provider, ProviderInterface}; + use super::{Config, Provider}; + + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } /// Setup a UTA Provider with data source depending on environment variables. /// /// See README.md for information on environment variable setup. - pub fn build_provider() -> Result, Error> { + pub fn build_provider() -> Result, Error> { log::debug!("building provider..."); let db_url = std::env::var("TEST_UTA_DATABASE_URL") .expect("Environment variable TEST_UTA_DATABASE_URL undefined!"); @@ -198,8 +203,8 @@ pub mod test_helpers { let (seqrepo, seqrepo_path) = if sr_cache_mode == "read" { log::debug!("reading provider..."); - let seqrepo: Rc = - Rc::new(CacheReadingSeqRepo::new(sr_cache_path)?); + let seqrepo: Arc = + Arc::new(CacheReadingSeqRepo::new(sr_cache_path)?); log::debug!("construction done..."); (seqrepo, "".to_string()) } else if sr_cache_mode == "write" { @@ -210,7 +215,7 @@ pub mod test_helpers { }; log::debug!("now returning provider..."); - Ok(Rc::new(Provider::with_seqrepo( + Ok(Arc::new(Provider::with_seqrepo( Config { db_url, db_schema, @@ -223,7 +228,7 @@ pub mod test_helpers { /// Helper that builds the cache writing SeqRepo with inner stock SeqRepo. pub fn build_writing_sr( sr_cache_path: String, - ) -> Result<(Rc, String), Error> { + ) -> Result<(Arc, String), Error> { let seqrepo_path = std::env::var("TEST_SEQREPO_PATH") .expect("Environment variable TEST_SEQREPO_PATH undefined!"); let path_buf = PathBuf::from(seqrepo_path.clone()); @@ -245,10 +250,9 @@ pub mod test_helpers { .to_str() .expect("problem with path to string conversion") .to_string(); - let seqrepo: Rc = Rc::new(CacheWritingSeqRepo::new( - SeqRepo::new(path, &instance)?, - sr_cache_path, - )?); + let seqrepo: Arc = Arc::new( + CacheWritingSeqRepo::new(SeqRepo::new(path, &instance)?, sr_cache_path)?, + ); Ok((seqrepo, seqrepo_path)) } } diff --git a/src/mapper/alignment.rs b/src/mapper/alignment.rs index d442671..3456b76 100644 --- a/src/mapper/alignment.rs +++ b/src/mapper/alignment.rs @@ -22,7 +22,7 @@ // n. -2 -1 ! 1 2 3 4 5 6 7 8 9 // g. ... 123 124 125 126 127 128 129 130 131 132 133 ... -use std::rc::Rc; +use std::sync::Arc; use crate::{ data::interface::{Provider, TxExonsRecord}, @@ -119,7 +119,7 @@ pub struct Mapper { /// Configuration for alignment mapping. pub config: Config, /// Data provider to use for the mapping. - pub provider: Rc, + pub provider: Arc, /// The transcript accession. pub tx_ac: String, @@ -138,7 +138,7 @@ pub struct Mapper { impl Mapper { pub fn new( config: &Config, - provider: Rc, + provider: Arc, tx_ac: &str, alt_ac: &str, alt_aln_method: &str, @@ -499,6 +499,12 @@ mod test { use super::{build_tx_cigar, none_if_default, Mapper}; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + #[test] fn build_tx_cigar_empty() { assert!(build_tx_cigar(&Vec::new(), 1).is_err()); diff --git a/src/mapper/altseq.rs b/src/mapper/altseq.rs index 3a0036c..0ad9585 100644 --- a/src/mapper/altseq.rs +++ b/src/mapper/altseq.rs @@ -1,6 +1,6 @@ //! Code for building alternative sequence and convertion to HGVS.p. -use std::{cmp::Ordering, rc::Rc}; +use std::{cmp::Ordering, sync::Arc}; use crate::{ data::interface::Provider, @@ -35,7 +35,7 @@ impl RefTranscriptData { /// * `tx_ac` -- Transcript accession. /// * `pro_ac` -- Protein accession. pub fn new( - provider: Rc, + provider: Arc, tx_ac: &str, pro_ac: Option<&str>, ) -> Result { diff --git a/src/mapper/assembly.rs b/src/mapper/assembly.rs index 1448a01..586b32b 100644 --- a/src/mapper/assembly.rs +++ b/src/mapper/assembly.rs @@ -2,10 +2,11 @@ use std::collections::{HashMap, HashSet}; use std::ops::Range; -use std::rc::Rc; + +use std::sync::Arc; use crate::mapper::error::Error; -use crate::mapper::variant::{Config as VariantMapperConfig, Mapper as VariantMapper}; +use crate::mapper::variant; use crate::parser::HgvsVariant; use crate::{data::interface::Provider, static_data::Assembly, validator::ValidationLevel}; @@ -68,7 +69,7 @@ impl Default for Config { /// Provides simplified variant mapping for a single assembly and transcript-reference /// alignment method. /// -/// `AssemblyMapper` uses `VariantMapper`, to provide all projection functionality, and add: +/// `AssemblyMapper` uses `variant::Mapper`, to provide all projection functionality, and add: /// /// * Automatic selection of genomic sequence accession /// * Transcript selection from genomic coordinates @@ -76,7 +77,7 @@ impl Default for Config { /// * Special handling for PAR regions /// /// `AssemblyMapper` is instantiated with an assembly name and `alt_aln_method`. These enable -/// the following conveniences over `VariantMapper`: +/// the following conveniences over `variant::Mapper`: /// /// * The assembly and alignment method are used to automatically select an appropriate /// chromosomal reference sequence when mapping from a transcript to a genome (i.e., @@ -90,8 +91,8 @@ impl Default for Config { /// not support contigs or other genomic sequences (e.g., NT_167249.1). pub struct Mapper { config: Config, - provider: Rc, - inner: VariantMapper, + provider: Arc, + inner: variant::Mapper, /// Accessions of contigs in assembly. asm_accessions: HashSet, /// Map from accession to contig name. @@ -100,8 +101,8 @@ pub struct Mapper { impl Mapper { /// Construct new assembly mapper from config and provider. - pub fn new(config: Config, provider: Rc) -> Self { - let inner_config = VariantMapperConfig { + pub fn new(config: Config, provider: Arc) -> Self { + let inner_config = variant::Config { replace_reference: config.replace_reference, strict_validation: config.strict_validation, prevalidation_level: config.prevalidation_level, @@ -110,7 +111,7 @@ impl Mapper { renormalize_g: config.renormalize_g, genome_seq_available: config.genome_seq_available, }; - let inner = VariantMapper::new(&inner_config, provider.clone()); + let inner = variant::Mapper::new(&inner_config, provider.clone()); let asm_accessions = provider .as_ref() .get_assembly_map(config.assembly) @@ -377,6 +378,12 @@ mod test { use super::{Config, Mapper}; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + fn build_mapper_38(normalize: bool) -> Result { let provider = build_provider()?; let config = Config { @@ -403,8 +410,8 @@ mod test { Ok(()) } - /// The following is a port of `Test_VariantMapper` in - /// `test_hgvs_variantmapper_near_discrepancies.py` (sic!) + /// The following is a port of `Test_variant::Mapper` in + /// `test_hgvs_variant::Mapper_near_discrepancies.py` (sic!) mod cases { use anyhow::Error; use std::str::FromStr; @@ -605,7 +612,7 @@ mod test { } /// The following is a port of the `Test_RefReplacement` in - /// `test_hgvs_variantmapper_near_discrepancies.py` (sic!) + /// `test_hgvs_variant::Mapper_near_discrepancies.py` (sic!) mod ref_replacement { use anyhow::Error; use std::str::FromStr; @@ -864,7 +871,7 @@ mod test { } /// The following is a port of `Test_AssemblyMapper` in - /// `test_hgvs_variantmapper_near_discrepancies.py` (sic!) + /// `test_hgvs_variant::Mapper_near_discrepancies.py` (sic!) mod projections { use anyhow::Error; use std::str::FromStr; @@ -930,7 +937,7 @@ mod test { } } - /// The following is a port of the `test_hgvs_variantmapper_near_discrepancies.py` (sic!) + /// The following is a port of the `test_hgvs_variant::Mapper_near_discrepancies.py` (sic!) mod near_discrepancies { use anyhow::Error; use std::str::FromStr; diff --git a/src/mapper/variant.rs b/src/mapper/variant.rs index 4128140..a57b44e 100644 --- a/src/mapper/variant.rs +++ b/src/mapper/variant.rs @@ -1,14 +1,14 @@ //! Code for mapping variants between sequences. -use std::{ops::Range, rc::Rc}; +use std::{ops::Range, sync::Arc}; use log::{debug, info}; -use super::alignment::{Config as AlignmentConfig, Mapper as AlignmentMapper}; +use super::alignment; use crate::{ data::interface::Provider, mapper::Error, - normalizer::{self, Config as NormalizerConfig, Normalizer}, + normalizer::{self, Normalizer}, parser::{ Accession, CdsInterval, CdsLocEdit, CdsPos, GeneSymbol, GenomeInterval, GenomeLocEdit, HgvsVariant, Mu, NaEdit, TxInterval, TxLocEdit, TxPos, @@ -53,8 +53,8 @@ impl Default for Config { /// Projects variants between sequences using `alignment::Mapper`. pub struct Mapper { config: Config, - provider: Rc, - validator: Rc, + provider: Arc, + validator: Arc, } /// Maps SequenceVariant objects between g., n., r., c., and p. representations. @@ -91,7 +91,7 @@ pub struct Mapper { /// differences. For example, c_to_g accounts for the transcription /// start site offset, then calls n_to_g. impl Mapper { - pub fn new(config: &Config, provider: Rc) -> Mapper { + pub fn new(config: &Config, provider: Arc) -> Mapper { let validator = config .prevalidation_level .validator(config.strict_validation, provider.clone()); @@ -110,7 +110,7 @@ impl Mapper { } /// Return a copy of the internal provider. - pub fn provider(&self) -> Rc { + pub fn provider(&self) -> Arc { self.provider.clone() } @@ -120,10 +120,10 @@ impl Mapper { tx_ac: &str, alt_ac: &str, alt_aln_method: &str, - ) -> Result { + ) -> Result { // TODO: implement caching - AlignmentMapper::new( - &AlignmentConfig { + alignment::Mapper::new( + &alignment::Config { strict_bounds: self.config.strict_bounds, }, self.provider.clone(), @@ -139,7 +139,7 @@ impl Mapper { self, self.provider.clone(), self.validator.clone(), - NormalizerConfig { + normalizer::Config { replace_reference: self.config.replace_reference, ..Default::default() }, @@ -959,6 +959,12 @@ mod test { use super::{Config, Mapper}; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + fn build_mapper() -> Result { let provider = build_provider()?; let config = Config::default(); @@ -1085,10 +1091,10 @@ mod test { use anyhow::Error; use std::{ path::{Path, PathBuf}, - rc::Rc, + sync::Arc, }; - use crate::data::interface::Provider as ProviderInterface; + use crate::data::interface; use crate::{ data::interface::TxIdentityInfo, mapper::variant::{Config, Mapper}, @@ -1122,7 +1128,7 @@ mod test { } } - impl ProviderInterface for Provider { + impl interface::Provider for Provider { fn data_version(&self) -> &str { panic!("for test use only"); } @@ -1264,7 +1270,7 @@ mod test { pub fn build_mapper(strict_bounds: bool) -> Result { let path = PathBuf::from("tests/data/mapper/sanity_cp.tsv"); - let provider = Rc::new(Provider::new(&path)?); + let provider = Arc::new(Provider::new(&path)?); let config = Config { strict_bounds, ..Default::default() diff --git a/src/normalizer.rs b/src/normalizer.rs index a02a398..34faa72 100644 --- a/src/normalizer.rs +++ b/src/normalizer.rs @@ -1,11 +1,11 @@ //! Variant normalization. -use std::{cmp::Ordering, ops::Range, rc::Rc}; +use std::{cmp::Ordering, ops::Range, sync::Arc}; pub use crate::normalizer::error::Error; use crate::{ data::interface::Provider, - mapper::variant::Mapper as VariantMapper, + mapper::variant, parser::{ GenomeInterval, GenomeLocEdit, HgvsVariant, MtInterval, MtLocEdit, Mu, NaEdit, RnaInterval, RnaLocEdit, RnaPos, TxInterval, TxLocEdit, TxPos, @@ -87,10 +87,10 @@ impl Default for Config { /// Normalizes variants (5' and 3' shifting). pub struct Normalizer<'a> { - pub provider: Rc, - pub validator: Rc, + pub provider: Arc, + pub validator: Arc, pub config: Config, - pub mapper: &'a VariantMapper, + pub mapper: &'a variant::Mapper, } /// Helper type used in `Normalizer::check_and_guard()`. @@ -102,9 +102,9 @@ struct CheckAndGuardResult { impl<'a> Normalizer<'a> { pub fn new( - mapper: &'a VariantMapper, - provider: Rc, - validator: Rc, + mapper: &'a variant::Mapper, + provider: Arc, + validator: Arc, config: Config, ) -> Self { Self { @@ -1043,7 +1043,7 @@ mod test { use test_log::test; use anyhow::Error; - use std::{rc::Rc, str::FromStr}; + use std::{str::FromStr, sync::Arc}; use pretty_assertions::assert_eq; @@ -1055,11 +1055,17 @@ mod test { validator::IntrinsicValidator, }; + #[test] + fn test_sync() { + fn is_sync() {} + is_sync::(); + } + fn normalizers( mapper: &Mapper, ) -> Result<(Normalizer, Normalizer, Normalizer, Normalizer), Error> { let provider = mapper.provider(); - let validator = Rc::new(IntrinsicValidator::new(true)); + let validator = Arc::new(IntrinsicValidator::new(true)); Ok(( Normalizer::new( diff --git a/src/static_data/mod.rs b/src/static_data/mod.rs index 8c43d88..11b5282 100644 --- a/src/static_data/mod.rs +++ b/src/static_data/mod.rs @@ -10,7 +10,7 @@ const GRCH37_JSON_GZ: &[u8] = include_bytes!("_data/GRCh37.json.gz"); const GRCH37_P10_JSON_GZ: &[u8] = include_bytes!("_data/GRCh37.p10.json.gz"); const GRCH38_JSON_GZ: &[u8] = include_bytes!("_data/GRCh38.json.gz"); -#[derive(Debug, Deserialize, Enum, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Deserialize, Enum, Clone, Copy, PartialEq, Eq, Hash)] pub enum Assembly { Grch37, Grch37p10, diff --git a/src/validator/mod.rs b/src/validator/mod.rs index 9f273ea..81e6a77 100644 --- a/src/validator/mod.rs +++ b/src/validator/mod.rs @@ -2,7 +2,7 @@ mod error; -use std::rc::Rc; +use std::sync::Arc; use log::{error, warn}; @@ -30,11 +30,15 @@ pub enum ValidationLevel { } impl ValidationLevel { - pub fn validator(&self, strict: bool, provider: Rc) -> Rc { + pub fn validator( + &self, + strict: bool, + provider: Arc, + ) -> Arc { match self { - ValidationLevel::Null => Rc::new(NullValidator::new()), - ValidationLevel::Intrinsic => Rc::new(IntrinsicValidator::new(strict)), - ValidationLevel::Full => Rc::new(FullValidator::new(strict, provider)), + ValidationLevel::Null => Arc::new(NullValidator::new()), + ValidationLevel::Intrinsic => Arc::new(IntrinsicValidator::new(strict)), + ValidationLevel::Full => Arc::new(FullValidator::new(strict, provider)), } } } @@ -121,7 +125,7 @@ pub struct ExtrinsicValidator { } impl ExtrinsicValidator { - pub fn new(strict: bool, provider: Rc) -> Self { + pub fn new(strict: bool, provider: Arc) -> Self { let config = Config { replace_reference: false, strict_validation: false, @@ -211,7 +215,7 @@ pub struct FullValidator { } impl FullValidator { - pub fn new(strict: bool, provider: Rc) -> Self { + pub fn new(strict: bool, provider: Arc) -> Self { Self { intrinsic: IntrinsicValidator::new(strict), extrinsic: ExtrinsicValidator::new(strict, provider),