Skip to content
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

Adds a full entity to the semsim search response #504

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/src/monarch_py/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ def search(self, termset: List[str], prefix: str, limit: int):
response = rq.get(url=url)
data = response.json()
results = [
SemsimSearchResult(score=i[0], similarity=self.convert_tsps_data(i[1]), subject_id=i[2]) for i in data
SemsimSearchResult(
subject=solr().get_entity(i[2], extra=False), score=i[0], similarity=self.convert_tsps_data(i[1])
)
for i in data
]

return results


Expand Down
2 changes: 1 addition & 1 deletion backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ class BestMatch(ConfiguredBaseModel):

class SemsimSearchResult(ConfiguredBaseModel):

subject_id: str = Field(...)
subject: Entity = Field(...)
score: Optional[float] = Field(None)
similarity: Optional[TermSetPairwiseSimilarity] = Field(None)

Expand Down
6 changes: 5 additions & 1 deletion backend/src/monarch_py/datamodels/similarity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ classes:

SemsimSearchResult:
slots:
- subject_id
- subject
- score
- similarity
slot_usage:
subject:
range: Entity
inlined: true

types:
ZeroToOne:
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def association_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 1,
"params": {
"mm": "100%",
"q": "*:*",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/autocomplete_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def autocomplete_response():
return {
"responseHeader": {
"QTime": 1,
"QTime": 0,
"params": {
"mm": "100%",
"q": "fanc",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/histopheno_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def histopheno_response():
return {
"responseHeader": {
"QTime": 2,
"QTime": 1,
"params": {
"facet.query": [
'object_closure:"HP:0000924"',
Expand Down
12 changes: 6 additions & 6 deletions backend/tests/fixtures/phenotype_explorer_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
def phenotype_explorer_compare():
return {
"subject_termset": {
"MP:0010771": {"id": "MP:0010771", "label": "integument phenotype (MPO)"},
"MP:0002169": {"id": "MP:0002169", "label": "no abnormal phenotype detected (MPO)"},
"MP:0010771": {"id": "MP:0010771", "label": "integument phenotype (MPO)"},
},
"object_termset": {"HP:0004325": {"id": "HP:0004325", "label": "Decreased body weight (HPO)"}},
"subject_best_matches": {
Expand Down Expand Up @@ -69,16 +69,16 @@ def phenotype_explorer_compare():
"HP:0004325": {
"match_source": "HP:0004325",
"match_source_label": "Decreased body weight (HPO)",
"match_target": "MP:0010771",
"match_target_label": "integument phenotype (MPO)",
"match_target": "MP:0002169",
"match_target_label": "no abnormal phenotype detected (MPO)",
"score": 1.5540019332516637,
"match_subsumer": None,
"match_subsumer_label": None,
"similarity": {
"subject_id": "HP:0004325",
"subject_label": None,
"subject_source": None,
"object_id": "MP:0010771",
"object_id": "MP:0002169",
"object_label": None,
"object_source": None,
"ancestor_id": "UPHENO:0001003",
Expand All @@ -87,10 +87,10 @@ def phenotype_explorer_compare():
"object_information_content": None,
"subject_information_content": None,
"ancestor_information_content": 1.5540019332516637,
"jaccard_similarity": 0.24,
"jaccard_similarity": 0.23076923076923078,
"cosine_similarity": None,
"dice_similarity": None,
"phenodigm_score": 0.61070489107293,
"phenodigm_score": 0.5988454147360435,
},
}
},
Expand Down
Loading