In sb genetic ke topics ki very short notes ki pdf bna do font thoda big rkhna or diagram add Krna ho toh bhi kr dena jha need ho . Bs unit 3 ko mt add Krna jldi pdf bna do
mkdir -p /tmp/workspace/genetics-notes && ls /tmp/workspace/genetics-notes/
~/genetics-notes/make_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Circle, Polygon, Ellipse
from reportlab.graphics import renderPDF
from reportlab.platypus.flowables import Flowable
import math
# ─── Colors ──────────────────────────────────────────────────────────────────
C_BG = colors.HexColor("#F0F4FF")
C_HDR = colors.HexColor("#1A237E") # dark indigo
C_HDR_LIGHT = colors.HexColor("#3949AB") # medium indigo
C_ACCENT = colors.HexColor("#E53935") # red
C_YELLOW = colors.HexColor("#FFF9C4") # pale yellow
C_GREEN = colors.HexColor("#E8F5E9") # pale green
C_BLUE = colors.HexColor("#E3F2FD") # pale blue
C_PURPLE = colors.HexColor("#F3E5F5") # pale purple
C_ORANGE = colors.HexColor("#FFF3E0") # pale orange
C_WHITE = colors.white
C_TEXT = colors.HexColor("#212121")
C_BOX_HDR = colors.HexColor("#5C6BC0") # box header indigo
C_TEAL = colors.HexColor("#006064")
# ─── Document Setup ──────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
"/tmp/workspace/genetics-notes/Genetics_Short_Notes.pdf",
pagesize=A4,
leftMargin=1.5*cm, rightMargin=1.5*cm,
topMargin=1.5*cm, bottomMargin=1.5*cm
)
W, H = A4
CW = W - 3*cm # content width
# ─── Styles ──────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def S(name, **kw):
return ParagraphStyle(name, **kw)
TITLE_STYLE = S("Title2",
fontSize=26, leading=32, textColor=C_WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER)
UNIT_STYLE = S("Unit",
fontSize=18, leading=24, textColor=C_WHITE,
fontName="Helvetica-Bold", alignment=TA_LEFT)
HEADING_STYLE = S("H2",
fontSize=15, leading=20, textColor=C_HDR,
fontName="Helvetica-Bold", alignment=TA_LEFT,
spaceAfter=4)
SUBHD_STYLE = S("SubH",
fontSize=13, leading=18, textColor=C_HDR_LIGHT,
fontName="Helvetica-Bold", alignment=TA_LEFT,
spaceAfter=2)
BODY_STYLE = S("Body2",
fontSize=12, leading=17, textColor=C_TEXT,
fontName="Helvetica", alignment=TA_JUSTIFY,
spaceAfter=3)
BULLET_STYLE = S("Bullet2",
fontSize=12, leading=16, textColor=C_TEXT,
fontName="Helvetica", leftIndent=12, bulletIndent=0,
spaceAfter=3)
SMALL_STYLE = S("Small2",
fontSize=10, leading=14, textColor=colors.HexColor("#424242"),
fontName="Helvetica", alignment=TA_LEFT)
NOTE_STYLE = S("Note",
fontSize=11, leading=15, textColor=C_ACCENT,
fontName="Helvetica-Bold", alignment=TA_LEFT)
# ─── Helper Flowables ────────────────────────────────────────────────────────
class ColorBox(Flowable):
"""Colored background banner."""
def __init__(self, text, style, bg, width, height=32, radius=6):
super().__init__()
self.text = text
self.style = style
self.bg = bg
self.bw = width
self.bh = height
self.radius = radius
def wrap(self, *args):
return self.bw, self.bh
def draw(self):
self.canv.setFillColor(self.bg)
self.canv.roundRect(0, 0, self.bw, self.bh, self.radius, fill=1, stroke=0)
p = Paragraph(self.text, self.style)
p.wrapOn(self.canv, self.bw - 16, self.bh)
p.drawOn(self.canv, 8, (self.bh - p.height) / 2)
def unit_header(title, subtitle=""):
items = [
ColorBox(title, UNIT_STYLE, C_HDR, CW, height=44, radius=8),
]
if subtitle:
items.append(Spacer(1, 4))
items.append(Paragraph(subtitle, SMALL_STYLE))
items.append(Spacer(1, 6))
return items
def section_box(title, content_rows, bg=C_BLUE):
"""Bordered box with a header and bullet rows."""
data = [[Paragraph(f"<b>{title}</b>", SUBHD_STYLE)]] + \
[[Paragraph(r, BODY_STYLE)] for r in content_rows]
t = Table(data, colWidths=[CW])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), C_BOX_HDR),
('TEXTCOLOR', (0,0), (-1,0), C_WHITE),
('BACKGROUND', (0,1), (-1,-1), bg),
('BOX', (0,0), (-1,-1), 1, C_HDR_LIGHT),
('LINEBELOW', (0,0), (-1,0), 1, C_WHITE),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (-1,-1), 10),
('RIGHTPADDING', (0,0), (-1,-1), 10),
('ROUNDEDCORNERS', [6]),
]))
return [t, Spacer(1, 8)]
def two_col_table(rows, bg1=C_YELLOW, bg2=C_GREEN):
"""Two-column key-value table."""
data = [[Paragraph(f"<b>{k}</b>", SUBHD_STYLE),
Paragraph(v, BODY_STYLE)] for k,v in rows]
t = Table(data, colWidths=[CW*0.35, CW*0.65])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,-1), bg1),
('BACKGROUND', (1,0), (1,-1), bg2),
('BOX', (0,0), (-1,-1), 1, C_HDR_LIGHT),
('INNERGRID', (0,0), (-1,-1), 0.5, colors.HexColor("#9FA8DA")),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
return [t, Spacer(1, 8)]
def hr():
return [HRFlowable(width=CW, thickness=1.5, color=C_HDR_LIGHT), Spacer(1, 6)]
# ═══════════════════════════════════════════════════════════════════════════════
# DIAGRAMS (pure ReportLab Drawing)
# ═══════════════════════════════════════════════════════════════════════════════
# ── Diagram 1: Gene Structure ─────────────────────────────────────────────────
def gene_structure_diagram():
d = Drawing(CW, 130)
# background
d.add(Rect(0, 0, CW, 130, fillColor=colors.HexColor("#E8EAF6"), strokeColor=None))
# title
d.add(String(CW/2, 113, "GENE STRUCTURE", fontSize=12,
fontName="Helvetica-Bold", fillColor=C_HDR, textAnchor="middle"))
# DNA double helix simplified as two parallel wavy lines
import math
cx = CW / 2
# Draw chromosome bar
d.add(Rect(20, 68, CW-40, 18, fillColor=colors.HexColor("#3949AB"),
strokeColor=C_HDR, strokeWidth=1))
d.add(String(cx, 73, "CHROMOSOME", fontSize=9,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
# Gene segments on chromosome
gene_data = [
(30, "Promoter", colors.HexColor("#FF7043")),
(100, "Exon 1", colors.HexColor("#66BB6A")),
(170, "Intron", colors.HexColor("#FFCA28")),
(240, "Exon 2", colors.HexColor("#66BB6A")),
(310, "3'UTR", colors.HexColor("#AB47BC")),
]
for x, label, col in gene_data:
bw = 60
d.add(Rect(x, 68, bw, 18, fillColor=col, strokeColor=C_WHITE, strokeWidth=0.8))
d.add(String(x+bw/2, 73, label, fontSize=7,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
# Arrow below
d.add(Line(20, 55, CW-20, 55, strokeColor=C_HDR, strokeWidth=1.5))
d.add(Polygon([CW-20, 55, CW-28, 58, CW-28, 52],
fillColor=C_HDR, strokeColor=C_HDR))
d.add(String(cx, 44, "5' ─────────────────────── 3'", fontSize=9,
fontName="Helvetica", fillColor=C_HDR, textAnchor="middle"))
# Labels below
d.add(String(20, 28, "DNA is made of nucleotides: Adenine (A) | Thymine (T) | Guanine (G) | Cytosine (C)",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT))
d.add(String(20, 14, "Gene = segment of DNA that codes for a specific protein",
fontSize=8, fontName="Helvetica-Bold", fillColor=C_ACCENT))
return d
# ── Diagram 2: Chromosomal Aberrations ───────────────────────────────────────
def chromosomal_aberration_diagram():
d = Drawing(CW, 155)
d.add(Rect(0, 0, CW, 155, fillColor=colors.HexColor("#E8F5E9"), strokeColor=None))
d.add(String(CW/2, 140, "CHROMOSOMAL ABERRATIONS", fontSize=12,
fontName="Helvetica-Bold", fillColor=C_HDR, textAnchor="middle"))
types = [
("Deletion", colors.HexColor("#EF5350"), "Loss of segment"),
("Duplication",colors.HexColor("#42A5F5"), "Extra copy"),
("Inversion", colors.HexColor("#AB47BC"), "Segment reversed"),
("Translocation",colors.HexColor("#FFA726"),"Segment moves"),
]
per_col = CW / 4
for i, (name, col, desc) in enumerate(types):
bx = i * per_col + 10
# normal chr
d.add(Rect(bx, 90, per_col-20, 38, fillColor=col,
strokeColor=C_HDR, strokeWidth=1, rx=10, ry=10))
d.add(String(bx+(per_col-20)/2, 105, name, fontSize=8,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
# arrow
ax = bx+(per_col-20)/2
d.add(Line(ax, 87, ax, 78, strokeColor=C_TEXT, strokeWidth=1))
d.add(Polygon([ax, 76, ax-4, 81, ax+4, 81],
fillColor=C_TEXT, strokeColor=C_TEXT))
# desc
d.add(String(bx+(per_col-20)/2, 62, desc, fontSize=7,
fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 42,
"Numerical: Aneuploidy (extra/missing chromosome) | Polyploidy (extra full set)",
fontSize=8, fontName="Helvetica-Bold", fillColor=C_ACCENT, textAnchor="middle"))
d.add(String(CW/2, 28,
"Structural: Deletion, Duplication, Inversion, Translocation",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 14,
"e.g. Trisomy 21 = Down Syndrome (extra chr 21)",
fontSize=8, fontName="Helvetica-Bold", fillColor=C_HDR, textAnchor="middle"))
return d
# ── Diagram 3: Patterns of Inheritance ───────────────────────────────────────
def inheritance_diagram():
d = Drawing(CW, 200)
d.add(Rect(0, 0, CW, 200, fillColor=colors.HexColor("#F3E5F5"), strokeColor=None))
d.add(String(CW/2, 185, "AUTOSOMAL DOMINANT INHERITANCE (Pedigree)", fontSize=11,
fontName="Helvetica-Bold", fillColor=C_HDR, textAnchor="middle"))
# Generation I - parents
# Father (circle = female, square = male)
# squares = males, circles = females
def draw_male(cx, cy, affected=False):
col = colors.HexColor("#1565C0") if affected else colors.HexColor("#90CAF9")
d.add(Rect(cx-16, cy-16, 32, 32, fillColor=col,
strokeColor=C_HDR, strokeWidth=1.5))
def draw_female(cx, cy, affected=False):
col = colors.HexColor("#C62828") if affected else colors.HexColor("#FFCDD2")
d.add(Circle(cx, cy, 16, fillColor=col,
strokeColor=C_ACCENT, strokeWidth=1.5))
def couple_line(x1, y1, x2, y2):
d.add(Line(x1, y1, x2, y2, strokeColor=C_TEXT, strokeWidth=1.5))
def descent_line(px, py, cx, cy):
mid_y = (py + cy) / 2
d.add(Line(px, py, px, mid_y, strokeColor=C_TEXT, strokeWidth=1))
d.add(Line(px, mid_y, cx, mid_y, strokeColor=C_TEXT, strokeWidth=1))
d.add(Line(cx, mid_y, cx, cy, strokeColor=C_TEXT, strokeWidth=1))
# Gen I
draw_male(90, 160, affected=True)
draw_female(190, 160, affected=False)
couple_line(106, 160, 174, 160)
d.add(String(140, 162, "x", fontSize=10, fontName="Helvetica-Bold",
fillColor=C_TEXT, textAnchor="middle"))
d.add(String(60, 170, "Gen I", fontSize=8, fontName="Helvetica-Bold",
fillColor=C_HDR))
# Gen II - 4 children
children = [(60, 80, True), (130, 80, False), (200, 80, True), (270, 80, False)]
cx_mid = (90 + 190) / 2 # 140
d.add(Line(cx_mid, 144, cx_mid, 120, strokeColor=C_TEXT, strokeWidth=1))
d.add(Line(60, 120, 270, 120, strokeColor=C_TEXT, strokeWidth=1))
for i, (cx, cy, aff) in enumerate(children):
d.add(Line(cx, 120, cx, 96, strokeColor=C_TEXT, strokeWidth=1))
if i % 2 == 0:
draw_male(cx, cy, aff)
else:
draw_female(cx, cy, aff)
d.add(String(30, 90, "Gen II", fontSize=8, fontName="Helvetica-Bold",
fillColor=C_HDR))
# Legend
d.add(Rect(30, 14, 20, 20, fillColor=colors.HexColor("#1565C0"),
strokeColor=C_HDR, strokeWidth=1))
d.add(String(55, 20, "Affected Male", fontSize=9, fontName="Helvetica", fillColor=C_TEXT))
d.add(Rect(160, 14, 20, 20, fillColor=colors.HexColor("#90CAF9"),
strokeColor=C_HDR, strokeWidth=1))
d.add(String(185, 20, "Unaffected Male", fontSize=9, fontName="Helvetica", fillColor=C_TEXT))
d.add(Circle(320, 24, 10, fillColor=colors.HexColor("#C62828"),
strokeColor=C_ACCENT, strokeWidth=1))
d.add(String(335, 20, "Affected Female", fontSize=9, fontName="Helvetica", fillColor=C_TEXT))
d.add(Circle(440, 24, 10, fillColor=colors.HexColor("#FFCDD2"),
strokeColor=C_ACCENT, strokeWidth=1))
d.add(String(455, 20, "Unaffected", fontSize=9, fontName="Helvetica", fillColor=C_TEXT))
return d
# ── Diagram 4: Down Syndrome Karyotype (simplified) ──────────────────────────
def down_syndrome_diagram():
d = Drawing(CW, 110)
d.add(Rect(0, 0, CW, 110, fillColor=colors.HexColor("#FFF3E0"), strokeColor=None))
d.add(String(CW/2, 97, "DOWN SYNDROME - Trisomy 21", fontSize=12,
fontName="Helvetica-Bold", fillColor=C_ACCENT, textAnchor="middle"))
# Draw chr 21 x3 and others schematically
chr_colors = {
"1": "#E57373", "2": "#64B5F6", "3": "#81C784",
"21a":"#FFB300", "21b":"#FFB300", "21c":"#E53935",
}
labels = ["Chr 1","Chr 2","...","Chr 21","Chr 21","Chr 21 (EXTRA!)"]
xs = [20, 90, 160, 230, 295, 360]
widths = [45,45,30,45,45,60]
highlight = [False,False,False,False,False,True]
chr_col = ["#E57373","#64B5F6","#B0BEC5","#FFB300","#FFB300","#E53935"]
for x, lbl, w, hl, col in zip(xs, labels, widths, highlight, chr_col):
sw = 3 if hl else 1
sc = C_ACCENT if hl else C_HDR
# chromosome shape: two bands
d.add(Rect(x, 48, w, 30, fillColor=colors.HexColor(col),
strokeColor=sc, strokeWidth=sw, rx=5, ry=5))
d.add(Rect(x, 40, w, 8, fillColor=colors.HexColor(col),
strokeColor=sc, strokeWidth=sw, rx=2, ry=2))
d.add(String(x+w/2, 30, lbl, fontSize=7,
fontName="Helvetica-Bold" if hl else "Helvetica",
fillColor=C_ACCENT if hl else C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 14,
"Karyotype: 47,XX,+21 or 47,XY,+21 | Occurs due to Non-Disjunction in Meiosis",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
return d
# ── Diagram 5: Inborn Errors of Metabolism ───────────────────────────────────
def metabolism_diagram():
d = Drawing(CW, 120)
d.add(Rect(0, 0, CW, 120, fillColor=colors.HexColor("#E0F7FA"), strokeColor=None))
d.add(String(CW/2, 107, "INBORN ERRORS OF METABOLISM - Concept", fontSize=11,
fontName="Helvetica-Bold", fillColor=C_TEAL, textAnchor="middle"))
# Normal pathway
steps = ["Substrate A", "Enzyme X", "Product B", "Product C"]
sx = [30, 130, 230, 330]
for i, (s, x) in enumerate(zip(steps, sx)):
col = colors.HexColor("#00897B") if i==0 else (
colors.HexColor("#E53935") if i==1 else colors.HexColor("#1565C0"))
d.add(Rect(x, 72, 85, 28, fillColor=col, strokeColor=C_TEAL,
strokeWidth=1, rx=4, ry=4))
d.add(String(x+42, 82, s, fontSize=8,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
if i < 3:
d.add(Line(x+85, 86, x+100, 86, strokeColor=C_TEXT, strokeWidth=2))
d.add(Polygon([x+100, 86, x+94, 90, x+94, 82],
fillColor=C_TEXT, strokeColor=C_TEXT))
# Block cross
d.add(String(152, 65, "BLOCKED", fontSize=7, fontName="Helvetica-Bold",
fillColor=C_ACCENT, textAnchor="middle"))
d.add(Line(140, 72, 165, 57, strokeColor=C_ACCENT, strokeWidth=2))
d.add(Line(165, 72, 140, 57, strokeColor=C_ACCENT, strokeWidth=2))
# Accumulation arrow
d.add(Line(72, 72, 72, 50, strokeColor=C_ACCENT, strokeWidth=1.5))
d.add(Polygon([72, 47, 68, 53, 76, 53], fillColor=C_ACCENT, strokeColor=C_ACCENT))
d.add(String(72, 38, "Accumulates", fontSize=7, fontName="Helvetica-Bold",
fillColor=C_ACCENT, textAnchor="middle"))
d.add(String(CW/2, 18,
"PKU: Phenylalanine accumulates (no PAH enzyme) | Galactosaemia: Galactose accumulates",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 6,
"Huntington: CAG repeat expansion | Haemochromatosis: Iron overload",
fontSize=8, fontName="Helvetica-Bold", fillColor=C_TEAL, textAnchor="middle"))
return d
# ── Diagram 6: Genetic Testing Overview ──────────────────────────────────────
def genetic_testing_diagram():
d = Drawing(CW, 130)
d.add(Rect(0, 0, CW, 130, fillColor=colors.HexColor("#EDE7F6"), strokeColor=None))
d.add(String(CW/2, 115, "TYPES OF GENETIC TESTING", fontSize=12,
fontName="Helvetica-Bold", fillColor=colors.HexColor("#4A148C"),
textAnchor="middle"))
types = [
("Karyotyping", "#7B1FA2", "Chromosome\nnumber/structure"),
("DNA Sequencing", "#1565C0", "Mutations in\ngene sequence"),
("FISH", "#00695C", "Specific\nchromosome region"),
("PCR", "#E65100", "Amplify &\ndetect DNA"),
]
bw = (CW - 40) / 4
for i, (name, col, desc) in enumerate(types):
bx = 20 + i * bw
d.add(Rect(bx, 58, bw-8, 42, fillColor=colors.HexColor(col),
strokeColor=C_WHITE, strokeWidth=1.5, rx=6, ry=6))
d.add(String(bx+(bw-8)/2, 73, name, fontSize=8,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
# description below box
for j, line in enumerate(desc.split("\n")):
d.add(String(bx+(bw-8)/2, 48 - j*12, line, fontSize=7,
fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 16,
"Prenatal: Amniocentesis | CVS | Ultrasound | Maternal serum screening",
fontSize=8, fontName="Helvetica-Bold",
fillColor=colors.HexColor("#4A148C"), textAnchor="middle"))
d.add(String(CW/2, 4,
"Postnatal: Newborn screening (PKU, hypothyroidism, galactosaemia)",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
return d
# ── Diagram 7: Genetic Therapy ────────────────────────────────────────────────
def gene_therapy_diagram():
d = Drawing(CW, 130)
d.add(Rect(0, 0, CW, 130, fillColor=colors.HexColor("#E8F5E9"), strokeColor=None))
d.add(String(CW/2, 115, "GENE THERAPY - How it works", fontSize=12,
fontName="Helvetica-Bold", fillColor=colors.HexColor("#1B5E20"),
textAnchor="middle"))
steps = [
("Normal\nGene", "#2E7D32"),
("Vector\n(Virus/Plasmid)", "#1565C0"),
("Delivery\ninto Cell", "#6A1B9A"),
("Expression\nin Cell", "#C62828"),
]
bw = (CW - 60) / 4
for i, (name, col) in enumerate(steps):
bx = 20 + i * (bw + 16)
# box
d.add(Rect(bx, 52, bw, 50, fillColor=colors.HexColor(col),
strokeColor=C_WHITE, strokeWidth=1.5, rx=8, ry=8))
for j, line in enumerate(name.split("\n")):
d.add(String(bx+bw/2, 82 - j*14, line, fontSize=8,
fontName="Helvetica-Bold", fillColor=C_WHITE, textAnchor="middle"))
# arrow
if i < 3:
ax = bx + bw + 2
d.add(Line(ax, 77, ax+12, 77, strokeColor=C_TEXT, strokeWidth=2))
d.add(Polygon([ax+12, 77, ax+7, 81, ax+7, 73],
fillColor=C_TEXT, strokeColor=C_TEXT))
# step num
d.add(String(bx+bw/2, 46, f"Step {i+1}", fontSize=7,
fontName="Helvetica-Bold", fillColor=C_TEXT, textAnchor="middle"))
d.add(String(CW/2, 22,
"In Vivo: directly into patient | Ex Vivo: cells removed, treated, returned",
fontSize=8, fontName="Helvetica-Bold",
fillColor=colors.HexColor("#1B5E20"), textAnchor="middle"))
d.add(String(CW/2, 8,
"Vectors: Adenovirus, Retrovirus, Lentivirus, AAV, Liposomes",
fontSize=8, fontName="Helvetica", fillColor=C_TEXT, textAnchor="middle"))
return d
# ═══════════════════════════════════════════════════════════════════════════════
# BUILD CONTENT
# ═══════════════════════════════════════════════════════════════════════════════
story = []
# ── Cover / Title ─────────────────────────────────────────────────────────────
story.append(Spacer(1, 10))
story.append(ColorBox("GENETICS", TITLE_STYLE, C_HDR, CW, height=60, radius=12))
story.append(Spacer(1, 4))
story.append(ColorBox("Short Notes | Units 1, 2, 4 & 5 (Unit 3 Excluded)", UNIT_STYLE,
C_HDR_LIGHT, CW, height=36, radius=8))
story.append(Spacer(1, 10))
story.append(HRFlowable(width=CW, thickness=2, color=C_ACCENT))
story.append(Spacer(1, 10))
# ══════════════════════════════════════════════════════════════════════════════
# UNIT 1
# ══════════════════════════════════════════════════════════════════════════════
story += unit_header("UNIT 1 - Genetics in Nursing Applications, Gene Structure, Chromosomal Aberrations & Patterns of Inheritance")
# 1.1 Genetics in Nursing
story += section_box("1.1 Genetics in Nursing Application", [
"<b>Definition:</b> Genetics = study of genes, heredity and variation in living organisms.",
"<b>Nursing roles:</b> Identify at-risk families, educate about genetic conditions, support genetic testing decisions, coordinate with genetic counselors.",
"<b>Types of Genetic Disorders:</b>",
" • Single gene (Mendelian) - e.g. PKU, Sickle cell",
" • Chromosomal - e.g. Down syndrome, Turner's",
" • Multifactorial - e.g. Cleft palate, Diabetes",
" • Mitochondrial - passed via mother only",
"<b>Family History:</b> 3-generation pedigree helps identify risk patterns.",
], bg=C_BLUE)
# Gene structure diagram
story.append(gene_structure_diagram())
story.append(Spacer(1, 8))
# 1.2 Characteristics & Structure of Genes
story += section_box("1.2 Characteristics & Structure of Genes", [
"<b>Gene:</b> Segment of DNA that codes for a specific protein or functional RNA.",
"<b>DNA:</b> Double-stranded helix; nucleotides = Sugar (Deoxyribose) + Phosphate + Base.",
"<b>Bases:</b> A-T (Adenine-Thymine) and G-C (Guanine-Cytosine) pairing.",
"<b>Chromosome:</b> Condensed DNA + histone proteins; humans have 46 chromosomes (23 pairs).",
"<b>Allele:</b> Alternate forms of a gene at same locus.",
"<b>Genotype:</b> Genetic makeup (e.g. AA, Aa, aa). <b>Phenotype:</b> Observable trait.",
"<b>Homozygous:</b> Both alleles same (AA or aa). <b>Heterozygous:</b> Different alleles (Aa).",
"<b>Locus:</b> Fixed position on chromosome where a gene is located.",
], bg=C_BLUE)
# 1.3 Chromosomal Aberration
story.append(chromosomal_aberration_diagram())
story.append(Spacer(1, 8))
story += section_box("1.3 Chromosomal Aberrations", [
"<b>Numerical Aberrations:</b>",
" • <b>Aneuploidy:</b> Extra or missing single chromosome",
" - Monosomy (2n-1): e.g. Turner's syndrome 45,XO",
" - Trisomy (2n+1): e.g. Down (chr 21), Patau (chr 13), Edwards (chr 18)",
" • <b>Polyploidy:</b> Extra complete chromosome set (triploid, tetraploid)",
"<b>Structural Aberrations:</b>",
" • <b>Deletion:</b> Loss of chromosome segment",
" • <b>Duplication:</b> Extra copy of a segment",
" • <b>Inversion:</b> Segment flipped 180°",
" • <b>Translocation:</b> Segment moves to another chromosome",
"<b>Cause:</b> Non-disjunction during meiosis, environmental mutagens, radiation.",
], bg=C_YELLOW)
# 1.4 Patterns of Inheritance
story.append(inheritance_diagram())
story.append(Spacer(1, 8))
story += section_box("1.4 Patterns of Inheritance", [
"<b>Autosomal Dominant (AD):</b> One mutant allele enough; each generation affected; 50% risk per child. e.g. Huntington's, Marfan's.",
"<b>Autosomal Recessive (AR):</b> Two mutant alleles needed; parents are carriers; 25% risk. e.g. PKU, Sickle cell, CF.",
"<b>X-Linked Dominant:</b> Gene on X chromosome; dominant; e.g. Vitamin D-resistant rickets.",
"<b>X-Linked Recessive:</b> Males affected more; females carriers; e.g. Haemophilia, G6PD, Duchenne MD.",
"<b>Y-Linked:</b> Father to all sons; e.g. Y chromosome infertility.",
"<b>Mitochondrial:</b> Mother to all children; no paternal transmission; e.g. MELAS syndrome.",
"<b>Codominance:</b> Both alleles expressed; e.g. AB blood group.",
"<b>Incomplete Dominance:</b> Intermediate phenotype; e.g. sickle cell trait.",
], bg=C_GREEN)
story += hr()
# ══════════════════════════════════════════════════════════════════════════════
# UNIT 2
# ══════════════════════════════════════════════════════════════════════════════
story += unit_header("UNIT 2 - Conditions Affecting the Mother")
# 2.1 Prenatal Testing
story += section_box("2.1 Prenatal Testing & Diagnosis", [
"<b>Purpose:</b> Identify fetal genetic/structural abnormalities early in pregnancy.",
"<b>1. Amniocentesis (15-20 weeks):</b> Amniotic fluid sample → karyotype, DNA analysis. Risk: ~0.5% miscarriage.",
"<b>2. Chorionic Villus Sampling (CVS) (10-13 weeks):</b> Placental tissue sample → earlier diagnosis. Risk slightly higher than amniocentesis.",
"<b>3. Maternal Serum Screening:</b>",
" • Triple test: AFP, hCG, Estriol",
" • Quad test: adds Inhibin A",
" • NIPT (Non-Invasive Prenatal Testing): Cell-free fetal DNA in maternal blood - detects trisomies",
"<b>4. Ultrasound:</b> Nuchal translucency (11-14 wks), fetal anomaly scan (18-22 wks).",
"<b>5. Preimplantation Genetic Diagnosis (PGD):</b> IVF embryo tested before implantation.",
], bg=C_BLUE)
story.append(genetic_testing_diagram())
story.append(Spacer(1, 8))
# 2.2 Infertility
story += section_box("2.2 Infertility", [
"<b>Definition:</b> Inability to conceive after 12 months of regular unprotected intercourse.",
"<b>Genetic causes in females:</b> Turner syndrome (45,XO), Premature ovarian failure (FMR1 mutation), PCOS.",
"<b>Genetic causes in males:</b> Klinefelter (47,XXY) - azoospermia; Y chromosome microdeletions (AZF regions).",
"<b>Investigations:</b> Karyotype, hormonal profile, semen analysis, genetic mutation testing.",
"<b>Management:</b> ART (IVF/ICSI), donor gametes, PGD, surrogacy; Genetic counseling for couples.",
], bg=C_PURPLE)
# 2.3 Spontaneous Abortion
story += section_box("2.3 Spontaneous Abortion", [
"<b>Definition:</b> Loss of pregnancy before 20 weeks gestation.",
"<b>Incidence:</b> ~15-20% of clinically recognized pregnancies.",
"<b>Genetic causes (most common ~50%):</b> Chromosomal abnormalities - trisomies most frequent (T16 most common in 1st trimester), monosomy X, triploidy.",
"<b>Other causes:</b> Uterine anomalies, hormonal imbalance, thrombophilia, immunological, infections.",
"<b>Types:</b> Threatened, Inevitable, Incomplete, Complete, Missed, Recurrent (3+ losses).",
"<b>Nursing care:</b> Emotional support, explain genetic causes, refer for karyotyping, genetic counseling for recurrent abortions.",
], bg=C_ORANGE)
# 2.4 Neural Tube Defects
story += section_box("2.4 Neural Tube Defects (NTDs)", [
"<b>Definition:</b> Failure of neural tube to close during 3rd-4th week of fetal development.",
"<b>Types:</b>",
" • <b>Spina Bifida:</b> Incomplete closure of spinal column",
" - Spina bifida occulta (hidden, minor)",
" - Meningocele (meninges protrude)",
" - Myelomeningocele (most severe - spinal cord + meninges protrude)",
" • <b>Anencephaly:</b> Absence of brain + skull vault - incompatible with life",
" • <b>Encephalocele:</b> Brain tissue protrudes through skull",
"<b>Risk factors:</b> Folic acid deficiency, valproate use, diabetes, family history.",
"<b>Prevention:</b> Folic acid 400 mcg/day pre-conception and first trimester (4 mg if previous NTD).",
"<b>Diagnosis:</b> Maternal AFP elevated, ultrasound, amniocentesis.",
], bg=C_BLUE)
# 2.5 Down Syndrome
story.append(down_syndrome_diagram())
story.append(Spacer(1, 8))
story += section_box("2.5 Down Syndrome (Trisomy 21)", [
"<b>Definition:</b> Chromosomal disorder due to extra copy of chromosome 21 (47 chromosomes).",
"<b>Incidence:</b> 1 in 700 live births; increases with maternal age.",
"<b>Cause:</b> Non-disjunction in meiosis (95%); Translocation (4%); Mosaicism (1%).",
"<b>Features:</b> Flat facial profile, upslanting palpebral fissures, epicanthal folds, single palmar crease, hypotonia, intellectual disability.",
"<b>Associated conditions:</b> Congenital heart defects (40%), GI anomalies, hypothyroidism, Alzheimer's (early onset), leukemia.",
"<b>Diagnosis:</b> Karyotype (gold standard), NIPT, amniocentesis, CVS.",
"<b>Nursing care:</b> Early intervention programs, developmental support, family education, support groups.",
], bg=C_ORANGE)
story += hr()
# ══════════════════════════════════════════════════════════════════════════════
# UNIT 4
# ══════════════════════════════════════════════════════════════════════════════
story += unit_header("UNIT 4 - Inborn Errors of Metabolism, Huntington's Disease & Genetic Haemochromatosis")
# Metabolism diagram
story.append(metabolism_diagram())
story.append(Spacer(1, 8))
# 4.1 Inborn Errors of Metabolism
story += section_box("4.1 Inborn Errors of Metabolism (IEM)", [
"<b>Definition:</b> Inherited disorders where a specific enzyme is absent/non-functional → substrate accumulates / product deficit.",
"<b>Inheritance:</b> Mostly autosomal recessive.",
"<b>Common examples:</b>",
" • <b>Phenylketonuria (PKU):</b> Phenylalanine hydroxylase (PAH) deficiency → phenylalanine accumulates → intellectual disability. Tx: Low-phenylalanine diet.",
" • <b>Galactosaemia:</b> GALT enzyme deficiency → galactose accumulates → jaundice, liver failure. Tx: Galactose-free diet.",
" • <b>MSUD (Maple Syrup Urine Disease):</b> BCAA metabolism defect → sweet-smelling urine, encephalopathy.",
" • <b>Gaucher Disease:</b> Glucocerebrosidase deficiency → glucocerebroside accumulates in liver/spleen/bone.",
" • <b>Pompe Disease:</b> Acid alpha-glucosidase deficiency → glycogen accumulates → cardiomyopathy.",
"<b>Diagnosis:</b> Newborn screening (tandem mass spectrometry), enzyme assay, DNA analysis.",
"<b>Nursing:</b> Monitor diet compliance, developmental milestones, metabolic crises.",
], bg=C_BLUE)
# 4.2 Huntington's Disease
story += section_box("4.2 Huntington's Disease (HD)", [
"<b>Definition:</b> Progressive neurodegenerative disorder caused by CAG trinucleotide repeat expansion in HTT gene (chromosome 4).",
"<b>Inheritance:</b> Autosomal Dominant; 100% penetrance if mutation present.",
"<b>Normal repeats:</b> <36 CAG | <b>HD:</b> ≥40 CAG repeats | Intermediate: 36-39.",
"<b>Features (onset usually 30-50 yrs):</b>",
" • <b>Motor:</b> Chorea (involuntary jerking), dystonia, rigidity, falls",
" • <b>Cognitive:</b> Dementia, memory loss, poor planning",
" • <b>Psychiatric:</b> Depression, OCD, psychosis",
"<b>Pathology:</b> Striatal (caudate + putamen) neuronal death.",
"<b>Diagnosis:</b> DNA test (CAG repeat count). Presymptomatic testing possible with counseling.",
"<b>Management:</b> No cure - symptomatic; Tetrabenazine (chorea), antidepressants, physiotherapy, speech therapy.",
"<b>Nursing:</b> Safety measures (falls), nutritional support (high calorie), communication aids, end-of-life care.",
], bg=C_YELLOW)
# 4.3 Genetic Haemochromatosis
story += section_box("4.3 Genetic (Hereditary) Haemochromatosis (HH)", [
"<b>Definition:</b> Autosomal recessive disorder of iron overload due to mutations in HFE gene (C282Y, H63D).",
"<b>Mechanism:</b> Excess iron absorption from gut → iron deposits in liver, heart, pancreas, joints, skin.",
"<b>Features:</b> Liver cirrhosis, hepatocellular carcinoma, diabetes ('bronze diabetes'), cardiomyopathy, arthropathy, hypogonadism, bronze skin discolouration.",
"<b>Diagnosis:</b> Transferrin saturation >45%, serum ferritin elevated, HFE gene testing, liver biopsy.",
"<b>Screening:</b> First-degree relatives of affected individuals.",
"<b>Treatment:</b> Phlebotomy (venesection) - 500 mL blood/week until ferritin <50 μg/L, then maintenance. Chelation (deferoxamine) if phlebotomy contraindicated.",
"<b>Nursing:</b> Monitor ferritin/iron studies, educate on diet (avoid iron supplements, vitamin C with meals), encourage compliance with venesection.",
], bg=C_GREEN)
story += hr()
# ══════════════════════════════════════════════════════════════════════════════
# UNIT 5
# ══════════════════════════════════════════════════════════════════════════════
story += unit_header("UNIT 5 - Genetic Testing, Genetic Therapy & Genetic Counseling")
# 5.1 Genetic Testing
story += section_box("5.1 Genetic Testing", [
"<b>Definition:</b> Analysis of chromosomes, DNA, RNA, proteins, or metabolites to detect genetic variants.",
"<b>Types:</b>",
" • <b>Diagnostic testing:</b> Confirms/rules out a suspected genetic condition.",
" • <b>Predictive testing:</b> Identifies risk before symptoms (e.g. BRCA1/2 for breast cancer, HTT for HD).",
" • <b>Carrier testing:</b> Detects carriers of AR conditions (e.g. CF, sickle cell).",
" • <b>Prenatal testing:</b> Amniocentesis, CVS, NIPT, ultrasound.",
" • <b>Newborn screening:</b> Early detection (PKU, congenital hypothyroidism, galactosaemia).",
" • <b>Pharmacogenomics:</b> Genetic variants affecting drug response/metabolism.",
"<b>Methods:</b> Karyotyping, FISH, PCR, DNA sequencing (Sanger, NGS), microarray.",
"<b>Ethical issues:</b> Confidentiality, informed consent, insurance discrimination, psychological impact.",
], bg=C_PURPLE)
# 5.2 Gene Therapy
story.append(gene_therapy_diagram())
story.append(Spacer(1, 8))
story += section_box("5.2 Genetic Therapy (Gene Therapy)", [
"<b>Definition:</b> Introduction, alteration, or replacement of genetic material within a cell to treat disease.",
"<b>Types:</b>",
" • <b>Somatic gene therapy:</b> Targets non-reproductive cells; changes not inherited.",
" • <b>Germline gene therapy:</b> Targets reproductive cells; changes heritable (ethically controversial).",
" • <b>Gene replacement:</b> Replace faulty gene with normal copy.",
" • <b>Gene silencing:</b> Suppress overactive/harmful gene (e.g. RNAi, antisense oligonucleotides).",
" • <b>Gene editing (CRISPR-Cas9):</b> Precise cut and edit at specific DNA location.",
"<b>Delivery (vectors):</b> Viral (adenovirus, AAV, retrovirus, lentivirus); Non-viral (liposomes, nanoparticles).",
"<b>In vivo:</b> Gene delivered directly into patient's body.",
"<b>Ex vivo:</b> Patient's cells removed, modified in lab, re-infused.",
"<b>Examples:</b> Luxturna (RPE65 mutation - blindness), Zolgensma (SMA), CAR-T cell therapy.",
"<b>Challenges:</b> Immune reactions, insertional mutagenesis, delivery efficiency, cost.",
], bg=C_ORANGE)
# 5.3 Genetic Counseling
story += section_box("5.3 Genetic Counseling", [
"<b>Definition:</b> Process of providing individuals/families with information about genetic conditions, risks, testing options and decision support.",
"<b>Goals:</b> Educate, empower, support non-directive decision making, reduce anxiety, improve outcomes.",
"<b>Indications:</b>",
" • Advanced maternal age (≥35 years)",
" • Previous child with genetic disorder",
" • Family history of hereditary disease",
" • Consanguinity (related parents)",
" • Recurrent miscarriages",
" • Abnormal prenatal screen results",
"<b>Process:</b> Risk assessment → Information giving → Discuss options → Psychological support → Follow-up.",
"<b>Principles:</b> Non-directive, confidentiality, informed consent, autonomy.",
"<b>Nurse's role:</b> Identify at-risk patients, initiate referral, provide pre/post-test counseling, emotional support, document accurately.",
"<b>Ethical considerations:</b> Right not to know, duty to warn relatives, privacy vs. family disclosure.",
], bg=C_BLUE)
# ── Quick Reference Summary Table ────────────────────────────────────────────
story.append(Spacer(1, 6))
story += hr()
story.append(ColorBox("QUICK REFERENCE SUMMARY", UNIT_STYLE, C_ACCENT, CW, height=36, radius=6))
story.append(Spacer(1, 6))
summary_data = [
[Paragraph("<b>Topic</b>", SUBHD_STYLE),
Paragraph("<b>Key Point</b>", SUBHD_STYLE)],
[Paragraph("Down Syndrome", BODY_STYLE),
Paragraph("Trisomy 21 | Non-disjunction | 47 chromosomes | Flat face, hypotonia, IDD", BODY_STYLE)],
[Paragraph("NTD Prevention", BODY_STYLE),
Paragraph("Folic acid 400 mcg/day pre-conception | High AFP on maternal screen", BODY_STYLE)],
[Paragraph("Huntington's", BODY_STYLE),
Paragraph("AD | CAG repeat ≥40 | Chr 4 | Chorea, dementia | No cure", BODY_STYLE)],
[Paragraph("Haemochromatosis", BODY_STYLE),
Paragraph("AR | HFE gene | Iron overload | Tx: venesection | Bronze diabetes", BODY_STYLE)],
[Paragraph("PKU", BODY_STYLE),
Paragraph("AR | PAH deficiency | Phenylalanine ↑ | Tx: Low-phe diet | Newborn screen", BODY_STYLE)],
[Paragraph("Gene Therapy", BODY_STYLE),
Paragraph("Somatic (not heritable) vs Germline | CRISPR, viral vectors | In vivo / Ex vivo", BODY_STYLE)],
[Paragraph("Genetic Counseling", BODY_STYLE),
Paragraph("Non-directive | Risk assessment | Informed consent | Support | Confidentiality", BODY_STYLE)],
]
t = Table(summary_data, colWidths=[CW*0.28, CW*0.72])
t.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,0), C_HDR),
('TEXTCOLOR', (0,0), (-1,0), C_WHITE),
('BACKGROUND', (0,1), (-1,-1), C_YELLOW),
('ROWBACKGROUNDS', (0,1), (-1,-1), [C_YELLOW, C_GREEN]),
('BOX', (0,0), (-1,-1), 1.5, C_HDR_LIGHT),
('INNERGRID', (0,0), (-1,-1), 0.5, colors.HexColor("#9FA8DA")),
('TOPPADDING', (0,0), (-1,-1), 7),
('BOTTOMPADDING', (0,0), (-1,-1), 7),
('LEFTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
story.append(t)
story.append(Spacer(1, 10))
# Footer note
story.append(Paragraph(
"<b>Note:</b> Unit 3 excluded as per instruction. These notes cover Units 1, 2, 4 & 5 only.",
NOTE_STYLE))
# ─── Build ────────────────────────────────────────────────────────────────────
doc.build(story)
print("PDF created successfully!")
cd /tmp/workspace/genetics-notes && python make_pdf.py 2>&1
ls -lh /tmp/workspace/genetics-notes/Genetics_Short_Notes.pdf
Genetics Short Notes
PDF Document · PDF
Ye jyada hi very short notes ho gy h thodi details add kro inhe short notes bna do
Pdf bhejo
ls -lh /tmp/workspace/genetics-notes/
Please send fast
Ha please fast
Genetics Short Notes
PDF Document · PDF
thoda expand karke pdf bnao or diagram add kr dena
File ko expand krne me itna time kyu lg rha h jldi kro na
Ha
In sb genetic ke topic se ki short note ki PDF banaa do font thoda big rakhna aur diagram add kar dena . You need to 3 ko add mat Karna jaldi banaa do bakiyon ki PDF
Bhejo PDF