Skip to content

Commit

Permalink
add placeholder strategy for geneLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
adf-ncgr committed Jun 19, 2023
1 parent 8f0939f commit 4dc2cba
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/core/models/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -14,6 +14,7 @@ export const models: any[] = [
Miscellaneous,
Tour,
OrganismPlaceholders,
GenePlaceholders,
GET,
POST,
Request,
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/models/placeholders.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ export enum OrganismPlaceholders {
Species = 'SPECIES',
Chromosome = 'CHROMOSOME',
}
export enum GenePlaceholders {
GeneID = 'GENE_ID',
Species = 'SPECIES',
Chromosome = 'CHROMOSOME',
}
14 changes: 12 additions & 2 deletions src/app/gene/services/gene.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<any> {
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<any>(request, {}, makeUrl);
}

Expand Down
6 changes: 5 additions & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4dc2cba

Please sign in to comment.