Skip to content
Snippets Groups Projects
Commit 18a1cda6 authored by Hartung, Michael's avatar Hartung, Michael
Browse files

Merge branch 'master' of gitlab.rrz.uni-hamburg.de:cosy-bio/drugst.one/frontend

parents fe829f10 c89d765f
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ export type InteractionDrugProteinDB = 'NeDRex' | 'DrugBank' | 'DrugCentral' | ' ...@@ -32,7 +32,7 @@ export type InteractionDrugProteinDB = 'NeDRex' | 'DrugBank' | 'DrugCentral' | '
export type InteractionProteinProteinDB = 'NeDRex' | 'BioGRID' | 'IID' | 'IntAct' | 'STRING' | 'APID'; export type InteractionProteinProteinDB = 'NeDRex' | 'BioGRID' | 'IID' | 'IntAct' | 'STRING' | 'APID';
export type IndicationDrugDisorderDB = 'NeDRex' | 'CTD' | 'DrugCentral' | 'DrugBank'; export type IndicationDrugDisorderDB = 'NeDRex' | 'CTD' | 'DrugCentral' | 'DrugBank';
export type AssociatedProteinDisorderDB = 'NeDRex' | 'DisGeNET' | 'OMIM'; export type AssociatedProteinDisorderDB = 'NeDRex' | 'DisGeNET' | 'OMIM';
export type AdvAnalysisContentTypes = 'drug-target-search' | 'drug-search' | 'enrichment-gprofiler'; export type AdvAnalysisContentTypes = 'drug-target-search' | 'drug-search' | 'enrichment-gprofiler' | 'enrichment-digest';
// TODO: should this be external or integrated in the backend? // TODO: should this be external or integrated in the backend?
...@@ -145,7 +145,7 @@ export const defaultConfig: IConfig = { ...@@ -145,7 +145,7 @@ export const defaultConfig: IConfig = {
showItemSelector: true, showItemSelector: true,
showSimpleAnalysis: true, showSimpleAnalysis: true,
showAdvAnalysis: true, showAdvAnalysis: true,
showAdvAnalysisContent: ['drug-search', 'drug-target-search', 'enrichment-gprofiler'], showAdvAnalysisContent: ['drug-search', 'drug-target-search', 'enrichment-gprofiler', 'enrichment-digest'],
showSelection: true, showSelection: true,
showTasks: true, showTasks: true,
showNetworkMenu: 'right', showNetworkMenu: 'right',
......
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
<div class="control"> <div class="control">
<a <a
*ngIf="analysis.getCount() > 0" *ngIf="analysis.getCount() > 0"
[href]="gProfilerLink()" (click)="openExternal(gProfilerLink())"
target="_blank" target="_blank"
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }" [ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
class="button is-primary is-fullwidth is-rounded has-tooltip" class="button is-primary is-fullwidth is-rounded has-tooltip"
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
<span <span
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }" [ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
> >
Enrichment Analysis g:Profiler Enrichment Analysis
</span> </span>
</a> </a>
<a <a
...@@ -319,7 +319,54 @@ ...@@ -319,7 +319,54 @@
<span <span
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }" [ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
> >
Enrichment Analysis g:Profiler Enrichment Analysis
</span>
</a>
</div>
</div>
<div class="field" *ngIf="!drugstoneConfig.config.showAdvAnalysisContent || drugstoneConfig.config.showAdvAnalysisContent.includes('enrichment-digest')">
<div class="control">
<a
*ngIf="analysis.getCount() > 0"
(click)="openDigest()"
target="_blank"
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
class="button is-primary is-fullwidth is-rounded has-tooltip"
pTooltip="Use enrichment analysis via DIGEST (external)."
[tooltipStyleClass]="
'drgstn drgstn-tooltip drgstn-tooltip-top'
"
tooltipPosition="top"
>
<app-fa-solid-icon
classString="first-item-in-button"
icon="external-link-alt"
></app-fa-solid-icon>
<span
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
>
DIGEST Enrichment Analysis
</span>
</a>
<a
*ngIf="analysis.getCount() === 0"
disabled
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
class="button is-primary is-fullwidth is-rounded has-tooltip"
pTooltip="Use enrichment analysis via DIGEST (external)."
[tooltipStyleClass]="
'drgstn drgstn-tooltip drgstn-tooltip-top'
"
tooltipPosition="top"
>
<app-fa-solid-icon
icon="external-link-alt"
classString="first-item-in-button"
></app-fa-solid-icon>
<span
[ngClass]="{ 'text-small': drugstoneConfig.smallStyle }"
>
DIGEST Enrichment Analysis
</span> </span>
</a> </a>
</div> </div>
......
...@@ -78,7 +78,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -78,7 +78,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
try { try {
this.networkJSON = JSON.stringify(typeof network === 'string' ? JSON5.parse(network) : network); this.networkJSON = JSON.stringify(typeof network === 'string' ? JSON5.parse(network) : network);
} catch { } catch {
console.log('ERROR: Failed parsing input network') console.log('ERROR: Failed parsing input network');
} }
this.activateConfig(); this.activateConfig();
} }
...@@ -120,8 +120,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -120,8 +120,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public selectedAnalysisToken: string | null = null; public selectedAnalysisToken: string | null = null;
@Input() set taskId(token: string | null) { @Input() set taskId(token: string | null) {
if (token == null || token.length === 0) if (token == null || token.length === 0) {
this.selectedAnalysisToken = null this.selectedAnalysisToken = null;
}
this.selectedAnalysisToken = token; this.selectedAnalysisToken = token;
} }
...@@ -158,7 +159,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -158,7 +159,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
selected, selected,
this.networkHandler.activeNetwork.getGradient(wrapper.id), this.networkHandler.activeNetwork.getGradient(wrapper.id),
this.networkHandler.activeNetwork.nodeRenderer this.networkHandler.activeNetwork.nodeRenderer
) );
nodeStyled.x = pos[wrapper.id].x; nodeStyled.x = pos[wrapper.id].x;
nodeStyled.y = pos[wrapper.id].y; nodeStyled.y = pos[wrapper.id].y;
updatedNodes.push(nodeStyled); updatedNodes.push(nodeStyled);
...@@ -257,36 +258,41 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -257,36 +258,41 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
let node_map = {}; let node_map = {};
nodes.filter(n => n.drugstoneType === 'protein').forEach(node => { nodes.filter(n => n.drugstoneType === 'protein').forEach(node => {
if (typeof node.drugstoneId === 'string') { if (typeof node.drugstoneId === 'string') {
if (node_map[node.drugstoneId]) if (node_map[node.drugstoneId]) {
node_map[node.drugstoneId].push(node.id); node_map[node.drugstoneId].push(node.id);
else } else {
node_map[node.drugstoneId] = [node.id]; node_map[node.drugstoneId] = [node.id];
}
} else { } else {
node.drugstoneId.forEach(n => { node.drugstoneId.forEach(n => {
if (node_map[n]) if (node_map[n]) {
node_map[n].push(node.id); node_map[n].push(node.id);
else } else {
node_map[n] = [node.id]; node_map[n] = [node.id];
}) }
});
} }
}) });
const netexEdges = await this.netex.fetchEdges(nodes, this.drugstoneConfig.config.interactionProteinProtein, this.drugstoneConfig.config.licensedDatasets); const netexEdges = await this.netex.fetchEdges(nodes, this.drugstoneConfig.config.interactionProteinProtein, this.drugstoneConfig.config.licensedDatasets);
edges.push(...netexEdges.map(netexEdge => mapNetexEdge(netexEdge, this.drugstoneConfig.config, node_map)).flatMap(e => e)); edges.push(...netexEdges.map(netexEdge => mapNetexEdge(netexEdge, this.drugstoneConfig.config, node_map)).flatMap(e => e));
} }
const edge_map = {} const edge_map = {};
edges = edges.filter(edge => { edges = edges.filter(edge => {
if (edge_map[edge.to] && edge_map[edge.to].indexOf(edge.from) !== -1) if (edge_map[edge.to] && edge_map[edge.to].indexOf(edge.from) !== -1) {
return false return false;
if (edge_map[edge.from] && edge_map[edge.from].indexOf(edge.to) !== -1) }
return false if (edge_map[edge.from] && edge_map[edge.from].indexOf(edge.to) !== -1) {
if (!edge_map[edge.from]) return false;
edge_map[edge.from] = [edge.to] }
else if (!edge_map[edge.from]) {
edge_map[edge.from].push(edge.to) edge_map[edge.from] = [edge.to];
return true } else {
}) edge_map[edge.from].push(edge.to);
}
return true;
});
// @ts-ignore // @ts-ignore
if (!this.drugstoneConfig.selfReferences) { if (!this.drugstoneConfig.selfReferences) {
...@@ -375,10 +381,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -375,10 +381,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
}); });
if (network.edges != null) if (network.edges != null)
// @ts-ignore // @ts-ignore
{
network.edges.forEach(edge => { network.edges.forEach(edge => {
edge.from = this.removeEnsemblVersion(edge.from); edge.from = this.removeEnsemblVersion(edge.from);
edge.to = this.removeEnsemblVersion(edge.to); edge.to = this.removeEnsemblVersion(edge.to);
}); });
}
} }
// map data to nodes in backend // map data to nodes in backend
...@@ -401,12 +409,13 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -401,12 +409,13 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
// adjust edge labels accordingly and filter // adjust edge labels accordingly and filter
const edges = new Array(); const edges = new Array();
if (network.edges != null) if (network.edges != null) {
network.edges.forEach(edge => { network.edges.forEach(edge => {
if (edge.from !== undefined && edge.to !== undefined) { if (edge.from !== undefined && edge.to !== undefined) {
edges.push(edge); edges.push(edge);
} }
}); });
}
// remove edges without endpoints // remove edges without endpoints
network.edges = edges; network.edges = edges;
this.networkHandler.activeNetwork.inputNetwork = network; this.networkHandler.activeNetwork.inputNetwork = network;
...@@ -423,7 +432,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -423,7 +432,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.networkHandler.activeNetwork.selectedWrapper = item; this.networkHandler.activeNetwork.selectedWrapper = item;
// add expression information if loaded // add expression information if loaded
if (this.networkHandler.activeNetwork.expressionMap && this.networkHandler.activeNetwork.selectedWrapper.id in this.networkHandler.activeNetwork.expressionMap) { if (this.networkHandler.activeNetwork.expressionMap && this.networkHandler.activeNetwork.selectedWrapper.id in this.networkHandler.activeNetwork.expressionMap) {
this.networkHandler.activeNetwork.selectedWrapper.expression = this.networkHandler.activeNetwork.expressionMap[this.networkHandler.activeNetwork.selectedWrapper.id] this.networkHandler.activeNetwork.selectedWrapper.expression = this.networkHandler.activeNetwork.expressionMap[this.networkHandler.activeNetwork.selectedWrapper.id];
} }
if (zoom) { if (zoom) {
this.zoomToNode(item.id); this.zoomToNode(item.id);
...@@ -490,7 +499,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -490,7 +499,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
border: group.color, border: group.color,
background: group.color background: group.color
} }
} };
} }
// if image is given, set node shape to image // if image is given, set node shape to image
if (group.image) { if (group.image) {
...@@ -539,9 +548,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -539,9 +548,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
// nodes in selection have drugstoneId // nodes in selection have drugstoneId
const queryString = this.analysis.getSelection() const queryString = this.analysis.getSelection()
.filter(wrapper => wrapper.data.drugstoneType === 'protein') .filter(wrapper => wrapper.data.drugstoneType === 'protein')
.map(wrapper => wrapper.data.uniprotAc) .map(wrapper => wrapper.data.id)
.join('%0A'); .join('%0A');
return 'http://biit.cs.ut.ee/gprofiler/gost?' + return 'https://biit.cs.ut.ee/gprofiler/gost?' +
'organism=hsapiens&' + 'organism=hsapiens&' +
`query=${queryString}&` + `query=${queryString}&` +
'ordered=false&' + 'ordered=false&' +
...@@ -557,19 +566,44 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -557,19 +566,44 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
'background='; 'background=';
} }
openExternal(url) {
window.open(url, '_blank').focus();
}
async openDigest() {
let proteins = this.analysis.getSelection()
.filter(wrapper => wrapper.data.drugstoneType === 'protein')
.map(wrapper => wrapper.data.id);
let params = {
runs: 1000,
replace: 100,
distance: 'jaccard',
background_model: 'complete',
type: 'gene',
target: proteins,
target_id: this.drugstoneConfig.config.identifier
};
let resp = await this.netex.digest_request(params).catch(err => console.error(err));
let url = 'https://digest-validation.net/result?id=' + resp.task;
this.openExternal(url)
}
//TODO change to access through network service //TODO change to access through network service
@ViewChild('analysisPanel') analysisPanel; @ViewChild('analysisPanel') analysisPanel;
getNodes(): any { getNodes(): any {
if (this.selectedAnalysisToken && this.analysisPanel) if (this.selectedAnalysisToken && this.analysisPanel) {
return this.analysisPanel.getResultNodes() return this.analysisPanel.getResultNodes();
}
return this.networkHandler.activeNetwork.inputNetwork.nodes; return this.networkHandler.activeNetwork.inputNetwork.nodes;
} }
getEdges(): any { getEdges(): any {
if (this.selectedAnalysisToken && this.analysisPanel) if (this.selectedAnalysisToken && this.analysisPanel) {
return this.analysisPanel.getResultEdges() return this.analysisPanel.getResultEdges();
return this.networkHandler.activeNetwork.inputNetwork.edges }
return this.networkHandler.activeNetwork.inputNetwork.edges;
} }
......
...@@ -43,6 +43,10 @@ export class NetexControllerService { ...@@ -43,6 +43,10 @@ export class NetexControllerService {
return this.http.get<Tissue[]>(`${environment.backend}tissues/`); return this.http.get<Tissue[]>(`${environment.backend}tissues/`);
} }
public digest_request(payload): Promise<any> {
return this.http.post('https://api.digest-validation.net/set', payload).toPromise();
}
public tissueExpressionGenes(tissue: Tissue, nodes: Node[]): Observable<any> { public tissueExpressionGenes(tissue: Tissue, nodes: Node[]): Observable<any> {
/** /**
* Returns the expression in the given tissue for given nodes and cancerNodes * Returns the expression in the given tissue for given nodes and cancerNodes
...@@ -58,9 +62,9 @@ export class NetexControllerService { ...@@ -58,9 +62,9 @@ export class NetexControllerService {
public adjacentDisorders(nodes: Node[], nodeType: string, dataset: string, licenced: boolean): Observable<any> { public adjacentDisorders(nodes: Node[], nodeType: string, dataset: string, licenced: boolean): Observable<any> {
const params = {dataset: dataset, licenced: licenced}; const params = {dataset: dataset, licenced: licenced};
if (nodeType === 'proteins') { if (nodeType === 'proteins') {
params["proteins"] = nodes.filter((node: Node) => node.drugstoneId && node.drugstoneType === 'protein').flatMap((node: Node) => node.drugstoneId).map(id => id.slice(1)); params['proteins'] = nodes.filter((node: Node) => node.drugstoneId && node.drugstoneType === 'protein').flatMap((node: Node) => node.drugstoneId).map(id => id.slice(1));
} else if (nodeType === 'drugs') { } else if (nodeType === 'drugs') {
params["drugs"] = nodes.map((node: Node) => node.drugId && node.drugstoneType === 'drug' ? node.drugstoneId.slice(2) : undefined).filter(id => id != null); params['drugs'] = nodes.map((node: Node) => node.drugId && node.drugstoneType === 'drug' ? node.drugstoneId.slice(2) : undefined).filter(id => id != null);
} }
return this.http.post<any>(`${environment.backend}adjacent_disorders/`, params); return this.http.post<any>(`${environment.backend}adjacent_disorders/`, params);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<title>Network Expander</title> <title>Network Expander</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script> <script type="text/javascript" src="http://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="./stylesheets/default-theme.css">--> <!-- <link rel="stylesheet" type="text/css" href="./stylesheets/default-theme.css">-->
</head> </head>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment