Skip to content

Commit

Permalink
Adds frequency_quantifier mixin fields as defined by biolink-model (#606
Browse files Browse the repository at this point in the history
)

Required for #329
  • Loading branch information
kevinschaper authored Mar 12, 2024
1 parent 5c1d4a2 commit eb35fd0
Show file tree
Hide file tree
Showing 39 changed files with 67,860 additions and 47,589 deletions.
3 changes: 1 addition & 2 deletions backend/src/monarch_py/api/semsim.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fastapi import APIRouter, Path, Query
from typing import List

from monarch_py.api.additional_models import (
SemsimCompareRequest,
Expand All @@ -10,7 +9,7 @@
from monarch_py.api.config import semsimian, solr
from monarch_py.api.utils.similarity_utils import parse_similarity_prefix
from monarch_py.datamodels.category_enums import AssociationPredicate, EntityCategory
from monarch_py.datamodels.model import SearchResults, SemsimSearchResult
from monarch_py.datamodels.model import SearchResults

router = APIRouter(tags=["semsim"], responses={404: {"description": "Not Found"}})

Expand Down
14 changes: 14 additions & 0 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class Association(ConfiguredBaseModel):
has_evidence_links: Optional[List[ExpandedCurie]] = Field(
default_factory=list, description="""List of ExpandedCuries with id and url for evidence"""
)
has_count: Optional[int] = Field(None, description="""count of out of has_total representing a frequency""")
has_total: Optional[int] = Field(None, description="""total, devided by has_count, representing a frequency""")
has_percentage: Optional[float] = Field(
None,
description="""percentage, which may be calculated from has_count and has_total, as 100 * quotient or provided directly, rounded to the integer level""",
)
has_quotient: Optional[float] = Field(None, description="""quotient, which should be 1/100 of has_percentage""")
grouping_key: Optional[str] = Field(
None,
description="""A concatenation of fields used to group associations with the same essential/defining properties""",
Expand Down Expand Up @@ -264,6 +271,13 @@ class DirectionalAssociation(Association):
has_evidence_links: Optional[List[ExpandedCurie]] = Field(
default_factory=list, description="""List of ExpandedCuries with id and url for evidence"""
)
has_count: Optional[int] = Field(None, description="""count of out of has_total representing a frequency""")
has_total: Optional[int] = Field(None, description="""total, devided by has_count, representing a frequency""")
has_percentage: Optional[float] = Field(
None,
description="""percentage, which may be calculated from has_count and has_total, as 100 * quotient or provided directly, rounded to the integer level""",
)
has_quotient: Optional[float] = Field(None, description="""quotient, which should be 1/100 of has_percentage""")
grouping_key: Optional[str] = Field(
None,
description="""A concatenation of fields used to group associations with the same essential/defining properties""",
Expand Down
16 changes: 16 additions & 0 deletions backend/src/monarch_py/datamodels/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ classes:
- evidence_count
- has_evidence
- has_evidence_links
- has_count
- has_total
- has_percentage
- has_quotient
- grouping_key
- provided_by
- provided_by_link
Expand Down Expand Up @@ -389,6 +393,18 @@ slots:
grouping_key:
description: A concatenation of fields used to group associations with the same essential/defining properties
range: string
has_count:
description: count of out of has_total representing a frequency
range: integer
has_total:
description: total, devided by has_count, representing a frequency
range: integer
has_percentage:
description: percentage, which may be calculated from has_count and has_total, as 100 * quotient or provided directly, rounded to the integer level
range: float
has_quotient:
description: quotient, which should be 1/100 of has_percentage
range: float
has_evidence:
range: string
multivalued: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def build_association_table_query(
) -> SolrQuery:
if sort is None:
sort = [
"frequency_computed_sortable_float desc",
"evidence_count desc",
"subject_label asc",
"predicate asc",
Expand Down
4 changes: 2 additions & 2 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": 3875, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 125, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Phenotypes", "count": 3873, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 124, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 139, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
]
}
Loading

0 comments on commit eb35fd0

Please sign in to comment.