Struct hpo::annotations::OmimDisease
source · pub struct OmimDisease { /* private fields */ }
Expand description
A single OMIM disease
A disease has a unique OmimDiseaseId
and a name and is
connected to a set of HPO terms
Implementations§
source§impl OmimDisease
impl OmimDisease
sourcepub fn new(id: OmimDiseaseId, name: &str) -> OmimDisease
pub fn new(id: OmimDiseaseId, name: &str) -> OmimDisease
Initializes a new OMIM disease
This method should rarely, if ever, be used directly. The
preferred way to create new genes is through Ontology::add_omim_disease
to ensure that each disease exists only once.
sourcepub fn id(&self) -> &OmimDiseaseId
pub fn id(&self) -> &OmimDiseaseId
The unique OmimDiseaseId
of the disease, the OMIM MIM number
sourcepub fn add_term<I: Into<HpoTermId>>(&mut self, term_id: I) -> bool
pub fn add_term<I: Into<HpoTermId>>(&mut self, term_id: I) -> bool
Connect another HPO term to the disease
sourcepub fn as_bytes(&self) -> Vec<u8> ⓘ
pub fn as_bytes(&self) -> Vec<u8> ⓘ
Returns a binary representation of the OmimDisease
The binary layout is defined as:
Byte offset | Number of bytes | Description |
---|---|---|
0 | 4 | The total length of the binary data blob as big-endian u32 |
4 | 4 | The OmimDiseaseId as big-endian u32 |
8 | 4 | The length of the OmimDisease Name as big-endian u32 |
12 | n | The OmimDisease name as u8 vector |
12 + n | 4 | The number of associated HPO terms as big-endian u32 |
16 + n | x * 4 | The HpoTermId s of the associated terms, each encoded as big-endian u32 |
§Examples
use hpo::annotations::OmimDisease;
let mut disease = OmimDisease::new(123.into(), "FooBar");
let bytes = disease.as_bytes();
assert_eq!(bytes.len(), 4 + 4 + 4 + 6 + 4);
assert_eq!(bytes[4..8], [0u8, 0u8, 0u8, 123u8]); // ID of disease => 123
assert_eq!(bytes[8..12], [0u8, 0u8, 0u8, 6u8]); // Length of Name => 6
sourcepub fn to_hpo_set<'a>(&self, ontology: &'a Ontology) -> HpoSet<'a>
pub fn to_hpo_set<'a>(&self, ontology: &'a Ontology) -> HpoSet<'a>
Returns an HpoSet
from the OmimDisease
Trait Implementations§
source§impl Clone for OmimDisease
impl Clone for OmimDisease
source§fn clone(&self) -> OmimDisease
fn clone(&self) -> OmimDisease
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for OmimDisease
impl Debug for OmimDisease
source§impl Default for OmimDisease
impl Default for OmimDisease
source§fn default() -> OmimDisease
fn default() -> OmimDisease
Returns the “default value” for a type. Read more
source§impl Hash for OmimDisease
impl Hash for OmimDisease
source§impl PartialEq for OmimDisease
impl PartialEq for OmimDisease
source§fn eq(&self, other: &OmimDisease) -> bool
fn eq(&self, other: &OmimDisease) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl TryFrom<&[u8]> for OmimDisease
impl TryFrom<&[u8]> for OmimDisease
source§fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>
Returns an OmimDisease
from a bytes vector
The byte layout for this method is defined in
OmimDisease::as_bytes
§Examples
use hpo::annotations::{OmimDisease, OmimDiseaseId};
let bytes = vec![
0u8, 0u8, 0u8, 22u8, // Total size of Blop
0u8, 0u8, 0u8, 123u8, // ID of the disease => 123
0u8, 0u8, 0u8, 6u8, // Length of name => 6
b'F', b'o', b'o', b'b', b'a', b'r', // Foobar
0u8, 0u8, 0u8, 0u8 // Number of associated HPO Terms => 0
];
let disease = OmimDisease::try_from(&bytes[..]).unwrap();
assert_eq!(disease.name(), "Foobar");
assert_eq!(disease.id(), &OmimDiseaseId::from(123u32));
impl Eq for OmimDisease
Auto Trait Implementations§
impl Freeze for OmimDisease
impl RefUnwindSafe for OmimDisease
impl Send for OmimDisease
impl Sync for OmimDisease
impl Unpin for OmimDisease
impl UnwindSafe for OmimDisease
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
Mutably borrows from an owned value. Read more
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<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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.