Skip to content

Commit

Permalink
add groupSetOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Masselot committed Sep 17, 2014
1 parent d343cce commit 6440c7c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 9 deletions.
27 changes: 20 additions & 7 deletions src/js/views/SeqEntryAnnotInteractiveView.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,35 @@ define(
});

//it is possible to pass the category Order, thus sort on it at first
var categoryOrder;
if (self.options.categoryOrder !== undefined) {
categoryOrder = {};
_.each(self.options.categoryOrder, function (n, i) {
categoryOrder[n] = i + 1;
});
}
var buildOrder=function(orderName){
var order;
if (self.options[orderName] !== undefined) {
order = {};
_.each(self.options[orderName], function (n, i) {
order[n] = i + 1;
});
return order;
}
return undefined;
};
var categoryOrder = buildOrder('categoryOrder');
var groupSetOrder = buildOrder('groupSetOrder');


_.chain(groupedFeatures)
.sortBy(function (group) {
if (categoryOrder !== undefined) {
return 1000000 * (categoryOrder[group[0].category] || 100);
}

if(groupSetOrder){
return 1000000 * (groupSetOrder[group[0].groupSet] || 100);

}
if (!group[0].groupSet) {
return -99999;
}

return group[0].groupSet;
})
.each(function (group, groupConcatName) {
Expand Down
60 changes: 58 additions & 2 deletions test/suites/views/SeqEntryAnnotInteractiveView-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,62 @@ define(
});
describe('shorty with groupSet, noLayerMenu', function() {
var se = new SeqEntry({
id : 'shorty',
id : 'with-groupSet',
label : 'asuper short on',
sequence : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
})
se.set('features', [ {
category : 'full',
start : 0,
end : 25,
type : 'ttt'
}, {
category : 'Region',
start : 1,
end : 4,
type : 'ttt',
text : '2-5',
description:'one description'
}, {
category : 'Region',
start : 6,
end : 11,
type : 'xxx',
description:'another description'
},{category:'Amino acid modification', start:6, end:6, type:'xxx', text:'A', groupSet:'AAA (pouet)'},
{category:'Amino acid modification', start:11, end:11, type:'xxx', text:'A', groupSet:'AAA (pouet)'},
{category:'Amino acid modification', start:24, end:24, type:'xxx', text:'C', groupSet:'CCC'},
{category:'Amino acid modification', start:14, end:14, type:'xxx', text:'B', groupSet:'BBB'},
{category:'Amino acid modification', start:25, end:25, type:'xxx', text:'B', groupSet:'BBB'},
{category:'Amino acid modification', start:24, end:24, type:'xxx', text:'A', groupSet:'AAA (pouet)'},
{category:'Amino acid modification', start:21, end:25, type:'xxx', text:'A', groupSet:'AAA (pouet)'},
{category:'Amino acid modification', start:6, end:6, type:'xxx', text:'C', groupSet:'CCC'},
{category:'Amino acid modification', start:11, end:11, type:'xxx', text:'C', groupSet:'CCC'},
{category:'Amino acid modification', start:21, end:25, type:'xxx', text:'C1', groupSet:'CCC'},
{category:'catP', categoryName:'cat catP', start:11, end:11, type:'xxx', text:'C_P', groupSet:'CCC'},
{category:'catP', categoryName:'cat catP', start:6, end:6, type:'xxx', text:'A_P', groupSet:'AAA (pouet)'},
{category:'catP', categoryName:'cat catP', start:25, end:25, type:'xxx', text:'B_P', groupSet:'BBB'}
]);

var div = addDZDiv('annot-interactive', 'with-groupSet', 600, 'auto');
var view = new SeqEntryAnnotInteractiveView({
model : se,
el : div
//layerMenu : 'off'
})
view.render();

it('count ft displayed', function() {
// heihei, this a a D3 svg rendered test!!
expect(
view.svg.selectAll("g.feature.data.Region").selectAll(
"rect.feature").length).toBe(2);
})

})
describe('shorty with groupSet and groupSetOrder', function() {
var se = new SeqEntry({
id : 'with-groupSetOrder',
label : 'asuper short on',
sequence : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
})
Expand Down Expand Up @@ -233,10 +288,11 @@ define(
{category:'catP', categoryName:'cat catP', start:25, end:25, type:'xxx', text:'B_P', groupSet:'BBB'}
]);

var div = addDZDiv('annot-interactive', 'shorty', 600, 'auto');
var div = addDZDiv('annot-interactive', 'with-groupSetOrder', 600, 'auto');
var view = new SeqEntryAnnotInteractiveView({
model : se,
el : div,
groupSetOrder:['CCC', 'AAA (pouet)', 'BBB']
//layerMenu : 'off'
})
view.render();
Expand Down

0 comments on commit 6440c7c

Please sign in to comment.