From cff06eda7e0f3e6184d9b18ec91cd661e44a2582 Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Tue, 21 Nov 2023 14:02:42 +0100 Subject: [PATCH 1/2] add tables.js script --- docs/scripts_js/Tables.js | 50 +++++++++++++++++++++++++++++++ docs/scripts_js/package-lock.json | 40 ++++++++++++------------- docs/scripts_js/package.json | 4 +-- 3 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 docs/scripts_js/Tables.js diff --git a/docs/scripts_js/Tables.js b/docs/scripts_js/Tables.js new file mode 100644 index 00000000..7063ff01 --- /dev/null +++ b/docs/scripts_js/Tables.js @@ -0,0 +1,50 @@ +// This script presents the most straightforward way to create and write an assay file filled with tables +// In principle, there are three steps +// 1. Create and manipulate object in datamodel +// 2. Transform object to generic spreadsheet +// 3. Write spreadsheet to xlsx file (or bytes) + +// Import ARCtrl +import * as arctrl from "@nfdi4plants/arctrl" +// Alternative import +// import { + // Comment$ as Comment, OntologyAnnotation, Person, Publication, + // IOType, CompositeHeader, CompositeCell, CompositeColumn, ArcTable, + // ArcAssay, ArcStudy, ArcInvestigation, + // Template, Organisation, Templates, JsWeb, + // ARC } from "@nfdi4plants/arctrl"; + +// Import ARCtrl Assay to Spreadsheet transformation +import {toFsWorkbook,fromFsWorkbook} from "@nfdi4plants/arctrl/ISA/ISA.Spreadsheet/ArcAssay.js" + +// Import Spreadsheet to XLSX reader/writer +import {Xlsx} from "@fslab/fsspreadsheet"; + +// -------- 1. Create and manipulate object in datamodel ---------- + +// Create assay +const myAssay = arctrl.ArcAssay.init("MyAssay"); + +// Create annotation table +const growth = arctrl.ArcTable.init("Growth"); + +// Add input column with one value to table +growth.AddColumn(new arctrl.CompositeHeader(11, [new arctrl.IOType(0, [])]), [arctrl.CompositeCell.createFreeText("Input1")]); + +// Add characteristic column with one value +const oa_species = arctrl.OntologyAnnotation.fromString("species", "GO", "GO:0123456"); +const oa_chlamy = arctrl.OntologyAnnotation.fromString("Chlamy", "NCBI", "NCBI:0123456"); +growth.AddColumn(new arctrl.CompositeHeader(1, [oa_species]), [arctrl.CompositeCell.createTerm(oa_chlamy)]); + +// Add table to assay +myAssay.AddTable(growth); + +// -------- 2. Transform object to generic spreadsheet ---------- +let spreadsheet = toFsWorkbook(myAssay); + +// -------- 3. Write spreadsheet to xlsx file (or bytes) ---------- +const outPath = "./myFile.xlsx"; + +console.log(Xlsx.toBytes(spreadsheet)); + +await Xlsx.toFile(outPath,spreadsheet); diff --git a/docs/scripts_js/package-lock.json b/docs/scripts_js/package-lock.json index 33850f67..b537c921 100644 --- a/docs/scripts_js/package-lock.json +++ b/docs/scripts_js/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@nfdi4plants/arctrl": "^1.0.0-alpha6", - "fsspreadsheet": "^4.0.0-alpha2" + "@fslab/fsspreadsheet": "^5.0.0", + "@nfdi4plants/arctrl": "^1.0.0-beta.7" } }, "node_modules/@fast-csv/format": { @@ -40,19 +40,18 @@ "lodash.uniq": "^4.5.0" } }, - "node_modules/@nfdi4plants/arctrl": { - "version": "1.0.0-alpha9", - "resolved": "https://registry.npmjs.org/@nfdi4plants/arctrl/-/arctrl-1.0.0-alpha9.tgz", - "integrity": "sha512-yY1bq10wkIbMfu/Ho+vKPw3Gg1UnQHVZLiE0gtNdp3elb1KYBuV2PldIKYIor/e+9EOls04HC4tKkDrtSgcTRg==", + "node_modules/@fslab/fsspreadsheet": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@fslab/fsspreadsheet/-/fsspreadsheet-5.0.0.tgz", + "integrity": "sha512-57Uv0F8D2woQjWjltNOBs18bh3yu1u9zLXfYNEgDw4v2pNTO6B1kLcuYF6+EvBVm3dEKpZZ29RnloWXnwJ5tCw==", "dependencies": { - "fable-library": "^1.1.1", - "isomorphic-fetch": "^3.0.0" + "@nfdi4plants/exceljs": "^0.3.0" } }, - "node_modules/@nfdi4plants/exceljs": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@nfdi4plants/exceljs/-/exceljs-0.2.0.tgz", - "integrity": "sha512-oGln4qXIDizm+PCGsW2KOL7RGEF2wXPQdF2/uew3xGhMrdhPJnwG0XdrVM5iumJtlU0WAUGBo3M/CDELtQ1gnw==", + "node_modules/@fslab/fsspreadsheet/node_modules/@nfdi4plants/exceljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@nfdi4plants/exceljs/-/exceljs-0.3.0.tgz", + "integrity": "sha512-/IvHS3ozGyZ2jG1pYpMoUn2vz+GMzkdo8zUnhsfnn2175ajnjlQKQi7qVhp8Kgpvt/FtthcysrloOjlttbyJQQ==", "dependencies": { "archiver": "^5.0.0", "dayjs": "^1.8.34", @@ -68,6 +67,15 @@ "node": ">=8.3.0" } }, + "node_modules/@nfdi4plants/arctrl": { + "version": "1.0.0-beta.7", + "resolved": "https://registry.npmjs.org/@nfdi4plants/arctrl/-/arctrl-1.0.0-beta.7.tgz", + "integrity": "sha512-QBXsomNHmiFaYONsM22/qWWPa/De6nyi6Wdvkh6FqTESFaGBrTT5PQ1hYnHdtgOpX0FIYy7elIO3ui2pyWUu2Q==", + "dependencies": { + "fable-library": "^1.1.1", + "isomorphic-fetch": "^3.0.0" + } + }, "node_modules/@types/node": { "version": "14.18.63", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", @@ -390,14 +398,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/fsspreadsheet": { - "version": "4.0.0-alpha2", - "resolved": "https://registry.npmjs.org/fsspreadsheet/-/fsspreadsheet-4.0.0-alpha2.tgz", - "integrity": "sha512-inhygUG7sdRkIlsge3bLeqyz53ap8xyJiVEYnxQyrFFJ8IxQHJbMb/SvlTcZAmI7RiROvPZMdFEBgaqUrs238w==", - "dependencies": { - "@nfdi4plants/exceljs": "0.2.0" - } - }, "node_modules/fstream": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", diff --git a/docs/scripts_js/package.json b/docs/scripts_js/package.json index 7c2fd5d8..7c0a1f82 100644 --- a/docs/scripts_js/package.json +++ b/docs/scripts_js/package.json @@ -9,7 +9,7 @@ "author": "Kevin Frey", "license": "MIT", "dependencies": { - "@nfdi4plants/arctrl": "^1.0.0-alpha6", - "fsspreadsheet": "^4.0.0-alpha2" + "@nfdi4plants/arctrl": "^1.0.0-beta.7", + "@fslab/fsspreadsheet": "^5.0.0" } } From 861c52687a80864f5181e9be097cbeba9db6438f Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Tue, 21 Nov 2023 14:09:06 +0100 Subject: [PATCH 2/2] update shields.io badges to directly link to nuget and npm --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5350da74..d2e4271d 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ and __JavaScript__! ❤️ | Version | Downloads | | :--------|-----------:| -|![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/ARCtrl?logo=nuget&color=%234fb3d9)|![Nuget](https://img.shields.io/nuget/dt/ARCtrl?color=%234FB3D9)| -|![npm (scoped with tag)](https://img.shields.io/npm/v/%40nfdi4plants/arctrl/next?logo=npm&color=%234fb3d9)|![npm](https://img.shields.io/npm/dt/%40nfdi4plants%2Farctrl?color=%234fb3d9)| +|Nuget|Nuget| +|NPM|NPM| + ## Install