Skip to content
Open
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/utils/similarity_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def compare_termsets(
offset: int = 0,
limit: int = 20,
):
hp_db = OAKLIB_MODULE.ensure_gunzip(url=HP_DB_URL, autoclean=False, download_kwargs={"backend": "requests", "headers": {"User-Agent": "monarch-app"}})
hp_db = OAKLIB_MODULE.ensure_gunzip(
url=HP_DB_URL,
autoclean=False,
download_kwargs={"backend": "requests", "headers": {"User-Agent": "monarch-app"}},
)
oi = SqlImplementation(OntologyResource(slug=hp_db))
results = oi.termset_pairwise_similarity(subjects, objects, predicates)
return results
Expand Down
58 changes: 27 additions & 31 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class Entity(ConfiguredBaseModel):
symbol: Optional[str] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
type: Optional[str] = Field(default=None, description="""The type of the entity (e.g. sequence onotology type for genes etc)""")
description: Optional[str] = Field(default=None)
iri: Optional[str] = Field(default=None)
Expand All @@ -170,7 +171,6 @@ class Entity(ConfiguredBaseModel):
same_as: Optional[list[str]] = Field(default=None)
subsets: Optional[list[str]] = Field(default=None, description="""A list of subsets that the entity belongs to""")
synonyms: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
namespace: Optional[str] = Field(default=None, description="""The namespace/prefix portion of this entity's identifier""")
has_phenotype: Optional[list[str]] = Field(default=None, description="""A list of phenotype identifiers that are known to be associated with this entity""")
has_phenotype_label: Optional[list[str]] = Field(default=None, description="""A list of phenotype labels that are known to be associated with this entity""")
Expand All @@ -190,19 +190,14 @@ class Association(ConfiguredBaseModel):
predicate: str = Field(default=...)
category: Optional[str] = Field(default=None)
agent_type: str = Field(default=..., description="""Describes the high-level category of agent who originally generated a statement of knowledge or other type of information.""")
has_attribute: Optional[list[str]] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
knowledge_level: str = Field(default=..., description="""Describes the level of knowledge expressed in a statement, based on the reasoning or analysis methods used to generate the statement, or the scope or specificity of what the statement expresses to be true.""")
negated: Optional[bool] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
onset_qualifier: Optional[str] = Field(default=None)
primary_knowledge_source: Optional[str] = Field(default=None)
publications: Optional[list[str]] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
has_evidence: Optional[list[str]] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
publications: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
FDA_adverse_event_level: Optional[str] = Field(default=None, description="""The level of FDA adverse event reporting for a drug-condition association.""")
disease_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a disease or condition in which a relationship expressed in an association took place.""")
original_predicate: Optional[str] = Field(default=None, description="""used to hold the original relation/predicate that an external knowledge source uses before transformation to match the biolink-model specification.""")
Expand All @@ -211,12 +206,15 @@ class Association(ConfiguredBaseModel):
has_percentage: Optional[float] = Field(default=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(default=None, description="""quotient, which should be 1/100 of has_percentage""")
has_total: Optional[int] = Field(default=None, description="""total, devided by has_count, representing a frequency""")
negated: Optional[bool] = Field(default=None)
onset_qualifier: Optional[str] = Field(default=None)
sex_qualifier: Optional[str] = Field(default=None)
sources: Optional[list[str]] = Field(default=None)
supporting_text: Optional[list[str]] = Field(default=None, description="""The text in a publication that supports the assertion in the association.""")
has_attribute: Optional[list[str]] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
species_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a species in which a relationship expressed in an association took place.""")
stage_qualifier: Optional[str] = Field(default=None)
qualifier: Optional[str] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
subject: str = Field(default=...)
object: str = Field(default=...)
original_subject: Optional[str] = Field(default=None)
Expand Down Expand Up @@ -301,19 +299,14 @@ class ExpandedAssociation(Association):
predicate: str = Field(default=...)
category: Optional[str] = Field(default=None)
agent_type: str = Field(default=..., description="""Describes the high-level category of agent who originally generated a statement of knowledge or other type of information.""")
has_attribute: Optional[list[str]] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
knowledge_level: str = Field(default=..., description="""Describes the level of knowledge expressed in a statement, based on the reasoning or analysis methods used to generate the statement, or the scope or specificity of what the statement expresses to be true.""")
negated: Optional[bool] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
onset_qualifier: Optional[str] = Field(default=None)
primary_knowledge_source: Optional[str] = Field(default=None)
publications: Optional[list[str]] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
has_evidence: Optional[list[str]] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
publications: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
FDA_adverse_event_level: Optional[str] = Field(default=None, description="""The level of FDA adverse event reporting for a drug-condition association.""")
disease_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a disease or condition in which a relationship expressed in an association took place.""")
original_predicate: Optional[str] = Field(default=None, description="""used to hold the original relation/predicate that an external knowledge source uses before transformation to match the biolink-model specification.""")
Expand All @@ -322,11 +315,15 @@ class ExpandedAssociation(Association):
has_percentage: Optional[float] = Field(default=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(default=None, description="""quotient, which should be 1/100 of has_percentage""")
has_total: Optional[int] = Field(default=None, description="""total, devided by has_count, representing a frequency""")
negated: Optional[bool] = Field(default=None)
onset_qualifier: Optional[str] = Field(default=None)
sex_qualifier: Optional[str] = Field(default=None)
sources: Optional[list[str]] = Field(default=None)
has_attribute: Optional[list[str]] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
species_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a species in which a relationship expressed in an association took place.""")
stage_qualifier: Optional[str] = Field(default=None)
qualifier: Optional[str] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
subject: str = Field(default=...)
object: str = Field(default=...)
original_subject: Optional[str] = Field(default=None)
Expand Down Expand Up @@ -383,19 +380,14 @@ class DirectionalAssociation(ExpandedAssociation):
predicate: str = Field(default=...)
category: Optional[str] = Field(default=None)
agent_type: str = Field(default=..., description="""Describes the high-level category of agent who originally generated a statement of knowledge or other type of information.""")
has_attribute: Optional[list[str]] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
knowledge_level: str = Field(default=..., description="""Describes the level of knowledge expressed in a statement, based on the reasoning or analysis methods used to generate the statement, or the scope or specificity of what the statement expresses to be true.""")
negated: Optional[bool] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
onset_qualifier: Optional[str] = Field(default=None)
primary_knowledge_source: Optional[str] = Field(default=None)
publications: Optional[list[str]] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
aggregator_knowledge_source: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
has_evidence: Optional[list[str]] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
publications: Optional[list[str]] = Field(default=None)
qualifiers: Optional[list[str]] = Field(default=None)
FDA_adverse_event_level: Optional[str] = Field(default=None, description="""The level of FDA adverse event reporting for a drug-condition association.""")
disease_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a disease or condition in which a relationship expressed in an association took place.""")
original_predicate: Optional[str] = Field(default=None, description="""used to hold the original relation/predicate that an external knowledge source uses before transformation to match the biolink-model specification.""")
Expand All @@ -404,11 +396,15 @@ class DirectionalAssociation(ExpandedAssociation):
has_percentage: Optional[float] = Field(default=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(default=None, description="""quotient, which should be 1/100 of has_percentage""")
has_total: Optional[int] = Field(default=None, description="""total, devided by has_count, representing a frequency""")
negated: Optional[bool] = Field(default=None)
onset_qualifier: Optional[str] = Field(default=None)
sex_qualifier: Optional[str] = Field(default=None)
sources: Optional[list[str]] = Field(default=None)
has_attribute: Optional[list[str]] = Field(default=None)
object_aspect_qualifier: Optional[str] = Field(default=None, description="""Composes with the core concept (+ qualifier) to describe new concepts of a more specific kind. The aspect qualifier represents an attribute of the object that is the focus of the relationship (e.g. for an association where the object is a gene, this might be the expression, abundance, activity, or stability of the gene).""")
species_context_qualifier: Optional[str] = Field(default=None, description="""A context qualifier representing a species in which a relationship expressed in an association took place.""")
stage_qualifier: Optional[str] = Field(default=None)
qualifier: Optional[str] = Field(default=None)
object_specialization_qualifier: Optional[str] = Field(default=None, description="""A qualifier that composes with a core subject/object concept to define a more specific version of the object concept, specifically using an ontology term that is not a subclass or descendant of the core concept and in the vast majority of cases, is of a different ontological namespace than the category or namespace of the object identifier.""")
subject: str = Field(default=...)
object: str = Field(default=...)
original_subject: Optional[str] = Field(default=None)
Expand Down Expand Up @@ -528,6 +524,7 @@ class Node(Entity):
symbol: Optional[str] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
type: Optional[str] = Field(default=None, description="""The type of the entity (e.g. sequence onotology type for genes etc)""")
description: Optional[str] = Field(default=None)
iri: Optional[str] = Field(default=None)
Expand All @@ -540,7 +537,6 @@ class Node(Entity):
same_as: Optional[list[str]] = Field(default=None)
subsets: Optional[list[str]] = Field(default=None, description="""A list of subsets that the entity belongs to""")
synonyms: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
namespace: Optional[str] = Field(default=None, description="""The namespace/prefix portion of this entity's identifier""")
has_phenotype: Optional[list[str]] = Field(default=None, description="""A list of phenotype identifiers that are known to be associated with this entity""")
has_phenotype_label: Optional[list[str]] = Field(default=None, description="""A list of phenotype labels that are known to be associated with this entity""")
Expand Down Expand Up @@ -670,6 +666,7 @@ class SearchResult(Entity):
symbol: Optional[str] = Field(default=None)
file_source: Optional[str] = Field(default=None, description="""Source file stem injected by koza at load time.""")
provided_by: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
type: Optional[str] = Field(default=None, description="""The type of the entity (e.g. sequence onotology type for genes etc)""")
description: Optional[str] = Field(default=None)
iri: Optional[str] = Field(default=None)
Expand All @@ -683,7 +680,6 @@ class SearchResult(Entity):
same_as: Optional[list[str]] = Field(default=None)
subsets: Optional[list[str]] = Field(default=None, description="""A list of subsets that the entity belongs to""")
synonyms: Optional[str] = Field(default=None)
has_gene: Optional[list[str]] = Field(default=None)
namespace: Optional[str] = Field(default=None, description="""The namespace/prefix portion of this entity's identifier""")
has_phenotype: Optional[list[str]] = Field(default=None, description="""A list of phenotype identifiers that are known to be associated with this entity""")
has_phenotype_label: Optional[list[str]] = Field(default=None, description="""A list of phenotype labels that are known to be associated with this entity""")
Expand Down
Loading