-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLAUDE.html
More file actions
108 lines (85 loc) · 10.5 KB
/
CLAUDE.html
File metadata and controls
108 lines (85 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en-US"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>CLAUDE.md • mrgsolve</title><script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet"><link href="deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet"><script src="deps/headroom-0.11.0/headroom.min.js"></script><script src="deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="deps/search-1.0.0/fuse.min.js"></script><script src="deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="pkgdown.js"></script><meta property="og:title" content="CLAUDE.md"></head><body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">
<a class="navbar-brand me-2" href="index.html">mrgsolve</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.0.1</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto"><li class="nav-item"><a class="nav-link" href="articles/mrgsolve.html">Get started</a></li>
<li class="nav-item"><a class="nav-link" href="reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><a class="dropdown-item" href="articles/extra/dollar-pred.html">Models without compartments</a></li>
<li><a class="dropdown-item" href="articles/extra/events.html">Event objects</a></li>
<li><a class="dropdown-item" href="articles/extra/init.html">Set initial conditions</a></li>
<li><a class="dropdown-item" href="articles/extra/modeled-event-time.html">Modeled events</a></li>
<li><a class="dropdown-item" href="articles/extra/steady-state.html">Steady-state</a></li>
<li><a class="dropdown-item" href="articles/extra/time-after-dose.html">Time after dose</a></li>
</ul></li>
<li class="nav-item"><a class="nav-link" href="news/index.html">Changelog</a></li>
</ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
<input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/metrumresearchgroup/mrgsolve/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
</ul></div>
</div>
</nav><div class="container template-title-body">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<h1>CLAUDE.md</h1>
<small class="dont-index">Source: <a href="https://github.com/metrumresearchgroup/mrgsolve/blob/HEAD/CLAUDE.md" class="external-link"><code>CLAUDE.md</code></a></small>
</div>
<div id="claudemd" class="section level1">
<p>This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.</p>
<div class="section level2">
<h2 id="what-this-is">What this is<a class="anchor" aria-label="anchor" href="#what-this-is"></a></h2>
<p><code>mrgsolve</code> is an R package for pharmacokinetic/pharmacodynamic (PK/PD) simulation from ODE-based models. Users write models in a domain-specific language (DSL) embedded in <code>.cpp</code> or text files, which are parsed, compiled to C++ shared objects, and executed via a LSODA ODE solver.</p>
</div>
<div class="section level2">
<h2 id="common-commands">Common commands<a class="anchor" aria-label="anchor" href="#common-commands"></a></h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">make</span> doc <span class="co"># Regenerate documentation (roxygen2)</span></span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a><span class="fu">make</span> build <span class="co"># Build package tarball</span></span>
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a><span class="fu">make</span> install <span class="co"># Install to ~/Rlibs</span></span>
<span id="cb1-4"><a href="#cb1-4" tabindex="-1"></a><span class="fu">make</span> check <span class="co"># Full check: clean + doc + build + R CMD check + unit tests</span></span>
<span id="cb1-5"><a href="#cb1-5" tabindex="-1"></a><span class="fu">make</span> just-check <span class="co"># Faster check: no tests, no manual</span></span>
<span id="cb1-6"><a href="#cb1-6" tabindex="-1"></a><span class="fu">make</span> unit <span class="co"># Run unit tests in inst/maintenance/unit/</span></span>
<span id="cb1-7"><a href="#cb1-7" tabindex="-1"></a><span class="fu">make</span> test-cpp <span class="co"># Run C++ unit tests in inst/maintenance/unit-cpp/</span></span>
<span id="cb1-8"><a href="#cb1-8" tabindex="-1"></a><span class="fu">make</span> test-all <span class="co"># Run all tests (requires installed package)</span></span>
<span id="cb1-9"><a href="#cb1-9" tabindex="-1"></a><span class="fu">make</span> ci <span class="co"># CI workflow: build + --as-cran check + unit tests</span></span>
<span id="cb1-10"><a href="#cb1-10" tabindex="-1"></a><span class="fu">make</span> house <span class="co"># Rebuild internal model library (inst/base/)</span></span>
<span id="cb1-11"><a href="#cb1-11" tabindex="-1"></a><span class="fu">make</span> clean <span class="co"># Remove build artifacts</span></span></code></pre></div>
<p>Run a single test file:</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu">testthat</span><span class="fu">::</span><span class="fu"><a href="https://testthat.r-lib.org/reference/test_file.html" class="external-link">test_file</a></span><span class="op">(</span><span class="st">"tests/testthat/test-foo.R"</span><span class="op">)</span></span></code></pre></div>
<p>Set <code>_MRGSOLVE_SKIP_MODLIB_BUILD_=yes</code> (already in Makefile) to skip rebuilding the built-in model library during development.</p>
</div>
<div class="section level2">
<h2 id="architecture">Architecture<a class="anchor" aria-label="anchor" href="#architecture"></a></h2>
<p>The package has two layers:</p>
<p><strong>R layer</strong> — user-facing API in <code>R/</code>. Key files: - <code>mread.R</code> / <code>compile.R</code> — parse DSL blocks, generate C++ code, invoke compiler - <code>class_mrgmod.R</code> — S4 <code>mrgmod</code> class (compiled model object with parameters, compartments, init conditions) - <code>class_mrgsims.R</code> — S4 <code>mrgsims</code> class (simulation output, data frame + metadata) - <code>class_ev.R</code> — S4 <code>ev</code> class (dosing/event specs with dplyr verb support) - <code>mrgsim*.R</code> — simulation runner functions - <code>modspec.R</code> — DSL block parsing - <code>matlist.R</code> — <code>omegalist</code>/<code>sigmalist</code> matrix containers for OMEGA/SIGMA</p>
<p><strong>C++ layer</strong> — simulation engine in <code>src/</code>: - <code>mrgsolve.cpp</code> — main solver loop, R↔︎C++ integration via Rcpp - <code>LSODA.cpp/h</code> — ODE solver - <code>odeproblem.cpp</code> — ODE system definition - <code>dataobject.cpp</code> / <code>datarecord.cpp</code> — data record management - <code>dsl-preprocess.cpp</code> — DSL preprocessing (fortran-style → C++ syntax) - <code>RcppExports.cpp</code> — auto-generated Rcpp bindings (do not edit manually)</p>
<p><strong>Model DSL</strong> — users write models with blocks like <code>$PARAM</code>, <code>$ODE</code>, <code>$TABLE</code>, <code>$MAIN</code>, <code>$OMEGA</code>, <code>$SIGMA</code>, <code>$CAPTURE</code>, <code>$PLUGIN</code>, etc. <code>compile.R</code> generates C++ from these blocks. Built-in model examples live in <code>inst/base/</code> (built by <code>inst/maintenance/build_housemodel.R</code>).</p>
<p><strong>Tests</strong> — <code>tests/testthat/</code> (~60 files) for package-level tests; <code>inst/maintenance/unit/</code> for unit tests; <code>inst/maintenance/unit-cpp/</code> for C++ layer tests.</p>
</div>
<div class="section level2">
<h2 id="important-conventions">Important conventions<a class="anchor" aria-label="anchor" href="#important-conventions"></a></h2>
<ul><li>
<code>Collate:</code> in <code>DESCRIPTION</code> controls R source load order — required for S4 class definitions to load before methods. Run <code>make doc</code> (roxygen2) to keep it current.</li>
<li>
<code>RcppExports.cpp</code> and <code>R/RcppExports.R</code> are auto-generated by <code><a href="https://rdrr.io/pkg/Rcpp/man/compileAttributes.html" class="external-link">Rcpp::compileAttributes()</a></code> — do not edit manually.</li>
<li>The <code>_MRGSOLVE_SKIP_MODLIB_BUILD_</code> env var controls whether <code>make house</code> runs during check; set to <code>no</code> for CRAN submissions.</li>
<li>Random effect parameters are named <code>ETA(n)</code> and residual error <code>EPS(n)</code> in model code — these are reserved.</li>
</ul></div>
</div>
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
</nav></aside></div>
<footer><div class="pkgdown-footer-left">
<p>Developed by Kyle T Baron.</p>
</div>
<div class="pkgdown-footer-right">
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.2.0.</p>
</div>
</footer></div>
</body></html>