vibepaper 0.1.0__tar.gz

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.
@@ -0,0 +1,208 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+ /.idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ACRF Cancer Genomics Facility
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: vibepaper
3
+ Version: 0.1.0
4
+ Summary: Data-bound Markdown-to-Word builder for scientific papers
5
+ Project-URL: Repository, https://github.com/PLACEHOLDER/vibepaper
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: jinja2,manuscript,markdown,pandoc,paper,reproducible-research,scientific-writing
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Topic :: Text Processing :: General
18
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: jinja2>=3.0
21
+ Requires-Dist: lxml>=4.0
22
+ Requires-Dist: pandas>=1.3
23
+ Requires-Dist: pyyaml>=6.0
24
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # vibepaper
28
+
29
+ Build scientific papers from Markdown where every number traces back to the analysis that produced it.
30
+
31
+ ## The problem
32
+
33
+ Numbers in scientific prose go stale. You finish the analysis, write up the results, and six months later a reviewer asks you to rerun with a corrected dataset. Now you have updated CSVs and a paper full of hardcoded figures: "the mean increased from 4.6 to 9.2", "of the 7,318 variants that lost HIGH impact". Finding every number, checking which is still current, updating without introducing new errors — this is tedious, error-prone, and nearly impossible to review.
34
+
35
+ ## The solution
36
+
37
+ vibepaper separates computation from communication. Analysis scripts write their key results to named CSV files. The paper references those values by name using Jinja2 template syntax. The build pipeline substitutes every reference before passing the document to pandoc for final Word output.
38
+
39
+ ```markdown
40
+ Mean transcripts per variant doubled from
41
+ {{ vep_impact.giab_mean_v112 | dp(1) }} to
42
+ {{ vep_impact.giab_mean_v115_full | dp(1) }} on upgrading to Ensembl v115.
43
+ ```
44
+
45
+ When you rerun the analysis, you rerun the build. The numbers update everywhere, simultaneously, with a loud error if any reference is missing.
46
+
47
+ **Three design principles:**
48
+
49
+ 1. **Templates express intent; scripts express computation.** No arithmetic in templates. If you need a percentage increase, the analysis script computes and writes it. The template formats it.
50
+ 2. **Loud failures over silent omissions.** A missing or renamed CSV column is a build error, not an empty string in the output.
51
+ 3. **Every number is traceable.** Any figure in the rendered paper can be grepped back to the template reference and the script that wrote the CSV.
52
+
53
+ ---
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install vibepaper
59
+ ```
60
+
61
+ Requires [pandoc](https://pandoc.org/installing.html) as a system dependency:
62
+
63
+ ```bash
64
+ # macOS
65
+ brew install pandoc
66
+
67
+ # Debian/Ubuntu
68
+ sudo apt-get install pandoc
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Quick start
74
+
75
+ ### Option 1 — paper.toml (recommended for full papers)
76
+
77
+ Create `paper.toml` in your project root:
78
+
79
+ ```toml
80
+ [paper]
81
+ sections = [
82
+ "paper/abstract.md",
83
+ "paper/introduction.md",
84
+ "paper/methods.md",
85
+ "paper/results.md",
86
+ "paper/discussion.md",
87
+ "paper/references.md",
88
+ "paper/figures.md",
89
+ ]
90
+ supplementary = ["paper/supplementary.md"]
91
+ name = "my_paper"
92
+ ```
93
+
94
+ Then build:
95
+
96
+ ```bash
97
+ vibepaper
98
+ # outputs: output/my_paper_2025-06-01.docx
99
+ # output/my_paper_supplementary_2025-06-01.docx
100
+ ```
101
+
102
+ ### Option 2 — sections file
103
+
104
+ Create a plain text file listing your sections in order:
105
+
106
+ ```
107
+ # order.txt
108
+ paper/abstract.md
109
+ paper/methods.md
110
+ paper/results.md
111
+ paper/discussion.md
112
+ ```
113
+
114
+ Then:
115
+
116
+ ```bash
117
+ vibepaper --sections-file order.txt --name my_paper
118
+ ```
119
+
120
+ Lines starting with `#` and blank lines are ignored. Paths are relative to the sections file's location.
121
+
122
+ ### Option 3 — direct file list
123
+
124
+ ```bash
125
+ vibepaper paper/abstract.md paper/results.md paper/discussion.md --name my_paper
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Template syntax
131
+
132
+ vibepaper uses [Jinja2](https://jinja.palletsprojects.com/) for template substitution. References follow the pattern `{{ namespace.field | filter }}`.
133
+
134
+ ### Number formatting filters
135
+
136
+ | Filter | Example | Output |
137
+ |---|---|---|
138
+ | `\| commas` | `{{ n \| commas }}` | `254,129` |
139
+ | `\| dp(n)` | `{{ mean \| dp(1) }}` | `9.2` |
140
+ | `\| pct(n)` | `{{ rate \| pct(1) }}` | `52.2%` |
141
+ | `\| fold(n)` | `{{ ratio \| fold(1) }}` | `2.0-fold` |
142
+ | `\| fmt(spec)` | `{{ v \| fmt('+.1f') }}` | `+3.7` |
143
+
144
+ `dp` (decimal places) is for numbers that will have surrounding text (e.g. "mean TPV was 9.2"). `pct` appends the `%` sign. Use `fmt` for any format string Python's `format()` accepts.
145
+
146
+ ### Examples
147
+
148
+ ```markdown
149
+ Of {{ clinvar.total_variants | commas }} ClinVar variants, {{ clinvar.gained_high_count | commas }}
150
+ ({{ clinvar.gained_high_pct | dp(2) }}%) gained HIGH impact on upgrading to v115.
151
+
152
+ Mean transcripts per variant increased {{ vep.mean_fold | fold }} from
153
+ {{ vep.mean_v112 | dp(1) }} to {{ vep.mean_v115 | dp(1) }}.
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Data sources
159
+
160
+ ### Facts CSVs (primary)
161
+
162
+ The main data binding mechanism. Analysis scripts write **1-row CSVs** to `output/facts/`. The filename stem becomes the template namespace; column names become field names.
163
+
164
+ ```
165
+ output/facts/
166
+ transcript_growth.csv → {{ transcript_growth.v112_count | commas }}
167
+ vep_impact.csv → {{ vep_impact.giab_mean_v115_full | dp(1) }}
168
+ clinvar_reclassification.csv → {{ clinvar_reclassification.total_variants | commas }}
169
+ ```
170
+
171
+ A CSV named `transcript_growth.csv` with columns `v112_count, v115_count`:
172
+
173
+ ```csv
174
+ v112_count,v115_count
175
+ 254129,509650
176
+ ```
177
+
178
+ Is referenced as:
179
+
180
+ ```markdown
181
+ Transcripts grew from {{ transcript_growth.v112_count | commas }}
182
+ to {{ transcript_growth.v115_count | commas }}.
183
+ ```
184
+
185
+ vibepaper raises a hard error if a referenced column doesn't exist. It warns if the rendered output contains literal `nan`, `None`, or unresolved `{{`.
186
+
187
+ ### JSON data (supplemental)
188
+
189
+ Pass additional values directly without creating a CSV file:
190
+
191
+ ```bash
192
+ # Inline dict
193
+ vibepaper --data '{"cohort_size": 412, "stats": {"pvalue": 0.003}}'
194
+
195
+ # From file
196
+ vibepaper --data results.json
197
+ ```
198
+
199
+ Top-level keys become namespaces:
200
+
201
+ ```markdown
202
+ Cohort: {{ cohort_size }} participants (p = {{ stats.pvalue | dp(3) }}).
203
+ ```
204
+
205
+ JSON is merged on top of facts CSVs. Nested dicts are deep-merged at the namespace level; scalar values override directly.
206
+
207
+ ---
208
+
209
+ ## Table directives
210
+
211
+ For supplementary tables, embed CSVs directly into the Markdown with a directive comment:
212
+
213
+ ```markdown
214
+ <!-- include-csv: output/consequence_changes.csv
215
+ columns: [consequence, v112_count, v115_count, pct_change]
216
+ rename:
217
+ v112_count: v112
218
+ v115_count: v115
219
+ pct_change: Change (%)
220
+ format:
221
+ v112_count: ",d"
222
+ v115_count: ",d"
223
+ pct_change: ".1f"
224
+ sort: [-pct_change]
225
+ max_rows: 20
226
+ -->
227
+ ```
228
+
229
+ Directive options:
230
+
231
+ | Option | Description |
232
+ |---|---|
233
+ | `columns` | List of columns to include, in order |
234
+ | `rename` | Dict mapping column names to display names |
235
+ | `format` | Dict mapping column names to Python format specs |
236
+ | `align` | `left`, `right`, `center`, or per-column dict |
237
+ | `sort` | List of column names; prefix `-` for descending |
238
+ | `filter` | pandas `query()` expression |
239
+ | `max_rows` | Truncate to this many rows |
240
+ | `na_rep` | String to use for missing values (default: `—`) |
241
+
242
+ ---
243
+
244
+ ## paper.toml reference
245
+
246
+ ```toml
247
+ [paper]
248
+ # Manuscript sections in order (paths relative to paper.toml)
249
+ sections = [
250
+ "paper/title.md",
251
+ "paper/abstract.md",
252
+ "paper/introduction.md",
253
+ "paper/methods.md",
254
+ "paper/results.md",
255
+ "paper/discussion.md",
256
+ "paper/references.md",
257
+ "paper/figures.md",
258
+ ]
259
+
260
+ # Built as a separate .docx unless --combined is passed
261
+ supplementary = ["paper/supplementary.md"]
262
+
263
+ # Output filename stem: {name}_{date}.docx
264
+ # Default: parent directory name
265
+ name = "my_paper"
266
+
267
+ # Directory of 1-row facts CSVs
268
+ # Default: "output/facts"
269
+ facts_dir = "output/facts"
270
+
271
+ # Output directory for .docx files
272
+ # Default: "output"
273
+ output_dir = "output"
274
+
275
+ # Intermediate build directory
276
+ # Default: "build"
277
+ build_dir = "build"
278
+
279
+ # Word reference document for custom formatting (double spacing, line numbers, etc.)
280
+ # Only used if the file exists; silently skipped otherwise.
281
+ # Default: "paper/reference.docx"
282
+ reference_doc = "paper/reference.docx"
283
+ ```
284
+
285
+ ### Word reference document
286
+
287
+ To apply journal-specific formatting (e.g. double line spacing, continuous line numbering):
288
+
289
+ 1. Open a blank Word document
290
+ 2. Set paragraph spacing to Double and enable Layout → Line Numbers → Continuous
291
+ 3. Save as `paper/reference.docx`
292
+
293
+ vibepaper will use it automatically if it exists at the configured path.
294
+
295
+ ---
296
+
297
+ ## CLI reference
298
+
299
+ ```
300
+ vibepaper [FILE.md ...] [options]
301
+
302
+ Input (choose one):
303
+ FILE.md ... Markdown files in order (no paper.toml needed)
304
+ --sections-file FILE Plain text file with one .md path per line
305
+ --config FILE paper.toml config file (default: paper.toml)
306
+
307
+ Data:
308
+ --data JSON JSON file path or inline dict for template context
309
+ --facts-dir DIR Override facts CSV directory
310
+
311
+ Output:
312
+ --output-dir DIR Output directory for .docx files
313
+ --name NAME Output filename stem
314
+ --combined Merge supplementary into main document
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Project layout convention
320
+
321
+ ```
322
+ my_paper/
323
+ ├── paper.toml
324
+ ├── paper/
325
+ │ ├── abstract.md
326
+ │ ├── introduction.md
327
+ │ ├── methods.md
328
+ │ ├── results.md
329
+ │ ├── discussion.md
330
+ │ ├── references.md
331
+ │ ├── figures.md
332
+ │ ├── supplementary.md
333
+ │ └── reference.docx ← optional Word formatting template
334
+ ├── output/
335
+ │ ├── facts/
336
+ │ │ ├── cohort.csv ← 1-row: n_patients, n_controls, ...
337
+ │ │ ├── model_results.csv ← 1-row: auc, pvalue, effect_size, ...
338
+ │ │ └── ...
339
+ │ └── tables/
340
+ │ └── full_results.csv ← multi-row: used in include-csv directives
341
+ └── scripts/
342
+ └── run_analysis.py ← writes to output/facts/
343
+ ```