Commit a29ed380 authored by Mathieu Giraud's avatar Mathieu Giraud

js: move filter functions from `list.js` to `model.js`

See #2228 and #2201.
parent f68b3f9d
......@@ -718,82 +718,7 @@ List.prototype = {
}
}
},
/**
* apply a boolean isFiltered too all Clones<br>
* filtered clone will be hidden in all views
* @param {boolean} bool - isFiltered value given to all clones
* */
reset_filter: function (bool) {
for (var i=0; i<this.m.clones.length; i++){
var c = this.m.clone(i)
c.isFiltered=bool
}
},
/**
* apply a filter to all clones <br>
* a clone need to contain a given string to pass the filter (search through name/nt sequence/sequenceName) (case insensitive)<br>
* filtered clone will be hidden in all views
* @param {string} str - required string to pass the filter
* */
filter: function (str) {
this.reset_filter(true)
for (var i=0; i<this.m.clones.length; i++){
var c = this.m.clone(i)
if (c.getName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSegAASequence('cdr3').toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getRevCompSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSequenceName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
}
this.m.update()
},
//filter with d error
/*filter: function(str){
this.reset_filter(true)
for (var i=0; i<this.m.clones.length; i++){
var c = this.m.clone(i)
if (distanceLevenshtein(c.getName().toUpperCase(), str.toUpperCase()) <= d)
c.isFiltered = false
if (distanceLevenshtein(c.getSequence().toUpperCase(), str.toUpperCase() <= d)
c.isFiltered = false
if (distanceLevenshtein(c.getRevCompSequence().toUpperCase(), str.toUpperCase()) <= d )
c.isFiltered = false
if (distanceLevenshtein(c.getSequenceName().toUpperCase(), str.toUpperCase()) <= d )
c.isFiltered = false
}
this.m.update()
},
*/
/**
* filter, keep only currently selected clones <br>
* */
focus: function () {
// this.reset_filter(true)
for (var i=0; i<this.m.clones.length; i++){
var c = this.m.clone(i)
c.isFiltered = !c.isSelected()
}
$("#filter_input").val("(focus on some clones)")
this.m.update()
},
/**
* hide selected clones
* */
hide: function () {
var list = this.m.getSelected();
for (var i=0; i < list.length; i++) {
this.m.clone(list[i]).isFiltered = true
}
$("#filter_input").val("(focus on some clones)")
this.m.update()
},
/**
* sort clone list by size (reorder html elements in the clone list/ no rebuild)
......
......@@ -2133,18 +2133,88 @@ changeCloneNotation: function(cloneNotationType) {
/* --------------------- */
/* Filters / .isFiltered */
/**
* apply a boolean isFiltered too all Clones<br>
* filtered clone will be hidden in all views
* @param {boolean} bool - isFiltered value given to all clones
* */
reset_filter: function (bool) {
for (var i=0; i<this.clones.length; i++){
var c = this.clone(i)
c.isFiltered=bool
}
},
/**
* apply a filter to all clones <br>
* a clone need to contain a given string to pass the filter (search through name/nt sequence/sequenceName) (case insensitive)<br>
* filtered clone will be hidden in all views
* @param {string} str - required string to pass the filter
* */
filter: function (str) {
this.reset_filter(true)
for (var i=0; i<this.clones.length; i++){
var c = this.clone(i)
if (c.getName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSegAASequence('cdr3').toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getRevCompSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSequenceName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
}
this.update()
},
//filter with d error
/*filter: function(str){
this.reset_filter(true)
for (var i=0; i<this.clones.length; i++){
var c = this.clone(i)
if (distanceLevenshtein(c.getName().toUpperCase(), str.toUpperCase()) <= d)
c.isFiltered = false
if (distanceLevenshtein(c.getSequence().toUpperCase(), str.toUpperCase() <= d)
c.isFiltered = false
if (distanceLevenshtein(c.getRevCompSequence().toUpperCase(), str.toUpperCase()) <= d )
c.isFiltered = false
if (distanceLevenshtein(c.getSequenceName().toUpperCase(), str.toUpperCase()) <= d )
c.isFiltered = false
}
this.update()
},
*/
/**
* filter, keep only currently selected clones
* */
focusSelected: function () {
// this.reset_filter(true)
for (var i=0; i<this.clones.length; i++){
var c = this.clone(i)
c.isFiltered = !c.isSelected()
}
$("#filter_input").val("(focus on some clones)")
this.update()
},
/**
* hide selected clones
* */
hideSelected: function () {
var list = this.getSelected();
for (var i=0; i < list.length; i++) {
this.clone(list[i]).isFiltered = true
}
$("#filter_input").val("(focus on some clones)")
this.update()
},
/* --------------------- */
/*For DBSCAN*/
......
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