Make a refined slide for Biochemistry lecture "Negatively Charged (Acidic) Amino Acids Aspartate: Strong negative charge at pH 7; forms oxaloacetate by transamination; important for albumin’s binding properties. Glutamate: Strong negative charge at pH 7; forms α-ketoglutarate by transamination; important for albumin’s binding properties.Albumin has these Negatively Charged acidic amino acids, which explains why it is a strong binding protein for calcium and other positively charged elements.

Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.

Make a refined slide for Biochemistry lecture "Negatively Charged (Acidic) Amino Acids Aspartate: Strong negative charge at pH 7; forms oxaloacetate by transamination; important for albumin’s binding properties. Glutamate: Strong negative charge at pH 7; forms α-ketoglutarate by transamination; important for albumin’s binding properties.Albumin has these Negatively Charged acidic amino acids, which explains why it is a strong binding protein for calcium and other positively charged elements.

Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/biochem-slides && cat > /home/daytona/workspace/biochem-slides/acidic_aa_slide.js << 'EOF' const pptxgen = require("pptxgenjs"); let pres = new pptxgen(); pres.layout = 'LAYOUT_16x9'; pres.title = 'Negatively Charged (Acidic) Amino Acids'; let slide = pres.addSlide(); // ── Background ────────────────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: "0D1B2A" } }); // ── Accent top bar ─────────────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 0.07, fill: { color: "E63946" } }); // ── Title block ────────────────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 0.45, y: 0.18, w: 9.1, h: 0.78, fill: { color: "1B2A3B" }, line: { color: "E63946", width: 1.5 } }); slide.addText("Negatively Charged (Acidic) Amino Acids", { x: 0.45, y: 0.18, w: 9.1, h: 0.78, fontSize: 24, bold: true, color: "FFFFFF", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); // ── pH label badge ─────────────────────────────────────────── slide.addShape(pres.ShapeType.roundRect, { x: 7.5, y: 1.15, w: 2.0, h: 0.42, rectRadius: 0.1, fill: { color: "E63946" } }); slide.addText("pKa side-chain < 4.1", { x: 7.5, y: 1.15, w: 2.0, h: 0.42, fontSize: 9, bold: true, color: "FFFFFF", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); // ── Aspartate card ─────────────────────────────────────────── // card bg slide.addShape(pres.ShapeType.rect, { x: 0.45, y: 1.12, w: 4.2, h: 2.88, fill: { color: "132133" }, line: { color: "E63946", width: 1.5 } }); // card top colour strip slide.addShape(pres.ShapeType.rect, { x: 0.45, y: 1.12, w: 4.2, h: 0.38, fill: { color: "E63946" } }); slide.addText("ASPARTATE (Asp / D)", { x: 0.45, y: 1.12, w: 4.2, h: 0.38, fontSize: 12, bold: true, color: "FFFFFF", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); // formula label slide.addShape(pres.ShapeType.roundRect, { x: 0.65, y: 1.62, w: 1.5, h: 0.32, rectRadius: 0.06, fill: { color: "1E3A55" } }); slide.addText("MW: 133.1 Da", { x: 0.65, y: 1.62, w: 1.5, h: 0.32, fontSize: 8, color: "A8C8E8", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); slide.addText([ { text: "Charge at pH 7: ", options: { bold: true, color: "E63946" } }, { text: "Strong negative (COO⁻)", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Transamination: ", options: { bold: true, color: "A8C8E8" } }, { text: "Asp → Oxaloacetate", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Role in Albumin: ", options: { bold: true, color: "A8C8E8" } }, { text: "Key contributor to Ca²⁺ & cation binding", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Other roles: ", options: { bold: true, color: "A8C8E8" } }, { text: "Urea cycle, purine synthesis, OAA in TCA", options: { color: "E0E0E0" } }, ], { x: 0.55, y: 2.02, w: 4.0, h: 1.88, fontSize: 10.5, fontFace: "Calibri", valign: "top", lineSpacingMultiple: 1.4 }); // ── Glutamate card ─────────────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 5.35, y: 1.12, w: 4.2, h: 2.88, fill: { color: "132133" }, line: { color: "2196F3", width: 1.5 } }); slide.addShape(pres.ShapeType.rect, { x: 5.35, y: 1.12, w: 4.2, h: 0.38, fill: { color: "2196F3" } }); slide.addText("GLUTAMATE (Glu / E)", { x: 5.35, y: 1.12, w: 4.2, h: 0.38, fontSize: 12, bold: true, color: "FFFFFF", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); slide.addShape(pres.ShapeType.roundRect, { x: 5.55, y: 1.62, w: 1.5, h: 0.32, rectRadius: 0.06, fill: { color: "1E3A55" } }); slide.addText("MW: 147.1 Da", { x: 5.55, y: 1.62, w: 1.5, h: 0.32, fontSize: 8, color: "A8C8E8", fontFace: "Calibri", align: "center", valign: "middle", margin: 0 }); slide.addText([ { text: "Charge at pH 7: ", options: { bold: true, color: "2196F3" } }, { text: "Strong negative (COO⁻)", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Transamination: ", options: { bold: true, color: "A8C8E8" } }, { text: "Glu → α-Ketoglutarate", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Role in Albumin: ", options: { bold: true, color: "A8C8E8" } }, { text: "Key contributor to Ca²⁺ & cation binding", options: { color: "E0E0E0" } }, { text: "\n" }, { text: "Other roles: ", options: { bold: true, color: "A8C8E8" } }, { text: "GABA synthesis, glutamine, TCA cycle hub", options: { color: "E0E0E0" } }, ], { x: 5.45, y: 2.02, w: 4.0, h: 1.88, fontSize: 10.5, fontFace: "Calibri", valign: "top", lineSpacingMultiple: 1.4 }); // ── Divider ────────────────────────────────────────────────── slide.addShape(pres.ShapeType.line, { x: 4.75, y: 1.2, w: 0, h: 2.7, line: { color: "3A5068", width: 1, dashType: "dash" } }); // ── Albumin footer banner ───────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 0.45, y: 4.18, w: 9.1, h: 1.1, fill: { color: "1B3A52" }, line: { color: "F4A261", width: 1.5 } }); // icon accent slide.addShape(pres.ShapeType.ellipse, { x: 0.55, y: 4.26, w: 0.6, h: 0.6, fill: { color: "F4A261" } }); slide.addText("🧬", { x: 0.55, y: 4.26, w: 0.6, h: 0.6, fontSize: 14, align: "center", valign: "middle", margin: 0 }); slide.addText([ { text: "Clinical Relevance - Albumin: ", options: { bold: true, color: "F4A261", fontSize: 11 } }, { text: "The abundance of Asp & Glu residues gives albumin a strong net negative charge, enabling it to bind Ca²⁺, Mg²⁺, and other cations. This is the biochemical basis for albumin's role as a carrier protein for calcium in plasma.", options: { color: "E8F4FD", fontSize: 10 } }, ], { x: 1.28, y: 4.18, w: 8.1, h: 1.1, fontFace: "Calibri", valign: "middle", lineSpacingMultiple: 1.3 }); // ── Bottom accent bar ──────────────────────────────────────── slide.addShape(pres.ShapeType.rect, { x: 0, y: 5.555, w: 10, h: 0.07, fill: { color: "F4A261" } }); // ── Footer text ────────────────────────────────────────────── slide.addText("Biochemistry | Amino Acid Chemistry", { x: 0.45, y: 5.37, w: 9.1, h: 0.2, fontSize: 7.5, color: "5A7A8A", fontFace: "Calibri", align: "right", italic: true }); pres.writeFile({ fileName: "/home/daytona/workspace/biochem-slides/Acidic_Amino_Acids.pptx" }) .then(() => console.log("DONE")) .catch(e => console.error(e)); EOF node /home/daytona/workspace/biochem-slides/acidic_aa_slide.js

Your slide is ready. Here's what was built:

Slide design highlights:
  • Dark navy background (#0D1B2A) - professional, easy on the eyes in lecture settings
  • Two side-by-side amino acid cards:
    • Aspartate - red accent (#E63946) with charge, transamination product (oxaloacetate), albumin role, and other metabolic functions
    • Glutamate - blue accent (#2196F3) with charge, transamination product (alpha-ketoglutarate), albumin role, and other functions (GABA, TCA)
  • Molecular weight badges on each card
  • Clinical Relevance footer banner (amber accent) clearly linking Asp/Glu abundance in albumin to Ca²+ and cation binding - the key teaching point
  • Thin colored bars at top and bottom for polish, with a discreet "Biochemistry | Amino Acid Chemistry" footer label

Acidic Amino Acids

Presentation · PPTX

Create slides for the other 18 amino acids (polar, nonpolar, special)

Running Command

cat > /home/daytona/workspace/biochem-slides/slide_nonpolar_aliphatic.js << 'JSEOF' const pptxgen = require("pptxgenjs"); let pres = new pptxgen(); pres.layout = 'LAYOUT_16x9'; pres.title = 'Nonpolar Aliphatic Amino Acids'; let slide = pres.addSlide(); // Background slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:5.625, fill:{color:"0D1B2A"} }); // Top bar slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:0.07, fill:{color:"27AE60"} }); // Title block slide.addShape(pres.ShapeType.rect, { x:0.35, y:0.13, w:9.3, h:0.72, fill:{color:"1B2A3B"}, line:{color:"27AE60",width:1.5} }); slide.addText("Nonpolar Aliphatic Amino Acids", { x:0.35, y:0.13, w:9.3, h:0.72, fontSize:22, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); // Badge slide.addShape(pres.ShapeType.roundRect, { x:7.8, y:0.93, w:1.82, h:0.34, rectRadius:0.08, fill:{color:"27AE60"} }); slide.addText("Hydrophobic | Core packing", { x:7.8, y:0.93, w:1.82, h:0.34, fontSize:7.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); // Helper to draw a card function card(slide, pres, x, y, w, h, title, accentColor, rows) { slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill:{color:"132133"}, line:{color:accentColor, width:1.2} }); slide.addShape(pres.ShapeType.rect, { x, y, w, h:0.33, fill:{color:accentColor} }); slide.addText(title, { x, y, w, h:0.33, fontSize:10, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); let textArr = []; rows.forEach((r, i) => { textArr.push({ text: r.label, options:{ bold:true, color:accentColor, fontSize:9 } }); textArr.push({ text: " " + r.value, options:{ color:"E0E0E0", fontSize:9 } }); if (i < rows.length-1) textArr.push({ text:"\n" }); }); slide.addText(textArr, { x:x+0.08, y:y+0.36, w:w-0.16, h:h-0.4, fontFace:"Calibri", valign:"top", lineSpacingMultiple:1.35 }); } // 5 cards in a row const cardW = 1.82, cardH = 3.35, cardY = 0.95, gap = 0.05; const startX = 0.35; card(slide, pres, startX, cardY, cardW, cardH, "GLY (G)", "27AE60", [ {label:"MW:", value:"75.0 Da"}, {label:"Charge pH7:", value:"Neutral"}, {label:"Unique:", value:"No chiral center; smallest AA"}, {label:"Structure:", value:"Single H side chain - extreme flexibility"}, {label:"Function:", value:"Found in collagen (Gly-X-Y repeat); glycine receptor (inhibitory NT)"}, {label:"Metabolism:", value:"One-carbon metabolism; serine interconversion"}, ]); card(slide, pres, startX + cardW + gap, cardY, cardW, cardH, "ALA (A)", "2ECC71", [ {label:"MW:", value:"89.1 Da"}, {label:"Charge pH7:", value:"Neutral"}, {label:"Unique:", value:"Methyl group; simplest chiral AA"}, {label:"Structure:", value:"CH₃ side chain; high alpha-helix propensity"}, {label:"Function:", value:"Most abundant AA in proteins; major gluconeogenic source"}, {label:"Metabolism:", value:"Alanine cycle: muscle → liver (glucose-alanine cycle)"}, ]); card(slide, pres, startX + 2*(cardW+gap), cardY, cardW, cardH, "VAL (V)", "1ABC9C", [ {label:"MW:", value:"117.1 Da"}, {label:"Charge pH7:", value:"Neutral"}, {label:"Unique:", value:"Branched-chain AA (BCAA); essential"}, {label:"Structure:", value:"Isopropyl side chain; β-sheet preferred"}, {label:"Function:", value:"BCAA; HbS mutation (Glu→Val) causes sickle cell"}, {label:"Metabolism:", value:"Degraded to succinyl-CoA (glucogenic)"}, ]); card(slide, pres, startX + 3*(cardW+gap), cardY, cardW, cardH, "LEU (L)", "16A085", [ {label:"MW:", value:"131.2 Da"}, {label:"Charge pH7:", value:"Neutral"}, {label:"Unique:", value:"BCAA; most common in proteins; essential"}, {label:"Structure:", value:"Isobutyl side chain; hydrophobic core"}, {label:"Function:", value:"mTOR activator; activates protein synthesis"}, {label:"Metabolism:", value:"Purely ketogenic → acetyl-CoA/acetoacetate"}, ]); card(slide, pres, startX + 4*(cardW+gap), cardY, cardW, cardH, "ILE (I)", "0E7A6B", [ {label:"MW:", value:"131.2 Da"}, {label:"Charge pH7:", value:"Neutral"}, {label:"Unique:", value:"BCAA; 2 chiral centers; essential"}, {label:"Structure:", value:"sec-butyl chain; tightly packed core"}, {label:"Function:", value:"BCAA; MSUD (maple syrup urine disease) with Leu/Val"}, {label:"Metabolism:", value:"Both glucogenic & ketogenic"}, ]); // Footer slide.addShape(pres.ShapeType.rect, { x:0.35, y:4.38, w:9.3, h:0.9, fill:{color:"1B3A52"}, line:{color:"27AE60",width:1} }); slide.addText([ {text:"Key Concept: ", options:{bold:true, color:"27AE60", fontSize:9.5}}, {text:"All five form the hydrophobic core of folded proteins. BCAAs (Val, Leu, Ile) are metabolized in muscle, not liver — clinically important in MSUD (deficient branched-chain α-keto acid dehydrogenase). Ala–Glu cycle shuttles nitrogen from muscle to liver.", options:{color:"E8F4FD", fontSize:9.5}}, ], { x:0.45, y:4.38, w:9.1, h:0.9, fontFace:"Calibri", valign:"middle", lineSpacingMultiple:1.3 }); slide.addShape(pres.ShapeType.rect, { x:0, y:5.555, w:10, h:0.07, fill:{color:"27AE60"} }); slide.addText("Biochemistry | Amino Acid Chemistry", { x:0.35, y:5.36, w:9.3, h:0.2, fontSize:7, color:"5A7A8A", fontFace:"Calibri", align:"right", italic:true }); pres.writeFile({ fileName:"/home/daytona/workspace/biochem-slides/Slide1_Nonpolar_Aliphatic.pptx" }) .then(()=>console.log("SLIDE1 DONE")).catch(e=>console.error(e)); JSEOF node /home/daytona/workspace/biochem-slides/slide_nonpolar_aliphatic.js

Running Command

cat > /home/daytona/workspace/biochem-slides/slide_nonpolar_aromatic.js << 'JSEOF' const pptxgen = require("pptxgenjs"); let pres = new pptxgen(); pres.layout = 'LAYOUT_16x9'; pres.title = 'Nonpolar Aromatic & Special Amino Acids'; let slide = pres.addSlide(); // Background slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:5.625, fill:{color:"0D1B2A"} }); slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:0.07, fill:{color:"9B59B6"} }); // Title slide.addShape(pres.ShapeType.rect, { x:0.35, y:0.13, w:9.3, h:0.72, fill:{color:"1B2A3B"}, line:{color:"9B59B6",width:1.5} }); slide.addText("Nonpolar Aromatic & Special Amino Acids", { x:0.35, y:0.13, w:9.3, h:0.72, fontSize:22, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); slide.addShape(pres.ShapeType.roundRect, { x:7.5, y:0.93, w:2.12, h:0.34, rectRadius:0.08, fill:{color:"9B59B6"} }); slide.addText("Aromatic | Cyclic | Sulfur-containing", { x:7.5, y:0.93, w:2.12, h:0.34, fontSize:7.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); function card(slide, pres, x, y, w, h, title, accentColor, rows) { slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill:{color:"132133"}, line:{color:accentColor, width:1.2} }); slide.addShape(pres.ShapeType.rect, { x, y, w, h:0.33, fill:{color:accentColor} }); slide.addText(title, { x, y, w, h:0.33, fontSize:10, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); let textArr = []; rows.forEach((r, i) => { textArr.push({ text: r.label, options:{ bold:true, color:accentColor, fontSize:9 } }); textArr.push({ text: " " + r.value, options:{ color:"E0E0E0", fontSize:9 } }); if (i < rows.length-1) textArr.push({ text:"\n" }); }); slide.addText(textArr, { x:x+0.08, y:y+0.36, w:w-0.16, h:h-0.4, fontFace:"Calibri", valign:"top", lineSpacingMultiple:1.35 }); } const cardW = 2.18, cardH = 3.35, cardY = 0.95, gap = 0.06; const startX = 0.35; card(slide, pres, startX, cardY, cardW, cardH, "PHE (F)", "9B59B6", [ {label:"MW:", value:"165.2 Da"}, {label:"Essential:", value:"Yes"}, {label:"Structure:", value:"Benzyl (phenyl) ring; most hydrophobic aromatic"}, {label:"Function:", value:"Precursor to Tyr; PKU when phenylalanine hydroxylase deficient"}, {label:"Metabolism:", value:"Phe → Tyr (PAH, BH4); blocked in PKU → phenylpyruvate"}, {label:"Clinical:", value:"PKU: intellectual disability if untreated; low-Phe diet"}, ]); card(slide, pres, startX + cardW + gap, cardY, cardW, cardH, "TRP (W)", "8E44AD", [ {label:"MW:", value:"204.2 Da"}, {label:"Essential:", value:"Yes (rarest AA)"}, {label:"Structure:", value:"Indole ring; highest MW standard AA"}, {label:"Function:", value:"Precursor: serotonin, melatonin, niacin (B3)"}, {label:"Metabolism:", value:"Tryptophan → 5-HTP → Serotonin → Melatonin; Kynurenine path → NAD⁺"}, {label:"Clinical:", value:"Hartnup disease: neutral AA transporter defect; pellagra if deficient"}, ]); card(slide, pres, startX + 2*(cardW+gap), cardY, cardW, cardH, "MET (M)", "6C3483", [ {label:"MW:", value:"149.2 Da"}, {label:"Essential:", value:"Yes"}, {label:"Structure:", value:"Thioether side chain (–S–CH₃)"}, {label:"Function:", value:"Start codon (AUG); methyl donor as SAM"}, {label:"Metabolism:", value:"Met → SAM → SAH → Homocysteine; remethylation needs B12/folate"}, {label:"Clinical:", value:"Homocystinuria / hyperhomocysteinemia → thrombosis, CVD"}, ]); card(slide, pres, startX + 3*(cardW+gap), cardY, cardW, cardH, "PRO (P)", "AF7AC1", [ {label:"MW:", value:"115.1 Da"}, {label:"Essential:", value:"Conditionally"}, {label:"Structure:", value:"Pyrrolidine ring; N in backbone — imino acid, NOT amino acid"}, {label:"Function:", value:"Helix breaker; essential in collagen (Hyp in Gly-Pro-Hyp)"}, {label:"Metabolism:", value:"Synthesized from glutamate; hydroxylated by prolyl hydroxylase (vit C)"}, {label:"Clinical:", value:"Scurvy: vit C def → no hydroxyproline → collagen instability"}, ]); // Footer slide.addShape(pres.ShapeType.rect, { x:0.35, y:4.38, w:9.3, h:0.9, fill:{color:"1B3A52"}, line:{color:"9B59B6",width:1} }); slide.addText([ {text:"Key Concepts: ", options:{bold:true, color:"9B59B6", fontSize:9.5}}, {text:"Phe/Trp absorb UV (280 nm) — basis of protein spectrophotometry. PKU (Phe), serotonin deficiency (Trp), homocystinuria (Met), and scurvy (Pro hydroxylation) are high-yield clinical correlates. Pro's ring locks the peptide backbone — helix/sheet breaker.", options:{color:"E8F4FD", fontSize:9.5}}, ], { x:0.45, y:4.38, w:9.1, h:0.9, fontFace:"Calibri", valign:"middle", lineSpacingMultiple:1.3 }); slide.addShape(pres.ShapeType.rect, { x:0, y:5.555, w:10, h:0.07, fill:{color:"9B59B6"} }); slide.addText("Biochemistry | Amino Acid Chemistry", { x:0.35, y:5.36, w:9.3, h:0.2, fontSize:7, color:"5A7A8A", fontFace:"Calibri", align:"right", italic:true }); pres.writeFile({ fileName:"/home/daytona/workspace/biochem-slides/Slide2_Nonpolar_Aromatic_Special.pptx" }) .then(()=>console.log("SLIDE2 DONE")).catch(e=>console.error(e)); JSEOF node /home/daytona/workspace/biochem-slides/slide_nonpolar_aromatic.js

Running Command

cat > /home/daytona/workspace/biochem-slides/slide_polar_uncharged.js << 'JSEOF' const pptxgen = require("pptxgenjs"); let pres = new pptxgen(); pres.layout = 'LAYOUT_16x9'; pres.title = 'Polar Uncharged Amino Acids'; let slide = pres.addSlide(); // Background slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:5.625, fill:{color:"0D1B2A"} }); slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:0.07, fill:{color:"F39C12"} }); // Title slide.addShape(pres.ShapeType.rect, { x:0.35, y:0.13, w:9.3, h:0.72, fill:{color:"1B2A3B"}, line:{color:"F39C12",width:1.5} }); slide.addText("Polar Uncharged Amino Acids", { x:0.35, y:0.13, w:9.3, h:0.72, fontSize:22, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); slide.addShape(pres.ShapeType.roundRect, { x:7.35, y:0.93, w:2.27, h:0.34, rectRadius:0.08, fill:{color:"F39C12"} }); slide.addText("H-bonding | Enzyme active sites", { x:7.35, y:0.93, w:2.27, h:0.34, fontSize:7.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); function card(slide, pres, x, y, w, h, title, accentColor, rows) { slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill:{color:"132133"}, line:{color:accentColor, width:1.2} }); slide.addShape(pres.ShapeType.rect, { x, y, w, h:0.33, fill:{color:accentColor} }); slide.addText(title, { x, y, w, h:0.33, fontSize:9.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); let textArr = []; rows.forEach((r, i) => { textArr.push({ text: r.label, options:{ bold:true, color:accentColor, fontSize:8.5 } }); textArr.push({ text: " " + r.value, options:{ color:"E0E0E0", fontSize:8.5 } }); if (i < rows.length-1) textArr.push({ text:"\n" }); }); slide.addText(textArr, { x:x+0.07, y:y+0.36, w:w-0.14, h:h-0.4, fontFace:"Calibri", valign:"top", lineSpacingMultiple:1.3 }); } // 6 cards, 3 per row const cardW = 3.06, cardH = 1.72, gap = 0.055; const startX = 0.35; // Row 1 card(slide, pres, startX, 0.95, cardW, cardH, "SER (S)", "F39C12", [ {label:"MW:", value:"105.1 Da | Conditionally essential"}, {label:"Structure:", value:"–CH₂–OH; hydroxyl group → H-bonds & phosphorylation"}, {label:"Function:", value:"Phosphoserine: major phosphorylation target (kinases); serine proteases (catalytic triad)"}, {label:"Metabolism:", value:"Gly ↔ Ser interconversion; one-carbon metabolism; sphingolipid backbone"}, ]); card(slide, pres, startX + cardW + gap, 0.95, cardW, cardH, "THR (T)", "E67E22", [ {label:"MW:", value:"119.1 Da | Essential"}, {label:"Structure:", value:"–CH(OH)–CH₃; 2nd chiral center; β-hydroxyl"}, {label:"Function:", value:"Phosphorylation target; O-glycosylation site; part of catalytic serine mimicry"}, {label:"Metabolism:", value:"Glucogenic (→ pyruvate/succinyl-CoA); cannot be synthesized in humans"}, ]); card(slide, pres, startX + 2*(cardW+gap), 0.95, cardW, cardH, "CYS (C)", "D35400", [ {label:"MW:", value:"121.2 Da | Conditionally essential"}, {label:"Structure:", value:"–CH₂–SH (thiol); pKa ~8.3; forms disulfide bonds (–S–S–)"}, {label:"Function:", value:"Disulfide bridges → protein 3D structure (insulin); metal binding (zinc fingers); active-site nucleophile"}, {label:"Metabolism:", value:"Met → Cys (transsulfuration); taurine & glutathione precursor"}, ]); // Row 2 card(slide, pres, startX, 2.74, cardW, cardH, "TYR (Y)", "F1C40F", [ {label:"MW:", value:"181.2 Da | Conditionally essential"}, {label:"Structure:", value:"Phenol ring (–OH on benzene); can ionize → phenolate (pKa ~10)"}, {label:"Function:", value:"Phosphorylation (Tyr kinases); catecholamine precursor (DOPA→dopamine→NE→Epi); thyroid hormone (T3/T4); melanin"}, {label:"Metabolism:", value:"Phe → Tyr (PAH); blocked in PKU and alkaptonuria (HGD deficiency)"}, ]); card(slide, pres, startX + cardW + gap, 2.74, cardW, cardH, "ASN (N)", "F4D03F", [ {label:"MW:", value:"132.1 Da | Non-essential"}, {label:"Structure:", value:"–CH₂–CO–NH₂; amide of Asp; H-bond donor & acceptor"}, {label:"Function:", value:"N-glycosylation site (Asn–X–Ser/Thr sequon); protein folding; asparagine synthetase"}, {label:"Metabolism:", value:"Asn ↔ Asp (asparaginase); leukemia treatment uses L-asparaginase to deplete serum Asn"}, ]); card(slide, pres, startX + 2*(cardW+gap), 2.74, cardW, cardH, "GLN (Q)", "D4AC0D", [ {label:"MW:", value:"146.2 Da | Conditionally essential"}, {label:"Structure:", value:"–CH₂–CH₂–CO–NH₂; amide of Glu; most abundant AA in blood"}, {label:"Function:", value:"Nitrogen carrier in blood; fuel for enterocytes & lymphocytes; purine/pyrimidine nitrogen donor"}, {label:"Metabolism:", value:"Glu + NH₃ → Gln (glutamine synthetase); Gln → Glu (glutaminase); brain ammonia detox"}, ]); // Footer slide.addShape(pres.ShapeType.rect, { x:0.35, y:4.53, w:9.3, h:0.77, fill:{color:"1B3A52"}, line:{color:"F39C12",width:1} }); slide.addText([ {text:"Key Concepts: ", options:{bold:true, color:"F39C12", fontSize:9.5}}, {text:"Ser/Thr/Tyr are phosphorylation targets (signal transduction). Cys disulfide bonds stabilize proteins. Tyr is the catecholamine/thyroid hormone precursor. Gln is the main nitrogen carrier. Asn is the N-glycosylation anchor.", options:{color:"E8F4FD", fontSize:9.5}}, ], { x:0.45, y:4.53, w:9.1, h:0.77, fontFace:"Calibri", valign:"middle", lineSpacingMultiple:1.3 }); slide.addShape(pres.ShapeType.rect, { x:0, y:5.555, w:10, h:0.07, fill:{color:"F39C12"} }); slide.addText("Biochemistry | Amino Acid Chemistry", { x:0.35, y:5.36, w:9.3, h:0.2, fontSize:7, color:"5A7A8A", fontFace:"Calibri", align:"right", italic:true }); pres.writeFile({ fileName:"/home/daytona/workspace/biochem-slides/Slide3_Polar_Uncharged.pptx" }) .then(()=>console.log("SLIDE3 DONE")).catch(e=>console.error(e)); JSEOF node /home/daytona/workspace/biochem-slides/slide_polar_uncharged.js

Running Command

cat > /home/daytona/workspace/biochem-slides/slide_basic.js << 'JSEOF' const pptxgen = require("pptxgenjs"); let pres = new pptxgen(); pres.layout = 'LAYOUT_16x9'; pres.title = 'Positively Charged (Basic) Amino Acids'; let slide = pres.addSlide(); // Background slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:5.625, fill:{color:"0D1B2A"} }); slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:0.07, fill:{color:"2980B9"} }); // Title slide.addShape(pres.ShapeType.rect, { x:0.35, y:0.13, w:9.3, h:0.72, fill:{color:"1B2A3B"}, line:{color:"2980B9",width:1.5} }); slide.addText("Positively Charged (Basic) Amino Acids", { x:0.35, y:0.13, w:9.3, h:0.72, fontSize:22, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); slide.addShape(pres.ShapeType.roundRect, { x:7.5, y:0.93, w:2.12, h:0.34, rectRadius:0.08, fill:{color:"2980B9"} }); slide.addText("pKa > 7 | Positive charge at pH 7", { x:7.5, y:0.93, w:2.12, h:0.34, fontSize:7.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); function card(slide, pres, x, y, w, h, title, accentColor, rows) { slide.addShape(pres.ShapeType.rect, { x, y, w, h, fill:{color:"132133"}, line:{color:accentColor, width:1.5} }); slide.addShape(pres.ShapeType.rect, { x, y, w, h:0.35, fill:{color:accentColor} }); slide.addText(title, { x, y, w, h:0.35, fontSize:11.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); let textArr = []; rows.forEach((r, i) => { textArr.push({ text: r.label, options:{ bold:true, color:accentColor, fontSize:9.5 } }); textArr.push({ text: " " + r.value, options:{ color:"E0E0E0", fontSize:9.5 } }); if (i < rows.length-1) textArr.push({ text:"\n" }); }); slide.addText(textArr, { x:x+0.1, y:y+0.38, w:w-0.2, h:h-0.42, fontFace:"Calibri", valign:"top", lineSpacingMultiple:1.4 }); } const cardW = 2.9, cardH = 3.32, cardY = 0.95, gap = 0.19; const startX = 0.42; card(slide, pres, startX, cardY, cardW, cardH, "LYS (K)", "2980B9", [ {label:"MW:", value:"146.2 Da | Essential"}, {label:"Charge pH7:", value:"Strong positive (pKa ~10.5, ε-amino)"}, {label:"Structure:", value:"–(CH₂)₄–NH₃⁺; long flexible side chain"}, {label:"Function:", value:"Histone acetylation/ubiquitination sites; collagen crosslinks; active-site nucleophile; binds DNA phosphates"}, {label:"Metabolism:", value:"Purely ketogenic; carnitine biosynthesis; acetyl-Lys in epigenetics"}, {label:"Clinical:", value:"Lysinuric protein intolerance; collagen disorders (lysyl oxidase deficiency)"}, ]); card(slide, pres, startX + cardW + gap, cardY, cardW, cardH, "ARG (R)", "1A5276", [ {label:"MW:", value:"174.2 Da | Conditionally essential"}, {label:"Charge pH7:", value:"Strongest positive (pKa ~12.5, guanidinium)"}, {label:"Structure:", value:"Guanidinium group (–NHC(=NH)NH₂); resonance-stabilized"}, {label:"Function:", value:"Urea cycle (argininosuccinate → Arg → urea + ornithine); NO synthesis (NOS: Arg → NO + citrulline); protein binding to nucleic acids"}, {label:"Metabolism:", value:"Urea cycle intermediate; conditionally essential in growth/stress"}, {label:"Clinical:", value:"Arginase deficiency → hyperammonemia; NO pathway (sepsis, hypertension)"}, ]); card(slide, pres, startX + 2*(cardW+gap), cardY, cardW, cardH, "HIS (H)", "5DADE2", [ {label:"MW:", value:"155.2 Da | Essential (adults borderline)"}, {label:"Charge pH7:", value:"Partial positive (pKa ~6.0 — unique buffer at physiological pH)"}, {label:"Structure:", value:"Imidazole ring; can be protonated or neutral at pH 7"}, {label:"Function:", value:"Enzyme active-site proton shuttle (serine proteases, carbonic anhydrase); hemoglobin Bohr effect (CO₂/O₂ exchange); histamine precursor"}, {label:"Metabolism:", value:"His → histamine (histidine decarboxylase); urocanic acid pathway"}, {label:"Clinical:", value:"Histidinemia; antihistamines block H1/H2 receptors; carbonic anhydrase inhibitors (glaucoma, altitude sickness)"}, ]); // pKa comparison strip slide.addShape(pres.ShapeType.rect, { x:0.35, y:4.38, w:9.3, h:0.36, fill:{color:"172A3A"}, line:{color:"2980B9",width:0.8} }); // pKa bars const bars = [{label:"Lys pKa ~10.5", w:3.0, color:"2980B9"}, {label:"Arg pKa ~12.5", w:4.0, color:"1A5276"}, {label:"His pKa ~6.0", w:1.5, color:"5DADE2"}]; let bx = 0.55; bars.forEach(b => { slide.addShape(pres.ShapeType.rect, { x:bx, y:4.47, w:b.w, h:0.16, fill:{color:b.color} }); slide.addText(b.label, { x:bx, y:4.47, w:b.w, h:0.16, fontSize:7.5, bold:true, color:"FFFFFF", fontFace:"Calibri", align:"center", valign:"middle", margin:0 }); bx += b.w + 0.07; }); // Footer slide.addShape(pres.ShapeType.rect, { x:0.35, y:4.8, w:9.3, h:0.72, fill:{color:"1B3A52"}, line:{color:"2980B9",width:1} }); slide.addText([ {text:"Key Concepts: ", options:{bold:true, color:"5DADE2", fontSize:9.5}}, {text:"His is the ONLY amino acid that buffers at physiological pH (pKa ~6.0) — critical in hemoglobin Bohr effect. Arg is the sole NO precursor and a urea cycle intermediate. Lys epigenetic modifications (acetylation, methylation) control gene expression.", options:{color:"E8F4FD", fontSize:9.5}}, ], { x:0.45, y:4.8, w:9.1, h:0.72, fontFace:"Calibri", valign:"middle", lineSpacingMultiple:1.3 }); slide.addShape(pres.ShapeType.rect, { x:0, y:5.555, w:10, h:0.07, fill:{color:"2980B9"} }); slide.addText("Biochemistry | Amino Acid Chemistry", { x:0.35, y:5.36, w:9.3, h:0.2, fontSize:7, color:"5A7A8A", fontFace:"Calibri", align:"right", italic:true }); pres.writeFile({ fileName:"/home/daytona/workspace/biochem-slides/Slide4_Basic_Charged.pptx" }) .then(()=>console.log("SLIDE4 DONE")).catch(e=>console.error(e)); JSEOF node /home/daytona/workspace/biochem-slides/slide_basic.js

Running Command

ls -lh /home/daytona/workspace/biochem-slides/*.pptx

All 4 slides are ready. Here's the complete set alongside the acidic AA slide you already have:

Download Links

SlideAmino Acids CoveredAccent Color

Slide1 Nonpolar Aliphatic

Presentation · PPTX

Gly, Ala, Val, Leu, IleGreen

Slide2 Nonpolar Aromatic Special

Presentation · PPTX

Phe, Trp, Met, ProPurple

Slide3 Polar Uncharged

Presentation · PPTX

Ser, Thr, Cys, Tyr, Asn, GlnAmber/Orange

Slide4 Basic Charged

Presentation · PPTX

Lys, Arg, HisBlue

Acidic Amino Acids

Presentation · PPTX

Asp, GluRed

Each slide includes for every amino acid:
  • MW, essential status, charge at pH 7
  • Structural feature (side chain chemistry)
  • Key metabolic pathways
  • Clinical correlates (PKU, MSUD, scurvy, sickle cell, homocystinuria, etc.)
Design is consistent across all 5 slides - dark navy background, color-coded per group, with a "Key Concepts" footer banner summarizing the high-yield teaching points for each group.

Combine all 5 slides into one master presentation

Running Command

ls -lh /home/daytona/workspace/biochem-slides/*.pptx

Reading File
Running Command

python3 << 'PYEOF' from pptx import Presentation from pptx.util import Inches import copy, lxml.etree as etree # Order: title slide first (acidic), then groups 1-4 files = [ "/home/daytona/workspace/biochem-slides/Acidic_Amino_Acids.pptx", "/home/daytona/workspace/biochem-slides/Slide1_Nonpolar_Aliphatic.pptx", "/home/daytona/workspace/biochem-slides/Slide2_Nonpolar_Aromatic_Special.pptx", "/home/daytona/workspace/biochem-slides/Slide3_Polar_Uncharged.pptx", "/home/daytona/workspace/biochem-slides/Slide4_Basic_Charged.pptx", ] def merge_presentations(file_list, output_path): # Use first file as base base = Presentation(file_list[0]) for src_path in file_list[1:]: src = Presentation(src_path) # For each slide in source, clone its XML and add to base for src_slide in src.slides: # Add blank slide to base using first layout slide_layout = base.slide_layouts[6] # blank layout new_slide = base.slides.add_slide(slide_layout) # Copy all shapes/elements from source slide spTree src_sp_tree = src_slide.shapes._spTree dest_sp_tree = new_slide.shapes._spTree # Remove default placeholders from new blank slide for child in list(dest_sp_tree): dest_sp_tree.remove(child) # Deep copy all children from source for child in src_sp_tree: dest_sp_tree.append(copy.deepcopy(child)) # Copy slide background if present src_bg = src_slide.background dest_bg = new_slide.background if src_slide._element.find('.//{http://schemas.openxmlformats.org/drawingml/2006/main}solidFill') is not None: # copy the cSld element which contains background src_cSld = src_slide._element.find('{http://schemas.openxmlformats.org/presentationml/2006/main}cSld') dest_cSld = new_slide._element.find('{http://schemas.openxmlformats.org/presentationml/2006/main}cSld') if src_cSld is not None and dest_cSld is not None: # copy bg element src_bg_elem = src_cSld.find('{http://schemas.openxmlformats.org/presentationml/2006/main}bg') if src_bg_elem is not None: dest_bg_elem = dest_cSld.find('{http://schemas.openxmlformats.org/presentationml/2006/main}bg') if dest_bg_elem is not None: dest_cSld.remove(dest_bg_elem) dest_cSld.insert(0, copy.deepcopy(src_bg_elem)) base.save(output_path) print(f"Saved: {output_path}") print(f"Total slides: {len(base.slides)}") merge_presentations(files, "/home/daytona/workspace/biochem-slides/Master_Amino_Acids.pptx") PYEOF

Running Command

# Check what's available for PPTX manipulation node -e "const p = require('pptxgenjs'); console.log('pptxgenjs ok');" python3 -c "import zipfile, shutil, os; print('stdlib ok')" ls /home/daytona/skills/pptx/scripts/office/

Running Command

# Unpack all 5 presentations cd /home/daytona/workspace/biochem-slides python3 /home/daytona/skills/pptx/scripts/office/unpack.py Acidic_Amino_Acids.pptx unpacked_acidic/ python3 /home/daytona/skills/pptx/scripts/office/unpack.py Slide1_Nonpolar_Aliphatic.pptx unpacked_s1/ python3 /home/daytona/skills/pptx/scripts/office/unpack.py Slide2_Nonpolar_Aromatic_Special.pptx unpacked_s2/ python3 /home/daytona/skills/pptx/scripts/office/unpack.py Slide3_Polar_Uncharged.pptx unpacked_s3/ python3 /home/daytona/skills/pptx/scripts/office/unpack.py Slide4_Basic_Charged.pptx unpacked_s4/ echo "All unpacked" ls unpacked_acidic/ppt/slides/

Running Command

python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/biochem-slides/Acidic_Amino_Acids.pptx /home/daytona/workspace/biochem-slides/unpacked_acidic/ && echo "done"

Running Command

python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/biochem-slides/Slide1_Nonpolar_Aliphatic.pptx /home/daytona/workspace/biochem-slides/unpacked_s1/ && echo "s1 done"

Running Command

python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/biochem-slides/Slide2_Nonpolar_Aromatic_Special.pptx /home/daytona/workspace/biochem-slides/unpacked_s2/ && echo "s2 done"

Running Command

python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/biochem-slides/Slide3_Polar_Uncharged.pptx /home/daytona/workspace/biochem-slides/unpacked_s3/ && echo "s3 done"

Running Command

python3 /home/daytona/skills/pptx/scripts/office/unpack.py /home/daytona/workspace/biochem-slides/Slide4_Basic_Charged.pptx /home/daytona/workspace/biochem-slides/unpacked_s4/ && echo "s4 done"

Running Command

ls /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/slides/ echo "---" ls /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/slides/_rels/ echo "---" # Check the presentation.xml sldIdLst grep -A 20 'sldIdLst' /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/presentation.xml | head -30

Running Command

cat /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/slides/_rels/slide1.xml.rels

Running Command

python3 << 'PYEOF' import os, shutil, re, xml.etree.ElementTree as ET BASE = "/home/daytona/workspace/biochem-slides" base_dir = f"{BASE}/unpacked_acidic" # Sources: (unpacked_dir, slide_number_in_source, new_slide_number_in_base) sources = [ (f"{BASE}/unpacked_s1", "slide1", "slide2"), (f"{BASE}/unpacked_s2", "slide1", "slide3"), (f"{BASE}/unpacked_s3", "slide1", "slide4"), (f"{BASE}/unpacked_s4", "slide1", "slide5"), ] slides_dir = f"{base_dir}/ppt/slides" rels_dir = f"{base_dir}/ppt/slides/_rels" for (src_dir, src_slide, dest_slide) in sources: # Copy slide XML shutil.copy( f"{src_dir}/ppt/slides/{src_slide}.xml", f"{slides_dir}/{dest_slide}.xml" ) # Copy notes slide if present src_notes = f"{src_dir}/ppt/notesSlides/notesSlide1.xml" dest_notes_dir = f"{base_dir}/ppt/notesSlides" note_num = dest_slide.replace("slide","") if os.path.exists(src_notes): os.makedirs(dest_notes_dir, exist_ok=True) dest_note = f"{dest_notes_dir}/notesSlide{note_num}.xml" shutil.copy(src_notes, dest_note) # Build slide rels — each slide only references slideLayout1 (and optionally notes) notes_line = "" if os.path.exists(src_notes): notes_line = f' <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" Target="../notesSlides/notesSlide{note_num}.xml"/>\n' rels_content = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n' ' <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>\n' + notes_line + '</Relationships>\n' ) with open(f"{rels_dir}/{dest_slide}.xml.rels", "w") as f: f.write(rels_content) print(f" Copied {src_slide} → {dest_slide}") # Now update presentation.xml to include all 5 slides pres_path = f"{base_dir}/ppt/presentation.xml" pres_rels_path = f"{base_dir}/ppt/_rels/presentation.xml.rels" with open(pres_path, "r") as f: pres_xml = f.read() # Find current sldIdLst and replace with 5 entries new_sld_id_lst = """<p:sldIdLst> <p:sldId id="256" r:id="rId2"/> <p:sldId id="257" r:id="rId10"/> <p:sldId id="258" r:id="rId11"/> <p:sldId id="259" r:id="rId12"/> <p:sldId id="260" r:id="rId13"/> </p:sldIdLst>""" pres_xml = re.sub( r'<p:sldIdLst>.*?</p:sldIdLst>', new_sld_id_lst, pres_xml, flags=re.DOTALL ) with open(pres_path, "w") as f: f.write(pres_xml) print("Updated presentation.xml") # Update presentation.xml.rels to add rId10–rId13 with open(pres_rels_path, "r") as f: rels_xml = f.read() new_rels = ( ' <Relationship Id="rId10" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide2.xml"/>\n' ' <Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide3.xml"/>\n' ' <Relationship Id="rId12" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide4.xml"/>\n' ' <Relationship Id="rId13" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide5.xml"/>\n' '</Relationships>' ) rels_xml = rels_xml.replace('</Relationships>', new_rels) with open(pres_rels_path, "w") as f: f.write(rels_xml) print("Updated presentation.xml.rels") print("Done!") # Verify print("\nSlides in base dir:") for f in sorted(os.listdir(slides_dir)): if not f.startswith('_'): print(f" {f}") PYEOF

Running Command

ls -la /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/slides/ chmod -R 777 /home/daytona/workspace/biochem-slides/unpacked_acidic/ 2>/dev/null || true ls -la /home/daytona/workspace/biochem-slides/unpacked_acidic/ppt/slides/

Running Command

python3 << 'PYEOF' import os, re BASE = "/home/daytona/workspace/biochem-slides" base_dir = f"{BASE}/unpacked_acidic" sources = [ (f"{BASE}/unpacked_s1", "slide1", "slide2"), (f"{BASE}/unpacked_s2", "slide1", "slide3"), (f"{BASE}/unpacked_s3", "slide1", "slide4"), (f"{BASE}/unpacked_s4", "slide1", "slide5"), ] slides_dir = f"{base_dir}/ppt/slides" rels_dir = f"{base_dir}/ppt/slides/_rels" for (src_dir, src_slide, dest_slide) in sources: # Copy slide XML using read/write with open(f"{src_dir}/ppt/slides/{src_slide}.xml", "r") as f: content = f.read() with open(f"{slides_dir}/{dest_slide}.xml", "w") as f: f.write(content) # Notes slide src_notes = f"{src_dir}/ppt/notesSlides/notesSlide1.xml" note_num = dest_slide.replace("slide","") dest_notes_dir = f"{base_dir}/ppt/notesSlides" notes_line = "" if os.path.exists(src_notes): os.makedirs(dest_notes_dir, exist_ok=True) with open(src_notes, "r") as f: nc = f.read() with open(f"{dest_notes_dir}/notesSlide{note_num}.xml", "w") as f: f.write(nc) notes_line = f' <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" Target="../notesSlides/notesSlide{note_num}.xml"/>\n' # Slide rels rels_content = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n' ' <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>\n' + notes_line + '</Relationships>\n' ) with open(f"{rels_dir}/{dest_slide}.xml.rels", "w") as f: f.write(rels_content) print(f" Copied {src_slide} → {dest_slide}") # Update presentation.xml pres_path = f"{base_dir}/ppt/presentation.xml" pres_rels_path = f"{base_dir}/ppt/_rels/presentation.xml.rels" with open(pres_path, "r") as f: pres_xml = f.read() new_sld_id_lst = """<p:sldIdLst> <p:sldId id="256" r:id="rId2"/> <p:sldId id="257" r:id="rId10"/> <p:sldId id="258" r:id="rId11"/> <p:sldId id="259" r:id="rId12"/> <p:sldId id="260" r:id="rId13"/> </p:sldIdLst>""" pres_xml = re.sub(r'<p:sldIdLst>.*?</p:sldIdLst>', new_sld_id_lst, pres_xml, flags=re.DOTALL) with open(pres_path, "w") as f: f.write(pres_xml) print("Updated presentation.xml") # Update presentation.xml.rels with open(pres_rels_path, "r") as f: rels_xml = f.read() # Check if already patched if 'rId10' not in rels_xml: new_rels = ( ' <Relationship Id="rId10" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide2.xml"/>\n' ' <Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide3.xml"/>\n' ' <Relationship Id="rId12" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide4.xml"/>\n' ' <Relationship Id="rId13" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide5.xml"/>\n' '</Relationships>' ) rels_xml = rels_xml.replace('</Relationships>', new_rels) with open(pres_rels_path, "w") as f: f.write(rels_xml) print("Updated presentation.xml.rels") else: print("presentation.xml.rels already patched") print("\nSlides in base:") for fn in sorted(os.listdir(slides_dir)): if not fn.startswith('_'): print(f" {fn}") print("\nRels in _rels:") for fn in sorted(os.listdir(rels_dir)): print(f" {fn}") PYEOF

Running Command

python3 /home/daytona/skills/pptx/scripts/office/pack.py \ /home/daytona/workspace/biochem-slides/unpacked_acidic/ \ /home/daytona/workspace/biochem-slides/Master_Amino_Acids.pptx \ --original /home/daytona/workspace/biochem-slides/Acidic_Amino_Acids.pptx \ && echo "PACKED OK"

Running Command

# Pack directly with zipfile — PPTX is just a ZIP python3 << 'PYEOF' import zipfile, os unpacked_dir = "/home/daytona/workspace/biochem-slides/unpacked_acidic" output_path = "/home/daytona/workspace/biochem-slides/Master_Amino_Acids.pptx" # Build the zip, preserving the same structure as original with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zf: for root, dirs, files in os.walk(unpacked_dir): # Sort for determinism for fn in sorted(files): full_path = os.path.join(root, fn) # Arcname = path relative to unpacked_dir arcname = os.path.relpath(full_path, unpacked_dir) zf.write(full_path, arcname) size = os.path.getsize(output_path) print(f"Packed: {output_path} ({size//1024} KB)") # Quick verify: list slides in the zip with zipfile.ZipFile(output_path, 'r') as zf: slides = sorted([n for n in zf.namelist() if n.startswith('ppt/slides/slide')]) print(f"Slides in archive: {slides}") PYEOF

Running Command

# Try writing to /tmp first, then move python3 << 'PYEOF' import zipfile, os, shutil unpacked_dir = "/home/daytona/workspace/biochem-slides/unpacked_acidic" tmp_path = "/tmp/Master_Amino_Acids.pptx" output_path = "/home/daytona/workspace/biochem-slides/Master_Amino_Acids.pptx" with zipfile.ZipFile(tmp_path, 'w', zipfile.ZIP_DEFLATED) as zf: for root, dirs, files in os.walk(unpacked_dir): for fn in sorted(files): full_path = os.path.join(root, fn) arcname = os.path.relpath(full_path, unpacked_dir) zf.write(full_path, arcname) # Move to workspace with open(tmp_path, 'rb') as src, open(output_path, 'wb') as dst: dst.write(src.read()) os.remove(tmp_path) size = os.path.getsize(output_path) print(f"Packed: {output_path} ({size//1024} KB)") with zipfile.ZipFile(output_path, 'r') as zf: slides = sorted([n for n in zf.namelist() if 'slides/slide' in n and '.xml' in n and '_rels' not in n]) print(f"Slides in archive: {slides}") PYEOF

All 5 slides confirmed inside the archive. The file is 32 KB which is correct for a text/shape-only presentation (no embedded images).

Master Amino Acids

Presentation · PPTX


What's inside the master (slide order):
SlideGroupAmino Acids
1Acidic (Negative)Asp, Glu
2Nonpolar AliphaticGly, Ala, Val, Leu, Ile
3Nonpolar Aromatic & SpecialPhe, Trp, Met, Pro
4Polar UnchargedSer, Thr, Cys, Tyr, Asn, Gln
5Basic (Positive)Lys, Arg, His
All 20 standard amino acids covered across 5 slides in one file, consistent dark-navy design throughout.

Create a quiz/study guide PDF covering amino acid metabolism & clinical correlates

Reading File
Running Command

python3 << 'PYEOF' from reportlab.lib.pagesizes import letter from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import inch from reportlab.lib import colors from reportlab.platypus import ( SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, PageBreak, KeepTogether ) from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY import os out_path = "/home/daytona/workspace/biochem-slides/AA_Metabolism_Quiz_StudyGuide.pdf" # ── Color palette ────────────────────────────────────────────── NAVY = colors.HexColor("#0D1B2A") TEAL = colors.HexColor("#1ABC9C") RED = colors.HexColor("#E63946") BLUE = colors.HexColor("#2980B9") PURPLE = colors.HexColor("#9B59B6") AMBER = colors.HexColor("#F39C12") GREEN = colors.HexColor("#27AE60") LIGHTGRAY = colors.HexColor("#F4F6F9") MIDGRAY = colors.HexColor("#D5D8DC") WHITE = colors.white DARKTEXT = colors.HexColor("#1C2833") MUTEDTEXT = colors.HexColor("#5D6D7E") doc = SimpleDocTemplate( out_path, pagesize=letter, leftMargin=0.75*inch, rightMargin=0.75*inch, topMargin=0.7*inch, bottomMargin=0.7*inch, ) W = letter[0] - 1.5*inch # usable width styles = getSampleStyleSheet() # Custom styles def S(name, **kw): return ParagraphStyle(name, **kw) sTitle = S("sTitle", fontSize=26, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=4, leading=32) sSubtitle = S("sSubtitle", fontSize=12, textColor=colors.HexColor("#A8C8E8"), fontName="Helvetica", alignment=TA_CENTER, spaceAfter=2, leading=16) sSectionHead = S("sSectionHead", fontSize=14, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_LEFT, spaceBefore=6, spaceAfter=4, leading=18, backColor=NAVY, leftIndent=-6, rightIndent=-6) sSubHead = S("sSubHead", fontSize=11, textColor=NAVY, fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3, leading=14) sBody = S("sBody", fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", spaceBefore=2, spaceAfter=2, leading=14, alignment=TA_JUSTIFY) sBodyBold = S("sBodyBold", fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica-Bold", spaceBefore=2, spaceAfter=2, leading=14) sBullet = S("sBullet", fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", leftIndent=14, spaceBefore=1, spaceAfter=1, leading=13, bulletIndent=4, bulletFontName="Helvetica", bulletFontSize=9.5) sQ = S("sQ", fontSize=10, textColor=NAVY, fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=2, leading=14) sA = S("sA", fontSize=9.5, textColor=colors.HexColor("#1A6B40"), fontName="Helvetica", spaceBefore=1, spaceAfter=3, leading=13, leftIndent=14) sNote = S("sNote", fontSize=8.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique", spaceBefore=1, spaceAfter=2, leading=12, leftIndent=10) sLabel = S("sLabel", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, leading=10) sTocHead = S("sTocHead", fontSize=11, textColor=NAVY, fontName="Helvetica-Bold", spaceBefore=4, spaceAfter=2) def b(txt): return f"<b>{txt}</b>" def i(txt): return f"<i>{txt}</i>" def c(txt, col): return f'<font color="{col}">{txt}</font>' def bullet(txt, style=sBullet): return Paragraph(f"• {txt}", style) def section_header(title, color=NAVY): data = [[Paragraph(title, S("sh2", fontSize=13, textColor=WHITE, fontName="Helvetica-Bold", leading=16))]] t = Table(data, colWidths=[W]) 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), ("ROUNDEDCORNERS", [4]), ])) return t def sub_header(title): return Paragraph(title, sSubHead) def qa(q_text, a_text, q_num=""): label = f"Q{q_num}. " if q_num else "" return [ Paragraph(f"{label}{q_text}", sQ), Paragraph(f"▶ {a_text}", sA), ] story = [] # ══════════════════════════════════════════════════════════════ # COVER BLOCK # ══════════════════════════════════════════════════════════════ cover_data = [[ Paragraph("Amino Acid Metabolism", sTitle), Paragraph("&amp; Clinical Correlates", sTitle), Spacer(1, 6), Paragraph("Quiz &amp; Study Guide", sSubtitle), Paragraph("Biochemistry — Medical Year 1 / Year 2", sSubtitle), Spacer(1, 4), HRFlowable(width=W*0.5, thickness=1.5, color=TEAL, spaceAfter=4), Paragraph("20 Standard Amino Acids · Metabolic Pathways · Enzyme Deficiencies · High-Yield Clinicals", S("cov2", fontSize=9, textColor=colors.HexColor("#7FB3D3"), fontName="Helvetica", alignment=TA_CENTER, leading=13)), ]] cover_tbl = Table(cover_data, colWidths=[W]) cover_tbl.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,-1), NAVY), ("TOPPADDING", (0,0), (-1,-1), 22), ("BOTTOMPADDING",(0,0), (-1,-1), 22), ("LEFTPADDING", (0,0), (-1,-1), 18), ("RIGHTPADDING", (0,0), (-1,-1), 18), ("ROUNDEDCORNERS",[6]), ])) story.append(cover_tbl) story.append(Spacer(1, 14)) # ── How to use ───────────────────────────────────────────────── story.append(Paragraph( "How to use: Read each <b>Study Note</b> section first, then attempt the <b>Quiz Questions</b> below it. " "Answers are shown immediately beneath each question — cover them with a card as you work through. " "Clinical correlates are highlighted in green boxes.", sBody)) story.append(Spacer(1, 10)) # ══════════════════════════════════════════════════════════════ # SECTION 1 — AMINO ACID CLASSIFICATION # ══════════════════════════════════════════════════════════════ story.append(section_header("SECTION 1 — Classification of the 20 Standard Amino Acids", NAVY)) story.append(Spacer(1, 6)) class_data = [ [Paragraph(b("Group"), sLabel), Paragraph(b("Members"), sLabel), Paragraph(b("Key Property"), sLabel)], ["Nonpolar Aliphatic", "Gly, Ala, Val, Leu, Ile, Pro, Met", "Hydrophobic; form protein core"], ["Nonpolar Aromatic", "Phe, Trp, Tyr", "UV absorption (280 nm); Phe/Trp most hydrophobic"], ["Polar Uncharged", "Ser, Thr, Cys, Asn, Gln", "H-bond donors/acceptors; phosphorylation targets"], ["Acidic (–)", "Asp, Glu", "pKa < 4.1; negative at pH 7; strong cation binders"], ["Basic (+)", "Lys, Arg, His", "Positive at pH 7; DNA/protein binding; His pKa ~6.0"], ] colwidths = [W*0.22, W*0.48, W*0.30] ct = Table(class_data, colWidths=colwidths) ct.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,0), NAVY), ("TEXTCOLOR", (0,0), (-1,0), WHITE), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,0), 9), ("BACKGROUND", (0,1), (-1,1), colors.HexColor("#EBF5FB")), ("BACKGROUND", (0,2), (-1,2), colors.HexColor("#F4ECF7")), ("BACKGROUND", (0,3), (-1,3), colors.HexColor("#FEF9E7")), ("BACKGROUND", (0,4), (-1,4), colors.HexColor("#FDECEA")), ("BACKGROUND", (0,5), (-1,5), colors.HexColor("#EBF5FB")), ("FONTNAME", (0,1), (-1,-1), "Helvetica"), ("FONTSIZE", (0,1), (-1,-1), 9), ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]), ("GRID", (0,0), (-1,-1), 0.4, MIDGRAY), ("ALIGN", (0,0), (-1,-1), "LEFT"), ("LEFTPADDING", (0,0), (-1,-1), 6), ("RIGHTPADDING", (0,0), (-1,-1), 6), ("TOPPADDING", (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4), ("VALIGN", (0,0), (-1,-1), "MIDDLE"), ])) story.append(ct) story.append(Spacer(1, 8)) # Essential AAs mnemonic story.append(sub_header("Essential Amino Acids (cannot be synthesized — must be dietary)")) story.append(Paragraph( b("PVT TIM HaLL") — Phe, Val, Thr, Trp, Ile, Met, His, Lys, Leu", sBody)) story.append(Paragraph( "Conditionally essential (increased demand): Arg, Gln, Gly, Pro, Cys, Tyr", sNote)) story.append(Spacer(1, 6)) # Quiz Q1-4 story.append(sub_header("Quiz — Classification")) for items in [ ("1", "Which amino acid has NO chiral center and why?", "Glycine (Gly/G). Its side chain is a single hydrogen atom, making both alpha-carbon substituents identical — therefore no stereocenter."), ("2", "Which amino acid is technically an imino acid, not an amino acid?", "Proline (Pro/P). Its side chain forms a pyrrolidine ring that bonds back to the backbone nitrogen, creating a secondary amine (imino group) rather than a primary amine."), ("3", "Name the only amino acid whose side chain can buffer at physiological pH and explain why.", "Histidine (His/H). Its imidazole side chain has a pKa of ~6.0 — close to physiological pH 7.4 — allowing it to accept or donate protons under normal cellular conditions. This is exploited in hemoglobin (Bohr effect) and enzyme active sites."), ("4", "Which amino acid absorbs UV light most strongly and at what wavelength?", "Tryptophan (Trp/W) absorbs most strongly at 280 nm due to its indole ring system. Tyrosine also absorbs at 280 nm. This is the basis for protein quantification by UV spectrophotometry."), ]: story.extend(qa(items[1], items[2], items[0])) story.append(PageBreak()) # ══════════════════════════════════════════════════════════════ # SECTION 2 — METABOLIC PATHWAYS # ══════════════════════════════════════════════════════════════ story.append(section_header("SECTION 2 — Amino Acid Metabolism: Key Pathways", colors.HexColor("#1A5276"))) story.append(Spacer(1, 6)) story.append(sub_header("2A. Transamination")) story.append(Paragraph( "Most amino acids donate their amino group via <b>transamination</b> to alpha-ketoglutarate (α-KG), " "producing <b>glutamate</b> and the corresponding alpha-keto acid. Enzyme: <b>aminotransferase (transaminase)</b>. " "Cofactor: <b>PLP (pyridoxal phosphate, vitamin B6)</b>.", sBody)) story.append(Paragraph("Key transamination reactions (high-yield):", sBodyBold)) trans_data = [ [Paragraph(b("Amino Acid"), sLabel), Paragraph(b("Alpha-Keto Product"), sLabel), Paragraph(b("Enzyme"), sLabel), Paragraph(b("Clinical"), sLabel)], ["Aspartate (Asp)", "Oxaloacetate (OAA)", "AST (GOT)", "Elevated in hepatocellular damage, MI"], ["Alanine (Ala)", "Pyruvate", "ALT (GPT)", "Most specific for hepatocellular injury"], ["Glutamate (Glu)", "α-Ketoglutarate", "GDH (also deamination)", "Central hub for all transaminations"], ["Leucine (Leu)", "α-Ketoisocaproate", "BCAT", "MSUD if BCKAD deficient"], ["Phenylalanine", "Phenylpyruvate", "PAH (then transaminase)", "PKU: phenylpyruvate in urine"], ] tt = Table(trans_data, colWidths=[W*0.20, W*0.22, W*0.22, W*0.36]) tt.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1A5276")), ("TEXTCOLOR", (0,0), (-1,0), WHITE), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,-1), 8.5), ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]), ("GRID", (0,0), (-1,-1), 0.4, MIDGRAY), ("LEFTPADDING", (0,0), (-1,-1), 5), ("TOPPADDING", (0,0), (-1,-1), 3), ("BOTTOMPADDING", (0,0), (-1,-1), 3), ("FONTNAME", (0,1), (-1,-1), "Helvetica"), ("VALIGN", (0,0), (-1,-1), "MIDDLE"), ])) story.append(tt) story.append(Spacer(1, 6)) story.append(sub_header("2B. The Urea Cycle — Nitrogen Disposal")) story.append(Paragraph( "Occurs in <b>hepatocytes</b> (cytosol + mitochondria). Disposes of excess ammonia as urea (excreted in urine).", sBody)) urea_steps = [ ("Step 1", "Mitochondria", "NH₃ + CO₂ + 2ATP → Carbamoyl phosphate", "CPS-I", "Activated by N-acetylglutamate (NAG)"), ("Step 2", "Mitochondria", "Carbamoyl-P + Ornithine → Citrulline", "OTC", "X-linked; most common urea cycle defect"), ("Step 3", "Cytosol", "Citrulline + Aspartate → Argininosuccinate", "ASS", "Citrullinemia type I"), ("Step 4", "Cytosol", "Argininosuccinate → Arginine + Fumarate", "ASL", "Argininosuccinic aciduria"), ("Step 5", "Cytosol", "Arginine → Ornithine + Urea", "Arginase", "Hyperargininemia; Arg → NO (NOS pathway)"), ] ud = [[Paragraph(b("Step"), sLabel), Paragraph(b("Location"), sLabel), Paragraph(b("Reaction"), sLabel), Paragraph(b("Enzyme"), sLabel), Paragraph(b("Notes"), sLabel)]] ud += urea_steps ut = Table(ud, colWidths=[W*0.08, W*0.14, W*0.32, W*0.14, W*0.32]) ut.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#117A65")), ("TEXTCOLOR", (0,0), (-1,0), WHITE), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,-1), 8), ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]), ("GRID", (0,0), (-1,-1), 0.4, MIDGRAY), ("LEFTPADDING", (0,0), (-1,-1), 4), ("TOPPADDING", (0,0), (-1,-1), 3), ("BOTTOMPADDING", (0,0), (-1,-1), 3), ("FONTNAME", (0,1), (-1,-1), "Helvetica"), ("VALIGN", (0,0), (-1,-1), "TOP"), ])) story.append(ut) story.append(Spacer(1, 5)) story.append(Paragraph("Memory tip: <b>O</b>rdinarily <b>C</b>areless <b>C</b>liver <b>A</b>rgonauts <b>A</b>re <b>A</b>wesome (OTC, CPS-I, citrulline, ASS, ASL, arginase)", sNote)) story.append(Spacer(1, 6)) story.append(sub_header("2C. Glucogenic vs. Ketogenic Amino Acids")) story.append(Paragraph( "<b>Glucogenic</b>: catabolized to pyruvate, OAA, α-KG, succinyl-CoA, or fumarate → can make glucose. " "<b>Ketogenic</b>: yield acetyl-CoA or acetoacetate → cannot make glucose (fuel for ketogenesis).", sBody)) gk_data = [ [Paragraph(b("Category"), sLabel), Paragraph(b("Amino Acids"), sLabel)], ["Purely Ketogenic", "Leucine (Leu), Lysine (Lys) — mnemonic: 'Luckily Ketogenic'"], ["Both (Glucogenic + Ketogenic)", "Ile, Phe, Trp, Tyr, Thr"], ["Purely Glucogenic", "All remaining 15 amino acids"], ] gkt = Table(gk_data, colWidths=[W*0.30, W*0.70]) gkt.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,0), NAVY), ("TEXTCOLOR", (0,0), (-1,0), WHITE), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,-1), 9), ("BACKGROUND", (0,1), (-1,1), colors.HexColor("#FDECEA")), ("BACKGROUND", (0,2), (-1,2), colors.HexColor("#FEF9E7")), ("BACKGROUND", (0,3), (-1,3), colors.HexColor("#EBF5FB")), ("GRID", (0,0), (-1,-1), 0.4, MIDGRAY), ("LEFTPADDING", (0,0), (-1,-1), 6), ("TOPPADDING", (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4), ("FONTNAME", (0,1), (-1,-1), "Helvetica"), ("VALIGN", (0,0), (-1,-1), "MIDDLE"), ])) story.append(gkt) story.append(Spacer(1, 6)) story.append(sub_header("2D. One-Carbon Metabolism (Folate & B12)")) story.append(Paragraph( "Serine is the primary one-carbon donor → THF (tetrahydrofolate) carries one-carbon units. " "Methionine cycle: Met → SAM (universal methyl donor) → SAH → Homocysteine. " "Homocysteine is remethylated to Met using <b>5-methyl-THF + B12 (methionine synthase)</b>, " "or transsulfurated to cysteine via <b>CBS (cystathionine β-synthase, B6-dependent)</b>.", sBody)) story.append(Spacer(1, 6)) # Quiz Q5-10 story.append(sub_header("Quiz — Metabolism")) for items in [ ("5", "ALT is elevated in a patient with jaundice. What is ALT's normal metabolic role?", "ALT (alanine aminotransferase) catalyzes: Alanine + α-KG ⇌ Pyruvate + Glutamate. It is central to the glucose–alanine cycle: muscle generates alanine from pyruvate (transamination), exports it to liver, where ALT regenerates pyruvate for gluconeogenesis and the amino group enters the urea cycle. Elevation in liver disease reflects hepatocyte lysis releasing cytosolic ALT."), ("6", "A newborn has hyperammonemia. Plasma citrulline is absent. Which urea cycle enzyme is most likely deficient?", "OTC (ornithine transcarbamylase) — the most common urea cycle defect (X-linked). OTC converts ornithine + carbamoyl phosphate → citrulline in mitochondria. Absent citrulline in plasma with elevated orotic acid (carbamoyl phosphate overflows into pyrimidine synthesis) is the classic pattern."), ("7", "Name the ONLY two purely ketogenic amino acids.", "Leucine and Lysine. They are degraded entirely to acetyl-CoA / acetoacetate and cannot contribute to gluconeogenesis. Mnemonic: 'Lucky Leu and Lys are Ketogenic.'"), ("8", "What cofactor is shared by ALL transaminases, and what vitamin is it derived from?", "Pyridoxal phosphate (PLP), derived from Vitamin B6 (pyridoxine). PLP acts as a Schiff base intermediate, shuttling amino groups between amino acids and alpha-keto acids."), ("9", "Homocysteine is elevated in a patient. Name two vitamins whose deficiency could cause this and explain the mechanism for each.", "① Vitamin B12 (cobalamin): required for methionine synthase (homocysteine + 5-methyl-THF → methionine). Deficiency traps folate as 5-methyl-THF (methylfolate trap) and prevents remethylation. ② Vitamin B6 (pyridoxine): required for CBS (cystathionine β-synthase) which converts homocysteine → cystathionine → cysteine via transsulfuration. B6 deficiency blocks this route. Folate (B9) deficiency can also raise homocysteine by reducing 5-methyl-THF availability."), ("10", "What activates CPS-I (the committed step of the urea cycle) and why is this physiologically important?", "N-acetylglutamate (NAG), synthesized by NAG synthase from acetyl-CoA + glutamate. NAG levels rise when amino acid catabolism increases (high protein intake, fasting), ensuring the urea cycle ramps up proportionally to handle more ammonia. Arginine stimulates NAG synthase — creating a feedforward loop."), ]: story.extend(qa(items[1], items[2], items[0])) story.append(PageBreak()) # ══════════════════════════════════════════════════════════════ # SECTION 3 — CLINICAL CORRELATES # ══════════════════════════════════════════════════════════════ story.append(section_header("SECTION 3 — High-Yield Clinical Correlates", RED)) story.append(Spacer(1, 6)) clinicals = [ ("Phenylketonuria (PKU)", RED, "Deficient enzyme", "Phenylalanine hydroxylase (PAH), or cofactor BH4 (tetrahydrobiopterin)", "Pathway blocked", "Phe → Tyr conversion fails; Phe accumulates and is transaminated to phenylpyruvate, phenylacetate, phenyllactate", "Presentation", "Intellectual disability, fair skin/hair/eyes (tyrosinase substrate depleted), musty/mousy odor (phenylacetate), eczema", "Lab finding", "Elevated plasma Phe (>1200 µmol/L); elevated phenylpyruvate in urine (ferric chloride test = green)", "Treatment", "Phenylalanine-restricted diet; BH4 supplementation (sapropterin) for BH4-deficient forms; enzyme therapy (pegvaliase)"), ("Maple Syrup Urine Disease (MSUD)", colors.HexColor("#7D3C98"), "Deficient enzyme", "Branched-chain alpha-keto acid dehydrogenase (BCKAD) complex", "Pathway blocked", "Catabolism of BCAAs (Leu, Ile, Val) — keto acids accumulate", "Presentation", "Sweet maple-syrup odor of urine/cerumen; neonatal encephalopathy, seizures, alternating hypo/hypertonia", "Lab finding", "Elevated plasma Leu, Ile, Val + their keto acids; alloisoleucine (pathognomonic)", "Treatment", "Restrict BCAAs dietarily; thiamine (B1) may help in thiamine-responsive form; liver transplant curative"), ("Homocystinuria", colors.HexColor("#1A5276"), "Deficient enzyme", "Cystathionine β-synthase (CBS) — most common form", "Pathway blocked", "Homocysteine → cystathionine → cysteine (transsulfuration); homocysteine accumulates", "Presentation", "Marfanoid habitus, downward lens dislocation (ectopia lentis), thromboembolism (venous + arterial), intellectual disability", "Lab finding", "Elevated plasma + urine homocysteine; urine sodium nitroprusside test positive", "Treatment", "Pyridoxine (B6) if CBS-responsive; methionine restriction + cysteine supplementation; B12 + folate; betaine"), ("Alkaptonuria", colors.HexColor("#117A65"), "Deficient enzyme", "Homogentisate oxidase (HGD)", "Pathway blocked", "Tyr catabolism: homogentisic acid accumulates", "Presentation", "Dark urine (oxidation of homogentisate → benzoquinone acetic acid), ochronosis (blue-black pigment in connective tissue, sclera, ear cartilage), arthritis", "Lab finding", "Urine darkens on standing / alkalinization; homogentisic acid in urine", "Treatment", "Nitisinone (NTBC, blocks HPPD upstream); low Phe/Tyr diet"), ("Hartnup Disease", colors.HexColor("#7E5109"), "Deficient enzyme", "Neutral amino acid transporter (SLC6A19) in intestine and kidney", "Pathway blocked", "Absorption of neutral AAs (especially Trp) impaired → tryptophan deficiency → niacin (B3) deficiency", "Presentation", "Pellagra-like: photosensitive rash, cerebellar ataxia, psychiatric symptoms (3 Ds: dermatitis, diarrhea, dementia); intermittent", "Lab finding", "Increased neutral AAs in urine (generalized aminoaciduria); normal plasma levels (intestinal defect predominates)", "Treatment", "Niacin supplementation; high-protein diet to compensate for malabsorption"), ("Cystinuria", colors.HexColor("#5D6D7E"), "Deficient enzyme", "Dibasic amino acid transporter (SLC3A1/SLC7A9) in kidney/intestine", "Pathway blocked", "Reabsorption of cystine, ornithine, arginine, lysine (COAL) impaired", "Presentation", "Recurrent kidney stones (cystine stones; radiopaque but less than calcium), staghorn calculi, UTIs", "Lab finding", "Cyanide-nitroprusside test positive; hexagonal cystine crystals on urinalysis", "Treatment", "High fluid intake; alkalinize urine (pH >7.5); D-penicillamine or tiopronin (chelate cystine)"), ("OTC Deficiency", colors.HexColor("#C0392B"), "Deficient enzyme", "Ornithine transcarbamylase (OTC) — X-linked", "Pathway blocked", "Urea cycle step 2 fails; carbamoyl phosphate overflows into pyrimidine pathway → orotic acid", "Presentation", "Neonatal: coma, hyperammonemia; later onset: episodic encephalopathy, protein aversion, vomiting", "Lab finding", "Elevated ammonia; elevated orotic acid in urine; LOW or absent plasma citrulline", "Treatment", "Protein restriction; sodium benzoate + sodium phenylacetate (alternative nitrogen disposal); arginine/citrulline supplementation; liver transplant"), ("Tyrosinemia Type I", colors.HexColor("#1A6B40"), "Deficient enzyme", "Fumarylacetoacetate hydrolase (FAH)", "Pathway blocked", "Tyr catabolism: fumarylacetoacetate accumulates → toxic metabolites (succinylacetone)", "Presentation", "Hepatocellular carcinoma (in childhood), cirrhosis, Fanconi syndrome (proximal tubule damage), 'cabbage-like' odor", "Lab finding", "Succinylacetone in urine (pathognomonic); elevated AFP; elevated plasma Tyr/Met", "Treatment", "Nitisinone (NTBC) + Phe/Tyr restriction; liver transplant"), ] for name, color, *pairs in clinicals: # Header hdr_data = [[Paragraph(name, S("ch", fontSize=11, textColor=WHITE, fontName="Helvetica-Bold", leading=14))]] ht = Table(hdr_data, colWidths=[W]) ht.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,-1), color), ("LEFTPADDING", (0,0), (-1,-1), 8), ("TOPPADDING", (0,0), (-1,-1), 4), ("BOTTOMPADDING", (0,0), (-1,-1), 4), ])) story.append(KeepTogether([ Spacer(1, 4), ht, ])) # Detail rows rows = [] for idx in range(0, len(pairs), 2): label = pairs[idx] val = pairs[idx+1] rows.append([ Paragraph(label, S("cl", fontSize=8.5, textColor=color, fontName="Helvetica-Bold", leading=12)), Paragraph(val, S("cv", fontSize=8.5, textColor=DARKTEXT, fontName="Helvetica", leading=12)), ]) dt = Table(rows, colWidths=[W*0.22, W*0.78]) dt.setStyle(TableStyle([ ("GRID", (0,0), (-1,-1), 0.3, MIDGRAY), ("LEFTPADDING", (0,0), (-1,-1), 6), ("RIGHTPADDING", (0,0), (-1,-1), 6), ("TOPPADDING", (0,0), (-1,-1), 3), ("BOTTOMPADDING", (0,0), (-1,-1), 3), ("ROWBACKGROUNDS",(0,0), (-1,-1), [WHITE, LIGHTGRAY]), ("VALIGN", (0,0), (-1,-1), "TOP"), ])) story.append(dt) story.append(PageBreak()) # ══════════════════════════════════════════════════════════════ # SECTION 4 — CLINICAL QUIZ # ══════════════════════════════════════════════════════════════ story.append(section_header("SECTION 4 — Clinical Vignette Quiz", colors.HexColor("#7D3C98"))) story.append(Spacer(1, 6)) vignettes = [ ("11", "A 3-week-old boy presents with poor feeding, vomiting, and progressive lethargy. His urine has a sweet, maple-syrup-like odor. " "EEG shows burst suppression. Plasma amino acids show elevated leucine, isoleucine, and valine. " "Alloisoleucine is detected. What is the diagnosis, deficient enzyme, and acute management priority?", "Diagnosis: Maple Syrup Urine Disease (MSUD). Enzyme: BCKAD (branched-chain alpha-keto acid dehydrogenase) complex. " "Acute management: stop all protein intake immediately; IV glucose + lipids (anabolic to suppress catabolism); " "dialysis if Leu >1000 µmol/L or encephalopathy is severe. Leucine is the neurotoxic driver — its reduction is the priority."), ("12", "A 6-month-old girl has fair skin, blonde hair, and blue eyes despite being born to dark-haired parents of Mediterranean descent. " "She misses developmental milestones. Newborn screen showed elevated phenylalanine. " "What is the diagnosis? What would urine ferric chloride test show? How does the disease cause hypopigmentation?", "Diagnosis: Phenylketonuria (PKU). Ferric chloride test: turns green (phenylpyruvate reacts with FeCl₃). " "Hypopigmentation: PAH normally converts Phe → Tyr; Tyr is the substrate for tyrosinase → melanin synthesis. " "In PKU, Tyr is depleted (and Phe competitively inhibits tyrosinase), resulting in reduced melanin."), ("13", "A 22-year-old tall, thin man presents with dislocation of the lens inferiorly and a DVT. " "He has a history of intellectual disability. Labs show homocysteine 320 µmol/L (normal <15). " "What enzyme is most likely deficient, and which vitamin may be therapeutic?", "Enzyme: Cystathionine β-synthase (CBS). Treatment: Pyridoxine (Vitamin B6) — about 50% of CBS-deficient patients respond " "to high-dose B6 (CBS requires PLP as cofactor; B6 supplementation may partially restore activity). " "Note: Marfan syndrome also causes lens dislocation but lens displaces superiorly — downward displacement is classic for homocystinuria."), ("14", "A 5-year-old boy has recurrent hyperammonemia episodes triggered by high-protein meals. " "Urine orotic acid is markedly elevated. Plasma citrulline is undetectable. " "His 3 brothers are unaffected. What is the diagnosis and inheritance pattern?", "Diagnosis: OTC (ornithine transcarbamylase) deficiency. Inheritance: X-linked recessive — explains why brothers (XY) are severely affected " "while mother may be a mildly symptomatic carrier (random X-inactivation). Elevated orotic acid is the key distinguishing feature " "(vs. CPS-I deficiency, which has LOW orotic acid because no carbamoyl phosphate overflow occurs)."), ("15", "A 30-year-old man has progressively darkening ears (blue-black cartilage) and dark urine that blackens on standing. " "X-ray shows dense calcifications of intervertebral discs. Urine shows homogentisic acid. What is the diagnosis?", "Alkaptonuria. Deficient enzyme: homogentisate oxidase (HGD). Accumulated homogentisic acid polymerizes into a dark pigment " "(ochronosis) deposited in cartilage, tendons, and sclera. The connective tissue deposition causes arthropathy. " "Treatment: nitisinone (inhibits HPPD, the enzyme two steps upstream, reducing homogentisate production)."), ("16", "A 2-year-old presents with Fanconi syndrome (glucosuria, phosphaturia, aminoaciduria), " "elevated AFP, and liver dysfunction. Urine succinylacetone is detected. What is the diagnosis?", "Tyrosinemia Type I (hepatorenal tyrosinemia). Deficient enzyme: fumarylacetoacetate hydrolase (FAH). " "Succinylacetone (formed from fumarylacetoacetate) inhibits delta-aminolevulinic acid dehydratase (ALA-D), " "causing secondary porphyria. It also damages renal proximal tubules → Fanconi syndrome. " "Treatment: nitisinone (NTBC) + dietary Phe/Tyr restriction; curative with liver transplantation."), ("17", "A patient has elevated plasma homocysteine and megaloblastic anemia but normal MMA (methylmalonic acid). " "Which vitamin deficiency is most likely?", "Folate (B9) deficiency. Both B12 and folate deficiency cause elevated homocysteine + megaloblastic anemia. " "However, only B12 deficiency elevates MMA (methylmalonate is a substrate for B12-dependent methylmalonyl-CoA mutase). " "Normal MMA rules out B12 deficiency, pointing to folate. This distinction is critical because B12 deficiency also causes " "subacute combined degeneration of the spinal cord — treating with folate alone would miss the neurological damage."), ("18", "A child with intermittent pellagra-like rash after sun exposure, cerebellar ataxia, and psychiatric symptoms " "has normal plasma amino acids but elevated neutral amino acids in urine. What is the diagnosis?", "Hartnup disease. Defect: neutral amino acid transporter (SLC6A19) in intestinal epithelium and renal tubules. " "Tryptophan absorption is impaired → niacin (NAD⁺ precursor) deficiency → pellagra. Normal plasma AAs because " "the intestinal defect impairs absorption but urinary loss is from renal tubule defect. Treatment: niacin supplementation."), ] for items in vignettes: story.extend(qa(items[1], items[2], items[0])) story.append(PageBreak()) # ══════════════════════════════════════════════════════════════ # SECTION 5 — RAPID-FIRE REVIEW TABLE # ══════════════════════════════════════════════════════════════ story.append(section_header("SECTION 5 — Rapid-Fire Reference Table: AA Metabolism at a Glance", NAVY)) story.append(Spacer(1, 6)) rf_data = [ [Paragraph(b("AA"), sLabel), Paragraph(b("Metabolic Product(s)"), sLabel), Paragraph(b("Key Enzyme"), sLabel), Paragraph(b("Vitamin/Cofactor"), sLabel), Paragraph(b("Disease if Blocked"), sLabel)], ["Phe", "Tyr; phenylpyruvate (PKU)", "PAH", "BH4", "PKU"], ["Tyr", "DOPA→dopamine→NE→Epi; T3/T4; melanin; homogentisate", "Tyrosinase, DOPA decarboxylase, TH", "B6, Cu", "Alkaptonuria, Tyrosinemia I, Albinism"], ["Trp", "Serotonin→melatonin; NAD⁺ (kynurenine path)", "Tryptophan hydroxylase", "B6, B3 (niacin)", "Hartnup disease, Carcinoid"], ["Met", "SAM (methyl donor) → SAH → Homocysteine → Cys", "CBS (B6), Methionine synthase (B12)", "B6, B12, Folate", "Homocystinuria"], ["Leu/Ile/Val", "Acetyl-CoA (Leu); succinyl-CoA/acetyl-CoA (Ile/Val)", "BCKAD", "B1 (thiamine)", "MSUD"], ["Glu", "α-KG; GABA; Gln; urea cycle N-donor", "GDH; GAD (B6)", "B6", "Hepatic encephalopathy (excess NH₃)"], ["Asp", "OAA; urea cycle (N-donor via ASS); pyrimidines", "AST; ASS", "B6", "Citrullinemia (ASS defect)"], ["Gly", "One-carbon units; porphyrins; creatine; serine", "SHMT", "B6, Folate", "Non-ketotic hyperglycinemia"], ["Ser", "One-carbon units; Gly; sphingolipids; Cys", "SHMT; serine dehydratase", "B6, Folate", "—"], ["Cys", "Taurine; glutathione; SO₄²⁻", "CBS; cystathionase", "B6", "Homocystinuria (CBS def)"], ["Arg", "Urea; NO (NOS); creatine; polyamines", "Arginase; NOS", "—", "Arginase deficiency"], ["His", "Histamine (HDC); urocanic acid", "Histidine decarboxylase", "B6", "Histidinemia (benign)"], ["Lys", "Carnitine; acetyl-CoA (purely ketogenic)", "Various lysine dehydrogenases", "B6, B12, C", "Lysinuric protein intolerance"], ["Pro", "Hydroxyproline (requires Vit C via prolyl hydroxylase)", "Prolyl hydroxylase", "Vit C", "Scurvy (Vit C deficiency)"], ["Orn", "Urea cycle intermediate; polyamines", "OTC; ODC", "—", "OTC deficiency; Hyperornithinemia"], ] rft = Table(rf_data, colWidths=[W*0.07, W*0.30, W*0.21, W*0.14, W*0.28]) rft.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,0), NAVY), ("TEXTCOLOR", (0,0), (-1,0), WHITE), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,-1), 7.5), ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]), ("GRID", (0,0), (-1,-1), 0.3, MIDGRAY), ("LEFTPADDING", (0,0), (-1,-1), 4), ("TOPPADDING", (0,0), (-1,-1), 2), ("BOTTOMPADDING", (0,0), (-1,-1), 2), ("FONTNAME", (0,1), (-1,-1), "Helvetica"), ("VALIGN", (0,0), (-1,-1), "TOP"), ])) story.append(rft) story.append(Spacer(1, 8)) # ── Mnemonics box ─────────────────────────────────────────────── mn_data = [[ Paragraph(b("High-Yield Mnemonics"), S("mnh", fontSize=10, textColor=WHITE, fontName="Helvetica-Bold", leading=14)), Paragraph( "<b>Essential AAs:</b> PVT TIM HaLL (Phe, Val, Thr, Trp, Ile, Met, His, Lys, Leu)<br/>" "<b>Purely Ketogenic:</b> Leu &amp; Lys — 'Lucky Leu and Lys are Ketogenic'<br/>" "<b>Urea Cycle order:</b> Ordinarily Careless Citrulline Ate ASS and ARGot — OTC → Citrulline → ASS → ASL → Arginase<br/>" "<b>PKU triad:</b> Fair + Musty + ID → PAH defect<br/>" "<b>Homocystinuria vs Marfan:</b> Lens Down = Homocystinuria, Lens Up = Marfan<br/>" "<b>Orotic acid elevated:</b> OTC def (NOT CPS-I def)<br/>" "<b>Elevated MMA + homocysteine:</b> B12 def; elevated homocysteine ONLY: Folate or B6 def", S("mnb", fontSize=8.5, textColor=DARKTEXT, fontName="Helvetica", leading=13)) ]] mnt = Table(mn_data, colWidths=[W*0.25, W*0.75]) mnt.setStyle(TableStyle([ ("BACKGROUND", (0,0), (0,-1), NAVY), ("BACKGROUND", (1,0), (1,-1), colors.HexColor("#EAF2FF")), ("LEFTPADDING", (0,0), (-1,-1), 8), ("RIGHTPADDING", (0,0), (-1,-1), 8), ("TOPPADDING", (0,0), (-1,-1), 8), ("BOTTOMPADDING", (0,0), (-1,-1), 8), ("GRID", (0,0), (-1,-1), 0.5, MIDGRAY), ("VALIGN", (0,0), (-1,-1), "MIDDLE"), ])) story.append(mnt) story.append(Spacer(1, 10)) story.append(HRFlowable(width=W, thickness=0.5, color=MIDGRAY)) story.append(Paragraph( "Study Guide prepared for Biochemistry — Amino Acid Metabolism &amp; Clinical Correlates. " "Questions designed to mirror USMLE Step 1 / licensing exam vignette format.", S("foot", fontSize=7.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique", alignment=TA_CENTER, leading=11))) # ── Build ──────────────────────────────────────────────────────── doc.build(story) import os size = os.path.getsize(out_path) print(f"PDF created: {out_path} ({size//1024} KB)") PYEOF

Writing File

~/biochem-slides/build_pdf.py

from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
import os

out_path = "/home/daytona/workspace/biochem-slides/AA_Metabolism_Quiz_StudyGuide.pdf"

NAVY      = colors.HexColor("#0D1B2A")
TEAL      = colors.HexColor("#1ABC9C")
RED       = colors.HexColor("#E63946")
BLUE      = colors.HexColor("#2980B9")
PURPLE    = colors.HexColor("#9B59B6")
AMBER     = colors.HexColor("#F39C12")
GREEN     = colors.HexColor("#27AE60")
LIGHTGRAY = colors.HexColor("#F4F6F9")
MIDGRAY   = colors.HexColor("#D5D8DC")
WHITE     = colors.white
DARKTEXT  = colors.HexColor("#1C2833")
MUTEDTEXT = colors.HexColor("#5D6D7E")

doc = SimpleDocTemplate(
    out_path,
    pagesize=letter,
    leftMargin=0.75*inch,
    rightMargin=0.75*inch,
    topMargin=0.7*inch,
    bottomMargin=0.7*inch,
)

W = letter[0] - 1.5*inch

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

sTitle    = S("sTitle", fontSize=26, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=4, leading=32)
sSubtitle = S("sSubtitle", fontSize=12, textColor=colors.HexColor("#A8C8E8"), fontName="Helvetica", alignment=TA_CENTER, spaceAfter=2, leading=16)
sSubHead  = S("sSubHead", fontSize=11, textColor=NAVY, fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3, leading=14)
sBody     = S("sBody", fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", spaceBefore=2, spaceAfter=2, leading=14, alignment=TA_JUSTIFY)
sBodyBold = S("sBodyBold", fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica-Bold", spaceBefore=2, spaceAfter=2, leading=14)
sQ        = S("sQ", fontSize=10, textColor=NAVY, fontName="Helvetica-Bold", spaceBefore=6, spaceAfter=2, leading=14)
sA        = S("sA", fontSize=9.5, textColor=colors.HexColor("#1A6B40"), fontName="Helvetica", spaceBefore=1, spaceAfter=3, leading=13, leftIndent=14)
sNote     = S("sNote", fontSize=8.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique", spaceBefore=1, spaceAfter=2, leading=12, leftIndent=10)
sLabel    = S("sLabel", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, leading=10)

def b(txt): return f"<b>{txt}</b>"
def i(txt): return f"<i>{txt}</i>"

def section_header(title, color=NAVY):
    data = [[Paragraph(title, S("sh2", fontSize=13, textColor=WHITE, fontName="Helvetica-Bold", leading=16))]]
    t = Table(data, colWidths=[W])
    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),
    ]))
    return t

def sub_header(title):
    return Paragraph(title, sSubHead)

def qa(q_text, a_text, q_num=""):
    label = f"Q{q_num}. " if q_num else ""
    return [
        Paragraph(f"{label}{q_text}", sQ),
        Paragraph(f"&#9658; {a_text}", sA),
    ]

story = []

# COVER
cover_data = [[
    Paragraph("Amino Acid Metabolism", sTitle),
    Paragraph("&amp; Clinical Correlates", sTitle),
    Spacer(1, 6),
    Paragraph("Quiz &amp; Study Guide", sSubtitle),
    Paragraph("Biochemistry -- Medical Year 1 / Year 2", sSubtitle),
    Spacer(1, 4),
    HRFlowable(width=W*0.5, thickness=1.5, color=TEAL, spaceAfter=4),
    Paragraph("20 Standard Amino Acids -- Metabolic Pathways -- Enzyme Deficiencies -- High-Yield Clinicals",
              S("cov2", fontSize=9, textColor=colors.HexColor("#7FB3D3"), fontName="Helvetica", alignment=TA_CENTER, leading=13)),
]]
cover_tbl = Table(cover_data, colWidths=[W])
cover_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), NAVY),
    ("TOPPADDING",   (0,0), (-1,-1), 22),
    ("BOTTOMPADDING",(0,0), (-1,-1), 22),
    ("LEFTPADDING",  (0,0), (-1,-1), 18),
    ("RIGHTPADDING", (0,0), (-1,-1), 18),
]))
story.append(cover_tbl)
story.append(Spacer(1, 14))

story.append(Paragraph(
    "How to use: Read each <b>Study Note</b> section first, then attempt the <b>Quiz Questions</b>. "
    "Answers are shown beneath each question -- cover them with a card as you work through.", sBody))
story.append(Spacer(1, 10))

# SECTION 1
story.append(section_header("SECTION 1 -- Classification of the 20 Standard Amino Acids", NAVY))
story.append(Spacer(1, 6))

class_data = [
    [Paragraph(b("Group"), sLabel), Paragraph(b("Members"), sLabel), Paragraph(b("Key Property"), sLabel)],
    ["Nonpolar Aliphatic", "Gly, Ala, Val, Leu, Ile, Pro, Met", "Hydrophobic; form protein core"],
    ["Nonpolar Aromatic", "Phe, Trp, Tyr", "UV absorption (280 nm); Phe/Trp most hydrophobic"],
    ["Polar Uncharged", "Ser, Thr, Cys, Asn, Gln", "H-bond donors/acceptors; phosphorylation targets"],
    ["Acidic (negative)", "Asp, Glu", "pKa < 4.1; negative at pH 7; strong cation binders"],
    ["Basic (positive)", "Lys, Arg, His", "Positive at pH 7; DNA/protein binding; His pKa ~6.0"],
]
ct = Table(class_data, colWidths=[W*0.22, W*0.48, W*0.30])
ct.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  NAVY),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,0),  9),
    ("BACKGROUND",    (0,1), (-1,1),  colors.HexColor("#EBF5FB")),
    ("BACKGROUND",    (0,2), (-1,2),  colors.HexColor("#F4ECF7")),
    ("BACKGROUND",    (0,3), (-1,3),  colors.HexColor("#FEF9E7")),
    ("BACKGROUND",    (0,4), (-1,4),  colors.HexColor("#FDECEA")),
    ("BACKGROUND",    (0,5), (-1,5),  colors.HexColor("#EBF5FB")),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("FONTSIZE",      (0,1), (-1,-1), 9),
    ("GRID",          (0,0), (-1,-1), 0.4, MIDGRAY),
    ("ALIGN",         (0,0), (-1,-1), "LEFT"),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(ct)
story.append(Spacer(1, 8))

story.append(sub_header("Essential Amino Acids (cannot be synthesized -- must be dietary)"))
story.append(Paragraph(
    "<b>PVT TIM HaLL</b> -- Phe, Val, Thr, Trp, Ile, Met, His, Lys, Leu", sBody))
story.append(Paragraph(
    "Conditionally essential (increased demand): Arg, Gln, Gly, Pro, Cys, Tyr", sNote))
story.append(Spacer(1, 6))

story.append(sub_header("Quiz -- Classification"))
for items in [
    ("1", "Which amino acid has NO chiral center and why?",
     "Glycine (Gly/G). Its side chain is a single hydrogen atom, making both alpha-carbon substituents identical -- no stereocenter."),
    ("2", "Which amino acid is technically an imino acid, not an amino acid?",
     "Proline (Pro/P). Its side chain forms a pyrrolidine ring that bonds back to the backbone nitrogen, creating a secondary amine (imino group) rather than a primary amine. This also makes Pro a helix-breaker."),
    ("3", "Name the only amino acid whose side chain can buffer at physiological pH and explain why.",
     "Histidine (His/H). Its imidazole side chain has a pKa of ~6.0 -- close to physiological pH 7.4 -- allowing it to accept or donate protons under normal cellular conditions. Exploited in hemoglobin (Bohr effect) and enzyme active sites."),
    ("4", "Which amino acid absorbs UV light most strongly and at what wavelength?",
     "Tryptophan (Trp/W) absorbs most strongly at 280 nm due to its indole ring. Tyrosine also absorbs at 280 nm. This is the basis for protein quantification by UV spectrophotometry."),
]:
    story.extend(qa(items[1], items[2], items[0]))

story.append(PageBreak())

# SECTION 2
story.append(section_header("SECTION 2 -- Amino Acid Metabolism: Key Pathways", colors.HexColor("#1A5276")))
story.append(Spacer(1, 6))

story.append(sub_header("2A. Transamination"))
story.append(Paragraph(
    "Most amino acids donate their amino group via <b>transamination</b> to alpha-ketoglutarate (alpha-KG), "
    "producing <b>glutamate</b> and the corresponding alpha-keto acid. Enzyme: <b>aminotransferase (transaminase)</b>. "
    "Cofactor: <b>PLP (pyridoxal phosphate, vitamin B6)</b>.", sBody))

trans_data = [
    [Paragraph(b("Amino Acid"), sLabel), Paragraph(b("Alpha-Keto Product"), sLabel),
     Paragraph(b("Enzyme"), sLabel), Paragraph(b("Clinical Relevance"), sLabel)],
    ["Aspartate (Asp)", "Oxaloacetate (OAA)", "AST (GOT)", "Elevated in hepatocellular damage, MI"],
    ["Alanine (Ala)", "Pyruvate", "ALT (GPT)", "Most specific for hepatocellular injury"],
    ["Glutamate (Glu)", "alpha-Ketoglutarate", "GDH (also deamination)", "Central hub for all transaminations"],
    ["Leucine (Leu)", "alpha-Ketoisocaproate", "BCAT", "MSUD if BCKAD deficient"],
    ["Phenylalanine", "Phenylpyruvate", "PAH then transaminase", "PKU: phenylpyruvate in urine"],
]
tt = Table(trans_data, colWidths=[W*0.20, W*0.22, W*0.22, W*0.36])
tt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  colors.HexColor("#1A5276")),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.4, MIDGRAY),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("TOPPADDING",    (0,0), (-1,-1), 3),
    ("BOTTOMPADDING", (0,0), (-1,-1), 3),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(tt)
story.append(Spacer(1, 6))

story.append(sub_header("2B. Urea Cycle -- Nitrogen Disposal"))
story.append(Paragraph(
    "Occurs in <b>hepatocytes</b> (cytosol + mitochondria). Disposes of excess ammonia as urea (excreted in urine).", sBody))

urea_steps = [
    ("Step 1", "Mitochondria", "NH3 + CO2 + 2ATP -- Carbamoyl phosphate", "CPS-I", "Activated by N-acetylglutamate (NAG)"),
    ("Step 2", "Mitochondria", "Carbamoyl-P + Ornithine -- Citrulline", "OTC", "X-linked; most common urea cycle defect"),
    ("Step 3", "Cytosol", "Citrulline + Aspartate -- Argininosuccinate", "ASS", "Citrullinemia type I"),
    ("Step 4", "Cytosol", "Argininosuccinate -- Arginine + Fumarate", "ASL", "Argininosuccinic aciduria"),
    ("Step 5", "Cytosol", "Arginine -- Ornithine + Urea", "Arginase", "Hyperargininemia; Arg -- NO (NOS pathway)"),
]
ud = [[Paragraph(b("Step"), sLabel), Paragraph(b("Location"), sLabel),
       Paragraph(b("Reaction"), sLabel), Paragraph(b("Enzyme"), sLabel),
       Paragraph(b("Notes"), sLabel)]]
ud += urea_steps
ut = Table(ud, colWidths=[W*0.08, W*0.14, W*0.32, W*0.14, W*0.32])
ut.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  colors.HexColor("#117A65")),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 8),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.4, MIDGRAY),
    ("LEFTPADDING",   (0,0), (-1,-1), 4),
    ("TOPPADDING",    (0,0), (-1,-1), 3),
    ("BOTTOMPADDING", (0,0), (-1,-1), 3),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(ut)
story.append(Spacer(1, 5))
story.append(Paragraph("Memory tip: <b>Ordinarily Careless Citrulline Ate ASS and ARGot</b> -- OTC, CPS-I, citrulline, ASS, ASL, arginase", sNote))
story.append(Spacer(1, 6))

story.append(sub_header("2C. Glucogenic vs. Ketogenic Amino Acids"))
story.append(Paragraph(
    "<b>Glucogenic</b>: catabolized to pyruvate, OAA, alpha-KG, succinyl-CoA, or fumarate -- can make glucose via gluconeogenesis. "
    "<b>Ketogenic</b>: yield acetyl-CoA or acetoacetate -- cannot make net glucose.", sBody))

gk_data = [
    [Paragraph(b("Category"), sLabel), Paragraph(b("Amino Acids"), sLabel)],
    ["Purely Ketogenic", "Leucine (Leu), Lysine (Lys) -- mnemonic: 'Lucky Leu and Lys are Ketogenic'"],
    ["Both (Glucogenic + Ketogenic)", "Ile, Phe, Trp, Tyr, Thr"],
    ["Purely Glucogenic", "All remaining 15 amino acids"],
]
gkt = Table(gk_data, colWidths=[W*0.30, W*0.70])
gkt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  NAVY),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 9),
    ("BACKGROUND",    (0,1), (-1,1),  colors.HexColor("#FDECEA")),
    ("BACKGROUND",    (0,2), (-1,2),  colors.HexColor("#FEF9E7")),
    ("BACKGROUND",    (0,3), (-1,3),  colors.HexColor("#EBF5FB")),
    ("GRID",          (0,0), (-1,-1), 0.4, MIDGRAY),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(gkt)
story.append(Spacer(1, 6))

story.append(sub_header("2D. One-Carbon Metabolism (Folate and B12)"))
story.append(Paragraph(
    "Serine is the primary one-carbon donor, transferring to THF (tetrahydrofolate). "
    "Methionine cycle: Met -- SAM (universal methyl donor) -- SAH -- Homocysteine. "
    "Homocysteine is remethylated to Met using <b>5-methyl-THF + B12 (methionine synthase)</b>, "
    "or transsulfurated to cysteine via <b>CBS (cystathionine beta-synthase, B6-dependent)</b>.", sBody))
story.append(Spacer(1, 6))

story.append(sub_header("Quiz -- Metabolism"))
for items in [
    ("5", "ALT is elevated in a patient with jaundice. What is ALT's normal metabolic role?",
     "ALT (alanine aminotransferase) catalyzes: Alanine + alpha-KG -- Pyruvate + Glutamate. Central to the glucose-alanine cycle: "
     "muscle generates alanine from pyruvate (transamination), exports it to liver, where ALT regenerates pyruvate for gluconeogenesis "
     "and the amino group enters the urea cycle. Elevation in liver disease reflects hepatocyte lysis releasing cytosolic ALT."),
    ("6", "A newborn has hyperammonemia. Plasma citrulline is absent. Which urea cycle enzyme is most likely deficient?",
     "OTC (ornithine transcarbamylase) -- the most common urea cycle defect (X-linked). OTC converts ornithine + carbamoyl phosphate "
     "-- citrulline in mitochondria. Absent citrulline with elevated orotic acid (carbamoyl phosphate overflows into pyrimidine synthesis) is the classic pattern."),
    ("7", "Name the ONLY two purely ketogenic amino acids.",
     "Leucine and Lysine. They are degraded entirely to acetyl-CoA/acetoacetate and cannot contribute to gluconeogenesis. Mnemonic: 'Lucky Leu and Lys are Ketogenic.'"),
    ("8", "What cofactor is shared by ALL transaminases, and what vitamin is it derived from?",
     "Pyridoxal phosphate (PLP), derived from Vitamin B6 (pyridoxine). PLP acts as a Schiff base intermediate, shuttling amino groups between amino acids and alpha-keto acids."),
    ("9", "Homocysteine is elevated in a patient. Name two vitamins whose deficiency could cause this and explain the mechanism for each.",
     "(1) Vitamin B12: required for methionine synthase (homocysteine + 5-methyl-THF -- methionine). Deficiency traps folate as 5-methyl-THF (methylfolate trap). "
     "(2) Vitamin B6: required for CBS which converts homocysteine -- cystathionine via transsulfuration. Folate (B9) deficiency also raises homocysteine by reducing 5-methyl-THF availability."),
    ("10", "What activates CPS-I (committed step of urea cycle) and why is this physiologically important?",
     "N-acetylglutamate (NAG), synthesized from acetyl-CoA + glutamate by NAG synthase. NAG rises with high amino acid catabolism, ensuring the urea cycle ramps up proportionally. Arginine stimulates NAG synthase -- creating a feedforward activation loop."),
]:
    story.extend(qa(items[1], items[2], items[0]))

story.append(PageBreak())

# SECTION 3 - Clinical Correlates
story.append(section_header("SECTION 3 -- High-Yield Clinical Correlates", RED))
story.append(Spacer(1, 6))

clinicals = [
    ("Phenylketonuria (PKU)", RED,
     "Deficient enzyme", "Phenylalanine hydroxylase (PAH), or cofactor BH4 (tetrahydrobiopterin)",
     "Pathway blocked", "Phe -- Tyr conversion fails; Phe accumulates and is transaminated to phenylpyruvate, phenylacetate, phenyllactate",
     "Presentation", "Intellectual disability, fair skin/hair/eyes (tyrosinase substrate depleted), musty/mousy odor (phenylacetate), eczema",
     "Lab finding", "Elevated plasma Phe (>1200 umol/L); elevated phenylpyruvate in urine (ferric chloride test = green)",
     "Treatment", "Phenylalanine-restricted diet; BH4 supplementation (sapropterin) for BH4-deficient forms; enzyme therapy (pegvaliase)"),
    ("Maple Syrup Urine Disease (MSUD)", colors.HexColor("#7D3C98"),
     "Deficient enzyme", "Branched-chain alpha-keto acid dehydrogenase (BCKAD) complex",
     "Pathway blocked", "Catabolism of BCAAs (Leu, Ile, Val) -- keto acids accumulate",
     "Presentation", "Sweet maple-syrup odor of urine/cerumen; neonatal encephalopathy, seizures, alternating hypo/hypertonia",
     "Lab finding", "Elevated plasma Leu, Ile, Val + their keto acids; alloisoleucine (pathognomonic)",
     "Treatment", "Restrict BCAAs dietarily; thiamine (B1) may help in thiamine-responsive form; liver transplant curative"),
    ("Homocystinuria", colors.HexColor("#1A5276"),
     "Deficient enzyme", "Cystathionine beta-synthase (CBS) -- most common form",
     "Pathway blocked", "Homocysteine -- cystathionine -- cysteine (transsulfuration); homocysteine accumulates",
     "Presentation", "Marfanoid habitus, DOWNWARD lens dislocation (ectopia lentis), thromboembolism, intellectual disability",
     "Lab finding", "Elevated plasma + urine homocysteine; urine sodium nitroprusside test positive",
     "Treatment", "Pyridoxine (B6) if CBS-responsive; methionine restriction + cysteine supplementation; B12 + folate; betaine"),
    ("Alkaptonuria", colors.HexColor("#117A65"),
     "Deficient enzyme", "Homogentisate oxidase (HGD)",
     "Pathway blocked", "Tyr catabolism: homogentisic acid accumulates",
     "Presentation", "Dark urine (oxidation of homogentisate), ochronosis (blue-black pigment in connective tissue, sclera, ear cartilage), arthritis",
     "Lab finding", "Urine darkens on standing/alkalinization; homogentisic acid in urine",
     "Treatment", "Nitisinone (NTBC); low Phe/Tyr diet"),
    ("Hartnup Disease", colors.HexColor("#7E5109"),
     "Deficient enzyme", "Neutral amino acid transporter (SLC6A19) in intestine and kidney",
     "Pathway blocked", "Trp absorption impaired -- tryptophan deficiency -- niacin (B3) deficiency",
     "Presentation", "Pellagra-like: photosensitive rash, cerebellar ataxia, psychiatric symptoms; intermittent",
     "Lab finding", "Increased neutral AAs in urine; normal plasma levels",
     "Treatment", "Niacin supplementation; high-protein diet"),
    ("Cystinuria", colors.HexColor("#5D6D7E"),
     "Deficient enzyme", "Dibasic amino acid transporter (SLC3A1/SLC7A9) in kidney/intestine",
     "Pathway blocked", "Reabsorption of cystine, ornithine, arginine, lysine (COAL) impaired",
     "Presentation", "Recurrent kidney stones (cystine; radiopaque), staghorn calculi, UTIs",
     "Lab finding", "Cyanide-nitroprusside test positive; hexagonal cystine crystals on UA",
     "Treatment", "High fluid intake; alkalinize urine (pH >7.5); D-penicillamine or tiopronin"),
    ("OTC Deficiency", colors.HexColor("#C0392B"),
     "Deficient enzyme", "Ornithine transcarbamylase (OTC) -- X-linked",
     "Pathway blocked", "Urea cycle step 2 fails; carbamoyl phosphate overflows into pyrimidine pathway -- orotic acid",
     "Presentation", "Neonatal: coma, hyperammonemia; later: episodic encephalopathy, protein aversion",
     "Lab finding", "Elevated ammonia; elevated orotic acid; LOW/absent plasma citrulline",
     "Treatment", "Protein restriction; sodium benzoate + sodium phenylacetate; arginine/citrulline supplementation; liver transplant"),
    ("Tyrosinemia Type I", colors.HexColor("#1A6B40"),
     "Deficient enzyme", "Fumarylacetoacetate hydrolase (FAH)",
     "Pathway blocked", "Tyr catabolism: fumarylacetoacetate accumulates -- succinylacetone (toxic)",
     "Presentation", "Hepatocellular carcinoma (childhood), cirrhosis, Fanconi syndrome (proximal tubule), 'cabbage-like' odor",
     "Lab finding", "Succinylacetone in urine (pathognomonic); elevated AFP; elevated plasma Tyr/Met",
     "Treatment", "Nitisinone (NTBC) + Phe/Tyr restriction; liver transplant"),
]

for entry in clinicals:
    name  = entry[0]
    color = entry[1]
    pairs = entry[2:]
    hdr_data = [[Paragraph(name, S("ch", fontSize=11, textColor=WHITE, fontName="Helvetica-Bold", leading=14))]]
    ht = Table(hdr_data, colWidths=[W])
    ht.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), color),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ]))
    rows = []
    for idx in range(0, len(pairs), 2):
        label = pairs[idx]
        val   = pairs[idx+1]
        rows.append([
            Paragraph(label, S("cl", fontSize=8.5, textColor=color, fontName="Helvetica-Bold", leading=12)),
            Paragraph(val,   S("cv", fontSize=8.5, textColor=DARKTEXT, fontName="Helvetica", leading=12)),
        ])
    dt = Table(rows, colWidths=[W*0.22, W*0.78])
    dt.setStyle(TableStyle([
        ("GRID",          (0,0), (-1,-1), 0.3, MIDGRAY),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("RIGHTPADDING",  (0,0), (-1,-1), 6),
        ("TOPPADDING",    (0,0), (-1,-1), 3),
        ("BOTTOMPADDING", (0,0), (-1,-1), 3),
        ("ROWBACKGROUNDS",(0,0), (-1,-1), [WHITE, LIGHTGRAY]),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ]))
    story.append(KeepTogether([Spacer(1, 4), ht, dt]))

story.append(PageBreak())

# SECTION 4 - Clinical Vignette Quiz
story.append(section_header("SECTION 4 -- Clinical Vignette Quiz", colors.HexColor("#7D3C98")))
story.append(Spacer(1, 6))

vignettes = [
    ("11",
     "A 3-week-old boy presents with poor feeding, vomiting, and progressive lethargy. His urine has a sweet, maple-syrup-like odor. "
     "EEG shows burst suppression. Plasma amino acids show elevated leucine, isoleucine, and valine. "
     "Alloisoleucine is detected. What is the diagnosis, deficient enzyme, and acute management priority?",
     "Diagnosis: MSUD. Enzyme: BCKAD complex. Acute management: stop all protein intake immediately; "
     "IV glucose + lipids (anabolic -- suppresses catabolism); dialysis if Leu >1000 umol/L or severe encephalopathy. "
     "Leucine is the most neurotoxic driver -- its rapid reduction is the priority."),
    ("12",
     "A 6-month-old girl has fair skin, blonde hair, and blue eyes despite being born to dark-haired Mediterranean parents. "
     "She misses developmental milestones. Newborn screen showed elevated phenylalanine. "
     "What is the diagnosis? What would urine ferric chloride test show? How does the disease cause hypopigmentation?",
     "Diagnosis: PKU. Ferric chloride test: turns green (phenylpyruvate). "
     "Hypopigmentation: PAH converts Phe -- Tyr; Tyr is the substrate for tyrosinase -- melanin. "
     "In PKU, Tyr is depleted (and Phe competitively inhibits tyrosinase), resulting in reduced melanin production."),
    ("13",
     "A 22-year-old tall, thin man presents with inferior dislocation of the lens and a DVT. "
     "He has a history of intellectual disability. Labs: homocysteine 320 umol/L (normal <15). "
     "What enzyme is most likely deficient, and which vitamin may be therapeutic?",
     "Enzyme: CBS (cystathionine beta-synthase). Treatment: Pyridoxine (B6) -- ~50% of CBS-deficient patients respond "
     "(CBS requires PLP as cofactor; B6 may partially restore activity). "
     "Key differentiator from Marfan: in Marfan, lens displaces SUPERIORLY; in homocystinuria, lens displaces INFERIORLY."),
    ("14",
     "A 5-year-old boy has recurrent hyperammonemia triggered by high-protein meals. "
     "Urine orotic acid is markedly elevated. Plasma citrulline is undetectable. His 3 brothers are unaffected. "
     "What is the diagnosis and inheritance pattern?",
     "Diagnosis: OTC deficiency. Inheritance: X-linked recessive -- explains severe disease in males and asymptomatic/mildly affected carrier females. "
     "Elevated orotic acid is the key distinguishing feature vs. CPS-I deficiency, which has LOW orotic acid."),
    ("15",
     "A 30-year-old man has progressively darkening ear cartilage (blue-black) and dark urine that blackens on standing. "
     "X-ray shows dense calcifications of intervertebral discs. Urine shows homogentisic acid. What is the diagnosis?",
     "Alkaptonuria. Enzyme: homogentisate oxidase (HGD). Accumulated homogentisic acid polymerizes into a dark pigment "
     "(ochronosis) deposited in cartilage, tendons, and sclera. Treatment: nitisinone (inhibits HPPD upstream, reducing homogentisate production)."),
    ("16",
     "A 2-year-old presents with Fanconi syndrome (glucosuria, phosphaturia, aminoaciduria), "
     "elevated AFP, and liver dysfunction. Urine succinylacetone is detected. What is the diagnosis?",
     "Tyrosinemia Type I. Enzyme: FAH. Succinylacetone inhibits ALA-D (causing secondary porphyria) and damages renal proximal tubules. "
     "Treatment: nitisinone (NTBC) + dietary Phe/Tyr restriction; liver transplantation is curative."),
    ("17",
     "A patient has elevated plasma homocysteine and megaloblastic anemia but NORMAL methylmalonic acid (MMA). "
     "Which vitamin deficiency is most likely?",
     "Folate (B9) deficiency. Both B12 and folate cause elevated homocysteine + megaloblastic anemia. "
     "However, only B12 deficiency elevates MMA (methylmalonyl-CoA mutase requires B12). "
     "Normal MMA rules out B12 -- pointing to folate. Critical distinction: treating with folate alone in B12 deficiency would miss subacute combined degeneration."),
    ("18",
     "A child has intermittent pellagra-like rash after sun exposure, cerebellar ataxia, and psychiatric symptoms. "
     "Plasma amino acids are normal. Urine shows increased neutral amino acids. What is the diagnosis?",
     "Hartnup disease. Defect: SLC6A19 neutral amino acid transporter in intestinal epithelium and renal tubules. "
     "Trp malabsorption -- niacin deficiency -- pellagra. Normal plasma AAs because the intestinal defect limits absorption "
     "but hepatic synthesis partially compensates; urine loss reflects renal tubule defect. Treatment: niacin supplementation."),
]

for items in vignettes:
    story.extend(qa(items[1], items[2], items[0]))

story.append(PageBreak())

# SECTION 5 - Rapid Fire Table
story.append(section_header("SECTION 5 -- Rapid-Fire Reference: AA Metabolism at a Glance", NAVY))
story.append(Spacer(1, 6))

rf_data = [
    [Paragraph(b("AA"), sLabel), Paragraph(b("Metabolic Product(s)"), sLabel),
     Paragraph(b("Key Enzyme"), sLabel), Paragraph(b("Vitamin/Cofactor"), sLabel),
     Paragraph(b("Disease if Blocked"), sLabel)],
    ["Phe", "Tyr; phenylpyruvate (PKU)", "PAH", "BH4", "PKU"],
    ["Tyr", "DOPA -- dopamine -- NE -- Epi; T3/T4; melanin; homogentisate", "Tyrosinase, TH, DOPA decarboxylase", "B6, Cu", "Alkaptonuria, Tyrosinemia I, Albinism"],
    ["Trp", "Serotonin -- melatonin; NAD+ (kynurenine path)", "Tryptophan hydroxylase", "B6, B3 (niacin)", "Hartnup disease, Carcinoid"],
    ["Met", "SAM (methyl donor) -- SAH -- Homocysteine -- Cys", "CBS (B6), Methionine synthase (B12)", "B6, B12, Folate", "Homocystinuria"],
    ["Leu/Ile/Val", "Acetyl-CoA (Leu); succinyl-CoA/acetyl-CoA (Ile/Val)", "BCKAD", "B1 (thiamine)", "MSUD"],
    ["Glu", "alpha-KG; GABA; Gln; urea cycle N-donor", "GDH; GAD (B6)", "B6", "Hepatic encephalopathy (excess NH3)"],
    ["Asp", "OAA; urea cycle N-donor via ASS; pyrimidines", "AST; ASS", "B6", "Citrullinemia (ASS defect)"],
    ["Gly", "One-carbon units; porphyrins; creatine; serine", "SHMT", "B6, Folate", "Non-ketotic hyperglycinemia"],
    ["Ser", "One-carbon units; Gly; sphingolipids; Cys", "SHMT; serine dehydratase", "B6, Folate", "--"],
    ["Cys", "Taurine; glutathione; SO4(2-)", "CBS; cystathionase", "B6", "Homocystinuria (CBS def)"],
    ["Arg", "Urea; NO (NOS); creatine; polyamines", "Arginase; NOS", "--", "Arginase deficiency"],
    ["His", "Histamine (HDC); urocanic acid", "Histidine decarboxylase", "B6", "Histidinemia (benign)"],
    ["Lys", "Carnitine; acetyl-CoA (purely ketogenic)", "Lysine dehydrogenases", "B6, B12, C", "Lysinuric protein intolerance"],
    ["Pro", "Hydroxyproline (requires Vit C)", "Prolyl hydroxylase", "Vit C", "Scurvy (Vit C deficiency)"],
    ["Orn", "Urea cycle intermediate; polyamines", "OTC; ODC", "--", "OTC deficiency; Hyperornithinemia"],
]

rft = Table(rf_data, colWidths=[W*0.07, W*0.30, W*0.21, W*0.14, W*0.28])
rft.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  NAVY),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 7.5),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.3, MIDGRAY),
    ("LEFTPADDING",   (0,0), (-1,-1), 4),
    ("TOPPADDING",    (0,0), (-1,-1), 2),
    ("BOTTOMPADDING", (0,0), (-1,-1), 2),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
]))
story.append(rft)
story.append(Spacer(1, 10))

# Mnemonics box
mn_data = [[
    Paragraph(b("High-Yield Mnemonics"), S("mnh", fontSize=10, textColor=WHITE, fontName="Helvetica-Bold", leading=14)),
    Paragraph(
        "<b>Essential AAs:</b> PVT TIM HaLL (Phe, Val, Thr, Trp, Ile, Met, His, Lys, Leu)<br/>"
        "<b>Purely Ketogenic:</b> Leu and Lys -- 'Lucky Leu and Lys are Ketogenic'<br/>"
        "<b>Urea Cycle order:</b> Ordinarily Careless Citrulline Ate ASS and ARGot<br/>"
        "<b>PKU triad:</b> Fair + Musty + ID -- PAH defect<br/>"
        "<b>Homocystinuria vs Marfan:</b> Lens Down = Homocystinuria; Lens Up = Marfan<br/>"
        "<b>Orotic acid elevated:</b> OTC deficiency (NOT CPS-I deficiency)<br/>"
        "<b>Elevated MMA + homocysteine:</b> B12 deficiency<br/>"
        "<b>Elevated homocysteine ONLY:</b> Folate or B6 deficiency",
        S("mnb", fontSize=8.5, textColor=DARKTEXT, fontName="Helvetica", leading=13))
]]
mnt = Table(mn_data, colWidths=[W*0.25, W*0.75])
mnt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (0,-1), NAVY),
    ("BACKGROUND",    (1,0), (1,-1), colors.HexColor("#EAF2FF")),
    ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ("RIGHTPADDING",  (0,0), (-1,-1), 8),
    ("TOPPADDING",    (0,0), (-1,-1), 8),
    ("BOTTOMPADDING", (0,0), (-1,-1), 8),
    ("GRID",          (0,0), (-1,-1), 0.5, MIDGRAY),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(mnt)
story.append(Spacer(1, 10))
story.append(HRFlowable(width=W, thickness=0.5, color=MIDGRAY))
story.append(Paragraph(
    "Study Guide prepared for Biochemistry -- Amino Acid Metabolism and Clinical Correlates. "
    "Questions designed to mirror USMLE Step 1 / licensing exam vignette format.",
    S("foot", fontSize=7.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique", alignment=TA_CENTER, leading=11)))

doc.build(story)
size = os.path.getsize(out_path)
print(f"PDF created: {out_path}  ({size//1024} KB)")
Running Command

python3 /home/daytona/workspace/biochem-slides/build_pdf.py

Your PDF is ready:

AA Metabolism Quiz StudyGuide

PDF Document · PDF


What's inside (6 pages):
SectionContent
CoverTitle, subtitle, topic overview
Section 1 - ClassificationColor-coded table of all 5 AA groups + essential AA mnemonic (PVT TIM HaLL) + 4 quiz questions
Section 2 - Metabolic PathwaysTransamination table (with AST/ALT clinical notes), full Urea Cycle table (all 5 steps + enzymes + diseases), glucogenic vs. ketogenic table, one-carbon metabolism summary + 6 quiz questions
Section 3 - Clinical CorrelatesColor-coded cards for 8 diseases: PKU, MSUD, Homocystinuria, Alkaptonuria, Hartnup, Cystinuria, OTC deficiency, Tyrosinemia Type I -- each with deficient enzyme, blocked pathway, presentation, labs, and treatment
Section 4 - Vignette Quiz8 USMLE-style clinical vignettes with full explanatory answers
Section 5 - Rapid-Fire Table + Mnemonics15-row metabolism reference table (AA -- product -- enzyme -- vitamin -- disease) + mnemonic box

Create a summary exam with 25 practice questions

Writing File

~/biochem-slides/build_exam.py

from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
import os

out_path = "/home/daytona/workspace/biochem-slides/AA_Summary_Exam_25Q.pdf"

NAVY      = colors.HexColor("#0D1B2A")
TEAL      = colors.HexColor("#1ABC9C")
RED       = colors.HexColor("#E63946")
BLUE      = colors.HexColor("#2980B9")
PURPLE    = colors.HexColor("#9B59B6")
AMBER     = colors.HexColor("#F39C12")
GREEN     = colors.HexColor("#27AE60")
LIGHTGRAY = colors.HexColor("#F4F6F9")
MIDGRAY   = colors.HexColor("#D5D8DC")
WHITE     = colors.white
DARKTEXT  = colors.HexColor("#1C2833")
MUTEDTEXT = colors.HexColor("#5D6D7E")
ANSWERGREEN = colors.HexColor("#E8F8F0")
ANSWERBORDER = colors.HexColor("#1A6B40")

doc = SimpleDocTemplate(
    out_path,
    pagesize=letter,
    leftMargin=0.75*inch,
    rightMargin=0.75*inch,
    topMargin=0.7*inch,
    bottomMargin=0.7*inch,
)
W = letter[0] - 1.5*inch

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

sTitle    = S("sTitle",    fontSize=24, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, leading=30)
sSubtitle = S("sSubtitle", fontSize=11, textColor=colors.HexColor("#A8C8E8"), fontName="Helvetica", alignment=TA_CENTER, leading=15)
sBody     = S("sBody",     fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", leading=14, alignment=TA_JUSTIFY)
sNote     = S("sNote",     fontSize=8.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique", leading=12)
sQ        = S("sQ",        fontSize=10, textColor=NAVY, fontName="Helvetica-Bold", leading=14, spaceBefore=4, spaceAfter=3)
sQBody    = S("sQBody",    fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", leading=14, spaceAfter=2)
sOption   = S("sOption",   fontSize=9.5, textColor=DARKTEXT, fontName="Helvetica", leading=13, leftIndent=12)
sLabel    = S("sLabel",    fontSize=8, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER, leading=10)
sAnsHdr   = S("sAnsHdr",   fontSize=10, textColor=WHITE, fontName="Helvetica-Bold", leading=13)
sAnsBody  = S("sAnsBody",  fontSize=9, textColor=colors.HexColor("#0B3D1E"), fontName="Helvetica", leading=13)
sAnsBold  = S("sAnsBold",  fontSize=9, textColor=colors.HexColor("#0B3D1E"), fontName="Helvetica-Bold", leading=13)

def section_header(title, color=NAVY):
    data = [[Paragraph(title, S("sh", fontSize=13, textColor=WHITE, fontName="Helvetica-Bold", leading=16))]]
    t = Table(data, colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("LEFTPADDING",  (0,0), (-1,-1), 10),
        ("RIGHTPADDING", (0,0), (-1,-1), 10),
        ("TOPPADDING",   (0,0), (-1,-1), 6),
        ("BOTTOMPADDING",(0,0), (-1,-1), 6),
    ]))
    return t

# Each question: (num, category, vignette, options dict, correct_key, explanation)
questions = [
    # --- SECTION A: Classification & Structure (Q1-5) ---
    (1, "Classification & Structure",
     "A biochemistry student notes that one amino acid cannot rotate plane-polarized light in either direction. "
     "Which amino acid is this, and what structural feature accounts for this property?",
     {"A": "Alanine -- the methyl side chain is too small to cause rotation",
      "B": "Glycine -- both substituents on the alpha-carbon are identical (H), so no chiral center exists",
      "C": "Proline -- the ring structure cancels optical activity",
      "D": "Serine -- the hydroxyl group neutralizes rotation",
      "E": "Valine -- branched chains produce equal rotation in both directions"},
     "B",
     "Glycine is the only achiral (optically inactive) standard amino acid. Its alpha-carbon bears two identical hydrogen substituents, "
     "so it has no stereocenter. All other standard amino acids have an asymmetric alpha-carbon and exist as L-enantiomers in proteins."),

    (2, "Classification & Structure",
     "A researcher is measuring the pKa values of amino acid side chains to predict which will act as proton shuttles "
     "inside an enzyme active site at physiological pH (7.35-7.45). Which amino acid side chain pKa is MOST suitable?",
     {"A": "Aspartate side chain -- pKa ~3.9",
      "B": "Glutamate side chain -- pKa ~4.1",
      "C": "Histidine imidazole -- pKa ~6.0",
      "D": "Lysine epsilon-amino -- pKa ~10.5",
      "E": "Arginine guanidinium -- pKa ~12.5"},
     "C",
     "Histidine (pKa ~6.0) is the only standard amino acid whose side chain can both accept and donate protons near physiological pH. "
     "This makes it the most effective proton shuttle in enzyme active sites (e.g., serine proteases -- catalytic triad His-Asp-Ser). "
     "It is also the basis of hemoglobin's Bohr effect: deoxyHb His residues become protonated, stabilizing the T-state."),

    (3, "Classification & Structure",
     "Which of the following correctly pairs an amino acid with its classification AND a unique structural property?",
     {"A": "Leucine -- polar uncharged; branched aliphatic chain",
      "B": "Proline -- nonpolar; secondary amine (imino acid) that disrupts alpha-helices",
      "C": "Tyrosine -- nonpolar aromatic; cannot be phosphorylated",
      "D": "Asparagine -- acidic; forms disulfide bonds",
      "E": "Methionine -- basic; thioether group donates methyl groups directly"},
     "B",
     "Proline is nonpolar aliphatic and uniquely contains a pyrrolidine ring where its side chain bonds back to the backbone nitrogen, "
     "forming a secondary (imino) amine. This restricts backbone rotation (no free N-H), disrupts alpha-helices, and is critical in "
     "collagen's Gly-Pro-Hyp triplet repeat. The other options contain errors: Leu is nonpolar; Tyr CAN be phosphorylated (Tyr kinases); "
     "Asn is polar uncharged and does NOT form disulfide bonds (Cys does); Met is nonpolar, not basic."),

    (4, "Classification & Structure",
     "A protein spectrophotometer measures absorbance at 280 nm to estimate protein concentration. "
     "Which two amino acids contribute MOST to this absorbance?",
     {"A": "Phenylalanine and Alanine",
      "B": "Tryptophan and Tyrosine",
      "C": "Histidine and Cysteine",
      "D": "Leucine and Isoleucine",
      "E": "Serine and Threonine"},
     "B",
     "Tryptophan (indole ring) and Tyrosine (phenol ring) absorb strongly at 280 nm due to their aromatic pi-electron systems. "
     "Phenylalanine absorbs weakly at 257-259 nm and contributes minimally at 280 nm. This is the basis of the A280 assay for protein quantification. "
     "Trp has the highest molar extinction coefficient (~5500 M-1cm-1) followed by Tyr (~1490 M-1cm-1)."),

    (5, "Classification & Structure",
     "Albumin has a net negative charge at physiological pH and binds calcium ions (Ca2+). "
     "Which amino acids are PRIMARILY responsible for this negative charge and cation-binding capacity?",
     {"A": "Lysine and Arginine -- their positive charges attract Ca2+ by charge reversal",
      "B": "Histidine and Cysteine -- their side chains chelate divalent cations",
      "C": "Aspartate and Glutamate -- their carboxylate side chains carry strong negative charges at pH 7",
      "D": "Serine and Threonine -- their hydroxyl groups form coordinate bonds with Ca2+",
      "E": "Glycine and Alanine -- small nonpolar residues create hydrophobic Ca2+ binding pockets"},
     "C",
     "Aspartate (pKa ~3.9) and Glutamate (pKa ~4.1) carry fully ionized carboxylate (COO-) side chains at physiological pH 7.4, "
     "giving albumin a strong net negative charge. This electrostatic property allows albumin to bind positively charged molecules including "
     "Ca2+, Mg2+, and various drugs and hormones. Albumin carries ~40-50% of total serum calcium in this way."),

    # --- SECTION B: Metabolism & Enzymes (Q6-12) ---
    (6, "Metabolism & Enzymes",
     "A 45-year-old man is found to have AST 850 U/L and ALT 1200 U/L after a paracetamol overdose. "
     "Which of the following BEST describes the normal metabolic role of ALT?",
     {"A": "ALT converts glutamine to glutamate in the kidney, regulating acid-base balance",
      "B": "ALT catalyzes: Alanine + alpha-ketoglutarate -- Pyruvate + Glutamate, central to the glucose-alanine cycle",
      "C": "ALT phosphorylates glucose in the liver as part of glycolysis",
      "D": "ALT deaminates glutamate to produce alpha-ketoglutarate and free NH3",
      "E": "ALT hydroxylates phenylalanine to produce tyrosine using BH4 as cofactor"},
     "B",
     "ALT (alanine aminotransferase) catalyzes the reversible transamination: Alanine + alpha-KG -- Pyruvate + Glutamate. "
     "In the glucose-alanine cycle: skeletal muscle transaminate pyruvate -- alanine, which is exported to the liver. Hepatic ALT "
     "converts alanine back to pyruvate (for gluconeogenesis) while transferring the amino group to the urea cycle. "
     "Hepatocyte lysis in overdose releases cytosolic ALT into blood, hence elevated serum levels."),

    (7, "Metabolism & Enzymes",
     "All transaminases (aminotransferases) share a common cofactor that acts as an amino group carrier via a Schiff base intermediate. "
     "Which vitamin is this cofactor derived from, and what is the cofactor's name?",
     {"A": "Vitamin B1 (thiamine) -- thiamine pyrophosphate (TPP)",
      "B": "Vitamin B2 (riboflavin) -- FAD/FMN",
      "C": "Vitamin B3 (niacin) -- NAD+/NADP+",
      "D": "Vitamin B6 (pyridoxine) -- pyridoxal phosphate (PLP)",
      "E": "Vitamin B12 (cobalamin) -- adenosylcobalamin"},
     "D",
     "Pyridoxal phosphate (PLP) is derived from vitamin B6 (pyridoxine). PLP forms a Schiff base (aldimine linkage) with the amino group "
     "of the amino acid substrate, accepting the amino group to become pyridoxamine phosphate, which then transfers it to an alpha-keto acid. "
     "B6 deficiency impairs ALL transamination reactions and also affects: GABA synthesis (GAD), heme synthesis (ALA synthase), "
     "homocysteine metabolism (CBS), serotonin synthesis (5-HTP decarboxylase), and glycogen phosphorylase."),

    (8, "Metabolism & Enzymes",
     "A patient is found to have purely ketogenic amino acid catabolism producing only acetyl-CoA and acetoacetate. "
     "Which two amino acids fit this description?",
     {"A": "Phenylalanine and Tyrosine",
      "B": "Isoleucine and Threonine",
      "C": "Leucine and Lysine",
      "D": "Tryptophan and Methionine",
      "E": "Valine and Leucine"},
     "C",
     "Leucine and Lysine are the ONLY two purely ketogenic amino acids. They are catabolized exclusively to acetyl-CoA and/or acetoacetate "
     "and cannot contribute net carbons to gluconeogenesis. Mnemonic: 'Lucky Leu and Lys.' "
     "Isoleucine, Phe, Trp, Tyr, and Thr are BOTH glucogenic AND ketogenic. Valine is purely glucogenic (-- succinyl-CoA)."),

    (9, "Metabolism & Enzymes",
     "During prolonged fasting, a patient's liver upregulates the urea cycle to handle increased amino acid catabolism. "
     "The committed step of the urea cycle is catalyzed by CPS-I. What ALLOSTERICALLY ACTIVATES CPS-I?",
     {"A": "ATP -- signals high energy state, driving the cycle forward",
      "B": "N-acetylglutamate (NAG) -- synthesized when amino acid catabolism is high",
      "C": "Ornithine -- the cycle substrate acts as its own activator",
      "D": "Arginine -- the final product feeds back positively",
      "E": "Bicarbonate (HCO3-) -- provides the carbon skeleton for carbamoyl phosphate"},
     "B",
     "N-acetylglutamate (NAG) is the essential allosteric activator of CPS-I. NAG is synthesized by NAG synthase from acetyl-CoA + glutamate. "
     "When amino acid catabolism increases (fasting, high-protein diet), glutamate levels rise, stimulating more NAG production -- "
     "a feedforward mechanism that ramps up the urea cycle proportionally. Arginine independently stimulates NAG synthase, "
     "adding another feedforward loop. Without NAG, CPS-I is essentially inactive."),

    (10, "Metabolism & Enzymes",
     "Methionine is converted to S-adenosylmethionine (SAM). After donating its methyl group, SAM becomes S-adenosylhomocysteine (SAH), "
     "which is hydrolyzed to homocysteine. What are the two main routes for homocysteine disposal?",
     {"A": "Oxidation to cystine (B2-dependent) OR deamination to alpha-keto acid",
      "B": "Remethylation to methionine (B12/folate-dependent) OR transsulfuration to cysteine (B6-dependent via CBS)",
      "C": "Gluconeogenesis (B1-dependent) OR ketogenesis (B3-dependent)",
      "D": "Urea cycle entry as ornithine (B6-dependent) OR oxidation to sulfate (B12-dependent)",
      "E": "Transamination to homocysteine thiolactone (PLP) OR methylation to betaine (folate)"},
     "B",
     "Homocysteine has two metabolic fates: "
     "(1) REMETHYLATION -- methionine: methionine synthase uses 5-methylTHF (folate) as methyl donor and requires B12 as cofactor. "
     "Betaine can also donate the methyl group via BHMT in the liver. "
     "(2) TRANSSULFURATION -- cystathionine -- cysteine: cystathionine beta-synthase (CBS) requires PLP (B6). "
     "Deficiency of B6, B12, or folate raises homocysteine, promoting thrombosis and endothelial damage."),

    (11, "Metabolism & Enzymes",
     "Glutamate dehydrogenase (GDH) catalyzes a key reaction in nitrogen metabolism. "
     "Which of the following BEST describes its role and the significance of its allosteric regulation?",
     {"A": "GDH synthesizes glutamine from glutamate + NH3; activated by ATP (high energy signals anabolism)",
      "B": "GDH deaminates glutamate -- alpha-KG + NH3 in mitochondria; activated by ADP/GDP (low energy) and inhibited by GTP/ATP",
      "C": "GDH transaminates alpha-KG + aspartate -- glutamate + OAA; regulated by NADH",
      "D": "GDH converts glutamate to GABA using PLP cofactor; inhibited by succinyl-CoA",
      "E": "GDH phosphorylates glutamate to glutamyl phosphate, the rate-limiting step of the urea cycle"},
     "B",
     "GDH (mitochondrial matrix) catalyzes: Glutamate + NAD(P)+ -- alpha-KG + NH3 + NAD(P)H. "
     "It is allosterically ACTIVATED by ADP and GDP (low energy -- deaminate AAs for fuel) "
     "and INHIBITED by ATP and GTP (high energy -- conserve amino acids). "
     "This reaction is central to amino acid catabolism, feeding alpha-KG into the TCA cycle and releasing NH3 for the urea cycle. "
     "Leucine also activates GDH (relevant in hyperinsulinism/hyperammonemia syndrome -- HIHA)."),

    (12, "Metabolism & Enzymes",
     "The glucose-alanine cycle is a key inter-organ nitrogen transport mechanism. "
     "Which of the following CORRECTLY describes the complete cycle?",
     {"A": "Liver generates alanine from glucose -- muscle uses alanine as energy -- liver receives lactate",
      "B": "Muscle: pyruvate + glutamate -- alanine (ALT) -- alanine exported to liver; "
           "Liver: alanine + alpha-KG -- pyruvate + glutamate (ALT) -- pyruvate enters gluconeogenesis, "
           "glutamate enters urea cycle",
      "C": "Kidney: glutamine -- NH3 (excreted) + glutamate -- alpha-KG -- glucose (gluconeogenesis)",
      "D": "Muscle: glycogen -- glucose -- pyruvate -- exported as pyruvate to liver for gluconeogenesis",
      "E": "Muscle: BCAAs -- alanine (BCAT) -- exported; Liver: alanine -- acetyl-CoA (ketogenesis)"},
     "B",
     "The glucose-alanine cycle: In muscle, pyruvate (from glycolysis) accepts an amino group from glutamate via ALT, forming alanine. "
     "Alanine is released into blood and taken up by liver. Hepatic ALT reverses the reaction: alanine + alpha-KG -- pyruvate + glutamate. "
     "Pyruvate enters gluconeogenesis (new glucose exported back to muscle). Glutamate is deaminated by GDH or "
     "enters the urea cycle via aspartate. Net effect: safe nitrogen transport from muscle to liver without free NH3 in blood."),

    # --- SECTION C: Clinical Correlates (Q13-20) ---
    (13, "Clinical Correlates",
     "A 2-day-old boy born to a consanguineous couple presents with poor feeding and progressive lethargy. "
     "Urine has a characteristic sweet odor. Plasma amino acid panel shows markedly elevated leucine, isoleucine, "
     "and valine, and a pathognomonic metabolite alloisoleucine is detected. "
     "What is the deficient enzyme and what cofactor, when supplemented, may help in the thiamine-responsive variant?",
     {"A": "Phenylalanine hydroxylase; tetrahydrobiopterin (BH4)",
      "B": "Branched-chain alpha-keto acid dehydrogenase (BCKAD); thiamine (B1)",
      "C": "Cystathionine beta-synthase (CBS); pyridoxine (B6)",
      "D": "Homogentisate oxidase; ascorbic acid (Vitamin C)",
      "E": "Ornithine transcarbamylase (OTC); arginine supplementation"},
     "B",
     "MSUD (Maple Syrup Urine Disease). BCKAD complex (branched-chain alpha-keto acid dehydrogenase) is deficient, "
     "blocking catabolism of BCAAs (Leu, Ile, Val) and their corresponding keto acids. "
     "BCKAD requires thiamine pyrophosphate (TPP) as cofactor; in thiamine-responsive MSUD, high-dose B1 increases residual BCKAD activity. "
     "Alloisoleucine is pathognomonic because BCKAD normally processes its precursor. "
     "Leucine is the primary neurotoxin in MSUD."),

    (14, "Clinical Correlates",
     "A 6-month-old girl has fair hair, fair skin, and blue eyes despite dark-pigmented parents. "
     "She is irritable, has a musty body odor, and is falling behind developmental milestones. "
     "Serum phenylalanine is 1800 umol/L (normal <120). What is the mechanism of hypopigmentation in this condition?",
     {"A": "Excess phenylalanine competitively inhibits DOPA decarboxylase, blocking catecholamine synthesis",
      "B": "PAH deficiency reduces tyrosine availability AND excess phenylalanine competitively inhibits tyrosinase, "
           "reducing melanin synthesis",
      "C": "Phenylpyruvate directly oxidizes melanin granules in melanocytes",
      "D": "Phenylacetate inhibits the enzyme that converts dopa to dopamine, depleting pigment",
      "E": "High phenylalanine upregulates albinism-associated transcription factors"},
     "B",
     "In PKU, PAH cannot convert Phe -- Tyr. Two mechanisms cause hypopigmentation: "
     "(1) Tyrosine depletion -- less substrate for tyrosinase (Tyr -- DOPA -- melanin). "
     "(2) Excess phenylalanine competitively inhibits tyrosinase (Phe and Tyr share structural similarity). "
     "Together, these dramatically reduce melanin production, causing the characteristic fair phenotype in an otherwise dark-complexioned family. "
     "Musty odor = phenylacetate from oxidative decarboxylation of phenylpyruvate."),

    (15, "Clinical Correlates",
     "A 24-year-old man is tall with an arm span exceeding his height, has a lens displaced INFERIORLY, and presents "
     "with an unprovoked deep vein thrombosis. Plasma homocysteine is 280 umol/L. "
     "Which enzyme is deficient and what is the single most important distinguishing feature from Marfan syndrome?",
     {"A": "Fibrillin-1 (FBN1 mutation); Marfan syndrome is autosomal dominant while this condition is recessive",
      "B": "Cystathionine beta-synthase (CBS); lens displaces INFERIORLY (downward) in this condition vs. SUPERIORLY (upward) in Marfan",
      "C": "Methionine synthase (B12-dependent); this condition features thrombosis while Marfan does not",
      "D": "Lysyl oxidase; reduced collagen crosslinking causes lens dislocation in both conditions equally",
      "E": "MTHFR (methylenetetrahydrofolate reductase); detected by plasma folate levels"},
     "B",
     "Homocystinuria due to CBS deficiency. Classic clinical triad: Marfanoid habitus + downward (inferior) lens dislocation + thromboembolism. "
     "The critical differentiator from Marfan syndrome: lens displaces SUPERIORLY in Marfan (fibrillin-1 defect -- zonular fiber weakness from above), "
     "INFERIORLY in homocystinuria (homocysteine disrupts zonular fiber anchoring differently). "
     "Thrombosis occurs because homocysteine damages vascular endothelium and promotes platelet aggregation. "
     "B6 (pyridoxine) is therapeutic in ~50% of CBS-deficient patients."),

    (16, "Clinical Correlates",
     "A 3-year-old boy has recurrent episodes of hyperammonemia and encephalopathy after high-protein meals. "
     "Urine orotic acid is markedly elevated. Plasma citrulline is undetectable. His 3 brothers are all severely affected "
     "but his mother has only mild symptoms. Which enzyme is deficient and why is this inheritance pattern expected?",
     {"A": "CPS-I -- autosomal recessive; severe in both sexes equally; orotic acid low",
      "B": "OTC -- X-linked recessive; males (XY) severely affected; females (XX) have variable symptoms due to random X-inactivation",
      "C": "ASS -- autosomal recessive; citrulline elevated (not absent); affects both sexes",
      "D": "Arginase -- autosomal recessive; arginine elevated; spastic diplegia more common than encephalopathy",
      "E": "GDH -- autosomal dominant; hyperammonemia + hyperinsulinism; not triggered by protein"},
     "B",
     "OTC (ornithine transcarbamylase) deficiency -- the most common urea cycle disorder. X-linked recessive. "
     "Males (hemizygous XY) have severe neonatal/infantile presentation. Females (heterozygous XX) have variable symptoms "
     "depending on random X-inactivation in hepatocytes (lyonization). "
     "Key lab pattern: absent citrulline (OTC step 2 fails -- no citrulline produced) + elevated orotic acid "
     "(excess carbamoyl phosphate diverted to pyrimidine synthesis -- orotic acid). "
     "CPS-I deficiency has LOW orotic acid -- this distinction is board-critical."),

    (17, "Clinical Correlates",
     "A 35-year-old man develops progressive darkening of his ear cartilage and sclera (ochronosis). "
     "His urine turns dark brown/black on standing. X-rays show calcification of intervertebral discs. "
     "Urine chromatography identifies homogentisic acid. Which enzyme is deficient and "
     "what is the underlying metabolic pathway?",
     {"A": "Fumarylacetoacetate hydrolase (FAH); blocked at the last step of tyrosine catabolism -- tyrosinemia type I",
      "B": "Homogentisate oxidase (HGD); blocked in the tyrosine/phenylalanine degradation pathway -- homogentisic acid accumulates",
      "C": "4-hydroxyphenylpyruvate dioxygenase (HPPD); nitisinone is its inhibitor used in treatment of this exact enzyme",
      "D": "Tyrosine aminotransferase (TAT); blocked at first step of tyrosine catabolism -- tyrosinemia type II",
      "E": "Maleylacetoacetate isomerase; blocked at penultimate step -- maleylacetoacetate in urine"},
     "B",
     "Alkaptonuria. Homogentisate oxidase (HGD) deficiency blocks tyrosine catabolism at the homogentisic acid step. "
     "Pathway: Phe -- Tyr -- 4-hydroxyphenylpyruvate -- Homogentisate [BLOCKED] -- Maleylacetoacetate -- Fumarylacetoacetate -- Fumarate + Acetoacetate. "
     "Accumulated homogentisic acid undergoes oxidative polymerization to a dark benzoquinone acetic acid polymer (ochronosis). "
     "Urine darkening on standing is due to spontaneous oxidation/polymerization. Treatment: nitisinone (inhibits HPPD, the step before HGD)."),

    (18, "Clinical Correlates",
     "A 10-year-old girl has recurrent bouts of photosensitive rash resembling pellagra, cerebellar ataxia, "
     "and psychiatric symptoms -- occurring especially after sun exposure or fasting. "
     "Urine amino acid analysis shows elevated neutral amino acids (especially tryptophan). "
     "Plasma amino acid levels are NORMAL. What is the diagnosis?",
     {"A": "Phenylketonuria -- PAH deficiency blocks Trp metabolism secondarily",
      "B": "Hartnup disease -- defective neutral amino acid transporter (SLC6A19) in intestine and renal tubules",
      "C": "Pellagra -- primary niacin (B3) deficiency from inadequate dietary intake",
      "D": "Tyrosinemia type II -- corneal plaques and palmar hyperkeratosis predominate",
      "E": "Tryptophanuria -- isolated tryptophan decarboxylase deficiency"},
     "B",
     "Hartnup disease. SLC6A19 (neutral brush border amino acid transporter) is defective in intestinal epithelium and renal proximal tubules. "
     "Tryptophan malabsorption -- niacin (NAD+ precursor) deficiency -- pellagra-like symptoms. "
     "Normal plasma levels result because the intestinal defect limits absorption but hepatic Trp metabolism partially compensates; "
     "the renal defect causes urinary loss (aminoaciduria). Normal MMA and homocysteine rule out B12 deficiency. "
     "Treatment: oral niacin supplementation + high-protein diet."),

    (19, "Clinical Correlates",
     "A 2-year-old presents with Fanconi syndrome (glucosuria with normal blood glucose, phosphaturia, aminoaciduria), "
     "hepatomegaly, elevated AFP, and a 'boiled cabbage' odor. Urine succinylacetone is detected. "
     "What is the primary enzyme deficiency and why does succinylacetone cause renal tubular toxicity?",
     {"A": "Fumarylacetoacetate hydrolase (FAH); succinylacetone inhibits ALA-D, causing secondary porphyria, and is "
           "directly toxic to proximal renal tubule cells, causing Fanconi syndrome",
      "B": "Homogentisate oxidase (HGD); succinylacetone inhibits collagen hydroxylation in tubular basement membranes",
      "C": "CBS; elevated homocysteine damages renal tubular endothelium via oxidative stress",
      "D": "PAH; phenylpyruvate accumulates in tubules and competitively inhibits renal glucose transporters",
      "E": "BCKAD; branched-chain keto acids acidify tubular fluid, impairing phosphate reabsorption"},
     "A",
     "Tyrosinemia Type I (hepatorenal tyrosinemia). FAH deficiency -- fumarylacetoacetate accumulates -- "
     "spontaneous conversion to succinylacetone. Succinylacetone: "
     "(1) Inhibits delta-ALA dehydratase (ALA-D) -- porphyria-like crises "
     "(2) Directly toxic to proximal renal tubule cells -- Fanconi syndrome (defective reabsorption of glucose, phosphate, AAs, urate, bicarb) "
     "(3) Promotes hepatocellular carcinoma (childhood HCC). "
     "Succinylacetone in urine is PATHOGNOMONIC. Treatment: nitisinone (NTBC) + dietary Phe/Tyr restriction; curative with liver transplant."),

    (20, "Clinical Correlates",
     "A patient has megaloblastic anemia, elevated plasma homocysteine, and elevated methylmalonic acid (MMA). "
     "A second patient has megaloblastic anemia and elevated homocysteine but NORMAL MMA. "
     "Which vitamin deficiency explains each patient respectively?",
     {"A": "Patient 1: Folate deficiency; Patient 2: B12 deficiency",
      "B": "Patient 1: B12 deficiency; Patient 2: Folate deficiency",
      "C": "Patient 1: B6 deficiency; Patient 2: B12 deficiency",
      "D": "Patient 1: B12 deficiency; Patient 2: B6 deficiency",
      "E": "Both patients: B12 deficiency at different stages of progression"},
     "B",
     "Patient 1 (elevated MMA + homocysteine): B12 (cobalamin) deficiency. "
     "B12 is required for TWO reactions: (1) Methylmalonyl-CoA mutase (MMA -- succinyl-CoA) -- MMA rises when B12 is low. "
     "(2) Methionine synthase (homocysteine + 5-methyl-THF -- Met) -- homocysteine rises. "
     "Patient 2 (elevated homocysteine, normal MMA): Folate (B9) deficiency. "
     "Folate provides 5-methyl-THF for homocysteine remethylation, but folate has no role in MMA metabolism. "
     "BOARD PEARL: Always check MMA to distinguish B12 vs. folate. Treating B12 deficiency with folate alone will correct anemia but allow subacute combined degeneration of spinal cord to progress undetected."),

    # --- SECTION D: Integrative/Challenging (Q21-25) ---
    (21, "Integrative & High-Yield",
     "A patient with cirrhosis develops hepatic encephalopathy after a high-protein meal. "
     "Serum ammonia is 180 umol/L (normal <50). "
     "Which of the following mechanisms BEST explains why protein ingestion triggers encephalopathy in liver disease?",
     {"A": "Excess dietary protein is directly converted to ammonia by intestinal bacteria; "
           "the damaged liver cannot adequately convert NH3 -- urea in the urea cycle",
      "B": "High protein diet causes osmotic diarrhea, depleting electrolytes and causing metabolic alkalosis",
      "C": "Branched-chain amino acids compete with aromatic AAs for entry into the brain, causing dopamine excess",
      "D": "Glutamine synthetase is overactivated in astrocytes, depleting glutamate and causing neurotransmitter imbalance",
      "E": "Dietary protein increases portal pressure, shunting blood away from hepatocytes and reducing urea synthesis"},
     "A",
     "Ammonia is generated by intestinal bacteria (urease on dietary proteins/urea) and by amino acid deamination. "
     "The liver normally converts NH3 to urea (urea cycle) and glutamine (glutamine synthetase). "
     "In cirrhosis: portosystemic shunting bypasses the liver; reduced hepatocyte mass impairs urea synthesis. "
     "NH3 enters the CNS -- astrocytes detoxify it by converting glutamate -- glutamine (glutamine synthetase). "
     "Astrocyte swelling from glutamine accumulation (osmotic effect) disrupts neurotransmission. "
     "Treatments: lactulose (traps NH4+ in colon), rifaximin (reduces intestinal bacteria), dietary protein restriction."),

    (22, "Integrative & High-Yield",
     "A 32-year-old woman with recurrent kidney stones passes a stone. Stone analysis shows cystine crystals. "
     "Urinalysis shows hexagonal crystals. Which of the following CORRECTLY describes the pathophysiology?",
     {"A": "Cystine is produced in excess due to overactive CBS, causing overflow aminoaciduria",
      "B": "SLC3A1/SLC7A9 transporter defect impairs reabsorption of COAL amino acids (Cystine, Ornithine, Arginine, Lysine) "
           "in renal proximal tubules, causing cystine to precipitate at urine pH",
      "C": "Cystinosis: defective lysosomal cystine transporter (CTNS) causes cystine accumulation inside cells",
      "D": "Cystine stones form because of vitamin C deficiency reducing cystine solubility",
      "E": "Excess methionine is converted to cystine in renal tubules, which precipitates at acid pH"},
     "B",
     "Cystinuria (NOT cystinosis -- a common confusion). Defective SLC3A1 or SLC7A9 transporter in renal proximal tubule "
     "and intestinal brush border impairs reabsorption of dibasic amino acids: Cystine, Ornithine, Arginine, Lysine (COAL). "
     "Only cystine is sparingly soluble at normal urine pH, forming hexagonal crystals and staghorn calculi. "
     "Note: Cystinosis is a completely separate disease -- CTNS lysosomal transporter defect -- causing intracellular cystine accumulation "
     "and Fanconi syndrome. Treatment of cystinuria: high fluid intake, urine alkalinization (pH >7.5), D-penicillamine or tiopronin."),

    (23, "Integrative & High-Yield",
     "A newborn screening program detects elevated phenylalanine on day 3 of life. "
     "Further testing shows LOW biopterin and elevated dihydrobiopterin (BH2) in urine, despite normal PAH enzyme. "
     "The infant also has low serotonin and low dopamine. "
     "What is the most likely diagnosis and why is dietary Phe restriction alone INSUFFICIENT?",
     {"A": "Classic PKU -- PAH is normal so diet alone is sufficient; retest at 2 weeks",
      "B": "BH4-deficient hyperphenylalaninemia (e.g., DHPR or GTPCH deficiency); "
           "BH4 is required not only by PAH but also by tyrosine hydroxylase and tryptophan hydroxylase, "
           "so neurotransmitter deficiencies (dopamine, serotonin) persist even if Phe is controlled",
      "C": "Tyrosinemia type II -- Tyr accumulates rather than Phe",
      "D": "Hartnup disease -- neutral amino acid transporter deficiency reduces Trp and secondarily impairs monoamine synthesis",
      "E": "MSUD -- the BCAAs compete with Phe for the large neutral amino acid transporter at the blood-brain barrier"},
     "B",
     "BH4-deficient PKU (malignant hyperphenylalaninemia). BH4 (tetrahydrobiopterin) is a cofactor for: "
     "(1) PAH (Phe -- Tyr), (2) Tyrosine hydroxylase (Tyr -- L-DOPA -- dopamine -- NE -- Epi), "
     "(3) Tryptophan hydroxylase (Trp -- 5-HTP -- serotonin). "
     "BH4 deficiency (from DHPR, GTPCH, PTPS deficiencies) impairs ALL three pathways. "
     "Even if Phe restriction normalizes plasma Phe, neurotransmitter synthesis remains impaired. "
     "Treatment: BH4 supplementation (sapropterin) + L-DOPA + 5-HTP (to bypass the hydroxylase steps)."),

    (24, "Integrative & High-Yield",
     "A medical student is studying why arginine is considered conditionally essential. "
     "Which of the following BEST explains arginine's metabolic importance beyond the urea cycle?",
     {"A": "Arginine is the sole precursor for creatine, polyamines (spermine/spermidine), and nitric oxide (NO); "
           "it is conditionally essential because biosynthesis may be insufficient during rapid growth, "
           "critical illness, or sepsis",
      "B": "Arginine is essential because humans lack arginase, requiring dietary arginine for urea cycle function",
      "C": "Arginine is the nitrogen donor for all pyrimidines and purines via carbamoyl phosphate synthesis",
      "D": "Arginine conditionally activates glucagon secretion, making it essential during hypoglycemia",
      "E": "Arginine is conditionally essential because it can only be synthesized from proline in the kidney"},
     "A",
     "Arginine is a metabolic hub beyond the urea cycle: "
     "(1) NO production: arginine + O2 -- NO + citrulline (NOS; 3 isoforms: eNOS, nNOS, iNOS). NO is critical for vasodilation, "
     "neurotransmission, and immune killing. Sepsis consumes massive amounts of Arg via iNOS. "
     "(2) Creatine: Arg + Gly -- guanidinoacetate -- Cr (in kidney/liver); stored as phosphocreatine in muscle. "
     "(3) Polyamines (putrescine, spermidine, spermine): via ornithine decarboxylase; regulate cell proliferation. "
     "Conditionally essential in neonates (immature urea cycle), rapid growth, wound healing, and critical illness."),

    (25, "Integrative & High-Yield",
     "USMLE-style integration: A 4-year-old presents with progressive spastic diplegia, seizures, and elevated serum arginine. "
     "He has no history of acute hyperammonemia crises, which differentiates him from other urea cycle defects. "
     "A different 6-month-old presents with profound hyperammonemia, absent plasma citrulline, and elevated orotic acid. "
     "A third patient has hyperammonemia with ELEVATED citrulline and normal orotic acid. "
     "Match each patient to the correct urea cycle enzyme deficiency.",
     {"A": "Patient 1: ASS; Patient 2: OTC; Patient 3: Arginase",
      "B": "Patient 1: Arginase; Patient 2: OTC; Patient 3: ASS",
      "C": "Patient 1: OTC; Patient 2: Arginase; Patient 3: CPS-I",
      "D": "Patient 1: ASL; Patient 2: CPS-I; Patient 3: OTC",
      "E": "Patient 1: CPS-I; Patient 2: ASS; Patient 3: OTC"},
     "B",
     "Patient 1 (spastic diplegia + elevated arginine, no acute hyperammonemia): ARGINASE deficiency. "
     "Arginase cleaves arginine -- ornithine + urea. Arginine accumulates and is neurotoxic (progressive spastic diplegia, seizures). "
     "Unlike other urea cycle defects, hyperammonemia is mild/absent because upstream steps still partially function. "
     "Patient 2 (profound hyperammonemia, ABSENT citrulline, elevated orotic acid): OTC deficiency. "
     "OTC step 2 fails -- no citrulline made. Excess carbamoyl phosphate -- pyrimidine synthesis -- orotic acid elevated. X-linked. "
     "Patient 3 (hyperammonemia, ELEVATED citrulline, normal orotic acid): ASS deficiency (Citrullinemia type I). "
     "Citrulline accumulates because ASS cannot condense citrulline + aspartate -- argininosuccinate. "
     "Normal orotic acid because OTC is intact and carbamoyl phosphate is being consumed normally."),
]

story = []

# ── COVER ──────────────────────────────────────────────────────
cover_data = [[
    Paragraph("Amino Acid Metabolism", sTitle),
    Paragraph("Summary Examination", sTitle),
    Spacer(1, 6),
    HRFlowable(width=W*0.4, thickness=2, color=TEAL, spaceAfter=4),
    Paragraph("25 Multiple-Choice Questions with Full Explanations", sSubtitle),
    Paragraph("Classification -- Metabolism -- Clinical Correlates -- Integrative Cases", sSubtitle),
    Spacer(1, 8),
    Paragraph("Instructions: Select the single best answer (A-E). "
              "Answers and detailed explanations follow each question. "
              "Estimated time: 35-45 minutes (90 seconds per question).",
              S("inst", fontSize=9, textColor=colors.HexColor("#7FB3D3"),
                fontName="Helvetica", alignment=TA_CENTER, leading=13)),
]]
cover_tbl = Table(cover_data, colWidths=[W])
cover_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), NAVY),
    ("TOPPADDING",   (0,0), (-1,-1), 24),
    ("BOTTOMPADDING",(0,0), (-1,-1), 24),
    ("LEFTPADDING",  (0,0), (-1,-1), 20),
    ("RIGHTPADDING", (0,0), (-1,-1), 20),
]))
story.append(cover_tbl)
story.append(Spacer(1, 12))

# Score box
score_data = [[
    Paragraph(b("Score: _____ / 25"), S("sc1", fontSize=12, textColor=NAVY, fontName="Helvetica-Bold", leading=15)),
    Paragraph("24-25: Distinction  |  20-23: Pass  |  15-19: Review needed  |  <15: Re-study",
              S("sc2", fontSize=9, textColor=MUTEDTEXT, fontName="Helvetica", leading=13)),
]]
st = Table(score_data, colWidths=[W*0.30, W*0.70])
st.setStyle(TableStyle([
    ("BACKGROUND",   (0,0), (-1,-1), LIGHTGRAY),
    ("GRID",         (0,0), (-1,-1), 0.5, MIDGRAY),
    ("LEFTPADDING",  (0,0), (-1,-1), 10),
    ("TOPPADDING",   (0,0), (-1,-1), 6),
    ("BOTTOMPADDING",(0,0), (-1,-1), 6),
    ("VALIGN",       (0,0), (-1,-1), "MIDDLE"),
]))
story.append(st)
story.append(Spacer(1, 10))

# ── QUESTION BLOCKS ─────────────────────────────────────────────
sections = {
    "Classification & Structure": ("Q1-5", BLUE),
    "Metabolism & Enzymes":       ("Q6-12", GREEN),
    "Clinical Correlates":        ("Q13-20", RED),
    "Integrative & High-Yield":   ("Q21-25", PURPLE),
}
current_section = None

for (num, section, vignette, options, correct, explanation) in questions:
    # Section header
    if section != current_section:
        current_section = section
        qrange, col = sections[section]
        story.append(Spacer(1, 6))
        story.append(section_header(f"{section.upper()}  ({qrange})", col))
        story.append(Spacer(1, 6))

    # Q block
    q_elems = []
    # Question number badge + vignette
    q_elems.append(Paragraph(f"Question {num}", S("qn", fontSize=9, textColor=WHITE,
                                                    fontName="Helvetica-Bold", leading=11)))
    qhdr = Table([[Paragraph(f"Question {num}", S("qnh", fontSize=9, textColor=WHITE,
                                                    fontName="Helvetica-Bold", leading=11))]],
                 colWidths=[W])
    qhdr.setStyle(TableStyle([
        ("BACKGROUND",   (0,0), (-1,-1), colors.HexColor("#2C3E50")),
        ("LEFTPADDING",  (0,0), (-1,-1), 8),
        ("TOPPADDING",   (0,0), (-1,-1), 3),
        ("BOTTOMPADDING",(0,0), (-1,-1), 3),
    ]))
    q_elems.append(qhdr)
    q_elems.append(Paragraph(vignette, sQBody))
    q_elems.append(Spacer(1, 3))

    # Options
    opt_rows = []
    for key in ["A", "B", "C", "D", "E"]:
        is_correct = (key == correct)
        bg = colors.HexColor("#D5F5E3") if is_correct else WHITE
        lbl_color = colors.HexColor("#1A6B40") if is_correct else MUTEDTEXT
        marker = " CORRECT" if is_correct else ""
        opt_rows.append([
            Paragraph(f"{key}{marker}", S(f"optk{key}", fontSize=8.5, textColor=lbl_color,
                                          fontName="Helvetica-Bold", leading=12)),
            Paragraph(options[key], S(f"optv{key}", fontSize=8.5, textColor=DARKTEXT,
                                      fontName="Helvetica", leading=12)),
        ])
    opt_tbl = Table(opt_rows, colWidths=[W*0.11, W*0.89])
    row_colors = []
    for i, key in enumerate(["A","B","C","D","E"]):
        if key == correct:
            row_colors.append(("BACKGROUND", (0,i), (-1,i), colors.HexColor("#D5F5E3")))
    opt_tbl.setStyle(TableStyle([
        ("GRID",         (0,0), (-1,-1), 0.3, MIDGRAY),
        ("LEFTPADDING",  (0,0), (-1,-1), 6),
        ("TOPPADDING",   (0,0), (-1,-1), 3),
        ("BOTTOMPADDING",(0,0), (-1,-1), 3),
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
        ("ROWBACKGROUNDS",(0,0), (-1,-1), [WHITE, LIGHTGRAY]),
    ] + row_colors))
    q_elems.append(opt_tbl)

    # Explanation box
    exp_rows = [[
        Paragraph("EXPLANATION", S("exhdr", fontSize=8, textColor=WHITE,
                                    fontName="Helvetica-Bold", leading=10)),
        Paragraph(f"Answer: {correct} -- {explanation}",
                  S("exbdy", fontSize=8.5, textColor=colors.HexColor("#0B3D1E"),
                    fontName="Helvetica", leading=12)),
    ]]
    exp_tbl = Table(exp_rows, colWidths=[W*0.13, W*0.87])
    exp_tbl.setStyle(TableStyle([
        ("BACKGROUND",   (0,0), (0,-1), colors.HexColor("#1A6B40")),
        ("BACKGROUND",   (1,0), (1,-1), ANSWERGREEN),
        ("GRID",         (0,0), (-1,-1), 0.3, colors.HexColor("#82C9A0")),
        ("LEFTPADDING",  (0,0), (-1,-1), 6),
        ("TOPPADDING",   (0,0), (-1,-1), 4),
        ("BOTTOMPADDING",(0,0), (-1,-1), 4),
        ("VALIGN",       (0,0), (-1,-1), "TOP"),
    ]))
    q_elems.append(Spacer(1, 3))
    q_elems.append(exp_tbl)
    q_elems.append(Spacer(1, 8))

    story.append(KeepTogether(q_elems))

# ── ANSWER KEY SUMMARY ──────────────────────────────────────────
story.append(PageBreak())
story.append(section_header("ANSWER KEY SUMMARY", NAVY))
story.append(Spacer(1, 6))

ak_rows = [[
    Paragraph(b("Q"), sLabel), Paragraph(b("Ans"), sLabel),
    Paragraph(b("Topic"), sLabel), Paragraph(b("Key Concept"), sLabel),
]]
for (num, section, vignette, options, correct, explanation) in questions:
    short_exp = explanation.split(".")[0] + "."
    ak_rows.append([str(num), correct,
                    section.replace(" & ", "/"),
                    Paragraph(short_exp, S(f"akb{num}", fontSize=7.5, textColor=DARKTEXT,
                                           fontName="Helvetica", leading=11))])

ak_tbl = Table(ak_rows, colWidths=[W*0.05, W*0.06, W*0.22, W*0.67])
ak_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0),  NAVY),
    ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
    ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
    ("FONTSIZE",      (0,1), (-1,-1), 7.5),
    ("FONTNAME",      (0,1), (-1,-1), "Helvetica"),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [LIGHTGRAY, WHITE]),
    ("GRID",          (0,0), (-1,-1), 0.3, MIDGRAY),
    ("LEFTPADDING",   (0,0), (-1,-1), 4),
    ("TOPPADDING",    (0,0), (-1,-1), 2),
    ("BOTTOMPADDING", (0,0), (-1,-1), 2),
    ("VALIGN",        (0,0), (-1,-1), "TOP"),
    ("ALIGN",         (0,0), (1,-1),  "CENTER"),
]))
story.append(ak_tbl)

story.append(Spacer(1, 10))
story.append(HRFlowable(width=W, thickness=0.5, color=MIDGRAY))
story.append(Paragraph(
    "Amino Acid Metabolism Summary Exam -- 25 Questions -- Biochemistry / USMLE Step 1 Preparation",
    S("foot", fontSize=7.5, textColor=MUTEDTEXT, fontName="Helvetica-Oblique",
      alignment=TA_CENTER, leading=11)))

doc.build(story)
size = os.path.getsize(out_path)
print(f"PDF created: {out_path}  ({size//1024} KB)")
Running Command

python3 /home/daytona/workspace/biochem-slides/build_exam.py

Editing File

~/biochem-slides/build_exam.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/biochem-slides/build_exam.py'
Running Command

python3 /home/daytona/workspace/biochem-slides/build_exam.py

Your exam is ready:

AA Summary Exam 25Q

PDF Document · PDF


Exam structure (25 questions, 4 sections):
SectionQsColorFocus
Classification & StructureQ1-5BlueChirality, pKa, UV absorption, albumin binding, structural properties
Metabolism & EnzymesQ6-12GreenALT/AST roles, PLP cofactor, glucogenic/ketogenic AAs, CPS-I activation, homocysteine disposal, GDH regulation, glucose-alanine cycle
Clinical CorrelatesQ13-20RedMSUD, PKU (mechanism of hypopigmentation), Homocystinuria vs Marfan, OTC deficiency, Alkaptonuria, Hartnup, Tyrosinemia I, B12 vs Folate distinction
Integrative & High-YieldQ21-25PurpleHepatic encephalopathy mechanism, Cystinuria vs Cystinosis, BH4-deficient PKU, Arginine as metabolic hub, Urea cycle enzyme mapping (3 patients simultaneously)
Every question includes:
  • USMLE-style vignette stem
  • 5 answer options (A-E) with the correct answer highlighted in green
  • Detailed explanation covering the mechanism, clinical pearls, and common distractors
Final page: Answer key summary table (all 25 answers + first-line explanation in one view)
Scoring guide: 24-25 = Distinction, 20-23 = Pass, 15-19 = Review needed, <15 = Re-study
This is a shared conversation. Sign in to Orris to start your own chat.