-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from KeithKelleher/main
framework updates
- Loading branch information
Showing
8 changed files
with
859 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import {Request, Response} from "express"; | ||
import {setHeaders} from "../../models/endpoints"; | ||
import url from "url"; | ||
import querystring from "querystring"; | ||
import PairwiseService from "../pairwise-relationship-data/pairwiseService"; | ||
import {PredictionSet} from "../../models/prediction"; | ||
import {getMinimalCitation} from "../../models/modelData"; | ||
|
||
function formatCancerSpecificData(data: any) { | ||
const ps = new PredictionSet("Cancer Specific Coexpression", "Protein", "", | ||
"", 1, 0, null, "Coexpressed Target", | ||
["Data Source", "Cancer Type", "Coexpressed Target"]); | ||
Object.entries(data).forEach((match: any) => { | ||
{ | ||
match = match[1]; | ||
let dataSource = match.dataDesc.id.split("|")[0]; | ||
let cancerType = match.dataDesc.id.split("|")[1]; | ||
if (match && match.posGenes) { | ||
match.posGenes.forEach((gene: any) => { | ||
const extraFields: any = | ||
{ | ||
identifier: [ | ||
{ | ||
"@type": "PropertyValue", | ||
"name": "Data Source", | ||
"value": dataSource | ||
}, | ||
{ | ||
"@type": "PropertyValue", | ||
"name": "Cancer Type", | ||
"value": cancerType | ||
} | ||
], | ||
}; | ||
ps.addPrediction(gene, "", null, extraFields); | ||
}); | ||
} | ||
} | ||
}) | ||
return ps; | ||
} | ||
|
||
function formatTissueSpecificData(data: any) { | ||
const ps = new PredictionSet("Tissue Specific Coexpression", "Protein", "", | ||
"", 1, 0, null, "Coexpressed Target", | ||
["Data Source", "Tissue", "Coexpressed Target"]); | ||
Object.entries(data).forEach((match: any) => { | ||
{ | ||
match = match[1]; | ||
let dataSource = match.dataDesc.id.split("|")[0]; | ||
let tissue = match.dataDesc.id.split("|")[1]; | ||
if (match && match.posGenes) { | ||
match.posGenes.forEach((gene: any) => { | ||
const extraFields: any = | ||
{ | ||
identifier: [ | ||
{ | ||
"@type": "PropertyValue", | ||
"name": "Data Source", | ||
"value": dataSource | ||
}, { | ||
"@type": "PropertyValue", | ||
"name": "Tissue", | ||
"value": tissue | ||
}], | ||
}; | ||
ps.addPrediction(gene, "", null, extraFields); | ||
}) | ||
} | ||
} | ||
}) | ||
ps.addCitation(getMinimalCitation(37333417)); | ||
return ps; | ||
} | ||
|
||
export async function coexpressionData(req: Request, res: Response): Promise<any>{ | ||
setHeaders(res); | ||
const parsedUrl = url.parse(req.url); | ||
const queryMap = querystring.parse(parsedUrl.query); | ||
if (queryMap.target) { | ||
const targetQuery = queryMap.target.toString(); | ||
const csDataDescriptions: any = PairwiseService.getAllDataDescs('TCGA', 'Gene_Coexpression'); | ||
const tsDataDescriptions: any = PairwiseService.getAllDataDescs('GTEx', 'Gene_Coexpression'); | ||
|
||
return Promise.all([csDataDescriptions, tsDataDescriptions]).then((dataDescriptionResults: any[]) => { | ||
const csDataDescIds = dataDescriptionResults[0].map((o: any) => Object(o.id)); | ||
const tsDataDescIds = dataDescriptionResults[1].map((o: any) => Object(o.id)); | ||
|
||
const csPairwiseSearch = PairwiseService.searchTermSecondaryPathways( | ||
{ | ||
"genes": [targetQuery], | ||
"dataDescs": csDataDescIds | ||
}); | ||
const tsPairwiseSearch = PairwiseService.searchTermSecondaryPathways( | ||
{ | ||
"genes": [targetQuery], | ||
"dataDescs": tsDataDescIds | ||
}); | ||
return Promise.all([csPairwiseSearch, tsPairwiseSearch]).then((pwSearchResults: any[]) => { | ||
const csPs = formatCancerSpecificData(pwSearchResults[0]); | ||
const tsPs = formatTissueSpecificData(pwSearchResults[1]); | ||
res.end(JSON.stringify([tsPs.asJSON(), csPs.asJSON()])); | ||
}) | ||
}); | ||
} | ||
res.end("No Protein Provided!"); | ||
} | ||
|
||
exports.coexpressionData = coexpressionData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {Request, Response} from "express"; | ||
import {setHeaders} from "../../models/endpoints"; | ||
import querystring from "querystring"; | ||
import PairwiseService from "./pairwiseService"; | ||
import url from "url"; | ||
import {PredictionSet} from "../../models/prediction"; | ||
import {getMinimalCitation} from "../../models/modelData"; | ||
|
||
export async function interactorScores(req: Request, res: Response): Promise<any> { | ||
setHeaders(res); | ||
const parsedUrl = url.parse(req.url); | ||
const queryMap = querystring.parse(parsedUrl.query); | ||
|
||
if (queryMap.target) { | ||
const targetQuery = queryMap.target.toString(); | ||
const score = +queryMap.score || 0.5; | ||
try { | ||
await PairwiseService.getInteractorScoresForTerm(targetQuery, score) | ||
.then(data => { | ||
const ps = new PredictionSet("Reactome Functional Interactions (FIs)", "Protein", "FI Score", | ||
"Score of how likely two proteins are to interact with each other functionally", | ||
1, 0, null, "FI Partner"); | ||
Object.entries(data).forEach((intScore: any) => { | ||
{ | ||
intScore = intScore[1] | ||
ps.addPrediction(intScore.gene, "", intScore.score); | ||
} | ||
}) | ||
ps.addCitation(getMinimalCitation(37333417)); | ||
res.end(JSON.stringify([ps.asJSON()])) | ||
}); | ||
return; | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
res.end("No Protein Provided!"); | ||
} | ||
|
||
exports.interactorScores = interactorScores; |
53 changes: 53 additions & 0 deletions
53
data_sources/pairwise-relationship-data/pairwiseService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import axios from "axios"; | ||
|
||
class PairwiseService { | ||
static getInteractorScoresForTerm(term: string, cutoff: number) { | ||
return new Promise((resolve, reject) => { | ||
axios | ||
.get(`https://idg.reactome.org/idgpairwise/relationships/combinedScoreGenesForTerm/${term}`) | ||
.then((res) => { | ||
resolve( | ||
Object.entries(res.data).map(([gene, score]) => ({ | ||
gene: gene, | ||
score: score, | ||
// @ts-ignore | ||
})).filter(({score}) => score >= cutoff) | ||
); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
static searchTermSecondaryPathways(postData: {}) { | ||
return new Promise((resolve, reject) => { | ||
axios | ||
.post(`https://idg.reactome.org/idgpairwise/pairwise/term/false`, postData) | ||
.then((res) => { | ||
resolve(res.data); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
static getAllDataDescs(provenance: string, dataType: string) { | ||
return new Promise((resolve, reject) => { | ||
axios | ||
.get(`https://idg.reactome.org/idgpairwise/datadesc`) | ||
.then((res) => { | ||
resolve( | ||
res.data.filter((desc: any) => | ||
desc.provenance === provenance && | ||
desc.dataType === dataType)) | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export default PairwiseService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
const endpoints = require("./models/endpoints"); | ||
const kinasecancer = require("./data_sources/kinase-cancer-predictions/index") | ||
const interactorScores = require("./data_sources/pairwise-relationship-data/index"); | ||
const coexpressionData = require("./data_sources/coexpression-data/index"); | ||
|
||
exports.ping = endpoints.ping; | ||
exports.sample = endpoints.sample; | ||
exports.predictions = kinasecancer.predictions; | ||
exports.predictions = kinasecancer.predictions; | ||
exports.interactorScores = interactorScores.interactorScores; | ||
exports.coexpressionData = coexpressionData.coexpressionData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.