// prokaryotes.sy -- Prokaryotic cell biology as native Scyla.
//
// Bacterial cell structure, gram staining, peptidoglycan,
// flagella, pili, binary fission, and clinically important bacteria.
//
// Sources:
//   Madigan MT et al. Brock's Biology of Microorganisms, 16th ed, 2021.
//   Murray PR et al. Medical Microbiology, 9th ed, 2021.
//   Silhavy TJ et al. Cold Spring Harb Perspect Biol 2:a000414, 2010 (envelope).
//
// Marjorie McCubbins + Aether, April 2026
// Patent pending: 64/034,536

struct ProkaryoteStructure {
    name: String,
    description: String,
    composition: String,
    essential: Bool,
    key_protein: String,
    key_protein_accession: String,
    gram_positive: Bool,
    gram_negative: Bool,
    citation: String,
}

struct GramStainResult {
    classification: String,
    color: String,
    wall_thickness: String,
    outer_membrane: Bool,
    lps: Bool,
    teichoic_acid: Bool,
    periplasm: Bool,
    examples: String,
    citation: String,
}

struct BinaryFissionStep {
    step_number: Int,
    phase_name: String,
    mechanism: String,
    key_protein: String,
    key_protein_accession: String,
    citation: String,
}

struct ClinicalBacterium {
    name: String,
    gram: String,
    morphology: String,
    oxygen_requirement: String,
    virulence_factors: String,
    diseases: String,
    treatment: String,
    citation: String,
}

struct BacterialMotility {
    motility_type: String,
    structure_involved: String,
    mechanism: String,
    energy_source: String,
    key_protein: String,
    citation: String,
}

fn pstruct(n: String, d: String, c: String, e: Bool, kp: String, kpa: String, gp: Bool, gn: Bool, ci: String) -> ProkaryoteStructure {
    return ProkaryoteStructure { name: n, description: d, composition: c, essential: e, key_protein: kp, key_protein_accession: kpa, gram_positive: gp, gram_negative: gn, citation: ci }
}

fn gramresult(cl: String, co: String, wt: String, om: Bool, lp: Bool, ta: Bool, pp: Bool, ex: String, ci: String) -> GramStainResult {
    return GramStainResult { classification: cl, color: co, wall_thickness: wt, outer_membrane: om, lps: lp, teichoic_acid: ta, periplasm: pp, examples: ex, citation: ci }
}

fn bfstep(sn: Int, pn: String, me: String, kp: String, kpa: String, ci: String) -> BinaryFissionStep {
    return BinaryFissionStep { step_number: sn, phase_name: pn, mechanism: me, key_protein: kp, key_protein_accession: kpa, citation: ci }
}

fn clinbact(n: String, g: String, m: String, o: String, v: String, d: String, t: String, ci: String) -> ClinicalBacterium {
    return ClinicalBacterium { name: n, gram: g, morphology: m, oxygen_requirement: o, virulence_factors: v, diseases: d, treatment: t, citation: ci }
}

fn bmotility(mt: String, si: String, me: String, es: String, kp: String, ci: String) -> BacterialMotility {
    return BacterialMotility { motility_type: mt, structure_involved: si, mechanism: me, energy_source: es, key_protein: kp, citation: ci }
}

// =========================================================
// CELL STRUCTURES
// =========================================================

fn prokaryote_structure(name: String) -> ProkaryoteStructure {
    if name == "cell_wall" { return pstruct("Cell wall (peptidoglycan/murein)", "Rigid exoskeleton surrounding cytoplasmic membrane. Provides shape, osmotic protection. Target of beta-lactam antibiotics (penicillin, cephalosporins).", "N-acetylglucosamine (NAG) and N-acetylmuramic acid (NAM) linked by beta-1,4 glycosidic bonds. Cross-linked by short peptide bridges (D-Ala-D-Ala target of vancomycin).", true, "MurA (UDP-NAG enolpyruvyl transferase)", "P0A749", true, true, "Silhavy TJ et al. Cold Spring Harb Perspect Biol 2:a000414, 2010") }
    if name == "outer_membrane" { return pstruct("Outer membrane", "Second lipid bilayer outside peptidoglycan in gram-negative bacteria. Contains LPS (endotoxin, lipid A). Porins allow small molecule diffusion.", "Phospholipid inner leaflet, lipopolysaccharide (LPS) outer leaflet. Porins (OmpF, OmpC) form channels.", true, "OmpF (porin)", "P02931", false, true, "Silhavy 2010") }
    if name == "lps" { return pstruct("Lipopolysaccharide (LPS/endotoxin)", "Gram-negative outer membrane component. Lipid A = endotoxin (activates TLR4, triggers septic shock). O-antigen = serotyping. Core oligosaccharide links them.", "Lipid A (diglucosamine with fatty acids) + core oligosaccharide + O-antigen (repeating polysaccharide).", true, "LpxC (lipid A biosynthesis)", "P0A725", false, true, "Raetz CR, Whitfield C. Annu Rev Biochem 71:635-700, 2002") }
    if name == "teichoic_acid" { return pstruct("Teichoic acid", "Gram-positive wall polymer. Wall teichoic acid (WTA) covalently linked to peptidoglycan. Lipoteichoic acid (LTA) anchored in membrane. Roles: cation binding, cell division, phage receptor.", "Polyol phosphate polymers (glycerol phosphate or ribitol phosphate). Decorated with D-alanine and sugars.", true, "TagB (teichoic acid biosynthesis)", "P13485", true, false, "Brown S et al. Annu Rev Microbiol 67:313-336, 2013") }
    if name == "capsule" { return pstruct("Capsule (glycocalyx)", "Polysaccharide layer outside cell wall. Prevents phagocytosis (antiphagocytic virulence factor). Basis for serotyping (S. pneumoniae has 100+ serotypes). Vaccine target.", "Polysaccharide (most species) or polypeptide (B. anthracis = poly-D-glutamic acid).", false, "Wza (capsule export)", "P0A930", true, true, "Whitfield C. Annu Rev Biochem 75:39-68, 2006") }
    if name == "flagellum" { return pstruct("Flagellum", "Rotary motor for swimming motility. Basal body (motor) embedded in envelope, hook (universal joint), filament (propeller). Rotates 100-1000 rpm. H-antigen for serotyping.", "Flagellin protein (FliC) polymerizes into hollow filament. Motor driven by proton motive force (MotA/MotB stator).", false, "FliC (flagellin)", "P04949", true, true, "Berg HC. Annu Rev Biochem 72:19-54, 2003") }
    if name == "pilus" { return pstruct("Pilus (fimbria)", "Hair-like surface appendages. Type I pili: adhesion to host cells. Type IV pili: twitching motility, DNA uptake. Sex pilus (F pilus): conjugation (horizontal gene transfer).", "Pilin protein subunits polymerize into helical fiber. Type IV pili retract (PilT ATPase).", false, "PilA (pilin)", "P02973", true, true, "Craig L et al. Nat Rev Microbiol 2:363-378, 2004") }
    if name == "cytoplasmic_membrane" { return pstruct("Cytoplasmic (inner) membrane", "Phospholipid bilayer. No sterols (except Mycoplasma). Houses ETC, ATP synthase, secretion systems. Selective barrier.", "Phospholipids (PE, PG, cardiolipin). No cholesterol. Contains all respiratory chain components.", true, "SecYEG (protein translocase)", "P0AGA2", true, true, "Madigan 16th ed, Ch 2") }
    if name == "ribosome" { return pstruct("Ribosome (70S)", "Protein synthesis. 70S = 30S small + 50S large (vs eukaryotic 80S). Target of many antibiotics: aminoglycosides (30S), tetracyclines (30S), macrolides (50S), chloramphenicol (50S).", "30S: 16S rRNA + 21 proteins. 50S: 23S rRNA + 5S rRNA + 31 proteins.", true, "RpsA (30S S1 protein)", "P0AG67", true, true, "Ramakrishnan V. Cell 108:557-572, 2002") }
    if name == "nucleoid" { return pstruct("Nucleoid", "Region containing circular chromosome. Not membrane-bound (no true nucleus). DNA is supercoiled and compacted by NAPs (nucleoid-associated proteins). Typically one circular chromosome (4-6 Mbp in E. coli).", "Circular dsDNA + HU, IHF, H-NS, Fis (NAPs). Some bacteria have linear chromosomes (Borrelia).", true, "HU (histone-like protein)", "P0ACF0", true, true, "Madigan 16th ed, Ch 2") }
    if name == "plasmid" { return pstruct("Plasmid", "Small circular extrachromosomal DNA. Self-replicating. Carries accessory genes: antibiotic resistance (R plasmids), virulence (pathogenicity islands), metabolism (degradative). Horizontal gene transfer vehicle.", "Circular dsDNA, 1-200 kb. Copy number varies (1-700 per cell). Incompatibility groups.", false, "TrfA (replication initiation)", "P07674", true, true, "Madigan 16th ed, Ch 9") }
    if name == "inclusion_body" { return pstruct("Inclusion bodies (storage granules)", "Intracellular reserves of carbon, energy, or nutrients. PHB (poly-beta-hydroxybutyrate) = carbon/energy. Polyphosphate (volutin) = phosphate reserve. Sulfur globules. Glycogen.", "PHB granules, polyphosphate granules, sulfur globules, carboxysomes (CO2 fixation), magnetosomes (Fe3O4).", false, "PhaC (PHB synthase)", "P12624", true, true, "Madigan 16th ed, Ch 2") }
    if name == "endospore" { return pstruct("Endospore", "Dormant, highly resistant structure formed by Bacillus and Clostridium. Survives boiling, radiation, desiccation, chemicals. Contains dipicolinic acid (DPA) + Ca2+ for heat resistance. Core is dehydrated. Small acid-soluble proteins (SASPs) protect DNA.", "Multilayered: core (dehydrated cytoplasm) + cortex (modified peptidoglycan) + coat (keratin-like proteins) + exosporium (some species).", false, "SpoIIE (sporulation phosphatase)", "P0AEL7", true, false, "Madigan 16th ed, Ch 2") }
    return pstruct("", "", "", false, "", "", false, false, "")
}

// =========================================================
// GRAM STAINING
// =========================================================

fn gram_stain(gram_type: String) -> GramStainResult {
    if gram_type == "positive" { return gramresult("Gram-positive", "Purple/violet (retains crystal violet-iodine complex)", "Thick (20-80 nm peptidoglycan, multiple layers)", false, false, true, false, "Staphylococcus aureus, Streptococcus pneumoniae, Bacillus anthracis, Clostridium difficile, Enterococcus faecalis, Listeria monocytogenes, Corynebacterium diphtheriae", "Gram HC. Fortschr Med 2:185-189, 1884") }
    if gram_type == "negative" { return gramresult("Gram-negative", "Pink/red (decolorized, counterstained with safranin)", "Thin (2-7 nm peptidoglycan, single layer)", true, true, false, true, "Escherichia coli, Pseudomonas aeruginosa, Neisseria meningitidis, Salmonella enterica, Klebsiella pneumoniae, Helicobacter pylori, Haemophilus influenzae", "Gram 1884") }
    if gram_type == "acid_fast" { return gramresult("Acid-fast (Ziehl-Neelsen stain)", "Red (retains carbol fuchsin after acid-alcohol decolorization)", "Mycolic acid layer (60-90 carbon fatty acids). Waxy cell wall. Neither gram-positive nor gram-negative by conventional staining.", false, false, false, false, "Mycobacterium tuberculosis, Mycobacterium leprae, Nocardia (partially acid-fast)", "Ziehl F. Dtsch Med Wochenschr 8:451, 1882") }
    if gram_type == "atypical" { return gramresult("Atypical (no cell wall)", "Do not gram stain (no peptidoglycan)", "No cell wall. Only cytoplasmic membrane with sterols (cholesterol). Smallest free-living organisms.", false, false, false, false, "Mycoplasma pneumoniae (walking pneumonia), Ureaplasma urealyticum. Intrinsically resistant to beta-lactams and vancomycin (no wall target).", "Murray 9th ed") }
    return gramresult("", "", "", false, false, false, false, "", "")
}

// =========================================================
// GRAM STAIN PROCEDURE
// =========================================================

fn gram_stain_step(step: Int) -> String {
    if step == 1 { return "Crystal violet (primary stain): Apply 1 min. Both gram+ and gram- stain purple. CV+ enters peptidoglycan." }
    if step == 2 { return "Iodine (mordant): Apply 1 min. Iodine forms CV-I complex inside cell. Complex is large, trapped in thick peptidoglycan." }
    if step == 3 { return "Alcohol/acetone (decolorizer): Apply 10-30 sec. CRITICAL STEP. Dehydrates thick gram+ wall (traps CV-I). Dissolves gram- outer membrane, washes CV-I out of thin wall. Gram+: stays purple. Gram-: loses purple." }
    if step == 4 { return "Safranin (counterstain): Apply 1 min. Gram- cells (now colorless) pick up pink/red safranin. Gram+ cells already purple, safranin not visible. Result: purple = gram+, pink = gram-." }
    return ""
}

// =========================================================
// BINARY FISSION
// =========================================================

fn binary_fission_step(step: Int) -> BinaryFissionStep {
    if step == 1 { return bfstep(1, "DNA replication initiation", "DnaA protein binds oriC (origin of replication). Melts AT-rich region (DUE, DnaA Unwinding Element). DnaB helicase loaded by DnaC. Bidirectional replication begins.", "DnaA (initiator)", "P03004", "Madigan 16th ed, Ch 5") }
    if step == 2 { return bfstep(2, "Bidirectional replication", "Two replication forks travel in opposite directions around circular chromosome. DNA pol III (main replicase) with sliding clamp (DnaN). Replication rate ~1000 nt/sec in E. coli. Complete genome (4.6 Mb) in ~40 min.", "DnaE (DNA pol III alpha)", "P10443", "Madigan 16th ed, Ch 5") }
    if step == 3 { return bfstep(3, "Chromosome segregation", "Daughter chromosomes segregated to cell poles. Par system (ParA/ParB/parS) actively partitions chromosomes. MukBEF (condensin) compacts DNA. Topoisomerase IV decatenates (unlinks) daughter chromosomes.", "ParA (partition ATPase)", "P07620", "Madigan 16th ed, Ch 5") }
    if step == 4 { return bfstep(4, "FtsZ ring assembly (Z-ring)", "FtsZ (tubulin homolog) polymerizes into Z-ring at midcell. MinCDE system prevents Z-ring at poles (oscillation ensures midcell placement). Nucleoid occlusion (SlmA) prevents division over unsegregated DNA.", "FtsZ (cell division GTPase)", "P0A9A6", "Bi EF, Lutkenhaus J. Nature 354:161-164, 1991") }
    if step == 5 { return bfstep(5, "Divisome assembly", "Z-ring recruits divisome proteins: FtsA, ZipA (membrane anchors), FtsK (DNA translocase), FtsQ/B/L, FtsW (peptidoglycan synthase), FtsI (PBP3, transpeptidase), FtsN (triggers constriction).", "FtsI (PBP3)", "P0AD68", "Madigan 16th ed, Ch 5") }
    if step == 6 { return bfstep(6, "Septum formation and constriction", "Z-ring constricts, pulling inner membrane inward. New peptidoglycan synthesized at septum by FtsW/FtsI. In gram-negatives, outer membrane follows. Amidases (AmiA/B/C) split shared peptidoglycan to separate daughter cells.", "AmiC (amidase)", "P63883", "Madigan 16th ed, Ch 5") }
    if step == 7 { return bfstep(7, "Daughter cell separation", "Two identical daughter cells. Generation time varies: E. coli ~20 min (rich media), M. tuberculosis ~24 hours. Exponential growth: N = N0 x 2^n where n = number of generations.", "Completed", "", "Madigan 16th ed, Ch 5") }
    return bfstep(0, "", "", "", "", "")
}

// =========================================================
// CLINICALLY IMPORTANT BACTERIA
// =========================================================

fn clinical_bacterium(name: String) -> ClinicalBacterium {
    if name == "staph_aureus" { return clinbact("Staphylococcus aureus", "Gram-positive", "Cocci in clusters (grape-like)", "Facultative anaerobe", "Protein A (binds IgG Fc), coagulase (clots plasma), PVL (Panton-Valentine leukocidin), TSST-1 (toxic shock), hemolysins, biofilm", "Skin infections (boils, cellulitis), bacteremia, endocarditis, osteomyelitis, pneumonia, toxic shock syndrome, food poisoning. MRSA = methicillin-resistant.", "MSSA: nafcillin/oxacillin. MRSA: vancomycin, daptomycin, linezolid. CA-MRSA: TMP-SMX, doxycycline.", "Murray 9th ed, Ch 18") }
    if name == "strep_pneumo" { return clinbact("Streptococcus pneumoniae", "Gram-positive", "Diplococci (lancet-shaped pairs)", "Facultative anaerobe", "Polysaccharide capsule (100+ serotypes, antiphagocytic), pneumolysin (pore-forming toxin), IgA protease, autolysin (LytA). Optochin sensitive. Bile soluble.", "Community-acquired pneumonia (number 1 cause), meningitis, otitis media, sinusitis. Leading cause of vaccine-preventable death worldwide.", "Penicillin (if susceptible), ceftriaxone, vancomycin. Vaccines: PCV13 (conjugate), PPSV23 (polysaccharide).", "Murray 9th ed, Ch 19") }
    if name == "ecoli" { return clinbact("Escherichia coli", "Gram-negative", "Rod (bacillus)", "Facultative anaerobe", "Type 1 fimbriae (UTI adhesion), P pili (pyelonephritis). Pathotypes: ETEC (heat-labile/stable toxins, traveler diarrhea), EHEC O157:H7 (Shiga toxin, HUS), EIEC (invasion), EPEC (A/E lesions), UPEC (UTI).", "UTI (most common cause), neonatal meningitis (K1 capsule), traveler diarrhea, hemolytic uremic syndrome, bacteremia, intra-abdominal infections.", "UTI: TMP-SMX, nitrofurantoin, fluoroquinolones. Serious: ceftriaxone, carbapenems. EHEC: supportive only (antibiotics may worsen HUS).", "Murray 9th ed, Ch 27") }
    if name == "pseudomonas" { return clinbact("Pseudomonas aeruginosa", "Gram-negative", "Rod (bacillus)", "Obligate aerobe", "Blue-green pigments (pyocyanin, pyoverdine), type III secretion (ExoU, ExoS), alginate biofilm (CF lungs), endotoxin (LPS), elastase, exotoxin A. Intrinsically resistant to many antibiotics.", "Hospital-acquired pneumonia (VAP), burn wound infections, CF chronic lung infections, UTI, bacteremia, otitis externa (swimmer ear). Opportunistic.", "Anti-pseudomonal: piperacillin-tazobactam, cefepime, ceftazidime, meropenem, ciprofloxacin, tobramycin. Often MDR.", "Murray 9th ed, Ch 28") }
    if name == "mtb" { return clinbact("Mycobacterium tuberculosis", "Acid-fast (neither gram+ nor gram-)", "Rod (bacillus), slow-growing (doubling time 15-24 hours)", "Obligate aerobe", "Mycolic acids (waxy cell wall, drug resistance), cord factor (trehalose dimycolate, granuloma), LAM (lipoarabinomannan, inhibits phagosome-lysosome fusion), ESX-1 secretion system.", "Pulmonary tuberculosis (cough, hemoptysis, night sweats, weight loss). Miliary TB (disseminated). TB meningitis. Latent TB (1/4 world population). Leading infectious disease killer globally.", "RIPE regimen: Rifampin (6 mo) + Isoniazid (6 mo) + Pyrazinamide (2 mo) + Ethambutol (2 mo). MDR-TB: bedaquiline, linezolid. BCG vaccine (variable efficacy).", "Murray 9th ed, Ch 25") }
    if name == "clostridium_diff" { return clinbact("Clostridioides difficile", "Gram-positive", "Rod (bacillus), spore-forming, obligate anaerobe", "Obligate anaerobe", "Toxin A (TcdA, enterotoxin, fluid secretion) and Toxin B (TcdB, cytotoxin, cell rounding/death). Both glucosyltransferases that inactivate Rho GTPases. Spores survive alcohol hand sanitizer.", "Antibiotic-associated diarrhea, pseudomembranous colitis. Leading cause of hospital-acquired diarrhea. Risk: recent antibiotics (clindamycin, fluoroquinolones, cephalosporins), PPI use, elderly.", "Mild: oral vancomycin or fidaxomicin. Severe: oral vancomycin + IV metronidazole. Recurrent: fecal microbiota transplant (FMT), bezlotoxumab (anti-toxin B mAb).", "Murray 9th ed, Ch 33") }
    if name == "neisseria_mening" { return clinbact("Neisseria meningitidis", "Gram-negative", "Diplococci (kidney bean-shaped, intracellular)", "Aerobe", "Polysaccharide capsule (serogroups A, B, C, W, Y), pili (attachment), IgA protease, endotoxin (LOS, lipooligosaccharide, very potent). Complement evasion.", "Bacterial meningitis (petechial rash), meningococcemia (DIC, Waterhouse-Friderichsen syndrome = bilateral adrenal hemorrhage). Outbreaks in close quarters (dorms, military).", "Ceftriaxone or penicillin G. Prophylaxis: ciprofloxacin or rifampin for close contacts. Vaccines: MenACWY (conjugate), MenB (recombinant).", "Murray 9th ed, Ch 24") }
    if name == "helicobacter" { return clinbact("Helicobacter pylori", "Gram-negative", "Curved/spiral rod, highly motile (lophotrichous flagella)", "Microaerophilic", "Urease (neutralizes gastric acid, creates alkaline microenvironment), CagA (oncogene, injected by T4SS, disrupts cell signaling), VacA (vacuolating cytotoxin), BabA (adhesin to Lewis b blood group antigen).", "Chronic gastritis, peptic ulcer disease (duodenal and gastric), gastric adenocarcinoma (WHO Group 1 carcinogen), MALT lymphoma. Infects half of world population.", "Triple therapy: PPI + clarithromycin + amoxicillin (14 days). Bismuth quadruple therapy if clarithromycin-resistant. Test-and-treat for dyspepsia.", "Marshall BJ, Warren JR. Lancet 1:1311-1315, 1984 (Nobel Prize 2005)") }
    return clinbact("", "", "", "", "", "", "", "")
}

// =========================================================
// BACTERIAL MOTILITY
// =========================================================

fn bacterial_motility(motility_type: String) -> BacterialMotility {
    if motility_type == "swimming" { return bmotility("Swimming (flagellar)", "Flagellum", "Rotary motor driven by proton motive force (PMF). MotA/MotB stator channels H+ ions, driving rotor (FliG/FliM/FliN). CCW rotation = run (smooth swimming). CW rotation = tumble (random reorientation). Chemotaxis: CheY-P switches rotation.", "Proton motive force (H+ gradient)", "FliC (flagellin), MotA/MotB (stator)", "Berg HC. Annu Rev Biochem 72:19-54, 2003") }
    if motility_type == "twitching" { return bmotility("Twitching (type IV pili)", "Type IV pilus", "Pilus extends (PilB ATPase polymerizes pilin), attaches to surface, then retracts (PilT ATPase depolymerizes). Retraction pulls cell forward. Jerky movement. Important for biofilm formation and pathogenesis.", "ATP (PilB extension, PilT retraction)", "PilT (retraction ATPase)", "Craig L et al. Nat Rev Microbiol 2:363-378, 2004") }
    if motility_type == "gliding" { return bmotility("Gliding", "No visible appendage (mechanism varies)", "Myxococcus: adventurous gliding uses focal adhesion complexes. Flavobacterium: SprB surface protein moves along cell body (helical rotor model). Mycoplasma: attachment organelle 'inchworming'.", "Proton motive force or ATP (species-dependent)", "SprB (Flavobacterium), AglZ (Myxococcus)", "Nan B, Bhatt S. Microbiol Mol Biol Rev 79:297-321, 2015") }
    if motility_type == "swarming" { return bmotility("Swarming", "Hyperflagellated cells", "Multicellular surface migration. Cells differentiate into elongated, hyperflagellated swarm cells. Requires surfactant production. Characteristic of Proteus mirabilis (bulls-eye colony pattern on agar).", "Proton motive force", "FlhDC (master regulator)", "Kearns DB. Nat Rev Microbiol 8:634-644, 2010") }
    return bmotility("", "", "", "", "", "")
}

// =========================================================
// HORIZONTAL GENE TRANSFER
// =========================================================

fn horizontal_gene_transfer(method: String) -> String {
    if method == "conjugation" { return "F pilus (sex pilus) from F+ donor contacts F- recipient. Pilus retracts, forming mating bridge. Single strand of F plasmid transferred through type IV secretion system (T4SS). Recipient synthesizes complement, becomes F+. Hfr (high frequency recombination): F plasmid integrated into chromosome, transfers chromosomal DNA. Cited: Lederberg J, Tatum EL. Nature 158:558, 1946 (Nobel 1958)." }
    if method == "transformation" { return "Free DNA from environment taken up by competent cell. Natural competence (Streptococcus pneumoniae, Haemophilus influenzae, Neisseria): ComEC channel imports ssDNA. Artificial competence: CaCl2/heat shock or electroporation. Griffith experiment (1928): rough S. pneumoniae + dead smooth = live smooth (the transforming principle = DNA). Cited: Griffith F. J Hyg (Lond) 27:113-159, 1928." }
    if method == "transduction" { return "Bacteriophage-mediated transfer. Generalized transduction: during lytic cycle, phage accidentally packages host DNA instead of phage DNA (P1, P22). Specialized transduction: lysogenic phage excises imprecisely, carries adjacent host genes (lambda phage carries gal/bio). Cited: Zinder ND, Lederberg J. J Bacteriol 64:679-699, 1952." }
    return ""
}

// =========================================================
// ANTIBIOTIC TARGETS IN PROKARYOTES
// =========================================================

fn antibiotic_target(target_site: String) -> String {
    if target_site == "cell_wall" { return "Beta-lactams (penicillins, cephalosporins, carbapenems): bind PBPs (penicillin-binding proteins), block transpeptidation (cross-linking) of peptidoglycan. Vancomycin: binds D-Ala-D-Ala, prevents transglycosylation. Bacitracin: inhibits bactoprenol recycling. Fosfomycin: inhibits MurA. Cycloserine: inhibits D-Ala-D-Ala ligase." }
    if target_site == "protein_synthesis_30S" { return "Aminoglycosides (gentamicin, tobramycin): bind 16S rRNA A-site, cause misreading. Tetracyclines: block aminoacyl-tRNA entry to A-site. Spectinomycin: inhibits translocation." }
    if target_site == "protein_synthesis_50S" { return "Macrolides (azithromycin, erythromycin): bind 23S rRNA, block translocation. Chloramphenicol: inhibits peptidyl transferase. Clindamycin: blocks translocation. Linezolid: blocks 70S initiation complex formation. Quinupristin-dalfopristin: block elongation." }
    if target_site == "dna_replication" { return "Fluoroquinolones (ciprofloxacin, levofloxacin): inhibit DNA gyrase (topoisomerase II) and topoisomerase IV. Prevent supercoiling/decatenation. Metronidazole: reduced to cytotoxic radicals in anaerobes, damages DNA." }
    if target_site == "rna_synthesis" { return "Rifampin: binds bacterial RNA polymerase beta subunit (RpoB), blocks transcription initiation. Resistance: single point mutations in rpoB (rapid resistance, never use alone). Essential for TB treatment." }
    if target_site == "folate_synthesis" { return "Sulfonamides: competitive inhibitor of dihydropteroate synthase (DHPS). Trimethoprim: inhibits dihydrofolate reductase (DHFR). TMP-SMX (Bactrim): synergistic sequential blockade of folate pathway. Humans get folate from diet (no DHPS), so selective toxicity." }
    if target_site == "cell_membrane" { return "Polymyxins (colistin): bind LPS, disrupt outer membrane (gram-negative only). Daptomycin: inserts into gram-positive membrane, causes depolarization. Last-resort drugs for MDR infections." }
    return ""
}

// =========================================================
// OXYGEN REQUIREMENTS
// =========================================================

fn oxygen_requirement(category: String) -> String {
    if category == "obligate_aerobe" { return "Requires O2. Uses aerobic respiration (O2 as terminal electron acceptor). Has superoxide dismutase (SOD) and catalase. Examples: Pseudomonas aeruginosa, Mycobacterium tuberculosis, Nocardia." }
    if category == "obligate_anaerobe" { return "Killed by O2. Lacks SOD and catalase (or has minimal). Cannot detoxify reactive oxygen species. Uses fermentation or anaerobic respiration (NO3-, SO4 2-, CO2 as terminal electron acceptors). Examples: Clostridium, Bacteroides, Actinomyces." }
    if category == "facultative_anaerobe" { return "Grows with or without O2. Prefers aerobic respiration (more ATP) but switches to fermentation/anaerobic respiration when O2 absent. Has SOD and catalase. Most clinically important bacteria. Examples: E. coli, Staphylococcus, Streptococcus." }
    if category == "microaerophile" { return "Requires O2 but at reduced levels (2-10%, not atmospheric 21%). Has limited SOD. Examples: Helicobacter pylori, Campylobacter jejuni, Borrelia burgdorferi." }
    if category == "aerotolerant_anaerobe" { return "Anaerobic metabolism only (fermentation) but tolerates O2 presence. Has SOD but no catalase. Does not use O2 for energy. Examples: Lactobacillus, Streptococcus (some species)." }
    return ""
}

// =========================================================
// QUICK ACCESS
// =========================================================

fn prokaryote_structure_count() -> Int {
    return 13
}

fn gram_stain_type_count() -> Int {
    return 4
}

fn binary_fission_step_count() -> Int {
    return 7
}

fn clinical_bacterium_count() -> Int {
    return 8
}

fn bacterial_motility_type_count() -> Int {
    return 4
}

fn hgt_method_count() -> Int {
    return 3
}

fn antibiotic_target_count() -> Int {
    return 7
}

fn ecoli_genome_size() -> Int {
    // E. coli K-12: 4,641,652 bp
    return 4641652
}

fn ecoli_generation_time_minutes() -> Int {
    // In rich media at 37C
    return 20
}
