-
Notifications
You must be signed in to change notification settings - Fork 1
/
interactingGenes.html
109 lines (96 loc) · 3.78 KB
/
interactingGenes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<title>Genes interacting with AKT2</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Copyright (c) 2018 Egon Willighagen <[email protected]>
MIT license -->
<!-- ops.js, d3.js, and depedencies -->
<script type="text/javascript" src="https://egonw.github.io/pils/lib/purl.js"></script>
<script type="text/javascript" src="https://egonw.github.io/pils/lib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="https://egonw.github.io/pils/src/combined.js"></script>
</head>
<body>
<h3>Gene</h3>
<div id="uri"></div>
<p>
<table>
<thead>
<tr>
<td><b>Interaction Gene</b></td>
<td><b>Database</b></td>
<td><b>Number of Interaction</b></td>
</tr>
</thead>
<tbody id="list">
</tbody>
</table>
</p>
<!-- dynamically create a table with type information -->
<script type="text/javascript">
var query = location.search.substr(1);
var result = {};
query.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = decodeURIComponent(item[1]);
});
var queryGene = 'http://identifiers.org/ensembl/ENSG00000105221'
if (result["uri"]) queryGene = result["uri"]
document.getElementById("uri").innerText = "Query: " + queryGene
var pathwayService = new PathwaySearch(
"https://beta.openphacts.org/2.1", "91f5d4d0", "1af5086da757e57c553bfa1351708d5f"
);
// results return asynchronously from the pathwayService.getInteractionsByEntity()
// call and are handled by the method
var handleInteractingGenes = function(success, status, interactionData) {
if (success && status == 200) {
var itemCount = interactionData.items.length;
var uniqueGenes = []
for (var i = 0; i < itemCount; i++) {
var interaction = interactionData.items[i]
var rowNode = document.createElement("tr");
if (interaction.source._about != queryGene) otherGeneURI = interaction.source._about
if (interaction.target._about != queryGene) otherGeneURI = interaction.target._about
var database = otherGeneURI.split("/")[3]
var otherDatabase = document.createElement("td");
var otherGene = otherGeneURI.split("/")[4]
var otherNode = document.createElement("td");
if (!(uniqueGenes.includes(otherGene))) {
otherNode.innerText = otherGene
otherDatabase.innerText = database
rowNode.setAttribute("id", otherGene)
rowNode.appendChild(otherNode)
rowNode.appendChild(otherDatabase)
document.getElementById("list").appendChild(rowNode);
pathwayService.countInteractionsByEntity(
otherGeneURI, null, null, null, handleInteractionCount
);
uniqueGenes.push(otherGene)
}
}
}
};
// results return asynchronously from the pathwayService.countInteractionsByEntity()
// call and are handled by the method
var handleInteractionCount = function(success, status, interactionData) {
if (success && status == 200) {
var geneURI = interactionData.primaryTopic.isPrimaryTopicOf.split("uri=")[1]
geneURI = geneURI.replace(new RegExp("%2F", 'g'), "/")
geneURI = geneURI.replace("%3A", ":")
var geneid = geneURI.split("/")[4]
var count = interactionData.primaryTopic.interactions_count
var otherNode = document.createElement("td");
var otherLink = document.createElement("a");
otherLink.setAttribute("href", "?uri=" + geneURI)
otherLink.innerText = count
otherNode.appendChild(otherLink)
document.getElementById(geneid).appendChild(otherNode);
}
};
pathwayService.getInteractionsByEntity(
queryGene, null, null, null, 0, 1000, null,
handleInteractingGenes
);
</script>
</body>
</html>