From 330fc0563ea5f0be801e82ba4bee6536017e0078 Mon Sep 17 00:00:00 2001 From: Jonas Marcello Date: Sun, 25 Jun 2023 20:55:49 +0200 Subject: [PATCH 1/3] Version bump to 0.8.1 Update README with downloading HPO data --- Cargo.toml | 2 +- README.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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..d5e71e5 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,25 @@ 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`]: +```rust + 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`]: +```rust + 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}; From e8dcc1fb777918c28b5c5402c9d99f7f601901dd Mon Sep 17 00:00:00 2001 From: Alexis Praga Date: Wed, 6 Mar 2024 17:46:19 +0100 Subject: [PATCH 2/3] Update README with downloading HPO data --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5e71e5..13d811a 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,14 @@ HPO data must be downloaded first from [Jax HPO](https://hpo.jax.org/) itself. - [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`]: -```rust +```no_run 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`]: -```rust +```no_run let ontology = Ontology::from_binary("your-hpo-binary.hpo").unwrap(); ``` From bdb8f52a52dc06832edec4b9f5a3f9a1942b3189 Mon Sep 17 00:00:00 2001 From: Alexis Praga Date: Wed, 6 Mar 2024 17:53:44 +0100 Subject: [PATCH 3/3] Fixes for cargo fmt, test and clippy Minor changes. Documentation should be added for panics. --- README.md | 2 ++ src/annotations/omim_disease.rs | 2 +- src/parser/binary/term.rs | 4 ++-- src/parser/hp_obo.rs | 2 +- src/set.rs | 2 ++ src/term/hpoterm.rs | 2 ++ 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 13d811a..d1eb0c6 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ HPO data must be downloaded first from [Jax HPO](https://hpo.jax.org/) itself. 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(); ``` @@ -57,6 +58,7 @@ HPO data must be downloaded first from [Jax HPO](https://hpo.jax.org/) itself. `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(); ``` 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);