Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with downloading HPO data #47

Merged
merged 3 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hpo"
version = "0.8.0"
version = "0.8.1"
edition = "2021"
authors = ["Jonas Marcello <jonas.marcello@esbme.com>"]
description = "Human Phenotype Ontology Similarity"
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PATH TO FOLDER WITH JAX DATA> <OUTPUT FILENAME>`
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 <https://github.com/anergictcell/hpo/blob/main/tests/ontology.hpo>. IT will not always be up to date, so please double-check yourself.

### Ontology
```rust
use hpo::{Ontology, HpoTermId};
Expand Down
2 changes: 1 addition & 1 deletion src/annotations/omim_disease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser/binary/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) fn from_bytes_v1(bytes: Bytes) -> Result<HpoTermInternal, HpoError> {
}

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()))
}
Expand Down Expand Up @@ -67,7 +67,7 @@ pub(crate) fn from_bytes_v2(bytes: Bytes) -> Result<HpoTermInternal, HpoError> {
}

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());

Expand Down
2 changes: 1 addition & 1 deletion src/parser/hp_obo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(super) fn read_obo_file<P: AsRef<Path>>(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") {
Expand Down
2 changes: 2 additions & 0 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/term/hpoterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ impl<'a> HpoTerm<'a> {
/// ]
/// );
/// ```
/// # Panics
/// TODO
pub fn path_to_term(&self, other: &HpoTerm) -> Option<Vec<HpoTermId>> {
if other.parent_of(self) {
return self.path_to_ancestor(other);
Expand Down
Loading