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

Fix multi-compare phenogrid #725

Merged
merged 10 commits into from
May 31, 2024
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

The Monarch Initiative is an extensive knowledge graph and ecosystem of tools made for the benefit of clinicians, researchers, and scientists. The knowledge graph consists of millions of entities – genes, diseases, phenotypes, and many more – imported from dozens of sources.

We welcome the contributions of the community to help us maintain and improve the knowledge graph and the tools that use it. To help get started on contributing to the Monarch Initiative, please see our CONTRIBUTING.md file.
We welcome the contributions of the community to help us maintain and improve the knowledge graph and the tools that use it. To help get started on contributing to the Monarch Initiative, please see our [CONTRIBUTING.md](./CONTRIBUTING.md) file.

# Monarch App

[![documentation](https://img.shields.io/badge/-Documentation-purple?logo=read-the-docs&logoColor=white&style=for-the-badge)](https://monarch-initiative.github.io/monarch-documentation/)
![](https://github.com/monarch-initiative/monarch-app/actions/workflows/test-backend.yaml/badge.svg)
![](https://github.com/monarch-initiative/monarch-app/actions/workflows/test-frontend.yaml/badge.svg)
Expand All @@ -18,9 +19,11 @@ as well as `monarch-py`, a Python library for interacting with the Monarch Initi

If you wish to run Monarch-App as a local web application, please install the requirements below and then follow on to the usage section to start the application. Refer to [Using Local Data](#using-local-data) to see how you can run the full Monarch website locally and use your own data store.

The app also offers a widget called Phenogrid that can be embedded in any website.
For more information on how to use the Phenogrid widget, please refer to the [Phenogrid documentation](./frontend/PHENOGRID.md).

### For developers

The monarch-app repository contains the code to run the Monarch Initiative website in the `frontend` and `backend` directories as well as documentation, helper scripts, Docker files and services to help set up a local environment for development and for deployment.

To start development, please refer to the CONTRIBUTING.md document with this README. If you are planning to only develop the frontend or backend of the application you can refer directly to the README and CONTRIBUTING files in each of those sections.
To start development, please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) document with this README. If you are planning to only develop the frontend or backend of the application you can refer directly to the README and CONTRIBUTING files in each of those sections.
523 changes: 165 additions & 358 deletions backend/poetry.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ packages = [{ include = "monarch_py", from = "src" }]
python = "^3.9"
pydantic = "^2"
curies = "<1"
linkml = "^1.6"
linkml = "^1.7.10"
prefixmaps = "^0.2"
bioregistry = "^0.10.57"
oaklib = ">=0.6.6"

docker = "^7.0.0"
fastapi = "^0.111.0"
docker = "^7.1.0"
# fastapi = "^0.111.0"
fastapi = "^0.103.1"
gunicorn = "^22.0.0"
loguru = "*"
pystow = ">=0.5.4"
requests = "^2.31.0"
rich = "*"
typer = "^0.12"
# spacy = ">=3.7.5,<3.8.0"
# typer = "^0.12"
typer = "^0.7.0"
typer-cli = "^0.0.13"
spacy = { git = "https://github.com/explosion/spaCy.git", branch = "master" }
beautifulsoup4 = "^4.12.3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Middleware to log requests."""

from loguru import logger
import logging

Expand All @@ -10,7 +11,6 @@


class LoggingMiddleware(BaseHTTPMiddleware):

"""Middleware to log requests."""

async def dispatch(self, request: Request, call_next):
Expand Down
47 changes: 22 additions & 25 deletions backend/src/monarch_py/api/semsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def _post_compare(request: SemsimCompareRequest):
Example: <br>
<pre>
{
"subjects": ["MP:0010771","MP:0002169","MP:0005391","MP:0005389","MP:0005367"],
"objects": ["HP:0004325","HP:0000093","MP:0006144"],
"metric": "ancestor_information_content"
"subjects": ["MP:0010771", "MP:0002169"],
"objects": ["HP:0004325"]
"metric": "ancestor_information_content"
}
</pre>
"""
Expand All @@ -94,30 +94,27 @@ def _post_compare(request: SemsimCompareRequest):
@router.post("/multicompare")
def _post_multicompare(request: SemsimMultiCompareRequest):
"""
Pairwise similarity between two sets of terms <br>
<br>
Example: <br>
<pre>
Pairwise similarity between two sets of terms <br>
<br>
Example: <br>
<pre>
{
"metric": "ancestor_information_content",
"subjects": [ "HP:0002616", "HP:0001763", "HP:0004944", "HP:0010749", "HP:0001533", "HP:0002020", "HP:0012450", "HP:0003394", "HP:0003771", "HP:0012378", "HP:0001278", "HP:0002827",
"HP:0002829", "HP:0002999", "HP:0003010"],
"object_sets": [
{
"id": "MGI:97486",
"label": "Pax2",
"phenotypes": [ "MP:0003675", "MP:0003675", "MP:0003675", "MP:0011382", "MP:0011366", "MP:0010097", "MP:0012536", "MP:0003558", "MP:0004729", "MP:0009113", "MP:0006090", "MP:0001325", "MP:0001325", "MP:0006309",
"MP:0004017", "MP:0012533", "MP:0004505", "MP:0004505", "MP:0004505"]
},
{
"id": "MGI:95819",
"label": "Grin1",
"phenotypes": ["MP:0001435", "MP:0001405", "MP:0002797", "MP:0001386", "MP:0001901", "MP:0001901", "MP:0001901", "MP:0001901", "MP:0001901", "MP:0002906", "MP:0004811", "MP:0001900",
"MP:0009748", "MP:0008428", "MP:0008428", "MP:0008428"]
}
]
"metric": "ancestor_information_content",
"subjects": ["HP:0002616","HP:0001763","HP:0004944","HP:0010749","HP:0001533","HP:0002020","HP:0012450"],
"object_sets": [
{
"id": "MGI:2441732",
"label": "Adgrg7",
"phenotypes": ["MP:0011965","MP:0002834","MP:0003731","MP:0011962","MP:0011960","MP:0008489","MP:0003291","MP:0001262"]
},
{
"id": "MGI:87909",
"label": "Acta2",
"phenotypes": ["MP:0002834","MP:0003070","MP:0004022","MP:0004021","MP:0003026","MP:0006264","MP:0000230","MP:0000233","MP:0000272","MP:0009862"]
}
]
}
</pre>
</pre>
"""
return semsimian().multi_compare(request)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ def get_association_facets(
offset=0,
total=query_result.response.num_found,
items=[],
facet_fields=convert_facet_fields(query_result.facet_counts.facet_fields)
if query_result.facet_counts
else [],
facet_queries=convert_facet_queries(query_result.facet_counts.facet_queries)
if query_result.facet_counts
else [],
facet_fields=(
convert_facet_fields(query_result.facet_counts.facet_fields) if query_result.facet_counts else []
),
facet_queries=(
convert_facet_queries(query_result.facet_counts.facet_queries) if query_result.facet_counts else []
),
)

def get_association_table(
Expand Down Expand Up @@ -505,9 +505,9 @@ def get_mappings(
subject_id=[subject_id] if isinstance(subject_id, str) else subject_id,
predicate_id=[p.value for p in predicate_id] if predicate_id else None,
object_id=[object_id] if isinstance(object_id, str) else object_id,
mapping_justification=[mapping_justification]
if isinstance(mapping_justification, str)
else mapping_justification,
mapping_justification=(
[mapping_justification] if isinstance(mapping_justification, str) else mapping_justification
),
offset=offset,
limit=limit,
)
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/fixtures/association_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
def association_counts():
return {
"items": [
{"label": "Phenotypes", "count": 3859, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 119, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 139, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
{"label": "Phenotypes", "count": 3932, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 126, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 146, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
]
}
Loading