Commit 24ce6e00 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/3917-assign-subset' into 'dev'

Assign subset

See merge request !497
parents 6a2a14bc 10a607a3
Pipeline #95390 passed with stages
in 5 minutes and 51 seconds
......@@ -136,9 +136,7 @@ function imgtPostForSegmenter(species, data, system, segmenter, override_imgt_op
//process to first 10 sequences then alert user about the remaining part
if (nb > 10) {
pos = nth_ocurrence(data, '>', 11);
var newdata = data.substr(pos);
data = data.substr(0, pos - 1);
data = getNFirstSequences(data, 10);
var msg = "The first 10 sequences were sent to IMGT/V-QUEST."
console.log({
......@@ -307,7 +305,7 @@ function imgtPostForSegmenter(species, data, system, segmenter, override_imgt_op
}
function igBlastPost(data, system) {
function igBlastPost(species, data, system) {
var igBlastInput = initIgBlastInput();
igBlastInput.queryseq = data;
if (system[0] == "I") {
......@@ -351,7 +349,7 @@ arrestInput.fname = "exported_func" ;
arrestInput.pjxrand = ".0033328778554" ;
arrestInput.elite = "" ;
function arrestPost(data, system) {
function arrestPost(species, data, system) {
arrestInput.args = data;
......@@ -394,7 +392,12 @@ blastInput.NCBIBLAST_BLASTN__ungapped = 0;
blastInput.NCBIBLAST_BLASTN__dust = 1;
blastInput.NCBIBLAST_BLASTN__repeat_mask = 1;
function blastPost(data, system) {
function blastPost(species, data, system) {
if (self.m.getSelected().length > 30) {
data = getNFirstSequences(data, 30);
console.log({"type": "flash", "msg": "A maximum of 30 clones are allowed by Blast. Only the first 30 sequences will be sent" , "priority": 1});
}
blastInput.query_sequence = data;
......@@ -415,3 +418,58 @@ function blastPost(data, system) {
form.submit();
}
function assignSubsetsPost(species, data, system) {
if (system != "IGH") {
console.log({"type": "flash",
"msg": "Subsets are only defined for IGH sequences. Thus you cannot launch it on other sequences",
"priority": 1});
} else {
var form = document.getElementById("form");
form.removeAllChildren();
// form.target = "_blank";
form.enctype = 'multipart/form-data';
form.name = 'assignsubsets';
form.action = "http://tools.bat.infspire.org/cgi-bin/arrest/assignsubsets_html.pl";
form.method = "POST";
var formData = {};
formData.fastatext = data;
formData.elite = null;
for (var k in formData) {
var input = document.createElement("input");
input.type = "hidden";
input.name = k;
if (formData[k] != null)
input.value = formData[k];
form.appendChild(input);
}
form.submit();
}
}
/**
* Creates and returns a sendTo button (in a span)
* @param {id}: id of the span
* @param {name}: name of the sendTo function ({name}Post) [useless if
* {onclick} is provided
* @param {label}: Label of the button
* @param {title}: Title when hovering the button
* @param {onclick}: (optional) Function to be called when clicking the button.
* By default will call {name}Post()
*
*/
function createSendToButton(id, name, label, title, segmenter, onclick) {
var span = document.createElement('span');
span.id = id;
span.setAttribute('title', 'title')
span.className = "button";
if (typeof onclick !== "undefined") {
span.onclick = onclick;
} else {
span.onclick = function () {
segmenter.sendTo(name);
};
}
span.appendChild(document.createTextNode(label));
return span;
}
......@@ -187,74 +187,47 @@ Segment.prototype = {
div_menu.appendChild(span)
//toIMGT button
span = document.createElement('span');
span.id = "toIMGT"
span.setAttribute('title', 'Send sequences to IMGT/V-QUEST and see the results in a new tab')
span.className = "button"
span.onclick = function () {
self.sendTo('IMGT')
}
span.appendChild(document.createTextNode("❯ to IMGT/V-QUEST"));
span = createSendToButton("toIMGT", 'imgt', "❯ to IMGT/V-QUEST",
'Send sequences to IMGT/V-QUEST and see the results in a new tab', this);
div_menu.appendChild(span)
//toIMGTSeg button
span = document.createElement('span');
span.id = "toIMGTSeg";
span.setAttribute('title', 'Send sequences to IMGT/V-QUEST and loads the results in the sequence panel')
span.className = "button button_next";
span.onclick = function () {
self.sendTo('IMGTSeg')
};
span.appendChild(document.createTextNode(""));
span = createSendToButton("toIMGTSeg", "IMGTSeg", "",
'Send sequences to IMGT/V-QUEST and loads the results in the sequence panel', this);
span.className += " button_next";
div_menu.appendChild(span);
//toIgBlast button
span = document.createElement('span');
span.id = "toIgBlast";
span.setAttribute('title', 'Send sequences to NCBI IgBlast and see the results in a new tab')
span.className = "button";
span.onclick = function () {
self.sendTo('igBlast')
};
span.appendChild(document.createTextNode("❯ to IgBlast"));
span = createSendToButton("toIgBlast", 'igBlast', "❯ to IgBlast",
'Send sequences to NCBI IgBlast and see the results in a new tab', this);
div_menu.appendChild(span);
//toARResT button
span = document.createElement('span');
span.id = "toARResT";
span.setAttribute('title', 'Send sequences to ARResT/CompileJunctions and see the results in a new tab')
span.className = "button devel-mode";
span.onclick = function () {
self.sendTo('ARResT')
};
span.appendChild(document.createTextNode("❯ to ARResT/CJ"));
span = createSendToButton("toARResT", "arrest", "❯ to ARResT/CJ",
'Send sequences to ARResT/CompileJunctions and see the results in a new tab', this);
span.className += " devel-mode";
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 ";
span.className += (typeof config !== 'undefined' && config.clonedb) ? "" : "devel-mode";
span.onclick = function () {
self.db.callCloneDB(self.m.getSelected());
};
span.appendChild(document.createTextNode("❯ to CloneDB"));
span = createSendToButton('toCloneDB', '', "❯ to CloneDB",
'Send sequences to EC-NGS/CloneDB in the background',
this,
function () {
self.db.callCloneDB(self.m.getSelected());
});
span.className += (typeof config !== 'undefined' && config.clonedb) ? "" : " devel-mode";
div_menu.appendChild(span);
//toBlast button
span = document.createElement('span');
span.id = "toBlast";
span.setAttribute('title', 'Send sequences to Ensembl Blast and see the results in a new tab')
span.className = "button";
span.onclick = function () {
if (self.m.getSelected().length > 30) {
console.log({"type": "flash", "msg": "A maximum of 30 clones are allowed by Blast" , "priority": 1});
} else {
self.sendTo('blast');
}
};
span.appendChild(document.createTextNode("❯ to Blast"));
span = createSendToButton("toBlast", "blast",
"❯ to Blast",
'Send sequences to Ensembl Blast and see the results in a new tab', this);
div_menu.appendChild(span);
// to AssignSubset
span = createSendToButton("toAssignSubsets", "assignSubsets", "❯ to AssignSubsets",
"Send sequences to ARResT/AssignSubsets to classify IGH sequence in a CLL subset", this);
span.className += " devel-mode";
div_menu.appendChild(span);
//toClipBoard button
......@@ -857,7 +830,7 @@ Segment.prototype = {
/**
* build a request with currently selected clones to send to IMGT or igblast <br>
* (see crossDomain.js)
* @param {string} address - 'IMGT', 'ARResT', 'igBlast' or 'Blast'
* @param {string} address - 'imgt', 'arrest', 'igBlast' or 'blast'
* */
sendTo: function (address) {
......@@ -884,18 +857,14 @@ Segment.prototype = {
request += ">" +list[i] + "\n" +this.germline[this.sequence[list[i]].locus][list[i]] + "\n";
}
}
if (address == 'IMGT') {
imgtPost(this.m.species, request, system);
}
if (address == 'IMGTSeg') {
imgtPostForSegmenter(this.m.species, request, system, this);
var change_options = {'xv_ntseq' : 'false', // Deactivate default output
'xv_summary' : 'true'}; // Activate Summary output
imgtPostForSegmenter(this.m.species, request, system, this, change_options);
} else {
window[address+"Post"](this.m.species, request, system)
}
if (address == 'ARResT') arrestPost(request, system);
if (address == 'igBlast') igBlastPost(request, system);
if (address == 'blast') blastPost(request, system);
this.update();
......
......@@ -712,4 +712,19 @@ function openAndFillNewTab (content){
html: content
}).appendTo(w.document.body);
return
}
\ No newline at end of file
}
/**
* @param {data} a string containing a multi-FASTA
* @param {n} the number of sequences to keep
* @return return a string containing at most {n} FASTA sequences.
* if {n} is negative or null return {data} itself
*/
function getNFirstSequences(data, n) {
var pos = nth_ocurrence(data, '>', n+1);
if (pos) {
return data.substr(0, pos);
} else {
return data;
}
}
......@@ -416,3 +416,11 @@ QUnit.test("Sort list locus", function(assert) {
assert.deepEqual(list_test_2, wait_test_2, "list2 is correctly sorted")
}
);
QUnit.test("Get n first sequences", function(assert) {
seqs=">seq1\nAT\n>seq2\nTC\n>seq3\nCC\n";
assert.equal(getNFirstSequences(seqs, 1), ">seq1\nAT\n");
assert.equal(getNFirstSequences(seqs, 0), seqs);
assert.equal(getNFirstSequences(seqs, -1), seqs);
assert.equal(getNFirstSequences(seqs, 2), ">seq1\nAT\n>seq2\nTC\n");
});
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