From 7730fa26827aee754fe29fb3833cd2b859a7ea23 Mon Sep 17 00:00:00 2001 From: Jim Allman Date: Thu, 24 Sep 2020 01:20:59 -0400 Subject: [PATCH 1/7] Test for script-managed trees, show warning msg --- curator/static/js/study-editor.js | 13 +++++++++++++ curator/views/study/edit.html | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index 773cb8189..0a3ea270d 100644 --- a/curator/static/js/study-editor.js +++ b/curator/static/js/study-editor.js @@ -9139,6 +9139,19 @@ 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, + function (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); + } + ); + return (bigTrees.length > 0); +} + 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..8b26e9388 100644 --- a/curator/views/study/edit.html +++ b/curator/views/study/edit.html @@ -374,6 +374,20 @@

Trees in this study

+ +
+ This study contains + script-managed trees + that are too large to store in phylesystem. + These cannot be managed in the curation web app, nor can + this study's OTUs, but you can edit the study's metadata + and see its revision history. +
+ + + +
No matching trees found! Add new trees or clear the filter above to see trees in this study. @@ -525,6 +539,7 @@

Trees in this study

+ From 34cd2beb152655b36316115c78c08d3a5f73b2aa Mon Sep 17 00:00:00 2001 From: Jim Allman Date: Sun, 4 Oct 2020 12:38:11 -0400 Subject: [PATCH 2/7] Ignore missing `node` list in script-managed trees. --- curator/static/js/study-editor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index 0a3ea270d..18c392b5c 100644 --- a/curator/static/js/study-editor.js +++ b/curator/static/js/study-editor.js @@ -1167,6 +1167,10 @@ function loadSelectedStudy() { if ($.isArray(chosenTrees)) { // it's a list of zero or more trees $.each( chosenTrees, function(i, tree) { + if (! $.isArray(tree.node)) { + // ignore "empty" (script-managed) trees + return; + } // check this tree's nodes for this OTU id $.each( tree.node, function( i, node ) { if (node['@otu']) { From 7700bdb9b1ac6502466f8ea3e4995a335a22f6e0 Mon Sep 17 00:00:00 2001 From: Jim Allman Date: Sun, 4 Oct 2020 12:51:51 -0400 Subject: [PATCH 3/7] Shared test for script-managed trees. --- curator/static/js/study-editor.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index 18c392b5c..f86f61877 100644 --- a/curator/static/js/study-editor.js +++ b/curator/static/js/study-editor.js @@ -1167,7 +1167,7 @@ function loadSelectedStudy() { if ($.isArray(chosenTrees)) { // it's a list of zero or more trees $.each( chosenTrees, function(i, tree) { - if (! $.isArray(tree.node)) { + if (isScriptManagedTree(tree)) { // ignore "empty" (script-managed) trees return; } @@ -8978,6 +8978,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 @@ -8990,6 +8995,7 @@ function getAmbiguousLabelsInTree(tree) { labelData[ nodeID ] = node['@label']; } }); + return labelData; } function showAmbiguousLabelsInTreeViewer(tree) { @@ -9148,13 +9154,14 @@ function studyContainsScriptManagedTrees() { var allTrees = viewModel.elementTypes.tree.gatherAll(viewModel.nexml); var bigTrees = ko.utils.arrayFilter( allTrees, - function (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); - } + 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 From 7a486f22a97be5684aa834986c2e57d3fb42f2ff Mon Sep 17 00:00:00 2001 From: Jim Allman Date: Sun, 4 Oct 2020 12:54:57 -0400 Subject: [PATCH 4/7] More tools to skip script-managed trees --- curator/static/js/study-editor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index f86f61877..c9fa65843 100644 --- a/curator/static/js/study-editor.js +++ b/curator/static/js/study-editor.js @@ -3037,6 +3037,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; @@ -3047,6 +3051,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; From caeabc99128a28b13fd3b51a7f0fdf7cf73fba72 Mon Sep 17 00:00:00 2001 From: Jim Allman Date: Wed, 7 Oct 2020 15:16:54 -0400 Subject: [PATCH 5/7] Block analysis tools if there are no eligible trees. The immediate use case is to handle script-managed trees with no mapped OTUs stored in Nexson. --- curator/static/js/study-editor.js | 6 +++++- curator/views/study/edit.html | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/curator/static/js/study-editor.js b/curator/static/js/study-editor.js index c9fa65843..1eb4dcf34 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 ); }); }); diff --git a/curator/views/study/edit.html b/curator/views/study/edit.html index 8b26e9388..77cbd81af 100644 --- a/curator/views/study/edit.html +++ b/curator/views/study/edit.html @@ -1627,11 +1627,17 @@

Adding new taxa

+ +
+ This study has no eligible trees. +
+ +