attachment
attachment

Explain with answers

Reading File
Finding Sources
Finding Sources
Reading File
Reading File

Answer: c. Give DMPA with 7 days of barrier


Explanation

DMPA (Depot Medroxyprogesterone Acetate) is a progestin-only injectable contraceptive given every 3 months (13 weeks). A 150 mg dose suppresses ovulation for at least 14 weeks - providing a built-in 1-week grace period beyond the scheduled 13-week interval.
The question states the woman is 14 days late (i.e., she is now at week 13 + 2 weeks = ~15 weeks since her last injection). This puts her just beyond the standard grace period.

Management Protocol for Late/Missed DMPA Dose

Delay from due dateAction
Up to 2 weeks late (i.e., within 14 weeks of last dose)Give DMPA immediately - no additional precautions needed
More than 2 weeks lateGive DMPA + advise 7 days of barrier contraception
Significant delay + sexually activeConsider pregnancy test before giving injection
Since this woman is exactly 14 days late, she has crossed the grace window. The correct action is:
  • Give DMPA now (do not delay until next period)
  • Advise 7 days of barrier contraception (condoms) to cover the time until the injection becomes effective again

Why the Other Options Are Wrong

  • a. Urine pregnancy test before DMPA - This would be appropriate only if there is a real concern about pregnancy (e.g., she was sexually active without protection during a long delay). Being only 14 days late, routine UPT is not the standard first-line advice - though some guidelines recommend it if >14 weeks since last injection. The primary recommended action remains giving DMPA + barrier.
  • b. Give DMPA (without barrier) - Correct only if she were within the 2-week grace period (i.e., ≤ 2 weeks late). Since she is exactly at the limit, barrier contraception is still recommended for safety.
  • d. Wait till next period - Unnecessary and delays contraceptive protection. DMPA can be restarted at any point with backup contraception; waiting for the next period is not required.

Key Pharmacology Recall

From Katzung's Basic and Clinical Pharmacology: "After a 150-mg dose, ovulation is inhibited for at least 14 weeks." This is the pharmacological basis for the 2-week grace period (13 weeks scheduled + 1 extra week = 14 weeks). Beyond 14 weeks, contraceptive efficacy cannot be guaranteed, hence barrier backup is required for 7 days after re-injection.

Can you make a flash cards of bacterias

Asking for Preferences
Reading File
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/bacteria-flashcards

Writing File

~/bacteria-flashcards/make_flashcards.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import Paragraph
from reportlab.lib.enums import TA_CENTER, TA_LEFT
import textwrap

OUTPUT = "/home/daytona/workspace/bacteria-flashcards/Bacteria_Flashcards.pdf"

# --- Flashcard data ---
# Format: (card_number, question, answer_lines, color_theme)
# color_theme: "gram_pos" (purple), "gram_neg" (pink/red), "special" (teal), "general" (blue)

CARDS = [
    # ── GENERAL / INTRO ─────────────────────────────────────────────────────────
    (1, "What is the basis of Gram staining?",
     ["Gram staining classifies bacteria by their CELL WALL structure:",
      "",
      "• Gram-positive → thick peptidoglycan layer",
      "  → Retains crystal violet → PURPLE/BLUE",
      "",
      "• Gram-negative → thin peptidoglycan + outer lipid membrane",
      "  → Loses crystal violet, takes safranin → PINK/RED",
      "",
      "Steps: Crystal violet → Iodine (mordant) → Alcohol wash → Safranin"],
     "general"),

    (2, "What are the two main shapes of bacteria?",
     ["COCCI (spherical)",
      "  • Diplococci – pairs",
      "  • Streptococci – chains",
      "  • Staphylococci – grape-like clusters",
      "  • Tetrads – groups of 4",
      "",
      "BACILLI (rod-shaped)",
      "  • Single rods, palisades, or Chinese-letter arrangement",
      "",
      "Others: Spirochetes (spiral), Vibrio (comma), Coccobacilli"],
     "general"),

    (3, "Name the clinically important GRAM-POSITIVE COCCI",
     ["STAPHYLOCOCCI (clusters):",
      "  • S. aureus – coagulase +ve; MRSA, toxins, abscesses",
      "  • S. epidermidis – coagulase –ve; catheter infections",
      "  • S. saprophyticus – UTI in young women",
      "",
      "STREPTOCOCCI (chains):",
      "  • S. pyogenes (Group A) – pharyngitis, rheumatic fever",
      "  • S. agalactiae (Group B) – neonatal meningitis",
      "  • S. pneumoniae – pneumonia, meningitis (lancet-shaped diplococci)",
      "  • Enterococcus – UTI, endocarditis"],
     "gram_pos"),

    (4, "Staphylococcus aureus – Key Features",
     ["Gram: Gram-positive cocci in clusters",
      "Catalase: POSITIVE (distinguishes from Streptococcus)",
      "Coagulase: POSITIVE (distinguishes from other Staph)",
      "",
      "Virulence factors:",
      "  • Protein A – binds IgG Fc, evades phagocytosis",
      "  • Toxins: TSST-1, exfoliatin, Panton-Valentine leukocidin",
      "",
      "Diseases: Abscesses, impetigo, osteomyelitis, septicemia,",
      "  toxic shock syndrome, food poisoning (heat-stable toxin)",
      "",
      "Treatment: Flucloxacillin; MRSA → Vancomycin/Linezolid"],
     "gram_pos"),

    (5, "Streptococcus pyogenes (Group A Strep) – Key Features",
     ["Gram: Gram-positive cocci in chains",
      "Haemolysis: BETA (complete) on blood agar",
      "Lancefield: Group A",
      "Bacitracin: SENSITIVE (differentiates from Group B)",
      "",
      "Virulence: M protein (antiphagocytic), streptolysin O & S,",
      "  streptokinase, hyaluronidase, pyrogenic exotoxins",
      "",
      "Diseases: Pharyngitis, scarlet fever, impetigo, cellulitis,",
      "  necrotizing fasciitis, rheumatic fever, post-strep glomerulonephritis",
      "",
      "Treatment: Penicillin G (never resistant)"],
     "gram_pos"),

    (6, "Streptococcus pneumoniae – Key Features",
     ["Gram: Gram-positive lancet-shaped DIPLOCOCCI",
      "Haemolysis: ALPHA (partial / green zone)",
      "Capsule: Large polysaccharide capsule (virulence factor)",
      "Optochin: SENSITIVE (differentiates from viridans strep)",
      "",
      "Diseases: #1 cause of:",
      "  • Community-acquired pneumonia (CAP)",
      "  • Bacterial meningitis (adults)",
      "  • Otitis media (children)",
      "  • Sinusitis",
      "",
      "Treatment: Penicillin (if sensitive) / Ceftriaxone",
      "Prevention: PCV13, PPSV23 vaccines"],
     "gram_pos"),

    (7, "Name the clinically important GRAM-POSITIVE BACILLI",
     ["SPORE-FORMING:",
      "  • Bacillus anthracis – anthrax (Medusa head colonies)",
      "  • Bacillus cereus – food poisoning",
      "  • Clostridium tetani – tetanus (drumstick spore)",
      "  • Clostridium botulinum – botulism",
      "  • Clostridium perfringens – gas gangrene",
      "  • Clostridium difficile – pseudomembranous colitis",
      "",
      "NON-SPORE-FORMING:",
      "  • Listeria monocytogenes – neonatal meningitis, tumbling motility",
      "  • Corynebacterium diphtheriae – diphtheria (club-shaped, metachromatic granules)",
      "  • Actinomyces – sulfur granules"],
     "gram_pos"),

    (8, "Clostridium species – Quick Summary",
     ["All: Gram-positive, spore-forming, ANAEROBIC bacilli",
      "",
      "C. tetani   → Tetanospasmin toxin → blocks inhibitory neurons",
      "  → Spastic paralysis, trismus (lockjaw), risus sardonicus",
      "  → Drumstick terminal spore",
      "",
      "C. botulinum → Botulin toxin → blocks Ach release at NMJ",
      "  → FLACCID paralysis, descending, diplopia, dysarthria",
      "  → Honey → infant botulism",
      "",
      "C. perfringens → Alpha toxin (lecithinase) → gas gangrene",
      "  → Double zone haemolysis; Nagler's reaction positive",
      "",
      "C. difficile → Toxin A (enterotoxin) + Toxin B (cytotoxin)",
      "  → Pseudomembranous colitis after antibiotics",
      "  → Treat: Oral Vancomycin / Fidaxomicin / Metronidazole"],
     "gram_pos"),

    # ── GRAM-NEGATIVE ───────────────────────────────────────────────────────────
    (9, "Name the clinically important GRAM-NEGATIVE COCCI",
     ["NEISSERIA genus:",
      "",
      "N. meningitidis (Meningococcus):",
      "  • Diplococcus, kidney-bean shaped",
      "  • Causes: Meningitis + septicemia (purpuric rash)",
      "  • Ferments: Glucose + Maltose",
      "  • Carried in nasopharynx; Polysaccharide capsule",
      "  • Treatment: Penicillin G / Ceftriaxone",
      "",
      "N. gonorrhoeae (Gonococcus):",
      "  • Causes: Gonorrhea, PID, neonatal ophthalmia",
      "  • Ferments: Glucose ONLY (not maltose)",
      "  • No capsule; oxidase positive",
      "  • Treatment: Ceftriaxone + Azithromycin"],
     "gram_neg"),

    (10, "Name the clinically important GRAM-NEGATIVE BACILLI (Enterobacteriaceae)",
     ["All: Gram-negative rods, facultative anaerobes, oxidase NEGATIVE",
      "",
      "• E. coli – UTI, diarrhea (ETEC, EPEC, EHEC), neonatal meningitis",
      "• Klebsiella – pneumonia (currant jelly sputum), UTI (elderly/alcoholics)",
      "• Salmonella – typhoid fever (S. typhi), gastroenteritis",
      "• Shigella – bacillary dysentery (blood + mucus, no gas)",
      "• Proteus – swarming, UTI (urease +ve, struvite stones)",
      "• Enterobacter – hospital-acquired infections",
      "• Serratia – red pigment (prodigiosin), ICU infections",
      "• Yersinia pestis – plague (safety pin bipolar staining)"],
     "gram_neg"),

    (11, "E. coli Diarrhea Variants – Quick Reference",
     ["ETEC – Traveler's diarrhea; watery, heat-labile + heat-stable toxins",
      "EPEC – Infantile diarrhea; attaching & effacing lesions; no toxin",
      "EHEC (O157:H7) – Bloody diarrhea; Shiga-like toxin → HUS",
      "  → Do NOT give antibiotics (↑ HUS risk)",
      "EIEC – Dysentery-like; invades colonic epithelium (like Shigella)",
      "EAEC – Persistent diarrhea in children; stacked-brick pattern",
      "",
      "Extra:",
      "• E. coli K1 antigen → #1 cause of neonatal meningitis",
      "• MacConkey agar → PINK colonies (lactose fermenter)"],
     "gram_neg"),

    (12, "Salmonella vs Shigella – Key Differences",
     ["Feature          | Salmonella        | Shigella",
      "-----------------|-------------------|------------------",
      "Motility         | Motile (flagella)  | Non-motile",
      "H2S production   | YES               | NO",
      "Gas production   | YES               | NO",
      "Urease           | Negative          | Negative",
      "Transmission     | Poultry/eggs/water | Feco-oral (4 Fs)",
      "Disease          | Typhoid, enteritis | Bacillary dysentery",
      "Blood in stool   | Rare (typhoid)    | YES (dysentery)",
      "Intracell. inv.  | Facultative       | YES",
      "Treatment        | Ciprofloxacin /   | Ciprofloxacin /",
      "                 | Azithromycin      | Azithromycin"],
     "gram_neg"),

    (13, "Gram-negative NON-Enterobacteriaceae Bacilli",
     ["OXIDASE POSITIVE (key distinction!):",
      "",
      "Pseudomonas aeruginosa:",
      "  • Strict aerobe; fruity odor; blue-green pigment (pyocyanin)",
      "  • Burns, CF lung, immunocompromised, swimmer's ear",
      "  • Treatment: Anti-pseudomonal penicillins, carbapenems, aminoglycosides",
      "",
      "Haemophilus influenzae:",
      "  • Requires Factor X (hemin) + Factor V (NAD) – Chocolate agar",
      "  • Type b → meningitis, epiglottitis (thumb sign on X-ray)",
      "  • Treatment: Ceftriaxone; Prevention: Hib vaccine",
      "",
      "Vibrio cholerae:",
      "  • Comma-shaped; El Tor biotype; rice-water stools",
      "  • Toxin → ↑ cAMP → massive Cl⁻/water loss",
      "  • Treatment: ORS + Doxycycline"],
     "gram_neg"),

    (14, "ANAEROBIC Gram-negative bacilli",
     ["Bacteroides fragilis:",
      "  • Most common anaerobe in human colon",
      "  • Capsule → abscess formation",
      "  • Causes: Intra-abdominal abscess, peritonitis after bowel perforation",
      "  • Resists penicillin (beta-lactamase producer)",
      "  • Treatment: Metronidazole, Carbapenems, Piperacillin-tazobactam",
      "",
      "Fusobacterium nucleatum:",
      "  • Lemierre syndrome (septic thrombophlebitis of jugular vein)",
      "",
      "Prevotella / Porphyromonas:",
      "  • Dental abscesses, aspiration pneumonia"],
     "gram_neg"),

    # ── SPECIAL / ATYPICAL ───────────────────────────────────────────────────────
    (15, "Atypical Bacteria – 'No Cell Wall' / Special Groups",
     ["MYCOPLASMA:",
      "  • NO cell wall → penicillin INEFFECTIVE",
      "  • M. pneumoniae → walking pneumonia; cold agglutinins; X-ray > clinical signs",
      "  • Fried-egg colonies; Treatment: Macrolides, Tetracyclines",
      "",
      "CHLAMYDIA:",
      "  • Obligate intracellular; cannot make ATP",
      "  • C. trachomatis → trachoma, urethritis, PID, LGV",
      "  • C. pneumoniae → atypical pneumonia",
      "  • C. psittaci → psittacosis (bird exposure)",
      "  • Treatment: Azithromycin / Doxycycline",
      "",
      "RICKETTSIA:",
      "  • Obligate intracellular; tick/louse vector",
      "  • R. rickettsii → Rocky Mountain spotted fever (rash: wrists → trunk)",
      "  • Treatment: Doxycycline (first-line)"],
     "special"),

    (16, "Mycobacterium – Acid-Fast Bacteria",
     ["Staining: ACID-FAST (Ziehl-Neelsen) → Red bacilli on blue background",
      "Cell wall: High mycolic acid content → Gram stain FAILS",
      "",
      "M. tuberculosis:",
      "  • Obligate aerobe; slow growing (3-8 weeks); CORD formation",
      "  • Ghon complex, caseating granuloma, Langhan's giant cells",
      "  • TB treatment: RIPE (Rifampicin, Isoniazid, Pyrazinamide, Ethambutol)",
      "",
      "M. leprae:",
      "  • Cannot be cultured in vitro (grows in armadillo footpads)",
      "  • Leprosy: Tuberculoid vs. Lepromatous",
      "  • Treatment: Dapsone + Rifampicin (± Clofazimine)",
      "",
      "M. avium complex (MAC):",
      "  • Opportunistic in AIDS patients (CD4 < 50)"],
     "special"),

    (17, "Spirochetes – Spiral-Shaped Bacteria",
     ["Too thin to see on Gram stain – require dark field microscopy / silver stain",
      "",
      "Treponema pallidum:",
      "  • Syphilis: primary (painless chancre), secondary (rash on palms/soles),",
      "    tertiary (gummas, tabes dorsalis, aortitis)",
      "  • VDRL/RPR screening; FTA-ABS confirmatory",
      "  • Treatment: Penicillin G (drug of choice)",
      "",
      "Borrelia burgdorferi:",
      "  • Lyme disease; Ixodes tick vector; erythema migrans (bull's-eye rash)",
      "  • Can see on Giemsa stain (larger spirochete)",
      "  • Treatment: Doxycycline (adults), Amoxicillin (children/pregnancy)",
      "",
      "Leptospira interrogans:",
      "  • Weil's disease (jaundice + renal failure); rat urine in water",
      "  • Treatment: Penicillin / Doxycycline"],
     "special"),

    (18, "Gram Staining – Quick Recall Chart",
     ["GRAM-POSITIVE (+) → PURPLE",
      "  Cocci: S. aureus, S. pyogenes, S. pneumoniae, Enterococcus",
      "  Bacilli: Bacillus, Clostridium, Listeria, Corynebacterium",
      "",
      "GRAM-NEGATIVE (−) → PINK",
      "  Cocci: Neisseria meningitidis, N. gonorrhoeae",
      "  Bacilli: E. coli, Klebsiella, Salmonella, Shigella, Pseudomonas,",
      "           Haemophilus, Vibrio, Bacteroides",
      "",
      "GRAM VARIABLE / STAIN POORLY:",
      "  • Mycobacterium → Acid-fast stain",
      "  • Mycoplasma → No cell wall (no staining)",
      "  • Chlamydia / Rickettsia → Obligate intracellular",
      "  • Treponema → Dark-field microscopy",
      "  • Legionella → Silver stain (Dieterle)"],
     "general"),
]

# ── Color themes ────────────────────────────────────────────────────────────────
THEMES = {
    "general":  {"header_bg": colors.HexColor("#1565C0"), "header_fg": colors.white,
                 "body_bg":   colors.HexColor("#E3F2FD"), "border":    colors.HexColor("#1565C0"),
                 "tag": "General"},
    "gram_pos": {"header_bg": colors.HexColor("#6A1B9A"), "header_fg": colors.white,
                 "body_bg":   colors.HexColor("#F3E5F5"), "border":    colors.HexColor("#6A1B9A"),
                 "tag": "Gram-Positive"},
    "gram_neg": {"header_bg": colors.HexColor("#B71C1C"), "header_fg": colors.white,
                 "body_bg":   colors.HexColor("#FFEBEE"), "border":    colors.HexColor("#B71C1C"),
                 "tag": "Gram-Negative"},
    "special":  {"header_bg": colors.HexColor("#00695C"), "header_fg": colors.white,
                 "body_bg":   colors.HexColor("#E0F2F1"), "border":    colors.HexColor("#00695C"),
                 "tag": "Special / Atypical"},
}

# ── PDF canvas ──────────────────────────────────────────────────────────────────
W, H = A4  # 595 x 842 pt
MARGIN = 18 * mm
CARD_W = W - 2 * MARGIN
CARD_H = (H - 3 * MARGIN) / 2  # 2 cards per page
RADIUS = 8

def rounded_rect(c, x, y, w, h, r, fill_color, stroke_color):
    c.setFillColor(fill_color)
    c.setStrokeColor(stroke_color)
    c.setLineWidth(1.5)
    c.roundRect(x, y, w, h, r, stroke=1, fill=1)

def draw_card(c, card_num, question, answer_lines, theme_key, origin_y):
    t = THEMES[theme_key]
    x = MARGIN
    header_h = 46
    body_y = origin_y
    body_h = CARD_H

    # Card background
    rounded_rect(c, x, body_y, CARD_W, body_h, RADIUS,
                 t["body_bg"], t["border"])

    # Header bar
    c.setFillColor(t["header_bg"])
    # Use clip path trick: draw header rect clipped to top of card
    c.saveState()
    p = c.beginPath()
    p.roundRect(x, body_y + body_h - header_h, CARD_W, header_h, RADIUS)
    c.clipPath(p, stroke=0)
    c.rect(x, body_y + body_h - header_h, CARD_W, header_h, stroke=0, fill=1)
    c.restoreState()
    # Also fill top corners square so the round is only at very top
    c.setFillColor(t["header_bg"])
    c.rect(x, body_y + body_h - header_h, CARD_W, RADIUS, stroke=0, fill=1)

    # Card number badge
    badge_r = 12
    badge_x = x + badge_r + 8
    badge_y = body_y + body_h - header_h / 2
    c.setFillColor(colors.white)
    c.circle(badge_x, badge_y, badge_r, stroke=0, fill=1)
    c.setFillColor(t["header_bg"])
    c.setFont("Helvetica-Bold", 11)
    c.drawCentredString(badge_x, badge_y - 4, str(card_num))

    # Tag label (top right)
    c.setFillColor(colors.HexColor("#FFFFFF"))
    c.setFont("Helvetica-Oblique", 7.5)
    c.drawRightString(x + CARD_W - 10, body_y + body_h - 14, t["tag"])

    # Question text
    c.setFillColor(t["header_fg"])
    c.setFont("Helvetica-Bold", 11.5)
    # Wrap question if needed
    avail_w = CARD_W - badge_r * 2 - 30
    q_x = badge_x + badge_r + 10
    q_y = body_y + body_h - header_h / 2 + 5
    c.drawString(q_x, q_y, question[:90])  # truncate safety

    # Answer area
    line_y = body_y + body_h - header_h - 12
    c.setFont("Courier", 8.2)
    c.setFillColor(colors.HexColor("#1A1A2E"))

    for line in answer_lines:
        if line_y < body_y + 8:
            break
        if line.startswith("• ") or line.startswith("  •"):
            c.setFillColor(t["border"])
            c.setFont("Courier-Bold", 8.2)
        elif line == "":
            line_y -= 3
            continue
        elif line.startswith("  "):
            c.setFillColor(colors.HexColor("#444444"))
            c.setFont("Courier", 8.0)
        else:
            c.setFillColor(colors.HexColor("#1A1A2E"))
            c.setFont("Courier-Bold", 8.3)
        c.drawString(x + 14, line_y, line[:100])
        line_y -= 11.5

def draw_cover(c):
    # Full page cover
    c.setFillColor(colors.HexColor("#0D1B2A"))
    c.rect(0, 0, W, H, fill=1, stroke=0)

    # Decorative circles
    for (cx, cy, r, col) in [
        (W * 0.85, H * 0.85, 120, "#1565C0"),
        (W * 0.1,  H * 0.15, 80,  "#6A1B9A"),
        (W * 0.5,  H * 0.5,  200, "#0A2740"),
    ]:
        c.setFillColor(colors.HexColor(col))
        c.circle(cx, cy, r, fill=1, stroke=0)

    # Title
    c.setFillColor(colors.white)
    c.setFont("Helvetica-Bold", 34)
    c.drawCentredString(W / 2, H * 0.62, "BACTERIOLOGY")
    c.setFont("Helvetica-Bold", 22)
    c.drawCentredString(W / 2, H * 0.55, "FLASHCARD DECK")

    # Subtitle
    c.setFillColor(colors.HexColor("#90CAF9"))
    c.setFont("Helvetica", 13)
    c.drawCentredString(W / 2, H * 0.48, "Classification & Gram Staining")
    c.setFont("Helvetica", 11)
    c.drawCentredString(W / 2, H * 0.44, "For Medical Students (MBBS / MD)")

    # Legend boxes
    legends = [
        ("Gram-Positive", "#6A1B9A"),
        ("Gram-Negative", "#B71C1C"),
        ("Special/Atypical", "#00695C"),
        ("General", "#1565C0"),
    ]
    box_w, box_h = 110, 24
    total_w = len(legends) * box_w + (len(legends) - 1) * 10
    start_x = (W - total_w) / 2
    for i, (label, col) in enumerate(legends):
        bx = start_x + i * (box_w + 10)
        by = H * 0.35
        c.setFillColor(colors.HexColor(col))
        c.roundRect(bx, by, box_w, box_h, 5, fill=1, stroke=0)
        c.setFillColor(colors.white)
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(bx + box_w / 2, by + 8, label)

    # Card count
    c.setFillColor(colors.HexColor("#B0BEC5"))
    c.setFont("Helvetica", 10)
    c.drawCentredString(W / 2, H * 0.30, f"{len(CARDS)} Flashcards  ·  Medical Microbiology")

    c.showPage()


# ── Build PDF ───────────────────────────────────────────────────────────────────
c = canvas.Canvas(OUTPUT, pagesize=A4)
c.setTitle("Bacteriology Flashcards – Classification & Gram Staining")

draw_cover(c)

# 2 cards per page
SLOT_TOP    = MARGIN + CARD_H + MARGIN        # y origin of top card
SLOT_BOTTOM = MARGIN                           # y origin of bottom card

for i in range(0, len(CARDS), 2):
    # Top card
    num, q, ans, theme = CARDS[i]
    draw_card(c, num, q, ans, theme, SLOT_TOP)

    # Bottom card (if exists)
    if i + 1 < len(CARDS):
        num2, q2, ans2, theme2 = CARDS[i + 1]
        draw_card(c, num2, q2, ans2, theme2, SLOT_BOTTOM)

    c.showPage()

c.save()
print(f"PDF saved: {OUTPUT}")
print(f"Total cards: {len(CARDS)}")
Running Command

cd /home/daytona/workspace/bacteria-flashcards && python make_flashcards.py

Running Command

ls -lh /home/daytona/workspace/bacteria-flashcards/Bacteria_Flashcards.pdf

Your flashcard PDF is ready! Download it here:

Bacteria Flashcards

PDF Document · PDF


What's inside - 18 flashcards across 10 pages

ColorCategoryCards
🟣 PurpleGram-PositiveStaph, Strep pneumoniae, Strep pyogenes, GP Bacilli, Clostridia
🔴 RedGram-NegativeNeisseria, Enterobacteriaceae, E. coli variants, Salmonella vs Shigella, Pseudomonas, Bacteroides
🟢 TealSpecial/AtypicalMycoplasma, Chlamydia, Rickettsia, Mycobacterium, Spirochetes
🔵 BlueGeneralGram stain mechanism, Bacterial shapes, Quick recall chart
Highlights:
  • Cover page with colour-coded legend
  • 2 cards per A4 page for easy printing and cutting
  • Each card has the question in the header bar + structured answer below
  • Mnemonics, key differentiators, and treatment included on every relevant card

Can you make a easy notes of pdf of cell injury and apoptosis . For mbbs student. For fmge ,next or usmle exam

Finding Sources
Finding Sources
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/cell-injury-notes

Writing File

~/cell-injury-notes/make_notes.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas as pdfcanvas
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.lib.colors import HexColor, white, black
import io

OUTPUT = "/home/daytona/workspace/cell-injury-notes/Cell_Injury_Apoptosis_Notes.pdf"

# ─── Colour palette ───────────────────────────────────────────────────────────
C_DARK     = HexColor("#0D1B2A")
C_BLUE     = HexColor("#1565C0")
C_LBLUE    = HexColor("#E3F2FD")
C_PURPLE   = HexColor("#6A1B9A")
C_LPURPLE  = HexColor("#F3E5F5")
C_RED      = HexColor("#B71C1C")
C_LRED     = HexColor("#FFEBEE")
C_GREEN    = HexColor("#1B5E20")
C_LGREEN   = HexColor("#E8F5E9")
C_TEAL     = HexColor("#00695C")
C_LTEAL    = HexColor("#E0F2F1")
C_ORANGE   = HexColor("#E65100")
C_LORANGE  = HexColor("#FFF3E0")
C_YELLOW   = HexColor("#F57F17")
C_LYELLOW  = HexColor("#FFFDE7")
C_GREY     = HexColor("#37474F")
C_LGREY    = HexColor("#ECEFF1")
C_EXAM     = HexColor("#880E4F")
C_LEXAM    = HexColor("#FCE4EC")

W, H = A4
LMARGIN = 18*mm
RMARGIN = 18*mm
TMARGIN = 18*mm
BMARGIN = 18*mm

# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, **kw)

TITLE_S = S("title_s", fontName="Helvetica-Bold", fontSize=28, textColor=white,
            alignment=TA_CENTER, spaceAfter=4)
SUB_S   = S("sub_s",   fontName="Helvetica",      fontSize=13, textColor=HexColor("#90CAF9"),
            alignment=TA_CENTER, spaceAfter=2)
EXAM_TAG= S("exam",    fontName="Helvetica-Bold",  fontSize=9,  textColor=white,
            alignment=TA_CENTER)

H1      = S("h1", fontName="Helvetica-Bold", fontSize=15, textColor=white,
            alignment=TA_LEFT, spaceBefore=6, spaceAfter=4, leftIndent=4)
H2      = S("h2", fontName="Helvetica-Bold", fontSize=12, textColor=C_BLUE,
            alignment=TA_LEFT, spaceBefore=10, spaceAfter=4)
H3      = S("h3", fontName="Helvetica-Bold", fontSize=10.5, textColor=C_PURPLE,
            spaceBefore=6, spaceAfter=3)
BODY    = S("body", fontName="Helvetica", fontSize=9.5, textColor=C_DARK,
            leading=14, spaceBefore=2, spaceAfter=2, alignment=TA_JUSTIFY)
BULLET  = S("bullet", fontName="Helvetica", fontSize=9.5, textColor=C_DARK,
            leading=13, leftIndent=14, firstLineIndent=-10, spaceBefore=1, spaceAfter=1)
BULLET2 = S("bullet2", fontName="Helvetica", fontSize=9, textColor=C_GREY,
            leading=12, leftIndent=28, firstLineIndent=-10, spaceBefore=0)
BOLD_B  = S("boldb", fontName="Helvetica-Bold", fontSize=9.5, textColor=C_DARK,
            leading=13, leftIndent=14, firstLineIndent=-10, spaceBefore=2)
MNEMONIC= S("mnemonic", fontName="Helvetica-Bold", fontSize=10, textColor=C_EXAM,
            alignment=TA_CENTER, spaceBefore=4, spaceAfter=4)
CAPTION = S("caption", fontName="Helvetica-Oblique", fontSize=8, textColor=C_GREY,
            alignment=TA_CENTER, spaceBefore=2)
TABLE_H = S("tblh", fontName="Helvetica-Bold", fontSize=9, textColor=white, alignment=TA_CENTER)
TABLE_B = S("tblb", fontName="Helvetica", fontSize=8.5, textColor=C_DARK, alignment=TA_LEFT, leading=12)
EXAM_P  = S("examp", fontName="Helvetica-Bold", fontSize=9, textColor=C_EXAM, leading=13,
            leftIndent=14, firstLineIndent=-10)

# ─── Helper builders ──────────────────────────────────────────────────────────
def b(txt):   return f"<b>{txt}</b>"
def i(txt):   return f"<i>{txt}</i>"
def col(txt, c): return f'<font color="{c}">{txt}</font>'

def section_header(title, bg=C_BLUE, num=None):
    label = f"{num}. {title}" if num else title
    tbl = Table([[Paragraph(label, H1)]], colWidths=[W - LMARGIN - RMARGIN])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [bg]),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("ROUNDEDCORNERS", [5]),
    ]))
    return tbl

def info_box(text_rows, bg=C_LBLUE, border=C_BLUE, title=None):
    """Coloured info box."""
    rows = []
    if title:
        rows.append([Paragraph(b(title), S("ibt", fontName="Helvetica-Bold", fontSize=9.5,
                                            textColor=border))])
    for t in text_rows:
        rows.append([Paragraph(t, BODY)])
    tbl = Table(rows, colWidths=[W - LMARGIN - RMARGIN - 8])
    style = [
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("BOX", (0,0), (-1,-1), 1.5, border),
        ("LINEAFTER", (0,0), (0,-1), 4, border),
    ]
    tbl.setStyle(TableStyle(style))
    return tbl

def exam_box(points):
    """High-yield exam tip box."""
    rows = [[Paragraph("⭐ HIGH-YIELD EXAM POINTS", S("ehdr", fontName="Helvetica-Bold",
                        fontSize=9, textColor=C_EXAM))]]
    for p in points:
        rows.append([Paragraph(f"• {p}", EXAM_P)])
    tbl = Table(rows, colWidths=[W - LMARGIN - RMARGIN])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_LEXAM),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 1.5, C_EXAM),
        ("LINEABOVE",     (0,1), (-1,1), 0.5, C_EXAM),
    ]))
    return tbl

def two_col_table(headers, rows, col_widths=None, hdr_bg=C_BLUE):
    available = W - LMARGIN - RMARGIN
    if col_widths is None:
        col_widths = [available * 0.38, available * 0.62]
    data = [[Paragraph(h, TABLE_H) for h in headers]]
    for row in rows:
        data.append([Paragraph(str(c), TABLE_B) for c in row])
    tbl = Table(data, colWidths=col_widths, repeatRows=1)
    style = [
        ("BACKGROUND",    (0,0), (-1,0), hdr_bg),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [C_LGREY, white]),
        ("GRID",          (0,0), (-1,-1), 0.5, HexColor("#B0BEC5")),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]
    tbl.setStyle(TableStyle(style))
    return tbl

def mnemonic_box(mnem, explanation):
    content = f'<b><font color="{C_EXAM.hexval()}">{mnem}</font></b>  —  {explanation}'
    tbl = Table([[Paragraph(content, MNEMONIC)]], colWidths=[W - LMARGIN - RMARGIN])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_LEXAM),
        ("BOX",           (0,0), (-1,-1), 1.5, C_EXAM),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ]))
    return tbl

def P(txt, style=BODY): return Paragraph(txt, style)
def SP(n=4): return Spacer(1, n)
def HR(): return HRFlowable(width="100%", thickness=0.5, color=HexColor("#B0BEC5"), spaceAfter=4)
def bul(txt, sub=False):
    st = BULLET2 if sub else BULLET
    bullet_char = "◦" if sub else "•"
    return Paragraph(f"{bullet_char}  {txt}", st)

# ─── Cover page ───────────────────────────────────────────────────────────────
def cover_page():
    story = []
    # Big colour block via a table
    cover_data = [[
        Paragraph("PATHOLOGY", S("c1", fontName="Helvetica-Bold", fontSize=36,
                                  textColor=white, alignment=TA_CENTER)),
    ],[
        Paragraph("Cell Injury &amp; Apoptosis", S("c2", fontName="Helvetica-Bold", fontSize=22,
                                  textColor=HexColor("#90CAF9"), alignment=TA_CENTER)),
    ],[
        Paragraph("Easy Notes for MBBS  ·  FMGE / NEXT / USMLE", S("c3", fontName="Helvetica",
                   fontSize=12, textColor=HexColor("#B0BEC5"), alignment=TA_CENTER)),
    ],[
        Paragraph(" ", S("sp", fontSize=8, alignment=TA_CENTER)),
    ],[
        Paragraph("Based on Robbins &amp; Kumar Basic Pathology", S("c4", fontName="Helvetica-Oblique",
                   fontSize=10, textColor=HexColor("#80CBC4"), alignment=TA_CENTER)),
    ]]
    tbl = Table(cover_data, colWidths=[W - LMARGIN - RMARGIN])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_DARK),
        ("TOPPADDING",    (0,0), (-1,-1), 14),
        ("BOTTOMPADDING", (0,0), (-1,-1), 14),
        ("LEFTPADDING",   (0,0), (-1,-1), 20),
    ]))
    story.append(SP(30))
    story.append(tbl)
    story.append(SP(16))

    # Chapter map
    chapters = [
        ("1", "Causes of Cell Injury",          C_BLUE),
        ("2", "Reversible vs Irreversible Injury", C_TEAL),
        ("3", "Morphology of Necrosis",         C_RED),
        ("4", "Types of Necrosis",              C_RED),
        ("5", "Mechanisms of Cell Injury",      C_PURPLE),
        ("6", "Apoptosis – Overview & Causes",  C_GREEN),
        ("7", "Pathways of Apoptosis",          C_GREEN),
        ("8", "Necrosis vs Apoptosis",          C_ORANGE),
        ("9", "Cellular Adaptations",           C_TEAL),
        ("10","Autophagy & Other Cell Deaths",  C_GREY),
        ("11","High-Yield One-Liners",          C_EXAM),
    ]
    ch_rows = [[Paragraph(f"<b>{n}</b>", TABLE_H),
                Paragraph(title, TABLE_B)] for n, title, _ in chapters]
    ch_tbl = Table(ch_rows, colWidths=[20*mm, W - LMARGIN - RMARGIN - 20*mm])
    bg_colors = []
    for i, (_, _, col_c) in enumerate(chapters):
        bg_colors.append(("BACKGROUND", (0,i), (0,i), col_c))
        bg_colors.append(("BACKGROUND", (0,i+1), (-1,i), HexColor("#F5F5F5") if i%2==0 else white))
    ch_tbl.setStyle(TableStyle([
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [C_LGREY, white]),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("BOX",           (0,0), (-1,-1), 1, HexColor("#B0BEC5")),
        ("GRID",          (0,0), (-1,-1), 0.3, HexColor("#CFD8DC")),
    ] + bg_colors))

    story.append(P(b("CONTENTS"), H2))
    story.append(ch_tbl)
    story.append(PageBreak())
    return story

# ─── Section 1: Causes of Cell Injury ────────────────────────────────────────
def sec1():
    s = []
    s.append(section_header("CAUSES OF CELL INJURY", C_BLUE, "1"))
    s.append(SP(6))
    causes = [
        (b("Hypoxia / Ischemia"),
         "Most common cause. Hypoxia = O₂ deficiency; Ischemia = ↓ blood supply. "
         "Ischemia is worse — also cuts off nutrients. "
         "Common cause: arterial blockage, pulmonary disease, anaemia."),
        (b("Toxins"),
         "Environmental (CO, asbestos, pesticides, ethanol, cigarette smoke) + "
         "therapeutic drugs in overdose/susceptible patients."),
        (b("Infectious Agents"),
         "Bacteria, viruses, fungi, parasites — injure via toxins or immune activation."),
        (b("Immunologic Reactions"),
         "Autoimmune, allergic, chronic inflammation. Inflammation = main mediator of tissue damage."),
        (b("Genetic Abnormalities"),
         "Chromosomal (Down syndrome), single-gene (sickle cell — 1 amino acid change in Hb). "
         "Mutations → ↓ or ↑ protein function, damaged DNA, misfolded proteins."),
        (b("Nutritional Imbalances"),
         "Protein-calorie deficiency (global). Excess → obesity → T2DM, atherosclerosis."),
        (b("Physical Agents"),
         "Trauma, extreme heat/cold, radiation, electric shock, barotrauma."),
    ]
    for title, detail in causes:
        s.append(bul(f"{title}: {detail}"))
    s.append(SP(6))
    s.append(exam_box([
        "Hypoxia / Ischemia = MOST COMMON cause of cell injury",
        "Ischemia worse than hypoxia (cuts off both O₂ AND nutrients)",
        "Genetic cause: sickle cell = single amino acid substitution (Val → Glu position 6)",
    ]))
    s.append(SP(8))
    return s

# ─── Section 2: Reversible vs Irreversible ────────────────────────────────────
def sec2():
    s = []
    s.append(section_header("REVERSIBLE vs IRREVERSIBLE CELL INJURY", C_TEAL, "2"))
    s.append(SP(6))

    s.append(P(b("Key Concept:"), H2))
    s.append(P("Cellular function is lost BEFORE cell death. Morphologic changes LAG behind functional loss.", BODY))
    s.append(SP(4))
    s.append(info_box([
        b("Myocardial Ischaemia Timeline:"),
        "• Non-contractile after  <b>1–2 min</b>  (function lost)",
        "• Cell death at  <b>20–30 min</b>  (irreversible)",
        "• EM changes:  <b>2–3 hrs</b>  after death",
        "• Light microscopy (H&amp;E):  <b>6–12 hrs</b>  after death",
    ], C_LTEAL, C_TEAL))
    s.append(SP(6))

    # Comparison table
    rev_irrev = two_col_table(
        ["REVERSIBLE INJURY", "IRREVERSIBLE INJURY"],
        [
            ["Cell can recover if stimulus removed",
             "Point of no return — cell dies"],
            ["Cell swelling (hydropic change / cloudy swelling)",
             "Membrane defects — ions & H₂O flood in"],
            ["Fatty change (lipid accumulation)",
             "Large flocculent mitochondrial densities (EM)"],
            ["ER swelling, ribosome detachment",
             "Nuclear changes: pyknosis, karyorrhexis, karyolysis"],
            ["Plasma membrane blebs (intact)",
             "Lysosome rupture → enzyme digestion"],
            ["Reduced ATP, ↑ anaerobic glycolysis",
             "Massive Ca²⁺ influx, ROS burst"],
        ],
        col_widths=[(W-LMARGIN-RMARGIN)*0.46, (W-LMARGIN-RMARGIN)*0.54],
        hdr_bg=C_TEAL,
    )
    s.append(rev_irrev)
    s.append(SP(6))

    s.append(P(b("Morphology of Reversible Injury:"), H3))
    s.append(bul(b("Cell swelling (hydropic / cloudy swelling):") + " ↓ ATP → Na⁺/K⁺ pump fails → Na⁺ + H₂O enter cell"))
    s.append(bul(b("Fatty change:") + " Lipid vacuoles appear in cytoplasm — liver, heart, kidney. Reflects severe metabolic disturbance."))
    s.append(bul("EM: small amorphous mitochondrial densities, ER dilation, plasma membrane blebs (membrane still intact)"))
    s.append(SP(8))
    return s

# ─── Section 3: Morphology of Necrosis ───────────────────────────────────────
def sec3():
    s = []
    s.append(section_header("MORPHOLOGY OF NECROSIS", C_RED, "3"))
    s.append(SP(6))

    s.append(info_box([
        b("Necrosis") + " = uncontrolled cell death. Cellular membranes fall apart → enzymes leak "
        "→ cell digestion → " + b("INFLAMMATION") + " (key feature distinguishing from apoptosis).",
    ], C_LRED, C_RED))
    s.append(SP(6))

    s.append(P(b("Nuclear Changes (3 patterns — ALL exam favourite!):"), H3))
    nuclear = two_col_table(
        ["Change", "Description"],
        [
            [b("Pyknosis"),       "Nuclear SHRINKAGE + increased basophilia. DNA condenses into dark mass. FIRST change."],
            [b("Karyorrhexis"),   "Pyknotic nucleus FRAGMENTS. Nuclear debris scattered in cytoplasm."],
            [b("Karyolysis"),     "Basophilia FADES — DNase digests the DNA. Nucleus dissolves. LAST change."],
        ],
        hdr_bg=C_RED,
    )
    s.append(nuclear)
    s.append(SP(4))
    s.append(mnemonic_box("P → K → K", "Pyknosis → Karyorrhexis → Karyolysis  (nuclear sequence in necrosis)"))
    s.append(SP(4))

    s.append(P(b("Cytoplasmic Changes:"), H3))
    s.append(bul(b("↑ Eosinophilia:") + " Denatured proteins bind eosin; RNA (basophilic) is lost"))
    s.append(bul(b("Glassy / homogeneous:") + " Loss of glycogen granules"))
    s.append(bul(b("Moth-eaten vacuolation:") + " Organelle digestion by enzymes"))
    s.append(bul(b("EM:") + " Discontinuous membranes, dilated mitochondria with large amorphous densities, disrupted lysosomes, myelin figures"))
    s.append(SP(4))

    s.append(P(b("Clinical use — serum markers of necrosis:"), H3))
    s.append(bul("Cardiac troponin I/T → myocardial infarction"))
    s.append(bul("AST / ALT (transaminases) → hepatocyte necrosis"))
    s.append(bul("Alkaline phosphatase (heat-resistant isoform) → bile duct epithelium"))
    s.append(bul("CK-MB → cardiac + skeletal muscle"))
    s.append(SP(8))
    return s

# ─── Section 4: Types of Necrosis ────────────────────────────────────────────
def sec4():
    s = []
    s.append(section_header("TYPES OF NECROSIS", C_RED, "4"))
    s.append(SP(6))

    necrosis_types = [
        (b("1. Coagulative"),
         "Most common type. Protein denaturation preserves cell outline (ghost outline). "
         + b("Ischaemia of solid organs") + " (heart, kidney, spleen). "
         "Exception: BRAIN → liquefactive (lacks structural proteins).",
         C_LORANGE),
        (b("2. Liquefactive"),
         b("Brain infarction") + " (neural tissue rich in lipid, lysosomal enzymes → liquid pus). "
         "Also: " + b("bacterial abscesses") + " anywhere (neutrophil enzymes digest tissue). "
         "Result: cyst filled with liquid/pus.",
         C_LYELLOW),
        (b("3. Caseous (Cheese-like)"),
         "Characteristic of " + b("tuberculosis") + " (also fungi). "
         "Soft, friable, white-cheese gross appearance. "
         "Micro: amorphous granular debris + " + b("granuloma") + " (Langhans giant cells).",
         C_LGREY),
        (b("4. Fat Necrosis"),
         b("Acute pancreatitis") + " — lipase digests fat → free fatty acids + Ca²⁺ → "
         + b("saponification (chalky white deposits = dystrophic calcification)") + ". "
         "Also: traumatic fat necrosis (breast).",
         C_LTEAL),
        (b("5. Fibrinoid Necrosis"),
         "In " + b("blood vessel walls") + ". Immune complexes + fibrin deposited in vessel walls. "
         "Seen in: malignant hypertension, vasculitis, polyarteritis nodosa. "
         "Bright pink (eosinophilic) smudgy deposits.",
         C_LPURPLE),
        (b("6. Gangrenous Necrosis"),
         b("Not a morphologic pattern") + " — clinical term. "
         "Dry gangrene = coagulative (ischaemia, e.g., diabetic limb). "
         "Wet gangrene = coagulative + liquefactive (superimposed infection). "
         "Gas gangrene = " + i("Clostridium perfringens") + ".",
         C_LRED),
    ]

    for title, detail, bg in necrosis_types:
        row_data = [[Paragraph(title, BOLD_B), Paragraph(detail, BODY)]]
        tbl = Table(row_data, colWidths=[38*mm, W - LMARGIN - RMARGIN - 38*mm])
        tbl.setStyle(TableStyle([
            ("BACKGROUND",    (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 5),
            ("BOTTOMPADDING", (0,0), (-1,-1), 5),
            ("LEFTPADDING",   (0,0), (-1,-1), 8),
            ("BOX",           (0,0), (-1,-1), 0.8, HexColor("#B0BEC5")),
            ("VALIGN",        (0,0), (-1,-1), "TOP"),
        ]))
        s.append(tbl)
        s.append(SP(3))

    s.append(SP(4))
    s.append(exam_box([
        "Coagulative necrosis = most organs (EXCEPT brain)",
        "Liquefactive necrosis = brain infarct + bacterial abscess",
        "Caseous necrosis = TB (+ systemic fungi)",
        "Fat necrosis + saponification = acute pancreatitis",
        "Fibrinoid necrosis = blood vessels (hypertension, vasculitis)",
        "Coagulative necrosis preserves cell outline — ghost cells",
    ]))
    s.append(SP(8))
    return s

# ─── Section 5: Mechanisms of Cell Injury ────────────────────────────────────
def sec5():
    s = []
    s.append(section_header("MECHANISMS OF CELL INJURY", C_PURPLE, "5"))
    s.append(SP(6))

    mechs = [
        ("Mitochondrial Dysfunction / ATP Depletion",
         C_LPURPLE, C_PURPLE, [
            "↓ ATP → Na⁺/K⁺ ATPase pump fails → Na⁺ + H₂O enter → " + b("cell swelling"),
            "↑ Anaerobic glycolysis → lactic acid → ↓ pH → enzymes inactivated",
            "Ribosome detachment from RER → ↓ protein synthesis",
            "Prolonged: mitochondrial membrane permeability transition (MPT) → cytochrome c release → apoptosis",
            b("Large amorphous mitochondrial densities") + " on EM = irreversible injury marker",
        ]),
        ("Calcium Influx",
         C_LYELLOW, C_YELLOW, [
            "Normally: intracellular Ca²⁺ very low (10⁻⁷ M). Injury → ↑↑ Ca²⁺",
            b("Activates:") + " phospholipases (membrane damage), proteases (cytoskeletal breakdown), "
            "endonucleases (DNA fragmentation), ATPases (↓↓ ATP)",
        ]),
        ("Reactive Oxygen Species (Free Radical Injury / Oxidative Stress)",
         C_LTEAL, C_TEAL, [
            "ROS = superoxide (O₂•⁻), H₂O₂, hydroxyl radical (OH•)",
            b("Sources:") + " ischemia-reperfusion, radiation, inflammation, toxins (CCl₄)",
            b("Damage:") + " lipid peroxidation (membranes), protein oxidation, DNA strand breaks",
            b("Defences:") + " SOD, catalase, glutathione peroxidase, vitamins C & E",
        ]),
        ("Membrane Damage",
         C_LRED, C_RED, [
            "Loss of phospholipid integrity → ion pumps fail → cell swelling → death",
            "Causes: ROS, Ca²⁺-activated phospholipases, toxins, ischaemia",
            "Plasma membrane + mitochondrial membrane damage are key late events",
        ]),
        ("ER Stress / Misfolded Proteins",
         C_LORANGE, C_ORANGE, [
            "ER normally folds proteins; stress → unfolded protein response (UPR)",
            "If severe/prolonged → proapoptotic BH3-only proteins activated → apoptosis",
            "Examples: Alzheimer's disease (tau), type 2 diabetes (amyloid in islets)",
        ]),
        ("DNA Damage",
         C_LGREY, C_GREY, [
            "Causes: radiation, cytotoxic drugs, free radicals",
            "P53 activated → " + b("p53 is the guardian of the genome"),
            "If repair impossible → p53 activates apoptosis via mitochondrial pathway",
        ]),
    ]

    for title, bg, border, points in mechs:
        header_row = [[Paragraph(b(title), S("mh", fontName="Helvetica-Bold", fontSize=10,
                                              textColor=border))]]
        body_rows = [[Paragraph(f"• {pt}", BODY)] for pt in points]
        all_rows = header_row + body_rows
        tbl = Table(all_rows, colWidths=[W - LMARGIN - RMARGIN])
        tbl.setStyle(TableStyle([
            ("BACKGROUND",    (0,0), (0,0), bg),
            ("BACKGROUND",    (0,1), (-1,-1), HexColor("#FAFAFA")),
            ("TOPPADDING",    (0,0), (-1,-1), 4),
            ("BOTTOMPADDING", (0,0), (-1,-1), 4),
            ("LEFTPADDING",   (0,0), (-1,-1), 10),
            ("BOX",           (0,0), (-1,-1), 1, border),
            ("LINEBELOW",     (0,0), (0,0), 0.5, border),
        ]))
        s.append(tbl)
        s.append(SP(4))

    s.append(exam_box([
        "P53 = guardian of the genome — activates apoptosis after DNA damage",
        "CCl₄ toxicity → free radical injury → fatty change in liver",
        "Ischemia-reperfusion injury → ↑ ROS burst on reperfusion (worse than ischaemia alone)",
        "Ca²⁺ influx activates 4 enzymes: phospholipase, protease, endonuclease, ATPase",
    ]))
    s.append(SP(8))
    return s

# ─── Section 6: Apoptosis – Overview & Causes ────────────────────────────────
def sec6():
    s = []
    s.append(section_header("APOPTOSIS — OVERVIEW & CAUSES", C_GREEN, "6"))
    s.append(SP(6))

    s.append(info_box([
        b("Apoptosis") + ' (Greek: "falling off") = ' + b("programmed cell death") + ". "
        "Enzymes (caspases) degrade nuclear DNA + cytoplasmic proteins. "
        "Cell fragments → " + b("apoptotic bodies") + " → rapidly phagocytosed by macrophages. "
        + b("NO inflammation") + " (contents never leak out). Plasma membrane remains INTACT.",
    ], C_LGREEN, C_GREEN))
    s.append(SP(6))

    s.append(P(b("Physiologic Causes of Apoptosis:"), H3))
    physio = [
        "Embryogenesis — organ shaping (digit separation, neural tube closure)",
        "Normal cell turnover — intestinal epithelium, lymphocytes",
        "Hormone-dependent involution — endometrium (menstruation), breast (post-lactation)",
        "End of immune/inflammatory responses — leukocyte decline",
        "Elimination of self-reactive lymphocytes — prevents autoimmunity (clonal deletion in thymus)",
    ]
    for p in physio: s.append(bul(p))

    s.append(SP(6))
    s.append(P(b("Pathologic Causes of Apoptosis:"), H3))
    patho = [
        "DNA damage — radiation, cytotoxic chemotherapy → p53 activation",
        "Accumulation of misfolded proteins — ER stress (Alzheimer's, type 2 diabetes)",
        "Viral infections — viral proteins or cytotoxic T lymphocytes (CTLs) activate caspases",
        "Bile salt accumulation — hepatocytes in cholestasis",
        "Graft-versus-host disease",
        "Atrophy of hormone-dependent tumours (e.g., prostate after castration)",
    ]
    for p in patho: s.append(bul(p))

    s.append(SP(6))
    s.append(P(b("Morphology of Apoptosis:"), H3))
    s.append(bul(b("Cell shrinkage") + " (opposite of necrotic cell swelling)"))
    s.append(bul(b("Chromatin condensation") + " (pyknosis) — crescent-shaped beneath nuclear membrane"))
    s.append(bul(b("Cytoplasmic budding") + " → formation of " + b("apoptotic bodies")))
    s.append(bul(b("Apoptotic bodies phagocytosed") + " by macrophages / neighbouring cells — no inflammation"))
    s.append(bul("Membrane-bound fragments — phosphatidylserine flipped to outer leaflet (eat-me signal for macrophages)"))
    s.append(SP(8))
    return s

# ─── Section 7: Pathways of Apoptosis ────────────────────────────────────────
def sec7():
    s = []
    s.append(section_header("PATHWAYS OF APOPTOSIS", C_GREEN, "7"))
    s.append(SP(6))

    s.append(P("Both pathways converge on " + b("CASPASE ACTIVATION") + " (cysteine proteases that cleave after aspartate residues).", BODY))
    s.append(SP(6))

    # Pathway 1
    p1_data = [
        [Paragraph(b("MITOCHONDRIAL (INTRINSIC) PATHWAY"), S("p1h", fontName="Helvetica-Bold",
                    fontSize=10, textColor=white, alignment=TA_CENTER))],
        [Paragraph(
            b("Triggers:") + " Loss of survival signals, DNA damage, misfolded proteins (ER stress)<br/><br/>"
            + b("Key players:") + "<br/>"
            "• " + b("BCL-2, BCL-XL") + " = ANTI-apoptotic — produced in response to growth factors; maintain mitochondrial integrity<br/>"
            "• " + b("BAX, BAK") + " = PRO-apoptotic — form channels in mitochondrial membrane<br/>"
            "• " + b("BH3-only proteins") + " (BID, BAD, PUMA, NOXA) = sensors of stress; shift balance toward BAX/BAK<br/><br/>"
            + b("Mechanism:") + "<br/>"
            "1. Survival signals ↓ → BCL-2/BCL-XL ↓<br/>"
            "2. BH3-only proteins activate BAX + BAK<br/>"
            "3. BAX/BAK dimerize → pores in outer mitochondrial membrane<br/>"
            "4. " + b("Cytochrome c") + " leaks into cytosol<br/>"
            "5. Cytochrome c + APAF-1 + caspase-9 → " + b("apoptosome") + "<br/>"
            "6. Caspase-9 activates downstream caspases (3, 6, 7) → cell death<br/><br/>"
            + b("Inhibited by:") + " IAPs (inhibitor of apoptosis proteins); themselves inhibited by SMAC/DIABLO from mitochondria",
            BODY)],
    ]
    p1_tbl = Table(p1_data, colWidths=[W - LMARGIN - RMARGIN])
    p1_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_GREEN),
        ("BACKGROUND",    (0,1), (-1,-1), C_LGREEN),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 1.5, C_GREEN),
    ]))
    s.append(p1_tbl)
    s.append(SP(6))

    # Pathway 2
    p2_data = [
        [Paragraph(b("DEATH RECEPTOR (EXTRINSIC) PATHWAY"), S("p2h", fontName="Helvetica-Bold",
                    fontSize=10, textColor=white, alignment=TA_CENTER))],
        [Paragraph(
            b("Triggers:") + " Elimination of self-reactive lymphocytes; CTL-mediated killing<br/><br/>"
            + b("Key players:") + "<br/>"
            "• " + b("Death receptors") + " = TNF receptor family (Fas/CD95, TNFR1)<br/>"
            "• " + b("Death ligands") + " = FasL (on CTLs/cells), TNF<br/>"
            "• " + b("FADD") + " = adaptor protein<br/>"
            "• " + b("Caspase-8") + " = initiator caspase<br/><br/>"
            + b("Mechanism:") + "<br/>"
            "1. FasL binds Fas (CD95) on target cell<br/>"
            "2. Death domain clustering → FADD recruited<br/>"
            "3. FADD activates caspase-8 → DISC (Death-Inducing Signalling Complex)<br/>"
            "4. Caspase-8 → caspase-3 (executioner) → apoptosis<br/>"
            "5. Caspase-8 can also cleave BID → truncated BID (tBID) → amplification via mitochondrial pathway<br/><br/>"
            + b("Role:") + " Peripheral tolerance (Fas mutation → autoimmune lymphoproliferative syndrome)",
            BODY)],
    ]
    p2_tbl = Table(p2_data, colWidths=[W - LMARGIN - RMARGIN])
    p2_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_TEAL),
        ("BACKGROUND",    (0,1), (-1,-1), C_LTEAL),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 1.5, C_TEAL),
    ]))
    s.append(p2_tbl)
    s.append(SP(6))

    s.append(exam_box([
        "Intrinsic pathway: BCL-2 = anti-apoptotic; BAX/BAK = pro-apoptotic",
        "Cytochrome c release → apoptosome → caspase-9 → caspase-3 → death",
        "Extrinsic pathway: FasL–Fas → FADD → caspase-8 → caspase-3",
        "BCL-2 overexpression → follicular lymphoma (t(14;18)) — cells evade apoptosis",
        "p53 mutation → cells ignore DNA damage → cancer",
        "IAPs inhibit caspases (anti-apoptotic); SMAC inhibits IAPs",
    ]))
    s.append(SP(8))
    return s

# ─── Section 8: Necrosis vs Apoptosis ────────────────────────────────────────
def sec8():
    s = []
    s.append(section_header("NECROSIS vs APOPTOSIS — COMPARISON", C_ORANGE, "8"))
    s.append(SP(6))

    comp = two_col_table(
        ["FEATURE", "NECROSIS  vs  APOPTOSIS"],
        [
            [b("Type of death"),        "Pathologic (abnormal) vs Physiologic OR pathologic"],
            [b("Stimulus"),             "Severe/irreversible injury vs DNA damage, loss of signals"],
            [b("Cell size"),            "Swelling (oncosis) vs Shrinkage"],
            [b("Nucleus"),              "Pyknosis → karyorrhexis → karyolysis vs Condensation, fragmentation"],
            [b("Membrane"),             "Disrupted (leaky) vs Intact (phosphatidylserine flipped out)"],
            [b("Cell contents"),        "Leak out vs Packaged in apoptotic bodies"],
            [b("Inflammation"),         "YES (major feature) vs NO (phagocytosed before leaking)"],
            [b("Mechanism"),            "Enzyme leakage, ATP depletion vs Caspase activation"],
            [b("Histology"),            "Ghost cells, inflammatory infiltrate vs Apoptotic bodies, no inflammation"],
            [b("BCL-2 role"),           "Not directly relevant vs Anti-apoptotic (↓ apoptosis)"],
            [b("Clinical use"),         "Serum markers (troponin, LFTs) vs Tissue remodelling, cancer therapy"],
        ],
        col_widths=[(W-LMARGIN-RMARGIN)*0.30, (W-LMARGIN-RMARGIN)*0.70],
        hdr_bg=C_ORANGE,
    )
    s.append(comp)
    s.append(SP(6))

    s.append(mnemonic_box(
        "SNAP",
        "S=Shrinks(apoptosis) N=No inflammation(apoptosis) A=Always caspases(apoptosis) P=Pathologic only(necrosis)"
    ))
    s.append(SP(8))
    return s

# ─── Section 9: Cellular Adaptations ─────────────────────────────────────────
def sec9():
    s = []
    s.append(section_header("CELLULAR ADAPTATIONS TO STRESS", C_TEAL, "9"))
    s.append(SP(6))

    adapt = [
        (b("Hypertrophy"), C_LTEAL, C_TEAL,
         "↑ Cell SIZE (not number). Organ enlarges. "
         "Occurs in cells that CANNOT divide (cardiac myocytes, neurons). "
         "Triggered by ↑ workload + growth factors (IGF-1, TGF-β). "
         + b("Physiologic:") + " athlete's heart, uterus in pregnancy. "
         + b("Pathologic:") + " hypertensive LV hypertrophy, aortic stenosis → concentric LVH."),
        (b("Hyperplasia"), C_LGREEN, C_GREEN,
         "↑ Cell NUMBER. Requires cells capable of dividing (stem cells present). "
         "Often co-exists with hypertrophy. "
         + b("Physiologic:") + " hormonal (breast/uterus), compensatory (liver regeneration, remaining kidney). "
         + b("Pathologic:") + " endometrial hyperplasia (excess oestrogen), benign prostatic hyperplasia (BPH), "
         "viral warts (HPV)."),
        (b("Atrophy"), C_LGREY, C_GREY,
         "↓ Cell SIZE (+ possibly number via apoptosis). "
         b("Causes:") + " disuse, denervation, loss of blood supply, inadequate nutrition, "
         "loss of endocrine stimulation, ageing. "
         "Mechanism: ↓ protein synthesis + ↑ protein degradation (ubiquitin-proteasome pathway). "
         "Lipofuscin pigment accumulates in atrophic cells."),
        (b("Metaplasia"), C_LPURPLE, C_PURPLE,
         "Change in differentiated cell type — " + b("reversible") + " if stimulus removed. "
         "Stem cells reprogram under persistent stress. "
         b("Examples:") + " Barrett's oesophagus (squamous → columnar, acid reflux); "
         "Respiratory metaplasia (columnar → squamous, smokers); "
         "Cervical ectopy (columnar → squamous). "
         + b("Risk:") + " can progress to dysplasia → carcinoma if uncorrected."),
        (b("Dysplasia"), C_LEXAM, C_EXAM,
         b("NOT a true adaptation") + " — disordered growth. Variable cell size, nuclear pleomorphism, "
         "↑ mitoses, loss of polarity. "
         "Pre-neoplastic but " + b("REVERSIBLE") + " if stimulus removed. "
         "Examples: cervical dysplasia (HPV), bronchial dysplasia (smoking)."),
    ]

    for title, bg, border, detail in adapt:
        row = [[Paragraph(title, S("ah", fontName="Helvetica-Bold", fontSize=10, textColor=border)),
                Paragraph(detail, BODY)]]
        tbl = Table(row, colWidths=[32*mm, W - LMARGIN - RMARGIN - 32*mm])
        tbl.setStyle(TableStyle([
            ("BACKGROUND",    (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 5),
            ("BOTTOMPADDING", (0,0), (-1,-1), 5),
            ("LEFTPADDING",   (0,0), (-1,-1), 8),
            ("BOX",           (0,0), (-1,-1), 0.8, border),
            ("VALIGN",        (0,0), (-1,-1), "TOP"),
        ]))
        s.append(tbl)
        s.append(SP(3))

    s.append(SP(4))
    s.append(exam_box([
        "Hypertrophy = ↑ size; Hyperplasia = ↑ number (can co-exist)",
        "Barrett's oesophagus = squamous → columnar metaplasia (pre-malignant)",
        "Dysplasia is reversible but pre-neoplastic",
        "Atrophy in old age → lipofuscin (wear-and-tear pigment) accumulation",
        "Denervation atrophy — most classic example: disused limb after nerve injury",
    ]))
    s.append(SP(8))
    return s

# ─── Section 10: Autophagy & Other Deaths ────────────────────────────────────
def sec10():
    s = []
    s.append(section_header("AUTOPHAGY & OTHER FORMS OF CELL DEATH", C_GREY, "10"))
    s.append(SP(6))

    auto_data = [
        [Paragraph(b("AUTOPHAGY"), S("ah2", fontName="Helvetica-Bold", fontSize=10, textColor=C_TEAL))],
        [Paragraph(
            "Self-eating — cells degrade their own organelles to survive nutrient deprivation.<br/>"
            "Regulated by " + b("ATG genes") + " (autophagy-related genes).<br/>"
            b("Process:") + " Phagophore (isolation membrane) → wraps organelles → autophagosome → "
            "fuses with lysosome → contents degraded → nutrients recycled.<br/>"
            b("Role:") + " Survival mechanism during starvation. If stress not relieved → can trigger apoptosis.<br/>"
            b("Disease link:") + " Defective autophagy → Parkinson's disease, cancer, aging.",
            BODY)],
    ]
    auto_tbl = Table(auto_data, colWidths=[W - LMARGIN - RMARGIN])
    auto_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), C_LTEAL),
        ("BACKGROUND",    (0,1), (-1,-1), HexColor("#F9FFFE")),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 1.5, C_TEAL),
    ]))
    s.append(auto_tbl)
    s.append(SP(6))

    other_deaths = two_col_table(
        ["Type", "Features"],
        [
            [b("Necroptosis"),
             "Regulated necrosis — features of both necrosis AND apoptosis. "
             "Triggered by RIPK1/RIPK3 signalling. Inflammatory (like necrosis) but programmed (like apoptosis). "
             "Caspase-INDEPENDENT."],
            [b("Pyroptosis"),
             "Inflammatory programmed death. Activation of inflammasome (NLRP3) → caspase-1 → "
             "IL-1β + IL-18 release → fever + inflammation. Pore formation → cell lysis. "
             "Role: infection defence (Salmonella, COVID-19)."],
            [b("Ferroptosis"),
             "Iron-dependent lipid peroxidation → oxidative cell death. "
             "Distinct from apoptosis (no caspases), necrosis. "
             "Role: cancer, ischaemia-reperfusion injury."],
            [b("Anoikis"),
             "Apoptosis triggered by loss of cell-matrix attachment. "
             "Cancer cells evade anoikis → enable metastasis."],
        ],
        hdr_bg=C_GREY,
    )
    s.append(other_deaths)
    s.append(SP(8))
    return s

# ─── Section 11: High-Yield One-Liners ───────────────────────────────────────
def sec11():
    s = []
    s.append(section_header("HIGH-YIELD ONE-LINERS FOR FMGE / NEXT / USMLE", C_EXAM, "11"))
    s.append(SP(6))

    oneliners = [
        ("Cell function lost BEFORE morphologic changes — classic principle"),
        ("Ischemia: myocytes non-contractile at 1–2 min; die at 20–30 min"),
        ("EM changes of death at 2–3 h; H&E changes at 6–12 h"),
        ("Pyknosis → Karyorrhexis → Karyolysis (nuclear sequence in necrosis)"),
        ("Coagulative necrosis = most organs. Exception: BRAIN → liquefactive"),
        ("Brain infarct = liquefactive (not coagulative) necrosis"),
        ("Caseous necrosis = TB. Granuloma = Langhans giant cells"),
        ("Fat necrosis + saponification = acute pancreatitis"),
        ("Fibrinoid necrosis = vessel walls in hypertension / vasculitis"),
        ("Necrosis = ALWAYS inflammatory. Apoptosis = NO inflammation"),
        ("Apoptosis = cell shrinks. Necrosis = cell swells"),
        ("BCL-2 = anti-apoptotic; t(14;18) in follicular lymphoma → BCL-2 overexpression"),
        ("P53 = guardian of genome — activated by DNA damage → apoptosis"),
        ("P53 mutation → most common mutation in all human cancers"),
        ("Cytochrome c + APAF-1 + caspase-9 = apoptosome (intrinsic pathway)"),
        ("FasL–Fas → caspase-8 = extrinsic pathway"),
        ("Caspase-8 can cross-activate mitochondrial pathway via BID cleavage"),
        ("IAPs inhibit caspases; SMAC/DIABLO from mitochondria inhibit IAPs"),
        ("Hypertrophy = ↑ size; Hyperplasia = ↑ number"),
        ("Cardiac hypertrophy: physiologic (athlete) vs pathologic (hypertension)"),
        ("Barrett's oesophagus: squamous → columnar (acid exposure) — pre-malignant"),
        ("Metaplasia reversible; dysplasia reversible but pre-neoplastic"),
        ("Lipofuscin (wear-and-tear pigment) = atrophic cells in elderly"),
        ("ROS: superoxide (O₂•⁻), H₂O₂, hydroxyl radical (OH•) — most reactive = OH•"),
        ("CCl₄ → trichloromethyl radical (CCl₃•) → lipid peroxidation → fatty liver"),
        ("Ischemia-reperfusion: reperfusion WORSENS damage via ROS burst + Ca²⁺ influx"),
        ("Pyroptosis = inflammasome (NLRP3) → caspase-1 → IL-1β/IL-18 → fever"),
        ("Necroptosis = regulated necrosis via RIPK1/RIPK3; caspase-independent"),
    ]

    for i, line in enumerate(oneliners):
        bg = C_LEXAM if i % 2 == 0 else white
        row = [[Paragraph(f"{i+1}.", TABLE_H),
                Paragraph(line, EXAM_P)]]
        tbl = Table(row, colWidths=[12*mm, W - LMARGIN - RMARGIN - 12*mm])
        tbl.setStyle(TableStyle([
            ("BACKGROUND",    (0,0), (-1,-1), bg),
            ("TOPPADDING",    (0,0), (-1,-1), 3),
            ("BOTTOMPADDING", (0,0), (-1,-1), 3),
            ("LEFTPADDING",   (0,0), (-1,-1), 6),
            ("BACKGROUND",    (0,0), (0,0), C_EXAM),
            ("BOX",           (0,0), (-1,-1), 0.3, HexColor("#F8BBD0")),
        ]))
        s.append(tbl)
    s.append(SP(10))
    return s

# ─── Build document ───────────────────────────────────────────────────────────
def build():
    doc = SimpleDocTemplate(
        OUTPUT,
        pagesize=A4,
        leftMargin=LMARGIN, rightMargin=RMARGIN,
        topMargin=TMARGIN, bottomMargin=BMARGIN,
        title="Cell Injury & Apoptosis — Easy Notes (FMGE/NEXT/USMLE)",
        author="Orris Medical",
    )

    story = []
    story += cover_page()
    story += sec1()
    story += sec2()
    story += sec3()
    story += sec4()
    story.append(PageBreak())
    story += sec5()
    story += sec6()
    story += sec7()
    story.append(PageBreak())
    story += sec8()
    story += sec9()
    story.append(PageBreak())
    story += sec10()
    story += sec11()

    doc.build(story)
    print(f"Done: {OUTPUT}")

build()
Running Command

cd /home/daytona/workspace/cell-injury-notes && python make_notes.py 2>&1

Reading File
Editing File

~/cell-injury-notes/make_notes.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/cell-injury-notes/make_notes.py'
Running Command

cd /home/daytona/workspace/cell-injury-notes && python make_notes.py 2>&1

Reading File
Editing File

~/cell-injury-notes/make_notes.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/cell-injury-notes/make_notes.py'
Running Command

cd /home/daytona/workspace/cell-injury-notes && python -c " import ast, sys with…

Editing File

~/cell-injury-notes/make_notes.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/cell-injury-notes/make_notes.py'
Running Command

cd /home/daytona/workspace/cell-injury-notes && python -c " import ast with open…

Your PDF notes are ready! Download here:

Cell Injury Apoptosis Notes

PDF Document · PDF


What's inside the PDF (11 sections, exam-optimised)

#SectionColour
1Causes of Cell InjuryBlue
2Reversible vs Irreversible Injury (with myocardium timeline)Teal
3Morphology of Necrosis — nuclear changes P→K→KRed
4All 6 Types of Necrosis with organ-wise examplesRed
5Mechanisms of Cell Injury (ATP, Ca²⁺, ROS, membrane, ER stress, DNA)Purple
6Apoptosis — Overview, Physiologic & Pathologic causesGreen
7Intrinsic (BCL-2/BAX/cytochrome c) + Extrinsic (Fas-FasL) pathwaysGreen
8Necrosis vs Apoptosis comparison tableOrange
9Cellular Adaptations (hypertrophy, hyperplasia, atrophy, metaplasia, dysplasia)Teal
10Autophagy, Necroptosis, Pyroptosis, FerroptosisGrey
1128 High-Yield One-Liners for FMGE/NEXT/USMLEPink
Every section has a highlighted "High-Yield Exam Points" box and mnemonics where useful (e.g., P-K-K for nuclear changes, SNAP for Necrosis vs Apoptosis). Based on Robbins & Kumar Basic Pathology.

Create flashcards from the apoptosis pathways (BCL-2, caspases)

Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Writing File

~/apoptosis-flashcards/make_apoptosis_cards.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.pdfgen import canvas
from reportlab.lib.colors import HexColor, white, black
from reportlab.platypus import Paragraph
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER
import textwrap

OUTPUT = "/home/daytona/workspace/apoptosis-flashcards/Apoptosis_Pathway_Flashcards.pdf"

# ─── Colour palette ───────────────────────────────────────────────────────────
GREEN     = HexColor("#1B5E20")
LGREEN    = HexColor("#E8F5E9")
TEAL      = HexColor("#00695C")
LTEAL     = HexColor("#E0F2F1")
PURPLE    = HexColor("#4A148C")
LPURPLE   = HexColor("#EDE7F6")
BLUE      = HexColor("#0D47A1")
LBLUE     = HexColor("#E3F2FD")
RED       = HexColor("#B71C1C")
LRED      = HexColor("#FFEBEE")
ORANGE    = HexColor("#E65100")
LORANGE   = HexColor("#FFF3E0")
EXAM      = HexColor("#880E4F")
LEXAM     = HexColor("#FCE4EC")
DARK      = HexColor("#0D1B2A")
GREY      = HexColor("#37474F")
LGREY     = HexColor("#ECEFF1")

# ─── Page layout ──────────────────────────────────────────────────────────────
W, H      = A4           # 595 x 842 pt
MARGIN    = 16 * mm
CARD_W    = W - 2 * MARGIN
CARD_GAP  = 6 * mm
CARD_H    = (H - 2 * MARGIN - CARD_GAP) / 2   # 2 cards per page
RADIUS    = 9

# ─── Font helpers ─────────────────────────────────────────────────────────────
def draw_wrapped(c, text, x, y, max_w, font, size, color=DARK, leading=13):
    """Draw text with manual word-wrap. Returns final y position."""
    c.setFont(font, size)
    c.setFillColor(color)
    words = text.split()
    line = ""
    cy = y
    for word in words:
        test = (line + " " + word).strip()
        if c.stringWidth(test, font, size) <= max_w:
            line = test
        else:
            if line:
                c.drawString(x, cy, line)
                cy -= leading
            line = word
    if line:
        c.drawString(x, cy, line)
        cy -= leading
    return cy

def draw_bullet_lines(c, lines, x, y, max_w, indent=10):
    """Draw a list of (bullet_char, text, font, size, color) tuples."""
    cy = y
    for item in lines:
        if len(item) == 5:
            bchar, text, font, size, color = item
        else:
            bchar, text = item
            font, size, color = "Helvetica", 8.8, DARK
        if cy < MARGIN + 12:
            break
        # bullet
        c.setFont("Helvetica-Bold", size)
        c.setFillColor(color)
        c.drawString(x, cy, bchar)
        # text
        bw = c.stringWidth(bchar + "  ", "Helvetica-Bold", size)
        cy = draw_wrapped(c, text, x + bw, cy, max_w - bw, font, size, color, leading=size * 1.45)
        cy -= 2
    return cy

# ─── Card drawing engine ──────────────────────────────────────────────────────
def draw_card(cv, origin_y, card):
    """
    card = {
      "num": int,
      "category": str,
      "question": str,
      "answer_sections": [
          {"title": str or None, "lines": [(bullet, text, font, size, color), ...]},
      ],
      "theme": (header_bg, body_bg, border),
      "exam_tip": str or None
    }
    """
    hdr_bg, body_bg, border = card["theme"]
    x = MARGIN
    cw = CARD_W
    ch = CARD_H
    HDR_H = 48

    # ── Card body background ──
    cv.setFillColor(body_bg)
    cv.setStrokeColor(border)
    cv.setLineWidth(1.8)
    cv.roundRect(x, origin_y, cw, ch, RADIUS, stroke=1, fill=1)

    # ── Header strip ──
    cv.saveState()
    p = cv.beginPath()
    p.roundRect(x, origin_y + ch - HDR_H, cw, HDR_H, RADIUS)
    cv.clipPath(p, stroke=0)
    cv.setFillColor(hdr_bg)
    cv.rect(x, origin_y + ch - HDR_H, cw, HDR_H, stroke=0, fill=1)
    # Fill bottom of header (kill lower rounding)
    cv.rect(x, origin_y + ch - HDR_H, cw, RADIUS, stroke=0, fill=1)
    cv.restoreState()

    # ── Number badge ──
    badge_r = 13
    bx = x + badge_r + 7
    by = origin_y + ch - HDR_H / 2
    cv.setFillColor(white)
    cv.circle(bx, by, badge_r, stroke=0, fill=1)
    cv.setFillColor(hdr_bg)
    cv.setFont("Helvetica-Bold", 11)
    cv.drawCentredString(bx, by - 4, str(card["num"]))

    # ── Category tag (top right) ──
    cv.setFillColor(HexColor("#FFFFFF88") if True else white)
    cv.setFillColor(white)
    cv.setFont("Helvetica-Oblique", 7.5)
    cat = card["category"]
    cv.drawRightString(x + cw - 10, origin_y + ch - 13, cat)

    # ── Question text ──
    q_x = bx + badge_r + 10
    q_y_mid = origin_y + ch - HDR_H / 2 + 5
    q_max_w = cw - (q_x - x) - 14
    cv.setFillColor(white)
    cv.setFont("Helvetica-Bold", 10.5)
    # Simple two-line truncation for question
    words = card["question"].split()
    line1, line2 = "", ""
    for w in words:
        test = (line1 + " " + w).strip()
        if cv.stringWidth(test, "Helvetica-Bold", 10.5) <= q_max_w:
            line1 = test
        else:
            if not line2:
                line2 = w
            else:
                test2 = (line2 + " " + w).strip()
                if cv.stringWidth(test2, "Helvetica-Bold", 10.5) <= q_max_w:
                    line2 = test2
    if line2:
        cv.drawString(q_x, q_y_mid + 5, line1)
        cv.setFont("Helvetica-Bold", 10.0)
        cv.drawString(q_x, q_y_mid - 8, line2)
    else:
        cv.drawString(q_x, q_y_mid - 3, line1)

    # ── Answer area ──
    inner_x = x + 12
    inner_w  = cw - 24
    cur_y = origin_y + ch - HDR_H - 12

    for sec in card["answer_sections"]:
        if cur_y < origin_y + 10:
            break
        title = sec.get("title")
        if title:
            cv.setFillColor(border)
            cv.setFont("Helvetica-Bold", 9)
            cv.drawString(inner_x, cur_y, title)
            cur_y -= 13
        cur_y = draw_bullet_lines(cv, sec["lines"], inner_x, cur_y, inner_w)
        cur_y -= 4

    # ── Exam tip strip ──
    tip = card.get("exam_tip")
    if tip:
        tip_h = 16
        tip_y = origin_y + 4
        cv.setFillColor(LEXAM)
        cv.roundRect(inner_x, tip_y, inner_w, tip_h, 4, stroke=0, fill=1)
        cv.setFillColor(EXAM)
        cv.setFont("Helvetica-Bold", 7.5)
        cv.drawString(inner_x + 6, tip_y + 4, "EXAM: " + tip[:130])


# ─── Cover ────────────────────────────────────────────────────────────────────
def draw_cover(cv):
    cv.setFillColor(DARK)
    cv.rect(0, 0, W, H, fill=1, stroke=0)
    # decorative circles
    for cx2, cy2, r, col in [
        (W*0.88, H*0.88, 110, "#1B5E20"),
        (W*0.1,  H*0.12, 75,  "#4A148C"),
        (W*0.5,  H*0.5,  190, "#0A2740"),
    ]:
        cv.setFillColor(HexColor(col))
        cv.circle(cx2, cy2, r, fill=1, stroke=0)

    cv.setFillColor(white)
    cv.setFont("Helvetica-Bold", 32)
    cv.drawCentredString(W/2, H*0.63, "APOPTOSIS PATHWAYS")
    cv.setFont("Helvetica-Bold", 19)
    cv.setFillColor(HexColor("#A5D6A7"))
    cv.drawCentredString(W/2, H*0.56, "BCL-2 Family  |  Caspases  |  Pathways")
    cv.setFont("Helvetica", 11.5)
    cv.setFillColor(HexColor("#B0BEC5"))
    cv.drawCentredString(W/2, H*0.50, "Flashcard Deck  -  FMGE / NEXT / USMLE")

    # colour key
    keys = [("Intrinsic Path", "#1B5E20"), ("Extrinsic Path", "#00695C"),
            ("BCL-2 Family",  "#4A148C"), ("Caspases",       "#0D47A1"),
            ("Clinical/Exam", "#880E4F"), ("Comparison",     "#E65100")]
    bw2, bh2 = 88, 22
    total_w = len(keys) * bw2 + (len(keys)-1)*8
    sx = (W - total_w)/2
    for i, (lab, col) in enumerate(keys):
        bx2 = sx + i*(bw2+8)
        by2 = H * 0.41
        cv.setFillColor(HexColor(col))
        cv.roundRect(bx2, by2, bw2, bh2, 5, fill=1, stroke=0)
        cv.setFillColor(white)
        cv.setFont("Helvetica-Bold", 7.5)
        cv.drawCentredString(bx2 + bw2/2, by2 + 7, lab)

    cv.setFillColor(HexColor("#78909C"))
    cv.setFont("Helvetica", 9.5)
    cv.drawCentredString(W/2, H*0.35, "22 Flashcards  -  Based on Robbins Pathology & Medical Microbiology")
    cv.showPage()


# ─── Card data ────────────────────────────────────────────────────────────────
T_INT  = (GREEN,  LGREEN,  GREEN)   # intrinsic
T_EXT  = (TEAL,   LTEAL,   TEAL)    # extrinsic
T_BCL  = (PURPLE, LPURPLE, PURPLE)  # BCL-2 family
T_CASP = (BLUE,   LBLUE,   BLUE)    # caspases
T_CL   = (EXAM,   LEXAM,   EXAM)    # clinical / exam
T_COMP = (ORANGE, LORANGE, ORANGE)  # comparison

CARDS = [

    # ════ OVERVIEW ════════════════════════════════════════════════════════════
    {
        "num": 1, "category": "Overview",
        "question": "What is apoptosis and how does it differ from necrosis?",
        "theme": T_COMP,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", 'Apoptosis = "falling off" (Greek) - programmed cell death', "Helvetica-Bold", 9, ORANGE),
                ("•", "Caspases degrade nuclear DNA + cytoplasmic proteins", "Helvetica", 8.8, DARK),
                ("•", "Cell fragments into APOPTOTIC BODIES - phagocytosed by macrophages", "Helvetica", 8.8, DARK),
                ("•", "Plasma membrane INTACT throughout (contents never leak)", "Helvetica", 8.8, DARK),
                ("•", "NO inflammation (vs necrosis which always causes inflammation)", "Helvetica-Bold", 9, RED),
                ("•", "Two pathways: Mitochondrial (intrinsic) + Death receptor (extrinsic)", "Helvetica", 8.8, DARK),
                ("•", "Both converge on CASPASE ACTIVATION", "Helvetica-Bold", 9, BLUE),
            ]
        }],
        "exam_tip": "Apoptosis = NO inflammation. Necrosis = ALWAYS inflammation."
    },

    {
        "num": 2, "category": "Overview",
        "question": "What are caspases and why are they central to apoptosis?",
        "theme": T_CASP,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "Caspases = Cysteine proteASES that cleave after ASPartate residues", "Helvetica-Bold", 9, BLUE),
                ("•", "Named: C (cysteine) + ASP (aspartate cleavage) + ASE (enzyme)", "Helvetica", 8.8, DARK),
                ("•", "Present as inactive PROCASPASES (zymogens) - activated by cleavage", "Helvetica", 8.8, DARK),
                ("",  "INITIATOR caspases (activate the cascade):", "Helvetica-Bold", 8.5, BLUE),
                ("   -", "Caspase-8: extrinsic/death receptor pathway", "Helvetica", 8.5, DARK),
                ("   -", "Caspase-9: intrinsic/mitochondrial pathway", "Helvetica", 8.5, DARK),
                ("",  "EXECUTIONER caspases (carry out cell death):", "Helvetica-Bold", 8.5, BLUE),
                ("   -", "Caspase-3, -6, -7: activated by initiator caspases", "Helvetica", 8.5, DARK),
                ("•", "Executioners cleave cytoskeletal proteins, DNA repair enzymes, activate DNase", "Helvetica", 8.8, DARK),
                ("•", "CASP-3 is the main executioner - considered the final common effector", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "Initiators: Casp-8 (extrinsic), Casp-9 (intrinsic). Executioner: Casp-3."
    },

    # ════ BCL-2 FAMILY ════════════════════════════════════════════════════════
    {
        "num": 3, "category": "BCL-2 Family",
        "question": "What is the BCL-2 family and how are members classified?",
        "theme": T_BCL,
        "answer_sections": [{
            "title": "BCL-2 Family (>20 proteins - all share BCL-2 Homology domains)",
            "lines": [
                ("•", "ANTI-apoptotic (pro-survival): BCL-2, BCL-XL, BCL-w, MCL-1, BFL-1/A1", "Helvetica-Bold", 9, GREEN),
                ("   -", "Have BH1+BH2+BH3+BH4 domains (all 4)", "Helvetica", 8.5, DARK),
                ("   -", "Maintain mitochondrial outer membrane integrity", "Helvetica", 8.5, DARK),
                ("•", "PRO-apoptotic effectors: BAX, BAK", "Helvetica-Bold", 9, RED),
                ("   -", "Have BH1+BH2+BH3 (3 domains)", "Helvetica", 8.5, DARK),
                ("   -", "Form pores in mitochondrial membrane -> cytochrome c release", "Helvetica", 8.5, DARK),
                ("•", "PRO-apoptotic BH3-only sensors (stress sensors): BAD, BIM, BID, PUMA, NOXA, HRK, BIK", "Helvetica-Bold", 9, RED),
                ("   -", "Only BH3 domain - activate BAX/BAK OR neutralize BCL-2", "Helvetica", 8.5, DARK),
            ]
        }],
        "exam_tip": "Anti-apoptotic: BCL-2, BCL-XL. Pro-apoptotic effectors: BAX, BAK. BH3-only sensors: BIM, PUMA, NOXA, BID, BAD."
    },

    {
        "num": 4, "category": "BCL-2 Family",
        "question": "How does BCL-2 protect cells from apoptosis?",
        "theme": T_BCL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "BCL-2 located in: outer mitochondrial membrane, ER, plasma membrane", "Helvetica", 8.8, DARK),
                ("•", "In healthy cells: BCL-2/BCL-XL produced in response to growth factors", "Helvetica-Bold", 9, GREEN),
                ("•", "Mechanism of protection:", "Helvetica-Bold", 9, PURPLE),
                ("   1.", "Sequesters BAX and BAK -> prevents pore formation", "Helvetica", 8.5, DARK),
                ("   2.", "Prevents mitochondrial outer membrane depolarization", "Helvetica", 8.5, DARK),
                ("   3.", "Blocks cytochrome c release from mitochondria", "Helvetica", 8.5, DARK),
                ("•", "BCL-XL also actively transports BAX from mitochondria to cytoplasm", "Helvetica", 8.8, DARK),
                ("•", "When survival signals fall: BCL-2/BCL-XL levels drop -> BAX/BAK unchecked", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "BCL-2 overexpression = cells survive inappropriate signals -> CANCER (follicular lymphoma)."
    },

    {
        "num": 5, "category": "BCL-2 Family",
        "question": "What are BH3-only proteins and what are their two functions?",
        "theme": T_BCL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "BH3-only proteins = upstream STRESS SENSORS of the BCL-2 family", "Helvetica-Bold", 9, PURPLE),
                ("•", "Only contain BH3 domain (third BCL-2 homology domain)", "Helvetica", 8.8, DARK),
                ("",  "TWO mechanisms of action:", "Helvetica-Bold", 9, PURPLE),
                ("   1.", "SENSITIZER function: compete with BAX/BAK for BCL-2 binding -> displaces BAX -> BAX free to oligomerize", "Helvetica", 8.5, DARK),
                ("   2.", "DIRECT ACTIVATOR function: bind BAX directly -> conformational change -> oligomerization -> pore formation", "Helvetica", 8.5, DARK),
                ("",  "Key BH3-only members:", "Helvetica-Bold", 9, PURPLE),
                ("•", "BIM, PUMA, NOXA: activated by DNA damage, growth factor withdrawal", "Helvetica", 8.5, DARK),
                ("•", "BAD: inactivated by phosphorylation (survival signal from Akt)", "Helvetica", 8.5, DARK),
                ("•", "BID: cleaved by CASPASE-8 -> tBID -> links extrinsic to intrinsic pathway", "Helvetica-Bold", 8.8, RED),
            ]
        }],
        "exam_tip": "BID connects extrinsic pathway to intrinsic: Casp-8 cleaves BID -> tBID -> mitochondria -> amplifies signal."
    },

    {
        "num": 6, "category": "BCL-2 Family",
        "question": "What is the role of BAX and BAK in the intrinsic pathway?",
        "theme": T_BCL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "BAX and BAK = pro-apoptotic EFFECTORS (BH1-2-3 domains)", "Helvetica-Bold", 9, RED),
                ("•", "BAX: normally cytoplasmic; translocates to outer mitochondrial membrane on apoptotic signal", "Helvetica", 8.8, DARK),
                ("•", "BAK: constitutively located in outer mitochondrial membrane", "Helvetica", 8.8, DARK),
                ("•", "Both form HOMOOLIGOMERS -> create pores (MOMP - Mitochondrial Outer Membrane Permeabilization)", "Helvetica-Bold", 9, RED),
                ("•", "Pores allow: cytochrome c, SMAC/DIABLO, HtrA2/Omi to escape into cytosol", "Helvetica", 8.8, DARK),
                ("•", "Functional REDUNDANCY: cells lacking BOTH BAX and BAK fail to undergo apoptosis", "Helvetica-Bold", 9, PURPLE),
                ("•", "Normally held in check by BCL-2/BCL-XL", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "BAX/BAK both needed - removing only one is not enough to block apoptosis (redundancy)."
    },

    # ════ INTRINSIC (MITOCHONDRIAL) PATHWAY ══════════════════════════════════
    {
        "num": 7, "category": "Intrinsic Pathway",
        "question": "What triggers the intrinsic (mitochondrial) apoptosis pathway?",
        "theme": T_INT,
        "answer_sections": [{
            "title": "Triggers (any stress that damages the cell from within):",
            "lines": [
                ("•", "Loss of survival signals / growth factors", "Helvetica", 8.8, DARK),
                ("•", "DNA damage (radiation, cytotoxic drugs) -> p53 activation -> PUMA/NOXA", "Helvetica", 8.8, DARK),
                ("•", "ER stress / misfolded protein accumulation (Alzheimer's, T2DM)", "Helvetica", 8.8, DARK),
                ("•", "Oxidative stress (excess ROS)", "Helvetica", 8.8, DARK),
                ("•", "Hypoxia, toxins, chemotherapy agents", "Helvetica", 8.8, DARK),
                ("",  "Result: BH3-only proteins activated -> shift balance from BCL-2 to BAX/BAK", "Helvetica-Bold", 9, GREEN),
            ]
        }],
        "exam_tip": "Intrinsic = MOST physiologic and pathologic apoptosis. DNA damage -> p53 -> PUMA -> BAX -> apoptosis."
    },

    {
        "num": 8, "category": "Intrinsic Pathway",
        "question": "Describe the step-by-step intrinsic apoptosis pathway",
        "theme": T_INT,
        "answer_sections": [{
            "title": "Step-by-step sequence:",
            "lines": [
                ("1.", "Stress signal -> BH3-only proteins (BIM, PUMA, NOXA) activated", "Helvetica", 8.8, DARK),
                ("2.", "BCL-2/BCL-XL levels fall + BH3-only proteins neutralize them", "Helvetica", 8.8, DARK),
                ("3.", "BAX + BAK dimerize -> insert into outer mitochondrial membrane", "Helvetica", 8.8, DARK),
                ("4.", "MOMP (pore formation) -> Cytochrome c leaks into cytosol", "Helvetica-Bold", 9, GREEN),
                ("5.", "Cytochrome c + APAF-1 + dATP -> conformational change in APAF-1", "Helvetica", 8.8, DARK),
                ("6.", "APAF-1 oligomerizes into HEPTAMER = APOPTOSOME (wheel structure)", "Helvetica-Bold", 9, GREEN),
                ("7.", "Apoptosome recruits PROCASPASE-9 via CARD domain", "Helvetica", 8.8, DARK),
                ("8.", "Procaspase-9 autocleaves -> active CASPASE-9 (initiator)", "Helvetica", 8.8, DARK),
                ("9.", "Caspase-9 activates CASPASE-3/-6/-7 (executioners) -> cell death", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "Cytochrome c + APAF-1 + caspase-9 = APOPTOSOME. Caspase-9 is the initiator of intrinsic pathway."
    },

    {
        "num": 9, "category": "Intrinsic Pathway",
        "question": "What is the apoptosome and what is its structure?",
        "theme": T_INT,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "Apoptosome = wheel-like activation platform for caspase-9", "Helvetica-Bold", 9, GREEN),
                ("•", "Structure: HEPTAMER of APAF-1 molecules", "Helvetica", 8.8, DARK),
                ("",  "Formation steps:", "Helvetica-Bold", 9, GREEN),
                ("   1.", "Cytochrome c binds monomeric APAF-1", "Helvetica", 8.5, DARK),
                ("   2.", "Cytochrome c-APAF-1 binds dATP -> conformational change", "Helvetica", 8.5, DARK),
                ("   3.", "Seven APAF-1 molecules oligomerize into HEPTOMERIC wheel", "Helvetica", 8.5, DARK),
                ("   4.", "Exposes CARD domain (Caspase Recruitment Domain) at hub", "Helvetica", 8.5, DARK),
                ("   5.", "Procaspase-9 recruited to CARD -> autocatalytic cleavage -> active Casp-9", "Helvetica", 8.5, DARK),
                ("•", "Apoptosome = cytochrome c + APAF-1 (x7) + caspase-9", "Helvetica-Bold", 9, RED),
                ("•", "Can be measured: cytochrome c release = early apoptosis marker", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "Apoptosome = Cytochrome c + APAF-1 (heptamer) + Caspase-9 assembled in cytosol."
    },

    {
        "num": 10, "category": "Intrinsic Pathway",
        "question": "What are IAPs and SMAC/DIABLO? How do they regulate caspases?",
        "theme": T_INT,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "IAPs = Inhibitor of Apoptosis Proteins (e.g. XIAP, cIAP1, cIAP2, survivin)", "Helvetica-Bold", 9, GREEN),
                ("•", "IAPs bind and inhibit caspase-3, -7, and -9 -> block apoptosis", "Helvetica", 8.8, DARK),
                ("•", "Therefore: IAPs are ANTI-apoptotic", "Helvetica-Bold", 9, GREEN),
                ("",  "SMAC/DIABLO and HtrA2/Omi:", "Helvetica-Bold", 9, RED),
                ("•", "Released from mitochondria along with cytochrome c during MOMP", "Helvetica", 8.8, DARK),
                ("•", "SMAC (Second Mitochondria-derived Activator of Caspases) / DIABLO:", "Helvetica", 8.8, DARK),
                ("   -", "Binds IAPs -> neutralizes them -> caspases become active", "Helvetica", 8.5, DARK),
                ("•", "Net effect: SMAC removes the brake (IAPs) on caspases", "Helvetica-Bold", 9, RED),
                ("",  "Summary: BCL-2 inhibits MOMP. IAPs inhibit caspases. SMAC inhibits IAPs.", "Helvetica-Bold", 8.5, PURPLE),
            ]
        }],
        "exam_tip": "IAPs inhibit caspases (anti-apoptotic). SMAC/DIABLO inhibit IAPs (pro-apoptotic). Double negative = pro-apoptosis."
    },

    # ════ EXTRINSIC (DEATH RECEPTOR) PATHWAY ═════════════════════════════════
    {
        "num": 11, "category": "Extrinsic Pathway",
        "question": "What triggers the extrinsic (death receptor) apoptosis pathway?",
        "theme": T_EXT,
        "answer_sections": [{
            "title": "Triggers (signals from OUTSIDE the cell):",
            "lines": [
                ("•", "Death receptors on cell surface activated by death ligands", "Helvetica-Bold", 9, TEAL),
                ("•", "Death receptors = members of TNF receptor superfamily", "Helvetica", 8.8, DARK),
                ("",  "Main death receptor-ligand pairs:", "Helvetica-Bold", 9, TEAL),
                ("•", "FAS (CD95) + FASL (FAS ligand) - most studied", "Helvetica-Bold", 8.8, DARK),
                ("•", "TNFR1 + TNF-alpha", "Helvetica", 8.8, DARK),
                ("•", "DR4/DR5 + TRAIL (TNF-related apoptosis-inducing ligand)", "Helvetica", 8.8, DARK),
                ("",  "Physiologic roles:", "Helvetica-Bold", 9, TEAL),
                ("•", "Elimination of self-reactive lymphocytes (peripheral tolerance)", "Helvetica", 8.8, DARK),
                ("•", "CTL (cytotoxic T cell) killing of infected/tumour cells via FASL", "Helvetica", 8.8, DARK),
                ("•", "Termination of immune responses", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "Extrinsic = immune regulation. FAS mutation -> autoimmune lymphoproliferative syndrome (ALPS)."
    },

    {
        "num": 12, "category": "Extrinsic Pathway",
        "question": "Describe the step-by-step extrinsic (FAS) apoptosis pathway",
        "theme": T_EXT,
        "answer_sections": [{
            "title": "FAS (CD95) / FasL pathway step-by-step:",
            "lines": [
                ("1.", "FasL (on CTL or adjacent cell) binds FAS receptor", "Helvetica", 8.8, DARK),
                ("2.", "FAS trimerization (3 FAS molecules cluster)", "Helvetica", 8.8, DARK),
                ("3.", "Death domains on FAS cytoplasmic tails aggregate", "Helvetica", 8.8, DARK),
                ("4.", "FADD (Fas-Associated Death Domain) adaptor protein recruited", "Helvetica-Bold", 9, TEAL),
                ("5.", "FADD recruits multiple PROCASPASE-8 molecules", "Helvetica", 8.8, DARK),
                ("6.", "DISC formed = Death-Inducing Signalling Complex (FAS + FADD + procasp-8)", "Helvetica-Bold", 9, TEAL),
                ("7.", "Procaspase-8 undergoes autocatalytic activation -> active CASPASE-8", "Helvetica", 8.8, DARK),
                ("8.", "Caspase-8 directly activates CASPASE-3 -> execution -> apoptosis", "Helvetica-Bold", 9, RED),
                ("",  "OR in Type II cells (see Card 14):", "Helvetica-Bold", 8.5, ORANGE),
                ("   -", "Casp-8 cleaves BID -> tBID -> mitochondria -> amplification loop", "Helvetica", 8.5, DARK),
            ]
        }],
        "exam_tip": "DISC = FAS + FADD + procaspase-8. Caspase-8 is the initiator of the extrinsic pathway."
    },

    {
        "num": 13, "category": "Extrinsic Pathway",
        "question": "What is FADD and what is the DISC complex?",
        "theme": T_EXT,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "FADD = Fas-Associated Death Domain protein", "Helvetica-Bold", 9, TEAL),
                ("•", "Adaptor protein that bridges FAS receptor to procaspase-8", "Helvetica", 8.8, DARK),
                ("",  "DISC = Death-Inducing Signalling Complex:", "Helvetica-Bold", 9, TEAL),
                ("•", "Components: FAS (trimerized) + FADD + multiple procaspase-8 molecules", "Helvetica", 8.8, DARK),
                ("•", "Formation brings procaspase-8 molecules into proximity", "Helvetica", 8.8, DARK),
                ("•", "Proximity -> autocleavage -> active caspase-8 (initiator)", "Helvetica", 8.8, DARK),
                ("",  "Death domain interactions:", "Helvetica-Bold", 9, TEAL),
                ("•", "FAS has cytoplasmic Death Domain (DD)", "Helvetica", 8.8, DARK),
                ("•", "FADD has DD (binds FAS) + DED (Death Effector Domain, binds procasp-8)", "Helvetica", 8.8, DARK),
                ("•", "Procaspase-8 also has DED -> interaction with FADD", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "FADD bridges FAS to caspase-8. FAS has DD; FADD has both DD and DED."
    },

    {
        "num": 14, "category": "Extrinsic Pathway",
        "question": "What is the difference between Type I and Type II cells in extrinsic apoptosis?",
        "theme": T_EXT,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("",  "TYPE I cells (e.g. thymocytes, lymphocytes):", "Helvetica-Bold", 9, TEAL),
                ("•", "Sufficient caspase-8 generated by DISC to directly activate caspase-3", "Helvetica", 8.8, DARK),
                ("•", "NO mitochondrial amplification needed", "Helvetica", 8.8, DARK),
                ("•", "BCL-2 overexpression does NOT protect Type I cells from death receptor apoptosis", "Helvetica-Bold", 9, RED),
                ("",  "TYPE II cells (e.g. hepatocytes, pancreatic beta cells):", "Helvetica-Bold", 9, TEAL),
                ("•", "Insufficient caspase-8 from DISC alone", "Helvetica", 8.8, DARK),
                ("•", "Caspase-8 cleaves BID -> truncated BID (tBID)", "Helvetica", 8.8, DARK),
                ("•", "tBID translocates to mitochondria -> activates BAX/BAK -> cytochrome c release", "Helvetica", 8.8, DARK),
                ("•", "Uses mitochondrial amplification loop (BID links the two pathways)", "Helvetica-Bold", 9, TEAL),
                ("•", "BCL-2 overexpression CAN block death receptor apoptosis in Type II cells", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "BID = bridge between extrinsic and intrinsic. Type II cells need mitochondrial amplification."
    },

    # ════ PATHWAY INTERSECTION ════════════════════════════════════════════════
    {
        "num": 15, "category": "Pathway Crosstalk",
        "question": "How do the intrinsic and extrinsic pathways intersect?",
        "theme": T_COMP,
        "answer_sections": [{
            "title": "Key crosslink: BID (BH3-only protein)",
            "lines": [
                ("•", "Extrinsic: FasL-Fas -> FADD -> Caspase-8 (activated)", "Helvetica-Bold", 9, TEAL),
                ("•", "Caspase-8 cleaves BID -> truncated BID (tBID)", "Helvetica", 8.8, DARK),
                ("•", "tBID migrates to mitochondria", "Helvetica", 8.8, DARK),
                ("•", "tBID activates BAX/BAK -> MOMP -> cytochrome c -> Apoptosome -> Casp-9", "Helvetica-Bold", 9, GREEN),
                ("",  "Terminal convergence:", "Helvetica-Bold", 9, ORANGE),
                ("•", "Both pathways activate CASPASE-3 (executioner)", "Helvetica", 8.8, DARK),
                ("•", "Caspase-3 -> activates CAD (Caspase-Activated DNase)", "Helvetica", 8.8, DARK),
                ("•", "CAD cleaves DNA at internucleosomal sites -> 180bp 'DNA ladder'", "Helvetica-Bold", 9, RED),
                ("•", "Caspase-3 -> cleaves cytoskeletal proteins, ICAD, PARP", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "DNA ladder (180bp fragments) on gel electrophoresis = hallmark of apoptosis (CAD activity)."
    },

    {
        "num": 16, "category": "Pathway Crosstalk",
        "question": "What is the terminal/execution phase of apoptosis?",
        "theme": T_CASP,
        "answer_sections": [{
            "title": "Execution phase (common to both pathways):",
            "lines": [
                ("•", "Caspase-8 and Caspase-9 both activate downstream effector caspases", "Helvetica-Bold", 9, BLUE),
                ("•", "CASPASE-3 = main executioner (also -6 and -7)", "Helvetica-Bold", 9, RED),
                ("",  "Caspase-3 targets:", "Helvetica-Bold", 9, BLUE),
                ("•", "ICAD (Inhibitor of Caspase-Activated DNase) -> CAD released -> DNA ladder", "Helvetica", 8.8, DARK),
                ("•", "Lamin A/B -> nuclear envelope breakdown", "Helvetica", 8.8, DARK),
                ("•", "Actin, fodrin -> cytoskeletal collapse -> membrane blebbing", "Helvetica", 8.8, DARK),
                ("•", "PARP (Poly-ADP ribose polymerase) cleavage -> forensic marker", "Helvetica", 8.8, DARK),
                ("",  "Clearance:", "Helvetica-Bold", 9, BLUE),
                ("•", "Phosphatidylserine flipped to outer leaflet -> 'eat-me' signal", "Helvetica", 8.8, DARK),
                ("•", "Apoptotic bodies phagocytosed by macrophages -> NO inflammation", "Helvetica-Bold", 9, GREEN),
            ]
        }],
        "exam_tip": "PARP cleavage + DNA ladder = biochemical hallmarks of apoptosis. PS flip = eat-me signal."
    },

    # ════ CLINICAL CORRELATIONS ═══════════════════════════════════════════════
    {
        "num": 17, "category": "Clinical",
        "question": "How does BCL-2 overexpression cause follicular lymphoma?",
        "theme": T_CL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "Follicular lymphoma = most common indolent B-cell lymphoma", "Helvetica-Bold", 9, EXAM),
                ("•", "Translocation: t(14;18)(q32;q21)", "Helvetica-Bold", 9, RED),
                ("•", "BCL-2 gene (chr 18) juxtaposed to IgH locus (chr 14)", "Helvetica", 8.8, DARK),
                ("•", "IgH promoter -> constitutive BCL-2 OVEREXPRESSION in B cells", "Helvetica", 8.8, DARK),
                ("•", "BCL-2 overexpressed -> cells survive inappropriate signals -> ACCUMULATE", "Helvetica-Bold", 9, EXAM),
                ("•", "NOT hyperproliferation - just failure to die (prolonged survival)", "Helvetica", 8.8, DARK),
                ("•", "BCL-2 overexpression also causes CHEMOTHERAPY RESISTANCE", "Helvetica-Bold", 9, RED),
                ("",  "Treatment implication:", "Helvetica-Bold", 9, EXAM),
                ("•", "Venetoclax = BCL-2 inhibitor (BH3 mimetic) - used in CLL, AML", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "Follicular lymphoma = t(14;18) = BCL-2 overexpression. Cells don't die, they accumulate."
    },

    {
        "num": 18, "category": "Clinical",
        "question": "What happens when p53 is mutated and how does it relate to apoptosis?",
        "theme": T_CL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "p53 = 'Guardian of the Genome' - tumour suppressor on chr 17p13", "Helvetica-Bold", 9, EXAM),
                ("•", "Activated by: DNA damage, telomere shortening, oncogene activation", "Helvetica", 8.8, DARK),
                ("",  "Normal p53 function:", "Helvetica-Bold", 9, GREEN),
                ("•", "Transcribes PUMA and NOXA (BH3-only proteins) -> intrinsic apoptosis", "Helvetica", 8.8, DARK),
                ("•", "Activates p21 -> G1 cell cycle arrest -> DNA repair", "Helvetica", 8.8, DARK),
                ("•", "If repair fails -> triggers apoptosis via BAX upregulation", "Helvetica", 8.8, DARK),
                ("",  "Mutant p53:", "Helvetica-Bold", 9, RED),
                ("•", "Most common mutation in ALL human cancers (~50%)", "Helvetica-Bold", 9, RED),
                ("•", "Li-Fraumeni syndrome = germline p53 mutation (multiple cancers)", "Helvetica", 8.8, DARK),
                ("•", "Cells ignore DNA damage -> accumulate mutations -> cancer", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "p53 -> PUMA/NOXA (BH3-only) -> intrinsic apoptosis. p53 mut = most common cancer mutation."
    },

    {
        "num": 19, "category": "Clinical",
        "question": "What is ALPS and how does FAS mutation cause it?",
        "theme": T_CL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("•", "ALPS = Autoimmune Lymphoproliferative Syndrome", "Helvetica-Bold", 9, EXAM),
                ("•", "Caused by mutations in: FAS (CD95), FASL, or Caspase-8/-10", "Helvetica", 8.8, DARK),
                ("",  "Normal FAS function in immune regulation:", "Helvetica-Bold", 9, TEAL),
                ("•", "FAS on lymphocytes + FASL on activated T cells", "Helvetica", 8.8, DARK),
                ("•", "Eliminates self-reactive lymphocytes (peripheral tolerance = clonal deletion)", "Helvetica", 8.8, DARK),
                ("•", "Terminates immune responses when antigen cleared", "Helvetica", 8.8, DARK),
                ("",  "FAS mutation effect:", "Helvetica-Bold", 9, RED),
                ("•", "Self-reactive lymphocytes cannot be deleted", "Helvetica", 8.8, DARK),
                ("•", "Lymphoproliferation + autoimmune disease", "Helvetica-Bold", 9, RED),
                ("•", "Features: splenomegaly, lymphadenopathy, haemolytic anaemia, thrombocytopenia", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "FAS mutation -> ALPS: lymphoproliferation + autoimmunity. Normal FAS = clonal deletion of self-reactive T cells."
    },

    {
        "num": 20, "category": "Clinical",
        "question": "How do cytotoxic T lymphocytes (CTLs) use both apoptosis pathways?",
        "theme": T_CL,
        "answer_sections": [{
            "title": None,
            "lines": [
                ("",  "CTLs kill target cells (infected/tumour) by TWO mechanisms:", "Helvetica-Bold", 9, EXAM),
                ("",  "1. PERFORIN-GRANZYME pathway (intrinsic):", "Helvetica-Bold", 9, GREEN),
                ("•", "Perforin creates pores in target cell membrane", "Helvetica", 8.8, DARK),
                ("•", "Granzyme B (serine protease) enters through pores", "Helvetica", 8.8, DARK),
                ("•", "Granzyme B directly cleaves and activates CASPASE-3 and CASPASE-9", "Helvetica-Bold", 9, GREEN),
                ("",  "2. FAS-FASL pathway (extrinsic):", "Helvetica-Bold", 9, TEAL),
                ("•", "CTL expresses FASL on surface", "Helvetica", 8.8, DARK),
                ("•", "FASL binds FAS on target cell -> DISC -> Caspase-8 -> Caspase-3", "Helvetica", 8.8, DARK),
                ("•", "Both pathways end in target cell apoptosis (no inflammation)", "Helvetica-Bold", 9, RED),
            ]
        }],
        "exam_tip": "CTL killing = Perforin/Granzyme B (intrinsic) + FasL-Fas (extrinsic). Both trigger caspase-3."
    },

    # ════ QUICK REFERENCE / COMPARISON ═══════════════════════════════════════
    {
        "num": 21, "category": "Quick Reference",
        "question": "BCL-2 family members - complete classification for exam",
        "theme": T_BCL,
        "answer_sections": [{
            "title": "ANTI-APOPTOTIC (pro-survival, BH1-2-3-4):",
            "lines": [
                ("•", "BCL-2 - prototype, follicular lymphoma, outer mito membrane", "Helvetica-Bold", 9, GREEN),
                ("•", "BCL-XL - most important in non-lymphoid cells", "Helvetica", 8.8, DARK),
                ("•", "BCL-w, MCL-1 (myeloid), BFL-1/A1", "Helvetica", 8.8, DARK),
            ]
        },{
            "title": "PRO-APOPTOTIC EFFECTORS (BH1-2-3):",
            "lines": [
                ("•", "BAX - cytoplasmic, translocates to mito on signal", "Helvetica-Bold", 9, RED),
                ("•", "BAK - constitutively on outer mito membrane", "Helvetica-Bold", 9, RED),
            ]
        },{
            "title": "PRO-APOPTOTIC BH3-ONLY SENSORS:",
            "lines": [
                ("•", "BIM, PUMA, NOXA - DNA damage/growth factor withdrawal", "Helvetica", 8.8, DARK),
                ("•", "BID - cleaved by caspase-8 (pathway crosslink)", "Helvetica-Bold", 9, RED),
                ("•", "BAD - inactivated by Akt phosphorylation (survival signal)", "Helvetica", 8.8, DARK),
                ("•", "HRK, BIK - less commonly tested", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "Mnemonic for BH3-only: BIG PANDA BAD = BIM, PUMA, NOXA, BID, BAD."
    },

    {
        "num": 22, "category": "Quick Reference",
        "question": "Caspase cascade summary - initiators, executioners and substrates",
        "theme": T_CASP,
        "answer_sections": [{
            "title": "INITIATOR CASPASES (activate the cascade):",
            "lines": [
                ("•", "Caspase-8: extrinsic pathway (DISC) - cleaves BID, activates Casp-3", "Helvetica-Bold", 9, BLUE),
                ("•", "Caspase-9: intrinsic pathway (Apoptosome) - activates Casp-3/-6/-7", "Helvetica-Bold", 9, BLUE),
                ("•", "Caspase-10: can substitute for Casp-8 in some death receptor signalling", "Helvetica", 8.8, DARK),
            ]
        },{
            "title": "EXECUTIONER CASPASES:",
            "lines": [
                ("•", "Caspase-3: MAIN executioner - activated by both pathways", "Helvetica-Bold", 9, RED),
                ("•", "Caspase-6: cleaves lamin A -> nuclear collapse", "Helvetica", 8.8, DARK),
                ("•", "Caspase-7: ER-associated apoptosis", "Helvetica", 8.8, DARK),
            ]
        },{
            "title": "KEY SUBSTRATES of Caspase-3:",
            "lines": [
                ("•", "ICAD -> releases CAD -> DNA ladder (180bp)", "Helvetica", 8.8, DARK),
                ("•", "PARP cleavage -> biochemical hallmark of apoptosis", "Helvetica", 8.8, DARK),
                ("•", "Lamins, Actin -> nuclear/cytoskeletal collapse", "Helvetica", 8.8, DARK),
                ("•", "Inhibits BCL-2 -> commits cell to death", "Helvetica", 8.8, DARK),
            ]
        }],
        "exam_tip": "PARP cleavage + DNA ladder + phosphatidylserine flip = 3 hallmarks of apoptosis biochemistry."
    },
]


# ─── Main builder ─────────────────────────────────────────────────────────────
import os
os.makedirs("/home/daytona/workspace/apoptosis-flashcards", exist_ok=True)

cv = canvas.Canvas(OUTPUT, pagesize=A4)
cv.setTitle("Apoptosis Pathways Flashcards - BCL-2 & Caspases")

# Cover
draw_cover(cv)

# Cards: 2 per page
SLOT_TOP = MARGIN + CARD_H + CARD_GAP
SLOT_BOT = MARGIN

for i in range(0, len(CARDS), 2):
    draw_card(cv, SLOT_TOP, CARDS[i])
    if i + 1 < len(CARDS):
        draw_card(cv, SLOT_BOT, CARDS[i+1])
    cv.showPage()

cv.save()
print(f"PDF saved: {OUTPUT}")
print(f"Total cards: {len(CARDS)}")
Running Command

cd /home/daytona/workspace/apoptosis-flashcards && python make_apoptosis_cards.p…

Running Command

ls -lh /home/daytona/workspace/apoptosis-flashcards/Apoptosis_Pathway_Flashcards…

Your apoptosis flashcard PDF is ready! Download here:

Apoptosis Pathway Flashcards

PDF Document · PDF


22 flashcards across 6 colour-coded categories

ColourCategoryCardsTopics
🟢 Dark GreenIntrinsic Pathway4Triggers, step-by-step, apoptosome, IAPs/SMAC
🟦 TealExtrinsic Pathway4Triggers, FAS step-by-step, FADD/DISC, Type I vs II cells
🟣 PurpleBCL-2 Family4Classification, BCL-2 mechanism, BH3-only proteins, BAX/BAK
🔵 BlueCaspases3Caspase overview, execution phase, substrates
🩷 PinkClinical4Follicular lymphoma t(14;18), p53 mutation, ALPS, CTL killing
🟠 OrangeComparison/Crosslink3Pathway crosstalk, BID bridge, BCL-2 family full table
Every card has:
  • Colour-coded header by pathway category
  • Numbered badge for easy reference
  • Step-by-step mechanisms with numbered sequences
  • A pink exam tip strip at the bottom with the single most testable fact from that card

Make a comparison chart PDF of all cell death pathways (apoptosis vs necrosis vs others)

Finding Sources
Finding Sources
Reading File
Running Command

mkdir -p /home/daytona/workspace/cell-death-chart && python3 - <<'PYEOF' # Quick…

Writing File

~/cell-death-chart/make_chart.py

"""
Cell Death Pathways – Comparison Chart PDF
Landscape A3-style layout on A4 Landscape pages
"""

from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib.units import mm
from reportlab.lib.colors import HexColor, white, black
from reportlab.pdfgen import canvas as pdfcanvas
from reportlab.platypus import (
    SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT

# ── Page setup (A4 landscape) ─────────────────────────────────────────────────
PW, PH  = landscape(A4)   # 842 x 595 pt
LM = RM = 10 * mm
TM = BM = 10 * mm
OUTPUT  = "/home/daytona/workspace/cell-death-chart/Cell_Death_Pathways_Chart.pdf"

# ── Colour palette ────────────────────────────────────────────────────────────
C = {
    "necr":   HexColor("#B71C1C"),   # necrosis      – red
    "apo":    HexColor("#1B5E20"),   # apoptosis     – green
    "ncpt":   HexColor("#4A148C"),   # necroptosis   – purple
    "pyro":   HexColor("#E65100"),   # pyroptosis    – orange
    "ferro":  HexColor("#0D47A1"),   # ferroptosis   – blue
    "auto":   HexColor("#00695C"),   # autophagy     – teal
    "header": HexColor("#0D1B2A"),   # header bg     – dark navy
    "row_a":  HexColor("#FAFAFA"),
    "row_b":  HexColor("#F0F4FF"),
    "lnecr":  HexColor("#FFEBEE"),
    "lapo":   HexColor("#E8F5E9"),
    "lncpt":  HexColor("#EDE7F6"),
    "lpyro":  HexColor("#FFF3E0"),
    "lferro": HexColor("#E3F2FD"),
    "lauto":  HexColor("#E0F2F1"),
    "exam":   HexColor("#880E4F"),
    "lexam":  HexColor("#FCE4EC"),
    "white":  white,
    "dark":   HexColor("#1A1A2E"),
    "grey":   HexColor("#546E7A"),
}

# ── Style helpers ─────────────────────────────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

HDR_S  = S("hdr",  fontName="Helvetica-Bold",    fontSize=9,  textColor=white,        alignment=TA_CENTER, leading=11)
FEAT_S = S("feat", fontName="Helvetica-Bold",    fontSize=8,  textColor=C["dark"],    alignment=TA_LEFT,   leading=10)
CELL_S = S("cell", fontName="Helvetica",         fontSize=7.8,textColor=C["dark"],    alignment=TA_LEFT,   leading=10)
GOOD_S = S("good", fontName="Helvetica",         fontSize=7.8,textColor=C["apo"],     alignment=TA_LEFT,   leading=10)
BAD_S  = S("bad",  fontName="Helvetica-Bold",    fontSize=7.8,textColor=C["necr"],    alignment=TA_LEFT,   leading=10)
EXAM_S = S("exam", fontName="Helvetica-Bold",    fontSize=7.5,textColor=C["exam"],    alignment=TA_LEFT,   leading=10)
TITLE_S= S("ttl",  fontName="Helvetica-Bold",    fontSize=18, textColor=white,        alignment=TA_CENTER, leading=22)
SUB_S  = S("sub",  fontName="Helvetica",         fontSize=11, textColor=HexColor("#90CAF9"), alignment=TA_CENTER)
SEC_S  = S("sec",  fontName="Helvetica-Bold",    fontSize=12, textColor=white,        alignment=TA_LEFT,   leading=14)

def P(txt, style=CELL_S):
    return Paragraph(txt, style)

def b(t): return f"<b>{t}</b>"
def col_txt(t, c): return f'<font color="{c.hexval()}">{t}</font>'

# ── Column widths ─────────────────────────────────────────────────────────────
AVAIL   = PW - LM - RM   # ~822 pt
F_COL   = 70             # Feature column
P_COLS  = 6              # number of pathway columns
P_COL_W = (AVAIL - F_COL) / P_COLS  # ~125 pt each

COLS = [F_COL] + [P_COL_W] * P_COLS

# ── Data for the main comparison table ───────────────────────────────────────
# Header row
PATH_HEADERS = [
    ("NECROSIS",     C["necr"]),
    ("APOPTOSIS",    C["apo"]),
    ("NECROPTOSIS",  C["ncpt"]),
    ("PYROPTOSIS",   C["pyro"]),
    ("FERROPTOSIS",  C["ferro"]),
    ("AUTOPHAGY",    C["auto"]),
]

# Each row: [Feature, Necrosis, Apoptosis, Necroptosis, Pyroptosis, Ferroptosis, Autophagy]
# Tuples: (text, style_key)  style_key: "n"=normal, "g"=good(green), "b"=bad(red), "e"=exam(pink)

ROWS = [
    ("Type of death",
     ("Pathologic only", "b"),
     ("Physiologic OR pathologic", "n"),
     ("Pathologic (regulated)", "n"),
     ("Pathologic (immune)", "n"),
     ("Pathologic", "n"),
     ("Protective OR cell death", "g")),

    ("Programmed?",
     ("NO — uncontrolled", "b"),
     ("YES — caspase-mediated", "g"),
     ("YES — RIPK1/RIPK3", "g"),
     ("YES — inflammasome", "g"),
     ("YES — lipid peroxidation", "g"),
     ("YES — ATG genes", "g")),

    ("Cell size",
     ("SWELLS (oncosis)", "b"),
     ("SHRINKS", "g"),
     ("Swells (necrosis-like)", "b"),
     ("Swells then lyses", "b"),
     ("Variable", "n"),
     ("Shrinks (organelles digested)", "n")),

    ("Plasma membrane",
     ("DISRUPTED — leaks", "b"),
     ("INTACT (PS flipped out)", "g"),
     ("DISRUPTED by MLKL pores", "b"),
     ("DISRUPTED by GSDMD pores", "b"),
     ("Lipid peroxidation damage", "b"),
     ("Intact initially", "g")),

    ("Nuclear changes",
     ("Pyknosis → Karyorrhexis → Karyolysis", "n"),
     ("Chromatin condensation + fragmentation", "n"),
     ("Similar to necrosis", "n"),
     ("Nuclear condensation", "n"),
     ("Nuclear condensation", "n"),
     ("Nucleus intact (organelles digested)", "n")),

    ("Inflammation",
     ("YES — always", "b"),
     ("NO — contents packaged", "g"),
     ("YES — contents released", "b"),
     ("YES — IL-1β, IL-18 released", "b"),
     ("Variable — DAMPs released", "b"),
     ("NO (protective phase)", "g")),

    ("Key mediator / molecule",
     ("Lysosomal enzymes, ROS, Ca²⁺", "n"),
     ("Caspase-3 (executioner)", "e"),
     ("RIPK1 + RIPK3 → MLKL", "e"),
     ("Inflammasome → Caspase-1 → GSDMD", "e"),
     ("GPX4 loss → lipid ROS", "e"),
     ("ATG5, ATG7, Beclin-1, LC3", "e")),

    ("Initiator / Trigger",
     ("Ischaemia, toxins, trauma, infection", "n"),
     ("DNA damage, growth factor loss, ER stress", "n"),
     ("TNF, viral dsRNA/DNA", "n"),
     ("Intracellular microbes (bacteria, viruses)", "n"),
     ("Iron overload, GPX4 inhibition, oxidative stress", "n"),
     ("Nutrient deprivation, organelle damage", "n")),

    ("Caspase involved?",
     ("NO", "n"),
     ("YES — Casp-8 or -9 → Casp-3", "g"),
     ("NO — caspase independent", "b"),
     ("YES — Casp-1 (inflammasome) or Casp-4/5", "n"),
     ("NO", "n"),
     ("Indirectly (can activate apoptosis)", "n")),

    ("Energy (ATP) required?",
     ("NOT required (passive)", "n"),
     ("YES — active process", "n"),
     ("NOT required", "n"),
     ("NOT required (passive lysis)", "n"),
     ("NOT required", "n"),
     ("YES — required for autophagosome formation", "n")),

    ("Cell fragments?",
     ("NO — ghost cells / debris", "b"),
     ("YES — apoptotic bodies", "g"),
     ("NO — cellular rupture", "b"),
     ("NO — cellular rupture", "b"),
     ("NO", "b"),
     ("YES — autophagosomes (organelle fragments)", "g")),

    ("Phagocytosis of debris",
     ("By neutrophils/macrophages (inflammatory)", "n"),
     ("By macrophages — SILENT (PS signal)", "g"),
     ("By macrophages — inflammatory", "n"),
     ("By macrophages — inflammatory", "n"),
     ("By macrophages", "n"),
     ("Self-digestion in lysosomes", "g")),

    ("BCL-2 role",
     ("Not relevant", "n"),
     ("BCL-2 = anti-apoptotic; BAX/BAK = pro", "e"),
     ("Not directly relevant", "n"),
     ("Not directly relevant", "n"),
     ("Not directly relevant", "n"),
     ("BCL-2 can inhibit autophagy via Beclin-1", "n")),

    ("DNA fragmentation",
     ("Non-specific (random breaks)", "n"),
     ("Internucleosomal 'DNA ladder' (180 bp)", "e"),
     ("Random (necrosis-like)", "n"),
     ("Fragmentation occurs", "n"),
     ("Random", "n"),
     ("Minimal (organelles degraded, not nucleus)", "n")),

    ("Histology finding",
     ("Ghost cells, eosinophilic, no nuclei; inflammatory infiltrate", "n"),
     ("Apoptotic bodies; shrunken cells; NO inflammation", "n"),
     ("Swollen cells, rupture, inflammatory infiltrate", "n"),
     ("Pore-forming; inflammatory cells; gasdermin pores", "n"),
     ("Iron deposits; lipid peroxidation products", "n"),
     ("Double-membrane vacuoles (autophagosomes) on EM", "n")),

    ("Clinical example / disease",
     ("MI infarct core, toxic liver injury, frostbite", "e"),
     ("Follicular lymphoma (BCL-2↑), p53 mutation cancers, embryogenesis", "e"),
     ("Viral infections, IBD, ischaemia-reperfusion", "e"),
     ("Sepsis, COVID-19, NLRP3 diseases, gout, atherosclerosis", "e"),
     ("Cancer, neurodeg. (ALS, Parkinson's), ischaemia-reperfusion", "e"),
     ("Starvation adaptation, cancer (dual role), Parkinson's", "e")),

    ("Reversibility",
     ("Irreversible — cell cannot recover", "b"),
     ("Irreversible once caspases activated", "b"),
     ("Irreversible", "b"),
     ("Irreversible", "b"),
     ("Irreversible", "b"),
     ("Reversible if nutrient restored; irreversible if prolonged", "g")),

    ("Therapeutic target?",
     ("No specific drugs (prevent ischaemia/toxin)", "n"),
     ("BCL-2 inhibitors (Venetoclax), IAP inhibitors", "e"),
     ("RIPK1 inhibitors (necrostatin-1), MLKL inhibitors", "e"),
     ("Caspase-1 / NLRP3 inhibitors (ongoing trials)", "e"),
     ("Ferroptosis inhibitors (Ferrostatin-1, Liproxstatin-1)", "e"),
     ("Rapamycin (induces autophagy); chloroquine (inhibits)", "e")),
]

# ── Style mapping ─────────────────────────────────────────────────────────────
def cell_para(txt, skey):
    style_map = {
        "n": CELL_S,
        "g": GOOD_S,
        "b": BAD_S,
        "e": EXAM_S,
    }
    return Paragraph(txt, style_map.get(skey, CELL_S))

def build_main_table():
    # Header
    header = [P("FEATURE", HDR_S)]
    for name, color in PATH_HEADERS:
        header.append(P(name, HDR_S))

    data = [header]
    row_bgs = [C["header"]]

    path_light = [C["lnecr"], C["lapo"], C["lncpt"], C["lpyro"], C["lferro"], C["lauto"]]

    for i, row in enumerate(ROWS):
        feature = row[0]
        cells = row[1:]
        feat_para = Paragraph(feature, FEAT_S)
        row_data = [feat_para] + [cell_para(txt, sk) for txt, sk in cells]
        data.append(row_data)
        row_bgs.append(C["row_a"] if i % 2 == 0 else C["row_b"])

    tbl = Table(data, colWidths=COLS, repeatRows=1)

    style_cmds = [
        # Header row
        ("BACKGROUND",    (0, 0), (-1, 0), C["header"]),
        ("TOPPADDING",    (0, 0), (-1, -1), 4),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
        ("LEFTPADDING",   (0, 0), (-1, -1), 5),
        ("RIGHTPADDING",  (0, 0), (-1, -1), 4),
        ("VALIGN",        (0, 0), (-1, -1), "TOP"),
        ("GRID",          (0, 0), (-1, -1), 0.4, HexColor("#CFD8DC")),
        ("LINEBELOW",     (0, 0), (-1, 0), 1.5, white),
        ("LINEAFTER",     (0, 0), (0, -1), 1.2, HexColor("#90A4AE")),
        # Feature column bg
        ("BACKGROUND",    (0, 1), (0, -1), HexColor("#ECEFF1")),
    ]

    # Colour-code each pathway column header
    for col_i, (_, color) in enumerate(PATH_HEADERS):
        style_cmds.append(("BACKGROUND", (col_i+1, 0), (col_i+1, 0), color))

    # Alternating row backgrounds for data columns
    for row_i in range(1, len(data)):
        bg = C["row_a"] if (row_i - 1) % 2 == 0 else C["row_b"]
        style_cmds.append(("BACKGROUND", (1, row_i), (-1, row_i), bg))

    tbl.setStyle(TableStyle(style_cmds))
    return tbl


# ── Quick-reference summary table ────────────────────────────────────────────
def build_summary_table():
    """A compact one-liner 'at a glance' table."""
    headers = ["PATHWAY", "TYPE", "INFLAM.", "CASPASE", "KEY MOLECULE", "CLASSIC TRIGGER", "HALLMARK FINDING"]
    rows = [
        ["Necrosis",    "Pathologic",    "YES",  "No",        "Lysosomal enzymes", "Ischaemia / toxin",      "Ghost cells + PMN infiltrate"],
        ["Apoptosis",   "Physiol/Path.", "NO",   "Casp-3",    "BCL-2 / BAX",       "DNA damage / GF loss",   "Apoptotic bodies; DNA ladder"],
        ["Necroptosis", "Pathologic",    "YES",  "No",        "RIPK1/RIPK3/MLKL",  "TNF; viral RNA/DNA",     "Necrosis-like + regulated"],
        ["Pyroptosis",  "Pathologic",    "YES",  "Casp-1/4",  "GSDMD (gasdermin)", "Intracell. microbes",    "IL-1β/IL-18 release; GSDMD pores"],
        ["Ferroptosis", "Pathologic",    "VAR.", "No",        "GPX4 (glutathione peroxidase)", "Iron overload; GPX4 loss", "Lipid peroxidation; Fe deposits"],
        ["Autophagy",   "Protective/Path","NO",  "Indirect",  "ATG5/Beclin-1/LC3", "Starvation; organelle stress", "Double-membrane autophagosomes (EM)"],
    ]
    avail = PW - LM - RM
    cws = [avail * f for f in [0.11, 0.09, 0.08, 0.09, 0.17, 0.17, 0.29]]
    data = [[P(h, HDR_S) for h in headers]]
    path_colors = [C["necr"], C["apo"], C["ncpt"], C["pyro"], C["ferro"], C["auto"]]
    for i, row in enumerate(rows):
        data.append([P(cell, CELL_S) for cell in row])

    tbl = Table(data, colWidths=cws, repeatRows=1)
    style = [
        ("BACKGROUND",    (0, 0), (-1, 0), C["header"]),
        ("TOPPADDING",    (0, 0), (-1, -1), 4),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
        ("LEFTPADDING",   (0, 0), (-1, -1), 5),
        ("VALIGN",        (0, 0), (-1, -1), "TOP"),
        ("GRID",          (0, 0), (-1, -1), 0.4, HexColor("#CFD8DC")),
        ("LINEBELOW",     (0, 0), (-1, 0), 1.2, white),
    ]
    for i, color in enumerate(path_colors):
        style.append(("BACKGROUND", (0, i+1), (0, i+1), color))
        style.append(("FONTNAME",   (0, i+1), (0, i+1), "Helvetica-Bold"))
        style.append(("TEXTCOLOR",  (0, i+1), (0, i+1), white))
        bg = C["row_a"] if i % 2 == 0 else C["row_b"]
        style.append(("BACKGROUND", (1, i+1), (-1, i+1), bg))
    tbl.setStyle(TableStyle(style))
    return tbl


# ── Exam tips table ───────────────────────────────────────────────────────────
def build_exam_table():
    tips = [
        ("Necrosis",    C["necr"],  "Most common type = COAGULATIVE (except brain = liquefactive). Ghost cells + PMN infiltrate. "
                                    "Serum markers: Troponin (heart), AST/ALT (liver). ALWAYS inflammatory."),
        ("Apoptosis",   C["apo"],   "NO inflammation. Apoptotic bodies phagocytosed silently. "
                                    "BCL-2 = anti-apoptotic (follicular lymphoma t(14;18)). "
                                    "p53 = guardian of genome; mutated in 50% cancers. "
                                    "DNA ladder (180 bp) = hallmark. Caspase-3 = main executioner."),
        ("Necroptosis", C["ncpt"],  "Looks like necrosis but PROGRAMMED. RIPK1/RIPK3 necrosome -> MLKL -> pores. "
                                    "Caspase-INDEPENDENT. Triggered by TNF. Role in viral infection, IBD, ischaemia-reperfusion."),
        ("Pyroptosis",  C["pyro"],  "Inflammatory cell death. Inflammasome (NLRP3, AIM2) -> Caspase-1 -> "
                                    "GSDMD pores + IL-1beta/IL-18 release. Pyro = FEVER. Role in sepsis, COVID-19, gout."),
        ("Ferroptosis", C["ferro"], "Iron-dependent lipid peroxidation. GPX4 (glutathione peroxidase 4) "
                                    "normally protects against this. GPX4 inhibition -> lipid ROS accumulate -> membrane damage. "
                                    "Ferrostatin-1 = specific inhibitor. Role in cancer, neurodegeneration."),
        ("Autophagy",   C["auto"],  "Self-eating — survival mechanism during starvation. "
                                    "ATG genes -> phagophore -> autophagosome -> lysosome -> degradation. "
                                    "Beclin-1 (autophagy initiator) inhibited by BCL-2. "
                                    "Rapamycin induces; Chloroquine inhibits. Dual role in cancer."),
    ]
    avail = PW - LM - RM
    cws = [avail * 0.13, avail * 0.87]
    data = []
    for name, color, tip in tips:
        data.append([
            P(f"<b>{name}</b>", ParagraphStyle("tn", fontName="Helvetica-Bold", fontSize=8.5, textColor=white, alignment=TA_CENTER, leading=11)),
            P(tip, EXAM_S)
        ])
    tbl = Table(data, colWidths=cws)
    style = [
        ("TOPPADDING",    (0, 0), (-1, -1), 5),
        ("BOTTOMPADDING", (0, 0), (-1, -1), 5),
        ("LEFTPADDING",   (0, 0), (-1, -1), 7),
        ("VALIGN",        (0, 0), (-1, -1), "TOP"),
        ("GRID",          (0, 0), (-1, -1), 0.5, HexColor("#CFD8DC")),
    ]
    for i, (_, color, _) in enumerate(tips):
        style.append(("BACKGROUND", (0, i), (0, i), color))
        bg = C["row_a"] if i % 2 == 0 else C["row_b"]
        style.append(("BACKGROUND", (1, i), (1, i), bg))
    tbl.setStyle(TableStyle(style))
    return tbl


# ── Cover (first page via canvas) ─────────────────────────────────────────────
def make_cover_page(c, pw, ph):
    c.setFillColor(C["header"])
    c.rect(0, 0, pw, ph, fill=1, stroke=0)

    # decorative
    for cx2, cy2, r, col in [
        (pw*0.93, ph*0.85, 90,  "#1B5E20"),
        (pw*0.05, ph*0.15, 65,  "#4A148C"),
        (pw*0.5,  ph*0.5,  160, "#0A2740"),
        (pw*0.7,  ph*0.2,  50,  "#B71C1C"),
    ]:
        c.setFillColor(HexColor(col))
        c.circle(cx2, cy2, r, fill=1, stroke=0)

    c.setFillColor(white)
    c.setFont("Helvetica-Bold", 36)
    c.drawCentredString(pw/2, ph*0.62, "CELL DEATH PATHWAYS")
    c.setFont("Helvetica-Bold", 20)
    c.setFillColor(HexColor("#90CAF9"))
    c.drawCentredString(pw/2, ph*0.52, "Complete Comparison Chart")
    c.setFont("Helvetica", 13)
    c.setFillColor(HexColor("#B0BEC5"))
    c.drawCentredString(pw/2, ph*0.45, "Necrosis  |  Apoptosis  |  Necroptosis  |  Pyroptosis  |  Ferroptosis  |  Autophagy")
    c.setFont("Helvetica-Oblique", 11)
    c.drawCentredString(pw/2, ph*0.39, "For MBBS  ·  FMGE / NEXT / USMLE  ·  Based on Robbins Pathology")

    # pathway pills
    pills = [
        ("NECROSIS",    "#B71C1C"), ("APOPTOSIS",   "#1B5E20"),
        ("NECROPTOSIS", "#4A148C"), ("PYROPTOSIS",  "#E65100"),
        ("FERROPTOSIS", "#0D47A1"), ("AUTOPHAGY",   "#00695C"),
    ]
    pw2, ph2 = 110, 24
    total = len(pills) * pw2 + (len(pills)-1)*10
    sx = (pw - total)/2
    for i, (lab, col) in enumerate(pills):
        bx = sx + i*(pw2+10)
        by = ph * 0.28
        c.setFillColor(HexColor(col))
        c.roundRect(bx, by, pw2, ph2, 6, fill=1, stroke=0)
        c.setFillColor(white)
        c.setFont("Helvetica-Bold", 9)
        c.drawCentredString(bx + pw2/2, by + 8, lab)

    c.setFillColor(HexColor("#607D8B"))
    c.setFont("Helvetica", 9)
    c.drawCentredString(pw/2, ph*0.20, "3 pages: Cover | Full Comparison Table (18 features) | Quick Summary + High-Yield Exam Tips")
    c.showPage()


# ── Section title helper ───────────────────────────────────────────────────────
def section_title(text, color=C["header"]):
    avail = PW - LM - RM
    tbl = Table([[Paragraph(text, SEC_S)]], colWidths=[avail])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), color),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("ROUNDEDCORNERS", [4]),
    ]))
    return tbl


# ── Build document ────────────────────────────────────────────────────────────
def build():
    # Cover via raw canvas
    cv = pdfcanvas.Canvas(OUTPUT, pagesize=landscape(A4))
    cv.setTitle("Cell Death Pathways – Comparison Chart")
    make_cover_page(cv, PW, PH)
    cv.save()

    # Main content via platypus (append to same file using multi-pass)
    # Use SimpleDocTemplate to append pages after cover
    from reportlab.lib.pagesizes import landscape as ls
    from pypdf import PdfWriter, PdfReader
    import io

    # Build main pages into a buffer
    buf = io.BytesIO()
    doc = SimpleDocTemplate(
        buf,
        pagesize=landscape(A4),
        leftMargin=LM, rightMargin=RM,
        topMargin=TM,  bottomMargin=BM,
        title="Cell Death Pathways",
    )

    story = []

    # ── Page 2: Full comparison table ──
    story.append(section_title("FULL COMPARISON TABLE  |  Cell Death Pathways  (18 Features x 6 Pathways)"))
    story.append(Spacer(1, 5))
    story.append(build_main_table())
    story.append(PageBreak())

    # ── Page 3: Quick summary + exam tips ──
    story.append(section_title("AT-A-GLANCE SUMMARY  |  6 Pathways in 7 Columns"))
    story.append(Spacer(1, 5))
    story.append(build_summary_table())
    story.append(Spacer(1, 10))
    story.append(section_title("HIGH-YIELD EXAM TIPS  |  Key Facts for FMGE / NEXT / USMLE", C["exam"]))
    story.append(Spacer(1, 5))
    story.append(build_exam_table())

    doc.build(story)

    # Merge cover + content
    buf.seek(0)
    cover_reader  = PdfReader(OUTPUT)
    content_reader = PdfReader(buf)

    writer = PdfWriter()
    for page in cover_reader.pages:
        writer.add_page(page)
    for page in content_reader.pages:
        writer.add_page(page)

    with open(OUTPUT, "wb") as f:
        writer.write(f)

    print(f"Done: {OUTPUT}")
    print(f"Pages: {len(cover_reader.pages) + len(content_reader.pages)}")

build()
Running Command

cd /home/daytona/workspace/cell-death-chart && python make_chart.py 2>&1

Running Command

ls -lh /home/daytona/workspace/cell-death-chart/Cell_Death_Pathways_Chart.pdf

Your comparison chart PDF is ready! Download here:

Cell Death Pathways Chart

PDF Document · PDF


What's inside — 4 pages, A4 Landscape

Page 1 — Cover with colour-coded pathway pills
Page 2 — Full Comparison Table (18 features × 6 pathways)
FeatureNecrosisApoptosisNecroptosisPyroptosisFerroptosisAutophagy
Type of deathPathologicPhysiol/PathPathologicPathologicPathologicProtective/Path
Programmed?NOYESYESYESYESYES
InflammationALWAYSNEVERYESYESVariableNO
Key moleculeLysosomal enzymesCaspase-3 / BCL-2RIPK1/RIPK3/MLKLCasp-1 / GSDMDGPX4 / lipid ROSATG5/Beclin-1
... and 14 more rows
Page 3 — At-a-Glance Summary (compact 7-column quick-reference table)
Page 4 — High-Yield Exam Tips - one dedicated tip block per pathway with the most testable facts for FMGE/NEXT/USMLE
Colour code: 🔴 Necrosis   🟢 Apoptosis   🟣 Necroptosis   🟠 Pyroptosis   🔵 Ferroptosis   🩵 Autophagy
This is a shared conversation. Sign in to Orris to start your own chat.