diff --git a/src/components/phylogeny/PhylogenyView.vue b/src/components/phylogeny/PhylogenyView.vue index 0e121543..53f70059 100644 --- a/src/components/phylogeny/PhylogenyView.vue +++ b/src/components/phylogeny/PhylogenyView.vue @@ -101,13 +101,13 @@ + + +
+
+ Taxonomic units in this phylogeny +
+
+ To add additional taxonomic units to this list, please label the corresponding node on the phylogeny. +
+ + + + + + + + + + + +
@@ -156,30 +216,21 @@ import { has } from 'lodash'; import { mapState } from 'vuex'; import { parse as parseNewick } from 'newick-js'; +import {PhylogenyWrapper, TaxonomicUnitWrapper} from '@phyloref/phyx'; import ModifiedCard from '../cards/ModifiedCard.vue'; import Phylotree from './Phylotree.vue'; import Citation from '../citations/Citation.vue'; +import Specifier from "@/components/specifiers/Specifier.vue"; export default { name: 'PhylogenyView', - components: { ModifiedCard, Phylotree, Citation }, + components: {Specifier, ModifiedCard, Phylotree, Citation }, data() { return { // Errors in the phylogenyId field. phylogenyIdError: undefined, }; }, - methods: { - deleteThisPhylogeny() { - // Delete this phylogeny, and unset the selected phylogeny so we return to the summary page. - if(confirm('Are you sure you wish to delete this phylogeny? This cannot be undone!')) { - this.$store.commit('deletePhylogeny', { - phylogeny: this.selectedPhylogeny, - }); - this.$store.commit('changeDisplay', {}); - } - }, - }, computed: { /* * The following properties allow you to get or set the phylogeny label, @@ -246,11 +297,11 @@ export default { if (parenLevels !== 0) { errors.push({ - title: 'Unbalanced parentheses in Newick string', - message: (parenLevels > 0 - ? `You have ${parenLevels} too many open parentheses` - : `You have ${-parenLevels} too few open parentheses` - ), + title: "Unbalanced parentheses in Newick string", + message: + parenLevels > 0 + ? `You have ${parenLevels} too many open parentheses` + : `You have ${-parenLevels} too few open parentheses`, }); } @@ -266,11 +317,74 @@ export default { return errors; }, + terminalLabelsSorted() { + // Return a list of terminal (i.e. leaf node) labels sorted alphabetically. + return new PhylogenyWrapper(this.selectedPhylogeny).getNodeLabels('terminal').sort(); + }, + internalLabelsSorted() { + // Return a list of internal (i.e. non-leaf node) labels sorted alphabetically. + return new PhylogenyWrapper(this.selectedPhylogeny).getNodeLabels('internal').sort(); + }, + taxonomicUnitsTable() { + // Create a table of taxonomic units and their additional taxonomic units found in this phylogeny. + const terminalLabels = this.terminalLabelsSorted; + const internalLabels = this.internalLabelsSorted; + + return terminalLabels + .map((nodeLabel) => ({ + node_label: nodeLabel, + node_type: "Terminal node", + additional_taxonomic_units: + this.getExplicitTUnitsForLabel(nodeLabel).length, + _showDetails: this.getExplicitTUnitsForLabel(nodeLabel).length > 0, + })) + .concat( + internalLabels.map((nodeLabel) => ({ + node_label: nodeLabel, + node_type: "Internal node", + additional_taxonomic_units: + this.getExplicitTUnitsForLabel(nodeLabel).length, + _showDetails: this.getExplicitTUnitsForLabel(nodeLabel).length > 0, + })) + ); + }, ...mapState({ currentPhyx: state => state.phyx.currentPhyx, loadedPhyx: state => state.phyx.loadedPhyx, selectedPhylogeny: state => state.ui.display.phylogeny, }), }, + methods: { + deleteThisPhylogeny() { + // Delete this phylogeny, and unset the selected phylogeny so we return to the summary page. + if (confirm('Are you sure you wish to delete this phylogeny? This cannot be undone!')) { + this.$store.commit('deletePhylogeny', { + phylogeny: this.selectedPhylogeny, + }); + this.$store.commit('changeDisplay', {}); + } + }, + getExplicitTUnitsForLabel(nodeLabel) { + // Return the list of "explicit" taxonomic units for a phylogeny node, which is the list of + // taxonomic units listed in the additionalNodeProperties. + // + // This will not include "implicit" taxonomic units, which we generate from the node label. + return this.$store.getters.getExplicitTaxonomicUnitsForPhylogenyNode( + this.selectedPhylogeny, + nodeLabel + ); + }, + addTUnitForNodeLabel(nodeLabel) { + // Add a taxonomic unit to a node label. + this.$store.commit('addTaxonomicUnitToPhylogenyNode', { + phylogeny: this.selectedPhylogeny, + nodeLabel, + tunit: TaxonomicUnitWrapper.fromLabel( + "", + this.$store.getters.getDefaultNomenCodeURI + ), + }); + }, + }, }; diff --git a/src/components/specifiers/Specifier.vue b/src/components/specifiers/Specifier.vue index 15215e24..275daf07 100644 --- a/src/components/specifiers/Specifier.vue +++ b/src/components/specifiers/Specifier.vue @@ -97,8 +97,8 @@ Specifier details - -
+ +