Skip to content

Commit

Permalink
Merge pull request #65 from anergictcell/refactor/remove-aquamarine
Browse files Browse the repository at this point in the history
Add `Builder` struct and refactor documentation
  • Loading branch information
anergictcell authored Aug 25, 2024
2 parents bcc1187 + 31f466f commit d0d89f6
Show file tree
Hide file tree
Showing 14 changed files with 1,390 additions and 1,114 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ categories = ["science", "data-structures", "parser-implementations"]

[dependencies]
thiserror = "1.0"
aquamarine = "0" # used in Docs
tracing = "0.1"
smallvec = "1"

Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ 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();
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
```sh
cargo run --example --release obo_to_bin <PATH TO FOLDER WITH JAX DATA> <OUTPUT FILENAME>`
```

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();
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.
Expand Down Expand Up @@ -164,7 +168,7 @@ fn example() {
```
### Enrichment
Identify which genes (or diseases) are enriched in a set of HpoTerms, e.g. in
Identify which genes (or diseases) are enriched in a set of `HpoTerm`s, e.g. in
the clinical information of a patient or patient cohort
```rust
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc-valid-idents = ["MacBook", ".."]
12 changes: 11 additions & 1 deletion src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ pub use orpha_disease::{OrphaDisease, OrphaDiseaseId, OrphaDiseaseIterator, Orph
/// The ID must be unique only within the annotation type, i.e. a gene and a disease
/// can have the same ID.
pub trait AnnotationId:
Clone + Copy + Debug + Hash + PartialEq + PartialOrd + Eq + Ord + Display + From<u32>
Clone
+ Copy
+ Debug
+ Hash
+ PartialEq
+ PartialOrd
+ Eq
+ Ord
+ Display
+ From<u32>
+ for<'a> TryFrom<&'a str>
{
/// Return the integer representation of the annotation ID
fn as_u32(&self) -> u32;
Expand Down
4 changes: 2 additions & 2 deletions src/annotations/gene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Gene {
/// Initializes a new Gene
///
/// This method should rarely, if ever, be used directly. The
/// preferred way to create new genes is through [`Ontology::add_gene`]
/// preferred way to create new genes is through [`Builder::annotate_gene`](`crate::builder::Builder::annotate_gene`)
/// to ensure that each gene exists only once.
pub fn new(id: GeneId, name: &str) -> Gene {
Gene {
Expand All @@ -90,7 +90,7 @@ impl Gene {
/// Initializes a new Gene from `str` values
///
/// This method should rarely, if ever, be used directly. The
/// preferred way to create new genes is through [`Ontology::add_gene`]
/// preferred way to create new genes is through [`Builder::annotate_gene`](`crate::builder::Builder::annotate_gene`)
/// to ensure that each gene exists only once.
///
/// # Errors
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 @@ -72,7 +72,7 @@ impl Disease for OmimDisease {
/// Initializes a new OMIM disease
///
/// This method should rarely, if ever, be used directly. The
/// preferred way to create new genes is through [`crate::Ontology::add_omim_disease`]
/// preferred way to create new genes is through [`Builder::annotate_omim_disease`](`crate::builder::Builder::annotate_omim_disease`)
/// to ensure that each disease exists only once.
fn new(id: Self::AnnoID, name: &str) -> OmimDisease {
Self {
Expand Down
2 changes: 1 addition & 1 deletion src/annotations/orpha_disease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Disease for OrphaDisease {
/// Initializes a new Orpha disease
///
/// This method should rarely, if ever, be used directly. The
/// preferred way to create new genes is through [`crate::Ontology::add_orpha_disease`]
/// preferred way to create new genes is through [`Builder::annotate_orpha_disease`](`crate::builder::Builder::annotate_orpha_disease`)
/// to ensure that each disease exists only once.
fn new(id: Self::AnnoID, name: &str) -> OrphaDisease {
Self {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod stats;
pub mod term;
pub mod utils;

pub use ontology::builder;
pub use ontology::comparison;
pub use ontology::Ontology;
pub use set::HpoSet;
Expand Down
Loading

0 comments on commit d0d89f6

Please sign in to comment.