Commit d71eb90c authored by Mikaël Salson's avatar Mikaël Salson
Browse files

js/{database,segmenter}.js: CloneDB call

parent ca09695c
......@@ -4,6 +4,7 @@ DB_TIMEOUT_GET_DATA = 20000 // Get patient/sample .data
DB_TIMEOUT_GET_CUSTOM_DATA = 1200000 // Launch custum fused sample .data
NOTIFICATION_PERIOD = 30000 // Time interval to check for notifications periodically
var SEQ_LENGTH_CLONEDB = 40; // Length of the sequence retrieved for CloneDB
/**
*
......@@ -249,6 +250,41 @@ Database.prototype = {
});
},
callCloneDB: function(clones) {
var windows = [];
var self = this;
var kept_clones = [];
for (var i = 0; i < clones.length; i++) {
var clone = this.m.clones[clones[i]];
if (clone.hasSeg('5', '3')) {
var middle_pos = Math.round((clone.seg['5']['stop'] + clone.seg['3']['start'])/2);
windows.push(clone.sequence.substr(middle_pos - Math.round(SEQ_LENGTH_CLONEDB/2), SEQ_LENGTH_CLONEDB));
kept_clones.push(clones[i]);
}
}
$.ajax({
type: "POST",
url: self.db_address+"clonedb",
data: "sequences="+windows.join()+"&sample_set_id="+self.m.sample_set_id,
xhrFields: {withCredentials: true},
success: function (result) {
self.connected = true;
for (var i = 0; i < kept_clones.length; i++) {
self.m.clones[kept_clones[i]].seg.clonedb = processCloneDBContents(result[i]);
}
},
error: function() {
self.connected = false;
console.log({
"type": "flash",
"msg": "Error while requesting CloneDB",
"priority": 2
});
}
});
},
pre_process_onChange : function () {
......
......@@ -182,6 +182,17 @@ Segment.prototype = {
span.appendChild(document.createTextNode("❯ to ARResT/CJ"));
div_menu.appendChild(span);
//toCloneDB button
span = document.createElement('span');
span.id = "toCloneDB";
span.setAttribute('title', 'Send sequences to EC-NGS/CloneDB in the background')
span.className = "button devel-mode";
span.onclick = function () {
self.db.callCloneDB(self.m.getSelected());
};
span.appendChild(document.createTextNode("❯ to CloneDB"));
div_menu.appendChild(span);
//toBlast button
span = document.createElement('span');
span.id = "toBlast";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment