From 4dc2cba3a6dd6e6cec3bc35f7a5e8f32b8a4e08f Mon Sep 17 00:00:00 2001 From: adf-ncgr Date: Sun, 18 Jun 2023 18:15:50 -0600 Subject: [PATCH] add placeholder strategy for geneLinks --- src/app/core/models/index.ts | 3 ++- src/app/core/models/placeholders.model.ts | 5 +++++ src/app/gene/services/gene.service.ts | 14 ++++++++++++-- src/config/config.json | 6 +++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/app/core/models/index.ts b/src/app/core/models/index.ts index 57e77c81..a30483f4 100644 --- a/src/app/core/models/index.ts +++ b/src/app/core/models/index.ts @@ -1,6 +1,6 @@ import { AppConfig, Brand, Communication, DashboardView, Dashboard, Miscellaneous, Tour } from './app-config.model'; -import { OrganismPlaceholders } from './placeholders.model'; +import { OrganismPlaceholders, GenePlaceholders } from './placeholders.model'; import { Script, isScript } from './script.model'; import { GET, POST, Request, Server } from './server.model'; @@ -14,6 +14,7 @@ export const models: any[] = [ Miscellaneous, Tour, OrganismPlaceholders, + GenePlaceholders, GET, POST, Request, diff --git a/src/app/core/models/placeholders.model.ts b/src/app/core/models/placeholders.model.ts index 17046756..c0380ce1 100644 --- a/src/app/core/models/placeholders.model.ts +++ b/src/app/core/models/placeholders.model.ts @@ -3,3 +3,8 @@ export enum OrganismPlaceholders { Species = 'SPECIES', Chromosome = 'CHROMOSOME', } +export enum GenePlaceholders { + GeneID = 'GENE_ID', + Species = 'SPECIES', + Chromosome = 'CHROMOSOME', +} diff --git a/src/app/gene/services/gene.service.ts b/src/app/gene/services/gene.service.ts index 13325969..db58e89d 100644 --- a/src/app/gene/services/gene.service.ts +++ b/src/app/gene/services/gene.service.ts @@ -9,9 +9,10 @@ import * as geneActions from '@gcv/gene/store/actions/gene.actions'; import * as fromRoot from '@gcv/store/reducers'; import * as fromGene from '@gcv/gene/store/selectors/gene/'; // app -import { AppConfig, ConfigError, GET, POST, GRPC } from '@gcv/core/models'; +import { AppConfig, GenePlaceholders, ConfigError, GET, POST, GRPC } from '@gcv/core/models'; import { HttpService } from '@gcv/core/services/http.service'; import { Gene, Track } from '@gcv/gene/models'; +import { placeholderReplace } from '@gcv/core/utils'; // api import { GenesGetReply, GenesGetRequest, GenesPromiseClient } from 'legumeinfo-microservices/dist/genes_service/v1'; @@ -74,11 +75,20 @@ export class GeneService extends HttpService { return this._store.select(fromGene.getSelectedGenes); } + //fill in templated geneLinksURL + //TODO: should different servers be able to specify their own geneLinks? + export function geneToGeneLinksURL(gene) { + let name = AppConfig.geneLinks.url; + const placeholders = {}; + placeholders[GenePlaceholders.GeneID] = gene; + return placeholderReplace(name, placeholders); + }; + // fetches source specific details for the given gene getGeneDetails(gene: string, source: string): Observable { const request = this._appConfig.getServerRequest(source, 'geneLinks'); //TODO: make this more configurable via template substitution - const makeUrl = (url: string) => url + gene; + const makeUrl = (url: string) => geneToGeneLinksURL(gene); return this._makeHttpRequest(request, {}, makeUrl); } diff --git a/src/config/config.json b/src/config/config.json index 28d64a65..b1101fec 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -56,7 +56,11 @@ }, "geneLinks": { "type": "GET", - "url": "https://legumeinfo.org/gene_links/" + "url": "https://services.lis.ncgr.org/gene_linkouts?genes={GENE_ID}" + }, + "regionLinks": { + "type": "GET", + "url": "https://services.lis.ncgr.org/linkouts/genomic_region_linkouts?" }, "familyTreeLink": { "type": "GET",