From f77534939e7bec20346958158b3ee30eda4dfe7b Mon Sep 17 00:00:00 2001 From: Michael Gargano Date: Wed, 11 Sep 2019 16:56:20 -0400 Subject: [PATCH 01/10] Assocation Table and Taxon Filtering WIP --- src/api/BioLink.js | 71 ++---- src/components/AssocTable.vue | 366 ++++++++++++--------------- src/components/NodeSidebar.vue | 23 +- src/components/NodeSidebarFacets.vue | 102 -------- src/components/TaxonFilter.vue | 150 +++++++++++ src/lib/TaxonMap.js | 5 + src/views/Node.vue | 54 +--- 7 files changed, 354 insertions(+), 417 deletions(-) delete mode 100644 src/components/NodeSidebarFacets.vue create mode 100644 src/components/TaxonFilter.vue diff --git a/src/api/BioLink.js b/src/api/BioLink.js index a71646a3..a3fb28d1 100644 --- a/src/api/BioLink.js +++ b/src/api/BioLink.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import { labelToId, isTaxonCardType } from '../lib/TaxonMap'; +import {labelToId, isTaxonCardType, isSubjectCardType} from '../lib/TaxonMap'; // TIP: Example of a domain-specific (as opposed to a generic loadJSON) // service function. This set of domain-specific services will pretty much @@ -23,20 +23,6 @@ const servers = { 'owlsim_services_url': 'https://beta.monarchinitiative.org/owlsim', 'analytics_id': '', 'biolink_url': 'https://api-dev.monarchinitiative.org/api/', - // 'biolink_url': 'https://api.monarchinitiative.org/api/', - }, - - production: { - 'type': 'production', - 'app_base': 'https://monarchinitiative.org', - 'scigraph_url': 'https://scigraph-ontology.monarchinitiative.org/scigraph/', - 'scigraph_data_url': 'https://scigraph-data.monarchinitiative.org/scigraph/', - 'golr_url': 'https://solr.monarchinitiative.org/solr/golr/', - 'search_url': 'https://solr.monarchinitiative.org/solr/search/', - 'owlsim_services_url': 'https://monarchinitiative.org/owlsim', - 'analytics_id': '', - // 'biolink_url': 'https://api.monarchinitiative.org/api/', - 'biolink_url': 'https://api.monarchinitiative.org/api/', }, beta: { @@ -51,11 +37,22 @@ const servers = { 'biolink_url': 'https://api-dev.monarchinitiative.org/api/' }, + production: { + 'type': 'production', + 'app_base': 'https://monarchinitiative.org', + 'scigraph_url': 'https://scigraph-ontology.monarchinitiative.org/scigraph/', + 'scigraph_data_url': 'https://scigraph-data.monarchinitiative.org/scigraph/', + 'golr_url': 'https://solr.monarchinitiative.org/solr/golr/', + 'search_url': 'https://solr.monarchinitiative.org/solr/search/', + 'owlsim_services_url': 'https://monarchinitiative.org/owlsim', + 'analytics_id': '', + 'biolink_url': 'https://api.monarchinitiative.org/api/', + } + }; const productionServers = [ - // 'localhost', - 'monarchinitiative.org', + 'monarchinitiative.org' ]; const defaultApiServer = @@ -69,7 +66,7 @@ const biolink = serverConfiguration.biolink_url; const scigraph = serverConfiguration.scigraph_url; /** - Lighter-weight BL node info. Used by LocalNav.vue + Lighter-weight BioLink node info. Used by LocalNav.vue */ export async function getNodeSummary(nodeId, nodeType) { @@ -138,8 +135,6 @@ export async function getNode(nodeId, nodeType) { [ axios.get(bioentityUrl, { params }), axios.get(getIdentifierUrl), - // axios.get(golrUrl1, {}), - // axios.get(golrUrl2, {}), ] ).then( axios.spread( @@ -423,33 +418,21 @@ export async function getNodeAssociations(nodeType, nodeId, cardType, taxons, pa const biolinkMappedCardType = getBiolinkAnnotation(cardType); const urlExtension = `${nodeType}/${nodeId}/${biolinkMappedCardType}`; const url = `${baseUrl}${urlExtension}`; - const useTaxonRestriction = taxons && taxons.length > 0 && isTaxonCardType(cardType); - - if (useTaxonRestriction) { - // console.log('getNodeAssociations', nodeType, nodeId, cardType); - // console.log(JSON.stringify(params, null, 2)); - // console.log(JSON.stringify(taxons, null, 2)); - params.start = 0; - params.rows = 10000; - } - const response = await axios.get(url, { params }); - if (useTaxonRestriction) { - response.data.associations = response.data.associations.filter((d) => { - const subjTaxon = d.subject.taxon; - const objTaxon = d.object.taxon; - let result = false; - if (subjTaxon.id !== null && taxons.indexOf(subjTaxon.id) >= 0) { - result = true; - } - if (objTaxon.id !== null && taxons.indexOf(objTaxon.id) >= 0) { - result = true; - } - return result; - }); - response.data.numFound = response.data.associations.length; + + if (isTaxonCardType(cardType)) { + params.facet = true; + params.facet_fields = "object_taxon"; + if(isSubjectCardType(cardType)){ + params.facet_fields = "subject_taxon"; + } + + if(taxons != null && taxons !== -1){ + params.taxon = taxons.length > 1 ? taxons.join(","): taxons[0]; + } } + const response = await axios.get(url, { params }); return response; } diff --git a/src/components/AssocTable.vue b/src/components/AssocTable.vue index c492be09..6e1a8b20 100644 --- a/src/components/AssocTable.vue +++ b/src/components/AssocTable.vue @@ -6,22 +6,24 @@ {{ dataError }} - -
- - -
- -
- -
-  {{ totalAssociations }}  - {{ cardType }} associations. -
- +
+ +
+
+  {{ totalAssociations }}  + {{ cardType }} associations. +
+ + + Taxon Filter +
+
{{ data.item.taxonLabel }} + +