Commit bb72c63b authored by Mikaël Salson's avatar Mikaël Salson

browser/js: Uniformize the way we deal with sites limiting the number of input sequences

parent 5237cf98
......@@ -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({
......@@ -395,6 +393,11 @@ blastInput.NCBIBLAST_BLASTN__dust = 1;
blastInput.NCBIBLAST_BLASTN__repeat_mask = 1;
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;
......
......@@ -248,11 +248,7 @@ Segment.prototype = {
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"));
div_menu.appendChild(span);
......
......@@ -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