Skip to content

Commit

Permalink
changed NO GUI pathfinding function
Browse files Browse the repository at this point in the history
  • Loading branch information
ivp08001 committed Dec 16, 2015
1 parent 0c462be commit b2d4c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
6 changes: 4 additions & 2 deletions VQI_PathwayEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,7 @@ var VQI_PathwayEditor = function (parent) {
cy.on('doubleTap', 'edge', function (event) {
target = event.cyTarget;
dialogEdge.dialog("open");
console.log(event.cyTarget._private.data.id)
});

cy.on('select', 'node', function (event) {
Expand Down Expand Up @@ -2155,14 +2156,15 @@ var VQI_PathwayEditor = function (parent) {

self.findPathAndScoreExternalYueNoGUI = function (sid, did, f) {
var paths = findPath(self.json, sid, did);
var nodes = convertEdgePathtoNodePathNoGUI(paths, self.json);
$.post(services['pathwayScorer'], {
data_json: JSON.stringify(self.json)
}, function (yue_data) {
var result = []
var scoreJSON = JSON.parse(yue_data);
for (var n = 0; n < paths.length; n++) {
var score = getPathScore(paths[n], scoreJSON).toString();
result.push({"path": n, "edges": paths[n], "score": score});
result.push({"path": n, "edges": paths[n], "nodes": nodes[n], "score": score});
}
f(result);
});
Expand All @@ -2177,7 +2179,7 @@ var VQI_PathwayEditor = function (parent) {
var result = [];
var score = JSON.parse(tham_data);
for (var n = 0; n < paths.length; n++) {
result.push({"path": n, "nodes": nodes[n], "score": score[n]});
result.push({"path": n, "edges": paths[n], "nodes": nodes[n], "score": score[n]});
}
f(result);
});
Expand Down
24 changes: 20 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,50 @@
<input type=button onclick="spray()" value="spray">
<input type=button onclick="findYue()" value="find Yue">
<input type=button onclick="findTham()" value="find Tham">
<input type=button onclick="print()" value="print">
<input id="file" type=file value="spray from file">
<div id="parent"></div>
<script src="VQI_Observable.js"></script>
<script src="VQI_PathwayEditor.js"></script>
<script>
var objVQI_PathwayEditor = new VQI_PathwayEditor("parent");
function load() {
objVQI_PathwayEditor.loadPathwayExternalNoGUI(331);
objVQI_PathwayEditor.loadPathwayExternalNoGUI(302);
}
function findYue() {
objVQI_PathwayEditor.findPathAndScoreExternalYueNoGUI("n0", "n22", function (result) {
console.log(result)
});
}
function findTham() {
objVQI_PathwayEditor.findPathAndScoreExternalThamNoGUI("n0", "n4", function (result) {
objVQI_PathwayEditor.findPathAndScoreExternalThamNoGUI("n0", "n22", function (result) {
console.log(result)
});
}
function spray() {
var data = [["AKT1", 1, 2, 3], ["AKT1", 1, 2, 3]];
objVQI_PathwayEditor.sprayColorExternalNoGUI(data);
}
function sprayFromFile() {
var data = [];
var lines = [];
var file = this.files[0];
var reader = new FileReader();
reader.onload = function(progressEvent) {
// By lines
var list = this.result.split('\n');
for(var line = 0; line < list.length; line++) {
lines[line] = list[line].split('\t');
}
objVQI_PathwayEditor.sprayColorExternalNoGUI(lines);
}
reader.readAsText(file);
}
function print() {
objVQI_PathwayEditor.printGraph();
}
document.getElementById("file").addEventListener("change", sprayFromFile);
</script>
</body>
</html>

0 comments on commit b2d4c64

Please sign in to comment.