Skip to content

Commit

Permalink
Fixes for cargo fmt, test and clippy
Browse files Browse the repository at this point in the history
Minor changes. Documentation should be added for panics.
  • Loading branch information
apraga committed Mar 6, 2024
1 parent e8dcc1f commit bdb8f52
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ 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();
```

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

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

0 comments on commit bdb8f52

Please sign in to comment.