/
Methods & resultsWork summary, 29 Oct 2026

Bio warehouse: full work summary (2026-10-29)

A private, local-first biopharma data warehouse built only from primary public sources. This file records what was done, why, and what it achieved. Detailed reports are in docs/.

0. Ground rules followed throughout (from CLAUDE.md)

  • No BiopharmaWatch (BPW) data was copied; BPW was used for recon only.
  • No LLM / AI API calls.
  • Raw copies on disk: a raw copy of every payload under data/raw/ with a manifest. Every row carries source_url, fetched_at and content_hash.
  • Explicit rules: every derived value names its rule (config/*.toml; rule_version = file sha256).
  • No silent guessing: uncertain matches go to review_queue.
  • Source etiquette: documented rate limits, and the SEC User-Agent with your approved contact. Secrets live only in .env.
  • Code quality: typed Python (strict mypy), ruff and pytest, all clean at the end (22 tests).
  • Git: nothing committed (not requested).

1. Phase 1: schema + source verification (finished 2026-10-25)

  • Why: docs/schema.md had been cut off mid-write in an earlier session.
  • What:
  • Completed it from the saved findings: tables, storage layout, provenance columns, source registry (endpoints, rate limits, licences, doc URLs), residual unknowns, volumes and checkpoint decisions.
  • Marked unverified cells with †.
  • Achieved: CHECKPOINT 1. Your decisions:
  • AACT monthly.
  • Keep unknown as a state.
  • Download all raw and pilot the resolution first.
  • Combinations become their own assets.
  • Open Targets primary, ChEMBL for gaps.
  • AdCom JSON OK.

2. Phase 2: trials, entity resolution, assets, state machine

Ingest

  • CT.gov API v2: all 141,672 industry interventional trials first posted 2005 onwards, in 709 gz pages (684 MB). Later, an incremental --since pull (1,378 trials) proved weekly refresh works. build all merges every pull; older copies of a trial become history.
  • AACT: 115 monthly snapshots (2017-01 → 2026-10) via website login plus HTTP range reads of single zip members.
  • Only our trials' rows were kept (2.2 GB vs ~9 GB), because disk was only 12–14 GiB free. Full-member CRC and sha256 are recorded. You approved this deviation.
  • Parsing gotchas solved: quoted fields, the ~ newline marker, 20 months with inconsistent quoting (unquoted parse plus status validation), and a legacy column schema before Nov 2021.
  • Trial versions: 12.0M observations collapse into 434k dated versions (rule TV-1), with honest date bounds.
  • Intervention roles from arm types: investigational, background, comparator, placebo, non-drug.

Sponsors and lineage

  • Pilot: Pfizer plus 17 predecessor or spun-off companies, Ipsen (acquirer of Epizyme), Spyre (formerly Aeglea), Clovis and Carisma (formerly Eleven Bio, then Sesen).
  • Aliases come from SEC submissions (current and former names, dated) and the latest 10-K Exhibit 21 subsidiary lists. An acquired company's list is valid only until its acquisition.
  • Lineage rule L-1: the child's own SEC 8-K names the parent with merger wording. L-1b is the parent-side fallback for pre-2004 deals, and legacy 8-K item numbers are handled. Completion-language detection separates closing dates from announcements.
  • Result: 19 of 20 pilot links cited (InnoPharma stays queued). The Upjohn → Viatris alias was confirmed by you.
  • Bugs fixed along the way: dotted suffixes ("S.A."), SEC "/WA" state tags, a stale variable that disabled the subsidiary-clause rule, and lineage-chain "collisions" (the descendant wins).

Assets (identity layer)

  • Sources: the Open Targets drug parquet (19,170 drugs, CC0), plus ChEMBL exact lookups for pilot names Open Targets lacks.
  • Rules:
  • A-0: name cleaning (doses, formulations, arm prefixes, isotope labels, parenthetical codes, comma lists).
  • A-0h: a leading drug name followed only by qualifier words.
  • A-1: one Open Targets identity.
  • A-1n: tie-break by preferred name. This fixed Open Targets listing "BICALUTAMIDE" as a synonym of talazoparib.
  • A-3: sponsor-local assets for undisclosed codes.
  • A-4: otherNames union-find that refuses conflicting merges (queued instead).
  • A-5: combinations.
  • Holders (H-1): a sponsor running ≥20% of the asset's industry trials.

State machine (config/asset_state.toml)

  • Evaluated monthly from 2017, per (asset, holder) and overall. States: approved, active, out-licensed, discontinued, dormant, unknown.
  • Each row stores its rule and evidence: open trials, last activity, last stop with whyStopped text, and the other sponsor's trial for out-licensing.
  • Thresholds: 24 months quiet → dormant; 12 months after a final stop → discontinued; a recent stop holds "active" until S4 fires.
  • Spot checks matched reality:
  • danuglipron and bococizumab discontinued, with the sponsors' own words;
  • out-licensing to Axsome, Tourmaline, Cardurion, AbbVie/Cerevel and SatRx;
  • correct FDA approval dates.

3. Phase 3: regulatory, events, deals, landscape, financials

  • Regulatory:
  • Drugs@FDA flat files (194k submissions), Orange Book patents and exclusivity, Purple Book BLAs, and openFDA CRLs (458 letters, partial coverage).
  • AdCom meetings from the FDA calendar JSON plus 1,871 Federal Register notices. Reading 1,472 notice full texts ("Agenda:" paragraph only) raised drug links from 7 to 862, later 2,095.
  • The Federal Register docs page is bot-blocked, so fields were verified with a live API call.
  • Dated approvals: S1 = earliest FDA original NDA/BLA approval (generic ANDAs excluded). The Open Targets flag stays as S1b, today only.
  • OOPD: your manual export, with 8,273 orphan designations carrying real designation dates. The site is behind a gov-use banner, so it wasn't scraped.
  • Company disclosures from 1,281 8-K press-release exhibits (curated sponsors):
  • 60 PDUFA dates, as versioned chains (lorcaserin, rucaparib, encorafenib/binimetinib and Vicineum verified);
  • CRLs openFDA lacks (lorcaserin 2010, Vicineum 2021);
  • about 100 designation disclosures;
  • third-party mentions and boilerplate filtered out.
  • Deals: 152 total. Text rules over 503 8-K item 1.01/2.01 filings, plus the cited lineage acquisitions; 48 duplicate filings merged. Example: Seagen–RemeGen ($200M upfront).
  • Events: 471k, with tiers, date_basis, available_at and re-guided-date versions. 14,106 are future catalysts.
  • Landscape: Open Targets mechanisms and indications (MeSH), plus v_landscape.
  • Financials:
  • Sources: SEC XBRL companyfacts for 1,110 filers.
  • Method: ordered tag fallbacks; year-to-date figures turned into quarters; burn and runway.
  • Coverage: cash 95%, burn 91%, R&D 90%, revenue 74%. This mostly answers the open question on tag coverage; burn and R&D are a few points short of the 95% target.

4. Phase 4: UI, validation, tests, docs

  • UI: python -m bio ui, a read-only standard-library web app on port 8765. Pages: sponsors, pipelines, graveyard, asset detail with state history and evidence, trial versions, FDA decisions, catalysts, landscape, financials and the review queue.
  • Gold validation (scripts/gold_validate.py → docs/phase4-validation.md) uses facts the rules don't read:
  • G1 explicit "development discontinued" statements: 311/323 (96.3%) agree.
  • G2 Open Targets vs FDA approvals agree on 1,604 assets; the differences are explained.
  • G3 lineage dates are sane.
  • Supporting pieces: README.md, the per-phase reports, Parquet export (python -m bio export, 37 tables), scripts/phase2_stats.py, and scripts/fingerprint.py (determinism check).

5. Widening (2026-10-26, your go)

  • Sponsors: all 111,552 industry-led trials resolved.
  • S-0: 16,611 sponsors, one per exact normalised name.
  • S-4: a CIK when SEC's 1.06M-name history gives exactly one (4,001 sponsors; a sample of 40 was all correct).
  • S-5: names sharing a CIK merge, so renames are caught.
  • S-2b: "X, a Y company".
  • 457 names that map to several CIKs are queued.
  • Lineage at scale: sec-lineage-auto cited 13 more acquisitions (Genzyme → Sanofi, Karuna → BMS, Juno → Celgene and others). Conflicts are queued.
  • Assets: 34,951 assets, held by 6,889 sponsors.
  • New state rules:
  • S3g: same-group guard, so "Novartis" vs "Novartis Pharmaceuticals" isn't out-licensing.
  • S4b: the newest-started trial was stopped → discontinued. This raised G1 from 298 to 313 of 325 at the time (311/323 in the final build).
  • Performance: quadratic loops removed, and per-asset regex replaced with an n-gram NameIndex. Phase 3 now runs in about 80 s.
  • Determinism: explicit ORDER BY, min() instead of any_value(), tie-breaks, and ambiguous local aliases no longer link. Two runs give identical fingerprints.

6. Advice given (nothing built)

  • Hetzner (4 GB / 40 GB): worth it. Data is about 4 GB. Run the scheduled ingest and builds there and rsync the Parquet down. Keep the UI private (SSH tunnel or Tailscale) and lock down .env.
  • LLM via API for financial statements and WACC:
  • Feasible and cheap from the server. Use it for tag-to-statement mapping, footnotes (debt terms) and one-off normalisation.
  • Numbers come from XBRL in code. Each LLM output must cite fact IDs and pass reconciliation checks, and is logged and marked inferred.
  • WACC beta and the equity risk premium are cited config assumptions.
  • CLAUDE.md's no-LLM rule must be lifted first.

7. Commands

uv run python -m bio build all && uv run python -m bio build3     # rebuild (~13 min + ~80 s)
uv run python -m bio ui                                            # browse
uv run python -m bio export                                        # parquet
uv run python scripts/gold_validate.py                             # validation
uv run python scripts/fingerprint.py                               # determinism check

Fetchers: ctgov-pull, aact-pull, sec-pilot, sec-lineage-auto, sec-facts(-all), sec-deals, sec-press, chembl-pilot, fda-pull, fedreg-text, ot-pull.

8. Open items / your decisions

  1. SEC text mining (deals, PDUFA dates, CRLs) is still limited to the curated sponsors. Widening it means tens of thousands of 8-Ks.
  2. ChEMBL lookups are still pilot-only.
  3. Review queue: about 5,000 items (asset merges and identities, CIK collisions, uncited lineage).
  4. Possible next steps: server move; the deterministic financial-statement and WACC skeleton; an optional LLM layer; a git commit.