Skip to content

timjm25/CPPCQAModeler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPP-CQA Relationship Modeler

License: MIT Python Flask Domain Tests Framework

Models CPP to CQA relationships for core MSAT process development and technology transfer. Quantifies relationship strength, direction, mechanism, and evidence level per ICH Q8(R2) Design Space methodology. Generates risk-weighted Tech Transfer Risk Scores to prioritise DoE studies and control strategy documentation before site transfer.


The Problem

In pharmaceutical MSAT (Manufacturing Science and Technology), understanding which Critical Process Parameters (CPPs) drive which Critical Quality Attributes (CQAs) is the foundation of:

  • ICH Q8(R2) Design Space — multivariate CPP-CQA characterisation to define proven acceptable ranges
  • Control Strategy (CTD 3.2.P.2.3 / 3.2.S.2.6) — per-unit-operation control requirements linked to CQA risk
  • Technology Transfer — identifying which CPP-CQA links are under-characterised and pose receiving-site risk
  • Process Development — prioritising DoE studies based on strength and risk of each CPP-CQA relationship

CPP-CQA Relationship Modeler maps all CPP → CQA linkages across programs, quantifies each relationship by strength (0–1), direction (positive/negative/optimal-range/complex), mechanism (cell physiology, protein chemistry, separation science, etc.), and evidence level (Level 1 DoE through Level 4 mechanistic model) — then computes a weighted Tech Transfer Risk Score to drive action.


What It Does

1. CPP-CQA Relationship Mapping — Per program, per unit operation:

Relationship Field Values Implication
Strength 0.0 – 1.0 Probability of CQA failure on CPP excursion
Direction Positive / Negative / Optimal Range / Complex Process behaviour shape
Mechanism Cell Physiology / Protein Chemistry / Glycosylation / Separation Science / Chemical Reaction / Physical Processing Mechanistic basis
Evidence Level Level 1 (DoE) → Level 4 (Mechanistic) Regulatory defensibility

2. Relationship Strength Classification — ICH Q8(R2)-aligned:

Strength Category Action
≥ 0.75 Strong Mandatory Level 1 DoE; NOR/PAR must be established
0.55 – 0.74 Moderate Level 2 OFAT studies; enhanced in-process control
< 0.55 Weak Platform data may suffice; routine CPV monitoring

3. Tech Transfer Risk Score — Weighted composite (0–100%):

  • High-risk links score 1.0 × strength, Medium-risk 0.5 × strength, Low-risk 0.0 × strength
  • Normalised to total relationship strength across the program
Score Verdict Action
≥ 70% High Risk Halt transfer — upgrade evidence for all Strong links
40–69% Medium Risk Transfer with enhanced monitoring
< 40% Low Risk Standard CPV per ICH Q10

4. CQA Sensitivity Profiles — Per CQA across all unit operations:

  • Number of CPPs affecting the attribute
  • Count of strong links and high-risk links
  • Average relationship strength → High / Medium / Low sensitivity verdict
  • Control strategy recommendation per ICH Q8(R2)/Q10

5. CPP Reach Analysis — Per parameter:

  • How many CQAs the CPP influences (reach breadth)
  • Maximum relationship strength to any CQA
  • Top risk level — drives prioritisation of NOR tightening at receiving site

6. Critical Links — Strong (≥0.75) + High-risk links listed with:

  • Specific required action (Level 1 DoE, comparability runs, enhanced monitoring)
  • Mechanistic rationale from DoE/OFAT study notes
  • ICH Q8(R2) / Q10 / Q11 regulatory reference

7. REST API — Full JSON API for integration with LIMS, ELN, or QMS


Architecture

CPPCQAModeler/
│
├── cppcqa/
│   ├── app.py        # Flask factory — web UI + REST API (port 5091)
│   ├── modeler.py    # Relationship analysis engine — strength, risk, profiles
│   ├── model.py      # SQLite persistence (WAL mode, 5-table normalised schema)
│   ├── seed.py       # Auto-seeds on first launch
│   └── templates/
│       ├── base.html          # Dark theme, navigation, badge/alert CSS
│       ├── dashboard.html     # Program summary, risk KPIs, reference tables
│       ├── program.html       # CQA sensitivity + CPP reach + critical links
│       ├── relationships.html # Full per-unit-operation relationship tables
│       └── tech_transfer.html # Tech transfer risk score, CQA-level breakdown
│
├── data/
│   └── mock_data.py   # 3 programs × 12 ops × 37 CPPs × 18 CQAs × 56 relationships
│
├── tests/
│   └── test_cppcqa.py  # 166 tests across 5 classes
│
├── run.py              # Entrypoint (port 5091)
└── requirements.txt    # Flask + pytest

Program Corpus (Mock Data)

3 GxP manufacturing programs across all product types and phases:

Program Type Pathway Phase CPPs CQAs Links Verdict
Emafilimab (Anti-PD-1 mAb) Biologic BLA Clinical Phase 3 16 6 23 Medium Risk
Nexarelin HCl Tablets 25 mg Small Molecule NDA Commercial 12 6 18 Medium Risk
GeneCure-X (Lentiviral Gene Therapy) Cell/Gene Therapy BLA Clinical Phase 1 9 6 15 High Risk

Total: 12 unit operations · 37 CPPs/KPPs · 18 CQAs · 56 CPP-CQA relationships

Representative Relationships

Program Unit Operation CPP CQA Strength Direction Evidence TT Risk
Emafilimab Production Bioreactor Bioreactor pH Potency 0.85 Optimal Range Level 1 High
Emafilimab CEX Chromatography Elution Salt Concentration Purity 0.88 Optimal Range Level 1 High
Nexarelin API Synthesis Reagent Equivalents Assay 0.88 Positive Level 1 High
Nexarelin Tablet Compression Compaction Force Dissolution 0.80 Negative Level 1 Medium
GeneCure-X Vector Production MOI Transduction Efficiency 0.90 Positive Level 2 High
GeneCure-X Downstream Purification Gradient Salt Concentration Empty Capsid Ratio 0.85 Negative Level 2 High

Quickstart

git clone https://github.com/timjm25/CPPCQAModeler.git
cd CPPCQAModeler

pip install -r requirements.txt

python run.py
# → http://127.0.0.1:5091

Auto-seeds 3 MSAT programs, 12 unit operations, 37 CPPs, 18 CQAs, and 56 relationships on first launch. No configuration required.


Pages

Route Description
/ Dashboard — KPI tiles, programs table with risk scores and verdicts, strength/evidence/risk reference tables
/program/<id> Program detail — CQA sensitivity table, CPP reach table, critical links with mechanistic notes
/program/<id>/relationships Full CPP-CQA relationship tables grouped by unit operation — strength bar, direction, mechanism, evidence badges
/program/<id>/tech-transfer Tech transfer risk assessment — risk score card, CQA-level breakdown, critical links with required actions

REST API

Method Endpoint Description
GET /api/v1/programs All programs with risk scores, verdicts, CPP/CQA/link counts
GET /api/v1/program/<id> Program summary — risk score, verdict, all counts
GET /api/v1/program/<id>/relationships All CPP-CQA relationships with strength, direction, mechanism, evidence, risk
GET /api/v1/program/<id>/cqas CQA list with specifications and types
GET /api/v1/program/<id>/cpps CPP/KPP list with NOR bounds and unit operations
GET /api/v1/stats Summary statistics
GET /healthz Health check

Examples

# All MSAT programs with tech transfer risk scores
curl http://127.0.0.1:5091/api/v1/programs

# GeneCure-X CPP-CQA relationship model (High Risk CGT)
curl http://127.0.0.1:5091/api/v1/program/PRG-003/relationships

# Emafilimab CQA list with specifications
curl http://127.0.0.1:5091/api/v1/program/PRG-001/cqas

Relationships Response (excerpt)

{
  "relationships": [
    {
      "rel_id": "REL-003-001",
      "cpp_name": "Multiplicity of Infection",
      "cqa_name": "Transduction Efficiency",
      "op_name": "Vector Production",
      "strength": 0.90,
      "strength_category": "Strong",
      "direction": "positive",
      "mechanism": "cell_physiology",
      "evidence_level": "Level 2",
      "tech_transfer_risk": "High"
    }
  ]
}

Testing

python3 -m pytest tests/ -v
# 166 tests — 5 classes — passes in < 2s
Class Tests Scope
TestMockData 27 3 programs, 12 ops, 37 CPPs, 18 CQAs, 56 relationships; required fields; referential integrity; valid enumerations; per-program counts
TestModeler 42 strength_category, direction_label, evidence_label, risk_score_from_relationships, program_risk_verdict, cqa_profile, cpp_profile, critical_links, analyze_program — all boundary conditions
TestModel 40 Seed, idempotent re-seed, all get_* methods, analyze_program, verdict checks, dashboard_summary, stats
TestFlaskRoutes 27 All 4 pages × 3 programs, 404 handling, alert banners, CQA/CPP content, risk verdict rendering
TestRestAPI 30 All 7 endpoints, response structure, field completeness, per-program counts, strength types, 404 handling

License

MIT License — see LICENSE.

Copyright (c) 2026 Tim Maguire.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors