imerss-bioinfo 1.0.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.
Files changed (182) hide show
  1. package/README.md +156 -0
  2. package/build.js +196 -0
  3. package/docs/css/imerss-viz-all.css +1227 -0
  4. package/docs/css/imerss-viz-wp-overrides.css +70 -0
  5. package/docs/css/pepiowelh.css +76 -0
  6. package/docs/css/xetthecum-external.css +47 -0
  7. package/docs/css/xetthecum-shared.css +80 -0
  8. package/docs/css/xetthecum.css +526 -0
  9. package/docs/js/imerss-viz-all.js +58 -0
  10. package/docs/js/imerss-viz-all.js.map +1 -0
  11. package/docs/js/jquery.js +10881 -0
  12. package/index.html +81 -0
  13. package/index.js +7 -0
  14. package/indexWithJustMap.html +92 -0
  15. package/indexWithMap.html +79 -0
  16. package/indexWithMapHoweSound.html +91 -0
  17. package/indexWithMapPepiowelh.html +119 -0
  18. package/indexWithMapValdes.html +90 -0
  19. package/indexWithMapXetthecum.html +90 -0
  20. package/package.json +50 -0
  21. package/src/WoRMS/taxonAPI.js +13 -0
  22. package/src/arphify.js +662 -0
  23. package/src/assignNames.js +103 -0
  24. package/src/auxBuild/restoreJQuery.js +1 -0
  25. package/src/buildSource/Comprehensive Lists.html +42 -0
  26. package/src/buildSource/Data Paper Part I Visualisation.html +50 -0
  27. package/src/buildSource/Galiano Life List.html +43 -0
  28. package/src/buildSource/Metchosin/index.html +22 -0
  29. package/src/buildSource/Pe'pi'ow'elh.html +72 -0
  30. package/src/buildSource/Squamish Life List.html +48 -0
  31. package/src/buildSource/Valdes Island Biodiversity.html +64 -0
  32. package/src/buildSource/Xetthecum.html +40 -0
  33. package/src/buildSource/dataPaperSunburstAndMap.html +30 -0
  34. package/src/buildSource/index.html +224 -0
  35. package/src/client/css/imerss-viz-wp-overrides.css +70 -0
  36. package/src/client/css/imerss-viz.css +531 -0
  37. package/src/client/css/pepiowelh.css +76 -0
  38. package/src/client/css/xetthecum-external.css +47 -0
  39. package/src/client/css/xetthecum-shared.css +80 -0
  40. package/src/client/css/xetthecum.css +526 -0
  41. package/src/client/html/imerss-viz-map-only.html +75 -0
  42. package/src/client/html/imerss-viz-map-pepi.html +77 -0
  43. package/src/client/html/imerss-viz-map-xetthecum.html +90 -0
  44. package/src/client/html/imerss-viz-map.html +75 -0
  45. package/src/client/html/imerss-viz.html +58 -0
  46. package/src/client/html/importing Xetthecum patterns.txt +10 -0
  47. package/src/client/html/xetthecum-patterns.html +27 -0
  48. package/src/client/img/Animalia_2.svg +1 -0
  49. package/src/client/img/Animalia_Annelida.svg +655 -0
  50. package/src/client/img/Animalia_Chaetognatha.svg +72 -0
  51. package/src/client/img/Animalia_Cnidaria.svg +173 -0
  52. package/src/client/img/Animalia_Ctenophora.svg +298 -0
  53. package/src/client/img/Animalia_Nemertea.svg +54 -0
  54. package/src/client/img/Animalia_Phoronida.svg +271 -0
  55. package/src/client/img/Animalia_Platyhelminthes.svg +58 -0
  56. package/src/client/img/Animalia_Porifera.svg +220 -0
  57. package/src/client/img/Animalia_Sipuncula.svg +155 -0
  58. package/src/client/img/Arachnoidiscus_schmidtii_web_1-2-scaled.webp +0 -0
  59. package/src/client/img/Arrow-down.svg +11 -0
  60. package/src/client/img/Arrow-up.svg +6 -0
  61. package/src/client/img/Chromista.svg +1 -0
  62. package/src/client/img/Pepiowelh/BlackNoWe2-wb-bb.png +0 -0
  63. package/src/client/img/Pepiowelh/BlackNoWe2-wb.png +0 -0
  64. package/src/client/img/Pepiowelh/BlackNoWe2.png +0 -0
  65. package/src/client/img/Pepiowelh/Ecocultural Mapping Banner.svg +1 -0
  66. package/src/client/img/Plankton.jpg +0 -0
  67. package/src/client/img/Plantae.svg +1 -0
  68. package/src/client/img/Plantae_2.svg +1 -0
  69. package/src/client/img/Protista.svg +1 -0
  70. package/src/client/img/Valdes/Valdes Island Conservancy.jpg +0 -0
  71. package/src/client/img/Xetthecum/Agricultural.jpg +0 -0
  72. package/src/client/img/Xetthecum/Anthropogenic_banner.jpg +0 -0
  73. package/src/client/img/Xetthecum/Broad_Leaf.jpg +0 -0
  74. package/src/client/img/Xetthecum/Caves.jpg +0 -0
  75. package/src/client/img/Xetthecum/Coastal_Bluffs.jpg +0 -0
  76. package/src/client/img/Xetthecum/Conifer_Pole_Sapling.jpg +0 -0
  77. package/src/client/img/Xetthecum/Developed.jpg +0 -0
  78. package/src/client/img/Xetthecum/Dock.jpg +0 -0
  79. package/src/client/img/Xetthecum/Eelgrass.jpg +0 -0
  80. package/src/client/img/Xetthecum/Forests_banner.jpg +0 -0
  81. package/src/client/img/Xetthecum/Freshwater_banner.jpg +0 -0
  82. package/src/client/img/Xetthecum/Greig_Creek.jpg +0 -0
  83. package/src/client/img/Xetthecum/Intertidal.jpg +0 -0
  84. package/src/client/img/Xetthecum/Laughlin_Lake.jpg +0 -0
  85. package/src/client/img/Xetthecum/Marine_banner.jpg +0 -0
  86. package/src/client/img/Xetthecum/Mature_Conifer_Forest.jpg +0 -0
  87. package/src/client/img/Xetthecum/Porlier_Pass_Road.jpg +0 -0
  88. package/src/client/img/Xetthecum/Riparian.jpg +0 -0
  89. package/src/client/img/Xetthecum/Rural.jpg +0 -0
  90. package/src/client/img/Xetthecum/Subtidal.jpg +0 -0
  91. package/src/client/img/Xetthecum/Wetland.jpg +0 -0
  92. package/src/client/img/Xetthecum/Woodland.jpg +0 -0
  93. package/src/client/img/Xetthecum/Woodland_banner.jpg +0 -0
  94. package/src/client/img/Xetthecum/Xetthecum.jpg +0 -0
  95. package/src/client/img/Xetthecum/Young_Conifer_Forest.jpg +0 -0
  96. package/src/client/img/Xetthecum/Young_Mixed_Forest.jpg +0 -0
  97. package/src/client/img/Xetthecum/food.svg +38 -0
  98. package/src/client/img/Xetthecum/indicator.svg +52 -0
  99. package/src/client/img/Xetthecum/material.svg +186 -0
  100. package/src/client/img/Xetthecum/medicinal.svg +62 -0
  101. package/src/client/img/Xetthecum/missing-value.svg +3 -0
  102. package/src/client/img/Xetthecum/spiritual.svg +13 -0
  103. package/src/client/img/Xetthecum/trade.svg +74 -0
  104. package/src/client/img/audio.svg +5 -0
  105. package/src/client/img/external-link.svg +3 -0
  106. package/src/client/img/selected-eye.svg +4 -0
  107. package/src/client/img/selected-tick.svg +3 -0
  108. package/src/client/img/thumbs/BCLeps.jpg +0 -0
  109. package/src/client/img/thumbs/Checklist.jpg +0 -0
  110. package/src/client/img/thumbs/Data-Paper-Figma.jpg +0 -0
  111. package/src/client/img/thumbs/Galiano-Data-Paper.jpg +0 -0
  112. package/src/client/img/thumbs/Galiano.jpg +0 -0
  113. package/src/client/img/thumbs/Maxwell.jpg +0 -0
  114. package/src/client/img/thumbs/Squamish.jpg +0 -0
  115. package/src/client/img/thumbs/Valdes.jpg +0 -0
  116. package/src/client/img/thumbs/Xetthecum.jpg +0 -0
  117. package/src/client/img/up-arrow.svg +4 -0
  118. package/src/client/js/autocomplete.js +53 -0
  119. package/src/client/js/checklist.js +179 -0
  120. package/src/client/js/colour.js +139 -0
  121. package/src/client/js/datasetControls.js +212 -0
  122. package/src/client/js/imerss-viz.js +1397 -0
  123. package/src/client/js/leafletMap.js +357 -0
  124. package/src/client/js/leafletMapWithGrid.js +337 -0
  125. package/src/client/js/leafletMapWithRegions.js +381 -0
  126. package/src/client/js/renderSVG.js +108 -0
  127. package/src/client/js/tabs.js +53 -0
  128. package/src/client/js/xetthecum.js +106 -0
  129. package/src/client/json/emptyPhyloMap.json +1 -0
  130. package/src/client/json/kingdomPhyloMap.json +17 -0
  131. package/src/client/json/phyloMap.json +58 -0
  132. package/src/compare.js +97 -0
  133. package/src/compilecsv.js +47 -0
  134. package/src/dataProcessing/LZ4.js +27 -0
  135. package/src/dataProcessing/coordinatePatch.js +151 -0
  136. package/src/dataProcessing/readCSV.js +107 -0
  137. package/src/dataProcessing/readCSVwithMap.js +90 -0
  138. package/src/dataProcessing/readCSVwithoutMap.js +25 -0
  139. package/src/dataProcessing/readJSON.js +23 -0
  140. package/src/dataProcessing/sqlite.js +174 -0
  141. package/src/dataProcessing/summarise.js +122 -0
  142. package/src/dataProcessing/taxonScrape.js +14 -0
  143. package/src/dataProcessing/worker.js +31 -0
  144. package/src/dataProcessing/writeCSV.js +34 -0
  145. package/src/dataProcessing/writeJSON.js +15 -0
  146. package/src/dbtaxa.js +96 -0
  147. package/src/deAuthorise.js +48 -0
  148. package/src/deqgis.js +148 -0
  149. package/src/expressions/expr.js +65 -0
  150. package/src/expressions/jsep.js +925 -0
  151. package/src/filterFirst.js +51 -0
  152. package/src/geom/geoJSON.js +121 -0
  153. package/src/iNaturalist/examples/api.inaturalist.org-v1-taxa!q=Acmispon americanus americanus.json +200 -0
  154. package/src/iNaturalist/examples/api.inaturalist.org-v1-taxa!q=Flabellina japonica.json +61 -0
  155. package/src/iNaturalist/examples/www.inaturalist.org-taxa-877359.json +132 -0
  156. package/src/iNaturalist/iNatUrls.js +17 -0
  157. package/src/iNaturalist/obsAPI.js +150 -0
  158. package/src/iNaturalist/taxonAPI.js +460 -0
  159. package/src/inatObs.js +120 -0
  160. package/src/inattify.js +123 -0
  161. package/src/intersect.js +80 -0
  162. package/src/intersectFilter.js +48 -0
  163. package/src/landlocked.js +137 -0
  164. package/src/lib/jquery.binarytransport.js +51 -0
  165. package/src/lib/lz4-commentary.txt +9 -0
  166. package/src/lib/lz4.js +73 -0
  167. package/src/lib/point-in-polygon.js +36 -0
  168. package/src/lz4.js +40 -0
  169. package/src/marmalise.js +333 -0
  170. package/src/materialise.js +68 -0
  171. package/src/reintegrate.js +71 -0
  172. package/src/taxonomise.js +615 -0
  173. package/src/unscrewGBIF.js +44 -0
  174. package/src/utils/dataSource.js +173 -0
  175. package/src/utils/settleStructure.js +62 -0
  176. package/src/utils/utils.js +92 -0
  177. package/src/viz/plethify.js +39 -0
  178. package/src/wormify.js +154 -0
  179. package/src/xetthecum/xetthecumFilters.js +126 -0
  180. package/test/testDataSource.js +182 -0
  181. package/test/testiNatObsSource.js +38 -0
  182. package/test/testiNatSource.js +50 -0
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # IMERSS Bioinformatics Working Group Data Archive, Pipelines and Visualisations
2
+
3
+ This repository houses the working data of the [IMERSS](https://imerss.org/) [biodiversity informatics working group](https://imerss.org/2019/01/01/biodiversity-informatics-working-group/)
4
+ together with algorithms for transforming, reconciling and projecting observation and checklist data into formats
5
+ suitable for publication, submission to global authorities such as [GBIF](https://www.gbif.org/), as well as
6
+ map-based and graphical visualisations.
7
+
8
+ # Mini-portal
9
+
10
+ A [mini-portal](https://imerss.github.io/imerss-bioinfo/) presenting a showcase of the latest versions of all of
11
+ IMERSS' user-facing visualisations is available in [GitHub Pages](https://imerss.github.io/imerss-bioinfo/).
12
+
13
+ # Data Archive
14
+
15
+ All data is stored in CSV files in subdirectories under [data](data) although some unprocessed checklist data is a
16
+ variety of formats such as XLSX and PDF.
17
+
18
+ Authoritative data resulting from the full reconciliation of upstream catalogues and curated summaries for the Galiano
19
+ Data Paper part 1: Marine Zoology is held in [data/dataPaper-I](data/dataPaper-I) and [data/dataPaper-I-in](data/dataPaper-I-in).
20
+ In particular, the reconciled and normalised observation data is at [data/dataPaper-I/reintegrated-obs.csv](data/dataPaper-I/reintegrated-obs.csv),
21
+ reconciled checklists derived from this data is at [/data/dataPaper-I/reintegrated.csv](/data/dataPaper-I/reintegrated.csv).
22
+ The corresponding checklists derived from the curated summaries is at [/data/dataPaper-I-in/reintegrated.csv](/data/dataPaper-I-in/reintegrated.csv).
23
+
24
+ Full intructions for running the data paper part I pipeline are held in
25
+ [Galiano Data Paper Vol I.md](Galiano%20Data%20Paper%20Vol%20I.md), but here follows an overview of the scripts and overall
26
+ installation instructions.
27
+
28
+ # Data Pipeline
29
+
30
+ The full data pipeline for deriving the observation data and its checklists from the upstream raw catalogues for
31
+ the data paper is held at [/data/dataPaper-I/fusion.json5](/data/dataPaper-I/fusion.json5). This is stored in
32
+ the [JSON5](https://json5.org/) format.
33
+ This file refers to the most up-to-date versions of the constituent catalogues in their various other subdirectories
34
+ under [/data](/data). Many of these subdirectories contain their own "fusion" files for producing other summaries
35
+ and visualisations as seen in the [mini-portal](https://imerss.github.io/imerss-bioinfo/).
36
+
37
+ All of the code operating the data pipelines is written in JavaScript running either in [node.js](http://nodejs.org) or
38
+ the browser.
39
+ After [installing git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) to check out this repository via
40
+
41
+ git clone IMERSS/imerss-biodata
42
+
43
+ , and then installing node.js from its [download](https://nodejs.org/en/download/), you can install the pipeline's
44
+ dependencies by running
45
+
46
+ npm install
47
+
48
+ in the checkout directory.
49
+
50
+ The scripts in [src](src) will then be ready to run via various `node` commands. These scripts are currently of a
51
+ basic quality and not easily usable without being in close contact with members of the IMERSS BIWG team. Please join us
52
+ in our [Matrix](https://matrix.org/) channels [IMERSS general](https://matrix.to/#/#imerss-general:matrix.org) and
53
+ [IMERSS tech](https://matrix.to/#/#imerss-tech:matrix.org).
54
+
55
+ More detailed documentation for these scripts will be forthcoming, but the principal ones involved in the data paper
56
+ pipeline are:
57
+
58
+ taxonomise.js [obs or summary CSV file] [--map map JSON file] [-o output file]
59
+
60
+ Main point of ingesting a collection of catalogues or summary in some CSV form. Accepts a "fusion" JSON5 file laying out
61
+ all of the constituent catalogues files as CSV together with accompanying "map" files mapping columns for ingestion and
62
+ rendering. Produces one or two `reintegrated` files combining the catalogues. This operates several stages of
63
+ normalisation, including normalising species names with respect to the internal ontology mapping file
64
+ [taxon-swaps.json5](data/taxon-swaps.json5), filtering out unwanted taxa, georeferencing correction patches,
65
+ and filtering with respect to a project boundary defined in GeoJSON. Details of all the capabilities of this
66
+ "Swiss Army knife" data processor can be followed in the data paper fusion file [data/dataPaper-I/fusion.json5](data/dataPaper-I/fusion.json5).
67
+
68
+ inatObs.js
69
+
70
+ Downloads all observations in an iNaturalist project, whilst remaining within the iNaturalist team's recommended request
71
+ rate limit (one per second). Currently hardwired to download Animalia from the Galiano project. Produces a CSV file suitable
72
+ to form part of the input to `taxonomise.js`.
73
+
74
+ materialise.js
75
+
76
+ From the curated summaries end, downloads a collection of summaries mapping in a Google Sheets directory. Currently hardwired
77
+ to download the "Animalia" at [Galiano Data Paper 2021/Marine Life/Animalia](https://drive.google.com/drive/folders/14gItR0p_4wYo4K1__tyPYeIuc2yLr6l_)
78
+ in the author's drive mapping.
79
+
80
+ compile.js
81
+
82
+ Given the folder of files output by `materialise.js`, combines them together - currently hardwired to produce a file `Animalia.csv`.
83
+
84
+ compare.js
85
+
86
+ Given the results of two `taxonomise.js` outputs as `reintegrated.csv` file checklists, compares them for any discrepancies,
87
+ after casting out any records for higher taxa which are trumped by a more specific species records. Outputs two CSV files
88
+ `excess1.csv` and `excess2.csv`.
89
+
90
+ arphify.js
91
+
92
+ Given a pipeline specification such as the one in [data/dataPaper-I-in/arpha-out.json5], accepts both a normalised
93
+ observation file such as [data/dataPaper-I/reintegrated-obs.csv](data/dataPaper-I/reintegrated-obs.csv) and a normalised
94
+ curated summary file such as [/data/dataPaper-I-in/reintegrated.csv](/data/dataPaper-I-in/reintegrated.csv) and emits a
95
+ directory of XLSX spreadsheets in the form accepted by the [ARPHA writing tool](https://arpha.pensoft.net/) used for
96
+ submission of biodiversity data papers as well as a Darwin Core CSV file
97
+ [Materials.csv](data/dataPaper-I-In/arphified/Materials.csv) suitable for submission to GBIF.
98
+
99
+ wormify.js
100
+
101
+ Accepts arguments as for `taxonomise.js`. Produces a scratch `reintegrated-WoRMS.csv` file after downloading and
102
+ caching WoRMS taxon files into [data/WoRMS](data/WoRMS) which compares the `authority` value listed against the
103
+ one found in the WoRMS API.
104
+
105
+ We dream of turning these pipelines into easily usable pluralistic graphical pipelines deployed on public live infrastructure
106
+ such as github and Google Sheets.
107
+
108
+ # Visualisations
109
+
110
+ ## Sunburst visualisation and map view
111
+
112
+ Observation and checklist data derived from condensed summaries such as, e.g. [data/dataPaper-I/reintegrated.csv](data/dataPaper-I/reintegrated.csv)
113
+ is in a sunburst partition layout inspired by <https://bl.ocks.org/mbostock/4348373>,
114
+ <https://www.jasondavies.com/coffee-wheel/>, as well as a map-based view rendered with [Leaflet](https://leafletjs.com/).
115
+
116
+ ## Preparing data for visualisation
117
+
118
+ Data is compiled into a compressed JSON representation from CSV sources via a command-line script.
119
+
120
+ To convert a CSV file, run `marmalise.js` e.g. via a line such as
121
+
122
+ node src/marmalise.js data/dataPaper-I/reintegrated.csv --map data/dataPaper-I/combinedOutMap.json
123
+
124
+ By default this will produce a `Life.json.lz4` file which can be copied into a suitable location, e.g. in the </data>
125
+ directories and then referred to in the JavaScript initialisation block seen, e.g. in the various [index.html](index.html)
126
+ files in this root. You can supply a `-o` option to output a file of a chosen name at a chosen path.
127
+
128
+ To preview the web UI, host this project via some suitable static web server and then access its `index.html`.
129
+
130
+ Condensed versions of the visualisation source files suitable for production hosting (JS and CSS) can be output to the
131
+ <build> directory via `node build.js`.
132
+
133
+ You can see such visualisations running online at locations like
134
+
135
+ https://biogaliano.org/map-prototype/
136
+
137
+ https://biogaliano.org/galiano-data-paper-map-view/
138
+
139
+ And also a gallery in our [visualisations mini-portal](https://imerss.github.io/imerss-bioinfo/).
140
+
141
+ These visualisations are entirely static and so easy to host at any kind of site simply by uploading a folder of files
142
+ and injecting an initialisation block into the markup such as
143
+
144
+ ````html
145
+ <script>
146
+ hortis.sunburstLoader(".fl-imerss-container", {
147
+ colourCount: "undocumentedCount",
148
+ selectOnStartup: "Life",
149
+ vizFile: "data/Galiano/Galiano-Life.json.lz4",
150
+ phyloMap: "%resourceBase/json/emptyPhyloMap.json",
151
+ commonNames: false
152
+ });
153
+ </script>
154
+ ````
155
+
156
+ together with `<script>` and `<style>` references to the built files.
package/build.js ADDED
@@ -0,0 +1,196 @@
1
+ /* eslint-env node */
2
+ "use strict";
3
+
4
+ const readline = require("readline"),
5
+ fs = require("fs-extra");
6
+
7
+ const fluid = require("infusion");
8
+ const terser = require("terser");
9
+
10
+ const buildIndex = {
11
+ excludes: [
12
+ "jquery.js"
13
+ ],
14
+ localSource: [
15
+ "src/client/css/imerss-viz.css",
16
+ "src/auxBuild/restoreJQuery.js",
17
+ "src/lib/lz4.js",
18
+ "src/client/js/imerss-viz.js",
19
+ "src/client/js/autocomplete.js",
20
+ "src/client/js/colour.js",
21
+ "src/client/js/leafletMap.js",
22
+ "src/client/js/datasetControls.js",
23
+ "src/client/js/leafletMapWithGrid.js",
24
+ "src/client/js/leafletMapWithRegions.js",
25
+ "src/client/js/renderSVG.js",
26
+ "src/client/js/tabs.js",
27
+ "src/client/js/checklist.js",
28
+ "src/client/js/xetthecum.js"
29
+ ],
30
+ codeHeader: "",
31
+ codeFooter: "", // "\njQuery.noConflict()",
32
+ copy: [{
33
+ src: "node_modules/infusion/src/lib/jquery/core/js/jquery.js",
34
+ dest: "docs/js/jquery.js"
35
+ }, {
36
+ src: "src/client/img",
37
+ dest: "docs/img"
38
+ }, {
39
+ src: "src/client/json",
40
+ dest: "docs/json"
41
+ }, {
42
+ src: "src/client/html",
43
+ dest: "docs/html"
44
+ }, {
45
+ src: "src/client/css/imerss-viz-wp-overrides.css",
46
+ dest: "docs/css/imerss-viz-wp-overrides.css"
47
+ }, {
48
+ src: "src/client/css/xetthecum.css",
49
+ dest: "docs/css/xetthecum.css"
50
+ }, {
51
+ src: "src/client/css/xetthecum-shared.css",
52
+ dest: "docs/css/xetthecum-shared.css"
53
+ }, {
54
+ src: "src/client/css/xetthecum-external.css",
55
+ dest: "docs/css/xetthecum-external.css"
56
+ }, {
57
+ src: "src/client/css/pepiowelh.css",
58
+ dest: "docs/css/pepiowelh.css"
59
+ }, {
60
+ src: "src/buildSource/Galiano Life List.html",
61
+ dest: "docs/Galiano Life List.html"
62
+ }, {
63
+ src: "src/buildSource/Comprehensive Lists.html",
64
+ dest: "docs/Comprehensive Lists.html"
65
+ }, {
66
+ src: "src/buildSource/Squamish Life List.html",
67
+ dest: "docs/Squamish Life List.html"
68
+ }, {
69
+ src: "src/buildSource/dataPaperSunburstAndMap.html",
70
+ dest: "docs/dataPaperSunburstAndMap.html"
71
+ }, {
72
+ src: "src/buildSource/Data Paper Part I Visualisation.html",
73
+ dest: "docs/Data Paper Part I Visualisation.html"
74
+ }, {
75
+ src: "src/buildSource/Valdes Island Biodiversity.html",
76
+ dest: "docs/Valdes Island Biodiversity.html"
77
+ }, {
78
+ src: "src/buildSource/Xetthecum.html",
79
+ dest: "docs/Xetthecum.html"
80
+ }, {
81
+ src: "src/buildSource/Pe'pi'ow'elh.html",
82
+ dest: "docs/Pe'pi'ow'elh.html"
83
+ }, {
84
+ src: "src/buildSource/index.html",
85
+ dest: "docs/index.html"
86
+ }, {
87
+ src: "data/dataPaper-I/Life.json.lz4",
88
+ dest: "docs/data/dataPaper-I/Life.json.lz4"
89
+ }, {
90
+ src: "data/Valdes/Life.json.lz4",
91
+ dest: "docs/data/Valdes/Life.json.lz4"
92
+ }, {
93
+ src: "data/Galiano/Galiano-Life.json.lz4",
94
+ dest: "docs/data/Galiano/Galiano-Life.json.lz4"
95
+ }, {
96
+ src: "data/Comprehensive Lists/Comp-Life.json.lz4",
97
+ dest: "docs/data/Comprehensive Lists/Comp-Life.json.lz4"
98
+ }, {
99
+ src: "data/Galiano/Galiano_map_0.js",
100
+ dest: "docs/data/Galiano/Galiano_map_0.js"
101
+ }, {
102
+ src: "data/Galiano WoL/Life.json.lz4",
103
+ dest: "docs/data/Galiano WoL/Life.json.lz4"
104
+ }, {
105
+ src: "data/Xetthecum/Life.json.lz4",
106
+ dest: "docs/data/Xetthecum/Life.json.lz4"
107
+ }, {
108
+ src: "data/Squamish/Squamish-Life.json.lz4",
109
+ dest: "docs/data/Squamish/Squamish-Life.json.lz4"
110
+ }, {
111
+ src: "data/Pepiowelh/Life.json.lz4",
112
+ dest: "docs/data/Pepiowelh/Life.json.lz4"
113
+ }]
114
+ };
115
+
116
+
117
+ const readLines = function (filename) {
118
+ const lines = [];
119
+ const togo = fluid.promise();
120
+ const rl = readline.createInterface({
121
+ input: fs.createReadStream(filename),
122
+ terminal: false
123
+ });
124
+ rl.on("line", function (line) {
125
+ lines.push(line);
126
+ });
127
+ rl.on("close", function () {
128
+ togo.resolve(lines);
129
+ });
130
+ rl.on("error", function (error) {
131
+ togo.reject(error);
132
+ });
133
+ return togo;
134
+ };
135
+
136
+ const filesToContentHash = function (allFiles, extension) {
137
+ const extFiles = allFiles.filter(function (file) {
138
+ return file.endsWith(extension);
139
+ });
140
+ const hash = fluid.transform(fluid.arrayToHash(extFiles), function (troo, filename) {
141
+ return fs.readFileSync(filename, "utf8");
142
+ });
143
+ return hash;
144
+ };
145
+
146
+ const computeAllFiles = function (buildIndex, nodeFiles) {
147
+ const withExcludes = nodeFiles.filter(function (oneFile) {
148
+ return !buildIndex.excludes.some(function (oneExclude) {
149
+ return oneFile.indexOf(oneExclude) !== -1;
150
+ });
151
+ });
152
+ return withExcludes.concat(buildIndex.localSource);
153
+ };
154
+
155
+ const buildFromFiles = function (buildIndex, nodeFiles) {
156
+ const allFiles = computeAllFiles(buildIndex, nodeFiles);
157
+ console.log("allFiles " + allFiles);
158
+ nodeFiles.concat(buildIndex.localSource);
159
+
160
+ const jsHash = filesToContentHash(allFiles, ".js");
161
+ const fullJsHash = fluid.extend({header: buildIndex.codeHeader}, jsHash, {footer: buildIndex.codeFooter});
162
+ fluid.log("Minifying " + Object.keys(fullJsHash).length + " JS files ... ");
163
+ const promise = terser.minify(fullJsHash, {
164
+ mangle: false,
165
+ sourceMap: {
166
+ filename: "imerss-viz.js",
167
+ url: "imerss-viz.js.map"
168
+ }
169
+ });
170
+ promise.then(function (minified) {
171
+ fs.removeSync("docs");
172
+ fs.ensureDirSync("docs/js");
173
+ fs.writeFileSync("docs/js/imerss-viz-all.js", minified.code, "utf8");
174
+ fs.writeFileSync("docs/js/imerss-viz-all.js.map", minified.map);
175
+
176
+ const cssHash = filesToContentHash(allFiles, ".css");
177
+ const cssConcat = String.prototype.concat.apply("", Object.values(cssHash));
178
+
179
+ fs.ensureDirSync("docs/css");
180
+ fs.writeFileSync("docs/css/imerss-viz-all.css", cssConcat);
181
+ buildIndex.copy.forEach(function (oneCopy) {
182
+ fs.copySync(oneCopy.src, oneCopy.dest);
183
+ });
184
+ fluid.log("Copied " + (buildIndex.copy.length + 3) + " files to " + fs.realpathSync("docs"));
185
+ });
186
+ };
187
+
188
+ fluid.setLogging(true);
189
+
190
+ const linesPromise = readLines("gh-pages-nm.txt");
191
+
192
+ linesPromise.then(function (lines) {
193
+ buildFromFiles(buildIndex, lines);
194
+ }, function (error) {
195
+ console.log(error);
196
+ });