Commit 68e9c2f5 authored by Francois Dubiez's avatar Francois Dubiez Committed by Mathieu Giraud

Changed IMGT defaut form

added a function using ajax to request data from imgt et process the response
parent 6e69ba26
//parametre IMGT par defaut
var imgtInput = {};
imgtInput["callback"] = "jQuery17106713638880755752_1378825832820"
imgtInput["callback"] = "jQuery17106713638880755752_1378825832820";
imgtInput["livret"] = "1";
imgtInput["Session"] = "<session code=¤0¤ appliName=¤IMGTvquest¤ time=¤3625396897¤/>";
imgtInput["l01p01c02"] = "Homo sapiens";
......@@ -34,15 +33,15 @@ imgtInput["l01p01c31"] = "Y";
imgtInput["l01p01c32"] = "Y";
imgtInput["l01p01c33"] = "Y";
imgtInput["l01p01c34"] = "Y";
imgtInput["l01p01c46"] = "Y";
imgtInput["l01p01c47"] = "Y";
imgtInput["l01p01c48"] = "Y";
imgtInput["l01p01c49"] = "Y";
imgtInput["l01p01c46"] = "N";
imgtInput["l01p01c47"] = "N";
imgtInput["l01p01c48"] = "N";
imgtInput["l01p01c49"] = "N";
imgtInput["l01p01c50"] = "Y";
imgtInput["l01p01c51"] = "Y";
imgtInput["l01p01c52"] = "Y";
imgtInput["l01p01c53"] = "Y";
imgtInput["l01p01c54"] = "Y";
imgtInput["l01p01c51"] = "N";
imgtInput["l01p01c52"] = "N";
imgtInput["l01p01c53"] = "N";
imgtInput["l01p01c54"] = "N";
imgtInput["l01p01c55"] = "NO";
imgtInput["l01p01c35"] = "F+ORF+ in-frame P";
imgtInput["l01p01c36"] = "0";
......@@ -83,7 +82,6 @@ igBlastInput["CMD"] = "request";
igBlastInput["seqtype"] = "TCR";
function imgtPost(data, system) {
imgtInput["l01p01c10"] = data;
......@@ -110,6 +108,120 @@ function imgtPost(data, system) {
form.submit();
}
/**
* Send of form to imgt to get valuable information from genes like
* operativeness, CDR3 sequence ....
* Process the information received
* display it in the segmenter div of the browser.
*
* @param data
* @param system
*/
function imgtPostForSegmenter(data, system) {
//limit #request to #
var pos, nb = 1;
pos = 0;
while ((pos = data.indexOf(">", pos + 1)) > 0) {
nb++;
}
//process to first 10 sequences then send another process to handle to remaining part
if (nb > 10) {
pos = nth_ocurrence(data, '>', 11);
var newdata = data.substr(pos);
data = data.substr(0, pos - 1);
var msg = "Analysis has been cut off after the 10th sequence due to IMGT limits. Please change your selection to update the other clones, after this processing. ";
/* Need to think about how to link a sequence list to a cloneID when more than 10.
if (pos >= 0) {
msg += " Please note that another set is to be sent for analysis to IMGT. this may take some time !";
imgtPostForSegmenter(newdata, system);
}*/
console.log({
"type": "flash",
"msg": msg ,
"priority": 1
});
}
imgtInput["l01p01c07"] = "3. Excel";
imgtInput["l01p01c10"] = data;
imgtInput["l01p01c62"] = 2;
if (system[0] == "I") {
imgtInput["l01p01c04"] = "IG";
}
if (system[0] == "T") {
imgtInput["l01p01c04"] = "TR";
}
var form = document.getElementById("form");
form.innerHTML = "";
form.target = "";
//disabled due to security concerns
//form.action = "http://www.imgt.org/IMGT_vquest/vquest";
//using proxy on server to allow requests on other site than vidjil one's in JS.
form.action = "https://test.vidjil.org/vidjil/proxy/imgt";
form.method = "POST";
for (var k in imgtInput) {
var input = document.createElement("input");
input.type = "hidden";
input.name = k;
input.value = imgtInput[k];
form.appendChild(input);
}
/*due to browser's security limitations, a proxy had to be settled. */
var httpRequest = new XMLHttpRequest();
var imgtArray;
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
console.log({
"type": "flash",
"msg": "imgtPostForSegmenter: Loading results from Imgt Form ",
"priority": 1
});
imgtArray = processImgtContents(httpRequest.responseText, "pre");
var logmsg = "IMGT: processing clone idx(";
var cloneIdx;
for (var i = 0; i < imgtArray.length; i++) {
//merge clone from segmenter and imgtinfo
//loop through the model maintained selection list
cloneIdx= m.orderedSelectedClones[i];
logmsg += cloneIdx + ",";
//remove unneeded info coz relative to # of selected items
delete imgtArray[i]["Sequence number"];
m.clones[cloneIdx].seg.imgt = imgtArray[i];
m.clones[cloneIdx].seg.imgt2display = computeStartStop(imgtArray[i],m.clones[cloneIdx].getSequence());
//toggle save in analysis file
m.clones[cloneIdx].segEdited = true;
}
logmsg=logmsg.substr(logmsg.length-1)==","?logmsg.substr(0,logmsg.length-1):logmsg;
m.updateElemStyle(m.getSelected());
console.log({
"type": "flash",
"msg": logmsg + ")" + httpRequest.statusText,
"priority": 1
});
}
}
httpRequest.onerror = function () {
console.log({
"type": "flash",
"msg": "imgtPostForSegmenter: error while requesting IMGT website: " + httpRequest.statusText,
"priority": 2
});
}
//test with a local file
//httpRequest.open('GET', '/vidjil/data/vquest.data');
httpRequest.open(form.method, form.action, true);
httpRequest.send(new FormData(form));
}
function igBlastPost(data, system) {
......@@ -175,7 +287,6 @@ function arrestPost(data, system) {
}
//parametre blast par defaut
var blastInput = {};
blastInput["query_sequence"] = "";
......
Markdown is supported
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