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

Autocomplete fix #275

Merged
merged 2 commits into from
Aug 14, 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/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ def _association_table(
title="Type of association to retrieve association table data for",
),
query: str = Query(None, example="thumb", title="Query string to limit results to a subset"),
sort: List[str] = Query(None, example=["subject_label asc", "predicate asc", "object_label asc"], title="Sort results by a list of field + direction statements"),
sort: List[str] = Query(
None,
example=["subject_label asc", "predicate asc", "object_label asc"],
title="Sort results by a list of field + direction statements",
),
pagination: PaginationParams = Depends(),
) -> AssociationTableResults:
"""
Expand Down
4 changes: 2 additions & 2 deletions backend/src/monarch_py/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def associations(
def search(
q: str = typer.Option(None, "--query", "-q"),
category: List[str] = typer.Option(None, "--category", "-c"),
in_taxon: str = typer.Option(None, "--in-taxon", "-t"),
in_taxon_label: str = typer.Option(None, "--in-taxon-label", "-t"),
facet_fields: List[str] = typer.Option(None, "--facet-fields", "-ff"),
facet_queries: List[str] = typer.Option(None, "--facet-queries"),
limit: int = typer.Option(20, "--limit", "-l"),
Expand All @@ -155,7 +155,7 @@ def search(
Args:
q: The query string to search for
category: The category of the entity
taxon: The taxon of the entity
in_taxon_label: The taxon label to filter by
limit: The number of entities to return
offset: The offset of the first entity to be retrieved
fmt: The format of the output (json, yaml, tsv, table)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/monarch_py/datamodels/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class HistoPhenoKeys(Enum):
class SolrQuery(BaseModel):
q: str = "*:*"
rows: int = 20
start: int = 1
start: int = 0
facet: bool = True
facet_min_count = 1
facet_fields: Optional[List[str]] = Field(default_factory=list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ def get_association_table(
self,
entity: str,
category: str,
q: str =None,
sort: List[str]=None,
offset: int=0,
limit: int =5,
q: str = None,
sort: List[str] = None,
offset: int = 0,
limit: int = 5,
) -> AssociationTableResults:

query = build_association_table_query(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def build_search_query(


def build_autocomplete_query(q: str) -> SolrQuery:
query = SolrQuery(q=q, limit=10, offset=0)
query = SolrQuery(q=q, limit=10, start=0)
query.q = q
# match the query fields to start with
query.query_fields = entity_query_fields()
Expand Down
1 change: 1 addition & 0 deletions backend/src/monarch_py/service/solr_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def get(self, id):

def query(self, q: SolrQuery) -> SolrQueryResult:
url = f"{self.base_url}/{self.core.value}/select?{q.query_string()}"
logger.debug(f"SolrService.query: {url}")
response = requests.get(url)

data = json.loads(response.text)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/monarch_py/solr_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def associations(
def search(
q: str = typer.Option(None, "--query", "-q"),
category: List[str] = typer.Option(None, "--category", "-c"),
in_taxon: str = typer.Option(None, "--in-taxon", "-t"),
in_taxon_label: str = typer.Option(None, "--in-taxon-label", "-t"),
facet_fields: List[str] = typer.Option(None, "--facet-fields", "-ff"),
facet_queries: List[str] = typer.Option(None, "--facet-queries"),
limit: int = typer.Option(20, "--limit", "-l"),
Expand All @@ -189,7 +189,7 @@ def search(
Optional Args:
q: The query string to search for
category: The category of the entity
taxon: The taxon of the entity
in_taxon_label: The taxon label to filter on
facet_fields: The fields to facet on
facet_queries: The queries to facet on
limit: The number of entities to return
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_table_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def association_table_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 1,
"params": {
"mm": "100%",
"q": "*:*",
Expand Down
47 changes: 26 additions & 21 deletions backend/tests/fixtures/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ def autocomplete():
"offset": 0,
"total": 195,
"items": [
{
"id": "MONDO:0019391",
"category": "biolink:Disease",
"name": "Fanconi anemia",
"full_name": None,
"description": "Fanconi anemia (FA) is a hereditary DNA repair disorder characterized by progressive pancytopenia with bone marrow failure, variable congenital malformations and predisposition to develop hematological or solid tumors.",
"xref": [
"DOID:13636",
"GARD:0006425",
"ICD9:284.09",
"MESH:D005199",
"MedDRA:10055206",
"NCIT:C62505",
"OMIMPS:227650",
"Orphanet:84",
"SCTID:30575002",
"UMLS:C0015625",
],
"provided_by": "phenio_nodes",
"in_taxon": None,
"in_taxon_label": None,
"symbol": None,
"synonym": [],
"highlight": None,
"score": None,
},
{
"id": "MONDO:0001083",
"category": "biolink:Disease",
Expand Down Expand Up @@ -353,27 +379,6 @@ def autocomplete():
"highlight": None,
"score": None,
},
{
"id": "MONDO:0012186",
"category": "biolink:Disease",
"name": "Fanconi anemia complementation group I",
"full_name": None,
"description": "Fanconi anemia caused by mutations in the FANCI gene, encoding Fanconi anemia group I protein.",
"xref": [
"DOID:0111091",
"MESH:C563802",
"NCIT:C129026",
"OMIM:609053",
"UMLS:C1836861",
],
"provided_by": "phenio_nodes",
"in_taxon": None,
"in_taxon_label": None,
"symbol": None,
"synonym": [],
"highlight": None,
"score": None,
},
],
"facet_fields": [],
"facet_queries": [],
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/autocomplete_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def autocomplete_query():
return {
"q": "fanc",
"rows": 20,
"start": 1,
"start": 0,
"facet": True,
"facet_fields": [],
"facet_queries": [],
Expand Down
37 changes: 21 additions & 16 deletions backend/tests/fixtures/autocomplete_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,35 @@ def autocomplete_response():
"defType": "edismax",
"facet_min_count": "1",
"qf": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac",
"start": "1",
"start": "0",
"boost": 'product(if(termfreq(category,"biolink:Disease"),10.0,1),if(and(termfreq(in_taxon,"NCBITaxon:9606"),termfreq(category,"biolink:Gene")),5.0,1))',
"rows": "20",
"facet": "true",
},
},
"response": {
"num_found": 195,
"start": 1,
"start": 0,
"docs": [
{
"id": "MONDO:0019391",
"category": "biolink:Disease",
"name": "Fanconi anemia",
"xref": [
"DOID:13636",
"GARD:0006425",
"ICD9:284.09",
"MESH:D005199",
"MedDRA:10055206",
"NCIT:C62505",
"OMIMPS:227650",
"Orphanet:84",
"SCTID:30575002",
"UMLS:C0015625",
],
"provided_by": "phenio_nodes",
"description": "Fanconi anemia (FA) is a hereditary DNA repair disorder characterized by progressive pancytopenia with bone marrow failure, variable congenital malformations and predisposition to develop hematological or solid tumors.",
},
{
"id": "MONDO:0001083",
"category": "biolink:Disease",
Expand Down Expand Up @@ -235,20 +254,6 @@ def autocomplete_response():
"provided_by": "phenio_nodes",
"description": "Inherited cancer-predisposing syndrome due to biallelic BRCA2 mutations is a rare cancer-predisposing syndrome, associated with the D1 subgroup of Fanconi anemia (FA), characterized by progressive bone marrow failure, cardiac, brain, intestinal or skeletal abnormalities and predisposition to various malignancies. Bone marrow suppression and the incidence of developmental abnormalities are less frequent than in other FA, but cancer risk is very high with the spectrum of childhood cancers including Wilms tumor, brain tumor (often medulloblastoma) and ALL/AML.",
},
{
"id": "MONDO:0012186",
"category": "biolink:Disease",
"name": "Fanconi anemia complementation group I",
"xref": [
"DOID:0111091",
"MESH:C563802",
"NCIT:C129026",
"OMIM:609053",
"UMLS:C1836861",
],
"provided_by": "phenio_nodes",
"description": "Fanconi anemia caused by mutations in the FANCI gene, encoding Fanconi anemia group I protein.",
},
],
},
"facet_counts": {"facet_fields": {}, "facet_queries": {}},
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
2 changes: 1 addition & 1 deletion backend/tests/fixtures/search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def search_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 1,
"params": {
"mm": "100%",
"q": "fanconi",
Expand Down
4 changes: 2 additions & 2 deletions frontend/fixtures/association-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"human disease or disorder"
],
"subject_taxon": null,
"subject_taxon_label": "test subject taxon label",
"subject_taxon_label": null,
"predicate": "biolink:has_phenotype",
"object": "HP:0002460",
"original_object": null,
Expand Down Expand Up @@ -134,7 +134,7 @@
"organ system subdivision"
],
"object_taxon": null,
"object_taxon_label": "test object taxon label",
"object_taxon_label": null,
"primary_knowledge_source": "infores:hpo-annotations",
"aggregator_knowledge_source": ["infores:monarchinitiative"],
"category": "biolink:DiseaseToPhenotypicFeatureAssociation",
Expand Down
47 changes: 26 additions & 21 deletions frontend/fixtures/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@
"offset": 0,
"total": 195,
"items": [
{
"id": "MONDO:0019391",
"category": "biolink:Disease",
"name": "Fanconi anemia",
"full_name": null,
"description": "Fanconi anemia (FA) is a hereditary DNA repair disorder characterized by progressive pancytopenia with bone marrow failure, variable congenital malformations and predisposition to develop hematological or solid tumors.",
"xref": [
"DOID:13636",
"GARD:0006425",
"ICD9:284.09",
"MESH:D005199",
"MedDRA:10055206",
"NCIT:C62505",
"OMIMPS:227650",
"Orphanet:84",
"SCTID:30575002",
"UMLS:C0015625"
],
"provided_by": "phenio_nodes",
"in_taxon": null,
"in_taxon_label": null,
"symbol": null,
"synonym": [],
"highlight": null,
"score": null
},
{
"id": "MONDO:0001083",
"category": "biolink:Disease",
Expand Down Expand Up @@ -332,27 +358,6 @@
"synonym": [],
"highlight": null,
"score": null
},
{
"id": "MONDO:0012186",
"category": "biolink:Disease",
"name": "Fanconi anemia complementation group I",
"full_name": null,
"description": "Fanconi anemia caused by mutations in the FANCI gene, encoding Fanconi anemia group I protein.",
"xref": [
"DOID:0111091",
"MESH:C563802",
"NCIT:C129026",
"OMIM:609053",
"UMLS:C1836861"
],
"provided_by": "phenio_nodes",
"in_taxon": null,
"in_taxon_label": null,
"symbol": null,
"synonym": [],
"highlight": null,
"score": null
}
],
"facet_fields": [],
Expand Down