@biolibs/bionet-tools 0.1.1 → 0.1.3

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 (78) hide show
  1. package/README.md +146 -4
  2. package/dist/digest-bench.d.ts +84 -0
  3. package/dist/digest-bench.d.ts.map +1 -0
  4. package/dist/digest-bench.js +127 -0
  5. package/dist/digest-bench.js.map +1 -0
  6. package/dist/digest-working.d.ts +155 -0
  7. package/dist/digest-working.d.ts.map +1 -0
  8. package/dist/digest-working.js +216 -0
  9. package/dist/digest-working.js.map +1 -0
  10. package/dist/index.d.ts +20 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +20 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/ligate-bench.d.ts +98 -0
  15. package/dist/ligate-bench.d.ts.map +1 -0
  16. package/dist/ligate-bench.js +139 -0
  17. package/dist/ligate-bench.js.map +1 -0
  18. package/dist/ligate-working.d.ts +96 -0
  19. package/dist/ligate-working.d.ts.map +1 -0
  20. package/dist/ligate-working.js +145 -0
  21. package/dist/ligate-working.js.map +1 -0
  22. package/dist/ligate.d.ts +152 -0
  23. package/dist/ligate.d.ts.map +1 -0
  24. package/dist/ligate.js +161 -0
  25. package/dist/ligate.js.map +1 -0
  26. package/dist/map.d.ts +69 -0
  27. package/dist/map.d.ts.map +1 -0
  28. package/dist/map.js +80 -0
  29. package/dist/map.js.map +1 -0
  30. package/dist/pcr-bench.d.ts +20 -2
  31. package/dist/pcr-bench.d.ts.map +1 -1
  32. package/dist/pcr-bench.js +34 -10
  33. package/dist/pcr-bench.js.map +1 -1
  34. package/dist/pcr-scene.d.ts +2 -0
  35. package/dist/pcr-scene.d.ts.map +1 -1
  36. package/dist/pcr-scene.js +8 -8
  37. package/dist/pcr-scene.js.map +1 -1
  38. package/dist/pcr-working.d.ts +126 -0
  39. package/dist/pcr-working.d.ts.map +1 -0
  40. package/dist/pcr-working.js +175 -0
  41. package/dist/pcr-working.js.map +1 -0
  42. package/dist/run.d.ts +101 -6
  43. package/dist/run.d.ts.map +1 -1
  44. package/dist/run.js +127 -11
  45. package/dist/run.js.map +1 -1
  46. package/dist/sequence-file.d.ts +108 -0
  47. package/dist/sequence-file.d.ts.map +1 -0
  48. package/dist/sequence-file.js +145 -0
  49. package/dist/sequence-file.js.map +1 -0
  50. package/dist/sequences-tool.d.ts +13 -0
  51. package/dist/sequences-tool.d.ts.map +1 -0
  52. package/dist/sequences-tool.js +61 -0
  53. package/dist/sequences-tool.js.map +1 -0
  54. package/dist/tools.d.ts +2 -2
  55. package/dist/tools.d.ts.map +1 -1
  56. package/dist/tools.js +9 -4
  57. package/dist/tools.js.map +1 -1
  58. package/dist/working.d.ts +58 -0
  59. package/dist/working.d.ts.map +1 -0
  60. package/dist/working.js +55 -0
  61. package/dist/working.js.map +1 -0
  62. package/package.json +5 -2
  63. package/src/digest-bench.tsx +311 -0
  64. package/src/digest-working.ts +288 -0
  65. package/src/index.ts +20 -0
  66. package/src/ligate-bench.tsx +297 -0
  67. package/src/ligate-working.ts +182 -0
  68. package/src/ligate.ts +243 -0
  69. package/src/map.tsx +170 -0
  70. package/src/pcr-bench.tsx +66 -9
  71. package/src/pcr-scene.ts +10 -8
  72. package/src/pcr-working.ts +228 -0
  73. package/src/run.ts +179 -14
  74. package/src/sequence-file.ts +172 -0
  75. package/src/sequences-tool.tsx +109 -0
  76. package/src/tools.tsx +13 -8
  77. package/src/working.tsx +96 -0
  78. package/tools.css +54 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The working, drawn: a figure that opens to show the steps that give it.
3
+ *
4
+ * It is shut until asked for, so a tool reads the same as before to somebody who trusts it, and
5
+ * opens to somebody who wants to follow it. Whether a figure is exact or an estimate is said on the
6
+ * outside, since that is worth knowing without opening anything.
7
+ */
8
+ import type { ReactNode } from "react";
9
+ import type { CutSite } from "./digest-working.js";
10
+ import type { JoinOverhangs } from "./ligate-working.js";
11
+ import type { BindingWorking, FacedBase, Working } from "./pcr-working.js";
12
+
13
+ /**
14
+ * One figure and its working.
15
+ *
16
+ * @param props - `working` is the figure; `children` is drawn under the steps, for a table or a picture that goes with them.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { ShowWorking, tmWorking } from "@biolibs/bionet-tools";
21
+ *
22
+ * const working = tmWorking("fwd", "GGATCACAGTCTACACTG");
23
+ * {working !== null && <ShowWorking working={working} />}
24
+ * ```
25
+ */
26
+ export function ShowWorking({ working, children }: { working: Working; children?: ReactNode }) {
27
+ return (
28
+ <details className="working">
29
+ <summary>
30
+ <span className="of">{working.of}</span> <strong>{working.comes}</strong>
31
+ <span className={`kind ${working.kind}`} title={working.kind === "exact" ? "This follows from the sequences alone." : "This rests on a rule of thumb. A different rule would give a different figure."}>{working.kind}</span>
32
+ </summary>
33
+ <ol>{working.steps.map((step) => <li key={step}>{step}</li>)}</ol>
34
+ {children}
35
+ {working.rests !== undefined && <p className="rests">{working.rests}</p>}
36
+ </details>
37
+ );
38
+ }
39
+
40
+ /**
41
+ * A primer laid against the strand it binds, each base over the one it faces.
42
+ *
43
+ * The primer is written 5′ to 3′. A line joins each pair that holds. The bases at the 3′ end that
44
+ * must pair are underlined, and a tail that does not bind stands apart from the strand.
45
+ *
46
+ * @param props - `working` is from `bindingWorking`; `name` is what the primer is called.
47
+ */
48
+ export function FacedBases({ working, name }: { working: BindingWorking; name: string }) {
49
+ const says = `${name}, 5′ to 3′, against the ${working.strand} strand: ${working.faced.filter((one) => one.pairs).length} of ${working.faced.length} bases pair.`;
50
+ const cell = (base: string, extra = ""): ReactNode => <span className={`base base-${base.toLowerCase() || "none"} ${extra}`}>{base || "·"}</span>;
51
+ return (
52
+ <div className="faced" role="img" aria-label={says}>
53
+ <div className="row"><span className="end">5′</span>{working.faced.map((one: FacedBase, at) => <span key={at}>{cell(one.primer, one.needed ? "needed" : "")}</span>)}<span className="end">3′ {name}</span></div>
54
+ <div className="row"><span className="end" />{working.faced.map((one, at) => <span key={at} className={one.pairs ? "bond" : "bond none"}>{one.pairs ? "|" : " "}</span>)}<span className="end" /></div>
55
+ <div className="row"><span className="end">3′</span>{working.faced.map((one, at) => <span key={at}>{cell(one.faces)}</span>)}<span className="end">5′ {working.strand} strand</span></div>
56
+ </div>
57
+ );
58
+ }
59
+
60
+ /**
61
+ * A cut, drawn in the bases it is made in: both strands, the recognised bases marked, and a bar
62
+ * where each strand is cut.
63
+ *
64
+ * @param props - `site` is from `cutSites`.
65
+ */
66
+ export function CutBases({ site }: { site: CutSite }) {
67
+ const { top, bottom, site: [start, end], cutTop, cutBottom } = site.around;
68
+ const says = `${site.enzyme} at base ${site.at.toLocaleString("en-US")}: it recognises ${site.recognises} and leaves ${site.overhang === "blunt" ? "a blunt end" : `a ${site.overhang} overhang of ${site.bases}`}.`;
69
+ const row = (bases: string, cut: number): ReactNode => [...bases].map((base, at) => (
70
+ <span key={at} className={`base base-${base.toLowerCase()}${at >= start && at < end ? " site" : ""}${at === cut ? " cut" : ""}`}>{base}</span>
71
+ ));
72
+ return (
73
+ <div className="faced cutbases" role="img" aria-label={says}>
74
+ <div className="row"><span className="end">5′</span>{row(top, cutTop)}<span className="end">3′ top</span></div>
75
+ <div className="row"><span className="end">3′</span>{row(bottom, cutBottom)}<span className="end">5′ bottom</span></div>
76
+ </div>
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Two ends of a ligation written one over the other, so that the pairing can be read.
82
+ *
83
+ * @param props - `bases` is from `joinWorking`.
84
+ */
85
+ export function JoinBases({ bases }: { bases: JoinOverhangs }) {
86
+ if (bases.kind === "blunt") return <p className="faced blunt">Both ends are blunt, so there is nothing to pair: ligase seals them as they meet.</p>;
87
+ const says = `${bases.from}'s ${bases.kind} overhang ${bases.left} against ${bases.to}'s ${bases.right}.`;
88
+ const row = (text: string): ReactNode => [...text].map((base, at) => <span key={at} className={`base base-${base.toLowerCase()}`}>{base}</span>);
89
+ return (
90
+ <div className="faced" role="img" aria-label={says}>
91
+ <div className="row"><span className="end">{bases.from}</span>{row(bases.left)}<span className="end" /></div>
92
+ <div className="row"><span className="end" />{[...bases.left].map((base, at) => <span key={at} className="bond">|</span>)}<span className="end" /></div>
93
+ <div className="row"><span className="end">{bases.to}</span>{row(bases.right)}<span className="end" /></div>
94
+ </div>
95
+ );
96
+ }
package/tools.css CHANGED
@@ -48,3 +48,57 @@
48
48
  .bionet.benchpanel .bar .fill.template { background: var(--bionet-dim) } .bionet.benchpanel .bar .fill.long { background: var(--bionet-theirs) }
49
49
  .bionet.benchpanel .bar .fill.product { background: var(--bionet-held) }
50
50
  .bionet.benchpanel .bar .count { text-align: right; font-variant-numeric: tabular-nums }
51
+ /* A sequence's map. */
52
+ .bionet .seqmap { display: block; width: 100%; max-width: 24rem; height: auto; margin: 0 auto }
53
+ .bionet .seqmap.linear { max-width: 44rem }
54
+ .bionet .seqmap .backbone { fill: none; stroke: var(--bionet-ink); stroke-width: 2 }
55
+ .bionet .seqmap .tick { stroke: var(--bionet-dim); stroke-width: 1 }
56
+ .bionet .seqmap .feature { opacity: .92 }
57
+ .bionet .seqmap .tone-yours, .bionet .swatch.tone-yours { fill: var(--bionet-yours); background: var(--bionet-yours) }
58
+ .bionet .seqmap .tone-theirs, .bionet .swatch.tone-theirs { fill: var(--bionet-theirs); background: var(--bionet-theirs) }
59
+ .bionet .seqmap .tone-held, .bionet .swatch.tone-held { fill: var(--bionet-held); background: var(--bionet-held) }
60
+ .bionet .seqmap .tone-found, .bionet .swatch.tone-found { fill: var(--bionet-found); background: var(--bionet-found) }
61
+ .bionet .seqmap .tone-good, .bionet .swatch.tone-good { fill: var(--bionet-good); background: var(--bionet-good) }
62
+ .bionet .seqmap .tone-attention, .bionet .swatch.tone-attention { fill: var(--bionet-attention); background: var(--bionet-attention) }
63
+ .bionet .seqmap .tone-dim, .bionet .swatch.tone-dim { fill: var(--bionet-dim); background: var(--bionet-dim) }
64
+ .bionet .seqmap .span { fill: var(--bionet-found) }
65
+ .bionet .seqmap .mark { fill: none; stroke: var(--bionet-attention); stroke-width: 1.2 }
66
+ .bionet .seqmap text { font-size: 10px; fill: var(--bionet-dim) }
67
+ .bionet .seqmap text.marked { fill: var(--bionet-attention); font-family: ui-monospace, monospace }
68
+ .bionet .seqmap text.name { font-size: 14px; font-weight: 600; fill: var(--bionet-ink) }
69
+ .bionet .seqmap text.length { font-family: ui-monospace, monospace }
70
+ .bionet .swatch { display: inline-block; width: .62rem; height: .62rem; margin-right: .45rem; border-radius: 2px; vertical-align: baseline }
71
+ .bionet .sequences .mapped { display: grid; grid-template-columns: minmax(15rem, 24rem) 1fr; gap: 1.4rem; align-items: start; margin-top: 1rem }
72
+ @media (max-width: 860px) { .bionet .sequences .mapped { grid-template-columns: 1fr } }
73
+ .bionet .sequences input[type="file"] { margin-top: .4rem }
74
+ .bionet .seqmap .span.wide { opacity: .55 }
75
+ .bionet .seqmap text.spanned { fill: var(--bionet-found) }
76
+ .bionet .benchpanel .seqmap { margin-top: .8rem; max-width: 20rem }
77
+ .bionet .benchpanel .seqmap.linear { max-width: 100% }
78
+ /* The working: a figure that opens to show the steps that give it. */
79
+ .bionet .working { margin: .3rem 0; border: 1px solid var(--bionet-rule); border-radius: 8px; font-size: .84rem }
80
+ .bionet .working summary { cursor: pointer; padding: .4rem .6rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline }
81
+ .bionet .working summary .of { color: var(--bionet-dim) }
82
+ .bionet .working summary .kind { margin-left: auto; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; padding: 0 .4rem; border-radius: 999px; border: 1px solid currentColor }
83
+ .bionet .working summary .kind.exact { color: var(--bionet-good) } .bionet .working summary .kind.estimate { color: var(--bionet-held) }
84
+ .bionet .working ol { margin: 0 .6rem .5rem 1.9rem; padding: 0; display: grid; gap: .25rem }
85
+ .bionet .working .rests { margin: 0 .6rem .6rem; color: var(--bionet-dim); font-size: .8rem }
86
+ .bionet .working table.counts { display: block; overflow-x: auto; margin: 0 .6rem .6rem; font-family: ui-monospace, monospace; font-size: .72rem }
87
+ .bionet .working table.counts td, .bionet .working table.counts th { text-align: right; padding: .1rem .3rem }
88
+ .bionet .checks .because { margin-left: .3rem; font-size: .76rem; color: var(--bionet-dim); white-space: nowrap }
89
+ .bionet .faced { --base-a: #5fd3a6; --base-t: #f0788a; --base-g: #e6b450; --base-c: #78aef5; margin: 0 .6rem .6rem; overflow-x: auto; font-family: ui-monospace, monospace; font-size: .8rem; line-height: 1.15 }
90
+ .bionet[data-bionet-theme="light"] .faced, [data-bionet-theme="light"] .bionet .faced { --base-a: #1f8a5b; --base-t: #c8394b; --base-g: #b97a08; --base-c: #2a66b8 }
91
+ .bionet .faced .row { display: flex; white-space: pre }
92
+ .bionet .faced .row > span { flex: 0 0 1ch; text-align: center }
93
+ .bionet .faced .row > .end { flex: 0 0 auto; min-width: 2.2ch; padding: 0 .5ch; color: var(--bionet-dim); font-family: inherit }
94
+ .bionet .faced .base-a { color: var(--base-a) } .bionet .faced .base-t { color: var(--base-t) } .bionet .faced .base-g { color: var(--base-g) } .bionet .faced .base-c { color: var(--base-c) }
95
+ .bionet .faced .base-none { color: var(--bionet-dim) }
96
+ .bionet .faced .needed { text-decoration: underline; text-underline-offset: .2em }
97
+ .bionet .faced .bond { color: var(--bionet-dim) }
98
+ .bionet .cutbases .row > .base { flex: 0 0 1.25ch; opacity: .55 }
99
+ .bionet .cutbases .row > .base.site { opacity: 1; font-weight: 700; background: color-mix(in srgb, var(--bionet-attention) 16%, transparent) }
100
+ .bionet .cutbases .row > .base.cut { box-shadow: -2px 0 0 var(--bionet-attention) }
101
+ .bionet .pieces td, .bionet .pieces th { font-size: .82rem; vertical-align: top }
102
+ .bionet .pieces code { font-size: .78rem }
103
+ .bionet .benchpanel .gel { max-width: 18rem }
104
+ .bionet .faced.blunt { margin: 0 .6rem .6rem; font-family: inherit; color: var(--bionet-dim) }