Skip to content

Add analysis/replicate.sh — single-command driver for the primary analysis#1

Merged
ppavlidis merged 1 commit into
mainfrom
add-original-analysis-replicate-sh
Jun 4, 2026
Merged

Add analysis/replicate.sh — single-command driver for the primary analysis#1
ppavlidis merged 1 commit into
mainfrom
add-original-analysis-replicate-sh

Conversation

@ppavlidis

Copy link
Copy Markdown
Contributor

Summary

Adds analysis/replicate.sh, a single-command driver for the original-submission pipeline. It mirrors the layout of revisions/replicate.sh (phases, DRY_RUN, PHASES filter, Keychain-based key resolution) but drives the scripts under analysis/strains/ (00–04) and analysis/cell_lines/ (00–07), preceded by the shared analysis/_downloads/download.R.

  • Phases: keysdownloadsstrainscells.
  • OPENAI_API_KEY resolves from the macOS Keychain, then a pre-set env var, then ~/openai/access_key.txt (the existing inst/gpt.py already supports the file path).
  • The 02 / 05 R scripts that submit OpenAI Batch jobs already block on completion via R/run_batches.R, so the bash driver does not need its own poll loop.
  • Kept deliberately separate from revisions/replicate.sh so the original and revision-round drivers do not drift.

Test plan

  • DRY_RUN=1 ./analysis/replicate.sh prints the full ordered command list across all four phases.
  • Live run on a fresh checkout (Keychain entry present) reproduces data-raw/strain_data/main_frame.rds and data-raw/cell_line_data/cell_line_inputs_second_pass.rds from a cold start.

🤖 Generated with Claude Code

…lysis

Mirrors the revisions/replicate.sh layout (phases + DRY_RUN + PHASES filter)
but drives the original-submission pipeline under analysis/strains/ (00–04)
and analysis/cell_lines/ (00–07), via the shared analysis/_downloads/
download. OPENAI_API_KEY is resolved from the macOS Keychain with
~/openai/access_key.txt and pre-set env var as fallbacks (inst/gpt.py
already supports the file path). The 02 / 05 R scripts that issue OpenAI
Batch jobs already block on completion via R/run_batches.R, so the bash
driver does not need a poll loop of its own.

Smoke-tested under DRY_RUN=1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ppavlidis ppavlidis requested a review from oganm May 25, 2026 22:24
@ppavlidis ppavlidis requested a review from Copilot June 4, 2026 23:35
@ppavlidis ppavlidis merged commit c826321 into main Jun 4, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new top-level driver script (analysis/replicate.sh) intended to run the “primary/original-submission” analysis pipeline end-to-end from the repo root, including key verification, shared downloads, strain pipeline, and cell-line pipeline.

Changes:

  • Introduces analysis/replicate.sh with phase-based execution (keys, downloads, strains, cells) and a PHASES filter.
  • Adds a DRY_RUN mode to print the ordered command list instead of executing.
  • Implements a macOS Keychain helper for resolving an OpenAI key into OPENAI_API_KEY.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread analysis/replicate.sh
Comment on lines +2 to +5
# replicate.sh — single-command end-to-end replication of the *primary*
# analysis (the one reported in the original submission). This is kept
# separate from revisions/replicate.sh, which drives the revision-round
# pipeline. Run from the repository root.
Comment thread analysis/replicate.sh
Comment on lines +55 to +61
run() {
if [[ "${DRY_RUN:-0}" == "1" ]]; then
printf " [dry-run] %s\n" "$*"
else
printf " [run] %s\n" "$*"
eval "$@"
fi
Comment thread analysis/replicate.sh
Comment on lines +99 to +116
# keys: ensure the OpenAI key is reachable. inst/gpt.py reads (in order)
# ~/openai/access_key.txt, then OPENAI_API_KEY env. We resolve from
# Keychain into OPENAI_API_KEY when neither is already set.
# ---------------------------------------------------------------------------
verify_keys() {
if [[ "${DRY_RUN:-0}" == "1" ]]; then
printf " [dry-run] resolve OPENAI_API_KEY (Keychain / env / ~/openai/access_key.txt)\n"
return
fi
if keychain_export OPENAI_API_KEY \
"${OPENAI_KEYCHAIN_ENTRY:-}" \
"OPENAI_API_KEY" "openai" "OpenAI" "openai-api-key"; then
echo " ok: OPENAI_API_KEY resolved"
return
fi
if [[ -f "$HOME/openai/access_key.txt" ]]; then
echo " ok: ~/openai/access_key.txt present (inst/gpt.py will read it)"
return
Comment thread analysis/replicate.sh
ANA="$REPO_ROOT/analysis"
RSCRIPT="${RSCRIPT:-Rscript}"

PHASES="${PHASES:-keys,downloads,strains,cells}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants