37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
const ejs = require("ejs");
|
|
const fs = require("fs-extra");
|
|
const path = require("path");
|
|
const parseVariantsData = require("../export-data/variants-data");
|
|
const getLigationData = require("../export-data/ligation-data");
|
|
const execMain = require("../shared/execMain");
|
|
|
|
const inputPath = process.argv[2];
|
|
const outputPath = process.argv[3];
|
|
const outputDataPath = process.argv[4];
|
|
|
|
execMain(main);
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
async function main() {
|
|
const weightGrades = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
const templatePath = path.join(inputPath, "index.ejs");
|
|
const variationData = await await parseVariantsData();
|
|
const ligationData = await getLigationData();
|
|
const html = await ejs.renderFile(templatePath, {
|
|
...variationData,
|
|
ligation: ligationData,
|
|
weights: weightGrades,
|
|
buildSsHtml(body, hc) {
|
|
const hcs = new Set(hc);
|
|
return [...body]
|
|
.map(ch => (hcs.has(ch) ? `<b>${ch}</b>` : ch))
|
|
.join("")
|
|
.replace(/\n/g, "<br/>");
|
|
}
|
|
});
|
|
await fs.writeFile(outputPath, html);
|
|
await fs.writeJson(outputDataPath, { ligation: ligationData }, { spaces: " " });
|
|
}
|