Skip to content

Commit

Permalink
Codon tree viewer fix for #2361 (#971)
Browse files Browse the repository at this point in the history
* Fix for CodonTree viewer. #2361
  • Loading branch information
JacobPorter authored May 26, 2020
1 parent 81a9f18 commit 8a23791
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 1 addition & 13 deletions public/js/p3/widget/WorkspaceBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,22 +583,10 @@ define([
});
}, self.path.split('/').length < 3);

this.browserHeader.addAction('ViewCodonTree', 'fa icon-tree2 fa-2x', {
label: 'VIEW',
multiple: false,
validTypes: ['CodonTree'],
tooltip: 'View Codon Tree'
}, function (selection) {
var sel = selection[0],
path = sel.path + '.' + sel.name + '/codontree_treeWithGenomeIds.nwk';

Topic.publish('/navigate', { href: '/view/PhylogeneticTree/?&labelSearch=true&idType=genome_id&labelType=genome_name&wsTreeFile=' + encodePath(path) });
}, false);

this.browserHeader.addAction('ViewTree', 'fa icon-tree2 fa-2x', {
label: 'VIEW',
multiple: false,
validTypes: ['PhylogeneticTree'],
validTypes: ['PhylogeneticTree', 'CodonTree'],
tooltip: 'View Tree'
}, function (selection) {
var expPath = this.get('path');
Expand Down
16 changes: 16 additions & 0 deletions public/js/p3/widget/viewer/PhylogeneticTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ define([
this.addChild(this.viewer);
this.inherited(arguments);
var dataFiles = [];
var nwkIds = null;
var nwkNames = null;
var folderCheck = this.state.search.match(/wsTreeFolder=..+?(?=&|$)/);
var fileCheck = this.state.search.match(/wsTreeFile=..+?(?=&|$)/);
var idType = this.state.search.match(/idType=..+?(?=&|$)/);
Expand Down Expand Up @@ -127,6 +129,10 @@ define([
Object.values(objs).forEach(function (obj) {
if (obj.type == 'json') {
dataFiles.push(obj.path);
} else if (obj.type == 'nwk' && obj.path.endsWith('treeWithGenomeIds.nwk')) {
nwkIds = obj.path;
} else if (obj.type == 'nwk' && obj.path.endsWith('treeWithGenomeNames.nwk')) {
nwkNames = obj.path;
}
});
if (dataFiles.length >= 1) {
Expand All @@ -139,6 +145,16 @@ define([
}
_self.prepareTree(treeDat, idType, labelType, labelSearch);
});
} else if (nwkIds || nwkNames) {
var objPath = nwkIds || nwkNames;
WorkspaceManager.getObjects([objPath]).then(lang.hitch(this, function (objs) {
var obj = objs[0];
var treeDat = {};
if (typeof obj.data == 'string') {
treeDat.tree = obj.data.replace(/[^(,)]+_@_/g, ''); // get rid of ridiculously annoying, super dirty embedded labels
_self.prepareTree(treeDat, idType, labelType, labelSearch);
}
}));
}
});
}
Expand Down

0 comments on commit 8a23791

Please sign in to comment.