diff --git a/Cargo.toml b/Cargo.toml index 63aa1c2..4297288 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hpo" -version = "0.8.0" +version = "0.8.1" edition = "2021" authors = ["Jonas Marcello "] description = "Human Phenotype Ontology Similarity" diff --git a/README.md b/README.md index 60a6758..d1eb0c6 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,27 @@ The most relevant modules are: ## Examples Some (more or less random) examples are included in the [`examples` folder](https://github.com/anergictcell/hpo/tree/main/examples). +HPO data must be downloaded first from [Jax HPO](https://hpo.jax.org/) itself. You need the following files: +- [phenotype.hpoa](https://hpo.jax.org/app/data/annotations) available as "Download HPO annotations" (Required to connect [`OmimDisease`]s to [`HpoTerm`]s) +- [phenotype_to_genes.txt](https://hpo.jax.org/app/data/annotations) available as "Phenotype to genes" (Required to connect [`Gene`]s to [`HpoTerm`]s) +- [hp.obo](https://hpo.jax.org/app/data/ontology) (Required for [`HpoTerm`]s and their connection to each other) + +1. Data can be loaded directly from the code with [`Ontology::from_standard`]: +```no_run + use hpo::Ontology; + let ontology = Ontology::from_standard("/path/to/master-data/").unwrap(); +``` + +2. Or it can be converted to a localy binary by copy `examples/obo_to_bin.rs` into your project, then run . +`cargo run --example --release obo_to_bin ` +Finally, load the data using [`Ontology::from_binary`]: +```no_run + use hpo::Ontology; + let ontology = Ontology::from_binary("your-hpo-binary.hpo").unwrap(); +``` + +3. Another possibility is to use the snapshot from the [Github repository](https://github.com/anergictcell/hpo) of this crate which contains a binary build of the ontology . IT will not always be up to date, so please double-check yourself. + ### Ontology ```rust use hpo::{Ontology, HpoTermId}; diff --git a/src/annotations/omim_disease.rs b/src/annotations/omim_disease.rs index 4308aaf..892ee1e 100644 --- a/src/annotations/omim_disease.rs +++ b/src/annotations/omim_disease.rs @@ -150,7 +150,7 @@ impl OmimDisease { res.append(&mut usize_to_u32(name_length).to_be_bytes().to_vec()); // OMIM Disease name (n bytes) - for c in name.iter() { + for c in name { res.push(*c); } diff --git a/src/parser/binary/term.rs b/src/parser/binary/term.rs index 3a10ba6..d70cd10 100644 --- a/src/parser/binary/term.rs +++ b/src/parser/binary/term.rs @@ -33,7 +33,7 @@ pub(crate) fn from_bytes_v1(bytes: Bytes) -> Result { } let Ok(name) = String::from_utf8(bytes[9..total_len as usize].to_vec()) else { - return Err(HpoError::ParseBinaryError) + return Err(HpoError::ParseBinaryError); }; Ok(HpoTermInternal::new(name, id.into())) } @@ -67,7 +67,7 @@ pub(crate) fn from_bytes_v2(bytes: Bytes) -> Result { } let Ok(name) = String::from_utf8(bytes[9..9 + name_len].to_vec()) else { - return Err(HpoError::ParseBinaryError) + return Err(HpoError::ParseBinaryError); }; let mut term = HpoTermInternal::new(name, id.into()); diff --git a/src/parser/hp_obo.rs b/src/parser/hp_obo.rs index 5aa8337..1e0b843 100644 --- a/src/parser/hp_obo.rs +++ b/src/parser/hp_obo.rs @@ -28,7 +28,7 @@ pub(super) fn read_obo_file>(filename: P, ontology: &mut Ontology let Ok(file_content) = fs::read_to_string(&filename) else { return Err(HpoError::CannotOpenFile( filename.as_ref().display().to_string(), - )) + )); }; for term in file_content.split("\n\n") { diff --git a/src/set.rs b/src/set.rs index d87a496..2fec0f2 100644 --- a/src/set.rs +++ b/src/set.rs @@ -115,6 +115,8 @@ impl<'a> HpoSet<'a> { /// let children = set.child_nodes(); /// assert_eq!(children.len(), 4); /// ``` + /// # Panics + /// TODO pub fn child_nodes(&self) -> Self { let group = self .group diff --git a/src/term/hpoterm.rs b/src/term/hpoterm.rs index feded82..f0bb71e 100644 --- a/src/term/hpoterm.rs +++ b/src/term/hpoterm.rs @@ -920,6 +920,8 @@ impl<'a> HpoTerm<'a> { /// ] /// ); /// ``` + /// # Panics + /// TODO pub fn path_to_term(&self, other: &HpoTerm) -> Option> { if other.parent_of(self) { return self.path_to_ancestor(other);