Biochemistry pathways and cycles in short understanding way


| Product | Amount |
|---|---|
| NADH | 3 |
| FADH₂ | 1 |
| GTP/ATP | 1 |
| CO₂ | 2 |

| Step | Compound | Location |
|---|---|---|
| 1 | NH₃ + HCO₃⁻ → Carbamoyl phosphate | Mitochondria |
| 2 | Carbamoyl phosphate + Ornithine → Citrulline | Mitochondria |
| 3 | Citrulline + Aspartate → Argininosuccinate | Cytosol |
| 4 | Argininosuccinate → Arginine + Fumarate | Cytosol |
| 5 | Arginine → Ornithine + Urea | Cytosol |
Diet (glucose, fats, proteins)
|
GLYCOLYSIS
Glucose → Pyruvate → Acetyl-CoA
|
┌────────────── TCA CYCLE ──────────────┐
| NADH / FADH₂ produced |
| ↓ |
| OXIDATIVE PHOSPHORYLATION |
| ATP !!! |
└────────────────────────────────────────┘
Fasting state:
Glycogen → Glucose (glycogenolysis)
OAA, lactate, amino acids → Glucose (gluconeogenesis)
Fatty acids → Acetyl-CoA (beta-oxidation) → TCA
Excess acetyl-CoA → Ketone bodies (brain fuel)
| Pathway | Location | Main Input | Main Output | Key Enzyme |
|---|---|---|---|---|
| Glycolysis | Cytosol | Glucose | Pyruvate, 2 ATP | PFK-1 |
| TCA Cycle | Mitochondria | Acetyl-CoA | NADH, FADH₂, CO₂ | Isocitrate DH |
| Oxid. Phosph. | Inner mito. membrane | NADH/FADH₂ | ~30 ATP | ATP synthase |
| Gluconeogenesis | Liver/Kidney | Lactate/AA/Glycerol | Glucose | PEPCK |
| Glycogenesis | Liver/Muscle | Glucose | Glycogen | Glycogen synthase |
| Glycogenolysis | Liver/Muscle | Glycogen | Glucose | Glycogen phosphorylase |
| Beta-oxidation | Mitochondria | Fatty acids | Acetyl-CoA | Acyl-CoA DH |
| FA Synthesis | Cytosol | Acetyl-CoA | Palmitate | Acetyl-CoA carboxylase |
| Urea Cycle | Liver (mito+cytosol) | NH₃, Aspartate | Urea | CPS I |
| PPP (HMP shunt) | Cytosol | Glucose-6-P | NADPH, Ribose-5-P | G6PD |
| Ketogenesis | Liver mitochondria | Acetyl-CoA | Ketone bodies | HMG-CoA synthase |
Make a flashcard deck (PDF) on key pathway intermediates and their fates
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"
mkdir -p /home/daytona/workspace/biochem-flashcards
~/biochem-flashcards/make_flashcards.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import (
SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, PageBreak, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus.flowables import KeepTogether
OUTPUT = "/home/daytona/workspace/biochem-flashcards/Biochemistry_Flashcards.pdf"
# ── colour palette ──────────────────────────────────────────────
C_NAVY = colors.HexColor("#1A2F5A")
C_BLUE = colors.HexColor("#2E5BA8")
C_LIGHT = colors.HexColor("#EAF0FB")
C_ACCENT = colors.HexColor("#F4A623")
C_GREEN = colors.HexColor("#27AE60")
C_GREEN_LT = colors.HexColor("#E8F8F0")
C_RED = colors.HexColor("#C0392B")
C_RED_LT = colors.HexColor("#FEF0EE")
C_PURPLE = colors.HexColor("#6C3483")
C_PURPLE_LT = colors.HexColor("#F4EEF9")
C_ORANGE = colors.HexColor("#D35400")
C_ORANGE_LT = colors.HexColor("#FEF5EC")
C_TEAL = colors.HexColor("#117A65")
C_TEAL_LT = colors.HexColor("#E8F6F3")
C_GRAY_LT = colors.HexColor("#F7F9FC")
C_WHITE = colors.white
C_BLACK = colors.HexColor("#1A1A2E")
# category colours: (header_bg, card_bg)
CAT_COLOURS = {
"Glycolysis": (C_BLUE, C_LIGHT),
"TCA Cycle": (C_GREEN, C_GREEN_LT),
"Oxidative Phosphorylation":(C_NAVY, C_GRAY_LT),
"Gluconeogenesis": (C_RED, C_RED_LT),
"Glycogen Metabolism": (C_PURPLE, C_PURPLE_LT),
"Beta-Oxidation": (C_ORANGE, C_ORANGE_LT),
"Fatty Acid Synthesis": (C_TEAL, C_TEAL_LT),
"Urea Cycle": (C_RED, C_RED_LT),
"Pentose Phosphate Pathway":(C_GREEN, C_GREEN_LT),
"Ketone Body Metabolism": (C_ORANGE, C_ORANGE_LT),
}
# ── flashcard data ───────────────────────────────────────────────
# Each card: (category, front_question, back_answer)
CARDS = [
# ── GLYCOLYSIS ──────────────────────────────────────────────
("Glycolysis",
"What is the fate of Glucose-6-Phosphate (G6P)?",
"Three possible fates:\n"
"1. Continue glycolysis → Fructose-6-P\n"
"2. Glycogenesis → stored as glycogen\n"
"3. Pentose phosphate pathway → NADPH + ribose-5-P\n\n"
"Key: G6P is the first committed intermediate; cannot exit most cells (no G6Pase except liver/kidney/intestine)."),
("Glycolysis",
"What is the fate of Fructose-1,6-Bisphosphate (F-1,6-BP)?",
"Cleaved by aldolase into two 3-carbon triose phosphates:\n"
"• DHAP (dihydroxyacetone phosphate)\n"
"• Glyceraldehyde-3-phosphate (G3P)\n\n"
"DHAP → G3P (by triose phosphate isomerase)\n"
"Both G3P molecules feed into ATP-generating phase."),
("Glycolysis",
"What is the fate of Pyruvate (the end product of glycolysis)?",
"FOUR possible fates depending on conditions:\n"
"1. With O₂ → Acetyl-CoA (pyruvate dehydrogenase) → TCA cycle\n"
"2. Without O₂ → Lactate (LDH; regenerates NAD⁺)\n"
"3. Gluconeogenesis → Oxaloacetate (pyruvate carboxylase, liver)\n"
"4. Transamination → Alanine (nitrogen transport from muscle)\n\n"
"Key enzyme: Pyruvate dehydrogenase (PDH) — irreversible, requires B1/B2/B3/B5/lipoic acid."),
("Glycolysis",
"What is the fate of DHAP (Dihydroxyacetone Phosphate)?",
"Three fates:\n"
"1. → G3P via triose phosphate isomerase (continues glycolysis)\n"
"2. → Glycerol-3-P → triacylglycerol synthesis (fat storage)\n"
"3. → Glycerol-3-P → glycerophospholipid synthesis\n\n"
"DHAP is the entry point for glycerol into both glycolysis and lipid synthesis."),
("Glycolysis",
"What is the fate of 1,3-Bisphosphoglycerate (1,3-BPG)?",
"Two fates:\n"
"1. → 3-Phosphoglycerate + ATP (via phosphoglycerate kinase)\n"
" — substrate-level phosphorylation\n"
"2. → 2,3-BPG (in RBCs, via bisphosphoglycerate mutase)\n"
" — 2,3-BPG allosterically reduces Hb-O₂ affinity → O₂ delivery to tissues"),
("Glycolysis",
"What is the fate of Phosphoenolpyruvate (PEP)?",
"Two fates:\n"
"1. → Pyruvate + ATP (via pyruvate kinase) — glycolysis continues\n"
"2. ← OAA (via PEPCK) — gluconeogenesis\n\n"
"PEP is the highest-energy phosphate compound in glycolysis.\n"
"Pyruvate kinase is inhibited by ATP and alanine (fed state signals)."),
# ── TCA CYCLE ────────────────────────────────────────────────
("TCA Cycle",
"What is the fate of Acetyl-CoA entering the TCA cycle?",
"Condenses with Oxaloacetate (4C) → Citrate (6C)\n"
"Enzyme: Citrate synthase\n\n"
"Per turn, acetyl-CoA carbons are NOT directly released as CO₂;\n"
"they become part of OAA in subsequent turns.\n\n"
"Acetyl-CoA can also:\n"
"→ FA synthesis (via citrate export to cytosol)\n"
"→ Ketone body synthesis (if OAA is limiting)"),
("TCA Cycle",
"What is the fate of Citrate (6C)?",
"In mitochondria: → Isocitrate (aconitase)\n"
"In cytosol (exported via citrate shuttle):\n"
"→ Acetyl-CoA + OAA (by citrate lyase)\n"
"→ Acetyl-CoA feeds fatty acid synthesis\n"
"→ OAA feeds back or → NADPH via malic enzyme\n\n"
"Citrate is an allosteric inhibitor of PFK-1 (slows glycolysis when TCA is full)."),
("TCA Cycle",
"What is the fate of Isocitrate (6C)?",
"→ α-Ketoglutarate (5C) + CO₂\n"
"Enzyme: Isocitrate dehydrogenase (IDH)\n"
"Cofactor: NAD⁺ → NADH produced\n\n"
"This is the first CO₂-releasing step and a major\n"
"regulatory point of the TCA cycle.\n"
"IDH is activated by ADP/Ca²⁺ and inhibited by ATP/NADH."),
("TCA Cycle",
"What is the fate of α-Ketoglutarate (5C)?",
"→ Succinyl-CoA (4C) + CO₂\n"
"Enzyme: α-Ketoglutarate dehydrogenase complex\n"
"Cofactors: Same as PDH (B1, B2, B3, B5, lipoic acid)\n"
"Produces: NADH\n\n"
"Also: α-KG ↔ Glutamate (transamination)\n"
"→ Entry point for glutamine/glutamate into TCA\n"
"→ Key link between amino acid and carbohydrate metabolism"),
("TCA Cycle",
"What is the fate of Succinyl-CoA (4C)?",
"→ Succinate + GTP\n"
"Enzyme: Succinyl-CoA synthetase\n"
"→ Substrate-level phosphorylation (only in TCA)\n\n"
"Also:\n"
"→ Heme synthesis (condenses with glycine → ALA)\n"
"→ Ketone body utilization (succinyl-CoA + acetoacetate → acetyl-CoA)"),
("TCA Cycle",
"What is the fate of Oxaloacetate (OAA, 4C)?",
"TCA: Condenses with Acetyl-CoA → Citrate (keeps cycle running)\n\n"
"Also:\n"
"1. → PEP (via PEPCK) — gluconeogenesis\n"
"2. → Aspartate (via transamination) — urea cycle nitrogen donor\n"
"3. → Malate (malate-aspartate shuttle) — NADH transfer\n"
"4. Anaplerosis: Pyruvate → OAA (pyruvate carboxylase)\n\n"
"OAA is the most metabolically connected TCA intermediate."),
("TCA Cycle",
"What is the fate of Fumarate (4C)?",
"TCA: → Malate (fumarase adds H₂O)\n\n"
"Also appears in:\n"
"• Urea cycle (product of argininosuccinate lyase step)\n"
"• Purine synthesis (product of adenylosuccinate lyase)\n\n"
"Clinical: Fumarate hydratase mutations → hereditary leiomyomatosis\n"
"and renal cell carcinoma (HLRCC)."),
# ── OXIDATIVE PHOSPHORYLATION ────────────────────────────────
("Oxidative Phosphorylation",
"What is the fate of NADH produced in metabolism?",
"→ Donates electrons to Complex I (NADH dehydrogenase) of ETC\n"
"→ Electrons flow: Complex I → CoQ → Complex III → Cyt c → Complex IV → O₂\n"
"→ Proton gradient drives ATP synthase (Complex V)\n"
"→ Yields ~2.5 ATP per NADH\n\n"
"Note: Cytoplasmic NADH uses malate-aspartate shuttle (2.5 ATP)\n"
"or glycerol-3-P shuttle (1.5 ATP) to enter ETC."),
("Oxidative Phosphorylation",
"What is the fate of FADH₂ produced in metabolism?",
"→ Donates electrons to Complex II (succinate dehydrogenase) of ETC\n"
"→ Bypasses Complex I → enters at CoQ\n"
"→ Yields ~1.5 ATP per FADH₂\n\n"
"Sources of FADH₂: TCA (succinate step), beta-oxidation\n"
"FADH₂ yields less ATP than NADH because it bypasses one proton-pumping complex."),
("Oxidative Phosphorylation",
"What is the fate of the proton gradient (Δψ) across inner mitochondrial membrane?",
"Generated by: Complexes I, III, IV pumping H⁺ into intermembrane space\n\n"
"Normally: H⁺ flows back through ATP synthase (Complex V) → ATP synthesis\n\n"
"If uncoupled (e.g., by DNP, thermogenin/UCP1 in brown fat):\n"
"→ H⁺ leaks back without making ATP → energy released as heat\n\n"
"Clinical: Uncoupling is the mechanism of brown fat thermogenesis in neonates."),
# ── GLUCONEOGENESIS ──────────────────────────────────────────
("Gluconeogenesis",
"What is the fate of Lactate during fasting/exercise?",
"→ Pyruvate (lactate dehydrogenase; oxidizes NADH → NAD⁺)\n"
"→ Pyruvate → OAA (pyruvate carboxylase, mitochondria)\n"
"→ OAA → PEP (PEPCK)\n"
"→ PEP → Glucose (gluconeogenesis)\n\n"
"This is the Cori cycle: liver converts muscle lactate → glucose;\n"
"glucose returns to muscle for further use."),
("Gluconeogenesis",
"What is the fate of Glycerol (from fat breakdown during fasting)?",
"→ Glycerol-3-phosphate (glycerol kinase, liver)\n"
"→ DHAP (glycerol-3-P dehydrogenase)\n"
"→ Enters gluconeogenesis or glycolysis\n\n"
"Glycerol provides ~5% of gluconeogenic substrate during prolonged fasting.\n"
"Note: Most cells lack glycerol kinase; only liver/kidney can use glycerol."),
("Gluconeogenesis",
"What is the fate of Alanine from muscle during fasting?",
"→ Pyruvate + NH₃ (alanine aminotransferase, liver)\n"
"→ NH₃ → Urea cycle\n"
"→ Pyruvate → OAA → PEP → Glucose\n\n"
"This is the Glucose-Alanine Cycle (Cahill cycle):\n"
"Muscle: glucose → pyruvate + glutamate → alanine\n"
"Liver: alanine → pyruvate → glucose (returned to muscle)"),
# ── GLYCOGEN METABOLISM ──────────────────────────────────────
("Glycogen Metabolism",
"What is the fate of UDP-Glucose?",
"Main fate: → Glycogen chain (glycogen synthase adds it to non-reducing end)\n\n"
"Also:\n"
"→ UDP-Galactose (galactose-1-P uridyl transferase) — lactose synthesis\n"
"→ Glucuronate formation — detoxification in liver\n"
"→ Synthesis of glycoproteins and proteoglycans\n\n"
"UDP-Glucose is the activated donor for glycogen synthesis."),
("Glycogen Metabolism",
"What is the fate of Glucose-1-Phosphate released from glycogen?",
"→ Glucose-6-phosphate (phosphoglucomutase)\n"
"Then:\n"
"• Liver/kidney: G6P → Glucose (glucose-6-phosphatase) → blood glucose\n"
"• Muscle: G6P → enters glycolysis directly (no G6Pase in muscle)\n\n"
"This explains why muscle glycogen cannot directly raise blood glucose."),
# ── BETA-OXIDATION ───────────────────────────────────────────
("Beta-Oxidation",
"What is the fate of Fatty Acyl-CoA in beta-oxidation?",
"Each cycle removes 2 carbons:\n"
"Fatty Acyl-CoA (n carbons) →\n"
" Fatty Acyl-CoA (n-2 carbons) + Acetyl-CoA + NADH + FADH₂\n\n"
"Acetyl-CoA fates:\n"
"1. → TCA cycle (energy, fed/exercise)\n"
"2. → Ketone bodies (fasting, if OAA limiting)\n"
"3. → Cholesterol/steroid synthesis"),
("Beta-Oxidation",
"What is the fate of Malonyl-CoA in fatty acid metabolism?",
"Malonyl-CoA is the first committed intermediate of FA synthesis.\n\n"
"Synthesized by: Acetyl-CoA carboxylase (ACC)\n"
"Activated by: insulin, citrate\n"
"Inhibited by: glucagon, fasting, AMPK\n\n"
"Key regulatory role: Malonyl-CoA INHIBITS carnitine\n"
"palmitoyltransferase I (CPT-I) → blocks FA import into mitochondria\n"
"→ prevents simultaneous FA synthesis AND oxidation."),
("Beta-Oxidation",
"What is the role and fate of Carnitine in beta-oxidation?",
"Carnitine shuttles long-chain fatty acyl groups across inner mitochondrial membrane.\n\n"
"Steps:\n"
"1. Fatty acyl-CoA + Carnitine → Acylcarnitine (CPT-I, outer membrane)\n"
"2. Acylcarnitine enters mitochondria via translocase\n"
"3. Acylcarnitine → Fatty acyl-CoA + Carnitine (CPT-II, inner membrane)\n\n"
"CPT-I is the rate-limiting step of beta-oxidation.\n"
"Carnitine deficiency → fatty acid oxidation defect → hypoglycemia + muscle weakness."),
# ── FATTY ACID SYNTHESIS ─────────────────────────────────────
("Fatty Acid Synthesis",
"What is the fate of Acetyl-CoA in the cytoplasm (FA synthesis)?",
"→ Malonyl-CoA (acetyl-CoA carboxylase, rate-limiting)\n"
"→ Used as 2C donor by fatty acid synthase (FAS)\n"
"→ Each cycle adds 2 carbons to the growing chain\n\n"
"Final product after 7 cycles: Palmitate (16:0)\n"
"Requires: 7 malonyl-CoA + 1 acetyl-CoA + 14 NADPH"),
("Fatty Acid Synthesis",
"What is the fate of NADPH in anabolic pathways?",
"NADPH is the key reductive cofactor for biosynthesis:\n"
"1. FA synthesis — H donor for FAS\n"
"2. Cholesterol synthesis — multiple reduction steps\n"
"3. Glutathione reductase — antioxidant defense (RBCs)\n"
"4. Cytochrome P450 reactions — drug/steroid metabolism\n\n"
"Sources of NADPH:\n"
"• Pentose phosphate pathway (main source)\n"
"• Malic enzyme (malate → pyruvate)\n"
"• Isocitrate dehydrogenase (cytosolic isoform)"),
# ── UREA CYCLE ───────────────────────────────────────────────
("Urea Cycle",
"What is the fate of NH₃ (Ammonia) in the body?",
"Ammonia is TOXIC (especially to brain — causes cerebral edema).\n\n"
"Transport to liver:\n"
"• Glutamine (main form in blood): Glu + NH₃ → Gln (glutamine synthetase)\n"
"• Alanine (from muscle): carries NH₃ from muscle to liver\n\n"
"In liver:\n"
"→ NH₃ + HCO₃⁻ → Carbamoyl phosphate (CPS I, mitochondria)\n"
"→ Enters urea cycle → Urea (excreted by kidney)\n\n"
"Clinical: CPS I deficiency → hyperammonemia"),
("Urea Cycle",
"What is the fate of Citrulline in the urea cycle?",
"Synthesized in mitochondria (ornithine + carbamoyl phosphate)\n"
"→ Transported to cytosol (via ornithine-citrulline antiporter)\n"
"→ Combines with Aspartate → Argininosuccinate (ATP required)\n"
"→ Argininosuccinate → Arginine + Fumarate\n\n"
"Fumarate re-enters TCA cycle (links urea cycle to TCA)\n"
"Arginine → Ornithine + Urea (arginase)\n"
"Defect in OTC (ornithine transcarbamylase) → citrullinemia/hyperammonemia"),
("Urea Cycle",
"What is the fate of Ornithine in the urea cycle?",
"Ornithine is the carrier/regenerating molecule of the urea cycle\n"
"(analogous to OAA in TCA cycle)\n\n"
"Accepts carbamoyl group → Citrulline (in mitochondria)\n"
"Regenerated by arginase at end of cycle\n"
"Transported back into mitochondria via antiporter\n\n"
"Also: Ornithine → Polyamines (spermine, spermidine)\n"
"→ important for cell growth and proliferation"),
# ── PENTOSE PHOSPHATE PATHWAY ────────────────────────────────
("Pentose Phosphate Pathway",
"What is the fate of Glucose-6-Phosphate in the PPP?",
"Oxidative branch (irreversible):\n"
"G6P → 6-Phosphogluconolactone → 6-Phosphogluconate\n"
"→ Ribulose-5-P + CO₂ + 2 NADPH\n"
"Enzyme: G6PD (glucose-6-phosphate dehydrogenase) — rate-limiting\n\n"
"Non-oxidative branch (reversible):\n"
"Ribulose-5-P ↔ Ribose-5-P (for nucleotide synthesis)\n"
"or ↔ F6P + G3P (feeds back into glycolysis)\n\n"
"Clinical: G6PD deficiency → hemolytic anemia with oxidant stress"),
("Pentose Phosphate Pathway",
"What is the fate of Ribose-5-Phosphate?",
"Two main fates:\n"
"1. → Nucleotide synthesis\n"
" R5P + ATP → PRPP (phosphoribosyl pyrophosphate)\n"
" PRPP → purines, pyrimidines, NAD⁺, FAD, CoA\n\n"
"2. Non-oxidative branch → F6P + G3P → back to glycolysis\n"
" (when NADPH needed but nucleotides are not)"),
# ── KETONE BODY METABOLISM ───────────────────────────────────
("Ketone Body Metabolism",
"What is the fate of HMG-CoA in the liver mitochondria?",
"→ Acetoacetate + Acetyl-CoA (HMG-CoA lyase)\n"
"This is KETOGENESIS — occurs only in LIVER mitochondria\n\n"
"Acetoacetate fates:\n"
"1. → β-Hydroxybutyrate (main blood transport form)\n"
"2. → Acetone (spontaneous; exhaled)\n\n"
"Note: HMG-CoA is also used for cholesterol synthesis — but that\n"
"pathway is in the CYTOSOL. Location determines fate."),
("Ketone Body Metabolism",
"What is the fate of Acetoacetate in peripheral tissues?",
"Peripheral tissues (brain, muscle, heart) USE ketones:\n"
"Acetoacetate + Succinyl-CoA → Acetoacetyl-CoA + Succinate\n"
"Enzyme: Succinyl-CoA transferase (thiophorase)\n"
"→ Acetoacetyl-CoA → 2 Acetyl-CoA → TCA → ATP\n\n"
"Liver LACKS thiophorase → cannot use its own ketones\n\n"
"Brain: Normally uses glucose; after ~2–3 weeks starvation,\n"
"ketones supply ~60–70% of brain energy."),
]
# ── Build PDF ────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=1.8*cm, rightMargin=1.8*cm,
topMargin=1.8*cm, bottomMargin=1.8*cm,
title="Biochemistry Pathway Intermediates — Flashcard Deck",
author="Orris Medical"
)
styles = getSampleStyleSheet()
# Custom styles
STYLE_COVER_TITLE = ParagraphStyle(
"CoverTitle", parent=styles["Title"],
fontSize=28, textColor=C_WHITE, alignment=TA_CENTER,
spaceAfter=6, leading=34
)
STYLE_COVER_SUB = ParagraphStyle(
"CoverSub", parent=styles["Normal"],
fontSize=13, textColor=colors.HexColor("#BDD0F5"), alignment=TA_CENTER,
spaceAfter=4
)
STYLE_SECTION = ParagraphStyle(
"Section", parent=styles["Heading1"],
fontSize=15, textColor=C_WHITE, alignment=TA_LEFT,
spaceAfter=2, leading=18, leftIndent=8
)
STYLE_CARD_Q = ParagraphStyle(
"CardQ", parent=styles["Normal"],
fontSize=11, textColor=C_BLACK, leading=15,
spaceAfter=2
)
STYLE_CARD_A = ParagraphStyle(
"CardA", parent=styles["Normal"],
fontSize=10.5, textColor=C_BLACK, leading=14.5,
spaceAfter=2
)
STYLE_LABEL = ParagraphStyle(
"Label", parent=styles["Normal"],
fontSize=8, textColor=colors.HexColor("#888888"),
alignment=TA_LEFT, spaceBefore=0
)
STYLE_FOOTER = ParagraphStyle(
"Footer", parent=styles["Normal"],
fontSize=8, textColor=colors.HexColor("#AAAAAA"), alignment=TA_CENTER
)
PAGE_W = A4[0] - 3.6*cm # usable width
def make_header_table(text, bg_color):
"""Full-width coloured section header bar."""
p = Paragraph(text, STYLE_SECTION)
t = Table([[p]], colWidths=[PAGE_W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg_color),
("ROUNDEDCORNERS", [6]),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
("TOPPADDING", (0,0), (-1,-1), 7),
("BOTTOMPADDING",(0,0), (-1,-1), 7),
]))
return t
def make_flashcard(q_text, a_text, card_bg, card_num):
"""A single flashcard as a bordered table with Q on top, A below."""
q_label = Paragraph("QUESTION", ParagraphStyle("QL", parent=STYLE_LABEL,
textColor=C_BLUE, fontSize=7.5, fontName="Helvetica-Bold"))
a_label = Paragraph("ANSWER / FATE", ParagraphStyle("AL", parent=STYLE_LABEL,
textColor=C_GREEN, fontSize=7.5, fontName="Helvetica-Bold"))
num_p = Paragraph(f"#{card_num}", ParagraphStyle("Num", parent=STYLE_LABEL,
textColor=colors.HexColor("#BBBBBB"), alignment=TA_LEFT, fontSize=8))
q_para = Paragraph(q_text, ParagraphStyle("QP", parent=STYLE_CARD_Q,
fontName="Helvetica-Bold", fontSize=11))
a_para = Paragraph(a_text.replace("\n", "<br/>"), STYLE_CARD_A)
divider = HRFlowable(width="100%", thickness=1, color=colors.HexColor("#DDDDDD"),
spaceAfter=4, spaceBefore=4)
data = [[
[num_p, q_label, Spacer(1, 3), q_para,
divider,
a_label, Spacer(1, 3), a_para]
]]
t = Table(data, colWidths=[PAGE_W - 1.6*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), card_bg),
("BOX", (0,0), (-1,-1), 1.2, colors.HexColor("#D0D8EC")),
("ROUNDEDCORNERS", [8]),
("LEFTPADDING", (0,0), (-1,-1), 14),
("RIGHTPADDING", (0,0), (-1,-1), 14),
("TOPPADDING", (0,0), (-1,-1), 10),
("BOTTOMPADDING",(0,0), (-1,-1), 10),
]))
return t
# ── Cover page ───────────────────────────────────────────────────
def cover_flowables():
items = []
# Navy cover block
cover_data = [[
[
Spacer(1, 1.2*cm),
Paragraph("BIOCHEMISTRY", STYLE_COVER_TITLE),
Paragraph("Pathway Intermediates & Their Fates", STYLE_COVER_TITLE),
Spacer(1, 0.4*cm),
Paragraph("Flashcard Deck", STYLE_COVER_SUB),
Spacer(1, 0.2*cm),
Paragraph("30 Cards · 10 Pathways", STYLE_COVER_SUB),
Spacer(1, 0.6*cm),
Paragraph("Glycolysis · TCA Cycle · Oxidative Phosphorylation · Gluconeogenesis", STYLE_COVER_SUB),
Paragraph("Glycogen Metabolism · Beta-Oxidation · Fatty Acid Synthesis", STYLE_COVER_SUB),
Paragraph("Urea Cycle · Pentose Phosphate Pathway · Ketone Body Metabolism", STYLE_COVER_SUB),
Spacer(1, 1.2*cm),
]
]]
cover_table = Table(cover_data, colWidths=[PAGE_W])
cover_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_NAVY),
("ROUNDEDCORNERS", [12]),
("LEFTPADDING", (0,0), (-1,-1), 20),
("RIGHTPADDING", (0,0), (-1,-1), 20),
("TOPPADDING", (0,0), (-1,-1), 10),
("BOTTOMPADDING",(0,0), (-1,-1), 10),
]))
items.append(cover_table)
items.append(Spacer(1, 0.8*cm))
# How to use box
how_data = [[
Paragraph(
"<b>How to Use:</b> Cover the ANSWER section and try to recall the fate of each intermediate. "
"Check your answer by reading the ANSWER / FATE section. "
"Cards are grouped by pathway and colour-coded for easy navigation.",
ParagraphStyle("HowTo", parent=styles["Normal"],
fontSize=10, textColor=C_BLACK, leading=14)
)
]]
how_table = Table(how_data, colWidths=[PAGE_W])
how_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#FFF8E1")),
("BOX", (0,0), (-1,-1), 1, C_ACCENT),
("ROUNDEDCORNERS", [6]),
("LEFTPADDING", (0,0), (-1,-1), 14),
("RIGHTPADDING", (0,0), (-1,-1), 14),
("TOPPADDING", (0,0), (-1,-1), 10),
("BOTTOMPADDING",(0,0), (-1,-1), 10),
]))
items.append(how_table)
items.append(PageBreak())
return items
# ── Group cards by category ──────────────────────────────────────
from collections import OrderedDict
grouped = OrderedDict()
for card in CARDS:
cat = card[0]
grouped.setdefault(cat, []).append(card)
# ── Build story ──────────────────────────────────────────────────
story = cover_flowables()
card_num = 1
for cat, cards_in_cat in grouped.items():
hdr_bg, card_bg = CAT_COLOURS.get(cat, (C_NAVY, C_GRAY_LT))
story.append(make_header_table(f" {cat}", hdr_bg))
story.append(Spacer(1, 0.25*cm))
for _, q, a in cards_in_cat:
fc = make_flashcard(q, a, card_bg, card_num)
story.append(KeepTogether([fc, Spacer(1, 0.3*cm)]))
card_num += 1
story.append(Spacer(1, 0.4*cm))
# ── Build ────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF written: {OUTPUT}")
print(f"Total cards: {card_num - 1}")
cd /home/daytona/workspace/biochem-flashcards && python make_flashcards.py
ls -lh /home/daytona/workspace/biochem-flashcards/Biochemistry_Flashcards.pdf
Biochemistry Flashcards
PDF Document · PDF
| Pathway | Cards | Colour |
|---|---|---|
| Glycolysis | 6 | Blue |
| TCA Cycle | 6 | Green |
| Oxidative Phosphorylation | 3 | Navy |
| Gluconeogenesis | 3 | Red |
| Glycogen Metabolism | 2 | Purple |
| Beta-Oxidation | 3 | Orange |
| Fatty Acid Synthesis | 2 | Teal |
| Urea Cycle | 3 | Red |
| Pentose Phosphate Pathway | 2 | Green |
| Ketone Body Metabolism | 2 | Orange |