ISA-JSON to ISA-Tab Conversion
This guide shows you how to convert your ISA-JSON datasets into ISA-Tab formatted files or compressed ZIP archives.
Installation
Section titled “Installation”Install the package in your project:
pnpm add isa4jsConvert to Raw ISA-Tab Strings
Section titled “Convert to Raw ISA-Tab Strings”Use convertIsaJsonToIsaTab to transform your ISA-JSON data into memory strings. This returns an object containing the formatted files.
import { convertIsaJsonToIsaTab, type ISAInvestigationSchema } from 'isa4js';
const isaJsonData: ISAInvestigationSchema = { // Your valid ISA-JSON object};
try { const files = convertIsaJsonToIsaTab(isaJsonData);
// Iterate through the generated files for (const [filename, content] of Object.entries(files)) { console.log(`--- ${filename} ---`); console.log(content); } // Or access a specific file directly if you know its generated name // console.log(files['i_investigation.txt']);} catch (error) { console.error('Conversion failed:', error);}Convert directly to a ZIP Archive
Section titled “Convert directly to a ZIP Archive”Use convertIsaJsonToZip to bundle all generated ISA-Tab matrices into a single compressed archive.
import { convertIsaJsonToZip } from 'isa4js';import { writeFile } from 'node:fs/promises';
const isaJsonData = { /* ... */ };
// Generates a ZIP archive bufferconst zipBuffer = await convertIsaJsonToZip(isaJsonData);
// Save the file to diskawait writeFile('./isa-metadata.zip', zipBuffer);