Optimize nupack service startup and compute

This commit is contained in:
Lihatoo 2026-05-28 01:04:44 +08:00
commit e1b3156754
25 changed files with 9435 additions and 0 deletions

191
service/design-guide.html Normal file
View file

@ -0,0 +1,191 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>NUPACK Design 使用笔记</title>
<style>
:root {
--paper: #f7f2e8;
--ink: #162033;
--muted: #64708a;
--line: #ddd4c4;
--accent: #1f6f5f;
--accent-2: #b65b2a;
}
body {
margin: 0;
background: linear-gradient(135deg, #fbf7ee 0%, #edf5f0 100%);
color: var(--ink);
font-family: "Avenir Next", "Noto Sans SC", sans-serif;
line-height: 1.65;
}
main {
max-width: 960px;
margin: 0 auto;
padding: 36px 20px 72px;
}
h1, h2, h3 {
line-height: 1.25;
}
h1 {
font-size: clamp(2rem, 5vw, 4rem);
letter-spacing: -0.04em;
margin: 0 0 12px;
}
h2 {
margin-top: 34px;
padding-top: 18px;
border-top: 1px solid var(--line);
}
code, pre {
font-family: "Inconsolata", "SFMono-Regular", Consolas, monospace;
}
pre {
overflow: auto;
background: #15221f;
color: #f4ead7;
border-radius: 18px;
padding: 16px;
}
.card {
background: rgba(255, 255, 255, 0.72);
border: 1px solid var(--line);
border-radius: 22px;
padding: 20px;
margin: 18px 0;
box-shadow: 0 18px 50px rgba(42, 31, 20, 0.08);
}
.toc {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin: 22px 0;
}
a.button {
display: inline-block;
border: 1px solid var(--line);
border-radius: 999px;
padding: 9px 14px;
color: var(--accent);
background: #fffaf0;
text-decoration: none;
font-weight: 700;
}
.warn {
border-left: 4px solid var(--accent-2);
padding-left: 14px;
color: #5b3828;
}
.muted {
color: var(--muted);
}
table {
width: 100%;
border-collapse: collapse;
background: rgba(255,255,255,0.75);
border-radius: 16px;
overflow: hidden;
}
th, td {
border-bottom: 1px solid var(--line);
padding: 10px;
text-align: left;
vertical-align: top;
}
th {
background: #efe6d6;
}
</style>
</head>
<body>
<main>
<p class="muted">NUPACK replica / Design workflow notes</p>
<h1>Design 使用笔记</h1>
<p>这份笔记只讲当前网页里已经接入的功能Design domains、target complexes、target tubes、hard constraints、soft constraints 和 defect weights。</p>
<nav class="toc">
<a class="button" href="#quick-start">快速跑通</a>
<a class="button" href="#targets">Targets 怎么填</a>
<a class="button" href="#hard">Hard constraints</a>
<a class="button" href="#soft">Soft constraints</a>
<a class="button" href="#speed">为什么会慢</a>
<a class="button" href="/#design-targets">跳到主界面 Targets</a>
<a class="button" href="/#design-hard">跳到主界面 Hard</a>
<a class="button" href="/#design-soft">跳到主界面 Soft</a>
<a class="button" href="/#history">跳到历史记录</a>
</nav>
<section id="quick-start" class="card">
<h2>1. 快速跑通</h2>
<p>主界面选择 <strong>Design</strong>,点击 <strong>载入示例</strong>,会得到一个可直接运行的双链设计:</p>
<pre><code>domain:
a = N10
strands:
A = a
B = ~a
target complex:
AB_target = A+B
structure = (10+)10
target tube:
AB_target = 1 uM
off-target max size = 2</code></pre>
<p><code>~a</code> 表示 domain <code>a</code> 的反向互补,因此 <code>(10+)10</code> 这个全双链目标结构是合法的。</p>
</section>
<section id="targets" class="card">
<h2>2. Targets 怎么填</h2>
<table>
<thead>
<tr><th>区域</th><th>含义</th><th>示例</th></tr>
</thead>
<tbody>
<tr><td>Design Domains</td><td>给每段可设计区域命名,并写 IUPAC 约束。</td><td><code>a = N10</code></td></tr>
<tr><td>链输入</td><td>Design 模式下,序列框可以写 domain composition。</td><td><code>A = a</code>, <code>B = ~a</code></td></tr>
<tr><td>Target Complex</td><td>指定哪些链组成目标复合物,以及目标二级结构。</td><td><code>A+B</code>, <code>(10+)10</code></td></tr>
<tr><td>Target Tube</td><td>Tube design 才需要。指定 on-target 浓度off-target 由 max size 自动补全。</td><td><code>AB_target = 1 uM</code></td></tr>
</tbody>
</table>
</section>
<section id="hard" class="card">
<h2>3. Hard constraints 怎么用</h2>
<p>Hard constraint 是“必须满足”的约束,写错会让设计空间为空,或直接报错。</p>
<table>
<thead>
<tr><th>类型</th><th>必填字段</th><th>当前推荐示例</th></tr>
</thead>
<tbody>
<tr><td>Match</td><td>左侧、右侧</td><td><code>a</code><code>a</code></td></tr>
<tr><td>Complementarity</td><td>左侧、右侧</td><td><code>A</code><code>B</code></td></tr>
<tr><td>Similarity</td><td>scope、reference、上下限</td><td><code>scope=a</code>, <code>reference=R10</code></td></tr>
<tr><td>Window</td><td>scope、source sequences</td><td><code>scope=a</code>, 每行一个 10 nt source</td></tr>
<tr><td>Pattern</td><td>patternsscope 可空表示全局</td><td><code>AAAA, UUUU</code></td></tr>
</tbody>
</table>
<p class="warn">如果看到 “Constraint scope cannot be empty”就是当前 constraint 类型需要填写 scope但该字段为空。新版界面会在提交前拦截这类错误。</p>
</section>
<section id="soft" class="card">
<h2>4. Soft constraints 和 weights</h2>
<p>Soft constraint 不会替代 ensemble defect只是给优化目标增加加权惩罚。权重越大设计器越偏向满足它但也可能变慢。</p>
<p>Defect weights 用来告诉设计器哪些 domain、strand、complex 或 tube 更重要。初学时建议先不填,确认 target 能跑通后再逐步添加。</p>
</section>
<section id="speed" class="card">
<h2>5. 为什么 Design 会慢</h2>
<p>NUPACK design 是优化问题,不是一次性的结构分析。影响耗时的主要因素:</p>
<ul>
<li><strong>off-target max size</strong> 越大,需要考虑的非目标复合物越多。</li>
<li><strong>f_stop</strong> 越小,停止条件越严格,通常越慢。</li>
<li><strong>trials</strong> 大于 1 时会跑多个随机种子NUPACK 源码里会并行提交多个 trial。</li>
<li><strong>hard constraints</strong> 太多或互相矛盾,会反复搜索甚至失败。</li>
</ul>
<p>当前服务已显式设置 NUPACK 的 <code>config.threads</code>,不再只依赖 <code>OMP_NUM_THREADS</code>。本地 NUPACK 源码里有 <code>NUPACK_CUDA</code> 编译选项,但当前 wheel/镜像不是 CUDA 构建;直接“打开 GPU”不能生效除非重新编译 NUPACK 的 CUDA 版本并替换镜像里的 wheel。</p>
</section>
</main>
</body>
</html>