Skip to content

Commit

Permalink
ran format
Browse files Browse the repository at this point in the history
  • Loading branch information
glass-ships committed Aug 22, 2023
1 parent 21f58fb commit af068d6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 133 deletions.
1 change: 0 additions & 1 deletion backend/src/monarch_py/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from monarch_py.api.additional_models import PaginationParams
from monarch_py.api.config import solr
from monarch_py.api.config import settings
from monarch_py.datamodels.model import SearchResults

router = APIRouter(
Expand Down
176 changes: 44 additions & 132 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ class Association(ConfiguredBaseModel):
id: str = Field(...)
subject: str = Field(...)
original_subject: Optional[str] = Field(None)
subject_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the subject entity"""
)
subject_category: Optional[str] = Field(
None, description="""The category of the subject entity"""
)
subject_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the subject entity""")
subject_category: Optional[str] = Field(None, description="""The category of the subject entity""")
subject_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing subject id and the ids of all of it's ancestors""",
)
subject_label: Optional[str] = Field(
None, description="""the label or name for the first entity"""
)
subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""")
subject_closure_label: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing subject name and the names of all of it's ancestors""",
Expand All @@ -69,19 +63,13 @@ class Association(ConfiguredBaseModel):
predicate: str = Field(...)
object: str = Field(...)
original_object: Optional[str] = Field(None)
object_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the object entity"""
)
object_category: Optional[str] = Field(
None, description="""The category of the object entity"""
)
object_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the object entity""")
object_category: Optional[str] = Field(None, description="""The category of the object entity""")
object_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing object id and the ids of all of it's ancestors""",
)
object_label: Optional[str] = Field(
None, description="""the label or name for the second entity"""
)
object_label: Optional[str] = Field(None, description="""the label or name for the second entity""")
object_closure_label: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing object name and the names of all of it's ancestors""",
Expand Down Expand Up @@ -109,9 +97,7 @@ class Association(ConfiguredBaseModel):
description="""count of supporting documents, evidence codes, and sources supplying evidence""",
)
pathway: Optional[str] = Field(None)
frequency_qualifier_label: Optional[str] = Field(
None, description="""The name of the frequency_qualifier entity"""
)
frequency_qualifier_label: Optional[str] = Field(None, description="""The name of the frequency_qualifier entity""")
frequency_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the frequency_qualifier entity"""
)
Expand All @@ -126,15 +112,11 @@ class Association(ConfiguredBaseModel):
default_factory=list,
description="""Field containing frequency_qualifier name and the names of all of it's ancestors""",
)
onset_qualifier_label: Optional[str] = Field(
None, description="""The name of the onset_qualifier entity"""
)
onset_qualifier_label: Optional[str] = Field(None, description="""The name of the onset_qualifier entity""")
onset_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the onset_qualifier entity"""
)
onset_qualifier_category: Optional[str] = Field(
None, description="""The category of the onset_qualifier entity"""
)
onset_qualifier_category: Optional[str] = Field(None, description="""The category of the onset_qualifier entity""")
onset_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing onset_qualifier id and the ids of all of it's ancestors""",
Expand All @@ -143,15 +125,11 @@ class Association(ConfiguredBaseModel):
default_factory=list,
description="""Field containing onset_qualifier name and the names of all of it's ancestors""",
)
sex_qualifier_label: Optional[str] = Field(
None, description="""The name of the sex_qualifier entity"""
)
sex_qualifier_label: Optional[str] = Field(None, description="""The name of the sex_qualifier entity""")
sex_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the sex_qualifier entity"""
)
sex_qualifier_category: Optional[str] = Field(
None, description="""The category of the sex_qualifier entity"""
)
sex_qualifier_category: Optional[str] = Field(None, description="""The category of the sex_qualifier entity""")
sex_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing sex_qualifier id and the ids of all of it's ancestors""",
Expand All @@ -160,15 +138,11 @@ class Association(ConfiguredBaseModel):
default_factory=list,
description="""Field containing sex_qualifier name and the names of all of it's ancestors""",
)
stage_qualifier_label: Optional[str] = Field(
None, description="""The name of the stage_qualifier entity"""
)
stage_qualifier_label: Optional[str] = Field(None, description="""The name of the stage_qualifier entity""")
stage_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the stage_qualifier entity"""
)
stage_qualifier_category: Optional[str] = Field(
None, description="""The category of the stage_qualifier entity"""
)
stage_qualifier_category: Optional[str] = Field(None, description="""The category of the stage_qualifier entity""")
stage_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing stage_qualifier id and the ids of all of it's ancestors""",
Expand Down Expand Up @@ -225,19 +199,13 @@ class DirectionalAssociation(Association):
id: str = Field(...)
subject: str = Field(...)
original_subject: Optional[str] = Field(None)
subject_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the subject entity"""
)
subject_category: Optional[str] = Field(
None, description="""The category of the subject entity"""
)
subject_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the subject entity""")
subject_category: Optional[str] = Field(None, description="""The category of the subject entity""")
subject_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing subject id and the ids of all of it's ancestors""",
)
subject_label: Optional[str] = Field(
None, description="""the label or name for the first entity"""
)
subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""")
subject_closure_label: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing subject name and the names of all of it's ancestors""",
Expand All @@ -247,19 +215,13 @@ class DirectionalAssociation(Association):
predicate: str = Field(...)
object: str = Field(...)
original_object: Optional[str] = Field(None)
object_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the object entity"""
)
object_category: Optional[str] = Field(
None, description="""The category of the object entity"""
)
object_namespace: Optional[str] = Field(None, description="""The namespace/prefix of the object entity""")
object_category: Optional[str] = Field(None, description="""The category of the object entity""")
object_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing object id and the ids of all of it's ancestors""",
)
object_label: Optional[str] = Field(
None, description="""the label or name for the second entity"""
)
object_label: Optional[str] = Field(None, description="""the label or name for the second entity""")
object_closure_label: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing object name and the names of all of it's ancestors""",
Expand Down Expand Up @@ -287,9 +249,7 @@ class DirectionalAssociation(Association):
description="""count of supporting documents, evidence codes, and sources supplying evidence""",
)
pathway: Optional[str] = Field(None)
frequency_qualifier_label: Optional[str] = Field(
None, description="""The name of the frequency_qualifier entity"""
)
frequency_qualifier_label: Optional[str] = Field(None, description="""The name of the frequency_qualifier entity""")
frequency_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the frequency_qualifier entity"""
)
Expand All @@ -304,15 +264,11 @@ class DirectionalAssociation(Association):
default_factory=list,
description="""Field containing frequency_qualifier name and the names of all of it's ancestors""",
)
onset_qualifier_label: Optional[str] = Field(
None, description="""The name of the onset_qualifier entity"""
)
onset_qualifier_label: Optional[str] = Field(None, description="""The name of the onset_qualifier entity""")
onset_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the onset_qualifier entity"""
)
onset_qualifier_category: Optional[str] = Field(
None, description="""The category of the onset_qualifier entity"""
)
onset_qualifier_category: Optional[str] = Field(None, description="""The category of the onset_qualifier entity""")
onset_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing onset_qualifier id and the ids of all of it's ancestors""",
Expand All @@ -321,15 +277,11 @@ class DirectionalAssociation(Association):
default_factory=list,
description="""Field containing onset_qualifier name and the names of all of it's ancestors""",
)
sex_qualifier_label: Optional[str] = Field(
None, description="""The name of the sex_qualifier entity"""
)
sex_qualifier_label: Optional[str] = Field(None, description="""The name of the sex_qualifier entity""")
sex_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the sex_qualifier entity"""
)
sex_qualifier_category: Optional[str] = Field(
None, description="""The category of the sex_qualifier entity"""
)
sex_qualifier_category: Optional[str] = Field(None, description="""The category of the sex_qualifier entity""")
sex_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing sex_qualifier id and the ids of all of it's ancestors""",
Expand All @@ -338,15 +290,11 @@ class DirectionalAssociation(Association):
default_factory=list,
description="""Field containing sex_qualifier name and the names of all of it's ancestors""",
)
stage_qualifier_label: Optional[str] = Field(
None, description="""The name of the stage_qualifier entity"""
)
stage_qualifier_label: Optional[str] = Field(None, description="""The name of the stage_qualifier entity""")
stage_qualifier_namespace: Optional[str] = Field(
None, description="""The namespace/prefix of the stage_qualifier entity"""
)
stage_qualifier_category: Optional[str] = Field(
None, description="""The category of the stage_qualifier entity"""
)
stage_qualifier_category: Optional[str] = Field(None, description="""The category of the stage_qualifier entity""")
stage_qualifier_closure: Optional[List[str]] = Field(
default_factory=list,
description="""Field containing stage_qualifier id and the ids of all of it's ancestors""",
Expand Down Expand Up @@ -374,15 +322,11 @@ class Entity(ConfiguredBaseModel):
id: str = Field(...)
category: Optional[str] = Field(None)
name: Optional[str] = Field(None)
full_name: Optional[str] = Field(
None, description="""The long form name of an entity"""
)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
in_taxon: Optional[str] = Field(
None, description="""The biolink taxon that the entity is in the closure of."""
)
in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""")
in_taxon_label: Optional[str] = Field(
None,
description="""The label of the biolink taxon that the entity is in the closure of.""",
Expand Down Expand Up @@ -434,9 +378,7 @@ class Node(Entity):
UI container class extending Entity with additional information
"""

in_taxon: Optional[str] = Field(
None, description="""The biolink taxon that the entity is in the closure of."""
)
in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""")
in_taxon_label: Optional[str] = Field(
None,
description="""The label of the biolink taxon that the entity is in the closure of.""",
Expand All @@ -454,9 +396,7 @@ class Node(Entity):
id: str = Field(...)
category: Optional[str] = Field(None)
name: Optional[str] = Field(None)
full_name: Optional[str] = Field(
None, description="""The long form name of an entity"""
)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
Expand Down Expand Up @@ -513,24 +453,16 @@ class EntityResults(Results):

class SearchResult(Entity):

highlight: Optional[str] = Field(
None, description="""matching text snippet containing html tags"""
)
score: Optional[str] = Field(
None, description="""Abstract base slot for different kinds of scores"""
)
highlight: Optional[str] = Field(None, description="""matching text snippet containing html tags""")
score: Optional[str] = Field(None, description="""Abstract base slot for different kinds of scores""")
id: str = Field(...)
category: str = Field(...)
name: str = Field(...)
full_name: Optional[str] = Field(
None, description="""The long form name of an entity"""
)
full_name: Optional[str] = Field(None, description="""The long form name of an entity""")
description: Optional[str] = Field(None)
xref: Optional[List[str]] = Field(default_factory=list)
provided_by: Optional[str] = Field(None)
in_taxon: Optional[str] = Field(
None, description="""The biolink taxon that the entity is in the closure of."""
)
in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""")
in_taxon_label: Optional[str] = Field(
None,
description="""The label of the biolink taxon that the entity is in the closure of.""",
Expand Down Expand Up @@ -571,41 +503,21 @@ class TermPairwiseSimilarity(PairwiseSimilarity):
A simple pairwise similarity between two atomic concepts/terms
"""

subject_id: str = Field(
..., description="""The first of the two entities being compared"""
)
subject_label: Optional[str] = Field(
None, description="""the label or name for the first entity"""
)
subject_source: Optional[str] = Field(
None, description="""the source for the first entity"""
)
object_id: Optional[str] = Field(
None, description="""The second of the two entities being compared"""
)
object_label: Optional[str] = Field(
None, description="""the label or name for the second entity"""
)
object_source: Optional[str] = Field(
None, description="""the source for the second entity"""
)
subject_id: str = Field(..., description="""The first of the two entities being compared""")
subject_label: Optional[str] = Field(None, description="""the label or name for the first entity""")
subject_source: Optional[str] = Field(None, description="""the source for the first entity""")
object_id: Optional[str] = Field(None, description="""The second of the two entities being compared""")
object_label: Optional[str] = Field(None, description="""the label or name for the second entity""")
object_source: Optional[str] = Field(None, description="""the source for the second entity""")
ancestor_id: Optional[str] = Field(
None,
description="""the most recent common ancestor of the two compared entities. If there are multiple MRCAs then the most informative one is selected""",
)
ancestor_label: Optional[str] = Field(
None, description="""the name or label of the ancestor concept"""
)
ancestor_label: Optional[str] = Field(None, description="""the name or label of the ancestor concept""")
ancestor_source: Optional[str] = Field(None)
object_information_content: Optional[float] = Field(
None, description="""The IC of the object"""
)
subject_information_content: Optional[float] = Field(
None, description="""The IC of the subject"""
)
ancestor_information_content: Optional[float] = Field(
None, description="""The IC of the object"""
)
object_information_content: Optional[float] = Field(None, description="""The IC of the object""")
subject_information_content: Optional[float] = Field(None, description="""The IC of the subject""")
ancestor_information_content: Optional[float] = Field(None, description="""The IC of the object""")
jaccard_similarity: Optional[float] = Field(
None,
description="""The number of concepts in the intersection divided by the number in the union""",
Expand Down
1 change: 1 addition & 0 deletions backend/tests/unit/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_autocomplete(autocomplete):
def test_compare(compare):
tsps = TermSetPairwiseSimilarity(**compare)
import pprint

pprint.PrettyPrinter(indent=2).pprint(tsps.dict())
assert len(tsps.subject_best_matches) != 0

Expand Down

0 comments on commit af068d6

Please sign in to comment.