Explain gram negative and gram positive bacteria
gram positive gram negative bacteria cell wall structure comparison diagram

A pathophysiology diagram illustrating the antibacterial mechanisms of copper oxide nanoparticles (CuO NPs) on Gram-positive and Gram-negative bacteria. The left panel shows Gram-positive bacteria with a thick peptidoglycan layer above a plasma membrane. The right panel shows Gram-negative bacteria with a complex cell wall including lipopolysaccharides, an outer membrane, lipoproteins, and a thin peptidoglycan layer. Both panels demonstrate CuO NPs causing cell wall damage and lysis. The central panel details the intracellular bactericidal pathway labeled as mechanism 1 and 2. Mechanism 1 involves the internalization of CuO NPs into the cytosol, while mechanism 2 illustrates the dissolution of CuO NPs into copper ions (Cu2+) which then permeate the cell. Inside the cell, both Cu2+ ions and CuO NPs induce the production of reactive oxygen species (ROS). The resulting oxidative stress leads to mitochondrial disruption and DNA damage, ultimately resulting in cell death. This infographic highlights the role of nanoparticle morphology and ion release in targeting bacterial structural and metabolic integrity.

This pathophysiology diagram illustrates quorum-sensing-regulated resistance mechanisms in Gram-positive bacteria. The bacterial cell structure is depicted with three distinct layers: an inner membrane, a periplasmic area, and an outer membrane. The diagram highlights two primary signaling pathways involved in cell-to-cell communication. The first involves 'peptide-type autoinducers' (represented as blue/yellow spheres), which are processed and secreted via a transmembrane receptor and then detected by a membrane-spanning kinase. The second pathway involves 'diffusible autoinducers' (pink squares) that freely enter the cell. Both pathways converge to trigger 'resistance gene expression' at the DNA level. This genetic activation leads to physiological outcomes, specifically 'efflux pump-mediated antibiotic resistance,' where a transmembrane efflux pump actively transports antibiotic molecules (green hexagons) out of the intracellular space. This educational graphic demonstrates the interplay between bacterial signaling and multidrug resistance mechanisms.

A medical microbiology diagram illustrating the biogenesis and classification of bacterial extracellular vesicles (BEVs) from Gram-negative and Gram-positive bacteria. The top half depicts a Gram-negative bacterium with its triple-layered cell envelope (outer membrane, periplasmic space, and cytoplasmic membrane). Three vesicle formation mechanisms are shown: blebbing of the outer membrane creating Outer Membrane Vesicles (OMV), and explosive cell death leading to Explosive Outer Membrane Vesicles (EOMV) and Outer-Inner Membrane Vesicles (OIMV). The bottom half represents a Gram-positive bacterium characterized by a thick peptidoglycan cell wall and a single cytoplasmic membrane. This section illustrates 'bubbling cell death' resulting in Cytoplasmic Membrane Vesicles (CMV). A legend identifies the internal cargo within these vesicles, including proteins (brown shapes), nucleic acids (wavy lines), metabolites (blue branched icons), and endolysin (light blue shapes). This pathophysiology diagram highlights the structural differences in bacterial envelopes and the various pathways—blebbing, explosive death, and bubbling—that contribute to BEV diversity and composition.

A scientific infographic illustrating the mechanisms of viral entry across different bacterial cell envelopes, focusing on enveloped and non-enveloped virions. The diagram is divided by host bacterial type: Mollicutes, Gram-negative, and Gram-positive bacteria. For enveloped virions infecting Mollicutes, the diagram shows fusion with the host cell membrane or host outer membrane, followed by membrane permeabilization. For Gram-negative bacteria, non-enveloped virions utilize mechanisms such as fusion with the cell membrane via a membrane tube or pilus retraction. For Gram-positive bacteria, entry is depicted as flagellum-mediated or viral ejection through the host envelope/cell wall using contractile, long flexible, or short tails, as well as pore-mediated entry. All pathways converge at the delivery of the 'Cytoplasmic viral genome' into the host cytoplasm, leading to 'Cytoplasmic replication and transcription.' The schematic effectively compares the structural challenges presented by different bacterial cell walls (e.g., lipid bilayers vs. thick peptidoglycan layers) and the corresponding viral penetration strategies.

Bright-field light microscopy of a Gram-stained bacterial smear reveals numerous small, slender, curved Gram-negative rods with a characteristic gull-wing appearance consistent with Campylobacter species. The image captures bacteria oriented individually and in small clusters against a pale pink counterstain, illustrating Bacillary morphology typical of enteric pathogens. Gram staining shows purple/blue rods (crystal violet retained by cell wall) with a light pink background from the counterstain (safranin), enabling discrimination from Gram-positive organisms. The organisms appear slender and curved, with a single polar flagellum suggested by motility or alignment in the smear. Specimen type is a bacterial smear obtained from a gastrointestinal sample (feces or culture isolate), prepared for diagnostic microbiology. The imaging modality is bright-field microscopy at high magnification (approximately 1000x with oil immersion), following Gram staining to highlight bacterial cell wall structure. Clinically, detection of Campylobacter species supports infectious gastroenteritis; in the IPSID (immunoproliferative small intestinal disease) context, Campylobacter involvement has been proposed as a pathogenic trigger mirroring Helicobacter pylori's role in gastric MALT lymphoma. Differential diagnoses include Helicobacter, Vibrio, and other curved Gram-negative bacteria. This image serves educational and diagnostic utility for microbiology, clinical pathology, gastroenterology, and infectious disease research.

This diagnostic imaging set displays Atomic Force Microscopy (AFM) phase images of two distinct bacterial species, Bacillus cereus (a) and Escherichia coli (b), deposited on a mica surface. The images facilitate a morphological comparison between Gram-positive and Gram-negative bacteria at the nanometer scale. Panel (a) shows B. cereus as a distinctly elongated, rod-shaped cell with a relatively uniform, smooth surface texture and well-defined edges. In contrast, panel (b) depicts E. coli with a more compact, oval or capsule-shaped morphology. The E. coli cell exhibits a significantly rougher surface topography with visible granularity compared to the smoother envelope of B. cereus. The background depicts the mica substrate with faint thread-like structures visible around the E. coli cell, likely representing extracellular filaments or surface dehydration artifacts. A 1 μm scale bar is provided in both panels. These images are used in microbiology to study bacterial cell wall structural integrity, surface roughness (Rq), and biophysical responses to environmental conditions like relative humidity (RH).
| Step | Reagent | Purpose |
|---|---|---|
| 1 | Crystal violet | Primary stain - binds to peptidoglycan |
| 2 | Gram iodine | Mordant - causes crystal violet to precipitate inside the cell |
| 3 | Decolorizer (acetone-alcohol) | Washes out stain from gram-negative cells |
| 4 | Safranin (red counterstain) | Stains gram-negative cells pink/red |


| Feature | Gram-Positive | Gram-Negative |
|---|---|---|
| Gram stain color | Purple | Pink/red |
| Peptidoglycan layer | Thick (150-500 Å) | Thin (single layer) |
| Outer membrane | Absent | Present |
| LPS (endotoxin) | Absent | Present (major virulence factor) |
| Teichoic acids | Present | Absent |
| Periplasmic space | Minimal | Present (contains beta-lactamases) |
| Porins | Absent | Present |
| Susceptibility to penicillin | Higher | Lower (OM is a barrier) |
| Susceptibility to lysozyme | Higher | Lower (OM protects) |
| Susceptibility to detergents | Lower | Higher (OM disrupted) |
Tuberculosis
tuberculosis lung granuloma caseous necrosis histology AFB acid fast bacilli

High-power light microscopy of a skin biopsy stained for acid-fast bacilli demonstrates a granulomatous dermatitis pattern consistent with a non-tuberculous mycobacterial infection, most classically Mycobacterium marinum causing fish tank granuloma. The specimen shows dermal and subcutaneous granulomas composed of aggregates of epithelioid histiocytes and multinucleated giant cells, often surrounded by lymphocytes and occasional neutrophils. Intracellular bacilli appear as slender rod-shaped organisms that stain brightly with acid-fast techniques, localized within macrophages and occasionally in the extracellular matrix. The inflammatory response may be granulomatous with varying degrees of necrosis, and the bacilli are typically sparse but identifiable on Ziehl-Neelsen or Fite-Faraco preparations. Clinically this pattern corresponds to chronic, often indolent lesions on exposed extremities following aquatic exposure or contact with fish tanks. Diagnostic significance lies in linking histology to infectious etiology, prompting targeted culture and molecular identification for Mycobacterium marinum and other non-tuberculous mycobacteria. Differential diagnoses include cutaneous tuberculosis, other atypical mycobacteria, nocardiosis, fungal infections, and sarcoidosis with infectious mimic. Clinical correlation with patient history (aquatic exposure), lesion appearance, and microbiologic confirmation guides antimicrobial therapy, which commonly includes combination regimens such as rifampin, ethambutol, and macrolides. Immunohistochemical stains or PCR can enhance detection when organisms are sparse and guide targeted therapy decisions.

Autopsy spleen histology obtained from a 75-year-old man with myelodysplastic syndrome who succumbed after a brief febrile illness. The section shows massive splenomegaly with multifocal to confluent necrotizing granulomas. Hematoxylin and eosin stained micrographs reveal densely packed macrophages/histiocytes, epithelioid cells, and scattered multinucleated giant cells organized into granulomatous nodules. Central areas of necrosis are admixed with numerous acid-fast bacilli visible within macrophages and the granuloma rims. The pattern is typical for disseminated Mycobacterium avium complex infection (MAC) in the immunocompromised host. The spleen demonstrates widespread granulomatous inflammation with abscess-like necrotic foci and a destructive, nodular architecture, reflecting sequestered microbial burden in the reticuloendothelial system. The presence of virulent AFB on Ziehl-Neelsen or auramine-rhodamine staining would confirm organisms. Clinically, disseminated MAC commonly complicates myelodysplastic syndromes and advanced age, presenting as fever, night sweats, weight loss, cytopenias, and organomegaly. Diagnostic significance includes recognition of opportunistic infection in non-HIV immunosuppression, evaluation of differential diagnosis such as M. tuberculosis and other non-tuberculous mycobacteria, and implications for antimicrobial therapy decisions and prognosis. This image is valuable for education in pathology, infectious disease, hematology, and autopsy correlations, illustrating splenic involvement, granulomatous immunopathology, macrophage-rich infiltrates, and the diagnostic impact of acid-fast bacilli in immunocompromised patients.

This is a light microscopy image of a formalin-fixed, paraffin-embedded tissue section stained with Hematoxylin and Eosin (H&E). The sample reveals a well-formed granulomatous lesion characterized by a surrounding cuff of lymphocytes and numerous epithelioid histiocytes with elongated, crescent-shaped nuclei. Within the granuloma, multinucleated giant cells (Langhans-type) are visible, and a central amorphous pink necrotic area (caseous necrosis) is evident. The tissue architecture demonstrates organized granulomatous inflammation with a necrotic core, consistent with infectious granulomas. The differential includes mycobacterial disease (tuberculosis) and certain fungal infections (histoplasmosis, coccioidomycosis), though non-necrotizing granulomas can occur in sarcoidosis. The staining highlights chromatin-rich nuclei and cytoplasmic eosinophilia; occasional fibroblasts and mild edema extend into the perigranulomatous region. Clinically, granulomatous tissue with caseation is highly suggestive of TB in the appropriate clinical context and warrants further diagnostic workup (acid-fast bacilli staining, fungal stains, culture, PCR). This image serves as teaching material for histopathology education, differential diagnosis of granulomatous inflammation, and correlation with radiologic and microbiologic findings in suspected infectious etiologies. Additional keywords for indexing: epithelioid macrophages, granuloma, necrosis, caseation, tuberculosis, mycobacteria, fungal infection, lymphohistiocytic rim, tissue biopsy, pathology slide, H&E, histology teaching. Clinical correlation with imaging and sputum analysis improves diagnostic yield.

This clinical photograph displays a gross pathological specimen of lung tissue, demonstrating characteristic manifestations of a Mycobacterium tuberculosis infection. The lung parenchyma appears primarily reddish-pink with focal areas of dark red congestion and hemorrhage. A dashed white circle highlights a significant region of granulomatous inflammation. Within this region, a prominent, opaque, whitish-tan mass (indicated by a black arrow) represents a large granuloma, likely containing caseous necrosis. Surrounding this primary lesion, multiple smaller, milliary-sized white nodules (indicated by arrowheads) are scattered throughout the parenchyma, representing smaller granulomas. These visual findings are hallmark macroscopic signs of pulmonary tuberculosis, illustrating the diffuse and localized inflammatory response of the immune system to the bacilli. The specimen demonstrates the typical morphology of granulomatous disease in a primate model, used here for zoonotic research and diagnostic validation.

A multi-panel medical image illustrating diagnostic findings for tuberculosis. (a) High-magnification (40x) H&E stained photomicrograph showing a well-formed granuloma with central caseous necrosis, surrounded by epithelioid cells, Langhans-type multinucleated giant cells, and a peripheral rim of chronic inflammatory cells. (b) Lower-magnification (10x) H&E stained photomicrograph displaying multiple coalescing granulomatous lesions within the connective tissue. (c) Photomicrograph using Ziehl-Neelsen (ZN) stain highlighting acid-fast bacilli, visible as small pink/red rod-shaped structures against a methylene blue background, confirmatory for Mycobacterium species. (d) Posteroanterior (PA) view chest X-ray demonstrating clear lung fields with normal bronchovascular markings and no evidence of active pulmonary infiltrates, consolidation, or hilar lymphadenopathy. This visual set educates on the histopathological diagnosis of extrapulmonary tuberculosis (such as primary oral TB) where localized granulomatous inflammation is present despite a normal systemic radiological presentation.

Imaging modality: light microscopy of hematoxylin and eosin stained tissue section with ancillary Ziehl-Neelsen acid-fast staining. Primary subject: granulomatous inflammation within pulmonary/parenchymal tissue, including both caseating and non-caseating granulomas, with scattered Langhans-type giant cells. Specimen: formalin-fixed tissue biopsy. Perspective: cross-sectional histologic view of a biopsy section. The morphology shows well-formed nodular granulomas with central necrosis in several foci, surrounded by lymphocytes and occasional plasma cells, small vessels, and fibrous rims. In addition, non-caseating granulomas lacking necrosis are present, suggesting mixed granulomatous response. The Ziehl-Neelsen stain demonstrates acid-fast bacilli within the granulomas, confirming infection with Mycobacterium tuberculosis complex or other mycobacteria; differential includes NTM. The combination of caseation necrosis and AFB positivity is highly suggestive of active mycobacterial infection. Notable features include epithelioid histiocytes, multinucleated giant cells (Langhans-type), surrounding rim of lymphocytes, and occasional necrotic debris. This histology is clinically significant for guiding antimicrobial therapy, infection control, and prognosis. Potential clinical use cases include diagnosis of TB or mycobacterial granulomatous disease, evaluation of granulomatous lesions in lung tissue, lymph nodes, or sites, and educational resource for pathology and microbiology training. Correlates with clinical TB symptoms and radiographic findings, and informs differential diagnoses such as sarcoidosis, fungal infections, and granulomatous diseases.
tuberculosis treatment guidelines


| Form | Sites |
|---|---|
| Miliary/Disseminated TB | Lungs, liver, spleen, bone marrow - lesions resemble millet seeds |
| Serosal TB | Pleural effusion, pericarditis, peritonitis, arthritis, TB meningitis (most dangerous) |
| Solid organ TB | Lymph nodes (scrofula), kidneys, spine (Pott's disease), adrenals (old cause of Addison disease) |
TB meningitis deserves special attention - diagnosis is difficult, permanent brain damage can result from delay. A 2026 Lancet Infectious Diseases guideline for tuberculous meningitis was recently published.
| Test | Notes |
|---|---|
| Sputum AFB smear | Fast, cheap; 3 specimens on 3 consecutive days; sensitivity ~50-80% |
| Sputum culture | Gold standard; Lowenstein-Jensen or liquid (MGIT) media; takes 2-8 weeks |
| Nucleic Acid Amplification Tests (NAATs) e.g. Xpert MTB/RIF | Rapid (2 hours), detects M. tuberculosis AND rifampin resistance simultaneously; important where culture is not available |
| Drug susceptibility testing (DST) | Mandatory for all previously treated patients; guides regimen |
| Chest X-ray | Upper lobe cavitation, infiltrates, nodules (reactivation); hilar adenopathy (primary) |
| HRCT chest | More sensitive; "tree-in-bud" pattern = endobronchial spread |
| Tissue biopsy | Needed for extrapulmonary TB; PCR on CSF has ~94% sensitivity in TB meningitis |
| Phase | Drugs | Duration |
|---|---|---|
| Intensive | Isoniazid (H) + Rifampin (R) + Pyrazinamide (Z) + Ethambutol (E) | 2 months |
| Continuation | Isoniazid (H) + Rifampin (R) | 4 months |
| Total | 6 months |
| Drug | Mechanism | Key Toxicity |
|---|---|---|
| Isoniazid (INH) | Inhibits mycolic acid synthesis (InhA) | Hepatotoxicity, peripheral neuropathy (give pyridoxine 25-50 mg/day) |
| Rifampin | Inhibits DNA-dependent RNA polymerase | Hepatotoxicity, orange discoloration of secretions, major drug interactions (potent CYP inducer) |
| Pyrazinamide (PZA) | Disrupts membrane potential (active in acidic pH of macrophage) | Hyperuricemia/gout, hepatotoxicity |
| Ethambutol (EMB) | Inhibits arabinosyl transferase (cell wall synthesis) | Optic neuritis (monitor visual acuity) |
| Type | Definition |
|---|---|
| MDR-TB | Resistant to at least INH and Rifampin |
| RR-TB | Rifampin-resistant (treated as MDR) |
| XDR-TB | MDR + resistance to fluoroquinolones + at least one injectable second-line drug |
Mycoplasma
Mycoplasma pneumoniae atypical pneumonia chest X-ray histology

A multi-modal diagnostic comparison illustrating Mycoplasma pneumoniae pneumonia. Image A is a posterior-anterior chest x-ray showing increased density and reticulonodular infiltrates primarily localized in the right lower lobe, signifying an active infectious process. Image B is a high-resolution computed tomography (HRCT) scan axial slice of the lung parenchyma. The HRCT demonstrates a dense region of lobar consolidation, marked with an asterisk (*), indicating alveolar filling. Additionally, arrows (↑) highlight significant bronchovascular bundle thickening, characterized by increased interstitial markings and peribronchial cuffing. The combination of these radiological findings reflects the classic presentation of atypical pneumonia, emphasizing the correlation between plain film radiography and the superior anatomical detail provided by cross-sectional CT imaging for evaluating pulmonary inflammation and consolidation.

A posterior-anterior (PA) view diagnostic chest X-ray illustrating pulmonary manifestations in a patient with status asthmaticus and concurrent Mycoplasma pneumoniae infection. The radiographic findings are characterized by bilateral, diffuse, and patchy interstitial infiltrates, most prominent in the basilar regions of both lung fields. There is a general decrease in pulmonary transparency at the bases, indicating areas of consolidation or fluid accumulation consistent with atypical pneumonia. The cardiac silhouette appears within normal limits for size and morphology, and the visible mediastinal structures are unremarkable. The skeletal framework, including the ribs and clavicles, shows no acute abnormalities. This image serves as a clinical example of secondary pulmonary infection complicating an acute exacerbation of reactive airway disease, highlighting the characteristic 'walking pneumonia' presentation on plain film radiography.

Educational radiological set containing chest radiography (a) and computed tomography (CT) in axial (b) and coronal (c) planes, demonstrating features typical of Mycoplasma pneumoniae pneumonia. (a) Posterior-anterior chest X-ray shows an area of increased opacity in the right lower lobe with visible bronchial tram lines. (b) Axial CT section (lung window) highlights multifocal airspace consolidations (white arrows), prominent bronchial wall thickening (white triangles), and numerous centrilobular nodules (black triangles), reflecting an inflammatory process involving both the interstitium and small airways. (c) Coronal CT reconstruction further illustrates these findings, specifically showing a region of hazy ground-glass opacity (GGO) in the right upper lobe (black arrow), alongside lower lobe consolidation and bronchial wall thickening. The combination of GGO, consolidations, and a tree-in-bud-like distribution of centrilobular nodules is a hallmark of atypical bacterial pneumonia. These images serve as a clinical reference for identifying infectious lung patterns and assessing the distribution of lobar and perilobular inflammatory changes.

This diagnostic image is a portable anteroposterior (AP) chest X-ray. The radiograph demonstrates a focal area of increased opacity in the right lower lung zone, consistent with a right lower lobe infiltrate or consolidation. The heart size appears within normal limits, though the mediastinal borders and hilar regions are partially obscured by the projection and patient positioning. Several linear radiopaque structures are visible across the thoracic cage, representing external monitoring leads or cables. The image includes 'PORTABLE' and 'LT' (left) orientation markers. This visual is characteristic of Mycoplasma pneumoniae-associated pneumonia, which in this clinical context is linked to the development of Stevens-Johnson syndrome (SJS). The description is optimized for medical education indexing regarding pulmonary manifestations of atypical infections and their extrapulmonary complications.

This diagnostic image consists of a four-panel comparison (A-D) of posterior-anterior chest X-rays demonstrating different radiological patterns of Mycoplasma pneumoniae pneumonia. Panel (A) displays a homogeneous dense lobar consolidation, characterized by a uniform, opaque white area in the right upper lobe with sharply defined margins. Panel (B) shows patchy consolidation, presenting as scattered, non-uniform areas of increased density primarily in the mid-to-upper lung fields. Panel (C) illustrates nodular opacities, appearing as multiple small, discrete, rounded densities distributed throughout both lung parenchymas. Panel (D) depicts bilateral parahilar infiltration, showing hazy, interstitial-like densities radiating from the hilar regions into the surrounding lung tissue. This comparison chart serves as an educational tool for identifying the diverse pulmonary manifestations of atypical bacterial pneumonia in clinical practice. The target audience includes medical students and radiology residents studying thoracic imaging and infectious disease presentations.

This composite of chest imaging (A-E) illustrates the clinical progression and long-term sequelae of Mycoplasma pneumoniae pneumonia (MPP) in a pediatric patient. Panels A (Day 9) and C (Day 11) are anteroposterior chest X-rays showing dense opacification in the right lung field, consistent with lobar consolidation and associated right-sided pleural effusion. Panel B (Day 10) is an axial CT slice confirming high-density parenchymal consolidation and pleural fluid during the acute phase. Panel D (Day 24) shows a follow-up chest X-ray with significant resolution of the acute consolidation and effusion, appearing near normal. Panel E is a high-resolution CT (HRCT) axial slice taken 9 months post-illness, demonstrating chronic sequelae. It reveals a distinct mosaic perfusion pattern, characterized by sharply demarcated areas of decreased attenuation (air trapping/hypoperfusion) and regions of higher density (normal or redistributed perfusion). These findings are diagnostic of bronchiolitis obliterans following severe respiratory infection. The series highlights the evolution from acute inflammatory consolidation to chronic obstructive small airway disease.
Mycoplasma pneumoniae infection treatment
| Feature | Detail |
|---|---|
| Size | 10 × 200 nm - can pass through 0.45-µm pore filters |
| Cell wall | Absent - bounded only by a sterol-containing plasma membrane (unique among bacteria) |
| Gram stain | Cannot be Gram stained (no cell wall to stain) |
| Growth | Slow; generation time ~6 hours; fastidious growth requirements |
| Antibiotic resistance | Naturally resistant to ALL beta-lactams (penicillins, cephalosporins, carbapenems) and glycopeptides (vancomycin) - all of which target cell wall synthesis |
| Species | Primary Disease |
|---|---|
| M. pneumoniae | "Walking pneumonia" / atypical CAP, URTI, tracheobronchitis |
| M. genitalium | Non-gonococcal urethritis (NGU), cervicitis, pelvic inflammatory disease |
| M. hominis | Urogenital infections, postpartum fever |
| Ureaplasma urealyticum | NGU, neonatal pneumonia, chorioamnionitis |


| System | Manifestations |
|---|---|
| Skin | Maculopapular/morbilliform/vesicular rash in 10-25%; erythema multiforme; erythema nodosum; urticaria |
| Severe skin | Stevens-Johnson syndrome in up to 7% (especially young males 2-4:1 ratio); erythematous vesicles, plaques, and bullae at mucocutaneous junctions; can occur without antibiotic exposure |
| Hematologic | Cold agglutinin-mediated hemolytic anemia (Coombs-positive); Raynaud phenomenon |
| Neurologic | Encephalitis, meningitis, Guillain-Barré syndrome, transverse myelitis |
| Cardiac | Myocarditis, pericarditis, complete heart block |
| GI/GU | Nausea, vomiting; hepatitis |
| Joints | Migratory polyarthritis |
| Test | Details |
|---|---|
| PCR (NAAT) | Most sensitive and specific; gold standard for diagnosis |
| Cold agglutinins | IgM against I-antigen; titer ≥1:32 highly suggestive; bedside test possible (cool blood to 4°C, observe clumping that reverses at 37°C); non-specific (also positive in EBV, CMV, lymphoma) |
| Serology (complement fixation / ELISA) | Rise in IgM/IgG titers; useful retrospectively; IgM appears days 7-10 |
| Culture | Very slow (weeks), impractical clinically |
| Gram stain | Cannot detect Mycoplasma (no cell wall to stain) |
| Sputum | PMNs without dominant organism; no pathogen on routine culture |
Key clue: Child/young adult with 2-3 week incubation, persistent nonproductive cough, mild or no chest findings, but CXR showing bilateral infiltrates, who has failed beta-lactam therapy - think M. pneumoniae.
| Drug | Regimen | Notes |
|---|---|---|
| Azithromycin | 500 mg Day 1, then 250 mg x 4 days | First-line; convenient 5-day course |
| Doxycycline | 100 mg every 12 hours x 7-14 days | Alternative first-line |
| Moxifloxacin | 400 mg daily x 7-10 days | For macrolide resistance or failure |
| Levofloxacin | 750 mg daily x 7-10 days | Alternative fluoroquinolone |
Explain in short for mini notes
| Species | Disease |
|---|---|
| M. pneumoniae | Atypical "walking" pneumonia |
| M. genitalium | NGU, PID, cervicitis |
| M. hominis | Postpartum fever, PID |
| Ureaplasma urealyticum | NGU, neonatal pneumonia |
| System | Complication |
|---|---|
| Skin | Maculopapular rash (10-25%) |
| Severe skin | Stevens-Johnson syndrome (up to 7%; young males) |
| Blood | Cold agglutinin hemolytic anemia |
| Neuro | Encephalitis, Guillain-Barré, meningitis |
| Heart | Myocarditis, pericarditis |
| Test | Note |
|---|---|
| PCR (NAAT) | Gold standard, most sensitive |
| Cold agglutinins | IgM; titer ≥1:32 suggestive; bedside test possible |
| Serology (IgM/IgG) | Retrospective; rises at 7-10 days |
| Culture | Too slow (weeks) - not practical |
| Gram stain | Useless - no cell wall |
Bedside cold agglutinin test: Draw blood → cool to 4°C → clumping = positive → rewarm to 37°C → clumping reverses ✓
| Drug | Dose | Notes |
|---|---|---|
| Azithromycin | 500 mg day 1 → 250 mg × 4 days | First-line |
| Doxycycline | 100 mg BD × 7-14 days | First-line alternative |
| Moxifloxacin | 400 mg OD × 7-10 days | Macrolide resistance / Asia |
| Levofloxacin | 750 mg OD × 7-10 days | Alternative FQ |
Spirochetes
spirochete Treponema pallidum dark field microscopy syphilis chancre

This histology image depicts a lymph node section stained with Steiner silver stain, visualizing Treponema pallidum organisms within the node. Light microscopy reveals numerous dark, corkscrew-shaped spirochetes aligned along walls of capsular vessels and scattered through the interstitial stroma, consistent with syphilitic lymphadenitis. The tissue architecture shows preserved lymphoid elements with areas of mild follicular hyperplasia and perivascular inflammation, overlaid by slender, hyaline backgrounds produced by the stain. Steiner silver staining yields high-contrast, fine filaments that stand out against the pale counterstain, enabling direct visualization of spirochetes in situ. Although histology can be variable in syphilis, the detection of multiple organisms strongly supports infection and guides confirmation with serology. This image exemplifies the complementary roles of histopathology, immunohistochemistry, and molecular methods (PCR on lymph node biopsy or fine-needle aspirate) in diagnosing syphilitic lymphadenitis. Clinically, the diagnosis is most reliably established by serologic tests (treponemal and non-treponemal assays) alongside clinical context and patient history. The image is part of the CDC educational collection (Skip Van Orden), serving as a teaching resource for infectious disease pathology, dermatopathology, and surgical pathology workflows in recognizing T. pallidum. This description emphasizes spirochete visualization as a diagnostic clue.

This composite of three clinical photographs illustrates the dermatological and urogenital manifestations of early syphilis (Treponema pallidum infection). Panel A shows a wide-field view of the anterior torso featuring a dense, generalized maculopapular rash, typical of secondary syphilis. The lesions are symmetric, non-confluent, and reddish-pink. Panel B provides a high-magnification view of the same rash, highlighting individual erythematous papules with distinct borders and underlying skin inflammation. Panel C depicts a primary syphilis lesion: a solitary, well-demarcated chancre on the dorsal penile shaft. The chancre presents as a round, reddish-brown ulcer with indurated edges, a clean base, and associated localized erythema. This educational visual is designed to assist in the clinical identification of primary versus secondary stages of syphilis, focusing on the transition from a localized inoculation site (chancre) to systemic cutaneous dissemination (maculopapular rash). It is intended for medical education in infectious diseases, dermatology, and sexual health.

This image is a clinical photograph of an oral mucosal lesion on the dorsal tongue surface. The modality is clinical photography (intraoral) with close-up macro framing to document mucosal pathology. The lesion presents as a solitary, pale-to-pearly central ulcer with a mildly erythematous surrounding plaque and an elevated, indurated-looking border. The base appears clean and non-fibrinous, and the adjacent mucosa is moist and reddened. In the context of primary syphilis, this presentation corresponds to an oral chancre—a painless, indurated ulcer that may occur at extragenital sites. The image lacks visible vesicles or crusts and does not demonstrate necrosis or extensive edema; the lesion is non-tender to palpation in typical cases. Pathophysiologically, primary syphilitic chancres reflect Treponema pallidum inoculation with local endarteritis and a proliferative plasma-cell infiltrate in the surrounding tissue; serology (RPR/VDRL and treponemal tests) and dark-field microscopy aid confirmation. Clinically, this finding should prompt sexually transmitted infection screening and partner notification. Differential considerations include aphthous ulcer, traumatic ulcer, candidal or ulcerative lesions, and early squamous cell carcinoma. Appropriate clinical correlation with history, systemic signs, and risk factors is essential for timely diagnosis and treatment. When treated, serologic titers typically decline, and mucosal lesions heal. Clinical evidence.

Histopathology image from a cutaneous syphilitic chancre after Hematoxylin and Eosin staining demonstrates a dense inflammatory infiltrate in the dermis with a perivascular pattern. The cellular milieu is dominated by plasma cells, accompanied by lymphocytes and histiocytes. Endothelial swelling and small-vessel endarteritis are evident, forming the classic histologic triad associated with Treponema pallidum infection. The epidermis may be relatively preserved with only mild spongiosis; necrosis is minimal. Although non-specific in isolation, the combination of perivascular plasma cell–rich infiltrate and endarteritis strongly points toward primary syphilis in the appropriate clinical context. Special stains or immunohistochemistry can reveal spirochetes, though they may be absent in this field. Clinically relevant for differentiating chronic inflammatory dermatoses and serving as an educational exemplar of syphilitic histopathology. Diagnostic significance lies in supporting early syphilis when integrated with serology (RPR/VDRL, FTA-ABS/TP-PA) and clinical findings; informs treatment decisions and epidemiologic interventions; useful for medical education, dermatopathology reviews, and infectious disease reference repositories.

This clinical photograph displays a primary syphilitic chancre located on the right lower lip of an adult male. The lesion is a well-demarcated, approximately 2x3 cm plaque that crosses the vermillion border, extending from the cutaneous surface to the labial mucosa. The center of the plaque is characterized by a dark, hemorrhagic, and necrotic crust, while the surrounding peripheral tissue shows significant erythema and localized edema. The adjacent skin exhibits normal texture with greyish-white facial hair. This image serves as an educational example of extragenital primary syphilis, highlighting the characteristic morphology of a chancre which often presents as a painless but indurated ulcer or crusted plaque. Key educational concepts include the clinical identification of Treponema pallidum infections and the differential diagnosis of lip lesions, such as squamous cell carcinoma or herpes simplex virus.

This darkfield video microscopy time series (1000x magnification) illustrates the dynamic interaction between the spirochete Treponema pallidum and a human platelet over a period of 43.21 seconds. The imagery displays a single treponeme, characterized by its distinctive helical morphology, interacting with a fully activated, spread platelet. The sequence captures various behavioral states: at 1.68 s, a cyan curved arrow indicates coiling and vigorous axial rotation against the platelet membrane. In subsequent frames (15.15 s – 34.40 s), the spirochete is seen extending away from or above the platelet surface. The final frame at 43.21 s highlights tip-mediated adhesion, where green arrows point to both distal ends of the treponeme anchored to the platelet membrane. This visual evidence demonstrates the ability of T. pallidum to recognize and physically engage with activated components of the human hemostatic system. A 10 μm scale bar is provided for reference in the final frame.

| Feature | Treponema | Borrelia | Leptospira |
|---|---|---|---|
| Morphology | Tight corkscrew | Loose coils | Tightly coiled, hooked ends |
| Size | Very thin (0.2 µm) | Wider, visible on smear | Thin, hooked |
| Motility | Rotation + flexion | Corkscrew | Rapid rotation |
| Transmission | Sexual / transplacental | Tick/louse | Contact with contaminated water/urine |
| Reservoir | Humans only | Animals (deer, mice) | Rodents (rats), wild/domestic animals |
| Culture | Cannot be cultured | Special media (weeks) | Special media (weeks) |
| Key disease | Syphilis | Lyme disease, Relapsing fever | Leptospirosis (Weil disease) |

| Type | Manifestations |
|---|---|
| Gummatous | Granulomatous lesions (gummas) in skin, bone, liver |
| Cardiovascular | Aortitis → aortic aneurysm (classically ascending aorta), aortic regurgitation |
| Neurosyphilis | Meningovascular syphilis; tabes dorsalis (posterior column degeneration → ataxia, Argyll Robertson pupil); general paresis (dementia, personality change) |
Tertiary lesions contain very few spirochetes - damage is largely from delayed hypersensitivity reaction
| Test | Notes |
|---|---|
| VDRL (Venereal Disease Research Laboratory) | Detects reagin (IgM+IgG vs. cardiolipin-lecithin-cholesterol antigen); used on CSF in neurosyphilis |
| RPR (Rapid Plasma Reagin) | More practical; automated |
| Both appear 1-4 weeks after chancre; titers fall after treatment → monitor response | |
| False positives: EBV, Lyme, pregnancy, autoimmune diseases, connective tissue diseases | |
| Prozone phenomenon: False negative in secondary syphilis (antibody excess) - dilute the serum |
| Test | Notes |
|---|---|
| FTA-ABS (Fluorescent Treponemal Antibody) | Patient serum + T. pallidum slide + FITC-labeled antibody; see fluorescent spirochetes |
| MHA-TP / TP-PA (Microhemagglutination) | Sensitized sheep RBCs + patient serum → agglutination = positive; preferred for simplicity |
| Become positive before nontreponemal tests; remain positive for life | |
| False positives: connective tissue diseases, elderly, related organisms (Borrelia) |
| Stage | Regimen |
|---|---|
| Primary, secondary, early latent (<1 yr) | Benzathine penicillin G 2.4 MU IM × single dose |
| Late latent, tertiary | Benzathine penicillin G 2.4 MU IM weekly × 3 doses |
| Neurosyphilis | IV aqueous crystalline penicillin G × 10-14 days |
| Penicillin allergy | Doxycycline; ceftriaxone |
Jarisch-Herxheimer reaction: Fever, chills, hypotension within hours of first penicillin dose - caused by release of toxic products from dying spirochetes. Manage with supportive care; do NOT stop antibiotics.
| Disease | Species | Geographic area |
|---|---|---|
| Yaws | T. pallidum subsp. pertenue | Africa, Asia, South America |
| Bejel (endemic syphilis) | T. pallidum subsp. endemicum | Africa, Asia, Middle East |
| Pinta | T. carateum | South America |
| Stage | Timing | Features |
|---|---|---|
| Early localized | 1-4 weeks | Erythema migrans ("bullseye" rash) - painless, expanding ring ≥5 cm; flu-like symptoms |
| Early disseminated | Weeks-months | Multiple EM lesions; facial nerve palsy (CN VII), AV block, meningitis, radiculopathy |
| Late disseminated | Months-years | Oligoarticular arthritis (especially knee), chronic neurologic disease |
| Type | Organism | Vector |
|---|---|---|
| Epidemic | B. recurrentis | Body louse (Pediculus humanus) |
| Endemic | B. hermsii, B. turicatae | Soft ticks (Ornithodoros spp.) |
| Phase | Timing | Features |
|---|---|---|
| Leptospiremic phase | Days 1-7 | Abrupt fever, chills, myalgias (especially calves), headache, conjunctival suffusion |
| Brief remission | 1-3 days | Apparent improvement |
| Immune/Weil phase | Days 10-30 | Jaundice, acute renal failure, hemorrhage, aseptic meningitis, uveitis |
| Feature | Treponema | Borrelia | Leptospira |
|---|---|---|---|
| Shape | Tight corkscrew | Loose coils | Tightly coiled + hooked ends |
| Gram stain | Negative (poorly visible) | Negative (visible on smear) | Negative (poorly visible) |
| Visualization | Dark-field, silver stain | Giemsa blood smear | Dark-field |
| Culture | Cannot culture | Special media | Special EMJH media |
| Transmission | Sexual | Tick/louse bite | Water/urine contact |
| Key disease | Syphilis | Lyme / Relapsing fever | Leptospirosis / Weil disease |
| Treatment | Penicillin G | Doxycycline / Ceftriaxone | Doxycycline / Penicillin G |
Create a comparison table PDF of gram-positive, gram-negative, and spirochetes
ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "ready"
mkdir -p /tmp/workspace/bacteria-comparison && cat > /tmp/workspace/bacteria-comparison/generate_pdf.py << 'PYEOF' from reportlab.lib.pagesizes import A4, landscape from reportlab.lib import colors from reportlab.lib.units import cm, mm from reportlab.platypus import (SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, HRFlowable) from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.enums import TA_CENTER, TA_LEFT from reportlab.platypus import KeepTogether # ── Output path ────────────────────────────────────────────────────────────── OUTPUT = "/tmp/workspace/bacteria-comparison/Bacteria_Comparison.pdf" # ── Page setup ─────────────────────────────────────────────────────────────── doc = SimpleDocTemplate( OUTPUT, pagesize=landscape(A4), leftMargin=1.2*cm, rightMargin=1.2*cm, topMargin=1.5*cm, bottomMargin=1.5*cm, ) # ── Colour palette ─────────────────────────────────────────────────────────── COL_PURPLE = colors.HexColor("#5C2D91") # gram-positive header COL_RED = colors.HexColor("#B22222") # gram-negative header COL_BLUE = colors.HexColor("#1A5276") # spirochetes header COL_TITLE_BG = colors.HexColor("#1C2833") # title bar background COL_HDR_TEXT = colors.white COL_ROW_ALT = colors.HexColor("#F2F3F4") # alternating row shading COL_ROW_WH = colors.white COL_CAT_BG = colors.HexColor("#D5D8DC") # category row background COL_BORDER = colors.HexColor("#7F8C8D") # ── Styles ─────────────────────────────────────────────────────────────────── styles = getSampleStyleSheet() title_style = ParagraphStyle("title_style", fontSize=18, textColor=colors.white, fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=4) subtitle_style = ParagraphStyle("subtitle_style", fontSize=10, textColor=colors.HexColor("#BDC3C7"), fontName="Helvetica", alignment=TA_CENTER) cat_style = ParagraphStyle("cat_style", fontSize=9, fontName="Helvetica-Bold", textColor=colors.HexColor("#1C2833"), alignment=TA_LEFT) cell_style = ParagraphStyle("cell_style", fontSize=8, fontName="Helvetica", textColor=colors.HexColor("#1C2833"), alignment=TA_LEFT, leading=11) gp_style = ParagraphStyle("gp_style", fontSize=8.5, fontName="Helvetica-Bold", textColor=COL_PURPLE, alignment=TA_LEFT, leading=11) gn_style = ParagraphStyle("gn_style", fontSize=8.5, fontName="Helvetica-Bold", textColor=COL_RED, alignment=TA_LEFT, leading=11) sp_style = ParagraphStyle("sp_style", fontSize=8.5, fontName="Helvetica-Bold", textColor=COL_BLUE, alignment=TA_LEFT, leading=11) hdr_style = ParagraphStyle("hdr_style", fontSize=9.5, fontName="Helvetica-Bold", textColor=colors.white, alignment=TA_CENTER, leading=12) def C(text, style=cell_style): return Paragraph(text, style) def GP(text): return Paragraph(text, gp_style) def GN(text): return Paragraph(text, gn_style) def SP(text): return Paragraph(text, sp_style) def CAT(text): return Paragraph(text, cat_style) # ══════════════════════════════════════════════════════════════════════════════ # TABLE DATA # ══════════════════════════════════════════════════════════════════════════════ FEATURE = C("Feature", cell_style) GP_HDR = Paragraph("Gram-Positive", hdr_style) GN_HDR = Paragraph("Gram-Negative", hdr_style) SP_HDR = Paragraph("Spirochetes", hdr_style) rows = [ # ── Header ── [FEATURE, GP_HDR, GN_HDR, SP_HDR], # ── STRUCTURE ── [CAT("STRUCTURE & CELL WALL"), C(""), C(""), C("")], [C("Gram stain result"), GP("Purple / Violet"), GN("Pink / Red"), SP("Stains poorly\n(too thin)")], [C("Cell wall thickness"), GP("Thick PG layer\n(150–500 Å)"), GN("Thin PG layer\n(single layer)"), SP("Thin PG layer\n(gram-negative type)")], [C("Outer membrane (OM)"), GP("Absent"), GN("Present (contains LPS)"), SP("Present (no LPS in\nTreponema)")], [C("LPS / Endotoxin"), GP("Absent"), GN("Present — major\nvirulence factor"), SP("Absent (Treponema)\nPresent (Leptospira)")], [C("Teichoic / Lipoteichoic acids"), GP("Present\n(strengthens cell wall)"), GN("Absent"), SP("Absent")], [C("Periplasmic space"), GP("Minimal"), GN("Present\n(contains β-lactamases)"), SP("Present + endoflagella\n(axial filaments)")], [C("Flagella location"), GP("External (if present)"), GN("External (if present)"), SP("Internal (periplasmic)\n= ENDOFLAGELLA")], # ── STAINING & MICROSCOPY ── [CAT("STAINING & MICROSCOPY"), C(""), C(""), C("")], [C("Gram stain"), GP("Retains crystal violet\n→ Purple"), GN("Decolorized by acetone-\nalcohol → Pink (safranin)"), SP("Cannot be reliably\nGram stained")], [C("Special stains / methods"), GP("Gram stain sufficient"), GN("Gram stain sufficient"), SP("Dark-field microscopy\nSilver stain (Warthin-Starry)\nImmunofluorescence\nGiemsa (Borrelia)")], [C("Can be cultured?"), GP("Yes — standard media"), GN("Yes — standard media"), SP("Treponema: NO\nBorrelia/Leptospira:\nspecial media (weeks)")], # ── VIRULENCE & PATHOGENESIS ── [CAT("VIRULENCE & PATHOGENESIS"), C(""), C(""), C("")], [C("Key toxins / virulence"), GP("Exotoxins (highly potent):\nToxic shock (TSST-1)\nDiphtheria toxin\nTetanus / Botulinum toxin\nPeptidoglycan fragments"), GN("Endotoxin (LPS):\n→ TLR-4 activation\n→ cytokine storm\n→ septic shock\nExotoxins (Cholera, etc.)"), SP("Treponema: hyaluronidase\nBorrelia: antigenic variation\nLeptospira: leptospiral\ntoxins → endarteritis")], [C("Sepsis / Shock mechanism"), GP("Peptidoglycan + TSST-1\n→ superantigen T-cell\nactivation"), GN("LPS → TLR-4 → TNF,\nIL-1, IL-6 → shock\n(more severe)"), SP("Immune-mediated\nendarteritis and\nhypersensitivity")], # ── ANTIBIOTIC SUSCEPTIBILITY ── [CAT("ANTIBIOTIC SUSCEPTIBILITY"), C(""), C(""), C("")], [C("Beta-lactams\n(Penicillins, Cephalosporins)"), GP("Generally susceptible\n(exposed PG target)"), GN("Lower susceptibility\n(OM barrier +\nperiplasmic β-lactamases)"), SP("Treponema: HIGHLY\nsusceptible (penicillin)\nLeptospira: sensitive\nBorrelia: ceftriaxone")], [C("Vancomycin"), GP("Active against most\ngram-positive organisms"), GN("Inactive\n(too large to cross OM)"), SP("Inactive")], [C("Macrolides / Tetracyclines"), GP("Active"), GN("Active (variable)"), SP("Active\n(Doxycycline = first-line\nfor Lyme, Leptospira)")], [C("Resistance mechanisms"), GP("β-lactamase\nMethicillin resistance (MRSA)\nVancomycin resistance (VRE)"), GN("Periplasmic β-lactamases\nPorin channel mutations\nEfflux pumps\nMDR strains common"), SP("Minimal resistance\n(Treponema: still 100%\npenicillin-sensitive)")], # ── CLINICAL EXAMPLES ── [CAT("KEY CLINICAL EXAMPLES"), C(""), C(""), C("")], [C("Cocci"), GP("Staph aureus (MRSA)\nStrep pyogenes (Group A)\nStrep pneumoniae\nEnterococcus"), GN("Neisseria gonorrhoeae\nNeisseria meningitidis"), SP("—")], [C("Rods / Bacilli"), GP("Bacillus anthracis\nClostridium (tetani, botulinum,\nperfringens, difficile)\nCorynebacterium diphth.\nListeria monocytogenes"), GN("E. coli, Klebsiella\nPseudomonas aeruginosa\nH. influenzae, Salmonella\nShigella, Helicobacter pylori\nLegionella, Yersinia"), SP("Treponema pallidum → Syphilis\nBorrelia burgdorferi → Lyme\nBorrelia recurrentis → Relapsing fever\nLeptospira interrogans → Leptospirosis")], [C("Key diseases"), GP("Skin/soft tissue infections\nPneumonia (pneumococcal)\nMeningitis\nFood poisoning\nGas gangrene, C. diff colitis"), GN("UTI, pneumonia, sepsis\nMeningococcal meningitis\nGonorrhoea\nCholera, typhoid fever\nLegionnaire's disease"), SP("Primary syphilis → Chancre\nSecondary → Maculopapular rash\nTertiary → Gummas, aortitis,\nneurosyphilis\nLyme → Erythema migrans,\nbell's palsy, arthritis\nWeil disease → jaundice +\nrenal failure + bleeding")], # ── DIAGNOSIS ── [CAT("DIAGNOSIS"), C(""), C(""), C("")], [C("Primary identification"), GP("Gram stain + culture\non standard media"), GN("Gram stain + culture\non standard media"), SP("Serology (VDRL/RPR +\nFTA-ABS for syphilis)\nDark-field microscopy\nPCR / NAAT\nGiemsa smear (Borrelia)")], [C("Unique diagnostic tests"), GP("Coagulase test (Staph)\nCatalase test\nASO titre (Strep)\nOptochin sensitivity (Pneumo)"), GN("Oxidase test\nMacConkey agar\nIndole test\nLactose fermentation"), SP("Non-treponemal: VDRL/RPR\nTreponemal: FTA-ABS/TP-PA\nLyme: 2-tier serology\nMAT for Leptospira")], ] # ══════════════════════════════════════════════════════════════════════════════ # TABLE STYLING # ══════════════════════════════════════════════════════════════════════════════ col_widths = [4.5*cm, 7.0*cm, 7.0*cm, 7.0*cm] style_cmds = [ # Overall ("BACKGROUND", (0,0), (-1,0), COL_TITLE_BG), # header row ("TEXTCOLOR", (0,0), (-1,0), COL_HDR_TEXT), ("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"), ("FONTSIZE", (0,0), (-1,0), 9.5), ("ALIGN", (0,0), (-1,0), "CENTER"), ("VALIGN", (0,0), (-1,-1), "TOP"), ("ROWBACKGROUNDS", (0,1), (-1,-1), [COL_ROW_WH, COL_ROW_ALT]), ("GRID", (0,0), (-1,-1), 0.4, COL_BORDER), ("LEFTPADDING", (0,0), (-1,-1), 5), ("RIGHTPADDING", (0,0), (-1,-1), 5), ("TOPPADDING", (0,0), (-1,-1), 5), ("BOTTOMPADDING",(0,0), (-1,-1), 5), # Column header colours ("BACKGROUND", (1,0), (1,0), COL_PURPLE), ("BACKGROUND", (2,0), (2,0), COL_RED), ("BACKGROUND", (3,0), (3,0), COL_BLUE), ] # Category rows — find them by index cat_indices = [i for i, row in enumerate(rows) if row[0] == CAT(row[0].text if hasattr(row[0],'text') else "")] # Simpler: detect rows where columns 1-3 are empty strings cat_row_indices = [i for i, row in enumerate(rows) if isinstance(row[1], Paragraph) and row[1].text == "" and isinstance(row[2], Paragraph) and row[2].text == ""] # Also handle C("") case cat_row_indices_2 = [i for i, row in enumerate(rows) if hasattr(row[1], 'text') and row[1].text == ""] # Mark category rows for i, row in enumerate(rows): try: if row[1].text == "" and row[2].text == "": style_cmds.append(("BACKGROUND", (0,i), (-1,i), COL_CAT_BG)) style_cmds.append(("SPAN", (0,i), (-1,i))) style_cmds.append(("FONTNAME", (0,i), (-1,i), "Helvetica-Bold")) style_cmds.append(("FONTSIZE", (0,i), (-1,i), 9)) except: pass table = Table(rows, colWidths=col_widths, repeatRows=1) table.setStyle(TableStyle(style_cmds)) # ══════════════════════════════════════════════════════════════════════════════ # DOCUMENT ASSEMBLY # ══════════════════════════════════════════════════════════════════════════════ story = [] # Title block (drawn as a table for coloured background) title_data = [[Paragraph("Bacterial Classification: Gram-Positive vs Gram-Negative vs Spirochetes", title_style)], [Paragraph("Comprehensive Comparison Table • Microbiology Quick Reference", subtitle_style)]] title_table = Table(title_data, colWidths=[25.6*cm]) title_table.setStyle(TableStyle([ ("BACKGROUND", (0,0), (-1,-1), COL_TITLE_BG), ("TOPPADDING", (0,0), (-1,-1), 8), ("BOTTOMPADDING", (0,0), (-1,-1), 8), ("LEFTPADDING", (0,0), (-1,-1), 10), ("RIGHTPADDING", (0,0), (-1,-1), 10), ])) story.append(title_table) story.append(Spacer(1, 0.4*cm)) story.append(table) story.append(Spacer(1, 0.3*cm)) # Footer note footer_style = ParagraphStyle("footer", fontSize=7, textColor=colors.grey, fontName="Helvetica", alignment=TA_CENTER) story.append(Paragraph( "Sources: Medical Microbiology 9e (Murray) • Jawetz Melnick & Adelbergs Medical Microbiology 28e • " "Sherris & Ryan's Medical Microbiology 8e • Katzung's Basic & Clinical Pharmacology 16e • " "Quick Compendium of Clinical Pathology 5e", footer_style)) doc.build(story) print(f"PDF created: {OUTPUT}") PYEOF echo "Script written"
cd /tmp/workspace/bacteria-comparison && python generate_pdf.py 2>&1
ls -lh /tmp/workspace/bacteria-comparison/Bacteria_Comparison.pdf
Bacteria Comparison
PDF Document · PDF