-
Notifications
You must be signed in to change notification settings - Fork 5
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
[#72] added service for single entity #73
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
package org.monarchinitiative.owlsim.services.resources; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.monarchinitiative.owlsim.compute.classmatch.ClassMatcher; | ||
import org.monarchinitiative.owlsim.compute.classmatch.SimpleClassMatch; | ||
import org.monarchinitiative.owlsim.compute.cpt.IncoherentStateException; | ||
import org.monarchinitiative.owlsim.compute.matcher.NegationAwareProfileMatcher; | ||
import org.monarchinitiative.owlsim.compute.matcher.ProfileMatcher; | ||
import org.monarchinitiative.owlsim.kb.filter.AnonIndividualFilter; | ||
import org.monarchinitiative.owlsim.kb.filter.TypeFilter; | ||
import org.monarchinitiative.owlsim.kb.filter.UnknownFilterException; | ||
import org.monarchinitiative.owlsim.model.match.MatchSet; | ||
import org.monarchinitiative.owlsim.model.match.ProfileQuery; | ||
import org.monarchinitiative.owlsim.model.match.ProfileQueryFactory; | ||
import org.monarchinitiative.owlsim.services.exceptions.NonNegatedMatcherException; | ||
import org.monarchinitiative.owlsim.services.exceptions.UnknownMatcherException; | ||
import org.prefixcommons.CurieUtil; | ||
|
||
import com.codahale.metrics.annotation.Timed; | ||
|
||
import io.dropwizard.jersey.caching.CacheControl; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
|
||
import io.dropwizard.jersey.caching.CacheControl; | ||
|
||
@Path("/ontomatch") | ||
@Api(value = "/ontomatch", description = "ontology match services") | ||
@Produces({MediaType.APPLICATION_JSON}) | ||
public class OntologyMatchResource { | ||
|
||
@Inject | ||
ClassMatcher classMatcher; | ||
|
||
@Inject | ||
CurieUtil curieUtil; | ||
|
||
@GET | ||
@Path("/{queryOntology}/{targetOntology}") | ||
|
@@ -61,6 +52,28 @@ public List<SimpleClassMatch> getOntoMatches( | |
return matches; | ||
} | ||
|
||
|
||
// TODO - API for comparing two entities | ||
|
||
@GET | ||
@Path("/{entity}/{ontology}") | ||
@Timed | ||
@CacheControl(maxAge = 2, maxAgeUnit = TimeUnit.HOURS) | ||
@ApiOperation(value = "Match", response = MatchSet.class, | ||
notes = "Additional notes on the match resource.") | ||
public List<SimpleClassMatch> getEntityMatches( | ||
@ApiParam(value = "entity, e.g. MP:0001951", | ||
required = true) @PathParam("entity") String entity, | ||
@ApiParam(value = "ontology to be matched, e.g. HP", | ||
required = true) @PathParam("ontology") String ontology) | ||
throws UnknownFilterException, IncoherentStateException { | ||
|
||
// TODO it's weird to resolve the curie here | ||
String resolveEntity = curieUtil.getIri(entity).orElse(entity); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a common pattern using the |
||
|
||
List<SimpleClassMatch> matches = | ||
classMatcher.matchEntity(resolveEntity, ontology); | ||
return matches; | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
But you're passing the
entity
into theClassMatcher
via thematchEntity()
method so you have the curieUtil accessible from you in there and don't need to do it here.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.
You mean passing the
CurieUtil
as a parameter ofmatchEntity()
?I'm wondering if the
ClassMatcher
should have aCurieUtil
in the constructor, what do you think?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.
Ahh, no sorry - I'm mistaken. The
curieUtil
is used internally within theBMKnowledgebase
, but is not accessible from it. Providing the ClassMatcher with thecurieUtil
andbmKnowledgeBase
in the constructor would solve this. Then you can moveinto the
ClassMatcher
.I just wonder to what extent we need to hide the
CurieUtil
inside theBMKnowledgeBase
- presumably we're always going to use the OWLAPI and theCurieUtil
in theBMKnowledgeBase
? If that's the case and these are going to be required externally to query theBMKnowledgeBase
, then it should expose them so they can be used, or provide methods like: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.
Yep I was also leaning towards that solution, I'll make that change in my PR!
Thanks!
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.
I meant to add the
resolveIri()
method to theBMKnowledgeBase
interface, in case I wasn't clear - which I wasn't!