Im 1st year mbbs student in exam imp questions list i saw one question is 4 mark question is classification of lipids give a answer of this question easy to understand English language,when I read this question answer I understand easily, give answer this type when I read this question answer first time so much answer I understand easily in first time and when i write this in exam my sir will give me full out of full marks and easy to read and understand,answer give as 1 st year mbbs [ Biochemistry ]and easy to understand and write Thank you
"Simple = Fatty acid + Alcohol only"
| Type | Description | Example |
|---|---|---|
| Fats (Triglycerides) | Fatty acid + Glycerol (3 fatty acids) | Butter, body fat |
| Waxes | Fatty acid + Long-chain alcohol | Beeswax, earwax |
"Compound = Simple lipid + Extra group"
| Type | Extra Group Added | Example |
|---|---|---|
| Phospholipids | Phosphate + Nitrogen base | Lecithin (in cell membranes) |
| Glycolipids | Carbohydrate (sugar) | Cerebrosides (in brain/nerve tissue) |
| Lipoproteins | Protein | HDL, LDL (transport lipids in blood) |
| Sulfolipids | Sulfate group | Present in brain |
| Aminolipids | Amino group | Present in tissues |
"Derived = Products obtained FROM simple or compound lipids"
| Type | Example |
|---|---|
| Fatty acids | Palmitic acid, Stearic acid |
| Sterols | Cholesterol, Ergosterol |
| Glycerol | Backbone of triglycerides |
| Fat-soluble vitamins | Vitamin A, D, E, K |
| Steroid hormones | Cortisol, Testosterone, Estrogen |
| Bile acids | Cholic acid (help in fat digestion) |
| Prostaglandins | Involved in inflammation |
"S - C - D"
- S = Simple (fats + waxes)
- C = Compound (phospholipids, glycolipids, lipoproteins)
- D = Derived (fatty acids, sterols, vitamins, hormones)
| Class | What it is | Key Example |
|---|---|---|
| Simple Lipids | FA + Alcohol | Triglycerides, Waxes |
| Compound Lipids | FA + Alcohol + Extra group | Phospholipids, Glycolipids |
| Derived Lipids | Breakdown products of above | Cholesterol, Fatty acids, Vitamins A/D/E/K |
Create a study guide PDF with lipid classification diagrams
ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or not found"
mkdir -p /home/daytona/workspace/lipids-study-guide && python3 -c "import reportlab; print('reportlab ok')"
~/lipids-study-guide/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.graphics.shapes import (
Drawing, Rect, String, Line, Polygon, RoundRect, Group
)
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Circle, RoundRect
from reportlab.lib.colors import (
HexColor, white, black
)
import os
OUTPUT = "/home/daytona/workspace/lipids-study-guide/Lipid_Classification_Study_Guide.pdf"
# ── Colour palette ──────────────────────────────────────────────────────────
C_BLUE_DARK = HexColor("#1A3C6E") # headings / title bar
C_BLUE_MID = HexColor("#2E6FD8") # subheadings
C_BLUE_LIGHT = HexColor("#D6E6FF") # row shading
C_GREEN = HexColor("#1B7A3E") # Simple lipids
C_GREEN_L = HexColor("#D4F0E0")
C_PURPLE = HexColor("#6A1B9A") # Compound lipids
C_PURPLE_L = HexColor("#EDE0F7")
C_ORANGE = HexColor("#B85C00") # Derived lipids
C_ORANGE_L = HexColor("#FDEBD0")
C_YELLOW = HexColor("#FFF9C4") # highlight
C_GRAY_LIGHT = HexColor("#F5F5F5")
C_GRAY_MID = HexColor("#CCCCCC")
C_RED = HexColor("#C0392B")
# ── Document ─────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT, pagesize=A4,
leftMargin=1.5*cm, rightMargin=1.5*cm,
topMargin=1.5*cm, bottomMargin=1.5*cm
)
W, H = A4
TW = W - 3*cm # text width
styles = getSampleStyleSheet()
# Custom paragraph styles
def PS(name, **kw):
return ParagraphStyle(name, **kw)
title_style = PS("Title2",
fontName="Helvetica-Bold", fontSize=22,
textColor=white, alignment=TA_CENTER, spaceAfter=4)
subtitle_style = PS("Subtitle",
fontName="Helvetica", fontSize=11,
textColor=HexColor("#BBDEFB"), alignment=TA_CENTER)
h1 = PS("H1",
fontName="Helvetica-Bold", fontSize=14,
textColor=white, alignment=TA_CENTER, spaceAfter=2)
h2 = PS("H2",
fontName="Helvetica-Bold", fontSize=12,
textColor=C_BLUE_DARK, spaceBefore=8, spaceAfter=4)
h3_green = PS("H3G",
fontName="Helvetica-Bold", fontSize=11,
textColor=C_GREEN, spaceBefore=6, spaceAfter=2)
h3_purple = PS("H3P",
fontName="Helvetica-Bold", fontSize=11,
textColor=C_PURPLE, spaceBefore=6, spaceAfter=2)
h3_orange = PS("H3O",
fontName="Helvetica-Bold", fontSize=11,
textColor=C_ORANGE, spaceBefore=6, spaceAfter=2)
body = PS("Body",
fontName="Helvetica", fontSize=9.5,
textColor=HexColor("#212121"), leading=14, spaceAfter=3)
body_bold = PS("BodyBold",
fontName="Helvetica-Bold", fontSize=9.5,
textColor=HexColor("#212121"), leading=14)
small = PS("Small",
fontName="Helvetica", fontSize=8.5,
textColor=HexColor("#444444"), leading=12)
tip = PS("Tip",
fontName="Helvetica-BoldOblique", fontSize=9,
textColor=C_BLUE_DARK, leading=13)
memory = PS("Memory",
fontName="Helvetica-Bold", fontSize=10,
textColor=C_RED, alignment=TA_CENTER, spaceAfter=2)
# ─────────────────────────────────────────────────────────────────────────────
# Helper: coloured banner paragraph
# ─────────────────────────────────────────────────────────────────────────────
def banner(text, style, bg, pad=6, radius=6):
tbl = Table([[Paragraph(text, style)]], colWidths=[TW])
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("ROUNDEDCORNERS", [radius]*4),
("TOPPADDING", (0,0), (-1,-1), pad),
("BOTTOMPADDING", (0,0), (-1,-1), pad),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
]))
return tbl
# ─────────────────────────────────────────────────────────────────────────────
# Helper: section box
# ─────────────────────────────────────────────────────────────────────────────
def section_box(content_rows, header_text, header_bg, stripe_bg):
"""content_rows: list of [left_cell, right_cell] pairs"""
data = [[Paragraph(f"<b>{header_text}</b>",
PS("SH", fontName="Helvetica-Bold", fontSize=10,
textColor=white, alignment=TA_LEFT)),
""]]
data += content_rows
col_w = [TW*0.38, TW*0.62]
tbl = Table(data, colWidths=col_w)
style_cmds = [
("SPAN", (0,0), (1,0)),
("BACKGROUND", (0,0), (1,0), header_bg),
("TEXTCOLOR", (0,0), (1,0), white),
("FONTNAME", (0,0), (1,0), "Helvetica-Bold"),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
("GRID", (0,1), (-1,-1), 0.4, C_GRAY_MID),
("LINEBELOW", (0,0), (1,0), 1, white),
("VALIGN", (0,0), (-1,-1), "TOP"),
]
for i in range(1, len(data)):
bg = stripe_bg if i % 2 == 0 else white
style_cmds.append(("BACKGROUND", (0,i), (1,i), bg))
tbl.setStyle(TableStyle(style_cmds))
return tbl
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 1 – Tree / Mind-map of Lipid Classification
# ─────────────────────────────────────────────────────────────────────────────
def make_tree_diagram():
dw, dh = TW, 210
d = Drawing(dw, dh)
cx = dw / 2 # centre x
root_y = dh - 30
root_w, root_h = 160, 30
def box(x, y, w, h, fill, text, font_size=9, text_color=white, radius=5):
r = RoundRect(x - w/2, y - h/2, w, h, radius, fillColor=fill,
strokeColor=HexColor("#555555"), strokeWidth=0.5)
d.add(r)
s = String(x, y - font_size*0.4, text,
fontName="Helvetica-Bold", fontSize=font_size,
fillColor=text_color, textAnchor="middle")
d.add(s)
def line(x1, y1, x2, y2, color=HexColor("#888888"), w=1):
d.add(Line(x1, y1, x2, y2, strokeColor=color, strokeWidth=w))
# Root
box(cx, root_y, root_w, root_h, C_BLUE_DARK, "LIPIDS", font_size=13)
# 3 branches
branch_y = root_y - 70
branches = [
(cx - 195, branch_y, 110, 28, C_GREEN, "1. SIMPLE"),
(cx, branch_y, 130, 28, C_PURPLE, "2. COMPOUND"),
(cx + 195, branch_y, 110, 28, C_ORANGE, "3. DERIVED"),
]
for bx, by, bw, bh, bc, bt in branches:
line(cx, root_y - root_h//2, bx, by + bh//2, color=bc, w=1.5)
box(bx, by, bw, bh, bc, bt, font_size=10)
# Leaves
leaves = [
# Simple lipids
(cx - 245, branch_y - 55, 95, 22, C_GREEN_L, "Fats (Triglycerides)", C_GREEN),
(cx - 145, branch_y - 55, 95, 22, C_GREEN_L, "Waxes", C_GREEN),
# Compound lipids
(cx - 75, branch_y - 55, 90, 22, C_PURPLE_L, "Phospholipids", C_PURPLE),
(cx + 5, branch_y - 55, 85, 22, C_PURPLE_L, "Glycolipids", C_PURPLE),
(cx + 85, branch_y - 55, 90, 22, C_PURPLE_L, "Lipoproteins", C_PURPLE),
# Derived
(cx + 145, branch_y - 55, 88, 22, C_ORANGE_L, "Fatty Acids", C_ORANGE),
(cx + 238, branch_y - 55, 88, 22, C_ORANGE_L, "Sterols", C_ORANGE),
]
# parent connections
parent_map = [
(0, cx-195), (1, cx-195),
(2, cx), (3, cx), (4, cx),
(5, cx+195), (6, cx+195),
]
for idx, (li, bx_parent) in enumerate(parent_map):
lx, ly, lw, lh, lc, lt, tc = leaves[idx]
line(bx_parent, branch_y - 28//2, lx, ly + lh//2, color=lc, w=1)
r = RoundRect(lx - lw/2, ly - lh/2, lw, lh, 4,
fillColor=lc, strokeColor=HexColor("#AAAAAA"), strokeWidth=0.4)
d.add(r)
s = String(lx, ly - 3.5, lt,
fontName="Helvetica", fontSize=7.5,
fillColor=tc, textAnchor="middle")
d.add(s)
# Extra leaves row (more derived items)
extra = [
(cx + 145, branch_y - 88, 88, 18, C_ORANGE_L, "Vitamins A,D,E,K", C_ORANGE),
(cx + 238, branch_y - 88, 88, 18, C_ORANGE_L, "Steroid Hormones", C_ORANGE),
]
for ex, ey, ew, eh, ec, et, etc_ in extra:
line(cx+195, branch_y - 55 - 22//2, ex, ey + eh//2, color=C_ORANGE, w=0.8)
r = RoundRect(ex - ew/2, ey - eh/2, ew, eh, 4,
fillColor=ec, strokeColor=HexColor("#AAAAAA"), strokeWidth=0.3)
d.add(r)
s = String(ex, ey - 3, et,
fontName="Helvetica", fontSize=7,
fillColor=etc_, textAnchor="middle")
d.add(s)
return d
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 2 – Phospholipid structure diagram
# ─────────────────────────────────────────────────────────────────────────────
def make_phospholipid_diagram():
dw, dh = TW * 0.55, 140
d = Drawing(dw, dh)
# Head group (hydrophilic)
head_y = dh - 35
head_r = RoundRect(dw/2 - 40, head_y - 20, 80, 40, 8,
fillColor=HexColor("#AED6F1"), strokeColor=C_BLUE_MID, strokeWidth=1)
d.add(head_r)
d.add(String(dw/2, head_y - 5, "POLAR HEAD",
fontName="Helvetica-Bold", fontSize=8,
fillColor=C_BLUE_DARK, textAnchor="middle"))
d.add(String(dw/2, head_y - 16, "(Phosphate + Choline)",
fontName="Helvetica", fontSize=7,
fillColor=C_BLUE_DARK, textAnchor="middle"))
# Glycerol backbone
bb_y = head_y - 45
d.add(RoundRect(dw/2 - 20, bb_y - 10, 40, 20, 4,
fillColor=HexColor("#F9E79F"), strokeColor=HexColor("#B7950B"), strokeWidth=1))
d.add(String(dw/2, bb_y - 5, "Glycerol",
fontName="Helvetica-Bold", fontSize=7.5,
fillColor=HexColor("#7D6608"), textAnchor="middle"))
# Connector lines
d.add(Line(dw/2, head_y - 20, dw/2, bb_y + 10,
strokeColor=C_BLUE_MID, strokeWidth=1.5))
# Two fatty acid tails
tail_y_top = bb_y - 10
tail_h = 50
for tx, label in [(dw/2 - 22, "Fatty Acid\n(tail 1)"), (dw/2 + 22, "Fatty Acid\n(tail 2)")]:
d.add(Line(tx, tail_y_top, tx, tail_y_top - tail_h,
strokeColor=C_ORANGE, strokeWidth=2.5))
for seg_y in range(int(tail_y_top - 5), int(tail_y_top - tail_h + 5), -8):
pass # just straight tails
d.add(String(tx, tail_y_top - tail_h - 8, label.split("\n")[0],
fontName="Helvetica", fontSize=6.5,
fillColor=C_ORANGE, textAnchor="middle"))
# Hydrophobic label
d.add(String(dw/2, 8, "HYDROPHOBIC TAILS (Non-polar)",
fontName="Helvetica-BoldOblique", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
d.add(String(dw/2, head_y + 12, "HYDROPHILIC HEAD (Polar)",
fontName="Helvetica-BoldOblique", fontSize=7,
fillColor=C_BLUE_MID, textAnchor="middle"))
return d
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 3 – Triglyceride structure
# ─────────────────────────────────────────────────────────────────────────────
def make_triglyceride_diagram():
dw, dh = TW * 0.45, 140
d = Drawing(dw, dh)
mid_x = dw / 2
# Glycerol column
gy = [dh - 30, dh - 60, dh - 90]
for i, y in enumerate(gy):
d.add(RoundRect(mid_x - 28, y - 12, 56, 24, 4,
fillColor=HexColor("#F9E79F"),
strokeColor=HexColor("#B7950B"), strokeWidth=0.8))
d.add(String(mid_x, y - 4, f"C{i+1} — OH",
fontName="Helvetica-Bold", fontSize=8,
fillColor=HexColor("#7D6608"), textAnchor="middle"))
# Backbone label
d.add(String(mid_x, dh - 10, "GLYCEROL",
fontName="Helvetica-Bold", fontSize=8,
fillColor=C_BLUE_DARK, textAnchor="middle"))
# Fatty acid tails
fa_x = mid_x + 80
for i, y in enumerate(gy):
d.add(Line(mid_x + 28, y, fa_x - 35, y,
strokeColor=HexColor("#888888"), strokeWidth=0.8))
d.add(Line(fa_x - 35, y - 10, fa_x + 35, y - 10,
strokeColor=C_ORANGE, strokeWidth=2.5))
d.add(String(fa_x, y - 10 - 8, f"Fatty Acid {i+1}",
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
# ester bond label
d.add(String(mid_x + 50, y + 3, "ester bond",
fontName="Helvetica-Oblique", fontSize=6,
fillColor=HexColor("#999999"), textAnchor="middle"))
d.add(String(dw/2, 5, "TRIGLYCERIDE = Glycerol + 3 Fatty Acids",
fontName="Helvetica-Bold", fontSize=7.5,
fillColor=C_GREEN, textAnchor="middle"))
return d
# ─────────────────────────────────────────────────────────────────────────────
# BUILD STORY
# ─────────────────────────────────────────────────────────────────────────────
story = []
# ── COVER BANNER ────────────────────────────────────────────────────────────
cover = Table(
[[Paragraph("CLASSIFICATION OF LIPIDS", title_style)],
[Paragraph("1st Year MBBS · Biochemistry · 4-Mark Study Guide", subtitle_style)]],
colWidths=[TW]
)
cover.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_BLUE_DARK),
("TOPPADDING", (0,0), (-1,-1), 12),
("BOTTOMPADDING", (0,0), (-1,-1), 12),
("LEFTPADDING", (0,0), (-1,-1), 12),
("RIGHTPADDING", (0,0), (-1,-1), 12),
("ROUNDEDCORNERS", [8]*4),
]))
story.append(cover)
story.append(Spacer(1, 10))
# ── DEFINITION ───────────────────────────────────────────────────────────────
story.append(banner("📌 DEFINITION", h1, C_BLUE_DARK))
story.append(Spacer(1, 4))
story.append(Paragraph(
"<b>Lipids</b> are <b>organic biomolecules</b> that are <b>insoluble in water</b> but "
"<b>soluble in organic solvents</b> (ether, chloroform, benzene). "
"They contain <b>C, H, O</b> (some also contain N, P, S). "
"They serve as energy stores, membrane components, and signalling molecules.",
body))
story.append(Spacer(1, 8))
# ── MAIN CLASSIFICATION DIAGRAM (Tree) ──────────────────────────────────────
story.append(banner("🌳 CLASSIFICATION OVERVIEW — MIND MAP", h1, C_BLUE_MID))
story.append(Spacer(1, 6))
story.append(make_tree_diagram())
story.append(Spacer(1, 6))
# ── SIMPLE LIPIDS ────────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("1. SIMPLE LIPIDS", h1, C_GREEN),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Esters of <b>fatty acids + alcohol ONLY</b>. "
"No extra group attached.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Fats (Triglycerides)</b>", body_bold),
Paragraph("3 Fatty acids + Glycerol. Main <b>energy storage</b> in body. "
"E.g., body fat, butter, ghee.", small)],
[Paragraph("<b>Waxes</b>", body_bold),
Paragraph("1 Fatty acid + Long-chain alcohol. Water-repellent. "
"E.g., Beeswax (Myricyl palmitate), Earwax, Lanolin (skin).", small)],
],
"TYPE ▸ SIMPLE LIPIDS", C_GREEN, C_GREEN_L
),
Spacer(1, 6),
]))
# Triglyceride diagram
story.append(Paragraph("<b>Triglyceride Structure:</b>", h2))
story.append(make_triglyceride_diagram())
story.append(Spacer(1, 6))
# ── COMPOUND LIPIDS ──────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("2. COMPOUND LIPIDS (Complex Lipids)", h1, C_PURPLE),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Simple lipid + <b>one extra non-lipid group</b>.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Phospholipids</b>", body_bold),
Paragraph("Fatty acid + Glycerol + <b>Phosphate + Nitrogen base</b>. "
"Form <b>cell membrane bilayer</b>. E.g., Lecithin (PC), Cephalin (PE), Sphingomyelin.", small)],
[Paragraph("<b>Glycolipids</b>", body_bold),
Paragraph("Fatty acid + Sphingosine + <b>Carbohydrate (sugar)</b>. "
"Found in <b>brain & nerve tissue</b>. E.g., Cerebrosides, Gangliosides.", small)],
[Paragraph("<b>Lipoproteins</b>", body_bold),
Paragraph("Lipid + <b>Protein</b>. Transport lipids in <b>blood</b>. "
"E.g., HDL, LDL, VLDL, Chylomicrons.", small)],
[Paragraph("<b>Sulfolipids</b>", body_bold),
Paragraph("Contain a <b>sulfate (–SO₄)</b> group. Found in brain tissue.", small)],
[Paragraph("<b>Aminolipids</b>", body_bold),
Paragraph("Contain an <b>amino (–NH₂)</b> group. Found in body tissues.", small)],
],
"TYPE ▸ COMPOUND LIPIDS", C_PURPLE, C_PURPLE_L
),
]))
story.append(Spacer(1, 6))
# Phospholipid diagram
story.append(Paragraph("<b>Phospholipid Structure (Amphipathic):</b>", h2))
diag_row = Table([[make_phospholipid_diagram(),
Paragraph(
"<b>Key Points:</b><br/>"
"• Has a <b>hydrophilic (water-loving) head</b> — faces outward<br/>"
"• Has <b>hydrophobic (water-fearing) tails</b> — face inward<br/>"
"• This amphipathic nature allows formation of the<br/>"
" <b>lipid bilayer</b> — the basic structure of all cell membranes<br/>"
"• Lecithin (phosphatidylcholine) is the most abundant<br/>"
" phospholipid in the body<br/>"
"• Dipalmitoyl lecithin = <b>lung surfactant</b> (prevents alveolar collapse)",
PS("Note", fontName="Helvetica", fontSize=8.5,
textColor=HexColor("#212121"), leading=13)
)]],
colWidths=[TW*0.45, TW*0.55])
diag_row.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 4),
("BACKGROUND", (1,0), (1,0), C_PURPLE_L),
("TOPPADDING", (1,0), (1,0), 8),
("BOTTOMPADDING", (1,0), (1,0), 8),
]))
story.append(diag_row)
story.append(Spacer(1, 6))
# ── DERIVED LIPIDS ───────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("3. DERIVED LIPIDS", h1, C_ORANGE),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Products obtained by <b>hydrolysis</b> of simple or compound lipids. "
"They do NOT contain ester linkage.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Fatty Acids</b>", body_bold),
Paragraph("E.g., Palmitic (C16:0), Stearic (C18:0), Oleic (C18:1 — unsaturated). "
"Basic building blocks of all lipids.", small)],
[Paragraph("<b>Sterols</b>", body_bold),
Paragraph("<b>Cholesterol</b> — most important sterol. Precursor for steroid hormones, "
"bile acids & Vitamin D. Plant: Phytosterols. Fungi: Ergosterol.", small)],
[Paragraph("<b>Glycerol</b>", body_bold),
Paragraph("3-carbon backbone of triglycerides. Released on fat hydrolysis.", small)],
[Paragraph("<b>Fat-Soluble Vitamins</b>", body_bold),
Paragraph("<b>A, D, E, K</b> — stored in adipose tissue & liver. "
"NOT excreted easily → risk of toxicity if excess.", small)],
[Paragraph("<b>Steroid Hormones</b>", body_bold),
Paragraph("Cortisol, Aldosterone (adrenal cortex); Testosterone, Estrogen, Progesterone "
"(gonads). All derived from <b>Cholesterol</b>.", small)],
[Paragraph("<b>Bile Acids</b>", body_bold),
Paragraph("Cholic acid, Chenodeoxycholic acid. Made in liver from cholesterol. "
"Help in <b>fat digestion & absorption</b> in intestine.", small)],
[Paragraph("<b>Prostaglandins</b>", body_bold),
Paragraph("20-carbon compounds derived from Arachidonic acid. "
"Involved in <b>inflammation, pain, fever</b>.", small)],
],
"TYPE ▸ DERIVED LIPIDS", C_ORANGE, C_ORANGE_L
),
Spacer(1, 6),
]))
# ── SUMMARY TABLE ────────────────────────────────────────────────────────────
story.append(banner("📋 EXAM SUMMARY TABLE — Write This in Your Exam!", h1, C_BLUE_DARK))
story.append(Spacer(1, 5))
sum_data = [
[Paragraph("<b>Class</b>", PS("SH2", fontName="Helvetica-Bold", fontSize=9, textColor=white)),
Paragraph("<b>Definition</b>", PS("SH2", fontName="Helvetica-Bold", fontSize=9, textColor=white)),
Paragraph("<b>Examples</b>", PS("SH2", fontName="Helvetica-Bold", fontSize=9, textColor=white)),
Paragraph("<b>Function</b>", PS("SH2", fontName="Helvetica-Bold", fontSize=9, textColor=white))],
[Paragraph("<b>Simple</b>", PS("GH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_GREEN)),
Paragraph("FA + Alcohol only", small),
Paragraph("Triglycerides, Waxes", small),
Paragraph("Energy storage, protection", small)],
[Paragraph("<b>Compound</b>", PS("PH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_PURPLE)),
Paragraph("Simple lipid + extra group", small),
Paragraph("Phospholipids, Glycolipids, Lipoproteins", small),
Paragraph("Cell membranes, lipid transport", small)],
[Paragraph("<b>Derived</b>", PS("OH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_ORANGE)),
Paragraph("Hydrolysis products", small),
Paragraph("Cholesterol, Fatty acids, Vitamins A/D/E/K", small),
Paragraph("Hormones, vitamins, bile, signalling", small)],
]
sum_tbl = Table(sum_data, colWidths=[TW*0.14, TW*0.25, TW*0.32, TW*0.29])
sum_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), C_BLUE_DARK),
("BACKGROUND", (0,1), (-1,1), C_GREEN_L),
("BACKGROUND", (0,2), (-1,2), C_PURPLE_L),
("BACKGROUND", (0,3), (-1,3), C_ORANGE_L),
("GRID", (0,0), (-1,-1), 0.5, C_GRAY_MID),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
]))
story.append(sum_tbl)
story.append(Spacer(1, 8))
# ── MEMORY TRICKS ─────────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("🧠 MEMORY TRICKS", h1, HexColor("#E74C3C")),
Spacer(1, 5),
Table(
[[Paragraph(
"<b>S – C – D</b><br/>"
"<font color='#1B7A3E'><b>S</b></font> = Simple (Fats + Waxes)<br/>"
"<font color='#6A1B9A'><b>C</b></font> = Compound (Phospho + Glyco + Lipoproteins)<br/>"
"<font color='#B85C00'><b>D</b></font> = Derived (Cholesterol, FA, Vitamins, Hormones)",
PS("Mem", fontName="Helvetica-Bold", fontSize=11,
textColor=C_BLUE_DARK, leading=18)),
Paragraph(
"<b>For Compound Lipids:</b><br/>"
"<font color='#6A1B9A'><b>P</b></font>lease <font color='#6A1B9A'><b>G</b></font>ive "
"<font color='#6A1B9A'><b>L</b></font>ectures<br/>"
"= <b>P</b>hosphol. · <b>G</b>lycolipids · <b>L</b>ipoproteins<br/><br/>"
"<b>Fat-Soluble Vitamins: ADEK</b><br/>"
"<i>\"A Dog Eats Kibble\"</i>",
PS("Mem2", fontName="Helvetica", fontSize=10,
textColor=C_BLUE_DARK, leading=16))]],
colWidths=[TW*0.5, TW*0.5]
),
Spacer(1, 5),
]))
# ── CLINICAL POINTS ───────────────────────────────────────────────────────────
story.append(Spacer(1, 4))
story.append(banner("⚕️ IMPORTANT CLINICAL POINTS (Impress Examiner!)", h1, HexColor("#1A7A1A")))
story.append(Spacer(1, 5))
clinical_data = [
["•", Paragraph("<b>Phospholipids</b> form the <b>lipid bilayer</b> of ALL cell membranes — amphipathic structure.", small)],
["•", Paragraph("<b>Cholesterol</b> is the parent molecule for: Steroid hormones, Bile acids, Vitamin D.", small)],
["•", Paragraph("<b>Triglycerides</b> = Main energy storage form. 1g fat → 9 kcal (more than carbs/proteins).", small)],
["•", Paragraph("<b>Lipoproteins</b> (HDL, LDL, VLDL, Chylomicrons) transport lipids in blood — lipids cannot dissolve alone in plasma.", small)],
["•", Paragraph("<b>Lung surfactant</b> = Dipalmitoyl phosphatidylcholine (DPPC) — prevents alveolar collapse on expiration.", small)],
["•", Paragraph("<b>Prostaglandins</b> derived from arachidonic acid — target of NSAIDs (aspirin, ibuprofen).", small)],
["•", Paragraph("<b>Fat-soluble vitamins A,D,E,K</b> → stored in liver/adipose tissue → toxicity possible if overdosed.", small)],
]
cli_tbl = Table(clinical_data, colWidths=[0.4*cm, TW - 0.4*cm])
cli_tbl.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
("ROWBACKGROUNDS", (0,0), (-1,-1),
[HexColor("#F0FFF0"), HexColor("#FFFFFF")]),
]))
story.append(cli_tbl)
story.append(Spacer(1, 8))
# ── FOOTER ───────────────────────────────────────────────────────────────────
story.append(HRFlowable(width=TW, color=C_BLUE_DARK, thickness=1))
story.append(Spacer(1, 4))
story.append(Paragraph(
"1st Year MBBS · Biochemistry · Classification of Lipids · Study Guide | Good Luck in Your Exams! 🎓",
PS("Footer", fontName="Helvetica-Oblique", fontSize=8,
textColor=HexColor("#888888"), alignment=TA_CENTER)
))
# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
python3 /home/daytona/workspace/lipids-study-guide/generate_pdf.py 2>&1
python3 -c "import reportlab.graphics.shapes as s; print(dir(s))" 2>&1 | tr ',' '\n' | grep -i round
python3 -c "import reportlab.graphics.shapes as s; shapes = [x for x in dir(s) if not x.startswith('_')]; print(shapes)"
RoundRect - I'll use Rect with standard corners and Path to simulate rounded corners, or simply use Rect. Let me fix the script to use only available shapes (Rect, Polygon, Circle, Line, String, Drawing, Group).~/lipids-study-guide/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Circle, Polygon, PolyLine
from reportlab.graphics import renderPDF
from reportlab.lib.colors import HexColor, white, black
OUTPUT = "/home/daytona/workspace/lipids-study-guide/Lipid_Classification_Study_Guide.pdf"
# ── Colour palette ──────────────────────────────────────────────────────────
C_BLUE_DARK = HexColor("#1A3C6E")
C_BLUE_MID = HexColor("#2E6FD8")
C_BLUE_LIGHT = HexColor("#D6E6FF")
C_GREEN = HexColor("#1B7A3E")
C_GREEN_L = HexColor("#D4F0E0")
C_PURPLE = HexColor("#6A1B9A")
C_PURPLE_L = HexColor("#EDE0F7")
C_ORANGE = HexColor("#B85C00")
C_ORANGE_L = HexColor("#FDEBD0")
C_RED = HexColor("#C0392B")
C_GRAY_MID = HexColor("#CCCCCC")
C_GRAY_LIGHT = HexColor("#F5F5F5")
# ── Document ─────────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT, pagesize=A4,
leftMargin=1.5*cm, rightMargin=1.5*cm,
topMargin=1.5*cm, bottomMargin=1.5*cm
)
W, H = A4
TW = W - 3*cm
styles = getSampleStyleSheet()
def PS(name, **kw):
return ParagraphStyle(name, **kw)
title_style = PS("Title2",
fontName="Helvetica-Bold", fontSize=22,
textColor=white, alignment=TA_CENTER, spaceAfter=4)
subtitle_style = PS("Subtitle",
fontName="Helvetica", fontSize=11,
textColor=HexColor("#BBDEFB"), alignment=TA_CENTER)
h1 = PS("H1",
fontName="Helvetica-Bold", fontSize=13,
textColor=white, alignment=TA_CENTER, spaceAfter=2)
h2 = PS("H2",
fontName="Helvetica-Bold", fontSize=12,
textColor=C_BLUE_DARK, spaceBefore=8, spaceAfter=4)
body = PS("Body",
fontName="Helvetica", fontSize=9.5,
textColor=HexColor("#212121"), leading=14, spaceAfter=3)
body_bold = PS("BodyBold",
fontName="Helvetica-Bold", fontSize=9.5,
textColor=HexColor("#212121"), leading=14)
small = PS("Small",
fontName="Helvetica", fontSize=8.5,
textColor=HexColor("#444444"), leading=12)
# ─────────────────────────────────────────────────────────────────────────────
# Helper: coloured banner
# ─────────────────────────────────────────────────────────────────────────────
def banner(text, style, bg, pad=7):
tbl = Table([[Paragraph(text, style)]], colWidths=[TW])
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), pad),
("BOTTOMPADDING", (0,0), (-1,-1), pad),
("LEFTPADDING", (0,0), (-1,-1), 12),
("RIGHTPADDING", (0,0), (-1,-1), 12),
]))
return tbl
# ─────────────────────────────────────────────────────────────────────────────
# Helper: section table
# ─────────────────────────────────────────────────────────────────────────────
def section_box(content_rows, header_text, header_bg, stripe_bg):
data = [[Paragraph(f"<b>{header_text}</b>",
PS("SH", fontName="Helvetica-Bold", fontSize=9,
textColor=white, alignment=TA_LEFT)),
""]]
data += content_rows
col_w = [TW*0.32, TW*0.68]
tbl = Table(data, colWidths=col_w)
cmds = [
("SPAN", (0,0), (1,0)),
("BACKGROUND", (0,0), (1,0), header_bg),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
("GRID", (0,1), (-1,-1), 0.4, C_GRAY_MID),
("LINEBELOW", (0,0), (1,0), 1, white),
("VALIGN", (0,0), (-1,-1), "TOP"),
]
for i in range(1, len(data)):
bg = stripe_bg if i % 2 == 0 else white
cmds.append(("BACKGROUND", (0,i), (1,i), bg))
tbl.setStyle(TableStyle(cmds))
return tbl
# ─────────────────────────────────────────────────────────────────────────────
# Helper: draw a box with label (using Rect + String)
# ─────────────────────────────────────────────────────────────────────────────
def draw_box(d, cx, cy, w, h, fill, stroke, text, font_size=8.5, text_color=None):
if text_color is None:
text_color = white
r = Rect(cx - w/2, cy - h/2, w, h,
fillColor=fill, strokeColor=stroke, strokeWidth=0.8)
d.add(r)
# Simple single-line text
s = String(cx, cy - font_size * 0.38, text,
fontName="Helvetica-Bold", fontSize=font_size,
fillColor=text_color, textAnchor="middle")
d.add(s)
def draw_small_box(d, cx, cy, w, h, fill, stroke, text, font_size=7.5, text_color=None):
if text_color is None:
text_color = black
r = Rect(cx - w/2, cy - h/2, w, h,
fillColor=fill, strokeColor=stroke, strokeWidth=0.5)
d.add(r)
s = String(cx, cy - font_size * 0.38, text,
fontName="Helvetica", fontSize=font_size,
fillColor=text_color, textAnchor="middle")
d.add(s)
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 1 – Classification Tree
# ─────────────────────────────────────────────────────────────────────────────
def make_tree_diagram():
dw = float(TW)
dh = 220.0
d = Drawing(dw, dh)
cx = dw / 2.0
# Root
root_y = dh - 28.0
draw_box(d, cx, root_y, 150, 28, C_BLUE_DARK, HexColor("#0A1E40"), "LIPIDS", 14, white)
# Branch centres
bx = [cx - 185.0, cx, cx + 185.0]
by = root_y - 68.0
b_colors = [C_GREEN, C_PURPLE, C_ORANGE]
b_labels = ["1. SIMPLE LIPIDS", "2. COMPOUND LIPIDS", "3. DERIVED LIPIDS"]
b_w = [115, 128, 115]
for i in range(3):
# Connector from root
d.add(Line(cx, root_y - 14, bx[i], by + 14,
strokeColor=b_colors[i], strokeWidth=1.5))
draw_box(d, bx[i], by, b_w[i], 26, b_colors[i],
HexColor("#000000"), b_labels[i], 9.5, white)
# Leaf nodes
leaf_y = by - 58.0
leaf_data = [
# (parent_x, leaf_x, label, fill, stroke_c)
(bx[0], bx[0]-30, "Fats\n(Triglycerides)", C_GREEN_L, C_GREEN),
(bx[0], bx[0]+38, "Waxes", C_GREEN_L, C_GREEN),
(bx[1], bx[1]-55, "Phospholipids", C_PURPLE_L, C_PURPLE),
(bx[1], bx[1]+2, "Glycolipids", C_PURPLE_L, C_PURPLE),
(bx[1], bx[1]+60, "Lipoproteins", C_PURPLE_L, C_PURPLE),
(bx[2], bx[2]-38, "Fatty Acids", C_ORANGE_L, C_ORANGE),
(bx[2], bx[2]+38, "Sterols &\nHormones", C_ORANGE_L, C_ORANGE),
]
lw, lh = 78.0, 24.0
for px, lx, label, fill, sc in leaf_data:
# connector
d.add(Line(px, by - 13, lx, leaf_y + lh/2,
strokeColor=sc, strokeWidth=0.9))
# box
r = Rect(lx - lw/2, leaf_y - lh/2, lw, lh,
fillColor=fill, strokeColor=sc, strokeWidth=0.5)
d.add(r)
# text (handle newline manually)
lines = label.split("\n")
if len(lines) == 1:
d.add(String(lx, leaf_y - 3.5, lines[0],
fontName="Helvetica", fontSize=7.5,
fillColor=sc, textAnchor="middle"))
else:
d.add(String(lx, leaf_y + 2, lines[0],
fontName="Helvetica", fontSize=7.5,
fillColor=sc, textAnchor="middle"))
d.add(String(lx, leaf_y - 8, lines[1],
fontName="Helvetica", fontSize=7.5,
fillColor=sc, textAnchor="middle"))
# Extra derived items below
extra_y = leaf_y - 40.0
extra_items = [
(bx[2]-38, "Vitamins A,D,E,K"),
(bx[2]+38, "Bile Acids &\nProstaglandins"),
]
ew, eh = 85.0, 22.0
for ex, elabel in extra_items:
d.add(Line(bx[2], leaf_y - lh/2, ex, extra_y + eh/2,
strokeColor=C_ORANGE, strokeWidth=0.7))
r = Rect(ex - ew/2, extra_y - eh/2, ew, eh,
fillColor=C_ORANGE_L, strokeColor=C_ORANGE, strokeWidth=0.4)
d.add(r)
lines = elabel.split("\n")
if len(lines) == 1:
d.add(String(ex, extra_y - 3, lines[0],
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
else:
d.add(String(ex, extra_y + 2.5, lines[0],
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
d.add(String(ex, extra_y - 7, lines[1],
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
return d
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 2 – Phospholipid (amphipathic structure)
# ─────────────────────────────────────────────────────────────────────────────
def make_phospholipid_diagram():
dw = float(TW * 0.48)
dh = 150.0
d = Drawing(dw, dh)
mx = dw / 2.0
# Hydrophilic head
head_y = dh - 32.0
r = Rect(mx - 44, head_y - 20, 88, 40,
fillColor=HexColor("#AED6F1"), strokeColor=C_BLUE_MID, strokeWidth=1)
d.add(r)
d.add(String(mx, head_y + 2, "POLAR HEAD",
fontName="Helvetica-Bold", fontSize=8.5,
fillColor=C_BLUE_DARK, textAnchor="middle"))
d.add(String(mx, head_y - 10, "(Phosphate + Nitrogen base)",
fontName="Helvetica", fontSize=7,
fillColor=C_BLUE_DARK, textAnchor="middle"))
# Glycerol
gly_y = head_y - 46.0
r2 = Rect(mx - 22, gly_y - 11, 44, 22,
fillColor=HexColor("#F9E79F"), strokeColor=HexColor("#B7950B"), strokeWidth=0.8)
d.add(r2)
d.add(String(mx, gly_y - 4, "Glycerol",
fontName="Helvetica-Bold", fontSize=8,
fillColor=HexColor("#7D6608"), textAnchor="middle"))
# Connector head to glycerol
d.add(Line(mx, head_y - 20, mx, gly_y + 11,
strokeColor=C_BLUE_MID, strokeWidth=1.5))
# Two tails
tail_top = gly_y - 11.0
tail_bot = tail_top - 52.0
for tx in [mx - 18, mx + 18]:
d.add(Line(tx, tail_top, tx, tail_bot,
strokeColor=C_ORANGE, strokeWidth=3))
# Tail labels
d.add(String(mx - 18, tail_bot - 9, "Tail 1",
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
d.add(String(mx + 18, tail_bot - 9, "Tail 2",
fontName="Helvetica", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
# Annotations
d.add(String(mx, dh - 8, "HYDROPHILIC HEAD (Water-loving)",
fontName="Helvetica-BoldOblique", fontSize=7,
fillColor=C_BLUE_MID, textAnchor="middle"))
d.add(String(mx, 5, "HYDROPHOBIC TAILS (Water-fearing)",
fontName="Helvetica-BoldOblique", fontSize=7,
fillColor=C_ORANGE, textAnchor="middle"))
return d
# ─────────────────────────────────────────────────────────────────────────────
# DIAGRAM 3 – Triglyceride structure
# ─────────────────────────────────────────────────────────────────────────────
def make_triglyceride_diagram():
dw = float(TW * 0.52)
dh = 150.0
d = Drawing(dw, dh)
mx = dw * 0.3
fa_x = dw * 0.75
# Title
d.add(String(dw/2, dh - 8, "TRIGLYCERIDE STRUCTURE",
fontName="Helvetica-Bold", fontSize=9,
fillColor=C_GREEN, textAnchor="middle"))
# Glycerol boxes
gy = [dh - 45.0, dh - 75.0, dh - 105.0]
labels = ["C1 – OH", "C2 – OH", "C3 – OH"]
for y, lbl in zip(gy, labels):
r = Rect(mx - 28, y - 11, 56, 22,
fillColor=HexColor("#F9E79F"),
strokeColor=HexColor("#B7950B"), strokeWidth=0.8)
d.add(r)
d.add(String(mx, y - 4, lbl,
fontName="Helvetica-Bold", fontSize=8,
fillColor=HexColor("#7D6608"), textAnchor="middle"))
# Glycerol label
d.add(String(mx, dh - 22, "GLYCEROL",
fontName="Helvetica-Bold", fontSize=8,
fillColor=C_BLUE_DARK, textAnchor="middle"))
# Fatty acid tails
for y in gy:
# Ester bond connector
d.add(Line(mx + 28, y, fa_x - 42, y,
strokeColor=HexColor("#888888"), strokeWidth=0.7))
# ester bond label
d.add(String(mx + 50, y + 5, "ester",
fontName="Helvetica-Oblique", fontSize=6,
fillColor=HexColor("#999999"), textAnchor="middle"))
# Fatty acid bar
d.add(Line(fa_x - 42, y, fa_x + 42, y,
strokeColor=C_ORANGE, strokeWidth=4))
# Fatty acid label
d.add(String(fa_x, dh - 22, "FATTY ACIDS (×3)",
fontName="Helvetica-Bold", fontSize=8,
fillColor=C_ORANGE, textAnchor="middle"))
# Formula at bottom
d.add(String(dw/2, 5, "Triglyceride = Glycerol + 3 Fatty Acids (via Ester Bonds)",
fontName="Helvetica-Bold", fontSize=7.5,
fillColor=C_GREEN, textAnchor="middle"))
return d
# ─────────────────────────────────────────────────────────────────────────────
# BUILD STORY
# ─────────────────────────────────────────────────────────────────────────────
story = []
# ── COVER BANNER ─────────────────────────────────────────────────────────────
cover = Table(
[[Paragraph("CLASSIFICATION OF LIPIDS", title_style)],
[Paragraph("1st Year MBBS | Biochemistry | 4-Mark Exam Study Guide", subtitle_style)]],
colWidths=[TW]
)
cover.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_BLUE_DARK),
("TOPPADDING", (0,0), (-1,-1), 12),
("BOTTOMPADDING", (0,0), (-1,-1), 12),
("LEFTPADDING", (0,0), (-1,-1), 14),
("RIGHTPADDING", (0,0), (-1,-1), 14),
]))
story.append(cover)
story.append(Spacer(1, 8))
# ── DEFINITION ───────────────────────────────────────────────────────────────
story.append(banner("DEFINITION", h1, C_BLUE_DARK))
story.append(Spacer(1, 4))
story.append(Paragraph(
"<b>Lipids</b> are <b>organic biomolecules</b> that are <b>insoluble in water</b> but "
"<b>soluble in organic solvents</b> (ether, chloroform, benzene). "
"They contain <b>Carbon, Hydrogen, Oxygen</b> (some also have N, P, S). "
"They serve as energy stores, membrane components, hormones, and signalling molecules.",
body))
story.append(Spacer(1, 8))
# ── MAIN CLASSIFICATION TREE DIAGRAM ─────────────────────────────────────────
story.append(banner("CLASSIFICATION OVERVIEW (Mind Map / Tree Diagram)", h1, C_BLUE_MID))
story.append(Spacer(1, 6))
story.append(make_tree_diagram())
story.append(Spacer(1, 8))
# ── 1. SIMPLE LIPIDS ─────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("1. SIMPLE LIPIDS", h1, C_GREEN),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Esters of <b>fatty acids + alcohol ONLY</b>. No extra group attached.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Fats (Triglycerides)</b>", body_bold),
Paragraph("3 Fatty acids + Glycerol (via ester bonds). Main <b>energy storage</b> form in body. "
"1 g fat = 9 kcal. Examples: body fat, butter, ghee, olive oil.", small)],
[Paragraph("<b>Waxes</b>", body_bold),
Paragraph("1 Fatty acid + Long-chain monohydric alcohol. "
"Water-repellent coating. "
"Examples: Beeswax (Myricyl palmitate), Earwax (cerumen), Lanolin (skin), Carnauba wax.", small)],
],
"TYPE vs DETAILS", C_GREEN, C_GREEN_L
),
Spacer(1, 6),
]))
# Triglyceride diagram
story.append(Paragraph("<b>Triglyceride Structure:</b>", h2))
story.append(make_triglyceride_diagram())
story.append(Spacer(1, 8))
# ── 2. COMPOUND LIPIDS ───────────────────────────────────────────────────────
story.append(KeepTogether([
banner("2. COMPOUND LIPIDS (Complex Lipids)", h1, C_PURPLE),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Consist of simple lipid + <b>one additional non-lipid group</b>.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Phospholipids</b>", body_bold),
Paragraph("FA + Glycerol + <b>Phosphate + Nitrogenous base</b>. "
"Form <b>cell membrane bilayer</b> (amphipathic). "
"E.g., Lecithin (PC), Cephalin (PE), Sphingomyelin. "
"Lung surfactant = DPPC (dipalmitoyl lecithin).", small)],
[Paragraph("<b>Glycolipids</b>", body_bold),
Paragraph("FA + Sphingosine + <b>Carbohydrate (sugar)</b>. "
"Found in <b>brain and nerve tissue</b>. "
"E.g., Cerebrosides (glucose/galactose), Gangliosides.", small)],
[Paragraph("<b>Lipoproteins</b>", body_bold),
Paragraph("Lipid + <b>Protein (apoprotein)</b>. "
"Transport lipids in <b>blood</b> (lipids can't dissolve in plasma alone). "
"E.g., Chylomicrons, VLDL, IDL, LDL, HDL.", small)],
[Paragraph("<b>Sulfolipids</b>", body_bold),
Paragraph("Contain a <b>sulfate (-SO4)</b> group. Found in brain tissue.", small)],
[Paragraph("<b>Aminolipids</b>", body_bold),
Paragraph("Contain an <b>amino (-NH2)</b> group. Found in tissues.", small)],
],
"TYPE vs DETAILS", C_PURPLE, C_PURPLE_L
),
Spacer(1, 6),
]))
# Phospholipid diagram + notes side by side
story.append(Paragraph("<b>Phospholipid (Amphipathic) Structure:</b>", h2))
diag_row = Table(
[[make_phospholipid_diagram(),
Paragraph(
"<b>Key Points:</b><br/>"
"- Has a <b>hydrophilic (polar) head</b> - faces water/outside<br/>"
"- Has <b>hydrophobic (non-polar) tails</b> - face inward<br/>"
"- This amphipathic property = <b>lipid bilayer</b> formation<br/>"
"- Bilayer = basic unit of ALL cell membranes<br/>"
"- Lecithin = most abundant phospholipid in body<br/>"
"- DPPC = lung surfactant (prevents alveolar collapse)<br/>"
"- Cephalin = important in blood clotting",
PS("Note", fontName="Helvetica", fontSize=8.5,
textColor=HexColor("#212121"), leading=14)
)]],
colWidths=[TW*0.46, TW*0.54]
)
diag_row.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 4),
("BACKGROUND", (1,0), (1,0), C_PURPLE_L),
("TOPPADDING", (1,0), (1,0), 10),
("BOTTOMPADDING", (1,0), (1,0), 10),
("LEFTPADDING", (1,0), (1,0), 10),
]))
story.append(diag_row)
story.append(Spacer(1, 8))
# ── 3. DERIVED LIPIDS ────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("3. DERIVED LIPIDS", h1, C_ORANGE),
Spacer(1, 4),
Paragraph(
"<b>Definition:</b> Products obtained by <b>hydrolysis</b> (breakdown) of simple or compound lipids. "
"They do NOT contain ester linkage but have lipid-like properties.",
body),
Spacer(1, 4),
section_box(
[
[Paragraph("<b>Fatty Acids</b>", body_bold),
Paragraph("Basic building blocks of all lipids. "
"Saturated: Palmitic (C16:0), Stearic (C18:0). "
"Unsaturated: Oleic (C18:1), Linoleic (C18:2, essential), Arachidonic (C20:4).", small)],
[Paragraph("<b>Sterols</b>", body_bold),
Paragraph("<b>Cholesterol</b> - most important. Animal sterols. "
"Phytosterols (plants), Ergosterol (fungi - precursor of Vit D). "
"Cholesterol = precursor of steroid hormones, bile acids, Vit D.", small)],
[Paragraph("<b>Glycerol</b>", body_bold),
Paragraph("3-carbon backbone released on hydrolysis of triglycerides.", small)],
[Paragraph("<b>Fat-Soluble Vitamins</b>", body_bold),
Paragraph("<b>A, D, E, K</b> - stored in liver and adipose tissue. "
"NOT excreted in urine - risk of toxicity if overdosed.", small)],
[Paragraph("<b>Steroid Hormones</b>", body_bold),
Paragraph("All derived from <b>Cholesterol</b>. "
"Cortisol, Aldosterone (adrenal cortex); "
"Testosterone, Estrogen, Progesterone (gonads).", small)],
[Paragraph("<b>Bile Acids</b>", body_bold),
Paragraph("Made in liver from cholesterol. "
"E.g., Cholic acid, Chenodeoxycholic acid. "
"Function: emulsify fats for digestion and absorption.", small)],
[Paragraph("<b>Prostaglandins</b>", body_bold),
Paragraph("20-carbon compounds from Arachidonic acid. "
"Involved in inflammation, pain, fever, platelet aggregation. "
"Target of NSAIDs (aspirin, ibuprofen).", small)],
],
"TYPE vs DETAILS", C_ORANGE, C_ORANGE_L
),
Spacer(1, 6),
]))
# ── SUMMARY TABLE ─────────────────────────────────────────────────────────────
story.append(banner("EXAM SUMMARY TABLE - Write This in Your Exam!", h1, C_BLUE_DARK))
story.append(Spacer(1, 5))
hdr = lambda t: Paragraph(f"<b>{t}</b>",
PS("SH2", fontName="Helvetica-Bold", fontSize=9, textColor=white))
sum_data = [
[hdr("Class"), hdr("Definition"), hdr("Examples"), hdr("Main Function")],
[Paragraph("<b>Simple</b>",
PS("GH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_GREEN)),
Paragraph("FA + Alcohol only<br/>(ester bond)", small),
Paragraph("Triglycerides, Waxes", small),
Paragraph("Energy storage, waterproofing", small)],
[Paragraph("<b>Compound</b>",
PS("PH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_PURPLE)),
Paragraph("Simple lipid +<br/>extra non-lipid group", small),
Paragraph("Phospholipids,<br/>Glycolipids, Lipoproteins", small),
Paragraph("Cell membranes,<br/>lipid transport in blood", small)],
[Paragraph("<b>Derived</b>",
PS("OH", fontName="Helvetica-Bold", fontSize=8.5, textColor=C_ORANGE)),
Paragraph("Hydrolysis products<br/>of above", small),
Paragraph("Cholesterol, Fatty acids,<br/>Vitamins A/D/E/K,<br/>Steroid hormones", small),
Paragraph("Hormones, vitamins,<br/>bile salts, signalling", small)],
]
sum_tbl = Table(sum_data, colWidths=[TW*0.13, TW*0.24, TW*0.32, TW*0.31])
sum_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), C_BLUE_DARK),
("BACKGROUND", (0,1), (-1,1), C_GREEN_L),
("BACKGROUND", (0,2), (-1,2), C_PURPLE_L),
("BACKGROUND", (0,3), (-1,3), C_ORANGE_L),
("GRID", (0,0), (-1,-1), 0.5, C_GRAY_MID),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
]))
story.append(sum_tbl)
story.append(Spacer(1, 8))
# ── MEMORY TRICKS ─────────────────────────────────────────────────────────────
story.append(KeepTogether([
banner("MEMORY TRICKS", h1, HexColor("#C0392B")),
Spacer(1, 5),
Table(
[[Paragraph(
"<b>Remember 3 Classes: S - C - D</b><br/><br/>"
"<font color='#1B7A3E'><b>S</b></font> = Simple (Fats + Waxes)<br/>"
"<font color='#6A1B9A'><b>C</b></font> = Compound (Phospholipids, Glycolipids, Lipoproteins)<br/>"
"<font color='#B85C00'><b>D</b></font> = Derived (Cholesterol, Fatty acids, Vitamins A/D/E/K)",
PS("M1", fontName="Helvetica-Bold", fontSize=10.5,
textColor=C_BLUE_DARK, leading=18)),
Paragraph(
"<b>For Compound Lipids - PGL:</b><br/>"
"<i>\"Please Give Lectures\"</i><br/>"
"<b>P</b> = Phospholipids<br/>"
"<b>G</b> = Glycolipids<br/>"
"<b>L</b> = Lipoproteins<br/><br/>"
"<b>Fat-Soluble Vitamins: ADEK</b><br/>"
"<i>\"A Dog Eats Kibble\"</i>",
PS("M2", fontName="Helvetica", fontSize=10,
textColor=C_BLUE_DARK, leading=15))]],
colWidths=[TW*0.54, TW*0.46]
),
Spacer(1, 5),
]))
# ── CLINICAL POINTS ───────────────────────────────────────────────────────────
story.append(Spacer(1, 4))
story.append(banner("IMPORTANT CLINICAL POINTS (Impress Your Examiner!)", h1, HexColor("#1A7A1A")))
story.append(Spacer(1, 5))
clinical_data = [
["*", Paragraph("<b>Phospholipids</b> form the <b>lipid bilayer</b> of ALL cell membranes because of their amphipathic structure.", small)],
["*", Paragraph("<b>Cholesterol</b> is parent molecule for: steroid hormones + bile acids + Vitamin D.", small)],
["*", Paragraph("<b>Triglycerides</b> = main energy storage (9 kcal/g vs 4 kcal/g for carbs/proteins).", small)],
["*", Paragraph("<b>Lipoproteins</b> (HDL, LDL, VLDL, Chylomicrons) transport lipids in blood since lipids alone cannot dissolve in plasma.", small)],
["*", Paragraph("<b>DPPC (Dipalmitoyl phosphatidylcholine)</b> = lung surfactant. Deficiency in premature babies = Respiratory Distress Syndrome (RDS).", small)],
["*", Paragraph("<b>Prostaglandins</b> from arachidonic acid - NSAIDs (aspirin, ibuprofen) block their synthesis = anti-inflammatory effect.", small)],
["*", Paragraph("<b>Fat-soluble vitamins A,D,E,K</b> - stored in liver/adipose - risk of hypervitaminosis (toxicity) if overdosed.", small)],
]
cli_tbl = Table(clinical_data, colWidths=[0.35*cm, TW - 0.35*cm])
cli_tbl.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
("ROWBACKGROUNDS", (0,0), (-1,-1),
[HexColor("#F0FFF0"), HexColor("#FFFFFF")]),
]))
story.append(cli_tbl)
story.append(Spacer(1, 8))
# ── FOOTER ────────────────────────────────────────────────────────────────────
story.append(HRFlowable(width=TW, color=C_BLUE_DARK, thickness=1))
story.append(Spacer(1, 4))
story.append(Paragraph(
"1st Year MBBS | Biochemistry | Classification of Lipids Study Guide | Best of Luck in Your Exams!",
PS("Footer", fontName="Helvetica-Oblique", fontSize=8,
textColor=HexColor("#888888"), alignment=TA_CENTER)
))
# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
~/lipids-study-guide/generate_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/lipids-study-guide/generate_pdf.py'
RoundRect imports. Let me overwrite it via execute directly:cat > /home/daytona/workspace/lipids-study-guide/generate_pdf.py << 'PYEOF' from reportlab.lib.pagesizes import A4 from reportlab.lib.units import cm from reportlab.lib.styles import ParagraphStyle from reportlab.lib.enums import TA_CENTER, TA_LEFT from reportlab.platypus import ( SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable, KeepTogether ) from reportlab.graphics.shapes import Drawing, Rect, String, Line from reportlab.lib.colors import HexColor, white, black OUTPUT = "/home/daytona/workspace/lipids-study-guide/Lipid_Classification_Study_Guide.pdf" C_BLUE_DARK = HexColor("#1A3C6E") C_BLUE_MID = HexColor("#2E6FD8") C_GREEN = HexColor("#1B7A3E") C_GREEN_L = HexColor("#D4F0E0") C_PURPLE = HexColor("#6A1B9A") C_PURPLE_L = HexColor("#EDE0F7") C_ORANGE = HexColor("#B85C00") C_ORANGE_L = HexColor("#FDEBD0") C_RED = HexColor("#C0392B") C_GRAY_MID = HexColor("#CCCCCC") doc = SimpleDocTemplate(OUTPUT, pagesize=A4, leftMargin=1.5*cm, rightMargin=1.5*cm, topMargin=1.5*cm, bottomMargin=1.5*cm) W, H = A4 TW = W - 3*cm def PS(name, **kw): return ParagraphStyle(name, **kw) title_s = PS("T", fontName="Helvetica-Bold", fontSize=22, textColor=white, alignment=TA_CENTER) sub_s = PS("S", fontName="Helvetica", fontSize=11, textColor=HexColor("#BBDEFB"), alignment=TA_CENTER) h1_s = PS("H1", fontName="Helvetica-Bold", fontSize=12, textColor=white, alignment=TA_CENTER) h2_s = PS("H2", fontName="Helvetica-Bold", fontSize=12, textColor=C_BLUE_DARK, spaceBefore=6, spaceAfter=3) body_s = PS("B", fontName="Helvetica", fontSize=9.5, textColor=HexColor("#212121"), leading=14) bold_s = PS("BB", fontName="Helvetica-Bold", fontSize=9.5, textColor=HexColor("#212121"), leading=14) small_s = PS("Sm", fontName="Helvetica", fontSize=8.5, textColor=HexColor("#444444"), leading=12) def banner(text, style, bg, pad=7): t = Table([[Paragraph(text, style)]], colWidths=[TW]) t.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,-1),bg), ("TOPPADDING",(0,0),(-1,-1),pad),("BOTTOMPADDING",(0,0),(-1,-1),pad), ("LEFTPADDING",(0,0),(-1,-1),12),("RIGHTPADDING",(0,0),(-1,-1),12), ])) return t def sec_table(rows, hdr, hbg, sbg): data = [[Paragraph(f"<b>{hdr}</b>", PS("sh",fontName="Helvetica-Bold",fontSize=9,textColor=white)),""]]+rows t = Table(data, colWidths=[TW*0.30, TW*0.70]) cmds = [ ("SPAN",(0,0),(1,0)),("BACKGROUND",(0,0),(1,0),hbg), ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5), ("LEFTPADDING",(0,0),(-1,-1),8),("RIGHTPADDING",(0,0),(-1,-1),8), ("GRID",(0,1),(-1,-1),0.4,C_GRAY_MID), ("LINEBELOW",(0,0),(1,0),1,white),("VALIGN",(0,0),(-1,-1),"TOP"), ] for i in range(1, len(data)): cmds.append(("BACKGROUND",(0,i),(1,i), sbg if i%2==0 else white)) t.setStyle(TableStyle(cmds)) return t # ── DIAGRAM 1: Classification Tree ────────────────────────────────────────── def tree_diagram(): dw, dh = float(TW), 215.0 d = Drawing(dw, dh) cx = dw / 2.0 def box(bx, by, bw, bh, fill, label, fs=9.5, tc=None): if tc is None: tc = white d.add(Rect(bx-bw/2, by-bh/2, bw, bh, fillColor=fill, strokeColor=HexColor("#333333"), strokeWidth=0.7)) d.add(String(bx, by - fs*0.38, label, fontName="Helvetica-Bold", fontSize=fs, fillColor=tc, textAnchor="middle")) def sbox(bx, by, bw, bh, fill, sc, label, fs=7.5): d.add(Rect(bx-bw/2, by-bh/2, bw, bh, fillColor=fill, strokeColor=sc, strokeWidth=0.5)) lines = label.split("|") if len(lines)==1: d.add(String(bx, by-fs*0.4, label, fontName="Helvetica", fontSize=fs, fillColor=sc, textAnchor="middle")) else: d.add(String(bx, by+2.5, lines[0], fontName="Helvetica", fontSize=fs, fillColor=sc, textAnchor="middle")) d.add(String(bx, by-8, lines[1], fontName="Helvetica", fontSize=fs-0.5, fillColor=sc, textAnchor="middle")) root_y = dh - 26.0 box(cx, root_y, 148, 28, C_BLUE_DARK, "LIPIDS", 14) br_y = root_y - 66.0 branches = [ (cx-183, 114, C_GREEN, "1. SIMPLE LIPIDS"), (cx, 130, C_PURPLE, "2. COMPOUND LIPIDS"), (cx+183, 114, C_ORANGE, "3. DERIVED LIPIDS"), ] for bx, bw, bc, bl in branches: d.add(Line(cx, root_y-14, bx, br_y+13, strokeColor=bc, strokeWidth=1.4)) box(bx, br_y, bw, 25, bc, bl, 9.5) leaf_y = br_y - 58.0 lw, lh = 76.0, 22.0 leaves = [ (cx-183, cx-183-28, "Fats|(Triglycerides)", C_GREEN_L, C_GREEN), (cx-183, cx-183+40, "Waxes", C_GREEN_L, C_GREEN), (cx, cx-58, "Phospholipids", C_PURPLE_L, C_PURPLE), (cx, cx+2, "Glycolipids", C_PURPLE_L, C_PURPLE), (cx, cx+62, "Lipoproteins", C_PURPLE_L, C_PURPLE), (cx+183, cx+183-40, "Fatty Acids", C_ORANGE_L, C_ORANGE), (cx+183, cx+183+40, "Sterols &|Hormones", C_ORANGE_L, C_ORANGE), ] for px, lx, lbl, fill, sc in leaves: d.add(Line(px, br_y-12.5, lx, leaf_y+lh/2, strokeColor=sc, strokeWidth=0.8)) sbox(lx, leaf_y, lw, lh, fill, sc, lbl) # Extra derived row ext_y = leaf_y - 38.0 ew, eh = 84.0, 20.0 extras = [(cx+183-40, "Vitamins A,D,E,K"), (cx+183+40, "Bile Acids &|Prostaglandins")] for ex, el in extras: d.add(Line(cx+183, leaf_y-lh/2, ex, ext_y+eh/2, strokeColor=C_ORANGE, strokeWidth=0.65)) d.add(Rect(ex-ew/2, ext_y-eh/2, ew, eh, fillColor=C_ORANGE_L, strokeColor=C_ORANGE, strokeWidth=0.4)) lines = el.split("|") if len(lines)==1: d.add(String(ex, ext_y-3.5, el, fontName="Helvetica", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) else: d.add(String(ex, ext_y+2, lines[0], fontName="Helvetica", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) d.add(String(ex, ext_y-8, lines[1], fontName="Helvetica", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) return d # ── DIAGRAM 2: Phospholipid ────────────────────────────────────────────────── def phospholipid_diagram(): dw, dh = float(TW*0.44), 150.0 d = Drawing(dw, dh) mx = dw / 2.0 # head hy = dh - 30.0 d.add(Rect(mx-46, hy-22, 92, 44, fillColor=HexColor("#AED6F1"), strokeColor=C_BLUE_MID, strokeWidth=1)) d.add(String(mx, hy+3, "POLAR HEAD", fontName="Helvetica-Bold", fontSize=9, fillColor=C_BLUE_DARK, textAnchor="middle")) d.add(String(mx, hy-10, "(Phosphate + Nitrogen base)", fontName="Helvetica", fontSize=7, fillColor=C_BLUE_DARK, textAnchor="middle")) # glycerol gy = hy - 46.0 d.add(Rect(mx-24, gy-12, 48, 24, fillColor=HexColor("#F9E79F"), strokeColor=HexColor("#B7950B"), strokeWidth=0.8)) d.add(String(mx, gy-4, "Glycerol", fontName="Helvetica-Bold", fontSize=8, fillColor=HexColor("#7D6608"), textAnchor="middle")) d.add(Line(mx, hy-22, mx, gy+12, strokeColor=C_BLUE_MID, strokeWidth=1.5)) # tails tt = gy - 12.0 tb = tt - 54.0 for tx in [mx-20, mx+20]: d.add(Line(tx, tt, tx, tb, strokeColor=C_ORANGE, strokeWidth=3.5)) d.add(String(mx-20, tb-9, "FA tail 1", fontName="Helvetica", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) d.add(String(mx+20, tb-9, "FA tail 2", fontName="Helvetica", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) d.add(String(mx, dh-6, "HYDROPHILIC HEAD (Polar, water-loving)", fontName="Helvetica-BoldOblique", fontSize=7, fillColor=C_BLUE_MID, textAnchor="middle")) d.add(String(mx, 4, "HYDROPHOBIC TAILS (Non-polar, water-fearing)", fontName="Helvetica-BoldOblique", fontSize=7, fillColor=C_ORANGE, textAnchor="middle")) return d # ── DIAGRAM 3: Triglyceride ────────────────────────────────────────────────── def triglyceride_diagram(): dw, dh = float(TW*0.56), 145.0 d = Drawing(dw, dh) gx = dw * 0.25 fax = dw * 0.72 d.add(String(dw/2, dh-7, "TRIGLYCERIDE STRUCTURE", fontName="Helvetica-Bold", fontSize=9, fillColor=C_GREEN, textAnchor="middle")) d.add(String(gx, dh-20, "GLYCEROL", fontName="Helvetica-Bold", fontSize=8, fillColor=C_BLUE_DARK, textAnchor="middle")) d.add(String(fax, dh-20, "FATTY ACIDS (x3)", fontName="Helvetica-Bold", fontSize=8, fillColor=C_ORANGE, textAnchor="middle")) gy_list = [dh-48.0, dh-78.0, dh-108.0] for i, gy in enumerate(gy_list): d.add(Rect(gx-30, gy-12, 60, 24, fillColor=HexColor("#F9E79F"), strokeColor=HexColor("#B7950B"), strokeWidth=0.8)) d.add(String(gx, gy-4, f"C{i+1} - OH", fontName="Helvetica-Bold", fontSize=8, fillColor=HexColor("#7D6608"), textAnchor="middle")) d.add(Line(gx+30, gy, fax-46, gy, strokeColor=HexColor("#888888"), strokeWidth=0.8)) d.add(String(gx+52, gy+5, "ester", fontName="Helvetica-Oblique", fontSize=6.5, fillColor=HexColor("#999999"), textAnchor="middle")) d.add(Line(fax-46, gy, fax+46, gy, strokeColor=C_ORANGE, strokeWidth=4.5)) d.add(String(dw/2, 5, "Triglyceride = Glycerol + 3 Fatty Acids (via Ester Bonds)", fontName="Helvetica-Bold", fontSize=8, fillColor=C_GREEN, textAnchor="middle")) return d # ── BUILD STORY ────────────────────────────────────────────────────────────── story = [] # Cover cov = Table([[Paragraph("CLASSIFICATION OF LIPIDS", title_s)], [Paragraph("1st Year MBBS | Biochemistry | 4-Mark Exam Study Guide", sub_s)]], colWidths=[TW]) cov.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,-1),C_BLUE_DARK), ("TOPPADDING",(0,0),(-1,-1),12),("BOTTOMPADDING",(0,0),(-1,-1),12), ("LEFTPADDING",(0,0),(-1,-1),14),("RIGHTPADDING",(0,0),(-1,-1),14), ])) story += [cov, Spacer(1,8)] # Definition story += [banner("DEFINITION", h1_s, C_BLUE_DARK), Spacer(1,4), Paragraph("<b>Lipids</b> are <b>organic biomolecules</b> that are <b>insoluble in water</b> " "but <b>soluble in organic solvents</b> (ether, chloroform, benzene). " "Contain <b>C, H, O</b> (some also N, P, S). Functions: energy storage, " "membrane structure, hormones, signalling.", body_s), Spacer(1,8)] # Tree diagram story += [banner("CLASSIFICATION OVERVIEW - Mind Map", h1_s, C_BLUE_MID), Spacer(1,6), tree_diagram(), Spacer(1,8)] # 1. Simple story.append(KeepTogether([ banner("1. SIMPLE LIPIDS", h1_s, C_GREEN), Spacer(1,4), Paragraph("<b>Definition:</b> Esters of <b>fatty acids + alcohol ONLY</b>. No extra group.", body_s), Spacer(1,4), sec_table( [[Paragraph("<b>Fats (Triglycerides)</b>", bold_s), Paragraph("3 Fatty acids + Glycerol via ester bonds. Main <b>energy storage</b> form. " "1 g fat = 9 kcal. Examples: body fat, butter, ghee, oils.", small_s)], [Paragraph("<b>Waxes</b>", bold_s), Paragraph("1 Fatty acid + Long-chain monohydric alcohol. Water-repellent. " "Examples: Beeswax (myricyl palmitate), Earwax, Lanolin.", small_s)]], "TYPE | DETAILS", C_GREEN, C_GREEN_L), Spacer(1,5), ])) # Triglyceride diagram story += [Paragraph("<b>Triglyceride Structure:</b>", h2_s), triglyceride_diagram(), Spacer(1,8)] # 2. Compound story.append(KeepTogether([ banner("2. COMPOUND LIPIDS (Complex Lipids)", h1_s, C_PURPLE), Spacer(1,4), Paragraph("<b>Definition:</b> Simple lipid + <b>one extra non-lipid group</b>.", body_s), Spacer(1,4), sec_table( [[Paragraph("<b>Phospholipids</b>", bold_s), Paragraph("FA + Glycerol + <b>Phosphate + Nitrogenous base</b>. " "Form <b>cell membrane bilayer</b> (amphipathic). " "E.g., Lecithin (PC), Cephalin (PE), Sphingomyelin. " "DPPC = lung surfactant.", small_s)], [Paragraph("<b>Glycolipids</b>", bold_s), Paragraph("FA + Sphingosine + <b>Carbohydrate (sugar)</b>. " "Brain and nerve tissue. E.g., Cerebrosides, Gangliosides.", small_s)], [Paragraph("<b>Lipoproteins</b>", bold_s), Paragraph("Lipid + <b>Protein (apoprotein)</b>. Transport lipids in blood. " "E.g., Chylomicrons, VLDL, LDL, HDL.", small_s)], [Paragraph("<b>Sulfolipids</b>", bold_s), Paragraph("Contain <b>sulfate (-SO4)</b> group. Brain tissue.", small_s)], [Paragraph("<b>Aminolipids</b>", bold_s), Paragraph("Contain <b>amino (-NH2)</b> group. Body tissues.", small_s)]], "TYPE | DETAILS", C_PURPLE, C_PURPLE_L), Spacer(1,5), ])) # Phospholipid diagram + key notes story += [Paragraph("<b>Phospholipid - Amphipathic Structure:</b>", h2_s)] pr = Table([[phospholipid_diagram(), Paragraph("<b>Key Points:</b><br/>" "- <b>Hydrophilic head</b> faces water (outside)<br/>" "- <b>Hydrophobic tails</b> face inward<br/>" "- This = <b>lipid bilayer</b> of all cell membranes<br/>" "- Lecithin = most abundant phospholipid<br/>" "- DPPC = lung surfactant<br/>" " (deficiency in premature babies = RDS)<br/>" "- Cephalin = important in blood clotting", PS("N",fontName="Helvetica",fontSize=8.5, textColor=HexColor("#212121"),leading=14)) ]], colWidths=[TW*0.42, TW*0.58]) pr.setStyle(TableStyle([ ("VALIGN",(0,0),(-1,-1),"TOP"),("LEFTPADDING",(0,0),(-1,-1),4), ("BACKGROUND",(1,0),(1,0),C_PURPLE_L), ("TOPPADDING",(1,0),(1,0),10),("BOTTOMPADDING",(1,0),(1,0),10), ("LEFTPADDING",(1,0),(1,0),10), ])) story += [pr, Spacer(1,8)] # 3. Derived story.append(KeepTogether([ banner("3. DERIVED LIPIDS", h1_s, C_ORANGE), Spacer(1,4), Paragraph("<b>Definition:</b> Products obtained by <b>hydrolysis</b> of simple or compound lipids. " "Do NOT contain ester linkage but have lipid-like solubility.", body_s), Spacer(1,4), sec_table( [[Paragraph("<b>Fatty Acids</b>", bold_s), Paragraph("Basic building blocks. Saturated: Palmitic (C16:0), Stearic (C18:0). " "Unsaturated: Oleic (C18:1), Linoleic (C18:2 - essential), Arachidonic (C20:4).", small_s)], [Paragraph("<b>Sterols</b>", bold_s), Paragraph("<b>Cholesterol</b> (most important) - precursor of steroid hormones, bile acids, Vit D. " "Phytosterols (plants), Ergosterol (fungi).", small_s)], [Paragraph("<b>Glycerol</b>", bold_s), Paragraph("3-carbon backbone. Released on hydrolysis of triglycerides.", small_s)], [Paragraph("<b>Fat-Soluble Vitamins</b>", bold_s), Paragraph("<b>A, D, E, K</b> - stored in liver and adipose tissue. " "Risk of toxicity (hypervitaminosis) if overdosed.", small_s)], [Paragraph("<b>Steroid Hormones</b>", bold_s), Paragraph("All derived from <b>Cholesterol</b>. " "Cortisol, Aldosterone (adrenal); Testosterone, Estrogen, Progesterone (gonads).", small_s)], [Paragraph("<b>Bile Acids</b>", bold_s), Paragraph("Made in liver from cholesterol. Cholic acid, Chenodeoxycholic acid. " "Emulsify fats for digestion and absorption.", small_s)], [Paragraph("<b>Prostaglandins</b>", bold_s), Paragraph("20-carbon compounds from Arachidonic acid. " "Inflammation, pain, fever. Target of NSAIDs (aspirin, ibuprofen).", small_s)]], "TYPE | DETAILS", C_ORANGE, C_ORANGE_L), Spacer(1,6), ])) # Summary table story += [banner("EXAM SUMMARY TABLE - Write This in Your Answer!", h1_s, C_BLUE_DARK), Spacer(1,5)] h = lambda t: Paragraph(f"<b>{t}</b>", PS("sh2",fontName="Helvetica-Bold",fontSize=9,textColor=white)) sum_data = [ [h("Class"), h("Definition"), h("Examples"), h("Function")], [Paragraph("<b>Simple</b>",PS("g",fontName="Helvetica-Bold",fontSize=9,textColor=C_GREEN)), Paragraph("FA + Alcohol only",small_s), Paragraph("Triglycerides, Waxes",small_s), Paragraph("Energy storage, waterproofing",small_s)], [Paragraph("<b>Compound</b>",PS("p",fontName="Helvetica-Bold",fontSize=9,textColor=C_PURPLE)), Paragraph("Simple lipid + extra group",small_s), Paragraph("Phospholipids, Glycolipids,\nLipoproteins",small_s), Paragraph("Cell membranes, lipid transport",small_s)], [Paragraph("<b>Derived</b>",PS("o",fontName="Helvetica-Bold",fontSize=9,textColor=C_ORANGE)), Paragraph("Hydrolysis products",small_s), Paragraph("Cholesterol, Fatty acids,\nVitamins A/D/E/K, Hormones",small_s), Paragraph("Hormones, vitamins, bile, signalling",small_s)], ] st = Table(sum_data, colWidths=[TW*0.13, TW*0.22, TW*0.35, TW*0.30]) st.setStyle(TableStyle([ ("BACKGROUND",(0,0),(-1,0),C_BLUE_DARK), ("BACKGROUND",(0,1),(-1,1),C_GREEN_L), ("BACKGROUND",(0,2),(-1,2),C_PURPLE_L), ("BACKGROUND",(0,3),(-1,3),C_ORANGE_L), ("GRID",(0,0),(-1,-1),0.5,C_GRAY_MID), ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5), ("LEFTPADDING",(0,0),(-1,-1),6),("RIGHTPADDING",(0,0),(-1,-1),6), ("VALIGN",(0,0),(-1,-1),"MIDDLE"), ])) story += [st, Spacer(1,8)] # Memory tricks story.append(KeepTogether([ banner("MEMORY TRICKS", h1_s, C_RED), Spacer(1,5), Table([[ Paragraph("<b>3 Classes = S - C - D</b><br/><br/>" "<font color='#1B7A3E'><b>S</b></font> = Simple (Fats + Waxes)<br/>" "<font color='#6A1B9A'><b>C</b></font> = Compound (Phospholipids, Glycolipids, Lipoproteins)<br/>" "<font color='#B85C00'><b>D</b></font> = Derived (Cholesterol, FA, Vitamins, Hormones)", PS("m1",fontName="Helvetica-Bold",fontSize=10.5,textColor=C_BLUE_DARK,leading=18)), Paragraph("<b>Compound = PGL</b><br/><i>\"Please Give Lectures\"</i><br/>" "P = Phospholipids<br/>G = Glycolipids<br/>L = Lipoproteins<br/><br/>" "<b>Fat-Soluble Vitamins = ADEK</b><br/><i>\"A Dog Eats Kibble\"</i>", PS("m2",fontName="Helvetica",fontSize=10,textColor=C_BLUE_DARK,leading=15)), ]], colWidths=[TW*0.54, TW*0.46]), Spacer(1,5), ])) # Clinical points story += [Spacer(1,4), banner("IMPORTANT CLINICAL POINTS (Impress Examiner!)", h1_s, HexColor("#1A7A1A")), Spacer(1,5)] clin = [ ["*", Paragraph("<b>Phospholipids</b> form the <b>lipid bilayer</b> of ALL cell membranes (amphipathic property).", small_s)], ["*", Paragraph("<b>Cholesterol</b> = parent molecule for steroid hormones + bile acids + Vitamin D.", small_s)], ["*", Paragraph("<b>Triglycerides</b> = main energy storage: 9 kcal/g (vs 4 kcal/g for carbs and proteins).", small_s)], ["*", Paragraph("<b>Lipoproteins</b> (HDL, LDL, VLDL, Chylomicrons) transport lipids in blood since lipids cannot dissolve in plasma alone.", small_s)], ["*", Paragraph("<b>DPPC (Dipalmitoyl phosphatidylcholine)</b> = lung surfactant. Deficiency in premature babies causes Respiratory Distress Syndrome (RDS).", small_s)], ["*", Paragraph("<b>NSAIDs</b> (aspirin, ibuprofen) block prostaglandin synthesis from arachidonic acid = anti-inflammatory action.", small_s)], ["*", Paragraph("<b>Vitamins A, D, E, K</b> are fat-soluble, stored in liver/adipose tissue - overdose causes toxicity (hypervitaminosis).", small_s)], ] ct = Table(clin, colWidths=[0.35*cm, TW-0.35*cm]) ct.setStyle(TableStyle([ ("VALIGN",(0,0),(-1,-1),"TOP"), ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4), ("LEFTPADDING",(0,0),(-1,-1),4),("RIGHTPADDING",(0,0),(-1,-1),4), ("ROWBACKGROUNDS",(0,0),(-1,-1),[HexColor("#F0FFF0"),white]), ])) story += [ct, Spacer(1,8)] # Footer story += [HRFlowable(width=TW, color=C_BLUE_DARK, thickness=1), Spacer(1,4), Paragraph("1st Year MBBS | Biochemistry | Classification of Lipids | Best of Luck in Your Exams!", PS("ft",fontName="Helvetica-Oblique",fontSize=8, textColor=HexColor("#888888"),alignment=TA_CENTER))] doc.build(story) print(f"PDF saved: {OUTPUT}") PYEOF echo "Script written"
python3 /home/daytona/workspace/lipids-study-guide/generate_pdf.py 2>&1
ls -lh /home/daytona/workspace/lipids-study-guide/Lipid_Classification_Study_Guide.pdf
Lipid Classification Study Guide
PDF Document · PDF
| Section | What you get |
|---|---|
| Cover Banner | Title + "1st Year MBBS - Biochemistry - 4-Mark Exam Study Guide" |
| Definition | Clean, exam-ready definition of lipids |
| Mind Map / Tree Diagram | Full colour branching diagram showing all 3 classes and their sub-types at a glance |
| 1. Simple Lipids | Colour-coded table (green) + Triglyceride structure diagram |
| 2. Compound Lipids | Colour-coded table (purple) + Phospholipid amphipathic structure diagram with key points |
| 3. Derived Lipids | Colour-coded table (orange) covering all 7 derived types |
| Exam Summary Table | 3-row quick-reference table - perfect to copy in your exam answer |
| Memory Tricks | S-C-D trick, PGL trick for compound lipids, ADEK trick for vitamins |
| Clinical Points | 7 important clinical facts to impress your examiner (RDS, NSAIDs, lipoproteins, etc.) |
| Footer | Motivational sign-off |