#![deny(clippy::pedantic)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::module_name_repetitions)]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
use core::fmt::Debug;
use std::num::ParseIntError;
use thiserror::Error;
pub mod annotations;
pub mod matrix;
mod ontology;
mod parser;
mod set;
pub mod similarity;
pub mod stats;
pub mod term;
pub mod utils;
pub use ontology::comparison;
pub use ontology::Ontology;
pub use set::HpoSet;
pub use term::{HpoTerm, HpoTermId};
const DEFAULT_NUM_PARENTS: usize = 10;
const DEFAULT_NUM_ALL_PARENTS: usize = 30;
const DEFAULT_NUM_GENES: usize = 50;
const DEFAULT_NUM_OMIM: usize = 20;
const MAX_HPO_ID_INTEGER: usize = 10_000_000;
const OBO_FILENAME: &str = "hp.obo";
const GENE_FILENAME: &str = "phenotype_to_genes.txt";
const DISEASE_FILENAME: &str = "phenotype.hpoa";
pub const PHENOTYPE_ID: HpoTermId = HpoTermId::from_u32(118);
#[derive(Error, Debug)]
pub enum HpoError {
#[error("not implemented")]
NotImplemented,
#[error("term does not exist")]
DoesNotExist,
#[error("unable to parse Integer")]
ParseIntError,
#[error("unable to parse binary data")]
ParseBinaryError,
#[error("cannot open file {0}")]
CannotOpenFile(String),
#[error("cannot convert int to float")]
TryFromIntError(#[from] std::num::TryFromIntError),
}
impl From<ParseIntError> for HpoError {
fn from(_: ParseIntError) -> Self {
HpoError::ParseIntError
}
}
pub type HpoResult<T> = Result<T, HpoError>;
fn u32_from_bytes(bytes: &[u8]) -> u32 {
u32::from_be_bytes([bytes[0], bytes[1], bytes[2], bytes[3]])
}
fn f32_from_usize(n: usize) -> HpoResult<f32> {
let intermediate: u16 = n.try_into()?;
Ok(intermediate.into())
}