imerss-bioinfo 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "imerss-bioinfo",
3
3
  "description": "Working data of the IMERSS biodiversity informatics working group, together with algorithms",
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "author": "Antranig Basman",
6
6
  "scripts": {
7
7
  "lint": "fluid-lint-all"
@@ -24,7 +24,7 @@ hortis.checklistItem = function (entry, selectedId) {
24
24
  const selectedClass = rank === "species" && record.id === selectedId ? " class=\"fl-checklist-selected\"" : "";
25
25
  const header = "<li " + selectedClass + ">";
26
26
  let name = "<p " + styleprop + rowid + " class=\"flc-checklist-rank-" +
27
- rank + "\">" + hortis.encodeHTML(record.iNaturalistTaxonName) + "</p>";
27
+ rank + "\">" + hortis.encodeHTML(record.taxonName || record.iNaturalistTaxonName) + "</p>";
28
28
  if (record.commonName) {
29
29
  name += " - <p " + styleprop + rowid + " class=\"flc-checklist-common-name\">" + record.commonName + "</p>";
30
30
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ // noinspection ES6ConvertVarToLetConst // otherwise this is a duplicate on minifying
3
4
  var hortis = fluid.registerNamespace("hortis");
4
5
 
5
6
  // Weird, non-general purpose intersect which modifies target by excluding source
@@ -12,14 +13,14 @@ hortis.intersect = function (target, source) {
12
13
  };
13
14
 
14
15
  hortis.combineDatasets = function (enabledList, quantiserDatasets) {
15
- var intersect;
16
- var union = {
16
+ let intersect;
17
+ const union = {
17
18
  obsCount: 0,
18
19
  buckets: {},
19
20
  byTaxonId: {}
20
21
  };
21
22
  enabledList.forEach(function (enabled) {
22
- var dataset = quantiserDatasets[enabled];
23
+ const dataset = quantiserDatasets[enabled];
23
24
  if (!intersect) {
24
25
  intersect = {
25
26
  buckets: fluid.extend({}, dataset.buckets),
@@ -41,7 +42,7 @@ hortis.combineDatasets = function (enabledList, quantiserDatasets) {
41
42
 
42
43
  hortis.renderDatasetControls = function (datasetEnabled, squareSide, datasets, quantiser, indexVersion) {
43
44
  console.log("renderDatasetControls executing for indexVersion " + indexVersion);
44
- var togo = [{
45
+ const togo = [{
45
46
  type: "hortis.datasetControlHeader"
46
47
  }];
47
48
 
@@ -53,9 +54,9 @@ hortis.renderDatasetControls = function (datasetEnabled, squareSide, datasets, q
53
54
  quantiserDataset: quantiser.datasets[datasetId]
54
55
  });
55
56
  });
56
- var enabledList = fluid.transforms.setMembershipToArray(datasetEnabled);
57
+ const enabledList = fluid.transforms.setMembershipToArray(datasetEnabled);
57
58
 
58
- var createFooter = function (prefix, dataset) {
59
+ const createFooter = function (prefix, dataset) {
59
60
  if (prefix) {
60
61
  hortis.quantiser.datasetToSummary(dataset, squareSide);
61
62
  dataset.obsCount = (prefix === "Union" ? dataset.obsCount : "");
@@ -68,7 +69,7 @@ hortis.renderDatasetControls = function (datasetEnabled, squareSide, datasets, q
68
69
  }, dataset));
69
70
  };
70
71
  if (enabledList.length > 1 && Object.keys(quantiser.datasets).length > 0) { // TODO: Ensure that relay pulls quantiser on startup!
71
- var combinedDatasets = hortis.combineDatasets(enabledList, quantiser.datasets);
72
+ const combinedDatasets = hortis.combineDatasets(enabledList, quantiser.datasets);
72
73
  createFooter("Intersection", combinedDatasets.intersect);
73
74
  createFooter("Union", combinedDatasets.union);
74
75
  } else {
@@ -193,7 +194,7 @@ hortis.datasetControl.columnNames = {
193
194
  };
194
195
 
195
196
  hortis.datasetControl.renderExtraColumns = function (markup, isHeader, dataset, quantiserDataset) {
196
- var extraColumns = fluid.transform(hortis.datasetControl.columnNames, function (columnInfo, key) {
197
+ const extraColumns = fluid.transform(hortis.datasetControl.columnNames, function (columnInfo, key) {
197
198
  return fluid.stringTemplate(markup, {
198
199
  columnClass: columnInfo.clazz,
199
200
  text: isHeader ? columnInfo.name : quantiserDataset[key]
@@ -204,8 +205,8 @@ hortis.datasetControl.renderExtraColumns = function (markup, isHeader, dataset,
204
205
 
205
206
  hortis.datasetControl.renderMarkup = function (markup, isHeader, dataset, quantiserDatasets, datasetId) {
206
207
  // Whilst we believe we have stuck this into the "source" model, it never actually arrives in the parent relay before rendering starts
207
- var quantiserDataset = quantiserDatasets && quantiserDatasets[datasetId];
208
- var extraColumns = hortis.datasetControl.renderExtraColumns(markup.cell, isHeader, dataset, quantiserDataset);
208
+ const quantiserDataset = quantiserDatasets && quantiserDatasets[datasetId];
209
+ const extraColumns = hortis.datasetControl.renderExtraColumns(markup.cell, isHeader, dataset, quantiserDataset);
209
210
  return fluid.stringTemplate(markup.container, {
210
211
  extraColumns: extraColumns
211
212
  });
@@ -695,7 +695,7 @@ hortis.renderTaxonDisplay = function (row, markup, options) {
695
695
  if (row.phyloPicUrl) {
696
696
  dumpPhyloPic("phyloPic", row.phyloPicUrl);
697
697
  }
698
- dumpRow(row.rank, row.iNaturalistTaxonName, "fl-taxonDisplay-rank");
698
+ dumpRow(row.rank, row.taxonName || row.iNaturalistTaxonName, "fl-taxonDisplay-rank");
699
699
  hortis.commonFields.forEach(function (field) {
700
700
  dumpRow(field, row[field]);
701
701
  });
@@ -709,9 +709,9 @@ hortis.renderTaxonDisplay = function (row, markup, options) {
709
709
  if (row.species) {
710
710
  // Used to read:
711
711
  // dumpRow("Species:", row.species + (row.authority ? (" " + row.authority) : ""), "fl-taxonDisplay-rank");
712
- // "species" now just holdes raw species name. In the long term we should support our own normalised species name
712
+ // "species" now just holds raw species name. In the long term we should support our own normalised species name
713
713
  // composed of taxon and infrataxon name but this is at least now complete and agrees with what is shown in the tooltip
714
- dumpRow("iNaturalistTaxonName", row.iNaturalistTaxonName + (row.authority ? (" " + row.authority) : ""), "fl-taxonDisplay-rank", options);
714
+ dumpRow("iNaturalistTaxonName", (row.taxonName || row.iNaturalistTaxonName) + (row.authority ? (" " + row.authority) : ""), "fl-taxonDisplay-rank", options);
715
715
  }
716
716
  if (row.hulqName) { // wot no polymorphism?
717
717
  togo += hortis.dumpHulqName(row, markup);
@@ -793,7 +793,7 @@ hortis.renderTooltip = function (row) {
793
793
  } else {
794
794
  terms.taxonRank = "Species";
795
795
  }
796
- const names = [row.iNaturalistTaxonName, row.commonName, row.hulqName].filter(name => name);
796
+ const names = [(row.taxonName || row.iNaturalistTaxonName), row.commonName, row.hulqName].filter(name => name);
797
797
  terms.taxonNames = names.join(" / ");
798
798
  return fluid.stringTemplate(hortis.tooltipTemplate, terms);
799
799
  };
@@ -62,7 +62,8 @@ fluid.defaults("hortis.leafletMap", {
62
62
  "buildMap.addTiles": "hortis.leafletMap.addTileLayer({that}.map, {that}.options.tileOptions)",
63
63
  "clearMapSelection.mapBlock": {
64
64
  changePath: "mapBlockTooltipId",
65
- value: null
65
+ value: null,
66
+ source: "{arguments}.0"
66
67
  }
67
68
  },
68
69
  invokers: {
@@ -31,9 +31,9 @@ fluid.defaults("hortis.leafletMap.withRegionsBase", {
31
31
  regions: "{sunburst}.viz.classes"
32
32
  },
33
33
  listeners: {
34
- "clearMapSelection.regions": "hortis.clearSelectedRegions({that})",
35
- // class, community
36
- "selectRegion.regionSelection": "hortis.leafletMap.regionSelection({that}, {arguments}.0, {arguments}.1)",
34
+ "clearMapSelection.regions": "hortis.clearSelectedRegions({that}, {arguments}.0)",
35
+ // class, community, source
36
+ "selectRegion.regionSelection": "hortis.leafletMap.regionSelection({that}, {arguments}.0, {arguments}.1, {arguments}.2)"
37
37
  }
38
38
  });
39
39
 
@@ -93,14 +93,15 @@ hortis.leafletMap.selectedRegions = function (selectedRegion, regions) {
93
93
  };
94
94
 
95
95
  // TODO: This gets preserved but we need to split off the outerPanel update
96
- hortis.leafletMap.regionSelection = function (map, className, community) {
97
- map.applier.change("mapBlockTooltipId", community);
98
- map.applier.change("selectedRegions", hortis.leafletMap.selectedRegions(className, map.classes));
99
- map.applier.change("selectedCommunities", hortis.leafletMap.selectedRegions(community, map.communities));
96
+ hortis.leafletMap.regionSelection = function (map, className, community, source) {
97
+ map.applier.change("mapBlockTooltipId", community, "ADD", source);
98
+ map.applier.change("selectedRegions", hortis.leafletMap.selectedRegions(className, map.classes), "ADD", source);
99
+ map.applier.change("selectedCommunities", hortis.leafletMap.selectedRegions(community, map.communities), "ADD", source);
100
100
 
101
101
  };
102
102
 
103
- hortis.clearSelectedRegions = function (map) {
104
- map.applier.change("selectedRegions", hortis.leafletMap.selectedRegions(null, map.classes));
105
- map.applier.change("selectedCommunities", hortis.leafletMap.selectedRegions(null, map.communities));
103
+ hortis.clearSelectedRegions = function (map, source) {
104
+ // mapBlockTooltipId is cleared in LeafletMap
105
+ map.applier.change("selectedRegions", hortis.leafletMap.selectedRegions(null, map.classes), "ADD", source);
106
+ map.applier.change("selectedCommunities", hortis.leafletMap.selectedRegions(null, map.communities), "ADD", source);
106
107
  };
package/src/descrolly.js CHANGED
@@ -11,6 +11,7 @@ require("./dataProcessing/readJSON.js");
11
11
  require("./dataProcessing/writeJSON.js");
12
12
  require("./dataProcessing/readCSV.js");
13
13
  require("./dataProcessing/readCSVWithMap.js");
14
+ require("./client/js/colour.js");
14
15
 
15
16
  require("./iNaturalist/taxonAPI.js");
16
17
 
@@ -48,8 +49,10 @@ hortis.descrolly = async function (config) {
48
49
  classes: {}
49
50
  };
50
51
 
51
- await hortis.asyncForEach(scrollyInput.MAP_LABEL, async function (label, index) {
52
- const taxaString = scrollyInput.taxa[index];
52
+ const scrollyInputTaxa = scrollyInput.taxa;
53
+
54
+ await hortis.asyncForEach(scrollyInputTaxa.MAP_LABEL, async function (label, index) {
55
+ const taxaString = scrollyInputTaxa.taxa[index];
53
56
  const taxa = taxaString.split(",").map(fluid.trim);
54
57
  console.log("Found " + taxa.length + " taxa for key " + label);
55
58
  const byTaxonId = {};
@@ -67,10 +70,13 @@ hortis.descrolly = async function (config) {
67
70
  } else {
68
71
  console.log("Failed to look up taxon " + san);
69
72
  }
70
- scrollyFeatures.classes[label] = {byTaxonId};
73
+ const fillColor = fluid.colour.hexToArray(scrollyInput.palette.col[index]);
74
+ scrollyFeatures.classes[label] = {byTaxonId, fillColor};
71
75
  });
72
76
  });
73
77
 
78
+
79
+
74
80
  hortis.writeJSONSync(fluid.module.resolvePath(config.scrollyFeatures), scrollyFeatures);
75
81
  };
76
82
 
package/src/marmalise.js CHANGED
@@ -281,7 +281,7 @@ hortis.indexScrollyRegions = function (treeBuilder) {
281
281
  const row = summaryById[key];
282
282
  byTaxonId[row.id] = true;
283
283
  });
284
- return {byTaxonId};
284
+ return {byTaxonId, fillColor: clazz.fillColor};
285
285
  });
286
286
  return {
287
287
  communities: newClasses,
package/src/taxonomise.js CHANGED
@@ -62,7 +62,8 @@ hortis.baseCommonOutMap = fluid.freezeRecursive({
62
62
  "columns": {
63
63
  "iNaturalistTaxonName": "iNaturalist taxon name",
64
64
  "iNaturalistTaxonId": "iNaturalist taxon ID",
65
- "taxonName": "Taxon name"
65
+ "taxonName": "Taxon name",
66
+ "authority": "Author" // TODO: Make this conditional on whether it is present in input?
66
67
  }
67
68
  });
68
69