-
Notifications
You must be signed in to change notification settings - Fork 1
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
Searching OMIM disease by name (partial match) #49
Searching OMIM disease by name (partial match) #49
Conversation
Thanks for the suggestion, this makes total sense to add to hpo. I'll try to help a bit with a few comments and remarks:
struct DiseaseIter<'a, F> {
inner: Filter<Values<'a, OmimDiseaseId, OmimDisease>, F>
}
impl<'a, F: FnMut(&&'a OmimDisease) -> bool + 'a> Iterator for DiseaseIter<'a, F> {
type Item = &'a OmimDisease;
fn next(&mut self) -> Option<Self::Item> {
self.inner.next()
}
}
impl Ontology {
// ...
pub fn diseases_by_name<'a>(&'a self, symbol: &'a str) -> DiseaseIter<impl FnMut(&&'a OmimDisease) -> bool + 'a> {
DiseaseIter{ inner: self.omim_diseases.values().filter(move |disease| disease.name() == symbol)}
}
// ...
} (I would actually prefer this even more strict and add the Your As for testing during development, I use an LSP (rust-analyzer) in my IDE that helps me to make sure I don't make any typing errors while coding. # Automatically fix formatting of the source code
cargo fmt
# Show suggestions how to improve my code
cargo clippy
# Run all tests
cargo test Feel free to ask more questions, I'm happy to help whenever I can. And thanks for helping to make |
Thanks a lot for your thoughtful and very details answer. I've edited the commit accordingly. However, I was unable to make the following tests works as the result order does not seems to be deterministic.
Actually, I also want to be able to search terms by name too, hence the PR name :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, the changes look very good, thanks a lot. I entered a few inline comments and have some minor suggestions in addition:
-
Can you rebase onto the current
main
branch. Some of the previous changes (e.g. version updates) are appearing in your commit but are already present in themain
branch. -
Please add some unit test cases as well, not only the doctests.
-
I suggest to add the following tetst cases for both functions:
- query that does not match any diseases
- query that matches exactly one disease
- query that matches several diseases. You rightfully mention that the order changes, so you could only check for the number of returned items or check the the returned disease is within a set of your expected results.
One function to get only the first match, the second returns an iterator for all matches, following @anergetictcell suggestions in #49.
The code has been changed according to your suggestions with 3 test cases for both function. Thanks for your help. |
Hi,
From the documentation, I could not find how to look for an HPO entity by name (like
get_hpo_object
in pyhpo ?). Here's a first stab at it. As it's my first commit to a rust project, I could not run the test but would like your advice regarding this feature.Thanks !