attachment
attachment

Please explain every topic in detail and deapth Prepare me for usmle questions Don't skip any topic I have test tmr Please explain everything in detail Add extra information that you fell like i should know as a medical student studying for usmle

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Here is your complete, high-yield USMLE study guide covering every topic on your list. This is organized to mirror how the USMLE asks questions - mechanism first, then clinical relevance.

USMLE MASTER REVIEW - Complete Study Guide


TOPIC 1: PLASMA MEMBRANE - Composition & Function

Composition (memorize the percentages)

The plasma membrane is 7.5-10 nm thick and composed of:
  • 55% proteins (the most abundant component by mass)
  • 25% phospholipids
  • 13% cholesterol
  • 4% other lipids
  • 3% carbohydrates (always on the extracellular face)
(Guyton and Hall Textbook of Medical Physiology)

Structure: The Fluid Mosaic Model

The membrane is a lipid bilayer - two layers of phospholipid molecules arranged tail-to-tail. Each phospholipid has:
  • A hydrophilic phosphate head - faces water (extracellular fluid or cytosol)
  • A hydrophobic fatty acid tail - faces inward, away from water
This arrangement is thermodynamically stable because the hydrophobic tails shield themselves from water.

The Three Lipids You Must Know

LipidKey Detail
PhospholipidsMost abundant; asymmetrically distributed (PS and PE on inner leaflet; PC and SM on outer leaflet)
SphingolipidsFrom sphingosine; especially abundant in nerve cell membranes; form lipid rafts; involved in signal transmission and cell adhesion
CholesterolInserts between phospholipids; regulates membrane fluidity - increases rigidity at high temperatures, prevents crystallization at low temperatures; also regulates permeability to water-soluble substances

Membrane Asymmetry (HIGH YIELD)

  • Outer leaflet: Phosphatidylcholine (PC), sphingomyelin, glycolipids
  • Inner leaflet: Phosphatidylserine (PS), phosphatidylethanolamine (PE), phosphatidylinositol (PI)
  • PS flipping to the outer leaflet is a signal for apoptosis - this is what macrophages recognize to phagocytose dying cells. PS exposure is also the trigger for the coagulation cascade (clotting factors bind PS)

Membrane Proteins

Integral (transmembrane) proteins:
  • Span the entire bilayer (7 transmembrane domains = serpentine receptors like GPCRs)
  • Form ion channels, transporters, receptors
  • Require detergents to extract
Peripheral proteins:
  • Attached only to one face (inner or outer)
  • Non-covalent interaction with lipid head groups or integral proteins
  • Example: spectrin in RBC membrane (cytoskeleton)

Membrane Fluidity - Key Modulators

  • Unsaturated fatty acids (double bonds = kinks) → increase fluidity
  • Saturated fatty acids (straight chains, pack tightly) → decrease fluidity
  • Cholesterol → acts as a buffer: prevents too fluid (high temp) and too rigid (low temp)
  • Short-chain fatty acids → increase fluidity
USMLE TIP: Bacteria exposed to cold increase membrane unsaturated fatty acids to maintain fluidity. Some bacteria use hopanoids in place of cholesterol.

Permeability Rules (what crosses freely vs. needs help)

  • Freely permeable (no transporter needed): O2, CO2, N2, alcohol, steroid hormones, small non-polar molecules, water (some, via osmosis)
  • Need transporters: glucose, amino acids, ions (Na+, K+, Ca2+, Cl-), large polar molecules
  • Cannot cross: proteins, nucleic acids, large charged molecules

Glycocalyx

  • Carbohydrates (3%) on the extracellular face only, attached to proteins (glycoproteins) and lipids (glycolipids)
  • Functions: cell-cell recognition, immune protection, ABO blood group antigens, cell adhesion
  • USMLE: ABO antigens are glycolipids on RBC surface

TOPIC 2: TRANSPORTERS - Active vs. Passive (All Types)

Passive Transport (NO energy required, moves DOWN concentration gradient)

1. Simple Diffusion

  • No protein needed
  • Rate is proportional to the concentration gradient (Fick's Law)
  • For lipid-soluble, small, non-polar molecules: O2, CO2, steroid hormones, ethanol
  • Obeys Fick's Law: Flux = P × A × (C1 - C2), where P = permeability, A = surface area

2. Facilitated Diffusion

  • Requires a transporter protein (channel or carrier)
  • Still moves DOWN the gradient - NO energy required
  • Cannot concentrate the solute inside the cell above outside levels
  • Shows saturation kinetics (Km, Vmax) - unlike simple diffusion
  • Examples: GLUTs (glucose transport into cells), aquaporins (water channels)
Channel proteins: Form a pore that opens and closes (gating)
  • Voltage-gated channels: Open/close based on membrane potential (Na+ channels in action potentials)
  • Ligand-gated channels: Open when a ligand binds (nAChR, GABA-A receptor)
  • Mechanically gated channels: Open with physical deformation (hair cells of inner ear)
Carrier proteins (transporters): Bind solute, change conformation, release on other side
  • More selective than channels
  • Slower than channels
  • Example: GLUT1, GLUT2, GLUT4

Active Transport (REQUIRES energy, moves AGAINST concentration gradient)

Primary Active Transport

  • Uses ATP directly
  • Na+/K+-ATPase (Na+/K+ pump): The most tested pump on USMLE
    • Pumps 3 Na+ OUT and 2 K+ IN per ATP hydrolyzed
    • Electrogenic (net positive charge out - contributes to resting membrane potential)
    • Inhibited by ouabain and cardiac glycosides (digoxin, digitalis)
    • Maintains the Na+ gradient that drives secondary active transport
  • Ca2+-ATPase (SERCA): Pumps Ca2+ back into SR in muscle
  • H+/K+-ATPase: On parietal cells of stomach - pumps H+ out (inhibited by PPIs like omeprazole)
  • ABC transporters: Use ATP; P-glycoprotein (MDR1) pumps drugs out of cells - causes multidrug resistance in cancer

Secondary Active Transport (uses the Na+ gradient as the energy source)

  • Does NOT directly use ATP, but depends on the Na+ gradient created by Na+/K+-ATPase
  • Two types:
TypeDirectionExample
Symport (co-transport)Na+ and solute move in SAME directionSGLT1/2 (Na+/glucose in intestine and kidney), Na+/amino acid in gut
Antiport (exchange)Na+ moves IN, solute moves OUTNa+/H+ exchanger (NHE1) - regulates pH; Na+/Ca2+ exchanger in heart
USMLE PEARL - SGLT2 inhibitors (gliflozins: empagliflozin, dapagliflozin): Block Na+/glucose symport in proximal tubule of kidney → glucose spills into urine → lower blood glucose. Used in Type 2 diabetes. Also reduce cardiovascular mortality.

Summary Table: Key Transporters

TransporterLocationTypeSubstrateClinical Relevance
Na+/K+-ATPaseAll cellsPrimary activeNa+ out, K+ inDigoxin inhibits this
SERCASR of musclePrimary activeCa2+ into SRDefective in heart failure
H+/K+-ATPaseGastric parietal cellsPrimary activeH+ outPPIs block this
SGLT1Small intestineSecondary active (symport)Na+, glucose, galactoseGlucose-galactose malabsorption
SGLT2Proximal tubuleSecondary active (symport)Na+, glucoseSGLT2 inhibitors for T2DM
GLUT1RBC, brain, placentaFacilitated diffusionGlucoseConstitutive (always expressed)
GLUT2Liver, beta cells, intestineFacilitated diffusionGlucose, fructoseGlucose sensor (high Km)
GLUT4Muscle, fatFacilitated diffusionGlucoseInsulin-dependent (the USMLE target)
Aquaporin-2Collecting ductFacilitated diffusionWaterRegulated by ADH/vasopressin

TOPIC 3: GLUTs (Glucose Transporters) - Every Single One

GLUTs are facilitated diffusion transporters - they never concentrate glucose against a gradient, move it down the gradient, and need no ATP.

GLUT1

  • Location: RBCs, brain (blood-brain barrier), placenta, basal glucose uptake in most cells
  • Km: Low (~1 mM) → high affinity, always saturated at physiological glucose levels
  • Regulation: Constitutively expressed; NOT regulated by insulin
  • Clinical: GLUT1 deficiency syndrome → seizures, low CSF glucose, developmental delay; treat with ketogenic diet

GLUT2

  • Location: Liver, pancreatic beta cells, small intestine (enterocytes), kidney proximal tubule
  • Km: High (~15-20 mM) → low affinity, ONLY transports glucose when blood glucose is HIGH
  • Function: Acts as a glucose sensor for the pancreatic beta cell - glucose freely enters the beta cell only when blood glucose is high → triggers insulin secretion
  • Regulation: NOT regulated by insulin
  • Bidirectional: Can transport glucose OUT of liver (during glucose export) or INTO enterocytes
  • Also transports fructose and galactose (lower affinity)

GLUT3

  • Location: Neurons (also some other high-demand tissues)
  • Km: Very low (~1.4 mM) → highest affinity of the GLUTs
  • Function: Ensures neurons always get glucose even when blood glucose is low
  • Regulation: NOT insulin-regulated

GLUT4

  • THE MOST IMPORTANT FOR USMLE
  • Location: Skeletal muscle, adipose tissue, cardiac muscle
  • Regulation: Stored in intracellular vesicles; insulin triggers translocation to the plasma membrane
  • Mechanism: Insulin → IR tyrosine kinase → IRS-1 → PI3K → Akt (PKB) → GLUT4 vesicle fusion with membrane → glucose uptake
  • Exercise also triggers GLUT4 translocation (via AMPK pathway, independent of insulin - important for Type 2 DM patients)
  • In Type 2 DM: GLUT4 translocation is impaired (insulin resistance)

GLUT5

  • Location: Small intestine (mainly), spermatocytes
  • Substrate: Fructose ONLY
  • No glucose transport
  • Free fructose from fruits/HFCS is absorbed here

Summary Trick: "GLUT numbering by location"

  • GLUT1 = everywhere (brain, RBC) - baseline
  • GLUT2 = liver/beta cells - glucose sensor
  • GLUT3 = neurons - highest affinity
  • GLUT4 = muscle/fat - insulin-dependent
  • GLUT5 = fructose only

TOPIC 4: CARBOHYDRATE METABOLISM

Glycolysis (10 steps - key ones for USMLE)

Glycolysis occurs in the cytosol. Net equation: Glucose → 2 Pyruvate + 2 ATP + 2 NADH
Rate-limiting enzymes (the "3 irreversible steps"):
  1. Hexokinase/Glucokinase (Step 1) - glucose → glucose-6-phosphate; ATP used; traps glucose in cell
    • Hexokinase: low Km, in most cells, product-inhibited by G6P
    • Glucokinase: high Km, in liver and beta cells, NOT inhibited by G6P, induced by insulin
  2. Phosphofructokinase-1 (PFK-1) (Step 3) - fructose-6-P → fructose-1,6-bisphosphate; THE main regulatory step
    • Activated by: AMP, ADP, fructose-2,6-bisphosphate (F-2,6-BP, the most potent activator)
    • Inhibited by: ATP, citrate (signals energy abundance)
    • F-2,6-BP is made by PFK-2 (activated by insulin via dephosphorylation; inhibited by glucagon via phosphorylation)
  3. Pyruvate kinase (Step 10) - PEP → pyruvate; ATP generated
    • Activated by fructose-1,6-bisphosphate (feedforward)
    • Inhibited by ATP, alanine
    • Deficiency → hemolytic anemia (RBCs can't regenerate ATP)
Key ATP accounting:
  • Steps 1 and 3: use 1 ATP each (2 total)
  • Steps 7 and 10: generate 1 ATP each per molecule (x2 since 2 trioses = 4 ATP total)
  • Net: 2 ATP per glucose (from substrate-level phosphorylation)
  • Also generates 2 NADH at step 6 (glyceraldehyde-3-phosphate dehydrogenase)
In RBCs: Glucose → Lactate (anaerobic only; RBCs have no mitochondria) The 2,3-BPG shunt (Luebering-Rapoport shunt) in RBCs: 1,3-BPG → 2,3-BPG (catalyzed by bisphosphoglycerate mutase); 2,3-BPG stabilizes deoxyhemoglobin → decreases O2 affinity → right shift of O2-Hb curve

Pyruvate Fate (critical junction point)

  • Aerobic conditions: Pyruvate → Acetyl-CoA (via PDH complex) → enters TCA cycle
  • Anaerobic conditions (muscle): Pyruvate → Lactate (LDH); regenerates NAD+ for continued glycolysis
  • In liver: Pyruvate → Oxaloacetate (gluconeogenesis via pyruvate carboxylase)
  • In yeast: Pyruvate → Ethanol + CO2
Pyruvate Dehydrogenase (PDH) Complex:
  • Location: Mitochondrial matrix
  • Requires: Thiamine (B1), FAD (B2), NAD+ (B3/niacin), CoA (B5/pantothenate), lipoic acid
  • Product: Acetyl-CoA + NADH + CO2
  • Inhibited by: Acetyl-CoA, NADH (high energy state), ATP
  • Activated by: NAD+, AMP, ADP, Ca2+ (in muscle during exercise)
  • PDH deficiency: Cannot make Acetyl-CoA from pyruvate → pyruvate accumulates → converted to lactate and alanine → lactic acidosis + neurological symptoms (seen in thiamine deficiency = Wernicke's encephalopathy, or genetic PDH deficiency)

TCA Cycle (Krebs Cycle / Citric Acid Cycle)

Location: Mitochondrial matrix (except succinate dehydrogenase, which is in the inner membrane)
Full equation per Acetyl-CoA: Acetyl-CoA + 3 NAD+ + FAD + GDP + Pi + 2 H2O → 2 CO2 + 3 NADH + FADH2 + GTP + CoA
Per glucose (2 acetyl-CoA):
  • 6 NADH
  • 2 FADH2
  • 2 GTP
Key enzymes and their regulators:
EnzymeReactionRegulation
Citrate synthaseOAA + Acetyl-CoA → CitrateInhibited by citrate, NADH, ATP
Isocitrate dehydrogenaseIsocitrate → α-ketoglutarate + CO2Rate-limiting; inhibited by ATP, NADH; activated by ADP, Ca2+
α-ketoglutarate dehydrogenaseα-KG → Succinyl-CoA + CO2Requires same cofactors as PDH (B1, B2, B3, B5, lipoic acid)
Succinate dehydrogenaseSuccinate → FumarateComplex II of ETC; inhibited by malonate (competitive)
Anaplerotic reactions (replenishing TCA intermediates):
  • OAA replenished by: pyruvate carboxylase (pyruvate + CO2 → OAA; requires biotin, ATP)
  • α-KG from glutamine/glutamate catabolism
  • Succinyl-CoA from odd-chain fatty acid oxidation and amino acid catabolism
TCA cycle intermediates as biosynthetic precursors:
  • Citrate → exported to cytosol → Acetyl-CoA for fatty acid synthesis
  • α-KG → glutamate (amino acid synthesis)
  • Succinyl-CoA → heme synthesis
  • OAA → aspartate, gluconeogenesis

Pentose Phosphate Pathway (PPP / Hexose Monophosphate Shunt)

Location: Cytosol Substrate: Glucose-6-phosphate
Two phases:
Oxidative phase (irreversible, makes NADPH and ribose-5-P):
  • G6P → 6-phosphogluconolactone → ribulose-5-phosphate + 2 NADPH + CO2
  • Key enzyme: Glucose-6-phosphate dehydrogenase (G6PD) - rate-limiting, inhibited by NADPH
  • Products: NADPH, ribose-5-phosphate (for nucleotide synthesis), CO2
Non-oxidative phase (reversible, interconverts sugars):
  • Uses transketolase (requires thiamine/B1) and transaldolase
  • Funnels excess pentoses back into glycolysis
Why NADPH matters - HIGH YIELD:
  • Glutathione recycling: GSSG + NADPH → GSH (via glutathione reductase). GSH is the major antioxidant in RBCs, neutralizing H2O2 (via glutathione peroxidase)
  • Fatty acid synthesis (NADPH is required for each 2-carbon addition)
  • Cholesterol synthesis (HMG-CoA reductase pathway)
  • Cytochrome P450 reactions (drug metabolism)
  • NADPH oxidase in neutrophils - makes superoxide to kill bacteria (NADPH → O2 → O2•-)
  • Nitric oxide synthesis (NOS uses NADPH)
G6PD Deficiency (X-linked recessive):
  • Cannot regenerate NADPH → cannot recycle glutathione → oxidative stress damages RBC membranes → Heinz bodies (denatured Hb) and bite cellshemolytic anemia
  • Triggered by: primaquine, dapsone, sulfonamides, fava beans, infection (oxidative stress)
  • Fluorescent spot test to diagnose
  • Most common enzymopathy worldwide; protective against malaria (Plasmodium needs normal G6PD)

Malate-Aspartate Shuttle (HIGH YIELD for USMLE)

The Problem: Glycolysis makes NADH in the CYTOSOL. But the inner mitochondrial membrane is impermeable to NADH. How does this NADH get its electrons into the mitochondria for the ETC?
Answer: Two shuttle systems exist:

Malate-Aspartate Shuttle (heart, liver, kidney - "MALI"):

(Medical Physiology)
This is the more efficient shuttle (produces 2.5 ATP per NADH):
Step-by-step:
  1. Cytosolic NADH reduces OAA → Malate (via cytosolic malate dehydrogenase)
  2. Malate enters mitochondrial matrix via the malate-α-ketoglutarate exchanger
  3. In the matrix, Malate → OAA + NADH (matrix NADH enters ETC at Complex I → 2.5 ATP)
  4. OAA cannot cross back out directly - so it is transaminated → Aspartate (+ αKG)
  5. Aspartate exits via the aspartate-glutamate exchanger; αKG exits via malate exchanger
  6. In cytosol, Aspartate is transaminated back to OAA, completing the cycle
Net: 1 cytosolic NADH → 1 mitochondrial NADH → 2.5 ATP

Glycerol-3-Phosphate Shuttle (brain, skeletal muscle):

  • Simpler: cytosolic NADH reduces DHAP → glycerol-3-phosphate
  • Glycerol-3-phosphate crosses membrane → oxidized by mitochondrial G3P dehydrogenase (FAD-linked) → FADH2
  • FADH2 enters ETC at Complex II → only 1.5 ATP (less efficient!)
  • Net: 1 cytosolic NADH → 1 FADH2 → 1.5 ATP
USMLE TIP: Total ATP from aerobic glycolysis of 1 glucose:
  • 2 substrate-level ATP (glycolysis)
  • 2 cytosolic NADH: via malate-aspartate = 5 ATP; via G3P shuttle = 3 ATP
  • 2 pyruvate → 2 acetyl-CoA: 2 NADH × 2.5 = 5 ATP
  • TCA cycle (×2): 6 NADH × 2.5 = 15 ATP; 2 FADH2 × 1.5 = 3 ATP; 2 GTP = 2 ATP
  • Total with malate-aspartate: ~30-32 ATP per glucose

TOPIC 5: TYPES OF RECEPTORS (General Overview)

Receptors transduce extracellular signals into intracellular responses. The four major families:

Class 1: Ion Channel Receptors (Ionotropic Receptors / Ligand-Gated Ion Channels)

  • Fastest response (milliseconds)
  • Ligand binding directly opens the channel
  • Examples:
    • Nicotinic acetylcholine receptor (nAChR) - Na+/K+ channel; at NMJ and autonomic ganglia
    • GABA-A - Cl- channel; barbiturates and benzodiazepines enhance this
    • NMDA receptor - Ca2+/Na+ channel; requires glutamate + glycine co-agonist + membrane depolarization to remove Mg2+ block; important for LTP and learning
    • AMPA receptor - Na+/K+ channel; fast excitatory

Class 2: G Protein-Coupled Receptors (GPCRs / Metabotropic Receptors)

  • 7 transmembrane domains
  • Slower than ion channels (seconds to minutes)
  • Extremely diverse (>800 in human genome)
  • Signal via second messengers
  • See detailed GPCR section below

Class 3: Receptor Tyrosine Kinases (RTKs)

  • Single transmembrane domain
  • Ligand binding → dimerization → autophosphorylation of tyrosine residues
  • Signal via RAS-MAP kinase, PI3K-Akt
  • Examples: insulin receptor, EGF receptor, PDGF receptor, VEGF receptor
  • Mutations cause cancer (RAS mutations in 30% of all cancers)

Class 4: Intracellular/Nuclear Receptors

  • Ligand must be lipid-soluble to cross membrane
  • Act as transcription factors
  • Slowest response (hours)
  • Examples: steroid hormone receptors (glucocorticoid, mineralocorticoid, androgen, estrogen, progesterone), thyroid hormone receptor, Vitamin D receptor, retinoic acid receptor
  • Mechanism: Ligand binds → receptor-HSP90 complex dissociates → receptor enters nucleus → binds hormone response elements (HREs) → changes gene transcription

TOPIC 6: ROS NEUTRALIZATION (CRITICAL FOR USMLE)

What Are Reactive Oxygen Species?

ROS are partially reduced forms of O2 that are highly reactive and damage proteins, lipids, and DNA:
  • Superoxide (O2•-) - made by mitochondrial ETC leakage and NADPH oxidase
  • Hydrogen peroxide (H2O2) - made from O2•- by superoxide dismutase
  • Hydroxyl radical (•OH) - most dangerous; made from H2O2 + Fe2+ (Fenton reaction)
  • Peroxynitrite (ONOO-) - made from O2•- + NO•

Sources of ROS

  • Normal mitochondrial respiration (electron leakage at Complex I and III)
  • Neutrophil oxidative burst (intentional ROS to kill bacteria)
  • P450 enzymes
  • Ionizing radiation
  • Reperfusion after ischemia (especially dangerous - burst of ROS floods the tissue)

Antioxidant Defense Systems (MEMORIZE THESE)

Enzymatic:

  1. Superoxide dismutase (SOD):
    • O2•- + O2•- → H2O2 + O2
    • Cytosolic SOD uses Cu2+/Zn2+ as cofactors (Cu/Zn-SOD)
    • Mitochondrial SOD uses Mn2+ (Mn-SOD)
    • Mutations in Cu/Zn-SOD cause familial ALS (Lou Gehrig's disease)
  2. Catalase:
    • 2 H2O2 → 2 H2O + O2
    • Located in peroxisomes (hence the name)
    • Found abundantly in liver and RBCs
    • Heme-containing enzyme
  3. Glutathione Peroxidase:
    • H2O2 + 2 GSH → 2 H2O + GSSG
    • Also handles lipid peroxides
    • Requires selenium as cofactor (selenocysteine in active site)
    • In RBCs, this is the primary H2O2-scavenging system
  4. Glutathione Reductase:
    • GSSG + NADPH + H+ → 2 GSH
    • Regenerates active (reduced) glutathione
    • Requires NADPH (from PPP via G6PD)
The RBC antioxidant chain: G6PD → NADPH → Glutathione reductase → GSH → Glutathione peroxidase → neutralizes H2O2
Why G6PD deficiency causes hemolysis: Cannot make NADPH → cannot recycle GSH → H2O2 accumulates → oxidizes Hb → Heinz bodies → splenic destruction

Non-enzymatic:

  • Vitamin E (α-tocopherol): Lipid-soluble; protects cell membranes from lipid peroxidation; chain-breaking antioxidant
  • Vitamin C (ascorbate): Water-soluble; donates electrons to free radicals; regenerates Vitamin E
  • Glutathione (GSH): Tripeptide (Glu-Cys-Gly); most important intracellular antioxidant
  • β-carotene: Quenches singlet oxygen

USMLE High-Yield ROS Points:

  • Reperfusion injury: During ischemia, xanthine dehydrogenase is converted to xanthine oxidase. Upon reperfusion, xanthine oxidase generates massive O2•- → tissue damage (heart attack, stroke)
  • Chronic granulomatous disease (CGD): Deficiency of NADPH oxidase → neutrophils cannot make O2•- → recurrent infections with catalase-positive organisms (S. aureus, Aspergillus, etc.)
  • Paraquat toxicity: Generates O2•- in lungs → pulmonary fibrosis
  • Acetaminophen overdose: NAPQI (toxic metabolite) depletes glutathione → hepatocyte necrosis; treat with N-acetylcysteine (replenishes GSH)

TOPIC 7: MYELIN & NEUROGLIA CELLS

The Glial Cell Family

(Ganong's Review of Medical Physiology)
Glia = Greek for "glue". They outnumber neurons 10:1 and are essential for CNS function.

Classification:

  • Microglia (small)
  • Macroglia (large): oligodendrocytes, Schwann cells, astrocytes, ependymal cells

MICROGLIA

  • CNS resident macrophages - part of the innate immune system
  • Derived from yolk sac myeloid precursors (NOT from neural crest, NOT from neuroectoderm - this is a common trap)
  • Functions:
    • Phagocytosis of debris, pathogens, dead neurons
    • Antigen presentation (express MHC II)
    • Release cytokines (IL-1, TNF-α) in neuroinflammation
  • Activated in: MS, Alzheimer's, Parkinson's, HIV dementia, prion disease
  • Form microglial nodules around virus-infected neurons

ASTROCYTES

  • Most abundant glial cell in CNS
  • Star-shaped with numerous processes
  • Functions (HIGH YIELD):
    1. Blood-brain barrier (BBB) maintenance - astrocytic "end feet" surround CNS capillaries, induce tight junctions
    2. Potassium buffering - take up excess K+ after neuronal firing → spatial K+ buffering
    3. Neurotransmitter recycling - take up glutamate from synaptic cleft (glutamate transporters EAAT1/2) → convert to glutamine → released to neurons → converted back to glutamate (glutamate-glutamine cycle)
    4. Glycogen storage - only CNS cells that store glycogen; provide lactate to neurons during starvation
    5. GFAP production - glial fibrillary acidic protein is the intermediate filament of astrocytes
    6. Reactive gliosis - respond to injury by proliferating and forming a glial scar
  • Clinical:
    • Glioblastoma multiforme (GBM) - malignant astrocytoma; butterfly pattern crossing corpus callosum
    • Hepatic encephalopathy - ammonia causes Alzheimer type II astrocytes (enlarged, pale nuclei) - NOT Alzheimer disease!
    • Alexander disease (genetic GFAP mutation) → leukodystrophy; pathologic feature: Rosenthal fibers

OLIGODENDROCYTES

  • CNS myelin-forming cells
  • One oligodendrocyte myelinates up to 50 different axons (contrast Schwann cells)
  • Located in white matter
  • Responsible for axon saltatory conduction
  • Destroyed in multiple sclerosis (MS)
  • Myelination: wraps around axons by extending cell processes → forms compacted myelin sheaths
MS Pathology: Immune attack on oligodendrocytes/myelin by CD4+ T cells → plaques in white matter (periventricular, optic nerve, corpus callosum) → demyelination → slowed conduction → symptoms

SCHWANN CELLS

  • PNS myelin-forming cells
  • One Schwann cell myelinates ONE segment of ONE axon (1:1 ratio per internode)
  • Also myelinate dorsal root ganglia axons
  • In unmyelinated fibers, still envelop axons in Remak bundles (one Schwann cell around many unmyelinated fibers)
  • Derived from neural crest cells
  • Express S-100 protein, Sox-10
Schwannoma: Benign tumor of Schwann cells; bilateral acoustic schwannomas in NF2 (neurofibromatosis type 2) Guillain-Barré Syndrome (GBS): Immune attack on PNS myelin (Schwann cells) → ascending paralysis → loss of deep tendon reflexes (demyelination slows conduction); often post-Campylobacter jejuni infection

EPENDYMAL CELLS

  • Line the ventricles and central canal of spinal cord
  • Produce and circulate CSF (choroid plexus ependymal cells)
  • Have cilia that help circulate CSF
  • Ependymoma - tumor of these cells; commonly in 4th ventricle in children

MYELIN - Structure and Function

Structure:
  • Multiple layers of plasma membrane wrapped around the axon
  • Composition: 70% lipid, 30% protein
  • Key proteins:
    • MBP (Myelin Basic Protein) - in PNS and CNS; target in MS
    • PLP (Proteolipid Protein) - CNS myelin (most abundant CNS myelin protein)
    • P0 protein - PNS myelin (most abundant PNS myelin protein)
    • MAG (Myelin-Associated Glycoprotein) - at paranodal regions
  • Nodes of Ranvier - gaps between myelin sheaths where action potentials jump (saltatory conduction)
  • Speed advantage: Myelinated fibers conduct at 70-120 m/s vs. unmyelinated at 0.5-2 m/s
Saltatory Conduction:
  • Action potentials "jump" from node to node
  • Na+ channels concentrated at nodes; fast and energy-efficient
  • K+ channels at juxtaparanodal regions

TOPIC 8: AXONAL TRANSPORT

(Ganong's, Neuroscience: Exploring the Brain, Principles of Neural Science)

Why It's Needed

Neurons are highly polarized cells; ribosomes are in the soma but axons can be meters long. Most axonal proteins are made in the cell body and must be transported to the terminals. Cutting the axon from the cell body causes Wallerian degeneration of the distal segment.

Anterograde Transport (soma → axon terminal)

Direction: Cell body → axon terminal (away from soma) Motor: Kinesin (plus-end-directed motor; moves along microtubules toward the + end = axon terminal) Cargo: Synaptic vesicle precursors, mitochondria, membrane proteins, mRNA-protein particles, smooth ER elements Two speeds:
TypeRateCargo
Fast axonal transport200-400 mm/day (some sources ~1000 mm/day)Membrane-enclosed vesicles, mitochondria, synaptic vesicle precursors, lipids
Slow axonal transport0.5-10 mm/dayCytoskeletal proteins (tubulin, actin, neurofilaments), soluble metabolic enzymes

Retrograde Transport (axon terminal → soma)

Direction: Axon terminal → cell body (toward soma) Motor: Dynein (minus-end-directed motor; moves toward the - end = cell body) Rate: ~200 mm/day Cargo: Used synaptic vesicle membranes for recycling, endosomes, lysosomes, growth factors (NGF), signals about synaptic activity
HIGH-YIELD USMLE: Retrograde transport is hijacked by viruses and toxins:
  • Rabies virus, HSV, polio virus, tetanus toxin - all travel retrograde to the cell body
  • Tetanus toxin specifically: taken up at NMJ, travels retrograde to spinal cord → transported trans-synaptically to inhibitory interneurons → blocks glycine/GABA release → spastic paralysis
  • Botulinum toxin: Acts at the NMJ presynaptic terminal (does NOT travel retrograde); cleaves SNARE proteins → prevents ACh release → flaccid paralysis

Molecular Motors Summary

MotorDirectionFuelFunction
KinesinAnterograde (+ end)ATPTakes cargo from soma to terminal
DyneinRetrograde (- end)ATPReturns cargo to soma; also positions organelles
Myosin IIAlong actin filamentsATPMuscle contraction; also some dendritic transport
USMLE PEARL: Mutations in dynein and dynein activators cause motor neuron diseases and are linked to Charcot-Marie-Tooth disease (peripheral neuropathy). Mutations in KIF1B (kinesin isoform) also cause CMT.

TOPIC 9: SYNAPSES & NEUROTRANSMITTERS

Synaptic Transmission - Step by Step

  1. Action potential arrives at presynaptic terminal
  2. Voltage-gated Ca2+ channels open (N-type, P/Q-type in CNS; mainly N-type at NMJ) → Ca2+ floods in
  3. Ca2+ triggers vesicle fusion via synaptotagmin (Ca2+ sensor protein)
  4. SNARE proteins mediate membrane fusion: v-SNARE (synaptobrevin/VAMP) on vesicle + t-SNARE (syntaxin + SNAP-25) on terminal membrane → zipper together → vesicle fuses → exocytosis
  5. Neurotransmitter diffuses across 20-40 nm synaptic cleft
  6. Binds postsynaptic receptors (ionotropic = fast; metabotropic/GPCRs = slow)
  7. Termination of signal:
    • Reuptake into presynaptic terminal (most common: dopamine, serotonin, norepinephrine, GABA)
    • Enzymatic degradation in cleft (ACh → choline + acetate by AChE; NE by MAO and COMT)
    • Diffusion away from cleft
(Histology: A Text and Atlas)

Key Neurotransmitters

NTPrecursorKey EnzymeLocationReceptorInactivation
AChCholine + Acetyl-CoACholine acetyltransferaseNMJ, ANS ganglia, basal forebrainnAChR (ionotropic), mAChR (GPCR)AChE (cleaves in cleft)
DopamineTyrosine → DOPA → DATyrosine hydroxylase (rate-limiting); DOPA decarboxylaseSubstantia nigra, VTAD1-D5 (all GPCRs)DAT (reuptake), MAO, COMT
NorepinephrineDA → NEDopamine-β-hydroxylaseLocus coeruleus, sympathetic gangliaα1, α2, β1, β2 (all GPCRs)NET (reuptake), MAO, COMT
Serotonin (5-HT)Tryptophan → 5-HTP → 5-HTTryptophan hydroxylase (rate-limiting)Raphe nuclei5-HT3 (ionotropic); all others are GPCRsSERT (reuptake), MAO
Glutamateα-KG (TCA)Glutaminase (in neurons)Most excitatory synapses in CNSNMDA, AMPA, kainate (ionotropic); mGluR (GPCR)EAAT transporters on astrocytes and neurons
GABAGlutamateGAD (glutamic acid decarboxylase); requires B6Most inhibitory synapses in CNSGABA-A (Cl- channel); GABA-B (GPCR)GAT reuptake transporters
GlycineSerineSerine hydroxymethyltransferaseSpinal cord inhibitory interneuronsGlyR (Cl- channel)GlyT reuptake

Excitatory vs. Inhibitory Synapses

Excitatory:
  • Main NT: Glutamate, Aspartate, ACh
  • Opens Na+ (or Ca2+) channels → depolarization → EPSP (excitatory postsynaptic potential)
  • If threshold is reached → action potential
Inhibitory:
  • Main NT: GABA, Glycine
  • Opens Cl- channels → Cl- enters → hyperpolarization → IPSP (inhibitory postsynaptic potential)
  • Makes it harder to fire

NMDA Receptor - Ultra High Yield

  • Coincidence detector - requires TWO things simultaneously:
    1. Glutamate binding
    2. Membrane depolarization (to remove Mg2+ block)
  • Also requires glycine as obligatory co-agonist
  • When both conditions met → Ca2+ influx → activates CaM kinase II → Long-Term Potentiation (LTP) - the cellular basis of learning and memory
  • Blocked by Mg2+ at rest (voltage-dependent block)
  • Drugs:
    • Ketamine: NMDA antagonist → dissociative anesthesia/analgesia
    • Memantine: NMDA antagonist → used in Alzheimer's disease (prevents excitotoxicity)
    • Phencyclidine (PCP): NMDA antagonist → psychosis symptoms (model for schizophrenia)
    • Ethanol: Inhibits NMDA receptors (and enhances GABA-A) → CNS depression

SNARE Complex (for USMLE)

  • Synaptobrevin (VAMP) on vesicle
  • Syntaxin on target membrane
  • SNAP-25 on target membrane
  • Form a tight complex → membrane fusion → exocytosis
  • Botulinum toxin: Cleaves synaptobrevin (serotypes A-G cleave different SNARE proteins) → no ACh release at NMJ → flaccid paralysis (used medically as Botox)
  • Tetanus toxin: Cleaves synaptobrevin in inhibitory interneurons → disinhibition → spastic paralysis ("lockjaw")
  • Alpha-latrotoxin (black widow spider): Causes massive ACh release → excessive excitation then depletion

Clinical Pharmacology of Neurotransmission

Dopamine pathways:
  • Mesolimbic: Reward, pleasure; hyperactive in schizophrenia
  • Mesocortical: Cognition, emotion; hypoactive in schizophrenia (negative symptoms)
  • Nigrostriatal: Motor control; deficient in Parkinson's disease
  • Tuberoinfundibular: Inhibits prolactin; antipsychotics block D2 here → hyperprolactinemia
Clinical relevance of NTs:
  • Parkinson's: Dopamine ↓ in substantia nigra → treat with L-DOPA + carbidopa
  • Schizophrenia: Dopamine ↑ (mesolimbic); treat with D2 antagonists (antipsychotics)
  • Depression: Serotonin ↓, NE ↓; treat with SSRIs, SNRIs, TCAs, MAOIs
  • Alzheimer's: ACh ↓ in basal forebrain; treat with AChE inhibitors (donepezil, rivastigmine)
  • Myasthenia Gravis: Autoantibodies to nAChR at NMJ → treat with AChE inhibitors
  • Anxiety/Epilepsy: GABA-A enhancement by benzodiazepines, barbiturates

TOPIC 10: GPCR - Full Deep Dive

GPCR Structure

  • 7 transmembrane (7-TM) alpha helical domains (hence "heptahelical receptors")
  • N-terminus: extracellular, glycosylated, part of ligand-binding site
  • C-terminus: intracellular, site of phosphorylation by GRK
  • Third intracellular loop (ICL3): couples to G-protein
  • Associated G-protein trimer (Gα + Gβγ) sits on intracellular face

GPCR Activation Cycle

  1. Ligand binds → conformational change in receptor
  2. Receptor acts as GEF (guanine nucleotide exchange factor) for Gα → GDP released → GTP binds Gα
  3. Gα-GTP separates from Gβγ; BOTH Gα-GTP and free Gβγ are active signaling molecules
  4. Gα activates/inhibits its effector (adenylyl cyclase, PLC, etc.)
  5. Gα has intrinsic GTPase activity → GTP → GDP → Gα reassociates with Gβγ → inactive state
  6. RGS proteins (Regulators of G-protein Signaling) accelerate GTPase activity → faster termination

G-Protein Types (MUST MEMORIZE)

G-proteinEffectorSecond MessengerEffectKey Receptors
GsAdenylyl cyclase (↑)cAMP ↑ → PKA ↑Generally stimulatoryβ1, β2 adrenergic; D1, D5 dopamine; H2 histamine; V2 vasopressin; glucagon; PTH; TSH
GiAdenylyl cyclase (↓)cAMP ↓ → PKA ↓Generally inhibitoryα2 adrenergic; M2/M4 muscarinic; D2, D3, D4 dopamine; μ/δ/κ opioid; GABA-B; adenosine A1
GqPhospholipase C-β (PLC-β, ↑)IP3 ↑ + DAG ↑IP3 → Ca2+ release from ER; DAG → PKC activationα1 adrenergic; M1, M3, M5 muscarinic; H1 histamine; angiotensin AT1; vasopressin V1; TRH; oxytocin
G12/13Rho GEFsRhoA activationCytoskeletal reorganizationMany receptors; LPA, thrombin

cAMP Pathway (Gs)

  • Gs → adenylyl cyclase → ATP → cAMP
  • cAMP activates PKA (protein kinase A)
  • PKA targets: glycogen phosphorylase kinase (activates), glycogen synthase (inhibits), CREB (nucleus: gene expression), hormone-sensitive lipase (in adipocytes: activates lipolysis)
  • cAMP degraded by phosphodiesterase (PDE)
  • PDE inhibitors (sildenafil, theophylline, caffeine) elevate cAMP/cGMP
USMLE: Cholera toxin permanently activates Gs (ADP-ribosylates Gαs so it can't hydrolyze GTP) → adenylyl cyclase always on → massive cAMP in intestinal cells → PKA → CFTR Cl- channel opens → Cl- and water pour into gut → secretory diarrhea Pertussis toxin permanently inactivates Gi (ADP-ribosylates Gαi so it can't exchange GDP for GTP) → cAMP remains high in respiratory epithelium

IP3/DAG Pathway (Gq)

  • Gq → PLC-β → PIP2 cleaved into IP3 + DAG
  • IP3 (hydrophilic) → moves to ER → opens IP3-gated Ca2+ channels → Ca2+ released
    • Ca2+ binds calmodulin → Ca2+-calmodulin activates CaM kinases, myosin light-chain kinase (smooth muscle contraction)
  • DAG (lipophilic, stays in membrane) → activates PKC (protein kinase C)
    • PKC phosphorylates many targets; can activate transcription factors (AP-1)
    • Phorbol esters (TPA) mimic DAG → constitutive PKC activation → tumor promotion
  • Ca2+ + DAG together → full PKC activation

GRK (G Protein-Coupled Receptor Kinases)

Function: Desensitize GPCRs after prolonged agonist exposure - prevents continuous signaling
Mechanism of Desensitization:
  1. Agonist-occupied receptor is phosphorylated on Ser/Thr residues in the C-tail or ICL3 by GRK (there are 7 GRKs: GRK1-7)
  2. Phosphorylated receptor has increased affinity for β-arrestin
  3. β-arrestin binds → sterically blocks G-protein coupling → uncouples receptor from G-protein = desensitization
  4. β-arrestin also recruits clathrin and AP-2 → receptor is internalized via clathrin-coated pits → receptor downregulation/internalization
  5. Internalized receptor can be: recycled back to membrane (resensitization) or sorted to lysosomes (degradation/downregulation)
Key GRK isoforms:
  • GRK1 (rhodopsin kinase): Phosphorylates light-activated rhodopsin; Oguchi disease (stationary night blindness) caused by GRK1 mutation
  • GRK2/3 (β-ARK1/2): Target β-adrenergic receptors; upregulated in heart failure (β-ARK1 is a therapeutic target)
  • GRK4/5/6: Widespread; GRK5 implicated in cardiac hypertrophy signaling
β-Arrestin as a Signaling Scaffold (not just a blocker): After internalization, β-arrestin can scaffold its own signaling complexes:
  • Activates ERK1/2 MAP kinase pathway
  • Activates Src kinase
  • This G-protein-independent signaling is called β-arrestin-biased signaling (important in drug development - "biased agonism")

MAP Kinase (MAPK) Pathway - RAS-ERK Pathway

This is activated by RTKs (like EGF receptor, insulin receptor) AND GPCRs (via Gβγ or β-arrestin).
Full Cascade:
  1. Ligand binds RTK → dimerization → autophosphorylation on Tyr
  2. Grb2 (adaptor protein) binds phosphotyrosine via its SH2 domain
  3. Grb2 recruits SOS (a RAS-GEF) via its SH3 domain
  4. SOS activates RAS (exchanges GDP → GTP on RAS)
  5. RAS-GTP activates RAF (= MAP3K)
  6. RAF phosphorylates and activates MEK (= MAP2K; also called MKK1/2)
  7. MEK phosphorylates and activates ERK1/2 (= MAPK; extracellular signal-regulated kinase)
  8. ERK1/2 enters the nucleus → phosphorylates transcription factors (Elk-1, c-Fos, c-Jun, c-Myc) → gene expression → cell proliferation, differentiation, survival
  9. ERK1/2 also phosphorylates cytosolic targets (ribosomal S6 kinase = RSK)
Termination:
  • RAS has intrinsic GTPase → RAS-GTP → RAS-GDP (self-limiting)
  • NF1 (neurofibromin) is a GAP (GTPase-activating protein) for RAS → accelerates GTP hydrolysis → turns off RAS
  • Phosphatases deactivate ERK
USMLE-Critical Mutations:
  • RAS mutation (Gly12 → Val): Locks RAS in GTP-bound active state (cannot hydrolyze GTP because GAP can't work) → constitutive MAPK signaling → cancer. Found in: KRAS in pancreatic cancer (>90%), colorectal cancer, lung cancer; NRAS in melanoma; HRAS in bladder cancer
  • RAF mutation (V600E): Constitutively active RAF → continuous MAPK signaling. Found in BRAF V600E in melanoma (>50%), papillary thyroid cancer, hairy cell leukemia
  • NF1 deletion: Loss of RAS-GAP → RAS stays active. Found in neurofibromatosis type 1; predisposes to NF1-associated tumors (neurofibromas, optic gliomas, leukemia)
  • EGFR mutations: Constitutive RTK activity → KRAS → MAPK. Lung adenocarcinoma; treated with EGFR inhibitors (erlotinib, gefitinib) - BUT only works if KRAS is wild-type!

Other GPCR-Related Signaling

cGMP pathway:
  • ANP/BNP bind receptor guanylyl cyclase (NOT a GPCR) → cGMP ↑ → PKG → vasodilation, natriuresis
  • NO (nitric oxide) activates soluble guanylyl cyclase in smooth muscle → cGMP → PKG → myosin light chain phosphatase → dephosphorylates MLC → smooth muscle relaxation/vasodilation
  • Sildenafil (Viagra): Inhibits PDE5 (which degrades cGMP) → cGMP stays elevated → prolonged smooth muscle relaxation → vasodilation in corpus cavernosum/pulmonary vessels
Phosphoinositide 3-kinase (PI3K)-Akt pathway:
  • RTKs (especially insulin receptor) → PI3K → PIP2 → PIP3 → recruits Akt (PKB) + PDK1 → Akt phosphorylated → active
  • Akt targets:
    • GLUT4 vesicle translocation (insulin-stimulated glucose uptake)
    • Glycogen synthase kinase-3 (GSK-3) → inhibited → glycogen synthase active → glycogen synthesis
    • FOXO transcription factors → phosphorylated → nuclear exclusion → anti-apoptotic
    • mTOR activation → protein synthesis, cell growth
  • PTEN is a phosphatase that converts PIP3 back to PIP2 → tumor suppressor; PTEN loss in prostate cancer, glioblastoma

BONUS: HIGH-YIELD CONNECTIONS & MNEMONICS

Mnemonics

  • GLUT locations: "1-4-ALL brain/RBC; 2-liver/beta; 3-neurons; 4-muscle/fat; 5-fructose"
  • Gs vs Gi vs Gq: "stimulate, inhibit, queeze the phospholipase"
  • PDH cofactors (B vitamins): "The Fairy Needs Candy Licorice" = Thiamine (B1), FAD (B2), NAD+ (B3), CoA (B5), Lipoic acid
  • Malate-aspartate shuttle: MALI organs (heart, liver, kidney) = Malate-aspartate = More ATP (2.5)
  • G3P shuttle: BRAIN and muscle = lower ATP (1.5) because uses FAD not NAD

Comparison Tables

Botulinum vs. Tetanus Toxin:
FeatureBotulinumTetanus
Site of actionNMJ presynapticInhibitory interneurons (spinal cord)
TransportDoes NOT travel retrogradeRetrograde transport to spinal cord
SNARE targetCleaves synaptobrevin (and SNAP-25 for some serotypes)Cleaves synaptobrevin
EffectBlocks ACh releaseBlocks glycine/GABA release
Paralysis typeFlaccidSpastic (rigidity, lockjaw)
CNS vs. PNS Demyelination:
FeatureMS (CNS)GBS (PNS)
Cell targetedOligodendrocytesSchwann cells
Lesion locationPeriventricular, optic nervePeripheral nerves
PathologyPlaques; periventricularAscending paralysis
CSFOligoclonal bands, ↑IgGAlbuminocytologic dissociation (↑protein, normal WBC)
DTRsOften preserved earlyLost (areflexia)
TriggerUnknown (HLA-DR15)Post-infection (C. jejuni, CMV)
Axonal Transport Hijacked by Pathogens:
  • Retrograde: Rabies, HSV, Polio, Tetanus toxin, NGF
  • Remember: they all go TO the cell body / CNS

Good luck on your test tomorrow! The highest-yield topics for USMLE from this list are: GLUT4/insulin signaling, G6PD deficiency, Na+/K+-ATPase pharmacology (digoxin), SNARE proteins (botulinum vs. tetanus), the MAPK/RAS pathway and its cancer mutations, GPCR desensitization (GRK/β-arrestin), and the malate-aspartate vs. glycerol-3-phosphate shuttle distinction. Make sure you know the "why" behind every mechanism - that is what USMLE tests.

Create a USMLE study PDF with high-yield facts, mnemonics, and clinical pearls

Reading File
Running Command

ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "created"

Running Command

mkdir -p /tmp/workspace/usmle-study-guide

Writing File

~/usmle-study-guide/build_pdf.py

#!/usr/bin/env python3
"""
USMLE High-Yield Study Guide PDF Builder
Uses ReportLab for rich formatting
"""

from reportlab.lib.pagesizes import letter
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.tableofcontents import TableOfContents
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate
from reportlab.lib.colors import HexColor, Color
import os

# ── Color palette ──────────────────────────────────────────────────────────────
NAVY       = HexColor("#1A2B5F")
TEAL       = HexColor("#0B7A75")
AMBER      = HexColor("#E07B00")
CORAL      = HexColor("#C0392B")
LIGHT_BLUE = HexColor("#EBF4FA")
LIGHT_TEAL = HexColor("#E0F7F6")
LIGHT_AMBER= HexColor("#FFF3E0")
LIGHT_CORAL= HexColor("#FDECEA")
LIGHT_GRAY = HexColor("#F5F5F5")
MID_GRAY   = HexColor("#CCCCCC")
DARK_GRAY  = HexColor("#444444")
WHITE      = colors.white
BLACK      = colors.black
GREEN      = HexColor("#1B6B35")
LIGHT_GREEN= HexColor("#E8F5E9")
PURPLE     = HexColor("#6A0DAD")
LIGHT_PURPLE=HexColor("#F3E5F5")

OUTPUT_PATH = "/tmp/workspace/usmle-study-guide/USMLE_High_Yield_Study_Guide.pdf"

# ── Document setup ─────────────────────────────────────────────────────────────
def build_styles():
    base = getSampleStyleSheet()

    styles = {}

    styles['cover_title'] = ParagraphStyle(
        'cover_title', fontName='Helvetica-Bold', fontSize=32,
        textColor=WHITE, alignment=TA_CENTER, leading=38, spaceAfter=8
    )
    styles['cover_sub'] = ParagraphStyle(
        'cover_sub', fontName='Helvetica', fontSize=14,
        textColor=HexColor("#AEDFF7"), alignment=TA_CENTER, leading=20, spaceAfter=6
    )
    styles['cover_tag'] = ParagraphStyle(
        'cover_tag', fontName='Helvetica-Oblique', fontSize=11,
        textColor=HexColor("#FFD580"), alignment=TA_CENTER, leading=16
    )
    styles['section_header'] = ParagraphStyle(
        'section_header', fontName='Helvetica-Bold', fontSize=17,
        textColor=WHITE, alignment=TA_LEFT, leading=22,
        spaceBefore=4, spaceAfter=6, leftIndent=0
    )
    styles['topic_header'] = ParagraphStyle(
        'topic_header', fontName='Helvetica-Bold', fontSize=13,
        textColor=NAVY, alignment=TA_LEFT, leading=17,
        spaceBefore=10, spaceAfter=4
    )
    styles['sub_header'] = ParagraphStyle(
        'sub_header', fontName='Helvetica-Bold', fontSize=11,
        textColor=TEAL, alignment=TA_LEFT, leading=14,
        spaceBefore=7, spaceAfter=3
    )
    styles['body'] = ParagraphStyle(
        'body', fontName='Helvetica', fontSize=9.5,
        textColor=DARK_GRAY, alignment=TA_JUSTIFY, leading=14,
        spaceBefore=2, spaceAfter=2, leftIndent=4
    )
    styles['bullet'] = ParagraphStyle(
        'bullet', fontName='Helvetica', fontSize=9.5,
        textColor=DARK_GRAY, alignment=TA_LEFT, leading=13,
        spaceBefore=1, spaceAfter=1, leftIndent=14, bulletIndent=4,
        bulletText='•'
    )
    styles['sub_bullet'] = ParagraphStyle(
        'sub_bullet', fontName='Helvetica', fontSize=9,
        textColor=DARK_GRAY, alignment=TA_LEFT, leading=12,
        spaceBefore=0, spaceAfter=0, leftIndent=28, bulletIndent=18,
        bulletText='–'
    )
    styles['pearl'] = ParagraphStyle(
        'pearl', fontName='Helvetica-Bold', fontSize=9.5,
        textColor=AMBER, alignment=TA_LEFT, leading=13,
        spaceBefore=2, spaceAfter=2, leftIndent=8
    )
    styles['mnemonic'] = ParagraphStyle(
        'mnemonic', fontName='Helvetica-BoldOblique', fontSize=10,
        textColor=PURPLE, alignment=TA_LEFT, leading=14,
        spaceBefore=2, spaceAfter=2, leftIndent=8
    )
    styles['warning'] = ParagraphStyle(
        'warning', fontName='Helvetica-Bold', fontSize=9.5,
        textColor=CORAL, alignment=TA_LEFT, leading=13,
        spaceBefore=2, spaceAfter=2, leftIndent=8
    )
    styles['table_header'] = ParagraphStyle(
        'table_header', fontName='Helvetica-Bold', fontSize=8.5,
        textColor=WHITE, alignment=TA_CENTER, leading=11
    )
    styles['table_cell'] = ParagraphStyle(
        'table_cell', fontName='Helvetica', fontSize=8,
        textColor=DARK_GRAY, alignment=TA_LEFT, leading=11
    )
    styles['table_cell_bold'] = ParagraphStyle(
        'table_cell_bold', fontName='Helvetica-Bold', fontSize=8,
        textColor=DARK_GRAY, alignment=TA_LEFT, leading=11
    )
    styles['page_num'] = ParagraphStyle(
        'page_num', fontName='Helvetica', fontSize=8,
        textColor=MID_GRAY, alignment=TA_CENTER
    )
    styles['highlight_body'] = ParagraphStyle(
        'highlight_body', fontName='Helvetica', fontSize=9.5,
        textColor=DARK_GRAY, alignment=TA_LEFT, leading=14,
        spaceBefore=2, spaceAfter=2, leftIndent=10
    )
    return styles

# ── Helper builders ─────────────────────────────────────────────────────────────

def section_banner(title, color=NAVY, styles=None):
    """Returns a full-width colored banner with white title text."""
    data = [[Paragraph(title, styles['section_header'])]]
    t = Table(data, colWidths=[7.0*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), color),
        ('TOPPADDING',   (0,0), (-1,-1), 8),
        ('BOTTOMPADDING',(0,0), (-1,-1), 8),
        ('LEFTPADDING',  (0,0), (-1,-1), 12),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('ROUNDEDCORNERS', [4]),
    ]))
    return t

def pearl_box(text, styles, color=LIGHT_AMBER, border=AMBER, label="⭐ USMLE PEARL"):
    full = f"<b>{label}:</b> {text}"
    data = [[Paragraph(full, styles['pearl'])]]
    t = Table(data, colWidths=[6.8*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), color),
        ('LEFTPADDING', (0,0), (-1,-1), 8),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('TOPPADDING', (0,0), (-1,-1), 5),
        ('BOTTOMPADDING', (0,0), (-1,-1), 5),
        ('LINEAFTER', (0,0), (0,-1), 4, border),
        ('BOX', (0,0), (-1,-1), 0.5, border),
    ]))
    return t

def mnemonic_box(text, styles):
    full = f"🧠 MNEMONIC: {text}"
    data = [[Paragraph(full, styles['mnemonic'])]]
    t = Table(data, colWidths=[6.8*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), LIGHT_PURPLE),
        ('LEFTPADDING', (0,0), (-1,-1), 8),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('TOPPADDING', (0,0), (-1,-1), 5),
        ('BOTTOMPADDING', (0,0), (-1,-1), 5),
        ('BOX', (0,0), (-1,-1), 0.5, PURPLE),
    ]))
    return t

def warning_box(text, styles):
    full = f"⚠️ WATCH OUT: {text}"
    data = [[Paragraph(full, styles['warning'])]]
    t = Table(data, colWidths=[6.8*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), LIGHT_CORAL),
        ('LEFTPADDING', (0,0), (-1,-1), 8),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('TOPPADDING', (0,0), (-1,-1), 5),
        ('BOTTOMPADDING', (0,0), (-1,-1), 5),
        ('BOX', (0,0), (-1,-1), 0.5, CORAL),
    ]))
    return t

def info_box(text, styles):
    data = [[Paragraph(text, styles['highlight_body'])]]
    t = Table(data, colWidths=[6.8*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('TOPPADDING', (0,0), (-1,-1), 5),
        ('BOTTOMPADDING', (0,0), (-1,-1), 5),
        ('LINEBEFORE', (0,0), (0,-1), 4, TEAL),
        ('BOX', (0,0), (-1,-1), 0.5, TEAL),
    ]))
    return t

def two_col_table(headers, rows, styles, col_widths=None):
    """Generic styled table."""
    if col_widths is None:
        n = len(headers)
        col_widths = [7.0*inch / n] * n

    table_data = [[Paragraph(h, styles['table_header']) for h in headers]]
    for row in rows:
        table_data.append([Paragraph(str(c), styles['table_cell']) for c in row])

    t = Table(table_data, colWidths=col_widths, repeatRows=1)
    cmd = [
        ('BACKGROUND', (0,0), (-1,0), NAVY),
        ('GRID', (0,0), (-1,-1), 0.4, MID_GRAY),
        ('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, LIGHT_GRAY]),
        ('TOPPADDING', (0,0), (-1,-1), 4),
        ('BOTTOMPADDING', (0,0), (-1,-1), 4),
        ('LEFTPADDING', (0,0), (-1,-1), 5),
        ('RIGHTPADDING', (0,0), (-1,-1), 5),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ]
    t.setStyle(TableStyle(cmd))
    return t

def sp(n=1):
    return Spacer(1, n * 4)

def hr(styles):
    return HRFlowable(width="100%", thickness=0.5, color=MID_GRAY, spaceAfter=4, spaceBefore=4)

# ── Page templates ─────────────────────────────────────────────────────────────

def on_page(canvas, doc):
    canvas.saveState()
    # Footer
    canvas.setFont('Helvetica', 7.5)
    canvas.setFillColor(MID_GRAY)
    canvas.drawString(inch*0.75, 0.45*inch, "USMLE High-Yield Study Guide")
    canvas.drawRightString(letter[0] - inch*0.75, 0.45*inch, f"Page {doc.page}")
    canvas.setStrokeColor(MID_GRAY)
    canvas.setLineWidth(0.3)
    canvas.line(inch*0.75, 0.55*inch, letter[0]-inch*0.75, 0.55*inch)
    canvas.restoreState()

def on_cover(canvas, doc):
    canvas.saveState()
    # Full navy background
    canvas.setFillColor(NAVY)
    canvas.rect(0, 0, letter[0], letter[1], fill=1, stroke=0)
    # Teal accent bar at top
    canvas.setFillColor(TEAL)
    canvas.rect(0, letter[1]-0.5*inch, letter[0], 0.5*inch, fill=1, stroke=0)
    # Amber bottom bar
    canvas.setFillColor(AMBER)
    canvas.rect(0, 0, letter[0], 0.35*inch, fill=1, stroke=0)
    canvas.restoreState()

# ── Content builders ───────────────────────────────────────────────────────────

def build_cover(styles):
    story = []
    story.append(Spacer(1, 2.0*inch))
    story.append(Paragraph("USMLE HIGH-YIELD", styles['cover_title']))
    story.append(Paragraph("STUDY GUIDE", styles['cover_title']))
    story.append(Spacer(1, 0.2*inch))
    story.append(HRFlowable(width="60%", thickness=2, color=TEAL, spaceAfter=12, hAlign='CENTER'))
    story.append(Paragraph("Cell Biology · Biochemistry · Neuroscience", styles['cover_sub']))
    story.append(Spacer(1, 0.15*inch))
    story.append(Paragraph(
        "Plasma Membrane • Transporters • GLUTs • Glycolysis • TCA • PPP\n"
        "Malate-Aspartate Shuttle • ROS Neutralization • Myelin & Glia\n"
        "Axonal Transport • Synapses • Neurotransmitters • GPCR Signaling",
        styles['cover_tag']
    ))
    story.append(Spacer(1, 0.5*inch))
    story.append(HRFlowable(width="40%", thickness=1, color=AMBER, spaceAfter=12, hAlign='CENTER'))
    story.append(Paragraph("High-Yield Facts • Mnemonics • Clinical Pearls • USMLE Traps", styles['cover_sub']))
    story.append(PageBreak())
    return story

def build_plasma_membrane(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 1: PLASMA MEMBRANE", NAVY, s))
    story.append(sp(2))

    story.append(Paragraph("Composition", s['topic_header']))
    story.append(info_box(
        "The plasma membrane is 7.5–10 nm thick. Composition: <b>55% proteins, 25% phospholipids, "
        "13% cholesterol, 4% other lipids, 3% carbohydrates</b>. "
        "Carbohydrates are <b>always on the extracellular face only</b> (glycoproteins + glycolipids = glycocalyx).",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Three Core Lipids", s['sub_header']))
    rows = [
        ["Phospholipids", "Most abundant; asymmetric distribution across leaflets"],
        ["Sphingolipids", "Abundant in nerve cells; form lipid rafts; signal transduction"],
        ["Cholesterol", "Regulates fluidity & permeability; buffers against temperature extremes"],
    ]
    story.append(two_col_table(["Lipid", "Key Role"], rows, s, [2.0*inch, 5.0*inch]))
    story.append(sp(2))

    story.append(Paragraph("Membrane Asymmetry", s['sub_header']))
    rows2 = [
        ["Outer Leaflet", "Phosphatidylcholine (PC), Sphingomyelin, Glycolipids, Cholesterol"],
        ["Inner Leaflet", "Phosphatidylserine (PS), Phosphatidylethanolamine (PE), Phosphatidylinositol (PI)"],
    ]
    story.append(two_col_table(["Leaflet", "Lipids Present"], rows2, s, [2.0*inch, 5.0*inch]))
    story.append(sp(1))
    story.append(pearl_box(
        "Phosphatidylserine (PS) normally on inner leaflet. Flipping to outer leaflet = signal for "
        "<b>apoptosis</b> (macrophage recognition) AND activates the <b>coagulation cascade</b>.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Membrane Proteins", s['sub_header']))
    rows3 = [
        ["Integral (transmembrane)", "Span entire bilayer; form channels, carriers, receptors; need detergent to extract"],
        ["Peripheral", "Attached to one surface; non-covalent; e.g. spectrin (RBC cytoskeleton)"],
    ]
    story.append(two_col_table(["Type", "Key Features"], rows3, s, [2.2*inch, 4.8*inch]))
    story.append(sp(2))

    story.append(Paragraph("Fluidity Modifiers", s['sub_header']))
    rows4 = [
        ["Unsaturated fatty acids (double bonds/kinks)", "↑ Fluidity"],
        ["Saturated fatty acids (straight chains, pack tightly)", "↓ Fluidity"],
        ["Short-chain fatty acids", "↑ Fluidity"],
        ["Cholesterol", "Buffer: prevents too-fluid at high temp; too-rigid at low temp"],
    ]
    story.append(two_col_table(["Factor", "Effect on Fluidity"], rows4, s, [4.0*inch, 3.0*inch]))
    story.append(sp(2))

    story.append(Paragraph("Permeability Rules", s['sub_header']))
    story.append(Paragraph("Freely cross (no transporter): O₂, CO₂, N₂, alcohol, steroid hormones, small nonpolar molecules, water (partial)", s['bullet']))
    story.append(Paragraph("Need a transporter: glucose, amino acids, ions (Na⁺, K⁺, Ca²⁺, Cl⁻), large polar molecules", s['bullet']))
    story.append(Paragraph("Cannot cross: proteins, nucleic acids, large charged molecules", s['bullet']))
    story.append(sp(2))
    story.append(warning_box("ABO blood group antigens are GLYCOLIPIDS on the RBC surface (not glycoproteins). MHC molecules are glycoproteins.", s))
    story.append(sp(3))
    return story

def build_transporters(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 2: MEMBRANE TRANSPORTERS", TEAL, s))
    story.append(sp(2))

    story.append(Paragraph("Overview: Passive vs. Active Transport", s['topic_header']))
    rows = [
        ["Simple Diffusion", "No", "No", "Down gradient", "O₂, CO₂, steroids, EtOH"],
        ["Facilitated Diffusion", "Yes (channel or carrier)", "No", "Down gradient", "Glucose (GLUTs), H₂O (AQP)"],
        ["Primary Active", "Yes (pump/ATPase)", "Yes (ATP)", "Against gradient", "Na⁺/K⁺-ATPase, SERCA, H⁺/K⁺-ATPase"],
        ["Secondary Active", "Yes (cotransporter)", "No (uses Na⁺ gradient)", "Against gradient (solute)", "SGLTs, Na⁺/H⁺ exchanger"],
    ]
    story.append(two_col_table(
        ["Type", "Protein Required?", "Direct ATP?", "Direction", "Examples"],
        rows, s, [1.6*inch, 1.6*inch, 1.1*inch, 1.3*inch, 1.4*inch]
    ))
    story.append(sp(2))

    story.append(Paragraph("Na⁺/K⁺-ATPase — THE Most Tested Pump", s['sub_header']))
    story.append(info_box(
        "<b>Pumps 3 Na⁺ OUT and 2 K⁺ IN</b> per ATP hydrolyzed. Electrogenic (net positive charge out). "
        "Maintains resting membrane potential and Na⁺ gradient for secondary active transport. "
        "<b>Inhibited by: ouabain, digoxin (cardiac glycosides)</b>.",
        s
    ))
    story.append(pearl_box(
        "Digoxin inhibits Na⁺/K⁺-ATPase → intracellular Na⁺ ↑ → Na⁺/Ca²⁺ exchanger works less → "
        "intracellular Ca²⁺ ↑ → increased cardiac contractility. Used in heart failure + atrial fibrillation.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Key Transporters for USMLE", s['sub_header']))
    rows2 = [
        ["Na⁺/K⁺-ATPase", "All cells", "3 Na⁺ out, 2 K⁺ in", "Digoxin, ouabain inhibit"],
        ["SERCA", "SR of muscle", "Ca²⁺ into SR", "Defective in heart failure"],
        ["H⁺/K⁺-ATPase", "Gastric parietal cells", "H⁺ out → acid secretion", "PPIs (omeprazole) block irreversibly"],
        ["SGLT1", "Small intestine", "Na⁺ + glucose/galactose", "Glucose-galactose malabsorption if mutated"],
        ["SGLT2", "Proximal tubule", "Na⁺ + glucose reabsorption", "SGLT2 inhibitors: T2DM treatment"],
        ["P-glycoprotein (MDR1)", "Many tumors, BBB, gut", "Pumps drugs out", "Multidrug resistance in cancer"],
        ["Aquaporin-2 (AQP2)", "Collecting duct", "Water reabsorption", "Regulated by ADH/vasopressin"],
    ]
    story.append(two_col_table(
        ["Transporter", "Location", "Substrate/Action", "Clinical Relevance"],
        rows2, s, [1.5*inch, 1.5*inch, 2.0*inch, 2.0*inch]
    ))
    story.append(sp(2))

    story.append(mnemonic_box("Secondary active transport: the Na⁺ gradient is the 'battery' – charged by Na⁺/K⁺-ATPase (uses ATP), then SGLT/NHE run off this battery (no direct ATP needed).", s))
    story.append(sp(2))
    story.append(pearl_box(
        "SGLT2 inhibitors (empagliflozin, dapagliflozin, canagliflozin): block Na⁺/glucose co-transport in proximal tubule → glucosuria → lower blood glucose. "
        "Also reduce cardiovascular mortality and renal disease progression in T2DM.",
        s
    ))
    story.append(sp(3))
    return story

def build_gluts(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 3: GLUCOSE TRANSPORTERS (GLUTs)", TEAL, s))
    story.append(sp(2))

    story.append(info_box(
        "All GLUTs are <b>facilitated diffusion</b> transporters — bidirectional, no ATP, cannot concentrate glucose above extracellular levels. "
        "They show saturation kinetics (Km, Vmax).",
        s
    ))
    story.append(sp(2))

    rows = [
        ["GLUT1", "Low (~1 mM)", "RBC, brain (BBB), placenta, basal all cells",
         "NOT insulin-regulated; constitutive", "GLUT1 deficiency: seizures, low CSF glucose → ketogenic diet"],
        ["GLUT2", "High (~15–20 mM)", "Liver, pancreatic β-cells, intestine (enterocytes), kidney proximal tubule",
         "NOT insulin-regulated; glucose SENSOR", "Fanconi-Bickel syndrome (GLUT2 mutation): glycogen accumulation in liver/kidney"],
        ["GLUT3", "Very low (~1.4 mM)", "Neurons (highest affinity — neurons always get glucose first)",
         "NOT insulin-regulated; constitutive", "Ensures neuron glucose supply even when blood glucose is low"],
        ["GLUT4", "~5 mM", "Skeletal muscle, adipose tissue, cardiac muscle",
         "INSULIN-DEPENDENT — stored in vesicles, translocates to membrane on insulin signal", "Impaired translocation in Type 2 DM (insulin resistance); exercise also triggers via AMPK"],
        ["GLUT5", "~6 mM (fructose)", "Small intestine (mainly), spermatocytes",
         "Transports FRUCTOSE ONLY — no glucose", "Hereditary fructose intolerance ≠ GLUT5; GLUT5 mutation = fructose malabsorption (diarrhea)"],
    ]
    story.append(two_col_table(
        ["GLUT", "Km", "Location", "Regulation", "Clinical Relevance"],
        rows, s, [0.6*inch, 0.9*inch, 1.7*inch, 2.0*inch, 1.8*inch]
    ))
    story.append(sp(2))

    story.append(mnemonic_box(
        '"1 brain (always on), 2 liver-sensor, 3 neurons (highest affinity), 4 muscle (insulin-dependent), 5 fructose-only"\n'
        'GLUT4 needs Insulin to Translocate — "G4 = Gym (muscle) + Insulin"',
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("GLUT4 Signaling Cascade (HIGH YIELD)", s['sub_header']))
    story.append(info_box(
        "<b>Insulin → Insulin Receptor (RTK) → auto-phosphorylation Tyr → IRS-1 → PI3K → PIP3 → "
        "PDK1 → Akt (PKB) → GLUT4 vesicle fusion with plasma membrane → glucose uptake ↑</b>. "
        "Exercise activates GLUT4 via <b>AMPK pathway</b>, independent of insulin.",
        s
    ))
    story.append(sp(3))
    return story

def build_carb_metabolism(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 4: CARBOHYDRATE METABOLISM", NAVY, s))
    story.append(sp(2))

    # Glycolysis
    story.append(Paragraph("Glycolysis (Cytosol)", s['topic_header']))
    story.append(info_box(
        "10-step pathway: Glucose → 2 Pyruvate + <b>2 net ATP</b> + 2 NADH (at step 6). "
        "Occurs in cytosol. ALL cells use glycolysis.",
        s
    ))
    story.append(sp(1))
    story.append(Paragraph("3 Irreversible (Regulated) Steps:", s['sub_header']))
    rows = [
        ["Step 1", "Hexokinase / Glucokinase", "Glucose → Glucose-6-P",
         "HK: low Km, product-inhibited; GK: high Km, liver/β-cells, induced by insulin", "ATP consumed"],
        ["Step 3", "PFK-1 ★ RATE-LIMITING", "Fructose-6-P → Fructose-1,6-BP",
         "Activated: AMP, ADP, F-2,6-BP; Inhibited: ATP, citrate", "ATP consumed"],
        ["Step 10", "Pyruvate kinase", "PEP → Pyruvate",
         "Activated: F-1,6-BP (feedforward); Inhibited: ATP, alanine; Deficiency = hemolytic anemia", "ATP generated"],
    ]
    story.append(two_col_table(
        ["Step", "Enzyme", "Reaction", "Regulation", "Energy"],
        rows, s, [0.5*inch, 1.6*inch, 1.5*inch, 2.6*inch, 0.8*inch]
    ))
    story.append(sp(1))
    story.append(mnemonic_box('"PFK-1 is the GATEKEEPER of glycolysis: AMP opens the gate (need energy), ATP closes it (enough energy), F-2,6-BP is the master key (insulin signal)."', s))
    story.append(sp(2))

    # PDH
    story.append(Paragraph("Pyruvate Dehydrogenase (PDH) Complex — Cytosol → Mitochondria Bridge", s['sub_header']))
    story.append(info_box(
        "Converts Pyruvate → Acetyl-CoA + NADH + CO₂. Location: <b>mitochondrial matrix</b>. "
        "<b>Required cofactors (ALL B vitamins):</b> Thiamine (B1), FAD (B2), NAD⁺ (B3), CoA (B5), Lipoic acid. "
        "<b>Inhibited by:</b> Acetyl-CoA, NADH, ATP (product inhibition). "
        "<b>Activated by:</b> NAD⁺, AMP, Ca²⁺.",
        s
    ))
    story.append(mnemonic_box('"The Fairy Needs Candy Licorice" = Thiamine (B1), FAD (B2), NAD+ (B3), CoA (B5), Lipoic acid', s))
    story.append(warning_box(
        "PDH deficiency / Thiamine (B1) deficiency → cannot convert pyruvate to Acetyl-CoA → "
        "pyruvate → lactate + alanine → LACTIC ACIDOSIS. Seen in Wernicke's encephalopathy (B1 deficiency). "
        "Treat with thiamine BEFORE giving glucose IV (giving glucose first depletes B1 further!).",
        s
    ))
    story.append(sp(2))

    # TCA
    story.append(Paragraph("TCA Cycle / Krebs Cycle (Mitochondrial Matrix)", s['topic_header']))
    story.append(info_box(
        "Per glucose: 2 acetyl-CoA → <b>6 NADH + 2 FADH₂ + 2 GTP</b>. "
        "Each NADH → 2.5 ATP; each FADH₂ → 1.5 ATP. "
        "CO₂ is released at: isocitrate dehydrogenase step AND α-ketoglutarate dehydrogenase step.",
        s
    ))
    rows_tca = [
        ["Citrate synthase", "OAA + Acetyl-CoA → Citrate", "Inhibited by citrate, NADH, ATP"],
        ["Isocitrate dehydrogenase ★", "Isocitrate → α-KG + CO₂ (RATE-LIMITING)", "Inhibited by ATP, NADH; Activated by ADP, Ca²⁺"],
        ["α-KG dehydrogenase", "α-KG → Succinyl-CoA + CO₂", "Same cofactors as PDH (B1, B2, B3, B5, lipoic acid)"],
        ["Succinyl-CoA synthetase", "Succinyl-CoA → Succinate", "Substrate-level phosphorylation → GTP"],
        ["Succinate dehydrogenase", "Succinate → Fumarate + FADH₂", "Complex II of ETC; inhibited by malonate (competitive inhibitor)"],
    ]
    story.append(two_col_table(
        ["Key Enzyme", "Reaction", "Regulation / Note"],
        rows_tca, s, [2.2*inch, 2.5*inch, 2.3*inch]
    ))
    story.append(sp(1))
    story.append(pearl_box(
        "TCA cycle intermediates as biosynthetic precursors: Citrate → cytosol → fatty acid synthesis; "
        "α-KG → glutamate; Succinyl-CoA → heme synthesis; OAA → aspartate, gluconeogenesis.",
        s
    ))
    story.append(sp(2))

    # PPP
    story.append(Paragraph("Pentose Phosphate Pathway (PPP) — Cytosol", s['topic_header']))
    story.append(info_box(
        "<b>Substrate:</b> Glucose-6-phosphate. <b>Products (oxidative phase):</b> NADPH + Ribose-5-phosphate + CO₂. "
        "Rate-limiting enzyme: <b>G6PD</b> (inhibited by NADPH). "
        "Non-oxidative phase uses transketolase (requires Thiamine/B1).",
        s
    ))
    story.append(Paragraph("Why NADPH Is Essential:", s['sub_header']))
    rows_nadph = [
        ["Glutathione recycling (GSSG → GSH)", "Antioxidant defense in ALL cells, especially RBCs"],
        ["Fatty acid synthesis", "2 NADPH per 2-carbon addition by FAS"],
        ["Cholesterol synthesis", "Multiple steps of HMG-CoA pathway"],
        ["Cytochrome P450 reactions", "Drug/steroid metabolism in liver"],
        ["NADPH oxidase (neutrophils)", "O₂ → O₂•⁻ (superoxide) to kill bacteria — INTENTIONAL ROS"],
        ["Nitric oxide synthase (NOS)", "Arginine → NO (vasodilation, immune defense)"],
    ]
    story.append(two_col_table(["NADPH Use", "Purpose"], rows_nadph, s, [3.2*inch, 3.8*inch]))
    story.append(sp(1))
    story.append(warning_box(
        "G6PD Deficiency (X-linked): Cannot make NADPH → cannot recycle glutathione → oxidative stress → "
        "Heinz bodies (denatured Hb) + bite cells → hemolytic anemia. "
        "Triggered by: primaquine, dapsone, sulfonamides, fava beans, infection. "
        "Most common enzymopathy worldwide. Protective against malaria.",
        s
    ))
    story.append(sp(2))

    # Malate-Aspartate Shuttle
    story.append(Paragraph("Malate-Aspartate Shuttle vs. Glycerol-3-Phosphate Shuttle", s['topic_header']))
    story.append(info_box(
        "Problem: Glycolysis produces NADH in the CYTOSOL, but NADH cannot cross the inner mitochondrial membrane. "
        "Two shuttles transfer the electrons into the mitochondria.",
        s
    ))
    rows_shuttle = [
        ["Malate-Aspartate", "Heart, Liver, Kidney\n('MALI')", "2.5 ATP per cytosolic NADH",
         "Cytosolic NADH → malate → crosses membrane → matrix NADH → enters at Complex I",
         "More efficient; uses aspartate-glutamate exchanger + malate-α-KG exchanger"],
        ["Glycerol-3-Phosphate", "Brain, Skeletal Muscle", "1.5 ATP per cytosolic NADH",
         "Cytosolic NADH → G3P → crosses membrane → FADH₂ → enters at Complex II",
         "Less efficient; FAD-linked (not NAD-linked)"],
    ]
    story.append(two_col_table(
        ["Shuttle", "Location", "ATP Yield", "Mechanism", "Key Point"],
        rows_shuttle, s, [1.3*inch, 1.2*inch, 1.0*inch, 2.0*inch, 1.5*inch]
    ))
    story.append(sp(1))
    story.append(mnemonic_box('"MALI organs use MAlate-aspartate and get More ATP (2.5). Brain and muscle use G3P and get less (1.5)."', s))
    story.append(sp(1))
    story.append(pearl_box(
        "Total ATP from 1 glucose (aerobic, with malate-aspartate shuttle): "
        "2 (glycolysis substrate-level) + 5 (2 cytosolic NADH via M-A shuttle) + 5 (2 PDH NADH) + "
        "15 (6 TCA NADH) + 3 (2 TCA FADH₂) + 2 (2 GTP) = <b>~30–32 ATP total</b>.",
        s
    ))
    story.append(sp(3))
    return story

def build_ros(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 5: ROS NEUTRALIZATION", CORAL, s))
    story.append(sp(2))

    story.append(Paragraph("Reactive Oxygen Species (ROS)", s['topic_header']))
    rows = [
        ["Superoxide (O₂•⁻)", "ETC leakage, NADPH oxidase", "Converted by SOD to H₂O₂"],
        ["Hydrogen peroxide (H₂O₂)", "SOD reaction, peroxisomal oxidases", "Converted by catalase or GPx to H₂O"],
        ["Hydroxyl radical (•OH)", "H₂O₂ + Fe²⁺ (Fenton reaction)", "MOST DANGEROUS — damages DNA, proteins, lipids; no enzyme neutralizes it directly"],
        ["Peroxynitrite (ONOO⁻)", "O₂•⁻ + NO•", "Potent oxidant; damages mitochondria"],
    ]
    story.append(two_col_table(["ROS", "Source", "Fate/Note"], rows, s, [1.5*inch, 2.2*inch, 3.3*inch]))
    story.append(sp(2))

    story.append(Paragraph("Enzymatic Antioxidant Defenses", s['sub_header']))
    rows2 = [
        ["Superoxide dismutase (SOD)", "O₂•⁻ → H₂O₂", "Cu/Zn-SOD (cytosol); Mn-SOD (mitochondria)\nSOD1 (Cu/Zn) mutation → familial ALS"],
        ["Catalase", "2 H₂O₂ → 2 H₂O + O₂", "In PEROXISOMES; heme-containing; abundant in liver, RBCs"],
        ["Glutathione peroxidase (GPx)", "H₂O₂ + 2 GSH → 2 H₂O + GSSG", "Requires SELENIUM cofactor; primary H₂O₂ scavenger in RBCs"],
        ["Glutathione reductase", "GSSG + NADPH → 2 GSH", "Regenerates active GSH; requires NADPH (from PPP/G6PD)"],
    ]
    story.append(two_col_table(["Enzyme", "Reaction", "Key Notes"], rows2, s, [1.8*inch, 2.2*inch, 3.0*inch]))
    story.append(sp(2))

    story.append(Paragraph("Non-Enzymatic Antioxidants", s['sub_header']))
    rows3 = [
        ["Glutathione (GSH)", "Tripeptide: Glu-Cys-Gly", "Most important intracellular antioxidant"],
        ["Vitamin E (α-tocopherol)", "Lipid-soluble", "Protects cell membranes from lipid peroxidation; chain-breaking antioxidant"],
        ["Vitamin C (ascorbate)", "Water-soluble", "Donates electrons to free radicals; regenerates Vitamin E"],
        ["β-carotene", "Fat-soluble", "Quenches singlet oxygen (¹O₂)"],
    ]
    story.append(two_col_table(["Antioxidant", "Solubility", "Function"], rows3, s, [1.8*inch, 1.5*inch, 3.7*inch]))
    story.append(sp(2))

    story.append(mnemonic_box('"RBC antioxidant chain: G6PD → NADPH → Glutathione Reductase → GSH → GPx → H₂O₂ neutralized. Break ANY link in this chain = hemolysis."', s))
    story.append(sp(2))

    story.append(Paragraph("High-Yield Clinical Correlates", s['sub_header']))
    story.append(pearl_box(
        "Chronic Granulomatous Disease (CGD): NADPH oxidase deficiency → no O₂•⁻ → can't kill "
        "catalase-positive organisms (S. aureus, Aspergillus, Nocardia, Serratia). "
        "NBT test negative. X-linked or AR. Treat with IFN-γ + prophylactic antibiotics/antifungals.",
        s
    ))
    story.append(sp(1))
    story.append(pearl_box(
        "Acetaminophen (APAP) overdose: CYP2E1 → NAPQI (toxic metabolite) depletes glutathione → hepatocyte necrosis (centrilobular). "
        "Treat with N-acetylcysteine (NAC) — replenishes cysteine for GSH synthesis.",
        s
    ))
    story.append(sp(1))
    story.append(pearl_box(
        "Reperfusion injury: ischemia converts xanthine dehydrogenase → xanthine oxidase. "
        "On reperfusion, burst of O₂•⁻ and H₂O₂ → tissue damage (myocardial infarction, stroke).",
        s
    ))
    story.append(sp(3))
    return story

def build_neuroglia(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 6: MYELIN & NEUROGLIA", TEAL, s))
    story.append(sp(2))

    story.append(Paragraph("Glial Cell Comparison Table", s['topic_header']))
    rows = [
        ["Astrocyte", "CNS", "Neuroectoderm", "BBB maintenance (end feet), K⁺ buffering, glutamate reuptake, glycogen storage, reactive gliosis",
         "GFAP+; Alzheimer type II astrocytes (hepatic encephalopathy); GBM"],
        ["Oligodendrocyte", "CNS", "Neuroectoderm", "Myelinates up to 50 axons; one cell = multiple internodes",
         "Destroyed in MS; no Schwann-like ability to regenerate"],
        ["Schwann cell", "PNS", "Neural crest", "One cell = ONE internode of ONE axon; also envelops unmyelinated axons (Remak bundles)",
         "Schwannoma (NF2: bilateral acoustic); GBS (immune attack)"],
        ["Microglia", "CNS", "Yolk sac myeloid precursors (NOT neural crest!)", "CNS macrophages; phagocytosis; antigen presentation; cytokine release",
         "Activated in MS, Alzheimer, Parkinson, HIV dementia; form microglial nodules"],
        ["Ependymal cells", "CNS", "Neuroectoderm", "Line ventricles; produce/circulate CSF; have cilia",
         "Ependymoma (4th ventricle in children)"],
    ]
    story.append(two_col_table(
        ["Cell Type", "Location", "Origin", "Key Functions", "Clinical"],
        rows, s, [1.1*inch, 0.6*inch, 1.3*inch, 2.2*inch, 1.8*inch]
    ))
    story.append(sp(2))

    story.append(warning_box(
        "USMLE TRAP: Microglia are NOT derived from neural crest or neuroectoderm. "
        "They come from YOLK SAC myeloid precursors (same lineage as macrophages). "
        "They infiltrate the CNS early in development.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Myelin Structure & Function", s['sub_header']))
    story.append(info_box(
        "<b>Composition:</b> 70% lipid, 30% protein. "
        "<b>CNS myelin proteins:</b> PLP (most abundant CNS myelin protein), MBP, MAG. "
        "<b>PNS myelin proteins:</b> P0 (most abundant PNS myelin protein), MBP, MAG. "
        "<b>Nodes of Ranvier:</b> gaps between myelin sheaths; Na⁺ channels concentrated here; "
        "action potentials 'jump' between nodes = saltatory conduction (up to 120 m/s).",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Demyelinating Disease Comparison", s['sub_header']))
    rows_dm = [
        ["Multiple Sclerosis (MS)", "Oligodendrocytes (CNS)", "Periventricular, optic nerve, corpus callosum",
         "Oligoclonal bands, ↑IgG in CSF", "Relapsing-remitting; DTRs preserved early"],
        ["Guillain-Barré (GBS)", "Schwann cells (PNS)", "Peripheral nerves, ascending",
         "Albuminocytologic dissociation (↑protein, normal WBC)", "Areflexia; post-infection (C. jejuni, CMV, EBV)"],
        ["Charcot-Marie-Tooth", "Schwann cells (PNS)", "Peripheral nerves",
         "Genetic testing (PMP22, MPZ, GJB1)", "Hereditary; foot deformity (pes cavus), weakness"],
    ]
    story.append(two_col_table(
        ["Disease", "Cell Targeted", "Location", "CSF / Lab", "Key Feature"],
        rows_dm, s, [1.3*inch, 1.4*inch, 1.4*inch, 1.6*inch, 1.3*inch]
    ))
    story.append(sp(3))
    return story

def build_axonal_transport(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 7: AXONAL TRANSPORT", NAVY, s))
    story.append(sp(2))

    story.append(Paragraph("Overview", s['topic_header']))
    story.append(info_box(
        "Axons have virtually no ribosomes → most proteins synthesized in soma and transported down axon. "
        "Cutting axon from cell body → <b>Wallerian degeneration</b> of distal segment. "
        "Transport occurs along <b>microtubule tracks</b> powered by molecular motors.",
        s
    ))
    story.append(sp(2))

    rows = [
        ["Anterograde\n(Fast)", "Soma → Terminal", "~200–400 mm/day", "<b>Kinesin</b> (plus-end directed)\nATP-dependent",
         "Synaptic vesicle precursors, mitochondria, membrane proteins, smooth ER"],
        ["Anterograde\n(Slow)", "Soma → Terminal", "0.5–10 mm/day", "Kinesin (slow component)\nATP-dependent",
         "Cytoskeletal proteins (tubulin, actin, neurofilaments), metabolic enzymes"],
        ["Retrograde", "Terminal → Soma", "~200 mm/day", "<b>Dynein</b> (minus-end directed)\nATP-dependent",
         "Used vesicle membranes for recycling, endosomes, NGF, trophic signals, VIRUSES & TOXINS"],
    ]
    story.append(two_col_table(
        ["Type", "Direction", "Speed", "Motor / Energy", "Cargo"],
        rows, s, [0.85*inch, 1.0*inch, 1.0*inch, 1.6*inch, 2.55*inch]
    ))
    story.append(sp(2))

    story.append(mnemonic_box('"Kinesin = Kometo (goes away from cell body toward terminal). Dynein = Dynein drags stuff back to Dorm (cell body)."', s))
    story.append(sp(2))

    story.append(Paragraph("Retrograde Hijackers (HIGH YIELD)", s['sub_header']))
    rows2 = [
        ["Rabies virus", "Peripheral nerve → dorsal root ganglion → CNS", "Furious or paralytic rabies; encephalitis"],
        ["Herpes simplex (HSV)", "Sensory nerve endings → dorsal root ganglion (latency)", "Cold sores, genital herpes; reactivates under stress"],
        ["Poliovirus", "NMJ → motor neuron soma", "Destruction of anterior horn cells → flaccid paralysis"],
        ["Tetanus toxin", "NMJ → spinal cord inhibitory interneurons", "Blocks glycine/GABA → spastic paralysis, trismus (lockjaw)"],
        ["NGF (nerve growth factor)", "Target organ → sympathetic/sensory neuron soma", "Trophic signal for neuron survival"],
    ]
    story.append(two_col_table(
        ["Agent", "Route", "Disease / Effect"],
        rows2, s, [1.5*inch, 3.0*inch, 2.5*inch]
    ))
    story.append(sp(2))

    story.append(warning_box(
        "Botulinum toxin does NOT travel retrograde. It acts at the NMJ presynaptic terminal, "
        "cleaves SNARE proteins → blocks ACh release → FLACCID paralysis. "
        "Tetanus travels retrograde → SPASTIC paralysis. Know the difference!",
        s
    ))
    story.append(sp(3))
    return story

def build_synapses(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 8: SYNAPSES & NEUROTRANSMITTERS", TEAL, s))
    story.append(sp(2))

    story.append(Paragraph("Synaptic Transmission — Step by Step", s['topic_header']))
    steps = [
        "Action potential reaches presynaptic terminal",
        "Voltage-gated Ca²⁺ channels open (N-type/P-Q type) → Ca²⁺ influx",
        "Ca²⁺ binds synaptotagmin (Ca²⁺ sensor) → triggers SNARE complex zippering",
        "v-SNARE (synaptobrevin/VAMP) on vesicle + t-SNAREs (syntaxin + SNAP-25) on membrane → fusion → exocytosis",
        "Neurotransmitter diffuses across 20–40 nm synaptic cleft",
        "NT binds postsynaptic receptors (ionotropic = fast ms; metabotropic/GPCR = slow s–min)",
        "Signal termination: reuptake (DA, 5-HT, NE, GABA), enzymatic degradation (ACh by AChE), or diffusion",
    ]
    for i, step in enumerate(steps, 1):
        story.append(Paragraph(f"{i}. {step}", s['bullet']))
    story.append(sp(2))

    story.append(pearl_box(
        "SNARE proteins: Botulinum toxin cleaves synaptobrevin (and SNAP-25 for types A,E) → "
        "blocks ACh at NMJ → FLACCID paralysis. "
        "Tetanus toxin cleaves synaptobrevin in INHIBITORY interneurons → blocks glycine/GABA → SPASTIC paralysis.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Neurotransmitter Summary Table", s['topic_header']))
    rows = [
        ["ACh", "Choline + Acetyl-CoA", "Choline acetyltransferase", "NMJ, ANS ganglia, basal forebrain",
         "nAChR (ion), mAChR (GPCR)", "AChE in cleft; choline reuptake"],
        ["Dopamine (DA)", "Tyrosine → DOPA → DA", "Tyrosine hydroxylase ★", "Substantia nigra, VTA",
         "D1–D5 (all GPCR)", "DAT reuptake; MAO-B, COMT"],
        ["Norepinephrine (NE)", "DA → NE", "Dopamine-β-hydroxylase", "Locus coeruleus, sympathetic ganglia",
         "α1, α2, β1, β2 (GPCR)", "NET reuptake; MAO-A, COMT"],
        ["Serotonin (5-HT)", "Tryptophan → 5-HTP → 5-HT", "Tryptophan hydroxylase ★", "Raphe nuclei",
         "5-HT₃ (ion); all others GPCR", "SERT reuptake; MAO-A"],
        ["Glutamate", "α-KG (TCA)", "Glutaminase", "Most excitatory CNS synapses",
         "NMDA, AMPA, kainate (ion); mGluR (GPCR)", "EAAT transporters (astrocytes)"],
        ["GABA", "Glutamate", "GAD (needs Vit B6)", "Most inhibitory CNS synapses",
         "GABA-A (Cl⁻ ion); GABA-B (GPCR)", "GAT reuptake transporters"],
        ["Glycine", "Serine", "SHMT", "Spinal cord inhibitory interneurons",
         "GlyR (Cl⁻ ion)", "GlyT reuptake"],
    ]
    story.append(two_col_table(
        ["NT", "Precursor", "Rate-Limiting Enzyme", "Location", "Receptor", "Inactivation"],
        rows, s, [0.7*inch, 1.1*inch, 1.3*inch, 1.2*inch, 1.3*inch, 1.4*inch]
    ))
    story.append(sp(2))

    story.append(Paragraph("NMDA Receptor — Coincidence Detector (CRITICAL)", s['sub_header']))
    story.append(info_box(
        "<b>Requires simultaneously:</b> (1) Glutamate binding + (2) Membrane depolarization to remove Mg²⁺ block + (3) Glycine co-agonist. "
        "When both conditions met → Ca²⁺ influx → CaM kinase II activation → LTP (learning and memory). "
        "<b>Blocked by:</b> Ketamine (anesthesia), Memantine (Alzheimer's), PCP (psychosis model), Mg²⁺ (at rest), Ethanol.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("Dopamine Pathways (HIGH YIELD for Schizophrenia)", s['sub_header']))
    rows_da = [
        ["Mesolimbic", "VTA → limbic system", "Reward, motivation", "↑ in schizophrenia (positive symptoms)", "D2 antagonists (antipsychotics) target here"],
        ["Mesocortical", "VTA → prefrontal cortex", "Cognition, emotion", "↓ in schizophrenia (negative symptoms)", "Blocking here worsens negative symptoms"],
        ["Nigrostriatal", "Substantia nigra → striatum", "Motor control, movement", "↓ in Parkinson's disease", "L-DOPA + carbidopa replaces DA"],
        ["Tuberoinfundibular", "Hypothalamus → anterior pituitary", "Inhibits prolactin release", "Antipsychotics block D2 here", "→ hyperprolactinemia → gynecomastia, galactorrhea, amenorrhea"],
    ]
    story.append(two_col_table(
        ["Pathway", "Route", "Function", "Disease Relevance", "Drug Effect"],
        rows_da, s, [1.1*inch, 1.3*inch, 1.2*inch, 1.5*inch, 1.9*inch]
    ))
    story.append(sp(3))
    return story

def build_gpcr(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 9: GPCR SIGNALING", NAVY, s))
    story.append(sp(2))

    story.append(Paragraph("GPCR Structure", s['topic_header']))
    story.append(info_box(
        "<b>7 transmembrane (7-TM) alpha-helical domains</b>. N-terminus: extracellular (glycosylated, ligand binding). "
        "C-terminus: intracellular (phosphorylation site for GRK). "
        "3rd intracellular loop (ICL3): couples to G-protein. "
        "Associated heterotrimeric G-protein (Gα-GDP + Gβγ) at intracellular face. "
        ">800 GPCRs in human genome — largest receptor superfamily.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("G-Protein Types — MEMORIZE", s['topic_header']))
    rows_g = [
        ["Gs (stimulatory)", "Adenylyl cyclase ↑", "cAMP ↑ → PKA ↑",
         "β1, β2 adrenergic; D1, D5; H2 histamine; V2 vasopressin; glucagon; PTH; TSH; ACTH",
         "Cholera toxin ADP-ribosylates Gαs → permanent activation → massive cAMP → secretory diarrhea"],
        ["Gi (inhibitory)", "Adenylyl cyclase ↓", "cAMP ↓ → PKA ↓",
         "α2 adrenergic; M2, M4; D2, D3, D4; μ/δ/κ opioid; GABA-B; adenosine A1",
         "Pertussis toxin ADP-ribosylates Gαi → permanent inactivation → cAMP stays high"],
        ["Gq", "PLC-β ↑", "IP3 ↑ (→ Ca²⁺ release from ER) + DAG ↑ (→ PKC)",
         "α1 adrenergic; M1, M3, M5; H1 histamine; AT1 angiotensin; V1 vasopressin; TRH; oxytocin",
         "Phorbol esters mimic DAG → constitutive PKC activation → tumor promotion"],
        ["G12/13", "Rho GEFs", "RhoA activation → cytoskeletal changes",
         "Thrombin, LPA, many receptors",
         "Stress fiber formation; smooth muscle contraction; platelet shape change"],
    ]
    story.append(two_col_table(
        ["G-Protein", "Effector", "2nd Messenger / Effect", "Receptors", "Clinical Pearl"],
        rows_g, s, [0.8*inch, 1.0*inch, 1.3*inch, 1.8*inch, 2.1*inch]
    ))
    story.append(sp(2))

    story.append(mnemonic_box('"s=Stimulate cAMP; i=Inhibit cAMP; q=sQueeze PLC (triggers IP3+DAG); 12/13=Rho (cytoskeleton)"', s))
    story.append(sp(2))

    story.append(Paragraph("cAMP/PKA Pathway (Gs)", s['sub_header']))
    story.append(info_box(
        "Gs → adenylyl cyclase → ATP → <b>cAMP</b> → activates <b>PKA</b>. "
        "PKA targets: glycogen phosphorylase kinase (↑), glycogen synthase (↓), CREB (gene expression), "
        "hormone-sensitive lipase (↑ lipolysis in adipocytes). "
        "cAMP degraded by <b>phosphodiesterase (PDE)</b>. "
        "PDE inhibitors (sildenafil, theophylline, milrinone, caffeine) → ↑ cAMP/cGMP.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("GRK (G Protein-Coupled Receptor Kinases) & Desensitization", s['topic_header']))
    story.append(info_box(
        "After prolonged agonist exposure, the cell DESENSITIZES to prevent over-stimulation.",
        s
    ))
    steps = [
        "Agonist-occupied GPCR is phosphorylated on Ser/Thr (C-tail or ICL3) by <b>GRK</b> (7 isoforms: GRK1–7)",
        "Phosphorylated receptor gains high affinity for <b>β-arrestin</b>",
        "β-arrestin binds → sterically blocks G-protein coupling → <b>desensitization</b>",
        "β-arrestin recruits clathrin + AP-2 → receptor internalized via clathrin-coated pits → <b>downregulation</b>",
        "Internalized receptor: recycled back (resensitization) OR sorted to lysosome (degradation)",
    ]
    for i, step in enumerate(steps, 1):
        story.append(Paragraph(f"{i}. {step}", s['bullet']))
    story.append(sp(1))
    story.append(pearl_box(
        "GRK isoforms: GRK1 (rhodopsin kinase — mutation → Oguchi disease / stationary night blindness). "
        "GRK2 (β-ARK1) — upregulated in heart failure → β-receptor desensitization worsens cardiac function (therapeutic target). "
        "β-arrestin also signals independently ('biased agonism') — activates ERK1/2 after receptor internalization.",
        s
    ))
    story.append(sp(2))

    story.append(Paragraph("MAP Kinase (RAS-ERK) Pathway", s['topic_header']))
    story.append(info_box(
        "Activated by RTKs (EGF-R, insulin-R, PDGF-R) and GPCRs (via Gβγ or β-arrestin).",
        s
    ))
    cascade = [
        "Ligand → RTK dimerizes → Tyr autophosphorylation",
        "<b>Grb2</b> (SH2 domain) binds phosphoTyr → recruits <b>SOS</b> (RAS-GEF via SH3 domain)",
        "<b>SOS activates RAS</b>: GDP → GTP exchange on RAS protein",
        "<b>RAS-GTP → activates RAF</b> (MAP3K; first kinase in cascade)",
        "<b>RAF phosphorylates MEK</b> (MAP2K = MKK1/2) → MEK activated",
        "<b>MEK phosphorylates ERK1/2</b> (MAPK = extracellular signal-regulated kinase)",
        "<b>ERK1/2</b> → nucleus → phosphorylates Elk-1, c-Fos, c-Myc → gene expression → proliferation, differentiation, survival",
    ]
    for i, step in enumerate(cascade, 1):
        story.append(Paragraph(f"{i}. {step}", s['bullet']))
    story.append(sp(1))
    story.append(mnemonic_box('"RAS-RAF-MEK-ERK: Remember At Medical Exam Results" or "Grb2-SOS-RAS-RAF-MEK-ERK"', s))
    story.append(sp(2))

    story.append(Paragraph("MAPK Pathway Cancer Mutations (MUST KNOW)", s['sub_header']))
    rows_mut = [
        ["KRAS G12V/G12D", "Locks RAS in GTP-active state (GAP cannot work)", "Pancreatic cancer >90%, colorectal, lung adenocarcinoma", "KRAS mutations = NO response to anti-EGFR therapy (cetuximab)"],
        ["BRAF V600E", "Constitutively active RAF kinase", "Melanoma >50%, papillary thyroid, hairy cell leukemia", "Vemurafenib (BRAF inhibitor); combined with MEK inhibitor (trametinib)"],
        ["NF1 deletion", "Loss of RAS-GAP (neurofibromin) → RAS stays active", "Neurofibromatosis type 1; optic glioma, NF-associated tumors", "NF1: café-au-lait spots, Lisch nodules, neurofibromas"],
        ["EGFR mutation (exon 19/21)", "Constitutive RTK activity", "Lung adenocarcinoma (non-smokers, Asian women)", "Erlotinib, gefitinib, osimertinib (EGFR TKIs); ONLY if KRAS wild-type"],
    ]
    story.append(two_col_table(
        ["Mutation", "Mechanism", "Cancer", "Clinical Relevance"],
        rows_mut, s, [1.5*inch, 1.7*inch, 1.8*inch, 2.0*inch]
    ))
    story.append(sp(3))
    return story

def build_receptors_overview(styles):
    s = styles
    story = []
    story.append(section_banner("TOPIC 10: RECEPTOR TYPES — OVERVIEW", TEAL, s))
    story.append(sp(2))

    rows = [
        ["Ion Channel\n(Ionotropic)", "Milliseconds", "NONE needed", "Direct ion flow through pore",
         "nAChR (Na⁺/K⁺), GABA-A (Cl⁻), NMDA (Ca²⁺/Na⁺), AMPA (Na⁺/K⁺), glycine-R (Cl⁻)"],
        ["GPCR\n(Metabotropic)", "Seconds–minutes", "G-proteins, 2nd messengers", "cAMP, IP3/DAG, RhoA",
         "Muscarinic (M1–5), Adrenergic (α1,α2,β1,β2), Dopamine (D1–5), opioid, GABA-B"],
        ["Receptor Tyrosine\nKinase (RTK)", "Minutes–hours", "RAS, PI3K", "Phosphorylation cascade",
         "Insulin-R, EGF-R, PDGF-R, VEGF-R, FGF-R, IGF-1R"],
        ["Intracellular / Nuclear\nReceptor", "Hours–days", "None (ligand enters cell)", "Direct gene transcription (HREs)",
         "Glucocorticoid-R, mineralocorticoid-R, androgen-R, ER, PR, thyroid-R (T3), Vit D-R, RA-R"],
    ]
    story.append(two_col_table(
        ["Receptor Class", "Speed", "Transducer", "Mechanism", "Examples"],
        rows, s, [1.1*inch, 0.9*inch, 1.1*inch, 1.2*inch, 2.7*inch]
    ))
    story.append(sp(2))
    story.append(pearl_box(
        "RTK vs. GPCR: Both activate MAPK/ERK. RTKs directly phosphorylate Tyr. "
        "GPCRs go via Gβγ → Grb2 → SOS → RAS, or via β-arrestin after desensitization.",
        s
    ))
    story.append(sp(2))
    story.append(pearl_box(
        "Nuclear receptors: When UNBOUND, many are held in cytoplasm by HSP90 (heat shock protein 90). "
        "Ligand binding displaces HSP90 → receptor translocates to nucleus → binds HRE → transcription. "
        "Exception: Thyroid hormone receptor is ALWAYS in nucleus (even unbound — acts as repressor).",
        s
    ))
    story.append(sp(3))
    return story

def build_quick_ref(styles):
    s = styles
    story = []
    story.append(section_banner("QUICK REFERENCE: HIGH-YIELD FACTS & MNEMONICS", AMBER, s))
    story.append(sp(2))

    story.append(Paragraph("Master Mnemonics", s['topic_header']))
    mnemonics = [
        ("GLUTs", "1=All cells/brain (always on), 2=Liver/sensor, 3=Neurons (highest affinity), 4=Muscle (Insulin-dependent), 5=Fructose only"),
        ("PDH cofactors", "The Fairy Needs Candy Licorice = Thiamine (B1), FAD (B2), NAD (B3), CoA (B5), Lipoic acid"),
        ("Malate-aspartate shuttle organs", "MALI = Heart (M), Liver (A), Kidney (L+I) → More ATP (2.5 per NADH)"),
        ("G-proteins", "s=Stimulate cAMP, i=Inhibit cAMP, q=sQueeze PLC → IP3+DAG, 12/13=Rho cytoskeleton"),
        ("RAS-MAPK cascade", "Grb2-SOS-RAS-RAF-MEK-ERK (anagram: Go Slam Racing Fast Many Excellent times)"),
        ("Axonal motors", "Kinesin goes to synaptic terminal (anterograde); Dynein goes back to soma (retrograde)"),
        ("RBC antioxidant chain", "G6PD → NADPH → GSH (via GR) → GPx → H₂O₂ neutralized; break = hemolysis"),
        ("Dopamine pathways", "MNLT: Mesolimbic (reward), Mesocortical (cognition), Nigrostriatal (motor), Tuberoinfundibular (prolactin)"),
        ("Glial cell origins", "Micro = Yolk sac (macrophage lineage), Oligo/Astro/Ependymal = Neuroectoderm, Schwann = Neural crest"),
    ]
    for label, text in mnemonics:
        story.append(mnemonic_box(f"[{label}] {text}", s))
        story.append(sp(1))
    story.append(sp(2))

    story.append(Paragraph("Top USMLE Traps", s['topic_header']))
    traps = [
        "GLUT2 (not GLUT4) is the glucose SENSOR in beta cells — NOT insulin-regulated",
        "Giving IV glucose to a thiamine-deficient patient FIRST worsens Wernicke's — always give B1 first",
        "Cholera toxin locks Gαs ON (not Gs receptor ON); pertussis locks Gαi OFF",
        "Botulinum = FLACCID paralysis (blocks ACh release at NMJ); Tetanus = SPASTIC (blocks inhibitory NT at spinal cord)",
        "Phosphatidylserine on OUTER leaflet = apoptosis signal AND coagulation trigger",
        "Microglia derive from yolk sac myeloid precursors — NOT neural crest, NOT neuroectoderm",
        "One oligodendrocyte myelinates MANY axons (up to 50); one Schwann cell myelinates ONE axon segment",
        "RAS mutations prevent GTP hydrolysis (GAP cannot work) → constitutively active → KRAS = most common oncogene mutation",
        "BRAF V600E in melanoma → vemurafenib; but add MEK inhibitor (trametinib) to prevent resistance",
        "EGFR inhibitors (erlotinib) only work if KRAS is wild-type — KRAS mutation = no response",
        "G6PD deficiency: Heinz bodies (Hb denatured inside RBC) + bite cells (macrophages bite Heinz bodies out)",
        "Pyruvate kinase deficiency → hemolytic anemia (RBCs rely only on glycolysis for ATP)",
        "NMDA receptor: needs BOTH glutamate AND depolarization (to remove Mg²⁺) AND glycine co-agonist",
        "Tyrosine hydroxylase is rate-limiting for dopamine AND norepinephrine AND epinephrine synthesis",
        "Tryptophan hydroxylase is rate-limiting for serotonin synthesis",
        "Succinate dehydrogenase = Complex II of ETC; only TCA enzyme embedded in inner mitochondrial membrane (not in matrix)",
    ]
    for trap in traps:
        story.append(warning_box(trap, s))
        story.append(sp(1))

    story.append(sp(3))
    return story


# ── Main build ─────────────────────────────────────────────────────────────────

def build_pdf():
    styles = build_styles()

    doc = BaseDocTemplate(
        OUTPUT_PATH,
        pagesize=letter,
        leftMargin=0.75*inch,
        rightMargin=0.75*inch,
        topMargin=0.85*inch,
        bottomMargin=0.75*inch,
        title="USMLE High-Yield Study Guide",
        author="Orris AI",
        subject="Cell Biology, Biochemistry, Neuroscience"
    )

    cover_frame  = Frame(0, 0, letter[0], letter[1], id='cover')
    normal_frame = Frame(
        0.75*inch, 0.75*inch,
        letter[0] - 1.5*inch, letter[1] - 1.5*inch,
        id='normal'
    )

    doc.addPageTemplates([
        PageTemplate(id='Cover', frames=[cover_frame], onPage=on_cover),
        PageTemplate(id='Normal', frames=[normal_frame], onPage=on_page),
    ])

    story = []

    # Cover page
    story += build_cover(styles)

    # Switch to normal template
    from reportlab.platypus import NextPageTemplate
    story.append(NextPageTemplate('Normal'))
    story.append(PageBreak())

    story += build_plasma_membrane(styles)
    story.append(PageBreak())

    story += build_transporters(styles)
    story.append(PageBreak())

    story += build_gluts(styles)
    story.append(PageBreak())

    story += build_carb_metabolism(styles)
    story.append(PageBreak())

    story += build_ros(styles)
    story.append(PageBreak())

    story += build_neuroglia(styles)
    story.append(PageBreak())

    story += build_axonal_transport(styles)
    story.append(PageBreak())

    story += build_synapses(styles)
    story.append(PageBreak())

    story += build_gpcr(styles)
    story.append(PageBreak())

    story += build_receptors_overview(styles)
    story.append(PageBreak())

    story += build_quick_ref(styles)

    doc.build(story)
    print(f"PDF built successfully: {OUTPUT_PATH}")

if __name__ == '__main__':
    build_pdf()
Running Command

cd /tmp/workspace/usmle-study-guide && python3 build_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/usmle-study-guide/USMLE_High_Yield_Study_Guide.pdf

Your PDF is ready! Here's what's inside:

USMLE High Yield Study Guide

PDF Document · PDF


What's in the PDF (11 sections, fully formatted):

#TopicWhat's Included
1Plasma MembraneComposition %, lipid types, asymmetry, fluidity rules, permeability
2TransportersActive vs. passive table, Na⁺/K⁺-ATPase, SGLT2 inhibitors
3GLUTsFull table (GLUT1-5), Km values, insulin signaling for GLUT4
4Carb MetabolismGlycolysis regulated steps, PDH cofactors, TCA cycle, PPP, malate-aspartate vs G3P shuttle
5ROS NeutralizationROS types, SOD/catalase/GPx/GR enzymes, CGD, APAP overdose, reperfusion injury
6Myelin & Neuroglia5 glial cell types, origins (microglia trap!), myelin proteins, MS vs GBS
7Axonal TransportKinesin vs dynein, fast/slow transport, retrograde hijackers (rabies, tetanus, HSV)
8Synapses & NTsStep-by-step transmission, SNARE proteins, full NT table, NMDA receptor, dopamine pathways
9GPCR SignalingG-protein types (Gs/Gi/Gq/G12), GRK/β-arrestin desensitization, RAS-MAPK cascade, cancer mutations
10Receptor Overview4 classes compared (speed, mechanism, examples)
11Quick ReferenceMaster mnemonics + 16 USMLE traps (warning boxes)
Design features: Color-coded section banners, pearl boxes (amber), mnemonic boxes (purple), warning/trap boxes (red), structured comparison tables throughout. Good luck tomorrow!
This is a shared conversation. Sign in to Orris to start your own chat.