# -*- coding: utf-8 -*-
"""Round 234: batch add 5 more Biology PhD (Caltech Bio / Yale MCDB / UCLA MBIDP / Cornell MBG / UPenn Biology).
Key finding: Top-tier Biology PhD programs continue to move to GRE-free. Caltech Biology is 'strongly recommended but
not required'; Yale MCDB (BBS) 'not accepted'; UCLA MBIDP 'not required' (2027-28); Cornell MBG 'no longer required';
UPenn SAS Biology 'does not require or accept'. Deadlines: Dec 1 (Caltech/Yale/UCLA/Cornell); Dec 8 (UPenn).
All five admit fall-only, full-time, and provide full funding.
"""
import os, re

BASE = os.path.dirname(os.path.abspath(__file__))
DET = os.path.join(BASE, "details")
os.makedirs(DET, exist_ok=True)

PROGRAMS = [
    {
        "id": "caltech-bio-phd",
        "s": "caltech",
        "n": "生物学博士",
        "en": "PhD in Biology (California Institute of Technology Division of Biology and Biological Engineering, BBE; doctoral only, no master's)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; rotations in first year; thesis mentor identified by end of G1; no terminal master's",
        "ddl": "Fall 2027: December 1, 2026. Zoom interviews December 11-12, 2026; in-person interviews January 29-30, 2027; decisions early-to-mid February 2027.",
        "lang": "TOEFL iBT / IELTS Academic / PTE Academic / Cambridge C1-C2 accepted for non-native English speakers; no Caltech-wide minimum published; holistic review.",
        "test": {"cls": 'GRE GENERAL TEST STRONGLY RECOMMENDED (BBE Biology: "The Graduate Record Examination (GRE) general test is strongly recommended. You are also encouraged, but not required, to take a subject test relevant to your research interests."); scores not required but will be considered if submitted. Successful candidates typically have top-5% GPA, strong research record, and 3 LOR.'},
        "tui": "Full funding for admitted PhD students through Caltech (tuition + stipend + health insurance) for 5+ years; applicants automatically considered for fellowship support; no separate application.",
        "url": "details/caltech-bio-phd.html",
    },
    {
        "id": "yale-mcdb-phd",
        "s": "yale",
        "n": "分子细胞与发育生物学博士",
        "en": "PhD in Molecular, Cellular, and Developmental Biology (Yale Graduate School of Arts and Sciences; part of Biological & Biomedical Sciences BBS consortium, MCGD track)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; BBS first-year rotation structure across 12 PhD programs; thesis mentor declared at end of G1; no terminal master's",
        "ddl": "Fall 2027: December 1, 2026, 11:59 PM ET. Interviews January/February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT minimum 100 (paper 600 / CBT 250) or IELTS Academic minimum 8.0; ETS Yale institution code 3987; English-medium undergraduate (3+ years in residence) exempts.",
        "test": {"cls": 'GRE NOT ACCEPTED (Yale BBS: "We do not require the Graduate Record Examination (GRE) General Test. If you submit GRE scores we will not include them in the review of your application."). No minimum GPA; recommended coursework: biology, chemistry through organic chemistry, physics, calculus.'},
        "tui": "Full funding for admitted PhD students through Yale Graduate School (tuition + stipend + health insurance) for 5+ years; BBS consortium guarantees support contingent on satisfactory progress.",
        "url": "details/yale-mcdb-phd.html",
    },
    {
        "id": "ucla-molbio-phd",
        "s": "ucla",
        "n": "分子生物学博士",
        "en": "PhD in Molecular Biology (UCLA Molecular Biology Institute / Graduate Programs in Bioscience GPB; home areas: BBSB, CDB, GREAT, IMMP via ACCESS)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; GPB/ACCESS rotation structure across 11 home areas; thesis mentor identified at end of G1; MS offered only under exceptional circumstances",
        "ddl": "Fall 2027: December 1, 2026 (GPB/ACCESS common deadline). Application fee $120 US / $140 international. Interviews January; decisions March.",
        "lang": "TOEFL iBT minimum 87 (UCLA Graduate Division minimum) or IELTS Academic; ETS UCLA institution code 4837; English-medium undergraduate degree exempts.",
        "test": {"cls": "GRE NOT REQUIRED (UCLA GPB: 'As of September 2020, all Home Areas have decided to make the GRE General Exam optional. The Molecular Biology Institute MBIDP page lists 'Not required' for 2027-28). Minimum undergraduate GPA 3.00 (UCLA Graduate Division). Required: SOP, Personal History Statement, 3 LOR."},
        "tui": "Full funding for admitted PhD students through UCLA Graduate Programs in Bioscience (tuition + stipend + health insurance) for 5+ years; support via research/teaching assistantships and fellowships.",
        "url": "details/ucla-molbio-phd.html",
    },
    {
        "id": "cornell-mbg-phd",
        "s": "cornell",
        "n": "分子生物学与遗传学博士",
        "en": "PhD in Molecular Biology and Genetics (Cornell University CALS Department of Molecular Biology and Genetics; fields: Biochemistry, Molecular & Cell Biology BMCB / Genetics, Genomics & Development GGD)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission (no spring); rotations in BMCB/GGD; general exam in year 2; Biophysics field currently restricted to NIH T32 eligible students only",
        "ddl": "Fall 2027: December 1, 2026. Interviews January/February; decisions March; April 15 reply. No spring admission.",
        "lang": "TOEFL iBT / IELTS Academic / Duolingo DET accepted; Cornell Graduate School minimum iBT 90 (higher for some fields); English-medium undergraduate exempts.",
        "test": {"cls": "GRE NOT REQUIRED (Cornell BBS/CALS MBG: 'GRE test scores are no longer required for application to this program.'). Holistic review: research experience, SOP, 3 LOR, CV. No minimum GPA cutoff. Recommended: biology/chemistry major."},
        "tui": "Full funding for admitted PhD students through Cornell Graduate School and MBG department (tuition + stipend + health insurance) for 5 years; support via research assistantships, teaching assistantships, and fellowships.",
        "url": "details/cornell-mbg-phd.html",
    },
    {
        "id": "upenn-bio-phd",
        "s": "upenn",
        "n": "生物学博士（文理学院）",
        "en": "PhD in Biology (University of Pennsylvania School of Arts and Sciences Biology Graduate Group; separate from Perelman School of Medicine BGS/CAMB)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; rotations in first year; thesis mentor declared by end of G1; joint opportunities with Perelman BGS and Wistar Institute",
        "ddl": "Fall 2027: December 8, 2026, 11:59 PM ET (SAS Biology Graduate Group). Application opens October 1, 2026. Interviews January; decisions March.",
        "lang": "TOEFL iBT / IELTS Academic required for non-native English speakers; ETS UPenn institution code 2926 (Dept code 74 for Biology); English-medium undergraduate exempts.",
        "test": {"cls": 'GRE NOT REQUIRED / NOT ACCEPTED (UPenn Biology Graduate Group: "The Biology Graduate Group does not require or accept GRE scores."); 3 letters of recommendation, at least one from a scientist with whom the applicant has worked.'},
        "tui": "Full funding for admitted PhD students through University of Pennsylvania School of Arts and Sciences (tuition + stipend + health insurance) for 5+ years; support via Graduate Fellowships, research/teaching assistantships.",
        "url": "details/upenn-bio-phd.html",
    },
]

DETAIL_TEMPLATE = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{school} - {en}</title>
<style>
body{{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;max-width:960px;margin:24px auto;padding:0 20px;color:#222;line-height:1.6}}
h1{{font-size:24px;border-bottom:2px solid #1a73e8;padding-bottom:8px}}
h2{{font-size:18px;color:#1a73e8;margin-top:24px}}
.card{{background:#f8f9fa;border-left:4px solid #1a73e8;padding:12px 16px;margin:12px 0;border-radius:4px}}
.meta{{display:grid;grid-template-columns:120px 1fr;gap:6px 12px;font-size:14px}}
.meta b{{color:#555}}
ul{{margin:6px 0;padding-left:20px}}
.note{{background:#fff3cd;border-left-color:#ffc107;padding:10px 14px;margin-top:16px;font-size:13px}}
a{{color:#1a73e8}}
</style>
</head>
<body>
<h1>{school} - {en}</h1>
<div class="card">
<div class="meta">
<b>Degree</b><span>{deg}</span>
<b>Level</b><span>Research Doctorate (PhD)</span>
<b>STEM</b><span>{stem_label}</span>
<b>Duration</b><span>{dur}</span>
<b>Deadline</b><span>{ddl}</span>
<b>Language</b><span>{lang}</span>
<b>Standardized</b><span>{test_cls}</span>
<b>Funding</b><span>{tui}</span>
</div>
</div>

<h2>Program Overview</h2>
<div class="card">
{overview}
</div>

<h2>Admissions Requirements</h2>
<div class="card">
{requirements}
</div>

<h2>Research Areas</h2>
<div class="card">
{research}
</div>

<h2>Official Source</h2>
<div class="card">
{source}
</div>

<div class="note">
<strong>Note:</strong> This is a research-oriented PhD in biological sciences / molecular &amp; cell biology at a top-30 U.S. university. Admitted PhD students receive full financial support (tuition + stipend + insurance). Admission statistics shown are distribution ranges, not minimum thresholds. Course/credit details pending department bulletin verification. All five programs are STEM-designated per NSF GRFP field of study (Life Sciences) / CIP codes.
</div>
</body>
</html>
"""

PAGES = {
    "caltech-bio-phd": {
        "school": "Caltech Division of Biology and Biological Engineering (BBE)",
        "en": "PhD in Biology",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; doctoral only (no master's); rotations; thesis mentor end of G1",
        "ddl": "Fall 2027: December 1, 2026. Zoom interviews Dec 11-12, 2026; in-person interviews Jan 29-30, 2027; decisions early-to-mid Feb 2027.",
        "lang": "TOEFL iBT / IELTS Academic / PTE / Cambridge C1-C2 accepted; no Caltech-wide minimum; holistic.",
        "test_cls": "GRE GENERAL TEST STRONGLY RECOMMENDED (BBE Biology: 'strongly recommended; subject test encouraged but not required'). Successful candidates typically top-5% GPA, strong research, 3 LOR.",
        "tui": "Full funding through Caltech (tuition + stipend + health insurance) for 5+ years; automatic fellowship consideration.",
        "overview": "The Caltech Biology PhD is offered through the Division of Biology and Biological Engineering (BBE), one of six academic divisions at Caltech. The program trains students exclusively for the degree of Doctor of Philosophy; students are not admitted to study for the master's degree. BBE encompasses five options: Biology (BIO), Biochemistry and Molecular Biophysics (BMB), Bioengineering (BE), Computational and Neural Systems (CNS), and Neurobiology (NB). Students apply to a single option but may rotate across BBE faculty labs. The program also offers joint MD/PhD programs with UCLA and USC.",
        "requirements": "<ul><li>Bachelor's degree or equivalent (prior PhD not considered for second PhD)</li><li>GRE General Test strongly recommended (not required); subject test encouraged but optional</li><li>TOEFL iBT / IELTS Academic / PTE / Cambridge C1-C2 (non-native English)</li><li>Caltech Graduate Office online application (gradoffice.caltech.edu/admissions)</li><li>Statement of Purpose</li><li>3 letters of recommendation</li><li>CV/resume</li><li>Transcripts from each college/university attended</li><li>December 1, 2026 deadline</li><li>Fall entry only; full-time residential</li><li>Interviews by invitation (Zoom Dec 11-12; in-person Jan 29-30)</li></ul>",
        "research": "<ul><li>Molecular and cellular biology</li><li>Biochemistry and structural biology</li><li>Genetics, genomics, and developmental biology</li><li>Neurobiology and behavior</li><li>Biophysics and computational biology</li><li>Ecology and evolutionary biology</li><li>Joint MD/PhD with UCLA and USC</li><li>Cross-disciplinary work with Caltech EAS, HSS, JPL, and the Broad Institute</li></ul>",
        "source": '<a href="https://www.bbe.caltech.edu/academics/biology/graduate-admissions" target="_blank">Caltech BBE Biology Graduate Admissions (Dec 1; Zoom interviews Dec 11-12; in-person Jan 29-30; GRE strongly recommended)</a> | <a href="https://www.bbe.caltech.edu/academics/applying-to-caltech-2026-2027" target="_blank">Caltech BBE Applying 2026-27 (BBE options: BMB, BE, BIO, CNS, NB)</a> | <a href="https://catalog.caltech.edu/current/information-for-graduate-students/graduate-policies-and-procedures/admission-to-graduate-standing/" target="_blank">Caltech Catalog: Admission to Graduate Standing (Nov 15-Dec 15 window; automatic fellowship consideration)</a>',
    },
    "yale-mcdb-phd": {
        "school": "Yale Graduate School of Arts and Sciences",
        "en": "PhD in Molecular, Cellular, and Developmental Biology (BBS, MCGD track)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; BBS consortium first-year rotations across 12 PhD programs; thesis mentor end of G1",
        "ddl": "Fall 2027: December 1, 2026, 11:59 PM ET. Interviews January/February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT 100 minimum (paper 600/CBT 250) or IELTS 8.0; ETS Yale code 3987; English-medium undergraduate 3+ years exempts.",
        "test_cls": "GRE NOT ACCEPTED (Yale BBS: 'If you submit GRE scores we will not include them in the review.'). No minimum GPA; recommended: bio, chem through o-chem, physics, calculus.",
        "tui": "Full funding through Yale Graduate School (tuition + stipend + health insurance) for 5+ years via BBS consortium guarantee.",
        "overview": "The Yale PhD in Molecular, Cellular, and Developmental Biology (MCDB) is part of the Combined Program in the Biological and Biomedical Sciences (BBS), which serves as the admissions gateway and first-year academic home for 12 PhD programs at Yale. MCDB students apply through BBS and select the Molecular Cell Biology, Genetics & Development (MCGD) track. The 12 BBS PhD programs include Cell Biology, Cellular and Molecular Physiology, Computational Biology and Biomedical Informatics, Experimental Pathology, Genetics, Immunobiology, Interdepartmental Neuroscience, Microbiology, Molecular Biophysics and Biochemistry, MCDB, Pharmacology, and Program in Translational Biomedicine.",
        "requirements": "<ul><li>Bachelor's degree (any major; no minimum GPA)</li><li>Recommended coursework: biology, chemistry through organic chemistry, physics, calculus</li><li>GRE NOT accepted (scores not reviewed even if submitted)</li><li>TOEFL iBT 100 minimum (paper 600/CBT 250) or IELTS Academic 8.0; ETS code 3987; English-medium undergraduate 3+ years exempts</li><li>Yale Graduate School online application (select BBS, then MCGD track)</li><li>Statement of Purpose</li><li>3 letters of recommendation</li><li>Transcripts (unofficial at application)</li><li>CV/resume</li><li>December 1, 2026, 11:59 PM ET deadline</li><li>Fall entry only; full-time residential</li><li>No specific LOR deadline (submitted promptly after application closes)</li></ul>",
        "research": "<ul><li>Molecular and cell biology</li><li>Developmental biology and stem cells</li><li>Genetics, genomics, and epigenetics</li><li>Biochemistry and structural biology (via MCGD/BBS cross-tracks)</li><li>Microbiology and immunology</li><li>Neurobiology and behavior</li><li>Quantitative biology and biophysics</li><li>Cross-disciplinary work with Yale School of Medicine, Yale Cancer Center, and Yale Stem Cell Center</li></ul>",
        "source": '<a href="https://gsas.yale.edu/programs-of-study/molecular-cellular-developmental-biology" target="_blank">Yale GSAS: MCDB (Dec 1 11:59pm ET; GRE not accepted; TOEFL 100/IELTS 8.0; BBS MCGD track)</a> | <a href="https://gsas.yale.edu/programs-of-study/biological-biomedical-sciences-bbs" target="_blank">Yale BBS: 12 PhD programs, common gateway (Dec 1; GRE not accepted; TOEFL post-Jan 2026 sub-score 5.5/IELTS 8.0)</a> | <a href="https://gsas.yale.edu/admissions/phdmasters-application-process/dates-deadlines" target="_blank">Yale GSAS Dates & Deadlines (Dec 1, 2026: BBS, Chemistry, EEB, Econ; Dec 15: CS, ECE, Film, Germanic, Law)</a>',
    },
    "ucla-molbio-phd": {
        "school": "UCLA Molecular Biology Institute / Graduate Programs in Bioscience (GPB)",
        "en": "PhD in Molecular Biology (MBIDP via ACCESS)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; GPB/ACCESS rotations across 11 home areas; MS offered only under exceptional circumstances",
        "ddl": "Fall 2027: December 1, 2026 (GPB/ACCESS common deadline). Fee $120 US / $140 international. Interviews January; decisions March.",
        "lang": "TOEFL iBT 87 minimum (UCLA Graduate Division) or IELTS Academic; ETS UCLA code 4837; English-medium undergraduate exempts.",
        "test_cls": "GRE NOT REQUIRED (UCLA GPB: 'As of September 2020, all Home Areas have decided to make the GRE General Exam optional.' MBIDP page lists 'Not required' for 2027-28). Min GPA 3.0. Required: SOP, Personal History Statement, 3 LOR.",
        "tui": "Full funding through UCLA GPB (tuition + stipend + health insurance) for 5+ years via TA/RA/fellowship support.",
        "overview": "The UCLA PhD in Molecular Biology is offered through the Molecular Biology Institute (MBI) as part of the Graduate Programs in Bioscience (GPB). Applicants apply via UCLA ACCESS to Programs in the Molecular and Cellular Life Sciences and select one of four MBIDP home areas: Biochemistry, Biophysics, and Structural Biology (BBSB); Cell and Developmental Biology (CDB); Gene Regulation, Epigenomics and Transcriptomics (GREAT); or Immunity, Microbes and Molecular Pathogenesis (IMMP). The GPB umbrella includes 11 home areas. Medical students may apply via MSTP (MD/PhD) or STAR (MD seeking PhD); direct PhD applicants must secure a faculty sponsor in advance under extraordinary circumstances.",
        "requirements": "<ul><li>Bachelor's degree from accredited institution; minimum undergraduate GPA 3.00</li><li>GRE General Test NOT required (optional self-submission since September 2020)</li><li>TOEFL iBT 87 minimum or IELTS Academic (non-native English); ETS code 4837; English-medium undergraduate exempts</li><li>UCLA Graduate Division online application (select GPB/ACCESS, then MBIDP home area)</li><li>Statement of Purpose</li><li>Personal History Statement</li><li>3 letters of recommendation</li><li>Transcripts (unofficial at application)</li><li>CV/resume</li><li>Application fee $120 (US) / $140 (international; fee waivers available)</li><li>December 1, 2026 deadline</li><li>Fall entry only; full-time residential</li><li>MD/PhD via MSTP; MD seeking PhD via STAR (requires pre-identified dissertation supervisor)</li></ul>",
        "research": "<ul><li>Biochemistry, biophysics, and structural biology (BBSB)</li><li>Cell and developmental biology (CDB)</li><li>Gene regulation, epigenomics, and transcriptomics (GREAT)</li><li>Immunity, microbes, and molecular pathogenesis (IMMP)</li><li>Molecular biology and genetics</li><li>Cross-disciplinary work with UCLA Health, David Geffen School of Medicine, and California NanoSystems Institute</li><li>MSTP/STAR joint MD/PhD options</li></ul>",
        "source": '<a href="https://grad.ucla.edu/requirements/?app=admission&major=0573" target="_blank">UCLA Graduate Programs: Molecular Biology 2027-28 (Dec 1, 2026; Fall-only; GRE not required; 3 LOR; MSTP/STAR options)</a> | <a href="https://grad.ucla.edu/gasaa/deptinfo/deptinfo.asp?academicyear=20262027&code=0644" target="_blank">UCLA MCDB Deptinfo 2026-27 (Dec 1; GRE not required; 3 LOR; STEM upper-division coursework)</a> | <a href="https://grad.ucla.edu/graduate-program-requirements/program-requirements-for-molecular-biology/" target="_blank">UCLA Program Requirements for Molecular Biology (PhD only; Fall; MBIDP joint student/mentor application; direct admission requires pre-identified faculty sponsor)</a>',
    },
    "cornell-mbg-phd": {
        "school": "Cornell University CALS Department of Molecular Biology and Genetics",
        "en": "PhD in Molecular Biology and Genetics (BMCB / GGD fields)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only (no spring); BMCB/GGD fields; rotations; general exam year 2; Biophysics field restricted to NIH T32 eligible students",
        "ddl": "Fall 2027: December 1, 2026. Interviews January/February; decisions March; April 15 reply. No spring admission.",
        "lang": "TOEFL iBT 90 minimum (Cornell Graduate School) or IELTS Academic / Duolingo DET; English-medium undergraduate exempts.",
        "test_cls": "GRE NOT REQUIRED (Cornell BBS/CALS MBG: 'GRE test scores are no longer required for application to this program.'). Holistic review: research experience, SOP, 3 LOR, CV. No GPA cutoff. Recommended: biology/chemistry major.",
        "tui": "Full funding through Cornell Graduate School and MBG (tuition + stipend + health insurance) for 5 years via RA/TA/fellowship.",
        "overview": "The Cornell PhD in Molecular Biology and Genetics is housed in the College of Agriculture and Life Sciences (CALS) and administered through three Graduate Fields: Biochemistry, Molecular and Cell Biology (BMCB); Genetics, Genomics and Development (GGD); and Biophysics. The Biophysics field is currently only accepting applications from candidates who are NIH T32 training grant eligible (US citizen or permanent resident). The BMCB and GGD fields welcome both international and domestic applicants. The MBG department was formed in 2000 by merging the Section of Genetics and Development (G&D) with the Section of Biochemistry, Molecular and Cell Biology (BMCB).",
        "requirements": "<ul><li>Bachelor's degree (typically biology or chemistry major; no GPA cutoff)</li><li>GRE NOT required (no longer reviewed for application)</li><li>TOEFL iBT 90 minimum or IELTS Academic / Duolingo DET (non-native English); English-medium undergraduate exempts</li><li>Cornell Graduate School online application (Apply-Now)</li><li>Statement of purpose (academic + personal)</li><li>3 letters of recommendation (submitted within 48 hours after deadline acceptable)</li><li>CV/resume</li><li>Unofficial transcripts from all colleges attended</li><li>December 1, 2026 deadline</li><li>Fall entry only; no spring admission</li><li>Biophysics field: restricted to NIH T32 eligible (US citizen/permanent resident)</li></ul>",
        "research": "<ul><li>Biochemistry and structural biology (BMCB)</li><li>Molecular and cell biology (BMCB)</li><li>Genetics, genomics, and development (GGD)</li><li>Biophysics (T32 eligible only)</li><li>Bioinformatics and computational biology</li><li>Microbiology and disease mechanisms</li><li>Cross-disciplinary work with Cornell Weill, Cornell Tech, and Boyce Thompson Institute</li></ul>",
        "source": '<a href="https://cals.cornell.edu/molecular-biology-genetics/academics/graduate/admissions" target="_blank">Cornell CALS MBG Graduate Admissions (Dec 1 fall deadline; no spring; BMCB/GGD welcome international; Biophysics T32-only)</a> | <a href="https://gradschool.cornell.edu/academic-progress/degrees-fields/cugradfos/" target="_blank">Cornell Fields of Study: Biochemistry, Biophysics, Genetics, Molecular & Cell Biology all revised to Dec 1, 2026</a> | <a href="https://courses.cornell.edu/programs/biomedical-sciences-phd/" target="_blank">Cornell Biomedical Sciences PhD (Dec 1; GRE no longer required; 2-4 LOR; SOP; optional 2-3 paragraph writing sample)</a>',
    },
    "upenn-bio-phd": {
        "school": "University of Pennsylvania School of Arts and Sciences",
        "en": "PhD in Biology (Biology Graduate Group)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; rotations; thesis mentor end of G1; joint opportunities with Perelman BGS and Wistar Institute",
        "ddl": "Fall 2027: December 8, 2026, 11:59 PM ET (SAS Biology Graduate Group). Application opens October 1, 2026. Interviews January; decisions March.",
        "lang": "TOEFL iBT / IELTS Academic required; ETS UPenn code 2926 (Dept code 74 for Biology); English-medium undergraduate exempts.",
        "test_cls": "GRE NOT REQUIRED / NOT ACCEPTED (UPenn Biology Graduate Group: 'The Biology Graduate Group does not require or accept GRE scores.'). 3 LOR, at least one from a scientist with whom applicant has worked.",
        "tui": "Full funding through UPenn SAS (tuition + stipend + health insurance) for 5+ years via Graduate Fellowships/RA/TA.",
        "overview": "The University of Pennsylvania PhD in Biology is offered through the School of Arts and Sciences (SAS) Biology Graduate Group, distinct from the Perelman School of Medicine's Biomedical Graduate Studies (BGS) umbrella (which includes CAMB, Immunology, Biochemistry/Biophysics/Chemical Biology, and other medical-school graduate groups). The SAS Biology Graduate Group offers interdisciplinary research across molecular biology, cell biology, genetics, ecology, evolution, and behavior. Joint opportunities exist with the Perelman School of Medicine, the Wistar Institute, and the Monell Chemical Senses Center. Note: Perelman BGS programs (CAMB, etc.) share the December 1 deadline, but SAS Biology is on the December 8 deadline.",
        "requirements": "<ul><li>Bachelor's degree (any major; diverse backgrounds encouraged)</li><li>GRE NOT required / NOT accepted (scores not reviewed even if submitted)</li><li>TOEFL iBT / IELTS Academic (non-native English); ETS code 2926, Dept code 74; TSE also accepted; English-medium undergraduate exempts</li><li>UPenn SAS Slate online application</li><li>Statement of Purpose</li><li>3 letters of recommendation (at least one from a scientist with whom the applicant has worked)</li><li>Transcripts (unofficial at application; official only from admitted students)</li><li>CV/resume</li><li>December 8, 2026, 11:59 PM ET deadline</li><li>Fall entry only; full-time residential</li><li>Joint research opportunities with Perelman BGS, Wistar Institute, and Monell Center</li></ul>",
        "research": "<ul><li>Molecular and cellular biology</li><li>Genetics, genomics, and epigenetics</li><li>Ecology and evolutionary biology</li><li>Animal behavior and neurobiology</li><li>Developmental biology</li><li>Computational biology and bioinformatics</li><li>Joint work with Perelman School of Medicine, Wistar Institute, and Monell Chemical Senses Center</li></ul>",
        "source": '<a href="http://www.shturl.cc/8427e95f2680854549d847fb56a286ac" target="_blank">UPenn SAS Application Information (all PhD applications close Dec 8, 2026, 11:59pm ET; Biology listed in Admissions Calendar)</a> | <a href="http://www.shturl.cc/ce9bb330cdbe2040aeb0dad0b03c184d" target="_blank">UPenn Biology Graduate Group Application Process (GRE not required or accepted; 3 LOR, one from a scientist; TOEFL code 2926 Dept 74)</a> | <a href="https://www.cceb.upenn.edu/bgs/admissions-faqs.html" target="_blank">UPenn BGS FAQ (reference for Perelman medical school deadline Dec 1; SAS Biology is separate on Dec 8)</a>',
    },
}

# Write detail pages
for p in PROGRAMS:
    key = p["id"]
    d = PAGES[key]
    html = DETAIL_TEMPLATE.format(
        school=d["school"], en=d["en"], deg=d["deg"], stem_label=d["stem_label"],
        dur=d["dur"], ddl=d["ddl"], lang=d["lang"], test_cls=d["test_cls"], tui=d["tui"],
        overview=d["overview"], requirements=d["requirements"],
        research=d["research"], source=d["source"],
    )
    path = os.path.join(DET, key + ".html")
    with open(path, "w", encoding="utf-8") as f:
        f.write(html)
    print(f"Wrote: {key}.html")

# Append PROGRAMS
idx_path = os.path.join(BASE, "index_main.html")
with open(idx_path, "r", encoding="utf-8") as f:
    html = f.read()

def build_entry(p):
    return ('{{id:"{id}",s:"{s}",n:"{n}",en:"{en}",deg:"{deg}",lvl:"{lvl}",stem:{stem},'
            'dur:"{dur}",ddl:"{ddl}",lang:"{lang}",test:{{cls:"{test_cls}"}},'
            'tui:"{tui}",url:"{url}"}}').format(
        id=p["id"], s=p["s"], n=p["n"], en=p["en"], deg=p["deg"], lvl=p["lvl"],
        stem=p["stem"], dur=p["dur"], ddl=p["ddl"], lang=p["lang"],
        test_cls=p["test"]["cls"].replace('"', "'"),
        tui=p["tui"].replace('"', "'"), url=p["url"],
    )

new_entries = ",\n".join(build_entry(p) for p in PROGRAMS)

m = re.search(r'const\s+PROGRAMS\s*=\s*\[', html)
start = m.end()
depth = 1
i = start
while i < len(html) and depth > 0:
    c = html[i]
    if c == '[': depth += 1
    elif c == ']': depth -= 1
    i += 1
insert_pos = i - 1
prefix = html[:insert_pos].rstrip()
suffix = html[insert_pos:]
if prefix.endswith('{'):
    new_block = prefix + "\n" + new_entries + "\n" + suffix
else:
    new_block = prefix + ",\n" + new_entries + "\n" + suffix

# Append VD on new_block (re-locate to avoid offset)
vd_entries = ",\n".join(f'"{p["url"]}"' for p in PROGRAMS)
m2 = re.search(r'VERIFIED_DETAILS\s*=\s*new\s+Set\s*\(\s*\[', new_block)
vstart = m2.end()
vdepth = 1
j = vstart
while j < len(new_block) and vdepth > 0:
    c = new_block[j]
    if c == '[': vdepth += 1
    elif c == ']': vdepth -= 1
    j += 1
vinsert_pos = j - 1
vprefix = new_block[:vinsert_pos].rstrip()
vsuffix = new_block[vinsert_pos:]
if vprefix.endswith(','):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
elif vprefix.endswith('['):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
else:
    new_block = vprefix + ",\n" + vd_entries + "\n" + vsuffix

with open(idx_path, "w", encoding="utf-8") as f:
    f.write(new_block)

print(f"Appended {len(PROGRAMS)} PROGRAMS entries and {len(PROGRAMS)} VD entries")
print(f"Done. File size: {os.path.getsize(idx_path)}")
