Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vidjil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,696
Issues
1,696
List
Boards
Labels
Service Desk
Milestones
Merge Requests
90
Merge Requests
90
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
vidjil
Commits
422df321
Commit
422df321
authored
Jan 22, 2019
by
flothoni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update fct to be call directly inside a sort call
link to
#2632
parent
6710ebc5
Pipeline
#59859
passed with stages
in 4 minutes and 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
40 deletions
+32
-40
browser/js/model_loader.js
browser/js/model_loader.js
+1
-1
browser/js/tools.js
browser/js/tools.js
+26
-30
browser/test/QUnit/testFiles/tools_test.js
browser/test/QUnit/testFiles/tools_test.js
+5
-9
No files found.
browser/js/model_loader.js
View file @
422df321
...
...
@@ -325,7 +325,7 @@ Model_loader.prototype = {
self
.
system_available
.
push
(
system
)
}
}
self
.
system_available
=
sort_list_locus
(
self
.
system_available
)
self
.
system_available
.
sort
(
locus_cmp
)
for
(
var
sa
in
self
.
system_available
){
system
=
this
.
system_available
[
sa
]
...
...
browser/js/tools.js
View file @
422df321
...
...
@@ -4,7 +4,7 @@ var INS="insertion";
var
DEL
=
"
deletion
"
;
var
END_CODON
=
"
end-codon
"
;
var
END_CODON_NOT_FIRST
=
"
end-codon-not-first
"
;
var
LOCUS_ORDER
=
[
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
,
"
TRA+D
"
,
"
TRD+
"
,
"
IGH
"
,
"
IGH+
"
,
"
IGK
"
,
"
IGK+
"
,
"
IGL
"
]
/**
* Get codons from two aligned sequences
* @pre both sequences are aligned together ref.length == seq.length
...
...
@@ -649,37 +649,33 @@ function pearsonCoeff(l1, l2) {
function
logadd1
(
x
)
{
return
Math
.
log
(
x
+
1
)
;
}
/**
* Sort list of available locus.
* The list is ordered on a preordered list of locus.
* Locus that are not in this list will be added a supplmeent of this one at the end of it.
* @param {Array} key_list List of system available in model, or a list of locus
* @return {Array} Ordered list of locus
* Compare two locus to sort them.
* The list is ordered on a preordered list of locus (LOCUS_ORDER).
* By this way, locus that are not in this list will be added at the end of it.
* @param {String} valA One locus value
* @param {String} valB Another locus value to compare
* @return {Number} A number -1 if A before B, else 1
*/
function
sort_list_locus
(
key_list
){
function
locus_cmp
(
valA
,
valB
){
// Ordered list of all generic locus
var
generic_locus_1
=
[
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
,
"
TRA+D
"
,
"
TRD+
"
,
"
IGH
"
,
"
IGH+
"
,
"
IGK
"
,
"
IGK+
"
,
"
IGL
"
]
var
generic_locus_2
=
[
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
,
"
TRA+D
"
,
"
TRD+
"
,
"
IGH
"
,
"
IGH+
"
,
"
IGK
"
,
"
IGK+
"
,
"
IGL
"
]
var
index
;
for
(
var
i
=
0
;
i
<
generic_locus_1
.
length
;
i
++
)
{
// If not present, deletion of result list
if
(
key_list
.
indexOf
(
generic_locus_1
[
i
])
==
-
1
)
{
index
=
generic_locus_2
.
indexOf
(
generic_locus_1
[
i
]);
generic_locus_2
.
splice
(
index
,
1
);
}
else
{
// else deletion of list given
index
=
key_list
.
indexOf
(
generic_locus_1
[
i
]);
key_list
.
splice
(
index
,
1
);
}
}
// key_list will only contain locus that are not in generic list of locus
// Sort keeped elements
key_list
.
sort
()
// Add these elements to result list
for
(
var
j
=
0
;
j
<
key_list
.
length
;
j
++
)
{
generic_locus_2
.
push
(
key_list
[
j
]
)
var
index_A
=
LOCUS_ORDER
.
indexOf
(
valA
)
var
index_B
=
LOCUS_ORDER
.
indexOf
(
valB
)
if
(
index_A
==
-
1
&&
index_B
==
-
1
){
// Neither A or B are present in LOCUS_ORDER
return
valA
.
localeCompare
(
valB
)
}
else
if
(
index_A
!=
-
1
&&
index_B
==
-
1
){
// Only A is present in LOCUS_ORDER
return
-
1
}
else
if
(
index_A
==
-
1
&&
index_B
!=
-
1
){
// Only B is present in LOCUS_ORDER
return
1
}
else
if
(
index_A
!=
-
1
&&
index_B
!=
-
1
){
// A & B are present in LOCUS_ORDER
return
index_A
-
index_B
}
return
generic_locus_2
return
0
}
browser/test/QUnit/testFiles/tools_test.js
View file @
422df321
...
...
@@ -397,19 +397,15 @@ QUnit.test("Pearson coefficient", function(assert) {
QUnit
.
test
(
"
Sort list locus
"
,
function
(
assert
)
{
liste_sort_1
=
[
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
,
"
TRA+D
"
,
"
TRD+
"
,
"
IGH
"
,
"
IGH+
"
,
"
IGK
"
,
"
IGK+
"
,
"
IGL
"
]
console
.
log
(
"
sort_list_locus
"
)
list_test_1
=
[
"
TRA
"
,
"
TRB
"
,
"
TRG
"
,
"
TRD
"
,
"
testlocus
"
,
"
IGH
"
,
"
IGK
"
,
"
IGL
"
]
wait_test_1
=
[
"
TRA
"
,
"
TRB
"
,
"
TRG
"
,
"
TRD
"
,
"
IGH
"
,
"
IGK
"
,
"
IGL
"
,
"
testlocus
"
]
list_test_2
=
[
"
IGH
"
,
"
IGH+
"
,
"
unknow_locus
"
,
"
IGK+
"
,
"
IGL
"
,
"
testlocus
"
,
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
]
wait_test_2
=
[
"
TRA
"
,
"
TRB
"
,
"
TRB+
"
,
"
TRG
"
,
"
TRD
"
,
"
IGH
"
,
"
IGH+
"
,
"
IGK+
"
,
"
IGL
"
,
"
testlocus
"
,
"
unknow_locus
"
]
list_test_1
.
sort
(
locus_cmp
)
list_test_2
.
sort
(
locus_cmp
)
// console.log( "result_1" )
// console.log( sort_list_locus(list_test_1))
// console.log( "result_2" )
// console.log( sort_list_locus(list_test_2))
assert
.
deepEqual
(
sort_list_locus
(
list_test_1
),
wait_test_1
,
"
list1 is correctly sorted
"
)
assert
.
deepEqual
(
sort_list_locus
(
list_test_2
),
wait_test_2
,
"
list2 is correctly sorted
"
)
assert
.
deepEqual
(
list_test_1
,
wait_test_1
,
"
list2 is correctly sorted
"
)
assert
.
deepEqual
(
list_test_2
,
wait_test_2
,
"
list2 is correctly sorted
"
)
}
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment