research-tool-cli 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.
- research_tool_cli-0.1.0/LICENSE +21 -0
- research_tool_cli-0.1.0/PKG-INFO +16 -0
- research_tool_cli-0.1.0/README.md +101 -0
- research_tool_cli-0.1.0/app/backend/_bootstrap.py +15 -0
- research_tool_cli-0.1.0/app/backend/exports/verification_script.py +19 -0
- research_tool_cli-0.1.0/app/backend/main.py +59 -0
- research_tool_cli-0.1.0/app/backend/routers/__init__.py +1 -0
- research_tool_cli-0.1.0/app/backend/routers/execution.py +478 -0
- research_tool_cli-0.1.0/app/backend/routers/ingestion.py +233 -0
- research_tool_cli-0.1.0/app/backend/routers/planning.py +265 -0
- research_tool_cli-0.1.0/app/backend/routers/reporting.py +531 -0
- research_tool_cli-0.1.0/app/backend/state.py +44 -0
- research_tool_cli-0.1.0/core/__init__.py +0 -0
- research_tool_cli-0.1.0/core/cli/__init__.py +0 -0
- research_tool_cli-0.1.0/core/cli/main.py +1705 -0
- research_tool_cli-0.1.0/core/database.py +62 -0
- research_tool_cli-0.1.0/core/ingestion/__init__.py +0 -0
- research_tool_cli-0.1.0/core/ingestion/csv_loader.py +191 -0
- research_tool_cli-0.1.0/core/ingestion/variable_classifier.py +171 -0
- research_tool_cli-0.1.0/core/masking/__init__.py +0 -0
- research_tool_cli-0.1.0/core/masking/gate.py +128 -0
- research_tool_cli-0.1.0/core/models.py +138 -0
- research_tool_cli-0.1.0/core/planning/__init__.py +0 -0
- research_tool_cli-0.1.0/core/planning/diagnostics.py +89 -0
- research_tool_cli-0.1.0/core/planning/lock.py +232 -0
- research_tool_cli-0.1.0/core/planning/study_plan.py +73 -0
- research_tool_cli-0.1.0/core/planning/test_selector.py +518 -0
- research_tool_cli-0.1.0/core/provenance/__init__.py +0 -0
- research_tool_cli-0.1.0/core/provenance/hashing.py +38 -0
- research_tool_cli-0.1.0/core/provenance/tracker.py +105 -0
- research_tool_cli-0.1.0/core/reporting/__init__.py +62 -0
- research_tool_cli-0.1.0/core/reporting/appendix.py +58 -0
- research_tool_cli-0.1.0/core/reporting/bundle.py +378 -0
- research_tool_cli-0.1.0/core/reporting/excel_export.py +683 -0
- research_tool_cli-0.1.0/core/reporting/flowchart/__init__.py +20 -0
- research_tool_cli-0.1.0/core/reporting/flowchart/flowchart.py +511 -0
- research_tool_cli-0.1.0/core/reporting/forensics.py +592 -0
- research_tool_cli-0.1.0/core/reporting/forest_plot.py +614 -0
- research_tool_cli-0.1.0/core/reporting/lineage.py +562 -0
- research_tool_cli-0.1.0/core/reporting/manuscript_draft.py +726 -0
- research_tool_cli-0.1.0/core/reporting/plots.py +568 -0
- research_tool_cli-0.1.0/core/reporting/strobe_checklist.py +460 -0
- research_tool_cli-0.1.0/core/stats/__init__.py +0 -0
- research_tool_cli-0.1.0/core/stats/descriptive.py +104 -0
- research_tool_cli-0.1.0/core/stats/inferential.py +540 -0
- research_tool_cli-0.1.0/core/stats/multiple_comparisons.py +62 -0
- research_tool_cli-0.1.0/core/stats/post_hoc.py +62 -0
- research_tool_cli-0.1.0/exports/verification_script.py +19 -0
- research_tool_cli-0.1.0/pyproject.toml +37 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/PKG-INFO +16 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/SOURCES.txt +96 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/dependency_links.txt +1 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/entry_points.txt +2 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/requires.txt +9 -0
- research_tool_cli-0.1.0/research_tool_cli.egg-info/top_level.txt +7 -0
- research_tool_cli-0.1.0/setup.cfg +4 -0
- research_tool_cli-0.1.0/tests/__init__.py +0 -0
- research_tool_cli-0.1.0/tests/conftest.py +45 -0
- research_tool_cli-0.1.0/tests/test_amendments.py +296 -0
- research_tool_cli-0.1.0/tests/test_analyze_batch_robustness.py +162 -0
- research_tool_cli-0.1.0/tests/test_app_statistical_reporting.py +383 -0
- research_tool_cli-0.1.0/tests/test_benchmark_21.py +556 -0
- research_tool_cli-0.1.0/tests/test_bundle.py +277 -0
- research_tool_cli-0.1.0/tests/test_cox_ph_plan.py +498 -0
- research_tool_cli-0.1.0/tests/test_csv_loader.py +368 -0
- research_tool_cli-0.1.0/tests/test_end_to_end.py +302 -0
- research_tool_cli-0.1.0/tests/test_excel_export.py +164 -0
- research_tool_cli-0.1.0/tests/test_flowchart.py +244 -0
- research_tool_cli-0.1.0/tests/test_forensics.py +305 -0
- research_tool_cli-0.1.0/tests/test_forest_plot.py +374 -0
- research_tool_cli-0.1.0/tests/test_from_json.py +176 -0
- research_tool_cli-0.1.0/tests/test_latest_plan_version.py +164 -0
- research_tool_cli-0.1.0/tests/test_lineage.py +329 -0
- research_tool_cli-0.1.0/tests/test_lock_immutability.py +133 -0
- research_tool_cli-0.1.0/tests/test_m1_fk_violation.py +85 -0
- research_tool_cli-0.1.0/tests/test_m2_data_hash_consistency.py +40 -0
- research_tool_cli-0.1.0/tests/test_m3_correction_timing.py +59 -0
- research_tool_cli-0.1.0/tests/test_m4_dedup_field.py +59 -0
- research_tool_cli-0.1.0/tests/test_m5_excel_hash_scope.py +45 -0
- research_tool_cli-0.1.0/tests/test_m6_fisher_exact_naming.py +44 -0
- research_tool_cli-0.1.0/tests/test_m7_duplicate_study_plan.py +55 -0
- research_tool_cli-0.1.0/tests/test_m8_filter_superseded.py +58 -0
- research_tool_cli-0.1.0/tests/test_m9_table1_groupby.py +56 -0
- research_tool_cli-0.1.0/tests/test_manuscript_draft.py +289 -0
- research_tool_cli-0.1.0/tests/test_masking_gate.py +196 -0
- research_tool_cli-0.1.0/tests/test_masking_migration.py +111 -0
- research_tool_cli-0.1.0/tests/test_multiple_comparisons.py +56 -0
- research_tool_cli-0.1.0/tests/test_plan_validation.py +289 -0
- research_tool_cli-0.1.0/tests/test_plots.py +394 -0
- research_tool_cli-0.1.0/tests/test_post_hoc_tagging.py +49 -0
- research_tool_cli-0.1.0/tests/test_posthoc_analyze.py +203 -0
- research_tool_cli-0.1.0/tests/test_provenance_tracker.py +110 -0
- research_tool_cli-0.1.0/tests/test_roadmap_features.py +148 -0
- research_tool_cli-0.1.0/tests/test_stats_descriptive.py +57 -0
- research_tool_cli-0.1.0/tests/test_stats_inferential.py +380 -0
- research_tool_cli-0.1.0/tests/test_strobe_checklist.py +172 -0
- research_tool_cli-0.1.0/tests/test_test_selector.py +350 -0
- research_tool_cli-0.1.0/tests/test_variable_classifier.py +124 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Manjunath N K
|
|
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,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: research-tool-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Retrospective clinical research tool with outcome-masking and provenance
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: pandas>=2.0
|
|
8
|
+
Requires-Dist: scipy>=1.11
|
|
9
|
+
Requires-Dist: statsmodels>=0.14
|
|
10
|
+
Requires-Dist: lifelines>=0.27
|
|
11
|
+
Requires-Dist: tableone>=0.8
|
|
12
|
+
Requires-Dist: matplotlib>=3.8
|
|
13
|
+
Requires-Dist: openpyxl>=3.1
|
|
14
|
+
Requires-Dist: fastapi>=0.141.1
|
|
15
|
+
Requires-Dist: uvicorn>=0.52.0
|
|
16
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Retrospective Clinical Research Tool
|
|
2
|
+
|
|
3
|
+
Local-first CLI and Web application that takes raw retrospective clinical study data to a STROBE-compliant manuscript draft. Built around a provenance-first, outcome-masking workflow to prevent HARKing and p-hacking.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install -e .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For development and tests, install the project environment with its dev dependencies and run pytest through that interpreter:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv sync --dev
|
|
15
|
+
.venv/bin/python -m pytest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This keeps pytest on the same Python environment as scipy, pandas, and tableone.
|
|
19
|
+
|
|
20
|
+
## Usage (CLI)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# ── Phase 1: Pre-Unmasking Protocol Specification ──────────────────────────
|
|
24
|
+
# 1. Create study
|
|
25
|
+
research-tool new-study "EMD Study"
|
|
26
|
+
|
|
27
|
+
# 2. Ingest CSV data
|
|
28
|
+
research-tool ingest <STUDY_ID> /Users/manjunathnk/Research/research-tool/synthetic_21_v2.csv
|
|
29
|
+
|
|
30
|
+
# 3. Classify variables (masks outcome variables)
|
|
31
|
+
research-tool classify-variables <STUDY_ID>
|
|
32
|
+
|
|
33
|
+
# 4. Explore baseline data (outcomes masked)
|
|
34
|
+
research-tool explore-baseline <STUDY_ID>
|
|
35
|
+
|
|
36
|
+
# 5. Declare study plan
|
|
37
|
+
research-tool plan <STUDY_ID> --type cohort --comparison "PFS by treatment arm" --outcome-var-ids "8,9" --test "8:kaplan_meier_logrank:KM PFS comparison" --cox-ph-models "pfs_multivariable:pfs_days:pfs_event:treatment_arm:age,high_risk_fish,prior_lines:Adjusted PFS model"
|
|
38
|
+
|
|
39
|
+
# 6. Lock study plan
|
|
40
|
+
research-tool lock <STUDY_ID>
|
|
41
|
+
|
|
42
|
+
# ── Phase 2: Data Unmasking & Execution ──────────────────────────────────
|
|
43
|
+
# 7. Unmask outcome data
|
|
44
|
+
research-tool unmask <STUDY_ID>
|
|
45
|
+
|
|
46
|
+
# 8. Run analyses
|
|
47
|
+
research-tool analyze <STUDY_ID> --force
|
|
48
|
+
|
|
49
|
+
# ── Phase 3: Visualizations & Tables ──────────────────────────────────────
|
|
50
|
+
# 9. Table 1 (baseline characteristics)
|
|
51
|
+
research-tool table1 <STUDY_ID>
|
|
52
|
+
|
|
53
|
+
# 10. Kaplan-Meier plot (requires test_id, e.g. 1)
|
|
54
|
+
research-tool plot-km <STUDY_ID> 1
|
|
55
|
+
|
|
56
|
+
# 11. Forest plot (SVG & ASCII)
|
|
57
|
+
research-tool plot-forest <STUDY_ID>
|
|
58
|
+
research-tool plot-forest <STUDY_ID> --ascii
|
|
59
|
+
|
|
60
|
+
# 12. CONSORT flowchart
|
|
61
|
+
research-tool flowchart <STUDY_ID>
|
|
62
|
+
|
|
63
|
+
# ── Phase 4: Compliance & Reporting ───────────────────────────────────────
|
|
64
|
+
# 13. STROBE checklist audit
|
|
65
|
+
research-tool strobe-check <STUDY_ID>
|
|
66
|
+
|
|
67
|
+
# 14. Manuscript draft
|
|
68
|
+
research-tool draft <STUDY_ID>
|
|
69
|
+
|
|
70
|
+
# 15. Provenance lineage DAG
|
|
71
|
+
research-tool lineage <STUDY_ID>
|
|
72
|
+
|
|
73
|
+
# 16. Data forensics
|
|
74
|
+
research-tool forensics <STUDY_ID>
|
|
75
|
+
|
|
76
|
+
# 17. Reviewer JSON export
|
|
77
|
+
research-tool export <STUDY_ID>
|
|
78
|
+
|
|
79
|
+
# ── Phase 5: Bundling, Excel Export & Verification ───────────────────────
|
|
80
|
+
# 18. Create hash-verified bundle archive (generates manifest & composite SHA-256)
|
|
81
|
+
research-tool bundle <STUDY_ID>
|
|
82
|
+
|
|
83
|
+
# 19. Export Excel report (reads bundle manifest & populates composite hash on Tab 4)
|
|
84
|
+
research-tool export-excel <STUDY_ID>
|
|
85
|
+
|
|
86
|
+
# 20. Verify bundle integrity
|
|
87
|
+
research-tool verify-bundle data/studies/<STUDY_ID>/<STUDY_ID>_bundle.tar.gz
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> **Note:** Variable IDs are auto-assigned per-study at ingest time and are **not predictable**. Always run `list-variables` after `classify-variables` to get the correct IDs for `--outcome-var-ids`.
|
|
91
|
+
|
|
92
|
+
See `research-tool --help` and `app/README.md` for web interface instructions.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Authors & Acknowledgments
|
|
97
|
+
|
|
98
|
+
- **Lead Maintainer**: [Manjunath N K](https://github.com/nkmanjunath)
|
|
99
|
+
- **AI Pair Programming & Collaboration**:
|
|
100
|
+
- **Google Antigravity (AGY)** — Pair Programming, 4-Gate Diagnostics & UI/UX design.
|
|
101
|
+
- **OpenCode** — Statistical engine verification & benchmarking fixtures.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Backend bootstrap module.
|
|
3
|
+
Ensures repository root and backend directory are registered in sys.path.
|
|
4
|
+
Exposes BACKEND_DIR and REPO_ROOT paths.
|
|
5
|
+
"""
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
BACKEND_DIR = Path(__file__).resolve().parent
|
|
10
|
+
REPO_ROOT = BACKEND_DIR.parent.parent
|
|
11
|
+
|
|
12
|
+
if str(REPO_ROOT) not in sys.path:
|
|
13
|
+
sys.path.insert(0, str(REPO_ROOT))
|
|
14
|
+
if str(BACKEND_DIR) not in sys.path:
|
|
15
|
+
sys.path.insert(0, str(BACKEND_DIR))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Standalone audit-binder verification script.
|
|
3
|
+
Checks (per DECISIONS.md §7.2):
|
|
4
|
+
1. Hash-chain integrity: H0 -> H1[-> Hn] -> Hexec unbroken.
|
|
5
|
+
2. Protocol audit: no post-hoc parameter changes between lock and execution.
|
|
6
|
+
3. Deterministic re-fit within a relative tolerance of ~1e-4.
|
|
7
|
+
"""
|
|
8
|
+
import json, hashlib, sys
|
|
9
|
+
|
|
10
|
+
def check_chain(manifest):
|
|
11
|
+
print("Checking hash chain...")
|
|
12
|
+
print(f" H0 = {manifest['h0']}")
|
|
13
|
+
print(f" H1..Hn = {manifest['plan_chain']}")
|
|
14
|
+
print(f" Hexec = {manifest['hexec']}")
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
with open("manifest.json") as f:
|
|
18
|
+
m = json.load(f)
|
|
19
|
+
check_chain(m)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Sandbox-to-Vault app — FastAPI backend.
|
|
3
|
+
localhost only. Phase 1 = Tab 1, Tab 2, Tab 3, & Tab 4 wired live.
|
|
4
|
+
"""
|
|
5
|
+
from _bootstrap import BACKEND_DIR, REPO_ROOT # noqa: F401
|
|
6
|
+
|
|
7
|
+
from fastapi import FastAPI
|
|
8
|
+
from fastapi.staticfiles import StaticFiles
|
|
9
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
10
|
+
|
|
11
|
+
from routers import ingestion, planning, execution, reporting
|
|
12
|
+
|
|
13
|
+
tags_metadata = [
|
|
14
|
+
{
|
|
15
|
+
"name": "Ingestion (Tab 1)",
|
|
16
|
+
"description": "Blinded dataset upload, schema mapping, sentinel configuration, and Stage 1 (H0) protocol vaulting.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Planning (Tab 2)",
|
|
20
|
+
"description": "Socratic Wizard for pre-registering exposure, confounders, missing-data strategy, live EPV calculations, and Stage 2 (H1) protocol lock.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Execution (Tab 3)",
|
|
24
|
+
"description": "Unattended statistical execution (Logistic / Cox PH), 4 diagnostic gates (Separation, VIF, Proportional Hazards, Linearity), and Autopsy Canvas remediation routing.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Reporting (Tab 4)",
|
|
28
|
+
"description": "Journal-ready manuscript assets (Table 1 Baseline Balance with SMD, Table 2 Primary Effect Estimates, Interactive SVG Forest Plots, STROBE Checklists, Cryptographic Audit Binder).",
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
app = FastAPI(
|
|
33
|
+
title="Clinical Research Tool — Sandbox-to-Vault Engine",
|
|
34
|
+
description="Publication-grade, audit-sealed epidemiological and clinical trial analytical framework.",
|
|
35
|
+
version="1.2.0-strobe-default",
|
|
36
|
+
openapi_tags=tags_metadata,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# CORS middleware for local SPA
|
|
40
|
+
app.add_middleware(
|
|
41
|
+
CORSMiddleware,
|
|
42
|
+
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173", "http://localhost:8000"],
|
|
43
|
+
allow_methods=["*"],
|
|
44
|
+
allow_headers=["*"],
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
app.include_router(ingestion.router, prefix="/api/ingest", tags=["Ingestion (Tab 1)"])
|
|
48
|
+
app.include_router(planning.router, prefix="/api/plan", tags=["Planning (Tab 2)"])
|
|
49
|
+
app.include_router(execution.router, prefix="/api/execute", tags=["Execution (Tab 3)"])
|
|
50
|
+
app.include_router(reporting.router, prefix="/api/report", tags=["Reporting (Tab 4)"])
|
|
51
|
+
|
|
52
|
+
# Serve exports directory for HTML/SVG asset viewing
|
|
53
|
+
exports_dir = REPO_ROOT / "exports"
|
|
54
|
+
exports_dir.mkdir(exist_ok=True)
|
|
55
|
+
app.mount("/exports", StaticFiles(directory=str(exports_dir)), name="exports")
|
|
56
|
+
|
|
57
|
+
# Serve the vanilla JS SPA
|
|
58
|
+
frontend_dir = BACKEND_DIR.parent / "frontend"
|
|
59
|
+
app.mount("/", StaticFiles(directory=str(frontend_dir), html=True), name="frontend")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Routers package for research-tool backend API."""
|