Skip to content

Commit

Permalink
Merge pull request #839 from legumeinfo/feature-newlinkouts
Browse files Browse the repository at this point in the history
Feature newlinkouts
  • Loading branch information
adf-ncgr authored Jun 23, 2023
2 parents 6cfda7e + 23ecbfb commit f1b41cf
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
4 changes: 3 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, RegionPlaceholders } from './placeholders.model';
import { Script, isScript } from './script.model';
import { GET, POST, Request, Server } from './server.model';

Expand All @@ -14,6 +14,8 @@ export const models: any[] = [
Miscellaneous,
Tour,
OrganismPlaceholders,
GenePlaceholders,
RegionPlaceholders,
GET,
POST,
Request,
Expand Down
10 changes: 10 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,13 @@ export enum OrganismPlaceholders {
Species = 'SPECIES',
Chromosome = 'CHROMOSOME',
}

export enum GenePlaceholders {
Gene = 'GENE',
}

export enum RegionPlaceholders {
Chromosome = 'CHROMOSOME',
Start = 'START',
Stop = 'STOP',
}
12 changes: 10 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,10 +75,17 @@ export class GeneService extends HttpService {
return this._store.select(fromGene.getSelectedGenes);
}

//fill in templated geneLinksURL
private geneToGeneLinksURL(urlTemplate: string, gene: string): string {
const placeholders = {};
placeholders[GenePlaceholders.Gene] = gene;
return placeholderReplace(urlTemplate, placeholders);
}

// fetches source specific details for the given gene
getGeneDetails(gene: string, source: string): Observable<any> {
const request = this._appConfig.getServerRequest(source, 'geneLinks');
const makeUrl = (url: string) => url + gene + '/json';
const makeUrl = (url: string) => this.geneToGeneLinksURL(request.url, gene);
return this._makeHttpRequest<any>(request, {}, makeUrl);
}

Expand Down
14 changes: 12 additions & 2 deletions src/app/gene/services/region.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Store } from '@ngrx/store';
import * as regionActions from '@gcv/gene/store/actions/region.actions';
import * as fromRoot from '@gcv/store/reducers';
// app
import { AppConfig, ConfigError, GET, POST, GRPC } from '@gcv/core/models';
import { AppConfig, RegionPlaceholders, ConfigError, GET, POST, GRPC } from '@gcv/core/models';
import { Region } from '@gcv/gene/models';
import { HttpService } from '@gcv/core/services/http.service';
import { grpcRegionToModel } from './shims';
import { placeholderReplace } from '@gcv/core/utils';
// api
import { ChromosomeRegionGetReply, ChromosomeRegionGetRequest,
ChromosomeRegionPromiseClient, } from 'legumeinfo-microservices/dist/chromosomeregion_service/v1';
Expand Down Expand Up @@ -61,10 +62,19 @@ export class RegionService extends HttpService {
this._store.dispatch(new regionActions.Get({chromosome, start, stop, source}));
}

//fill in templated regionLinksURL
private regionToRegionLinksURL(urlTemplate: string, chromosome: string, start: number, stop: number): string {
const placeholders = {};
placeholders[RegionPlaceholders.Chromosome] = chromosome;
placeholders[RegionPlaceholders.Start] = start.toString();
placeholders[RegionPlaceholders.Stop] = stop.toString();
return placeholderReplace(urlTemplate, placeholders);
}

// fetches source specific details for the given region
getRegionDetails(chromosome: string, start: number, end: number, source: string): Observable<any> {
const request = this._appConfig.getServerRequest(source, 'regionLinks');
const makeUrl = (url: string) => url + chromosome + '&start=' + start + '&end=' + end ;
const makeUrl = (url: string) => this.regionToRegionLinksURL(request.url, chromosome, start, end);
return this._makeHttpRequest<any>(request, {}, makeUrl);
}

Expand Down
8 changes: 6 additions & 2 deletions src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@
},
"geneLinks": {
"type": "GET",
"url": "https://legumeinfo.org/gene_links/"
"url": "https://services.lis.ncgr.org/gene_linkouts?genes={GENE}"
},
"regionLinks": {
"type": "GET",
"url": "https://services.lis.ncgr.org/genomic_region_linkouts?genomic_regions={CHROMOSOME}:{START}-{STOP}"
},
"familyTreeLink": {
"type": "GET",
"url": "http://legumeinfo.org/chado_gene_phylotree_v2?family="
"url": "https://funnotate.legumeinfo.org/?family="
},
"chromosome": {
"type": "GRPC",
Expand Down

0 comments on commit f1b41cf

Please sign in to comment.