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

tools.js: Function to get the common name of a species

IMGT/V-QUEST now requires to have the common name of the species, not the latin one.
Thus we need a function to do the conversion.

See #3913
parent 57402d95
......@@ -12,7 +12,7 @@ function setCrossDomainModel(model) {
//parametre IMGT par defaut
function initImgtInput(species) {
var imgtInput = {};
imgtInput.species = species;
imgtInput.species = getSpeciesCommonName(species);
imgtInput.receptorOrLocusType = "TR";
imgtInput.inputType = "inline";
imgtInput.resultType = "synthesis";
......
......@@ -134,6 +134,25 @@ function get_mutations(ref, seq, frame, with_end_codon) {
return mutations;
}
/**
* @return the common name of a species. Or the original name if the common
* name has not been set. The common names are given so that they are
* compatible with IMGT/V-QUEST®
*/
function getSpeciesCommonName(species) {
var lower_species = species.toLowerCase();
switch(lower_species) {
case "homo sapiens":
return "human";
case "mus musculus":
return "house mouse";
case "gallus gallus":
return "chicken";
default:
return species;
}
}
/**
* Find the position of the nth occurence of needle
*
......
......@@ -139,6 +139,13 @@ QUnit.test("test nth_ocurrence", function(assert) {
}
);
QUnit.test("test getSpeciesCommonName", function(assert) {
assert.equal(getSpeciesCommonName("homo sapiens"), "human");
assert.equal(getSpeciesCommonName("Homo sapiens"), "human");
assert.equal(getSpeciesCommonName("mus musculus"), "house mouse");
assert.equal(getSpeciesCommonName("gallus gallus"), "chicken");
});
QUnit.test("test tsvToArray", function(assert) {
var tabstring = "head1\thead2\thead3\thead4\nLine 1 data1\tLine 1 data2\tLine 1 data3\tLine 1 data4\n";
tabstring += "Line 2 data1\tLine 2 data2\tLine 2 data3\tLine 2 data4";
......
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