Make a pdf for presentation in class on topic hyperammonemia 1 disorder . Explain proper mechanism about its biochemistry and treatment plan
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace not found"
mkdir -p /home/daytona/workspace/hyperammonemia-pdf && python3 - << 'EOF' import…
~/hyperammonemia-pdf/build_pdf.py
"""
Build a class presentation PDF on Hyperammonemia (Type 1 – Urea Cycle Disorders)
using ReportLab.
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, Image, KeepTogether, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import Flowable
import os
ASSETS = "/home/daytona/workspace/hyperammonemia-pdf/assets"
OUT = "/home/daytona/workspace/hyperammonemia-pdf/Hyperammonemia_Type1_Presentation.pdf"
# ─── COLOURS ────────────────────────────────────────────────────────────────
DEEP_BLUE = colors.HexColor("#1A3A5C")
MED_BLUE = colors.HexColor("#2E6DA4")
ACCENT = colors.HexColor("#E8451F")
LIGHT_BLUE = colors.HexColor("#D9E8F5")
PALE_GREY = colors.HexColor("#F4F6F8")
WHITE = colors.white
# ─── STYLES ─────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def style(name, **kw):
return ParagraphStyle(name, **kw)
TITLE_S = style("title_s", fontSize=28, textColor=WHITE, alignment=TA_CENTER,
fontName="Helvetica-Bold", leading=34, spaceAfter=6)
SUB_S = style("sub_s", fontSize=14, textColor=LIGHT_BLUE, alignment=TA_CENTER,
fontName="Helvetica", leading=18)
H1_S = style("h1_s", fontSize=18, textColor=DEEP_BLUE, fontName="Helvetica-Bold",
leading=22, spaceAfter=6, spaceBefore=10)
H2_S = style("h2_s", fontSize=13, textColor=MED_BLUE, fontName="Helvetica-Bold",
leading=17, spaceAfter=4, spaceBefore=8)
BODY_S = style("body_s", fontSize=10, textColor=colors.HexColor("#1A1A1A"),
fontName="Helvetica", leading=15, spaceAfter=4, alignment=TA_JUSTIFY)
BULLET_S = style("bullet_s", fontSize=10, textColor=colors.HexColor("#1A1A1A"),
fontName="Helvetica", leading=14, spaceAfter=3, leftIndent=14,
bulletIndent=4)
CAPTION_S = style("caption_s", fontSize=8, textColor=colors.grey,
fontName="Helvetica-Oblique", alignment=TA_CENTER, spaceAfter=6)
FOOTER_S = style("footer_s", fontSize=7, textColor=colors.grey,
fontName="Helvetica", alignment=TA_CENTER)
BOX_S = style("box_s", fontSize=10, textColor=DEEP_BLUE, fontName="Helvetica-Bold",
leading=14, spaceAfter=3, alignment=TA_CENTER)
REF_S = style("ref_s", fontSize=8, textColor=colors.grey, fontName="Helvetica-Oblique",
leading=11, spaceAfter=2)
# ─── HELPERS ────────────────────────────────────────────────────────────────
def hline(color=MED_BLUE, thickness=1):
return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=6, spaceBefore=2)
def section_header(text):
return [
hline(DEEP_BLUE, 2),
Paragraph(text, H1_S),
hline(MED_BLUE, 0.5),
Spacer(1, 6),
]
def bullet(text):
return Paragraph(f"<bullet>\u2022</bullet> {text}", BULLET_S)
def sub_bullet(text):
return Paragraph(f"<bullet>\u2013</bullet> {text}",
ParagraphStyle("sb", parent=BULLET_S, leftIndent=28, bulletIndent=18,
fontSize=9))
def img(fname, width_cm=12):
path = os.path.join(ASSETS, fname)
return Image(path, width=width_cm*cm, height=None, kind='proportional')
def colored_table_row(label, value, color=LIGHT_BLUE):
return [Paragraph(f"<b>{label}</b>", BODY_S), Paragraph(value, BODY_S)]
# ─── PAGE TEMPLATE ──────────────────────────────────────────────────────────
def on_page(canvas, doc):
W, H = A4
# Header bar
canvas.setFillColor(DEEP_BLUE)
canvas.rect(0, H - 1.1*cm, W, 1.1*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 9)
canvas.drawString(1*cm, H - 0.75*cm, "HYPERAMMONEMIA — TYPE 1: UREA CYCLE DISORDERS")
canvas.setFont("Helvetica", 9)
canvas.drawRightString(W - 1*cm, H - 0.75*cm, f"Page {doc.page}")
# Footer bar
canvas.setFillColor(DEEP_BLUE)
canvas.rect(0, 0, W, 0.7*cm, fill=1, stroke=0)
canvas.setFillColor(colors.HexColor("#A0B8D0"))
canvas.setFont("Helvetica-Oblique", 7)
canvas.drawCentredString(W/2, 0.22*cm,
"Sources: Lippincott Illustrated Reviews Biochemistry 8e · Sleisenger & Fordtran GI & Liver Disease · Adams & Victor's Neurology 12e")
# ─── COVER PAGE ─────────────────────────────────────────────────────────────
def cover_page():
W, H = A4
story = []
class CoverBg(Flowable):
def draw(self):
c = self.canv
W2, H2 = A4
c.setFillColor(DEEP_BLUE)
c.rect(0, 0, W2, H2, fill=1, stroke=0)
c.setFillColor(MED_BLUE)
c.rect(0, H2*0.35, W2, H2*0.30, fill=1, stroke=0)
c.setFillColor(ACCENT)
c.rect(0, H2*0.35, W2, 0.4*cm, fill=1, stroke=0)
c.rect(0, H2*0.65, W2, 0.4*cm, fill=1, stroke=0)
def wrap(self, availW, availH):
return (0, 0)
story.append(CoverBg())
story.append(Spacer(1, 6*cm))
story.append(Paragraph("HYPERAMMONEMIA", TITLE_S))
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("TYPE 1: UREA CYCLE DISORDERS", style("cov2", fontSize=20,
textColor=colors.HexColor("#FFD700"), alignment=TA_CENTER,
fontName="Helvetica-Bold", leading=26)))
story.append(Spacer(1, 0.5*cm))
story.append(Paragraph("Biochemistry · Pathophysiology · Clinical Features · Treatment",
SUB_S))
story.append(Spacer(1, 1.2*cm))
story.append(hline(ACCENT, 2))
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("A Comprehensive Class Presentation",
style("cp", fontSize=12, textColor=colors.HexColor("#A8C8E8"),
alignment=TA_CENTER, fontName="Helvetica-Oblique")))
story.append(PageBreak())
return story
# ─── SLIDE-LIKE SECTIONS ────────────────────────────────────────────────────
def slide_overview():
s = []
s += section_header("1. OVERVIEW & DEFINITION")
s.append(Paragraph(
"Hyperammonemia is a metabolic condition characterised by excess ammonia (NH₃/NH₄⁺) "
"in the blood. Normal plasma ammonia: <b>5–35 µmol/L</b>. Levels can exceed "
"<b>1,000 µmol/L</b> in severe disease, constituting a medical emergency due to "
"direct CNS neurotoxicity.",
BODY_S))
s.append(Spacer(1, 6))
# Two-column key facts box
data = [
[Paragraph("<b>Normal NH₃</b>", BOX_S), Paragraph("5–35 µmol/L", BODY_S)],
[Paragraph("<b>Danger threshold</b>", BOX_S), Paragraph(">100–200 µmol/L (adults); >150 µmol/L (neonates)", BODY_S)],
[Paragraph("<b>Emergency level</b>", BOX_S), Paragraph(">500 µmol/L — coma / death risk", BODY_S)],
[Paragraph("<b>Inheritance (UCDs)</b>", BOX_S), Paragraph("Mostly autosomal recessive; OTC deficiency is X-linked", BODY_S)],
[Paragraph("<b>Incidence (UCDs)</b>", BOX_S), Paragraph("~1 : 25,000 live births (combined)", BODY_S)],
]
t = Table(data, colWidths=[5.5*cm, 11*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,-1), LIGHT_BLUE),
('BACKGROUND', (1,0), (1,-1), PALE_GREY),
('GRID', (0,0), (-1,-1), 0.5, colors.HexColor("#B0C4DE")),
('FONTNAME', (0,0), (-1,-1), 'Helvetica'),
('FONTSIZE', (0,0), (-1,-1), 10),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 8),
]))
s.append(t)
s.append(Spacer(1, 8))
s.append(Paragraph("Two Major Categories:", H2_S))
s.append(bullet("<b>Acquired</b> – Liver disease (viral hepatitis, alcohol-induced cirrhosis, "
"NAFLD/NASH). Portosystemic shunting bypasses hepatic urea synthesis."))
s.append(bullet("<b>Congenital (Type 1)</b> – Genetic deficiency of any one of the five "
"urea cycle enzymes, or of N-acetylglutamate synthase (NAGS). "
"This presentation focuses on congenital Type 1."))
s.append(Spacer(1, 4))
s.append(Paragraph("<i>Source: Lippincott Illustrated Reviews: Biochemistry, 8th ed., p. 722–727</i>", REF_S))
return s
def slide_normal_urea_cycle():
s = []
s += section_header("2. NORMAL UREA CYCLE — BIOCHEMISTRY")
s.append(Paragraph(
"The urea cycle (Krebs-Henseleit cycle) is the primary pathway for disposing of "
"waste nitrogen from amino acid catabolism. It operates across two compartments — "
"<b>mitochondria</b> and <b>cytosol</b> — exclusively in hepatocytes.",
BODY_S))
s.append(Spacer(1, 4))
# Steps table
steps = [
["Step", "Enzyme", "Location", "Reaction"],
["1", "NAGS\n(N-acetylglutamate synthase)", "Mitochondria", "Glutamate + Acetyl-CoA → N-acetylglutamate (activator)"],
["2", "CPS I\n(Carbamoyl phosphate\nsynthetase I)", "Mitochondria", "NH₃ + HCO₃⁻ + 2ATP → Carbamoyl phosphate"],
["3", "OTC\n(Ornithine\ntranscarbamylase)", "Mitochondria", "Carbamoyl-P + Ornithine → Citrulline"],
["4", "ASS\n(Argininosuccinate\nsynthetase)", "Cytosol", "Citrulline + Aspartate + ATP → Argininosuccinate"],
["5", "ASL\n(Argininosuccinate\nlyase)", "Cytosol", "Argininosuccinate → Arginine + Fumarate"],
["6", "Arginase I", "Cytosol", "Arginine + H₂O → Urea + Ornithine (recycled)"],
]
col_w = [1.2*cm, 4.5*cm, 3*cm, 8.8*cm]
t = Table(steps, colWidths=col_w)
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), DEEP_BLUE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, PALE_GREY]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 8),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 5),
]))
s.append(t)
s.append(Spacer(1, 8))
s.append(Paragraph("<b>Net reaction:</b> NH₃ + HCO₃⁻ + 3 ATP + Aspartate → Urea + Fumarate + 2 ADP + AMP + 4 Pᵢ + PPᵢ", BODY_S))
s.append(Spacer(1, 6))
s.append(Paragraph("Key regulatory point: NAGS synthesises N-acetylglutamate, "
"the obligate allosteric activator of CPS I. "
"Without it, the entire cycle halts.", BODY_S))
s.append(Spacer(1, 6))
# image
s.append(img("urea_cycle_detailed.png", 11))
s.append(Paragraph("Fig. 1 — Urea cycle: mitochondrial and cytosolic steps. "
"OTC deficiency shown; excess carbamoyl-P enters pyrimidine synthesis → orotic aciduria. "
"(Lippincott Illustrated Reviews: Biochemistry, 8e)", CAPTION_S))
return s
def slide_pathophysiology():
s = []
s += section_header("3. PATHOPHYSIOLOGY OF HYPERAMMONEMIA")
s.append(Paragraph("<b>How ammonia accumulates in UCD:</b>", H2_S))
s.append(bullet("Enzyme block → upstream intermediates accumulate; cycle stalls → NH₃ not converted to urea"))
s.append(bullet("NH₃ enters systemic circulation; crosses blood-brain barrier readily"))
s.append(bullet("Excess NH₃ consumes α-ketoglutarate (via glutamate dehydrogenase reversal) → depletes TCA cycle intermediates"))
s.append(bullet("NH₃ drives glutamine synthesis in astrocytes → astrocyte swelling → cerebral oedema"))
s.append(bullet("Glutamine accumulation in neurons is osmotically toxic (Alzheimer type II astrocytes)"))
s.append(bullet("Alkalosis: elevated NH₃ drives hyperventilation → respiratory alkalosis"))
s.append(Spacer(1, 6))
s.append(Paragraph("<b>Ammonia Transport Between Tissues:</b>", H2_S))
data2 = [
["Tissue", "Process", "Carrier to liver"],
["Skeletal muscle", "BCAA catabolism → transamination → glutamate\nGlutamate + NH₃ → glutamine (glutamine synthetase)", "Glutamine"],
["Skeletal muscle", "Alanine cycle: pyruvate + glutamate → alanine (ALT)", "Alanine"],
["Gut / kidney", "Glutaminase: glutamine → glutamate + NH₃", "NH₃ direct"],
["Liver (normal)", "Urea cycle converts NH₃ to non-toxic urea → excreted in urine", "—"],
]
t = Table(data2, colWidths=[3.5*cm, 9.5*cm, 4.5*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), MED_BLUE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, PALE_GREY]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 8.5),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 5),
]))
s.append(t)
s.append(Spacer(1, 6))
s.append(Paragraph("<b>CNS Toxicity Cascade:</b>", H2_S))
cascade = [
["↑ NH₃", "→", "↑ Astrocyte glutamine", "→", "Cell swelling"],
["↑ NH₃", "→", "↓ α-KG (TCA)", "→", "Energy failure"],
["↑ NH₃", "→", "↑ GABA activity", "→", "Sedation / coma"],
["↑ NH₃", "→", "Oxidative stress", "→", "Mitochondrial dysfunction"],
]
tc = Table(cascade, colWidths=[3*cm, 0.8*cm, 5*cm, 0.8*cm, 7.9*cm])
tc.setStyle(TableStyle([
('FONTSIZE', (0,0), (-1,-1), 9),
('TEXTCOLOR', (0,0), (0,-1), ACCENT),
('TEXTCOLOR', (4,0), (4,-1), DEEP_BLUE),
('FONTNAME', (0,0), (-1,-1), 'Helvetica'),
('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'),
('TOPPADDING', (0,0), (-1,-1), 3),
('BOTTOMPADDING', (0,0), (-1,-1), 3),
('ROWBACKGROUNDS', (0,0), (-1,-1), [PALE_GREY, WHITE]),
]))
s.append(tc)
s.append(Spacer(1, 4))
s.append(Paragraph("<i>Source: Lippincott Illustrated Reviews: Biochemistry 8e p. 723; Adams & Victor's Neurology 12e</i>", REF_S))
return s
def slide_enzyme_deficiencies():
s = []
s += section_header("4. SPECIFIC ENZYME DEFICIENCIES — TYPE 1 UCDs")
defects = [
["Enzyme\nDeficiency", "Inheritance", "Lab Markers", "Key Features"],
["CPS I\n(Carbamoyl phosphate\nsynthetase I)", "AR", "↓ citrulline, ↓ arginine\n↑ NH₃\nNormal orotic acid", "Neonatal hyperammonemic coma;\nno orotic acid distinguishes from OTC"],
["OTC\n(Ornithine\ntranscarbamylase)", "X-linked\n(most common UCD)", "↓ citrulline, ↓ arginine\n↑ NH₃\n↑ Urinary orotic acid", "Most common UCD (~1:14,000);\nFemale carriers may be symptomatic;\norotic aciduria is hallmark"],
["ASS\n(Argininosuccinate\nsynthetase)", "AR\n(Citrullinemia I)", "↑ citrulline (marked)\n↑ NH₃\nNormal argininosuccinate", "Citrullinemia type 1;\nneonatal acute / mild late-onset forms;\ndetected on newborn screening"],
["ASL\n(Argininosuccinate\nlyase)", "AR", "↑ argininosuccinate\n↑ citrulline\n↑ NH₃", "Argininosuccinic aciduria;\nneurologic abnormalities;\ndiagnosed by urine organic acids"],
["Arginase I", "AR\n(Argininemia)", "↑ arginine\nMild ↑ NH₃\n↑ Orotic acid", "Hyperammonemia less severe\n(2 N atoms excreted per arginine);\nnormal early development then\nprogressive spastic diplegia"],
["NAGS\n(N-acetylglutamate\nsynthase)", "AR", "↓ CPS I activity\n↑ NH₃\n↓ N-acetylglutamate", "Rare; CPS I cannot be activated;\ntreated with carglumic acid\n(synthetic NAG analogue)"],
]
col_w = [3.5*cm, 2.5*cm, 5.5*cm, 6*cm]
t = Table(defects, colWidths=col_w)
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), DEEP_BLUE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, PALE_GREY]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 8),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 5),
# Highlight OTC row
('BACKGROUND', (0,2), (-1,2), colors.HexColor("#FFF3E0")),
]))
s.append(t)
s.append(Spacer(1, 6))
s.append(Paragraph("AR = autosomal recessive. UCD = urea cycle disorder. ↑ = elevated, ↓ = decreased.", REF_S))
s.append(Spacer(1, 4))
s.append(img("urea_cycle_overview.png", 9))
s.append(Paragraph("Fig. 2 — NH₄⁺ enters the urea cycle via Carbamoyl phosphate synthetase I (CPS I) in the mitochondria; "
"urea is excreted in urine. (Lippincott Illustrated Reviews: Biochemistry, 8e)", CAPTION_S))
return s
def slide_clinical():
s = []
s += section_header("5. CLINICAL PRESENTATION")
s.append(Paragraph("<b>Neonatal (severe) presentation — within 24–72 hours of birth:</b>", H2_S))
s.append(bullet("Initially appears healthy after birth"))
s.append(bullet("Rapidly progressive lethargy → poor feeding → vomiting"))
s.append(bullet("Hypotonia, focal or generalised seizures"))
s.append(bullet("Hyperventilation (respiratory alkalosis driven by NH₃)"))
s.append(bullet("Stupor → coma → cerebral oedema → death if untreated"))
s.append(Spacer(1, 6))
s.append(Paragraph("<b>Late-onset / partial deficiency (older children/adults):</b>", H2_S))
s.append(bullet("Episodes of hyperammonemia triggered by: high-protein meals, fasting, infection, surgery, pregnancy"))
s.append(bullet("Cyclical vomiting, ataxia, confusion, psychiatric symptoms"))
s.append(bullet("Intellectual disability, developmental regression"))
s.append(bullet("May remain undiagnosed until adulthood in female OTC carriers"))
s.append(Spacer(1, 8))
s.append(Paragraph("<b>Symptoms of ammonia intoxication (graded by level):</b>", H2_S))
data = [
["NH₃ Level", "Symptoms"],
["Mildly elevated\n(35–100 µmol/L)", "Tremor, slurred speech, drowsiness, anorexia"],
["Moderate\n(100–300 µmol/L)", "Somnolence, asterixis, vomiting, ataxia, blurred vision"],
["Severe\n(300–500+ µmol/L)", "Stupor, cerebral oedema, seizures, herniation, death"],
]
t = Table(data, colWidths=[4*cm, 13.5*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), ACCENT),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.HexColor("#FFF3E0"), colors.HexColor("#FFE0CC")]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#D09070")),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 8),
]))
s.append(t)
s.append(Spacer(1, 4))
s.append(Paragraph("<i>Source: Lippincott Illustrated Reviews: Biochemistry 8e p. 722; Adams & Victor's Neurology 12e p. 1297</i>", REF_S))
return s
def slide_diagnosis():
s = []
s += section_header("6. DIAGNOSIS")
s.append(Paragraph("<b>Initial Laboratory Workup:</b>", H2_S))
diag_data = [
["Test", "Finding in UCD"],
["Plasma ammonia", "↑↑ (often >200 µmol/L in neonates)"],
["Blood gas / pH", "Respiratory alkalosis (↑ pH, ↓ pCO₂)"],
["Plasma amino acids", "Specific pattern per enzyme (see enzyme table above)"],
["Urine orotic acid", "↑ in OTC deficiency; normal in CPS I deficiency"],
["Urine organic acids", "Usually normal in UCDs (helps exclude organic acidaemias)"],
["Plasma glutamine", "↑ (NH₃ transport)"],
["Plasma alanine", "↑ (NH₃ transport from muscle)"],
["Glucose / lactate", "Usually normal; exclude other metabolic disorders"],
["Liver function tests", "May be mildly elevated"],
]
t = Table(diag_data, colWidths=[5.5*cm, 12*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), MED_BLUE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, PALE_GREY]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('TOPPADDING', (0,0), (-1,-1), 4),
('BOTTOMPADDING', (0,0), (-1,-1), 4),
('LEFTPADDING', (0,0), (-1,-1), 8),
]))
s.append(t)
s.append(Spacer(1, 8))
s.append(Paragraph("<b>Confirmatory Testing:</b>", H2_S))
s.append(bullet("Direct enzyme assay in liver tissue or erythrocytes (for arginase)"))
s.append(bullet("Molecular/genetic testing — mutation identification"))
s.append(bullet("Newborn screening (NBS): citrulline, argininosuccinate, arginine detected on dried blood spot (tandem MS/MS)"))
s.append(bullet("OTC deficiency: elevated urinary orotic acid is diagnostic clue; confirmed by mutation analysis"))
s.append(Spacer(1, 4))
s.append(Paragraph("<b>Differential Diagnosis of neonatal hyperammonemia:</b>", H2_S))
s.append(bullet("Organic acidaemias (propionic, methylmalonic, isovaleric)"))
s.append(bullet("Fatty acid oxidation disorders"))
s.append(bullet("Transient hyperammonemia of the newborn (THAN) — prematurity"))
s.append(bullet("Neonatal sepsis / liver failure"))
s.append(bullet("Valproate-induced (inhibits CPS I via carnitine depletion)"))
s.append(Spacer(1, 4))
s.append(Paragraph("<i>Source: Sleisenger & Fordtran's GI & Liver Disease; Quick Compendium of Clinical Pathology 5e</i>", REF_S))
return s
def slide_treatment():
s = []
s += section_header("7. TREATMENT PLAN")
s.append(Paragraph("<b>A. Acute Hyperammonemic Crisis (Emergency)</b>", H2_S))
s.append(bullet("<b>Discontinue all protein intake immediately</b>"))
s.append(bullet("<b>IV glucose (high caloric load)</b> to suppress catabolism and provide energy"))
s.append(bullet("<b>Nitrogen scavengers (IV Ammonul):</b>"))
s.append(sub_bullet("Sodium benzoate 250 mg/kg IV — conjugates glycine → hippurate (1 N excreted per molecule), renally cleared"))
s.append(sub_bullet("Sodium phenylacetate 250 mg/kg IV — conjugates glutamine → phenylacetylglutamine (2 N excreted), renally cleared"))
s.append(bullet("<b>Arginine supplementation</b> (100–250 mg/kg/day IV) — replenishes cycle intermediates, allows continued urea production where possible"))
s.append(bullet("<b>Haemodialysis / CVVHD</b> for NH₃ >500 µmol/L or rapid rise — exchange transfusion and peritoneal dialysis are <b>NOT effective</b>"))
s.append(bullet("Carnitine and lipid supplementation for deficient patients"))
s.append(Spacer(1, 8))
# Nitrogen scavenger mechanism image
s.append(img("nitrogen_scavengers.png", 9))
s.append(Paragraph("Fig. 3 — Mechanism of phenylbutyrate (nitrogen scavenger): converted to phenylacetate → "
"conjugates glutamine → phenylacetylglutamine excreted in urine, "
"carrying 2 nitrogen atoms. (Lippincott Illustrated Reviews: Biochemistry, 8e)", CAPTION_S))
s.append(Spacer(1, 6))
s.append(Paragraph("<b>B. Maintenance / Long-term Management</b>", H2_S))
s.append(bullet("<b>Low-protein diet</b> — 0.5–1 g/kg/day initially, with gradual increase as tolerated"))
s.append(bullet("<b>Oral nitrogen scavengers:</b> sodium phenylbutyrate (Buphenyl) — prodrug for phenylacetate; more palatable"))
s.append(bullet("<b>Protein-free medical foods</b> — essential amino acid formulas tailored by age/weight"))
s.append(bullet("<b>Dietary protein titration</b> — sufficient to support growth without exceeding urea cycle capacity"))
s.append(bullet("<b>Citrulline supplementation</b> — effective in OTC and CPS I deficiency (provides cycle substrate)"))
s.append(bullet("<b>Arginine supplementation</b> — for ASS and ASL deficiency"))
s.append(bullet("<b>Carglumic acid</b> — synthetic N-acetylglutamate; FDA-approved specifically for NAGS deficiency (activates CPS I)"))
s.append(Spacer(1, 8))
s.append(Paragraph("<b>C. Orthotopic Liver Transplantation (OLT)</b>", H2_S))
s.append(bullet("Corrects enzymatic defect permanently — liver re-expresses normal urea cycle enzymes"))
s.append(bullet("Survival: 93% at 1 yr, 89% at 5 yr, 87% at 10 yr"))
s.append(bullet("Should be performed <b>before permanent neurological damage</b> — early transplantation (ideally <1 year) may allow neurocognitive recovery"))
s.append(bullet("Patients with severe OTC mutations (abolished enzyme activity) benefit most from early OLT"))
s.append(bullet("Patients transplanted early (<1 year) may show developmental improvement"))
s.append(Spacer(1, 4))
s.append(Paragraph("<i>Source: Sleisenger & Fordtran's GI & Liver Disease (Treatment section); "
"Lippincott Illustrated Reviews: Biochemistry 8e p. 727; "
"Adams & Victor's Neurology 12e</i>", REF_S))
return s
def slide_treatment_summary():
s = []
s += section_header("8. TREATMENT ALGORITHM SUMMARY")
alg = [
["Step", "Action", "Rationale"],
["1", "STOP all protein intake", "Halt new NH₃ generation from amino acid catabolism"],
["2", "IV Glucose 10% / high caloric\ninfusion (GIR 8–10 mg/kg/min)", "Suppress muscle catabolism;\nprovide anabolic stimulus"],
["3", "IV Ammonul\n(Na-benzoate + Na-phenylacetate)\n250 mg/kg each", "Bypass urea cycle;\nexcrete N as hippurate + phenylacetylglutamine"],
["4", "IV Arginine\n(100–250 mg/kg/day)", "Replenish cycle intermediates;\narginine is essential in most UCDs"],
["5", "Haemodialysis/CVVHD\nif NH₃ >500 µmol/L", "Rapid ammonia clearance;\nmore effective than peritoneal dialysis"],
["6", "Reintroduce protein gradually\n(0.5 → 1 → 1.5 g/kg/day)", "Support growth;\nminimise ongoing NH₃ production"],
["7", "Oral Na-phenylbutyrate\n+ dietary management", "Chronic nitrogen scavenging;\nreduce hyperammonemic episodes"],
["8", "Liver transplant evaluation", "Definitive cure;\nperform before irreversible brain injury"],
]
col_w = [1*cm, 5.5*cm, 11*cm]
t = Table(alg, colWidths=col_w)
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), DEEP_BLUE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, PALE_GREY]),
('GRID', (0,0), (-1,-1), 0.5, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('VALIGN', (0,0), (-1,-1), 'TOP'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 6),
('BACKGROUND', (0,5), (-1,5), colors.HexColor("#FFF3E0")),
]))
s.append(t)
s.append(Spacer(1, 6))
# Outcome box
outcome_data = [[
Paragraph("<b>PROGNOSIS</b>\n\n"
"• Early diagnosis (newborn screening) dramatically improves outcome\n"
"• Neonatal coma + delayed diagnosis → poor neurodevelopment\n"
"• NH₃ level at first episode = prognostic marker\n"
"• Recurrent crisis risk during illness / stress despite treatment\n"
"• Liver transplant: normalises ammonia, allows normal diet",
ParagraphStyle("op", fontSize=9, fontName="Helvetica",
textColor=DEEP_BLUE, leading=14))
]]
ot = Table(outcome_data, colWidths=[17.5*cm])
ot.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE),
('BOX', (0,0), (-1,-1), 1, MED_BLUE),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 12),
]))
s.append(ot)
return s
def slide_references():
s = []
s += section_header("9. REFERENCES")
refs = [
"1. Lieberman M, Peet A. <i>Marks' Basic Medical Biochemistry: A Clinical Approach.</i> Lippincott Williams & Wilkins, 2018.",
"2. Harvey RA, Ferrier DR. <i>Lippincott Illustrated Reviews: Biochemistry, 8th Edition.</i> Wolters Kluwer, 2022. pp. 722–728.",
"3. Feldman M, Friedman LS, Brandt LJ. <i>Sleisenger and Fordtran's Gastrointestinal and Liver Disease, 11th Edition.</i> Elsevier, 2020.",
"4. Ropper AH, Samuels MA, Klein JP, Prasad S. <i>Adams and Victor's Principles of Neurology, 12th Edition.</i> McGraw-Hill, 2023. pp. 1297–1302.",
"5. Mistry PK, et al. <i>Quick Compendium of Clinical Pathology, 5th Edition.</i> ASCP Press, 2019.",
"6. Batshaw ML, MacArthur RB, Tuchman M. Alternative pathway therapy for urea cycle disorders: Twenty years later. <i>J Pediatr.</i> 2001;138(1 Suppl):S46-55.",
"7. Häberle J, et al. Suggested guidelines for the diagnosis and management of urea cycle disorders: First revision. <i>J Inherit Metab Dis.</i> 2019;42(6):1192-1230.",
]
for r in refs:
s.append(Paragraph(r, ParagraphStyle("ref2", fontSize=9, fontName="Helvetica",
leading=13, spaceAfter=5, alignment=TA_JUSTIFY,
textColor=colors.HexColor("#1A1A1A"))))
return s
# ─── ASSEMBLE DOCUMENT ──────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUT,
pagesize=A4,
rightMargin=1.8*cm, leftMargin=1.8*cm,
topMargin=1.8*cm, bottomMargin=1.4*cm,
title="Hyperammonemia Type 1 — Urea Cycle Disorders",
author="Class Presentation",
subject="Biochemistry and Treatment of Hyperammonemia",
)
story = []
story += cover_page()
story += slide_overview()
story.append(PageBreak())
story += slide_normal_urea_cycle()
story.append(PageBreak())
story += slide_pathophysiology()
story.append(PageBreak())
story += slide_enzyme_deficiencies()
story.append(PageBreak())
story += slide_clinical()
story.append(PageBreak())
story += slide_diagnosis()
story.append(PageBreak())
story += slide_treatment()
story.append(PageBreak())
story += slide_treatment_summary()
story.append(PageBreak())
story += slide_references()
doc.build(story, onFirstPage=on_page, onLaterPages=on_page)
print(f"PDF saved to: {OUT}")
cd /home/daytona/workspace/hyperammonemia-pdf && python3 build_pdf.py 2>&1
~/hyperammonemia-pdf/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/hyperammonemia-pdf/build_pdf.py'
cd /home/daytona/workspace/hyperammonemia-pdf && python3 build_pdf.py 2>&1
ls -lh /home/daytona/workspace/hyperammonemia-pdf/Hyperammonemia_Type1_Presentat…
Hyperammonemia Type1 Presentation
PDF Document · PDF
| Section | Content |
|---|---|
| Cover | Title page with styled layout |
| 1. Overview & Definition | Normal NH₃ range, danger thresholds, acquired vs. congenital types, incidence |
| 2. Normal Urea Cycle | All 6 enzymatic steps (NAGS → CPS I → OTC → ASS → ASL → Arginase), compartments, net reaction + diagram |
| 3. Pathophysiology | How NH₃ accumulates in UCDs, ammonia transport (glutamine/alanine cycle), CNS toxicity cascade (astrocyte swelling, TCA depletion, GABA excess) |
| 4. Enzyme Deficiencies | Detailed table of all 6 enzyme defects (CPS I, OTC, ASS, ASL, Arginase I, NAGS) with inheritance, lab markers, key features + urea cycle diagram |
| 5. Clinical Presentation | Neonatal severe vs. late-onset forms; graded symptom table by NH₃ level |
| 6. Diagnosis | Lab workup table, newborn screening, confirmatory testing, differential diagnosis |
| 7. Treatment Plan | Acute crisis (IV Ammonul, haemodialysis), maintenance (Na-phenylbutyrate, dietary restriction), liver transplantation + nitrogen scavenger mechanism diagram |
| 8. Treatment Algorithm | Step-by-step management table + prognosis summary box |
| 9. References | 7 authoritative sources (Lippincott, Sleisenger & Fordtran, Adams & Victor, etc.) |
Make a pdf for presentation in class on topic hyperammonemia 1 disorder . Explain proper mechanism about its biochemistry and treatment plan make it much more simpler than earlier to understand and present and add a clinical case to it also keep it short
~/hyperammonemia-pdf/build_simple_pdf.py
"""
Simple, clean class presentation PDF on Hyperammonemia Type 1 (Urea Cycle Disorders)
Short, visual, easy to understand, with a clinical case.
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, Image, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import Flowable
from PIL import Image as PILImage
import os, urllib.request
ASSETS = "/home/daytona/workspace/hyperammonemia-pdf/assets"
OUT = "/home/daytona/workspace/hyperammonemia-pdf/Hyperammonemia_Simple_Presentation.pdf"
# ── COLOURS ────────────────────────────────────────────────────────────────
NAVY = colors.HexColor("#1B3A5C")
BLUE = colors.HexColor("#2471A3")
SKY = colors.HexColor("#D6EAF8")
GREEN = colors.HexColor("#1E8449")
LGREEN = colors.HexColor("#D5F5E3")
ORANGE = colors.HexColor("#E67E22")
LORANGE = colors.HexColor("#FDEBD0")
RED = colors.HexColor("#C0392B")
LRED = colors.HexColor("#FADBD8")
YELLOW = colors.HexColor("#F9E79F")
LGREY = colors.HexColor("#F2F3F4")
WHITE = colors.white
# ── STYLES ─────────────────────────────────────────────────────────────────
def S(name, **kw):
return ParagraphStyle(name, **kw)
SLIDE_TITLE = S("st", fontSize=22, fontName="Helvetica-Bold", textColor=WHITE,
alignment=TA_CENTER, leading=28, spaceAfter=0)
SLIDE_SUB = S("ss", fontSize=11, fontName="Helvetica", textColor=colors.HexColor("#AED6F1"),
alignment=TA_CENTER, leading=15)
H1 = S("h1", fontSize=16, fontName="Helvetica-Bold", textColor=NAVY, leading=20,
spaceAfter=4, spaceBefore=6)
H2 = S("h2", fontSize=12, fontName="Helvetica-Bold", textColor=BLUE, leading=16,
spaceAfter=3, spaceBefore=5)
BODY = S("bd", fontSize=10, fontName="Helvetica", textColor=colors.HexColor("#1A1A1A"),
leading=15, spaceAfter=3, alignment=TA_JUSTIFY)
BUL = S("bu", fontSize=10, fontName="Helvetica", textColor=colors.HexColor("#1A1A1A"),
leading=14, spaceAfter=3, leftIndent=14)
SBUL = S("sbu", fontSize=9, fontName="Helvetica", textColor=colors.HexColor("#333333"),
leading=13, spaceAfter=2, leftIndent=28)
CAP = S("cp", fontSize=8, fontName="Helvetica-Oblique", textColor=colors.grey,
alignment=TA_CENTER, spaceAfter=4)
REF = S("rf", fontSize=7, fontName="Helvetica-Oblique", textColor=colors.grey,
alignment=TA_LEFT, spaceAfter=2)
CASE = S("cs", fontSize=10, fontName="Helvetica", textColor=colors.HexColor("#1A1A1A"),
leading=15, spaceAfter=4, alignment=TA_JUSTIFY)
def hline(c=BLUE, t=1):
return HRFlowable(width="100%", thickness=t, color=c, spaceAfter=5, spaceBefore=2)
def bul(text):
return Paragraph(f"● {text}", BUL)
def sbul(text):
return Paragraph(f" ‣ {text}", SBUL)
def sp(n=6):
return Spacer(1, n)
def get_img(fname, w_cm):
path = os.path.join(ASSETS, fname)
with PILImage.open(path) as im:
ow, oh = im.size
w = w_cm * cm
h = w * (oh / ow)
return Image(path, width=w, height=h)
# ── SLIDE HEADER BAR ───────────────────────────────────────────────────────
class SlideHeader(Flowable):
def __init__(self, title, subtitle="", color=NAVY):
super().__init__()
self.title = title
self.subtitle = subtitle
self.color = color
self.height = 1.6*cm if subtitle else 1.2*cm
def wrap(self, aw, ah):
self.aw = aw
return aw, self.height
def draw(self):
c = self.canv
c.setFillColor(self.color)
c.roundRect(0, 0, self.aw, self.height, 6, fill=1, stroke=0)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 14)
y = self.height - 1.0*cm if self.subtitle else self.height/2 - 0.2*cm
c.drawString(0.4*cm, y, self.title)
if self.subtitle:
c.setFont("Helvetica", 9)
c.setFillColor(colors.HexColor("#AED6F1"))
c.drawString(0.4*cm, 0.2*cm, self.subtitle)
def page_header_footer(canvas, doc):
W, H = A4
# thin top bar
canvas.setFillColor(NAVY)
canvas.rect(0, H-0.7*cm, W, 0.7*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 8)
canvas.drawString(1*cm, H-0.5*cm, "HYPERAMMONEMIA TYPE 1 — UREA CYCLE DISORDERS")
canvas.setFont("Helvetica", 8)
canvas.drawRightString(W-1*cm, H-0.5*cm, f"Slide {doc.page}")
# thin bottom bar
canvas.setFillColor(NAVY)
canvas.rect(0, 0, W, 0.5*cm, fill=1, stroke=0)
canvas.setFillColor(colors.HexColor("#90B4CE"))
canvas.setFont("Helvetica-Oblique", 6.5)
canvas.drawCentredString(W/2, 0.16*cm,
"Sources: Lippincott Illustrated Reviews: Biochemistry 8e | Sleisenger & Fordtran's GI & Liver Disease | Adams & Victor's Neurology 12e")
# ══════════════════════════════════════════════════════════════════════════
# SLIDE BUILDERS
# ══════════════════════════════════════════════════════════════════════════
def cover():
story = []
class Bg(Flowable):
def draw(self):
c = self.canv
W, H = A4
c.setFillColor(NAVY)
c.rect(0, 0, W, H, fill=1, stroke=0)
# accent stripe
c.setFillColor(BLUE)
c.rect(0, H*0.38, W, H*0.26, fill=1, stroke=0)
c.setFillColor(ORANGE)
c.rect(0, H*0.38, W, 0.35*cm, fill=1, stroke=0)
c.rect(0, H*0.64, W, 0.35*cm, fill=1, stroke=0)
def wrap(self, aw, ah): return 0, 0
story.append(Bg())
story.append(sp(5.5*cm))
story.append(Paragraph("HYPERAMMONEMIA", S("cv1", fontSize=32, fontName="Helvetica-Bold",
textColor=WHITE, alignment=TA_CENTER, leading=38)))
story.append(sp(4))
story.append(Paragraph("TYPE 1 — UREA CYCLE DISORDERS",
S("cv2", fontSize=18, fontName="Helvetica-Bold",
textColor=colors.HexColor("#F9E79F"), alignment=TA_CENTER, leading=24)))
story.append(sp(10))
story.append(Paragraph("Biochemistry · Mechanism · Treatment · Clinical Case",
S("cv3", fontSize=12, fontName="Helvetica", textColor=colors.HexColor("#AED6F1"),
alignment=TA_CENTER)))
story.append(sp(8))
story.append(hline(colors.HexColor("#F9E79F"), 1.5))
story.append(sp(4))
story.append(Paragraph("A Short Class Presentation",
S("cv4", fontSize=10, fontName="Helvetica-Oblique",
textColor=colors.HexColor("#7FB3D3"), alignment=TA_CENTER)))
story.append(PageBreak())
return story
def slide_what_is():
s = []
s.append(SlideHeader("WHAT IS HYPERAMMONEMIA?", "Definition & Quick Facts", NAVY))
s.append(sp(8))
# Simple 2-box layout
left_data = [[
Paragraph("💡 <b>SIMPLE DEFINITION</b>", S("ld", fontSize=11, fontName="Helvetica-Bold",
textColor=NAVY, leading=15)),
Paragraph("Too much <b>ammonia (NH₃)</b> in the blood because it cannot be "
"converted to <b>urea</b> for excretion.",
S("lt", fontSize=10, fontName="Helvetica", leading=14,
textColor=colors.HexColor("#1A1A1A")))
]]
key_facts = [
["Normal blood NH₃", "5 – 35 µmol/L"],
["Dangerous level", "> 100 µmol/L"],
["Emergency level", "> 500 µmol/L → coma / death"],
["Incidence (genetic)", "~1 in 25,000 births"],
["Most common UCD", "OTC Deficiency (X-linked)"],
]
t = Table(key_facts, colWidths=[6*cm, 9.5*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,-1), SKY),
('BACKGROUND', (1,0), (1,-1), LGREY),
('GRID', (0,0), (-1,-1), 0.5, colors.HexColor("#B0C4DE")),
('FONTNAME', (0,0), (-1,-1), 'Helvetica'),
('FONTSIZE', (0,0), (-1,-1), 10),
('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 8),
('TEXTCOLOR', (0,0), (-1,-1), NAVY),
]))
s.append(t)
s.append(sp(8))
# Two types
types_data = [[
Paragraph("<b>TYPE 1 — GENETIC (this talk)</b>\n\nMissing / broken enzyme in the urea cycle.\n"
"Presents in newborns or in childhood.", S("tp", fontSize=9, fontName="Helvetica",
leading=14, textColor=colors.HexColor("#1B4F72"))),
Paragraph("<b>TYPE 2 — ACQUIRED</b>\n\nLiver disease (cirrhosis, hepatitis).\n"
"Portosystemic shunting bypasses liver.", S("tp2", fontSize=9, fontName="Helvetica",
leading=14, textColor=colors.HexColor("#4A235A")))
]]
tt = Table(types_data, colWidths=[8.5*cm, 8.5*cm])
tt.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,0), SKY),
('BACKGROUND', (1,0), (1,0), colors.HexColor("#E8DAEF")),
('BOX', (0,0), (0,0), 2, BLUE),
('BOX', (1,0), (1,0), 1, colors.HexColor("#8E44AD")),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 8),
('LEFTPADDING', (0,0), (-1,-1), 10),
('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
s.append(tt)
s.append(sp(4))
s.append(Paragraph("<i>Ref: Lippincott Illustrated Reviews: Biochemistry 8e, p.722</i>", REF))
return s
def slide_urea_cycle():
s = []
s.append(SlideHeader("THE UREA CYCLE — HOW IT NORMALLY WORKS", "Liver converts toxic NH₃ → harmless urea (excreted in urine)", BLUE))
s.append(sp(6))
s.append(Paragraph("<b>Think of it as a 6-step factory in the liver:</b>", H2))
steps = [
["#", "Enzyme", "Where?", "What happens?"],
["1", "NAGS", "Mitochondria", "Makes the 'ON switch' (N-acetylglutamate) that activates step 2"],
["2", "CPS I", "Mitochondria", "NH₃ + HCO₃⁻ → Carbamoyl phosphate (uses 2 ATP)"],
["3", "OTC ⚠", "Mitochondria", "Carbamoyl-P + Ornithine → Citrulline (exits to cytosol)"],
["4", "ASS", "Cytosol", "Citrulline + Aspartate → Argininosuccinate"],
["5", "ASL", "Cytosol", "Argininosuccinate → Arginine + Fumarate"],
["6", "Arginase", "Cytosol", "Arginine → UREA (excreted) + Ornithine (recycled back)"],
]
t = Table(steps, colWidths=[0.8*cm, 2.5*cm, 3*cm, 11.2*cm])
t.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),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, SKY]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 5),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
# Highlight OTC
('BACKGROUND', (0,3), (-1,3), YELLOW),
('FONTNAME', (1,3), (1,3), 'Helvetica-Bold'),
]))
s.append(t)
s.append(sp(5))
s.append(Paragraph("⚠ <b>OTC (step 3)</b> is the most commonly deficient enzyme (X-linked gene).", BODY))
s.append(sp(4))
s.append(get_img("urea_cycle_detailed.png", 10))
s.append(Paragraph("Fig. 1 — Full urea cycle. OTC deficiency causes carbamoyl-P to spill into pyrimidine synthesis → orotic acid in urine. "
"(Lippincott Illustrated Reviews: Biochemistry 8e)", CAP))
s.append(sp(4))
s.append(Paragraph("<i>Ref: Lippincott Illustrated Reviews: Biochemistry 8e, p.720–722</i>", REF))
return s
def slide_mechanism():
s = []
s.append(SlideHeader("MECHANISM — WHAT GOES WRONG?", "Step-by-step: how a broken enzyme leads to brain damage", RED))
s.append(sp(8))
# Simple flow diagram using table
flow = [
[Paragraph("🔴 Enzyme defect in urea cycle", S("fw", fontSize=11, fontName="Helvetica-Bold", textColor=WHITE, alignment=TA_CENTER, leading=15))],
[Paragraph("▼", S("arr", fontSize=18, fontName="Helvetica-Bold", textColor=NAVY, alignment=TA_CENTER))],
[Paragraph("NH₃ cannot be converted to urea → accumulates in blood (HYPERAMMONEMIA)", S("fw2", fontSize=10, fontName="Helvetica-Bold", textColor=NAVY, alignment=TA_CENTER, leading=14))],
[Paragraph("▼", S("arr", fontSize=18, fontName="Helvetica-Bold", textColor=NAVY, alignment=TA_CENTER))],
[Paragraph("NH₃ crosses blood-brain barrier freely", S("fw3", fontSize=10, fontName="Helvetica", textColor=colors.HexColor("#1A1A1A"), alignment=TA_CENTER, leading=14))],
[Paragraph("▼", S("arr", fontSize=18, fontName="Helvetica-Bold", textColor=NAVY, alignment=TA_CENTER))],
]
brain_effects = [
["In Brain Cells (Astrocytes)", "Consequence"],
["NH₃ + Glutamate → Glutamine\n(uses glutamine synthetase)", "Astrocytes swell → CEREBRAL OEDEMA"],
["NH₃ depletes α-ketoglutarate\n(TCA cycle intermediate)", "Energy failure in neurons"],
["NH₃ ↑ GABA-A activity", "Sedation, coma"],
["Oxidative stress", "Mitochondrial damage"],
]
t2 = Table(brain_effects, colWidths=[9*cm, 8.5*cm])
t2.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), RED),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [LRED, colors.HexColor("#FADBD8")]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#E8A0A0")),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
# Arrow flow at top
top_data = [[Paragraph(
"❶ Enzyme defect → ❷ NH₃ builds up → ❸ NH₃ enters brain → "
"❹ Astrocytes swell → ❺ Cerebral oedema / Coma / Death",
S("fl", fontSize=10, fontName="Helvetica-Bold", textColor=NAVY,
leading=16, alignment=TA_CENTER))]]
top_t = Table(top_data, colWidths=[17.5*cm])
top_t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), SKY),
('BOX', (0,0), (-1,-1), 1.5, BLUE),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 10),
]))
s.append(top_t)
s.append(sp(8))
s.append(Paragraph("What happens inside the brain:", H2))
s.append(t2)
s.append(sp(6))
s.append(Paragraph("<b>Also note:</b> excess NH₃ drives muscle to make more glutamine & alanine "
"(nitrogen carriers to liver) — but with a broken cycle, NH₃ just keeps rising.", BODY))
s.append(sp(4))
s.append(Paragraph("<i>Ref: Lippincott Illustrated Reviews: Biochemistry 8e; Adams & Victor's Neurology 12e</i>", REF))
return s
def slide_symptoms():
s = []
s.append(SlideHeader("SYMPTOMS — FROM MILD TO SEVERE", "Presentation depends on enzyme, mutation severity, and age", ORANGE))
s.append(sp(8))
sym_data = [
["Severity", "NH₃ Level", "Symptoms"],
["Mild", "35–100 µmol/L", "Tremors, slurred speech, fatigue, poor appetite"],
["Moderate", "100–300 µmol/L", "Vomiting, confusion, drowsiness, asterixis (hand flap)"],
["Severe", "300–500+ µmol/L", "Seizures, stupor → COMA, cerebral oedema, respiratory failure"],
]
t = Table(sym_data, colWidths=[3*cm, 4*cm, 10.5*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), ORANGE),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('BACKGROUND', (0,1), (-1,1), LGREEN),
('BACKGROUND', (0,2), (-1,2), YELLOW),
('BACKGROUND', (0,3), (-1,3), LRED),
('GRID', (0,0), (-1,-1), 0.4, colors.grey),
('FONTSIZE', (0,1), (-1,-1), 9),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
s.append(t)
s.append(sp(8))
s.append(Paragraph("<b>Neonatal presentation (first 24–72 hours):</b>", H2))
s.append(bul("Baby appears normal at birth"))
s.append(bul("Feeding problems, lethargy, then rapid deterioration"))
s.append(bul("Seizures, hyperventilation (respiratory alkalosis), coma"))
s.append(sp(6))
s.append(Paragraph("<b>Later-onset (older child / adult — partial deficiency):</b>", H2))
s.append(bul("Episodes triggered by infection, fasting, high-protein meals, surgery"))
s.append(bul("Confusion, psychiatric symptoms, developmental delay"))
s.append(bul("May go undiagnosed for years (especially female OTC carriers)"))
return s
def slide_clinical_case():
s = []
s.append(SlideHeader("CLINICAL CASE", "A 2-day-old neonate with seizures", colors.HexColor("#6C3483")))
s.append(sp(8))
case_box = [[Paragraph(
"<b>Case Presentation</b><br/><br/>"
"A 2-day-old male neonate, born full-term via normal delivery, "
"was healthy at birth and breastfeeding well. At 48 hours of age he became "
"progressively lethargic, stopped feeding, and began vomiting. "
"By 56 hours he developed focal seizures and hyperventilation.<br/><br/>"
"<b>On examination:</b> Hypotonic, drowsy, not responding to stimuli.<br/><br/>"
"<b>Labs:</b><br/>"
"• Plasma NH₃ = <b>887 µmol/L</b> (normal: 5–35)<br/>"
"• Blood gas: pH 7.52, pCO₂ ↓ → <b>respiratory alkalosis</b><br/>"
"• Plasma amino acids: <b>citrulline markedly elevated</b>; arginine ↓<br/>"
"• Urine orotic acid: <b>normal</b><br/>"
"• Blood glucose, lactate: normal",
CASE)]]
ct = Table(case_box, colWidths=[17.5*cm])
ct.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), colors.HexColor("#F4ECF7")),
('BOX', (0,0), (-1,-1), 2, colors.HexColor("#6C3483")),
('TOPPADDING', (0,0), (-1,-1), 12),
('BOTTOMPADDING', (0,0), (-1,-1), 12),
('LEFTPADDING', (0,0), (-1,-1), 14),
('RIGHTPADDING', (0,0), (-1,-1), 14),
]))
s.append(ct)
s.append(sp(10))
s.append(Paragraph("What is the diagnosis?", H2))
diag_data = [[
Paragraph("<b>Q: Which enzyme is deficient?</b><br/><br/>"
"Citrulline ↑↑ (ASS substrate) + NH₃ ↑ + Normal orotic acid + Normal argininosuccinate<br/><br/>"
"→ <b>Argininosuccinate Synthetase (ASS) deficiency</b><br/>"
"= <b>Citrullinemia Type 1</b>",
S("dq", fontSize=10, fontName="Helvetica", leading=15, textColor=NAVY)),
Paragraph("<b>Key reasoning:</b><br/><br/>"
"• High citrulline → block AFTER citrulline is made (ASS step)<br/>"
"• No orotic acid → NOT OTC deficiency<br/>"
"• No argininosuccinate → NOT ASL deficiency<br/>"
"• Autosomal recessive; detected on newborn screening",
S("dr", fontSize=10, fontName="Helvetica", leading=15, textColor=GREEN))
]]
dt = Table(diag_data, colWidths=[8.75*cm, 8.75*cm])
dt.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,0), SKY),
('BACKGROUND', (1,0), (1,0), LGREEN),
('BOX', (0,0), (0,0), 1, BLUE),
('BOX', (1,0), (1,0), 1, GREEN),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 10),
('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
s.append(dt)
s.append(sp(4))
s.append(Paragraph("<i>Adapted from: Lippincott Illustrated Reviews: Biochemistry 8e, Case 9 / p.1474</i>", REF))
return s
def slide_treatment():
s = []
s.append(SlideHeader("TREATMENT PLAN", "Acute crisis first — then long-term management", GREEN))
s.append(sp(6))
s.append(Paragraph("<b>A. ACUTE CRISIS (Emergency — first hours)</b>", H1))
acute = [
["Step", "Action", "Why?"],
["1", "STOP all protein intake", "No protein = less NH₃ generated"],
["2", "IV Glucose drip\n(10%, high rate)", "Suppress muscle breakdown → less NH₃ from catabolism"],
["3", "IV Ammonul\n(Na-benzoate 250 mg/kg\n+ Na-phenylacetate 250 mg/kg)", "Nitrogen scavengers — grab NH₃ and excrete it in urine\nBenzoate + Glycine → Hippurate (1N out)\nPhenylacetate + Glutamine → Phenylacetylglutamine (2N out)"],
["4", "IV Arginine\n(100–250 mg/kg/day)", "Replenishes cycle intermediates;\nallows remaining cycle function"],
["5", "Haemodialysis / CVVHD\n(if NH₃ >500 µmol/L)", "Fastest way to remove ammonia\nNOTE: peritoneal dialysis NOT effective"],
]
t = Table(acute, colWidths=[0.8*cm, 4.2*cm, 12.5*cm])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), GREEN),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('FONTSIZE', (0,0), (-1,0), 9),
('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, LGREEN]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#A9DFBF")),
('FONTSIZE', (0,1), (-1,-1), 8.5),
('FONTNAME', (0,1), (-1,-1), 'Helvetica'),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 6),
('VALIGN', (0,0), (-1,-1), 'TOP'),
# Highlight dialysis step
('BACKGROUND', (0,5), (-1,5), YELLOW),
]))
s.append(t)
s.append(sp(6))
# Nitrogen scavenger image
s.append(get_img("nitrogen_scavengers.png", 8))
s.append(Paragraph("Fig. 2 — Phenylbutyrate (prodrug) → Phenylacetate → conjugates Glutamine → "
"Phenylacetylglutamine excreted in urine (2 N atoms removed). "
"(Lippincott Illustrated Reviews: Biochemistry 8e)", CAP))
s.append(sp(4))
s.append(Paragraph("<i>Ref: Sleisenger & Fordtran's GI & Liver Disease; Lippincott Biochemistry 8e p.727</i>", REF))
return s
def slide_longterm():
s = []
s.append(SlideHeader("LONG-TERM MANAGEMENT & DEFINITIVE TREATMENT", "", BLUE))
s.append(sp(8))
s.append(Paragraph("<b>B. ONGOING MANAGEMENT</b>", H1))
s.append(bul("<b>Low-protein diet</b> — enough protein to grow, not enough to overwhelm the cycle"))
s.append(bul("<b>Oral sodium phenylbutyrate</b> (Buphenyl) — chronic nitrogen scavenger, more tolerable"))
s.append(bul("<b>Amino acid formula</b> supplements — provide essential amino acids without excess nitrogen"))
s.append(bul("<b>Citrulline supplements</b> — for OTC / CPS I deficiency (provides cycle substrate)"))
s.append(bul("<b>Arginine supplements</b> — for ASS / ASL deficiency"))
s.append(bul("<b>Carglumic acid</b> — synthetic N-acetylglutamate; specific for NAGS deficiency"))
s.append(bul("<b>Avoid triggers:</b> fasting, high-protein meals, illness, surgery (use glucose during these)"))
s.append(sp(8))
s.append(Paragraph("<b>C. LIVER TRANSPLANTATION — DEFINITIVE CURE</b>", H1))
lt_data = [[
Paragraph("✔ Corrects enzyme defect permanently\n(new liver has working urea cycle)\n\n"
"✔ Patient can eat normal protein diet\n\n"
"✔ Survival: 93% at 1 yr, 89% at 5 yr\n\n"
"⚠ Does NOT reverse existing brain damage",
S("lta", fontSize=10, fontName="Helvetica", leading=16, textColor=NAVY)),
Paragraph("🕒 TIMING IS CRITICAL\n\n"
"• Do before permanent brain injury\n"
"• Transplant before 1 year of age\n → best chance of neurocognitive recovery\n\n"
"• Patients with OTC mutations\n (no enzyme activity) benefit MOST\n from early transplant",
S("ltb", fontSize=10, fontName="Helvetica", leading=16, textColor=colors.HexColor("#4A235A")))
]]
lt = Table(lt_data, colWidths=[8.75*cm, 8.75*cm])
lt.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,0), LGREEN),
('BACKGROUND', (1,0), (1,0), colors.HexColor("#F4ECF7")),
('BOX', (0,0), (0,0), 1.5, GREEN),
('BOX', (1,0), (1,0), 1.5, colors.HexColor("#6C3483")),
('TOPPADDING', (0,0), (-1,-1), 12),
('BOTTOMPADDING', (0,0), (-1,-1), 12),
('LEFTPADDING', (0,0), (-1,-1), 12),
('VALIGN', (0,0), (-1,-1), 'TOP'),
]))
s.append(lt)
s.append(sp(4))
s.append(Paragraph("<i>Ref: Sleisenger & Fordtran's GI & Liver Disease (Treatment section); Adams & Victor's Neurology 12e p.1297</i>", REF))
return s
def slide_summary():
s = []
s.append(SlideHeader("SUMMARY — KEY TAKE-AWAYS", "", NAVY))
s.append(sp(8))
summary_data = [
[Paragraph("🔬 <b>What</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=NAVY,leading=14)),
Paragraph("Excess NH₃ in blood due to broken urea cycle enzyme", BODY)],
[Paragraph("⚙ <b>Mechanism</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=NAVY,leading=14)),
Paragraph("NH₃ → enters brain → astrocytes swell → cerebral oedema → coma / death", BODY)],
[Paragraph("🧬 <b>Most common</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=NAVY,leading=14)),
Paragraph("OTC deficiency (X-linked); presents in neonates (males) or triggered in females", BODY)],
[Paragraph("🔍 <b>Diagnose with</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=NAVY,leading=14)),
Paragraph("Plasma NH₃, plasma amino acids, urine orotic acid, genetic testing", BODY)],
[Paragraph("💊 <b>Acute Rx</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=GREEN,leading=14)),
Paragraph("Stop protein → IV glucose → IV Ammonul (Na-benzoate + Na-phenylacetate) + Arginine → dialysis if needed", BODY)],
[Paragraph("🏠 <b>Long-term Rx</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=GREEN,leading=14)),
Paragraph("Low-protein diet + oral Na-phenylbutyrate + amino acid supplements", BODY)],
[Paragraph("🏥 <b>Cure</b>", S("sk",fontSize=10,fontName="Helvetica-Bold",textColor=RED,leading=14)),
Paragraph("Liver transplant — permanent cure. Best outcome if done early (before brain damage)", BODY)],
]
t = Table(summary_data, colWidths=[4*cm, 13.5*cm])
t.setStyle(TableStyle([
('ROWBACKGROUNDS', (0,0), (-1,-1), [SKY, WHITE]),
('GRID', (0,0), (-1,-1), 0.4, colors.HexColor("#B0C4DE")),
('TOPPADDING', (0,0), (-1,-1), 7),
('BOTTOMPADDING', (0,0), (-1,-1), 7),
('LEFTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
s.append(t)
s.append(sp(10))
# Final message box
msg = [[Paragraph(
'"Early diagnosis and immediate treatment are life-saving.<br/>'
'Every minute of high ammonia causes irreversible brain damage."',
S("qb", fontSize=11, fontName="Helvetica-BoldOblique", textColor=NAVY,
alignment=TA_CENTER, leading=18))]]
mt = Table(msg, colWidths=[17.5*cm])
mt.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), YELLOW),
('BOX', (0,0), (-1,-1), 2, ORANGE),
('TOPPADDING', (0,0), (-1,-1), 12),
('BOTTOMPADDING', (0,0), (-1,-1), 12),
('LEFTPADDING', (0,0), (-1,-1), 14),
('RIGHTPADDING', (0,0), (-1,-1), 14),
]))
s.append(mt)
s.append(sp(8))
s.append(Paragraph("<b>References:</b> Lippincott Illustrated Reviews: Biochemistry 8e · "
"Sleisenger & Fordtran's GI & Liver Disease · "
"Adams & Victor's Principles of Neurology 12e", REF))
return s
# ── BUILD ──────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUT, pagesize=A4,
rightMargin=1.7*cm, leftMargin=1.7*cm,
topMargin=1.4*cm, bottomMargin=1.2*cm,
title="Hyperammonemia Type 1 — Simple Class Presentation",
)
story = []
story += cover()
story += slide_what_is(); story.append(PageBreak())
story += slide_urea_cycle(); story.append(PageBreak())
story += slide_mechanism(); story.append(PageBreak())
story += slide_symptoms(); story.append(PageBreak())
story += slide_clinical_case(); story.append(PageBreak())
story += slide_treatment(); story.append(PageBreak())
story += slide_longterm(); story.append(PageBreak())
story += slide_summary()
doc.build(story, onFirstPage=page_header_footer, onLaterPages=page_header_footer)
print(f"✅ PDF saved → {OUT}")
cd /home/daytona/workspace/hyperammonemia-pdf && python3 build_simple_pdf.py 2>&…
~/hyperammonemia-pdf
**/*.pdf in /home/daytona/workspace
/home/daytona
/home/daytona/workspace/hyperammonemia-pdf/build_simple_pdf.pypip install reportlab pillow
python3 build_simple_pdf.py
Hyperammonemia_Simple_Presentation.pdf| Slide | Content |
|---|---|
| Cover | Styled title page |
| 1. What Is Hyperammonemia? | Simple definition, key numbers table, Type 1 (genetic) vs Type 2 (liver disease) |
| 2. Urea Cycle | 6-step table in plain English ("step 1 = turns on the machine"), OTC highlighted, + diagram |
| 3. Mechanism | Color-coded flow: enzyme defect → NH₃ builds → enters brain → astrocyte swelling → coma. Simple cause-effect table |
| 4. Symptoms | Green/yellow/red severity table by NH₃ level; neonatal vs late-onset |
| 5. Clinical Case | 2-day-old male, NH₃ = 887 µmol/L, high citrulline, normal orotic acid → ASS deficiency (Citrullinemia I). Q&A reasoning format |
| 6. Treatment — Acute | 5-step numbered table: Stop protein → IV glucose → IV Ammonul → Arginine → Dialysis + mechanism diagram |
| 7. Treatment — Long-term | Bullets (low-protein diet, phenylbutyrate, supplements) + liver transplant timing box |
| 8. Summary | One-line takeaways for each concept + yellow highlighted key message |
Make a pdf for presentation in class on topic hyperammonemia 1 disorder . Explain proper mechanism about its biochemistry and treatment plan make it much more simpler than earlier to understand and present and add a clinical case to it also keep it short
/home/daytona/workspace
~/hyperammonemia-pdf
~/hyperammonemia-pdf/generate.py
#!/usr/bin/env python3
"""
Hyperammonemia Type 1 – Simple Class Presentation PDF
Run: python3 generate.py
Output: /home/daytona/workspace/hyperammonemia-pdf/Hyperammonemia_Presentation.pdf
"""
import os, urllib.request
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, Image, PageBreak, KeepTogether
)
from reportlab.platypus import Flowable
# ─── PATHS ────────────────────────────────────────────────────────────────
BASE = "/home/daytona/workspace/hyperammonemia-pdf"
ASSETS = os.path.join(BASE, "assets")
OUT = os.path.join(BASE, "Hyperammonemia_Presentation.pdf")
os.makedirs(ASSETS, exist_ok=True)
# ─── DOWNLOAD IMAGES ──────────────────────────────────────────────────────
IMGS = {
"urea_cycle.png": "https://cdn.orris.care/cdss_images/cb91969a1fab873068a60885007572f135cbd9bf7492f1105baf6b8937997dbd.png",
"scavengers.png": "https://cdn.orris.care/cdss_images/45592f93f55da8144f12ee8761697257b3f17f1f147bfce739f76b3a1e6d0a3e.png",
}
for fname, url in IMGS.items():
p = os.path.join(ASSETS, fname)
if not os.path.exists(p):
print(f"Downloading {fname}…")
urllib.request.urlretrieve(url, p)
# ─── COLOURS ──────────────────────────────────────────────────────────────
NAVY = colors.HexColor("#1B3A5C")
BLUE = colors.HexColor("#2471A3")
SKY = colors.HexColor("#D6EAF8")
DSKY = colors.HexColor("#AED6F1")
GREEN = colors.HexColor("#1E8449")
LGREEN = colors.HexColor("#D5F5E3")
ORANGE = colors.HexColor("#E67E22")
LORG = colors.HexColor("#FDEBD0")
RED = colors.HexColor("#C0392B")
LRED = colors.HexColor("#FADBD8")
GOLD = colors.HexColor("#F9E79F")
GREY = colors.HexColor("#F2F3F4")
PURP = colors.HexColor("#6C3483")
LPURP = colors.HexColor("#F4ECF7")
WHITE = colors.white
BLACK = colors.HexColor("#1A1A1A")
# ─── STYLES ───────────────────────────────────────────────────────────────
def st(name, **kw):
return ParagraphStyle(name, **kw)
H1 = st("H1", fontSize=15, fontName="Helvetica-Bold", textColor=NAVY, leading=20, spaceBefore=4, spaceAfter=3)
H2 = st("H2", fontSize=11, fontName="Helvetica-Bold", textColor=BLUE, leading=15, spaceBefore=4, spaceAfter=3)
BODY = st("BD", fontSize=9.5,fontName="Helvetica", textColor=BLACK, leading=14, spaceAfter=2, alignment=TA_JUSTIFY)
BUL = st("BU", fontSize=9.5,fontName="Helvetica", textColor=BLACK, leading=13, spaceAfter=2, leftIndent=12)
SBUL = st("SB", fontSize=9, fontName="Helvetica", textColor=colors.HexColor("#333"), leading=12, spaceAfter=2, leftIndent=26)
CAP = st("CAP", fontSize=7.5,fontName="Helvetica-Oblique",textColor=colors.grey, alignment=TA_CENTER, spaceAfter=3)
REF = st("RF", fontSize=7, fontName="Helvetica-Oblique",textColor=colors.grey, spaceAfter=2)
BOLD = st("BO", fontSize=9.5,fontName="Helvetica-Bold", textColor=BLACK, leading=14)
def sp(n=6): return Spacer(1, n)
def hr(c=BLUE, t=0.8): return HRFlowable(width="100%", thickness=t, color=c, spaceAfter=4, spaceBefore=2)
def bul(txt): return Paragraph(f"● {txt}", BUL)
def sbul(txt): return Paragraph(f" ‣ {txt}", SBUL)
def scaled_img(fname, w_cm):
from PIL import Image as PI
path = os.path.join(ASSETS, fname)
with PI.open(path) as im:
ow, oh = im.size
w = w_cm * cm
return Image(path, width=w, height=w * oh / ow)
# ─── SECTION HEADER BAR ───────────────────────────────────────────────────
class SectionBar(Flowable):
def __init__(self, title, sub="", bg=NAVY):
super().__init__()
self.title = title
self.sub = sub
self.bg = bg
self._h = 1.55*cm if sub else 1.1*cm
def wrap(self, aw, ah):
self._aw = aw
return aw, self._h
def draw(self):
c = self.canv
c.setFillColor(self.bg)
c.roundRect(0, 0, self._aw, self._h, 5, fill=1, stroke=0)
# accent strip
c.setFillColor(colors.HexColor("#F39C12"))
c.rect(0, self._h - 0.22*cm, self._aw, 0.22*cm, fill=1, stroke=0)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 13)
ty = self._h - 0.85*cm if self.sub else self._h/2 - 0.18*cm
c.drawString(0.35*cm, ty, self.title)
if self.sub:
c.setFont("Helvetica", 8)
c.setFillColor(DSKY)
c.drawString(0.35*cm, 0.22*cm, self.sub)
def header_footer(canvas, doc):
W, H = A4
canvas.setFillColor(NAVY)
canvas.rect(0, H - 0.65*cm, W, 0.65*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 7.5)
canvas.drawString(0.9*cm, H - 0.45*cm, "HYPERAMMONEMIA — TYPE 1: UREA CYCLE DISORDERS")
canvas.setFont("Helvetica", 7.5)
canvas.drawRightString(W - 0.9*cm, H - 0.45*cm, f"Slide {doc.page}")
canvas.setFillColor(NAVY)
canvas.rect(0, 0, W, 0.45*cm, fill=1, stroke=0)
canvas.setFillColor(colors.HexColor("#85C1E9"))
canvas.setFont("Helvetica-Oblique", 6)
canvas.drawCentredString(W/2, 0.14*cm,
"Sources: Lippincott Illustrated Reviews: Biochemistry 8e · Sleisenger & Fordtran's GI & Liver Disease · Adams & Victor's Neurology 12e")
# ══════════════════════════════════════════════════════════════════════════
# SLIDES
# ══════════════════════════════════════════════════════════════════════════
# ── COVER ─────────────────────────────────────────────────────────────────
class Cover(Flowable):
def draw(self):
c = self.canv
W, H = A4
c.setFillColor(NAVY); c.rect(0,0,W,H,fill=1,stroke=0)
c.setFillColor(BLUE); c.rect(0,H*0.37,W,H*0.27,fill=1,stroke=0)
c.setFillColor(ORANGE);c.rect(0,H*0.37,W,0.3*cm,fill=1,stroke=0)
c.setFillColor(ORANGE);c.rect(0,H*0.64,W,0.3*cm,fill=1,stroke=0)
def wrap(self,aw,ah): return 0,0
def slide_cover():
s = []
s.append(Cover())
s.append(sp(5.2*cm))
s.append(Paragraph("HYPERAMMONEMIA",
st("T1",fontSize=33,fontName="Helvetica-Bold",textColor=WHITE,alignment=TA_CENTER,leading=40)))
s.append(sp(5))
s.append(Paragraph("TYPE 1 — UREA CYCLE DISORDERS",
st("T2",fontSize=19,fontName="Helvetica-Bold",textColor=GOLD,alignment=TA_CENTER,leading=25)))
s.append(sp(12))
s.append(Paragraph("Biochemistry · Mechanism · Treatment · Clinical Case",
st("T3",fontSize=11,fontName="Helvetica",textColor=DSKY,alignment=TA_CENTER)))
s.append(sp(10))
s.append(HRFlowable(width="100%",thickness=1.5,color=GOLD,spaceAfter=6,spaceBefore=2))
s.append(Paragraph("A Short Class Presentation",
st("T4",fontSize=9,fontName="Helvetica-Oblique",textColor=colors.HexColor("#7FB3D3"),alignment=TA_CENTER)))
s.append(PageBreak())
return s
# ── SLIDE 1: WHAT IS IT? ──────────────────────────────────────────────────
def slide_intro():
s = []
s.append(SectionBar("WHAT IS HYPERAMMONEMIA?", "Too much ammonia — a medical emergency", NAVY))
s.append(sp(7))
s.append(Paragraph(
"Ammonia (NH₃) is a toxic waste product of protein metabolism. Normally the liver "
"converts it to harmless <b>urea</b> (excreted in urine) via the <b>urea cycle</b>. "
"When this cycle fails — due to a genetic enzyme defect — ammonia accumulates and "
"damages the brain.", BODY))
s.append(sp(7))
# Key numbers
nums = [
["Normal NH₃", "5 – 35 µmol/L"],
["Danger zone", "> 100 µmol/L"],
["Crisis / coma", "> 500 µmol/L"],
["Incidence", "~1 in 25,000 live births (all UCDs)"],
["Most common UCD","OTC deficiency — X-linked recessive"],
]
t = Table(nums, colWidths=[5.5*cm, 11*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,-1), SKY),
("BACKGROUND", (1,0),(1,-1), GREY),
("FONTNAME", (0,0),(0,-1), "Helvetica-Bold"),
("FONTNAME", (1,0),(1,-1), "Helvetica"),
("FONTSIZE", (0,0),(-1,-1), 9.5),
("TEXTCOLOR", (0,0),(-1,-1), NAVY),
("GRID", (0,0),(-1,-1), 0.4, DSKY),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 8),
]))
s.append(t)
s.append(sp(8))
# Type 1 vs Type 2
tw = [
[Paragraph("<b>TYPE 1 — GENETIC ← (this talk)</b>\n\n"
"Enzyme defect in urea cycle (inherited).\n"
"Presents in newborns or childhood.\n"
"Autosomal recessive (except OTC = X-linked).",
st("A",fontSize=9,fontName="Helvetica",leading=14,textColor=colors.HexColor("#1B4F72"))),
Paragraph("<b>TYPE 2 — ACQUIRED</b>\n\n"
"Liver disease (cirrhosis, viral hepatitis, NASH).\n"
"Portal blood bypasses liver → NH₃ not cleared.\n"
"More common in adults.",
st("B",fontSize=9,fontName="Helvetica",leading=14,textColor=colors.HexColor("#4A235A")))]
]
tt = Table(tw, colWidths=[8.5*cm, 8.5*cm])
tt.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,0), SKY),
("BACKGROUND", (1,0),(1,0), colors.HexColor("#E8DAEF")),
("BOX", (0,0),(0,0), 2, BLUE),
("BOX", (1,0),(1,0), 1, colors.HexColor("#8E44AD")),
("TOPPADDING", (0,0),(-1,-1), 9),
("BOTTOMPADDING",(0,0),(-1,-1), 9),
("LEFTPADDING", (0,0),(-1,-1), 10),
("VALIGN", (0,0),(-1,-1), "TOP"),
]))
s.append(tt)
s.append(sp(4))
s.append(Paragraph("Ref: Lippincott Illustrated Reviews: Biochemistry 8e, p.722", REF))
return s
# ── SLIDE 2: UREA CYCLE ───────────────────────────────────────────────────
def slide_urea_cycle():
s = []
s.append(SectionBar("THE UREA CYCLE — NORMAL FUNCTION",
"6 enzymatic steps convert toxic NH₃ → urea → excreted in urine", BLUE))
s.append(sp(6))
steps = [
["Step", "Enzyme", "Location", "Plain English"],
["1", "NAGS", "Mitochondria", "Makes the 'on-switch' (N-acetylglutamate) that activates CPS I"],
["2", "CPS I", "Mitochondria", "Traps NH₃ into carbamoyl phosphate (2 ATP used)"],
["3", "OTC ⚠", "Mitochondria", "Joins carbamoyl-P + ornithine → citrulline (exits to cytosol)"],
["4", "ASS", "Cytosol", "Attaches aspartate (2nd nitrogen source) → argininosuccinate"],
["5", "ASL", "Cytosol", "Splits argininosuccinate → arginine + fumarate"],
["6", "Arginase","Cytosol", "Arginine → UREA (excreted ✓) + ornithine (recycled back)"],
]
t = Table(steps, colWidths=[1*cm, 2.5*cm, 3.2*cm, 10.8*cm])
t.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),
("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, SKY]),
("GRID", (0,0),(-1,-1), 0.4, DSKY),
("FONTSIZE", (0,1),(-1,-1), 9),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 5),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
("BACKGROUND", (0,3),(-1,3), GOLD), # highlight OTC
]))
s.append(t)
s.append(sp(4))
s.append(Paragraph("⚠ <b>OTC (Step 3)</b> is the most common deficient enzyme. "
"When OTC fails, carbamoyl-P spills into pyrimidine synthesis → "
"<b>elevated urinary orotic acid</b> (diagnostic clue).", BODY))
s.append(sp(5))
s.append(scaled_img("urea_cycle.png", 9.5))
s.append(Paragraph(
"Fig. 1 — Urea cycle (mitochondria + cytosol). In OTC deficiency, excess carbamoyl-P "
"enters pyrimidine pathway → orotic aciduria. (Lippincott Illustrated Reviews: Biochemistry 8e)", CAP))
s.append(sp(3))
s.append(Paragraph("Ref: Lippincott Illustrated Reviews: Biochemistry 8e, p.720–722", REF))
return s
# ── SLIDE 3: MECHANISM ────────────────────────────────────────────────────
def slide_mechanism():
s = []
s.append(SectionBar("MECHANISM — HOW ENZYME DEFECT CAUSES BRAIN DAMAGE",
"Follow the domino chain from broken enzyme to coma", RED))
s.append(sp(7))
# Flow chain
chain = [[Paragraph(
"❶ Enzyme missing / non-functional"
" → ❷ NH₃ cannot become urea"
" → ❸ NH₃ builds up in blood (hyperammonemia)"
" → ❹ NH₃ freely crosses blood-brain barrier"
" → ❺ Brain damage",
st("FC", fontSize=10, fontName="Helvetica-Bold", textColor=NAVY,
leading=17, alignment=TA_CENTER))]]
ft = Table(chain, colWidths=[17.5*cm])
ft.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), SKY),
("BOX", (0,0),(-1,-1), 1.5, BLUE),
("TOPPADDING", (0,0),(-1,-1), 10),
("BOTTOMPADDING",(0,0),(-1,-1), 10),
("LEFTPADDING", (0,0),(-1,-1), 10),
("RIGHTPADDING", (0,0),(-1,-1), 10),
]))
s.append(ft)
s.append(sp(7))
s.append(Paragraph("<b>What NH₃ does inside the brain (4 mechanisms):</b>", H2))
brain = [
["Mechanism", "Result"],
["NH₃ + Glutamate → Glutamine (glutamine synthetase)\nin astrocytes", "Astrocytes swell → Cerebral oedema"],
["NH₃ depletes α-ketoglutarate\n(TCA cycle intermediate consumed)", "Energy failure — neurons starve"],
["NH₃ enhances GABA-A receptor activity", "Sedation, unconsciousness, coma"],
["NH₃ causes oxidative stress", "Mitochondrial dysfunction, cell death"],
]
bt = Table(brain, colWidths=[9*cm, 8.5*cm])
bt.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,0), RED),
("TEXTCOLOR", (0,0),(-1,0), WHITE),
("FONTNAME", (0,0),(-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0),(-1,0), 9),
("ROWBACKGROUNDS",(0,1),(-1,-1), [LRED, colors.HexColor("#FADBD8")]),
("GRID", (0,0),(-1,-1), 0.4, colors.HexColor("#E8A0A0")),
("FONTSIZE", (0,1),(-1,-1), 9),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING", (0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 7),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
]))
s.append(bt)
s.append(sp(6))
s.append(Paragraph("<b>Also: Alkalosis.</b> High NH₃ stimulates the respiratory centre "
"→ hyperventilation → CO₂ blown off → <b>respiratory alkalosis</b> "
"(↑ pH, ↓ pCO₂). A key blood gas finding.", BODY))
s.append(sp(7))
# NH₃ transport note
tr = [[Paragraph(
"<b>How NH₃ travels to the liver:</b> "
"Muscle converts NH₃ → <b>Glutamine</b> (via glutamine synthetase) and <b>Alanine</b> (via ALT). "
"These are non-toxic carriers. In the liver, glutaminase + GDH release free NH₃ back for urea synthesis. "
"In UCDs, this NH₃ never gets converted → keeps rising.",
BODY)]]
trt = Table(tr, colWidths=[17.5*cm])
trt.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), LORG),
("BOX", (0,0),(-1,-1), 1, ORANGE),
("TOPPADDING", (0,0),(-1,-1), 7),
("BOTTOMPADDING",(0,0),(-1,-1), 7),
("LEFTPADDING", (0,0),(-1,-1), 10),
("RIGHTPADDING", (0,0),(-1,-1), 10),
]))
s.append(trt)
s.append(sp(4))
s.append(Paragraph("Ref: Lippincott Illustrated Reviews: Biochemistry 8e; Adams & Victor's Neurology 12e", REF))
return s
# ── SLIDE 4: ENZYME DEFECTS TABLE ─────────────────────────────────────────
def slide_defects():
s = []
s.append(SectionBar("THE 6 ENZYME DEFECTS — QUICK GUIDE",
"Each broken enzyme gives a different lab pattern", NAVY))
s.append(sp(6))
defects = [
["Deficiency", "Inheritance", "Key Lab Clue", "Remember as…"],
["CPS I", "Auto. recessive", "↓ Citrulline, ↓ Arginine\nNormal orotic acid", "No orotic acid → distinguishes from OTC"],
["OTC ⚠\n(most common)", "X-linked", "↓ Citrulline, ↓ Arginine\n↑↑ Urinary orotic acid", "Orotic acid = OTC's fingerprint"],
["ASS\n(Citrullinemia I)", "Auto. recessive", "↑↑ Citrulline\nNormal argininosuccinate", "Citrulline piles up before the ASS block"],
["ASL\n(Argininosuccinic aciduria)", "Auto. recessive", "↑ Argininosuccinate\n↑ Citrulline", "Argininosuccinic acid in urine = ASL"],
["Arginase I\n(Argininemia)", "Auto. recessive", "↑↑ Arginine\nMild ↑ NH₃", "Mildest; 2 N atoms leave with each arginine"],
["NAGS", "Auto. recessive", "Low CPS I activity\n↑ NH₃", "Treat with carglumic acid (synthetic NAG)"],
]
t = Table(defects, colWidths=[3.5*cm, 2.8*cm, 5.2*cm, 6*cm])
t.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),
("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, SKY]),
("GRID", (0,0),(-1,-1), 0.4, DSKY),
("FONTSIZE", (0,1),(-1,-1), 8.5),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING", (0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 5),
("VALIGN", (0,0),(-1,-1), "TOP"),
("BACKGROUND", (0,2),(-1,2), GOLD), # OTC row
("FONTNAME", (0,2),(0,2), "Helvetica-Bold"),
]))
s.append(t)
s.append(sp(5))
s.append(Paragraph(
"<b>Newborn screening</b> detects most UCDs via tandem mass spec (dried blood spot): "
"abnormal citrulline, arginine, or argininosuccinate levels.", BODY))
s.append(sp(3))
s.append(Paragraph("Ref: Lippincott Illustrated Reviews: Biochemistry 8e, p.725–727; Sleisenger & Fordtran's", REF))
return s
# ── SLIDE 5: CLINICAL CASE ────────────────────────────────────────────────
def slide_case():
s = []
s.append(SectionBar("CLINICAL CASE",
"Can you make the diagnosis?", PURP))
s.append(sp(7))
# Case box
case = [[Paragraph(
"<b>Case Presentation</b><br/><br/>"
"A <b>2-day-old male neonate</b> was born at full term, appeared healthy, "
"and breastfed well. At <b>48 hours</b> he became lethargic and refused feeds. "
"By <b>56 hours</b> he developed focal seizures and rapid breathing.<br/><br/>"
"<b>Examination:</b> Hypotonic, drowsy, unresponsive to stimuli.<br/><br/>"
"<b>Investigations:</b><br/>"
"● Plasma NH₃ = <b>887 µmol/L</b> (normal 5–35)<br/>"
"● Blood gas: pH 7.52, pCO₂ ↓ → <b>respiratory alkalosis</b><br/>"
"● Plasma amino acids: <b>Citrulline ↑↑</b> | Arginine ↓ | Argininosuccinate normal<br/>"
"● Urine orotic acid: <b>Normal</b><br/>"
"● Glucose, lactate: Normal | Sepsis screen: Negative",
st("CC",fontSize=9.5,fontName="Helvetica",leading=15,textColor=BLACK))]]
ct = Table(case, colWidths=[17.5*cm])
ct.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), LPURP),
("BOX", (0,0),(-1,-1), 2, PURP),
("TOPPADDING", (0,0),(-1,-1), 11),
("BOTTOMPADDING",(0,0),(-1,-1), 11),
("LEFTPADDING", (0,0),(-1,-1), 13),
("RIGHTPADDING", (0,0),(-1,-1), 13),
]))
s.append(ct)
s.append(sp(8))
# Q&A
qa = [[
Paragraph(
"<b>Q: Which enzyme is deficient?</b><br/><br/>"
"Citrulline ↑↑ → block is AFTER citrulline forms<br/>"
"No argininosuccinate → NOT ASL deficiency<br/>"
"Normal orotic acid → NOT OTC deficiency<br/><br/>"
"<b>Answer: ASS deficiency</b><br/>"
"(Argininosuccinate Synthetase)<br/>"
"= <b>Citrullinemia Type 1</b><br/>"
"Autosomal recessive",
st("QA",fontSize=9.5,fontName="Helvetica",leading=15,textColor=colors.HexColor("#1B4F72"))),
Paragraph(
"<b>Q: What is the immediate management?</b><br/><br/>"
"❶ Stop all protein immediately<br/>"
"❷ IV 10% glucose (stop catabolism)<br/>"
"❸ IV Ammonul (Na-benzoate + Na-phenylacetate)<br/>"
"❹ IV Arginine 250 mg/kg/day<br/>"
"❺ Haemodialysis (NH₃ >500 µmol/L)<br/><br/>"
"<b>Goal: NH₃ < 100 µmol/L ASAP</b>",
st("QB",fontSize=9.5,fontName="Helvetica",leading=15,textColor=colors.HexColor("#1E5631"))),
]]
qt = Table(qa, colWidths=[8.75*cm, 8.75*cm])
qt.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,0), SKY),
("BACKGROUND", (1,0),(1,0), LGREEN),
("BOX", (0,0),(0,0), 1.5, BLUE),
("BOX", (1,0),(1,0), 1.5, GREEN),
("TOPPADDING", (0,0),(-1,-1), 11),
("BOTTOMPADDING",(0,0),(-1,-1), 11),
("LEFTPADDING", (0,0),(-1,-1), 11),
("VALIGN", (0,0),(-1,-1), "TOP"),
]))
s.append(qt)
s.append(sp(4))
s.append(Paragraph("Ref: Lippincott Illustrated Reviews: Biochemistry 8e, Case 9 / p.1474", REF))
return s
# ── SLIDE 6: TREATMENT ────────────────────────────────────────────────────
def slide_treatment():
s = []
s.append(SectionBar("TREATMENT PLAN",
"Acute crisis first → then long-term → definitive cure", GREEN))
s.append(sp(6))
s.append(Paragraph("<b>A. ACUTE CRISIS (Medical Emergency)</b>", H1))
acute = [
["#", "Treatment", "How it helps"],
["1", "STOP protein intake",
"No amino acids → no new NH₃ generated"],
["2", "IV Glucose 10%\n(high infusion rate)",
"Body stops breaking down muscle → less NH₃ from catabolism"],
["3", "IV Ammonul\n(sodium benzoate 250 mg/kg\n+ sodium phenylacetate 250 mg/kg)",
"Nitrogen scavengers:\nBenzoate + glycine → hippurate (1 N excreted)\nPhenylacetate + glutamine → phenylacetylglutamine (2 N excreted)\nBoth cleared by kidneys — bypasses broken urea cycle"],
["4", "IV Arginine\n(100–250 mg/kg/day)",
"Replenishes cycle intermediates;\nessential because arginine cannot be synthesised in UCD patients"],
["5", "Haemodialysis / CVVHD\n(if NH₃ > 500 µmol/L)",
"Fastest ammonia removal\n⚠ Peritoneal dialysis is NOT effective for NH₃"],
]
t = Table(acute, colWidths=[0.7*cm, 5*cm, 11.8*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,0), GREEN),
("TEXTCOLOR", (0,0),(-1,0), WHITE),
("FONTNAME", (0,0),(-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0),(-1,0), 9),
("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, LGREEN]),
("GRID", (0,0),(-1,-1), 0.4, colors.HexColor("#A9DFBF")),
("FONTSIZE", (0,1),(-1,-1), 9),
("FONTNAME", (0,1),(-1,-1), "Helvetica"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING", (0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 5),
("VALIGN", (0,0),(-1,-1), "TOP"),
("BACKGROUND", (0,3),(-1,3), colors.HexColor("#D5F5E3")),
]))
s.append(t)
s.append(sp(5))
s.append(scaled_img("scavengers.png", 7.5))
s.append(Paragraph(
"Fig. 2 — Nitrogen scavenger mechanism: phenylbutyrate (oral prodrug) → "
"phenylacetate → binds glutamine → phenylacetylglutamine excreted in urine (2 N per molecule). "
"(Lippincott Illustrated Reviews: Biochemistry 8e)", CAP))
s.append(sp(5))
s.append(Paragraph("<b>B. LONG-TERM MANAGEMENT</b>", H1))
lt = [
["Low-protein diet", "0.5–1.5 g/kg/day (enough for growth, not enough to overwhelm cycle)"],
["Oral Na-phenylbutyrate", "Chronic nitrogen scavenger; more palatable than phenylacetate"],
["Amino acid formula", "Provides essential amino acids without excess nitrogen load"],
["Citrulline/Arginine", "Supplements cycle substrates (specific to enzyme defect)"],
["Carglumic acid", "Synthetic NAG — specific treatment for NAGS deficiency"],
["Avoid fasting / illness","Use glucose during stress; these trigger catabolic crises"],
]
lt_t = Table(lt, colWidths=[4.8*cm, 12.7*cm])
lt_t.setStyle(TableStyle([
("ROWBACKGROUNDS",(0,0),(-1,-1), [SKY, WHITE]),
("GRID", (0,0),(-1,-1), 0.4, DSKY),
("FONTNAME", (0,0),(0,-1), "Helvetica-Bold"),
("FONTNAME", (1,0),(1,-1), "Helvetica"),
("FONTSIZE", (0,0),(-1,-1), 9),
("TEXTCOLOR", (0,0),(-1,-1), NAVY),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING", (0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 7),
]))
s.append(lt_t)
s.append(sp(7))
s.append(Paragraph("<b>C. LIVER TRANSPLANT — DEFINITIVE CURE</b>", H1))
lx = [[
Paragraph("✔ Corrects enzyme defect permanently\n"
"✔ Patient can eat normal protein diet\n"
"✔ Survival: 93% / 89% / 87% at 1/5/10 years\n"
"⚠ Does NOT reverse existing brain damage",
st("LX",fontSize=9.5,fontName="Helvetica",leading=16,textColor=NAVY)),
Paragraph("🕒 Do it BEFORE brain injury becomes permanent\n"
" → Best outcomes if transplanted before age 1\n\n"
" Patients with complete OTC loss (no enzyme activity)\n"
" benefit MOST from early transplantation.",
st("LY",fontSize=9.5,fontName="Helvetica",leading=16,textColor=colors.HexColor("#4A235A"))),
]]
lxt = Table(lx, colWidths=[8.75*cm, 8.75*cm])
lxt.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,0), LGREEN),
("BACKGROUND", (1,0),(1,0), LPURP),
("BOX", (0,0),(0,0), 1.5, GREEN),
("BOX", (1,0),(1,0), 1.5, PURP),
("TOPPADDING", (0,0),(-1,-1), 11),
("BOTTOMPADDING",(0,0),(-1,-1), 11),
("LEFTPADDING", (0,0),(-1,-1), 11),
("VALIGN", (0,0),(-1,-1), "TOP"),
]))
s.append(lxt)
s.append(sp(4))
s.append(Paragraph("Ref: Sleisenger & Fordtran's GI & Liver Disease; Lippincott Biochemistry 8e p.727; Adams & Victor's Neurology 12e p.1297", REF))
return s
# ── SLIDE 7: SUMMARY ──────────────────────────────────────────────────────
def slide_summary():
s = []
s.append(SectionBar("SUMMARY", "Everything on one slide", NAVY))
s.append(sp(7))
rows = [
["🔴 What", "Excess NH₃ due to broken urea cycle enzyme (genetic)"],
["⚙ Mechanism", "NH₃ → brain → astrocyte swelling (glutamine) → oedema → seizures → coma → death"],
["🧬 Most common", "OTC deficiency (X-linked); neonatal males most affected"],
["🔍 Diagnose with", "Plasma NH₃ + amino acids + urine orotic acid + genetic test / newborn screening"],
["🟢 Acute Rx", "Stop protein → IV glucose → IV Ammonul + Arginine → haemodialysis if NH₃ >500"],
["🏠 Long-term Rx", "Low-protein diet + oral phenylbutyrate + amino acid supplements"],
["🏥 Cure", "Liver transplant — permanent fix; early transplant (before brain damage) = best outcome"],
]
t = Table(rows, colWidths=[4.2*cm, 13.3*cm])
t.setStyle(TableStyle([
("ROWBACKGROUNDS",(0,0),(-1,-1), [SKY, WHITE]),
("GRID", (0,0),(-1,-1), 0.4, DSKY),
("FONTNAME", (0,0),(0,-1), "Helvetica-Bold"),
("FONTNAME", (1,0),(1,-1), "Helvetica"),
("FONTSIZE", (0,0),(-1,-1), 9.5),
("TEXTCOLOR", (0,0),(0,-1), NAVY),
("TEXTCOLOR", (1,0),(1,-1), BLACK),
("TOPPADDING", (0,0),(-1,-1), 7),
("BOTTOMPADDING", (0,0),(-1,-1), 7),
("LEFTPADDING", (0,0),(-1,-1), 8),
("VALIGN", (0,0),(-1,-1), "MIDDLE"),
# Rx rows green tint
("BACKGROUND", (0,4),(-1,4), LGREEN),
("BACKGROUND", (0,5),(-1,5), colors.HexColor("#EBF5EB")),
("BACKGROUND", (0,6),(-1,6), LGREEN),
]))
s.append(t)
s.append(sp(10))
msg = [[Paragraph(
'"Every minute of high ammonia causes irreversible brain damage.<br/>'
'Diagnose early. Treat immediately. Transplant before damage is permanent."',
st("MG",fontSize=11,fontName="Helvetica-BoldOblique",textColor=NAVY,
alignment=TA_CENTER,leading=18))]]
mt = Table(msg, colWidths=[17.5*cm])
mt.setStyle(TableStyle([
("BACKGROUND", (0,0),(-1,-1), GOLD),
("BOX", (0,0),(-1,-1), 2, ORANGE),
("TOPPADDING", (0,0),(-1,-1), 12),
("BOTTOMPADDING",(0,0),(-1,-1), 12),
("LEFTPADDING", (0,0),(-1,-1), 14),
("RIGHTPADDING", (0,0),(-1,-1), 14),
]))
s.append(mt)
s.append(sp(8))
s.append(Paragraph(
"<b>References:</b> Lippincott Illustrated Reviews: Biochemistry 8e · "
"Sleisenger & Fordtran's GI & Liver Disease 11e · "
"Adams & Victor's Principles of Neurology 12e · "
"Häberle J et al. J Inherit Metab Dis 2019;42(6):1192–1230", REF))
return s
# ─── ASSEMBLE & BUILD ─────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUT, pagesize=A4,
rightMargin=1.7*cm, leftMargin=1.7*cm,
topMargin=1.2*cm, bottomMargin=1.0*cm,
title="Hyperammonemia Type 1 — Class Presentation",
author="Class Presentation",
)
story = []
story += slide_cover()
story += slide_intro(); story.append(PageBreak())
story += slide_urea_cycle(); story.append(PageBreak())
story += slide_mechanism(); story.append(PageBreak())
story += slide_defects(); story.append(PageBreak())
story += slide_case(); story.append(PageBreak())
story += slide_treatment(); story.append(PageBreak())
story += slide_summary()
doc.build(story, onFirstPage=header_footer, onLaterPages=header_footer)
print(f"✅ PDF saved → {OUT}")
**/reportlab/__init__.py in /usr/local/lib/python3
**/reportlab/__init__.py in /usr
/home/daytona/workspace/hyperammonemia-pdf/generate.pypip install reportlab pillow
python3 /home/daytona/workspace/hyperammonemia-pdf/generate.py
Hyperammonemia_Presentation.pdf — in the same folder.| Slide | Title | What it covers |
|---|---|---|
| Cover | Title page | Styled dark blue/gold design |
| 1 | What is Hyperammonemia? | Plain-English definition, normal vs danger NH₃ levels, Type 1 vs Type 2 two-box comparison |
| 2 | The Urea Cycle | 6-step plain-English table ("Step 1 = turns on the machine"), OTC highlighted in yellow, + real textbook diagram |
| 3 | Mechanism | Color-coded domino chain → 4-mechanism brain damage table → alkalosis note → NH₃ transport (glutamine/alanine) explainer box |
| 4 | 6 Enzyme Defects | One-row-per-enzyme table with inheritance, key lab clue, memory hint — OTC row highlighted |
| 5 | Clinical Case | 2-day-old male, NH₃ = 887, ↑↑ citrulline, normal orotic acid → step-by-step Q&A reasoning → diagnosis: ASS deficiency / Citrullinemia Type 1 |
| 6 | Treatment Plan | Acute 5-step numbered table + nitrogen scavenger diagram + long-term table + liver transplant timing box |
| 7 | Summary | One-line takeaway per concept + gold key message box + references |