diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index 773cb8189..c29cf5794 100644 --- a/curator/static/js/study-editor.js +++ b/curator/static/js/study-editor.js @@ -752,12 +752,16 @@ function loadSelectedStudy() { }, 'tree': { highestOrdinalNumber: null, - gatherAll: function(nexml) { + gatherAll: function(nexml, options) { // return an array of all matching elements + if (!options) options = {INCLUDE_SCRIPT_MANAGED_TREES: true}; var allTrees = []; var allTreesCollections = viewModel.elementTypes.trees.gatherAll(nexml); $.each(allTreesCollections, function(i, treesCollection) { $.each(treesCollection.tree, function(i, tree) { + if (!options.INCLUDE_SCRIPT_MANAGED_TREES) { + if (isScriptManagedTree(tree)) return true; + } allTrees.push( tree ); }); }); @@ -1167,6 +1171,10 @@ function loadSelectedStudy() { if ($.isArray(chosenTrees)) { // it's a list of zero or more trees $.each( chosenTrees, function(i, tree) { + if (isScriptManagedTree(tree)) { + // ignore "empty" (script-managed) trees + return; + } // check this tree's nodes for this OTU id $.each( tree.node, function( i, node ) { if (node['@otu']) { @@ -3033,6 +3041,10 @@ function getRootedStatusForTree( tree ) { // Let's check for some/all/none with separate functions. function anyBranchLengthsFoundInTree( tree ) { var foundBranchWithLength = false; + if (isScriptManagedTree(tree)) { + // ignore "empty" (script-managed) trees + return false; + } $.each(tree.edge, function(i, edge) { if ('@length' in edge) { foundBranchWithLength = true; @@ -3043,6 +3055,10 @@ function anyBranchLengthsFoundInTree( tree ) { } function allBranchLengthsFoundInTree( tree ) { var foundBranchWithoutLength = false; + if (isScriptManagedTree(tree)) { + // ignore "empty" (script-managed) trees + return false; + } $.each(tree.edge, function(i, edge) { if (!('@length' in edge)) { foundBranchWithoutLength = true; @@ -8974,6 +8990,11 @@ function getAmbiguousLabelsInTree(tree) { return labelData; } + if (isScriptManagedTree(tree)) { + // ignore "empty" (script-managed) trees + return labelData; + } + $.each( tree.node, function(i, node) { if (node['^ot:isLeaf'] === true) { /* We sometimes save a misspelled taxon name as `node[@label]` so @@ -8986,6 +9007,7 @@ function getAmbiguousLabelsInTree(tree) { labelData[ nodeID ] = node['@label']; } }); + return labelData; } function showAmbiguousLabelsInTreeViewer(tree) { @@ -9139,6 +9161,20 @@ function currentStudyVersionContributedToLatestSynthesis() { return (viewModel.startingCommitSHA === latestSynthesisSHA); } +function studyContainsScriptManagedTrees() { + // check for signature for this in Nexson (to modify UI, hide/block some features?) + var allTrees = viewModel.elementTypes.tree.gatherAll(viewModel.nexml); + var bigTrees = ko.utils.arrayFilter( + allTrees, + isScriptManagedTree + ); + return (bigTrees.length > 0); +} +function isScriptManagedTree(tree) { + // if this property is found (even if it's an empty object), assume it's a huge script-managed tree + return (tree["^ot:external_data"] !== undefined); +} + function getNormalizedStudyPublicationURL() { // just the bare URL, or '' if not found var url = $.trim(viewModel.nexml['^ot:studyPublication']['@href']); diff --git a/curator/views/study/edit.html b/curator/views/study/edit.html index 3eae4a72c..2410d7ca0 100644 --- a/curator/views/study/edit.html +++ b/curator/views/study/edit.html @@ -374,6 +374,20 @@