parent
5e88b187e5
commit
a6e27b66cc
20 changed files with 194 additions and 133 deletions
263
utility/export-data/ligation-data.js
Normal file
263
utility/export-data/ligation-data.js
Normal file
|
@ -0,0 +1,263 @@
|
|||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const toml = require("toml");
|
||||
|
||||
function TAG(...ltag) {
|
||||
return function(s) {
|
||||
return { tags: ltag, s: s };
|
||||
};
|
||||
}
|
||||
const arrow = TAG("arrow");
|
||||
const arrow2 = TAG("arrow2");
|
||||
const centerOps = TAG("center-ops");
|
||||
const eqeq = TAG("eqeq");
|
||||
const exeq = TAG("exeq");
|
||||
const eqeqeq = TAG("eqeq", "eqeqeq");
|
||||
const exeqeq = TAG("exeq", "exeqeq");
|
||||
const eqexeq = TAG("eqexeq", "eqexeq");
|
||||
const eqslasheq = TAG("slasheq", "eqslasheq");
|
||||
const slasheq = TAG("slasheq");
|
||||
const tildeeq = TAG("tildeeq");
|
||||
const ineq = TAG("ineq");
|
||||
const logc = TAG("logic");
|
||||
const brst = TAG("brst");
|
||||
const trig = TAG("trig");
|
||||
const ltgt = TAG("ltgt-diamond", "ltgt-ne");
|
||||
const dotOper = TAG("dotoper");
|
||||
const colons = TAG("colons");
|
||||
const htmlComment = TAG("html-comment");
|
||||
const plusplus = TAG("plusplus");
|
||||
|
||||
const ligationSamples = [
|
||||
[
|
||||
arrow2("-<<"),
|
||||
arrow2("-<"),
|
||||
arrow2("-<-"),
|
||||
arrow("<--"),
|
||||
arrow("<---"),
|
||||
arrow("<<-"),
|
||||
arrow("<-"),
|
||||
arrow("->"),
|
||||
arrow("->>"),
|
||||
arrow("-->"),
|
||||
arrow("--->"),
|
||||
arrow2("->-"),
|
||||
arrow2(">-"),
|
||||
arrow2(">>-"),
|
||||
arrow("<->"),
|
||||
arrow("<-->"),
|
||||
arrow("<--->"),
|
||||
arrow("<---->"),
|
||||
htmlComment("<!--")
|
||||
],
|
||||
[
|
||||
arrow2("=<<"),
|
||||
arrow2("=<"),
|
||||
arrow2("=<="),
|
||||
arrow("<=="),
|
||||
arrow("<==="),
|
||||
arrow("<<="),
|
||||
ineq("<="),
|
||||
arrow("=>"),
|
||||
arrow("=>>"),
|
||||
arrow("==>"),
|
||||
arrow("===>"),
|
||||
arrow2("=>="),
|
||||
ineq(">="),
|
||||
arrow2(">>="),
|
||||
arrow("<=>"),
|
||||
arrow("<==>"),
|
||||
arrow("<===>"),
|
||||
arrow("<====>"),
|
||||
htmlComment("<!---")
|
||||
],
|
||||
[
|
||||
arrow("<------"),
|
||||
arrow("------>"),
|
||||
arrow("<=====>"),
|
||||
arrow("<~~"),
|
||||
arrow("<~"),
|
||||
arrow("~>"),
|
||||
arrow("~~>"),
|
||||
colons("::"),
|
||||
colons(":::"),
|
||||
logc("\\/"),
|
||||
logc("/\\"),
|
||||
eqeq("=="),
|
||||
exeq("!="),
|
||||
slasheq("/="),
|
||||
tildeeq(`~=`),
|
||||
ltgt(`<>`),
|
||||
eqeqeq("==="),
|
||||
exeqeq("!=="),
|
||||
eqslasheq("=/="),
|
||||
eqexeq("=!=")
|
||||
],
|
||||
[
|
||||
centerOps(":="),
|
||||
centerOps(":-"),
|
||||
centerOps(":+"),
|
||||
centerOps("<*"),
|
||||
centerOps("<*>"),
|
||||
centerOps("*>"),
|
||||
trig("<|"),
|
||||
trig("<|>"),
|
||||
trig("|>"),
|
||||
dotOper("<."),
|
||||
dotOper("<.>"),
|
||||
dotOper(".>"),
|
||||
centerOps("+:"),
|
||||
centerOps("-:"),
|
||||
centerOps("=:"),
|
||||
centerOps("<******>"),
|
||||
brst("(* comm *)"),
|
||||
plusplus("++"),
|
||||
plusplus("+++"),
|
||||
logc("|-"),
|
||||
logc("-|")
|
||||
]
|
||||
];
|
||||
|
||||
const ligationSamplesNarrow = [
|
||||
[
|
||||
arrow("<--"),
|
||||
arrow("<---"),
|
||||
arrow("<<-"),
|
||||
arrow("<-"),
|
||||
arrow("<->"),
|
||||
arrow("->"),
|
||||
arrow("->>"),
|
||||
arrow("-->"),
|
||||
arrow("--->"),
|
||||
htmlComment("<!--")
|
||||
],
|
||||
[
|
||||
arrow2("-<<"),
|
||||
arrow2("-<"),
|
||||
arrow2("-<-"),
|
||||
arrow2("->-"),
|
||||
arrow2(">-"),
|
||||
arrow2(">>-"),
|
||||
arrow("<-->"),
|
||||
arrow("<--->"),
|
||||
arrow("<---->")
|
||||
],
|
||||
[
|
||||
arrow("<=="),
|
||||
arrow("<==="),
|
||||
arrow("<<="),
|
||||
ineq("<="),
|
||||
arrow("<=>"),
|
||||
arrow("=>"),
|
||||
arrow("=>>"),
|
||||
arrow("==>"),
|
||||
arrow("===>"),
|
||||
htmlComment("<!---")
|
||||
],
|
||||
[
|
||||
arrow2("=<<"),
|
||||
arrow2("=<"),
|
||||
arrow2("=<="),
|
||||
arrow2("=>="),
|
||||
ineq(">="),
|
||||
arrow2(">>="),
|
||||
arrow("<==>"),
|
||||
arrow("<===>"),
|
||||
arrow("<====>")
|
||||
],
|
||||
[
|
||||
arrow("<-------"),
|
||||
arrow("------->"),
|
||||
arrow("<======>"),
|
||||
arrow("<~~"),
|
||||
arrow("<~"),
|
||||
arrow("~>"),
|
||||
arrow("~~>")
|
||||
],
|
||||
[
|
||||
logc("\\/"),
|
||||
logc("/\\"),
|
||||
eqeq("=="),
|
||||
exeq("!="),
|
||||
slasheq("/="),
|
||||
tildeeq(`~=`),
|
||||
ltgt(`<>`),
|
||||
eqeqeq("==="),
|
||||
exeqeq("!=="),
|
||||
eqslasheq("=/="),
|
||||
eqexeq("=!=")
|
||||
],
|
||||
[
|
||||
centerOps(":="),
|
||||
centerOps(":-"),
|
||||
centerOps(":+"),
|
||||
centerOps("<*"),
|
||||
centerOps("<*>"),
|
||||
centerOps("*>"),
|
||||
trig("<|"),
|
||||
trig("<|>"),
|
||||
trig("|>"),
|
||||
centerOps("+:"),
|
||||
centerOps("-:"),
|
||||
centerOps("=:")
|
||||
],
|
||||
[
|
||||
colons("::"),
|
||||
colons(":::"),
|
||||
dotOper("<."),
|
||||
dotOper("<.>"),
|
||||
dotOper(".>"),
|
||||
brst("(* comm *)"),
|
||||
plusplus("++"),
|
||||
plusplus("+++"),
|
||||
logc("|-"),
|
||||
logc("-|")
|
||||
]
|
||||
];
|
||||
|
||||
module.exports = async function getLigationData() {
|
||||
const ligToml = await fs.readFile(path.join(__dirname, "../../ligation-set.toml"), "utf8");
|
||||
const ligData = toml.parse(ligToml);
|
||||
|
||||
const ligationSets = buildLigationSet(ligData, comp => comp.buildup.join(","));
|
||||
const nonMergeLigationSets = buildLigationSet(
|
||||
ligData,
|
||||
comp => comp.tag + comp.buildup.join(",")
|
||||
);
|
||||
|
||||
return {
|
||||
samples: ligationSamples,
|
||||
samplesNarrow: ligationSamplesNarrow,
|
||||
cherry: ligData.simple,
|
||||
rawSets: ligData.composite,
|
||||
sets: [...ligationSets.values()],
|
||||
nonMergeSets: [...nonMergeLigationSets.values()]
|
||||
};
|
||||
};
|
||||
|
||||
function buildLigationSet(ligData, getKey) {
|
||||
const ligationSets = new Map([
|
||||
["*off", { tag: "calt", switch: "off", desc: "Ligation Off", brief: "Off", buildup: [] }]
|
||||
]);
|
||||
for (const sel in ligData.composite) {
|
||||
const comp = ligData.composite[sel];
|
||||
if (!comp.tag) continue;
|
||||
const key = getKey(comp);
|
||||
let item = ligationSets.get(key);
|
||||
if (!item) {
|
||||
item = {
|
||||
tag: comp.tag,
|
||||
buildup: comp.buildup,
|
||||
tagName: comp.tag,
|
||||
desc: comp.desc,
|
||||
brief: comp.brief || comp.desc
|
||||
};
|
||||
ligationSets.set(key, item);
|
||||
} else {
|
||||
item.tagName += ", " + comp.tag;
|
||||
item.desc += ", " + comp.desc;
|
||||
item.brief += ", " + comp.brief;
|
||||
}
|
||||
}
|
||||
return ligationSets;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue