Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion curator/static/js/study-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
});
});
Expand Down Expand Up @@ -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']) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -8986,6 +9007,7 @@ function getAmbiguousLabelsInTree(tree) {
labelData[ nodeID ] = node['@label'];
}
});

return labelData;
}
function showAmbiguousLabelsInTreeViewer(tree) {
Expand Down Expand Up @@ -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']);
Expand Down
31 changes: 27 additions & 4 deletions curator/views/study/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,20 @@ <h4 class="pull-left" style="margin: 5px 1em 0 0">Trees in this study</h4>
</div>
</div>

<!-- ko if: studyContainsScriptManagedTrees() -->
<div class="empty-list-prompt">
This study contains
<a target="_blank"
href="https://github.com/OpenTreeOfLife/script-managed-trees/blob/master/README.md">script-managed trees</a>
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.
</div>

<!-- /ko -->

<!-- ko if: ! studyContainsScriptManagedTrees() -->
<div class="empty-list-prompt" data-bind="visible: viewModel.filteredTrees().pagedItems().length === 0">
No matching trees found! Add new trees or clear the
filter above to see trees in this study.
Expand Down Expand Up @@ -525,6 +539,7 @@ <h4 class="pull-left" style="margin: 5px 1em 0 0">Trees in this study</h4>
</li>
</ul>
</div>
<!-- /ko -->

</div>

Expand Down Expand Up @@ -1612,11 +1627,17 @@ <h4 style="margin-top: 0;">Adding new taxa</h4>
<div class="tab-pane" id="Analyses">
<div class="span8"><!-- main column... -->

<!-- ko if: viewModel.elementTypes.tree.gatherAll(viewModel.nexml, {INCLUDE_SCRIPT_MANAGED_TREES: false}).length === 0 -->
<div class="empty-list-prompt">
<em>This study has no eligible trees.</em>
</div>
<!-- /ko -->
<!-- ko if: viewModel.elementTypes.tree.gatherAll(viewModel.nexml, {INCLUDE_SCRIPT_MANAGED_TREES: false}).length > 0 -->
<form class="form-inline">
<label>Analyze tree</label>
<select id="tree-select"
onchange="(this); return false;"
data-bind="options: viewModel.elementTypes.tree.gatherAll(viewModel.nexml),
data-bind="options: viewModel.elementTypes.tree.gatherAll(viewModel.nexml, {INCLUDE_SCRIPT_MANAGED_TREES: false}),
optionsValue: '@id',
optionsText: '@label',
optionsCaption: 'Choose a tree from this study...',
Expand All @@ -1632,9 +1653,11 @@ <h4 style="margin-top: 0;">Adding new taxa</h4>
<button class="btn btn-info" data-bind="click: fetchAndShowTreeConflictSummary">GO!</button>
</form>

<div id="analysis-results">
<em>Analysis results will appear here...</em>
</div>
<div id="analysis-results">
<em>Analysis results will appear here...</em>
</div>

<!-- /ko -->

</div><!-- end of main column... -->
<div class="span4"><!-- right col -->
Expand Down