pub struct MSVocabulary();Expand description
A global facade for interacting with the PSI-MS controlled vocabulary.
This requires the cv feature which uses the mzcv library to work
with OBO files, runtime caching and embed static compile-time embedding
of controlled vocabulary data.
This type is a singleton guarded by a OnceLock wrapping a mzcv::CVIndex
that lets the caller fetch MSTerm entries by accession CURIE or name. It
also lets the caller traverse the controlled vocabulary tree.
let term = MSVocabulary::get(curie!(MS:1000044)).unwrap();
assert_eq!(term.name.as_ref(), "dissociation method");
assert!(!MSVocabulary::children_of(term.accession()).expect("this term is defined!").is_empty());§Data Source
Alternatively, you can take a reference to the global instance with
MSVocabulary::init, which first checks the on-disk cache and then
uses the statically embedded copy of the controlled vocabulary if it
isn’t available. Using MSVocabulary::init_static directly uses the
fixed, pre-compiled version if it is the first call. Finally, you can
choose to update the cached on-disk version using MSVocabulary::update_from_obo,
see the method documentation for more details.
Implementations§
Source§impl MSVocabulary
impl MSVocabulary
Sourcepub fn update_from_obo<P>(obo_path: P) -> Result<(), Box<dyn Error>>
pub fn update_from_obo<P>(obo_path: P) -> Result<(), Box<dyn Error>>
Update the PSI-MS vocabulary to the version at the provided path. This will update the parsed cache on disk and attempt to set the global in-memory representation to use this version.
§Warning
If the controlled vocabulary is already loaded, this will fail to update the current version in memory, but should still update the version on disk so that it will be read from when the a new process starts.
This does not update the compile time static version embedded in the binary used by Self::init_static.
That can only be upgraded at build time.
Sourcepub fn init() -> &'static CVIndex<MSVocabulary>
pub fn init() -> &'static CVIndex<MSVocabulary>
Get or create the global instance of the mzcv::CVIndex for MSVocabulary
Sourcepub fn init_static() -> &'static CVIndex<MSVocabulary>
pub fn init_static() -> &'static CVIndex<MSVocabulary>
Get or create the global instance of the mzcv::CVIndex for MSVocabulary
using only the statically embedded data.
Sourcepub fn get_by_name(name: &str) -> Option<Arc<MSTerm>>
pub fn get_by_name(name: &str) -> Option<Arc<MSTerm>>
Get a term by its human-readable name in a case-insensitive manner.
Sourcepub fn get_by_name_or_synonym(name: &str) -> Option<(bool, Arc<MSTerm>)>
pub fn get_by_name_or_synonym(name: &str) -> Option<(bool, Arc<MSTerm>)>
Load a term by name or if that fails by synonym, names are matched in a case insensitive manner. Returns a boolean indicating if it matches a name true or a synonym false
Sourcepub fn parents_of(curie: CURIE) -> Option<HashSet<Compat<CURIE>>>
pub fn parents_of(curie: CURIE) -> Option<HashSet<Compat<CURIE>>>
Get the immediate parents of this term
This follows the is_a OBO relationship.
Sourcepub fn parents_of_recursive(curie: CURIE) -> HashSet<Compat<CURIE>>
pub fn parents_of_recursive(curie: CURIE) -> HashSet<Compat<CURIE>>
Get all parents of this term, recursively querying the graph
This follows the is_a OBO relationship.
Sourcepub fn children_of(curie: CURIE) -> Option<&'static [Compat<CURIE>]>
pub fn children_of(curie: CURIE) -> Option<&'static [Compat<CURIE>]>
Get the immediate children of this term
This follows the is_a OBO relationship.
Sourcepub fn is_child_of(child: CURIE, parent: CURIE) -> bool
pub fn is_child_of(child: CURIE, parent: CURIE) -> bool
Test if child is derived from parent along a transitive is_a relationship
Trait Implementations§
Source§impl CVSource for MSVocabulary
impl CVSource for MSVocabulary
Source§type Structure = VocabularyData<MSTerm>
type Structure = VocabularyData<MSTerm>
Source§fn cv_name() -> &'static str
fn cv_name() -> &'static str
Source§fn static_data() -> Option<(CVVersion, <MSVocabulary as CVSource>::Structure)>
fn static_data() -> Option<(CVVersion, <MSVocabulary as CVSource>::Structure)>
Source§fn parse(
reader: impl Iterator<Item = HashBufReader<Box<dyn Read>, impl Digest>>,
) -> Result<(CVVersion, <MSVocabulary as CVSource>::Structure, Vec<BoxedError<'static, CVError>>), Vec<BoxedError<'static, CVError>>>
fn parse( reader: impl Iterator<Item = HashBufReader<Box<dyn Read>, impl Digest>>, ) -> Result<(CVVersion, <MSVocabulary as CVSource>::Structure, Vec<BoxedError<'static, CVError>>), Vec<BoxedError<'static, CVError>>>
Source§const AUTOMATICALLY_WRITE_UNCOMPRESSED: bool = false
const AUTOMATICALLY_WRITE_UNCOMPRESSED: bool = false
Source§fn cv_label() -> &'static str
fn cv_label() -> &'static str
Source§fn default_stem() -> PathBuf
fn default_stem() -> PathBuf
Source§fn write_uncompressed<W>(
_writer: W,
_version: &CVVersion,
_data: impl Iterator<Item = Arc<Self::Data>>,
) -> Result<(), BoxedError<'static, CVError>>where
W: Write,
fn write_uncompressed<W>(
_writer: W,
_version: &CVVersion,
_data: impl Iterator<Item = Arc<Self::Data>>,
) -> Result<(), BoxedError<'static, CVError>>where
W: Write,
AUTOMATICALLY_WRITE_UNCOMPRESSED is set to true. This is used to write out data when the
main way of interacting with this structure is via the crate::CVIndex::update method.
So for custom modification CVs for example. Read moreSource§impl CVTraversal<MSVocabulary> for CVIndex<MSVocabulary>
impl CVTraversal<MSVocabulary> for CVIndex<MSVocabulary>
fn child_map( &self, ) -> &HashMap<Compat<<MSTerm as CVData>::Index>, Vec<Compat<<MSTerm as CVData>::Index>>>
Source§fn children_of(
&self,
curie: CURIE,
) -> Option<&[Compat<<<MSVocabulary as CVSource>::Data as CVData>::Index>]>
fn children_of( &self, curie: CURIE, ) -> Option<&[Compat<<<MSVocabulary as CVSource>::Data as CVData>::Index>]>
Source§fn parents_of(
&self,
curie: CURIE,
) -> Option<HashSet<Compat<<<MSVocabulary as CVSource>::Data as CVData>::Index>>>
fn parents_of( &self, curie: CURIE, ) -> Option<HashSet<Compat<<<MSVocabulary as CVSource>::Data as CVData>::Index>>>
Source§fn get_by_index(
&self,
key: <<MSVocabulary as CVSource>::Data as CVData>::Index,
) -> Option<Arc<<MSVocabulary as CVSource>::Data>>
fn get_by_index( &self, key: <<MSVocabulary as CVSource>::Data as CVData>::Index, ) -> Option<Arc<<MSVocabulary as CVSource>::Data>>
mzcv::CVIndex::get_by_indexSource§fn parents_of_recursive(
&self,
curie: <<T as CVSource>::Data as CVData>::Index,
) -> HashSet<Compat<<<T as CVSource>::Data as CVData>::Index>>
fn parents_of_recursive( &self, curie: <<T as CVSource>::Data as CVData>::Index, ) -> HashSet<Compat<<<T as CVSource>::Data as CVData>::Index>>
Auto Trait Implementations§
impl Freeze for MSVocabulary
impl RefUnwindSafe for MSVocabulary
impl Send for MSVocabulary
impl Sync for MSVocabulary
impl Unpin for MSVocabulary
impl UnsafeUnpin for MSVocabulary
impl UnwindSafe for MSVocabulary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.