# -*- coding: utf-8 -*-
"""Round 237: batch add 5 more Biology PhD (Rice BCB / Georgetown Biology / Notre Dame Bio Sci / UNC Biology / UVA Biology).
Key finding: All five are GRE-free / optional / not required. Deadlines: Rice priority Dec 1 final Dec 31;
Georgetown/Notre/UVA = Dec 1; UNC = Nov 17 (earlier than typical Dec 1).
Rice BCB stipend $39,500/year. UVA Biology requires only 2 LOR (not 3).
UNC Biology EEOB/QBio track requires contacting prospective faculty BEFORE applying.
"""
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": "rice-bcb-phd",
        "s": "rice",
        "n": "生物化学与细胞生物学博士",
        "en": "PhD in Biochemistry and Cell Biology (Rice University Wiess School of Natural Sciences, Department of BioSciences; BCB track)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; minimum 6 semesters residency required by GA; 3 research rotations before selecting thesis advisor in second semester",
        "ddl": "Fall 2027: Priority Deadline December 1, 2026 (early evaluation); Final Deadline December 31, 2026 (international and domestic). Application opens September 1, 2026.",
        "lang": "TOEFL iBT minimum 90 (paper 600, computer 250) for non-native English; ETS Rice code 6609, dept code 0202 (BCB); IELTS also accepted; English-medium undergraduate exempts.",
        "test": {"cls": "GRE OPTIONAL (Rice BCB: 'Submission of GRE scores is optional for applicants to the BCB program. Scores submitted will be reviewed holistically; applicants who do not submit scores will not be at a disadvantage.' Subject tests not required. 3-4 LOR; Personal Statement; CV; unofficial transcripts; GPA 3.0/4.0 minimum)."},
        "tui": "Full funding for admitted PhD students through Rice BioSciences (annual stipend $39,500 + full tuition + health insurance); application covers both admission and research stipend (no separate financial aid application). Application fee $85 (waived for all domestic applicants).",
        "url": "details/rice-bcb-phd.html",
    },
    {
        "id": "geo-biology-phd",
        "s": "geo",
        "n": "生物科学博士",
        "en": "PhD in Biology (Georgetown University Graduate School of Arts & Sciences, Department of Biology; research in biochemistry/cell/molecular biology, ecology/evolution/behavior, parasitology, developmental biology and neurosciences)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall admission primary; 16 credit hours of coursework; qualifying and comprehensive examinations; dissertation defense; 1-3 lab rotations in first year (MCB foci: Microbes & Infectious Disease and Neurodevelopment)",
        "ddl": "Fall 2027: December 1, 2026 (11:59 PM EST). Applications accepted year-round for spring/summer but contingent on available funding; interview weekend February; decisions February/March; April 15 reply.",
        "lang": "TOEFL iBT minimum 80 (old scale) / 4.0 (new scale after Jan 21, 2026) or IELTS Academic minimum 7.0; ETS Georgetown code 5244 (GSAS); English-medium undergraduate exempts; test must be taken by Dec 15 (score may arrive after deadline).",
        "test": {"cls": "GRE OPTIONAL / NOT REQUIRED (Georgetown Biology does not list GRE as required; BMCB track states 'GRE/MCAT optional, but recommended for Ph.D. applicants'; scores not required for Biology Department PhD). 3 LOR; Academic Statement of Purpose; optional Statement on Diversity; CV/resume; transcripts; WES evaluation highly encouraged for international applicants."},
        "tui": "Full funding for admitted PhD students through Georgetown Graduate School (tuition + stipend + health insurance) via research/teaching assistantships and fellowships; PI fit is critical - applicants strongly encouraged to email prospective PIs before submitting application.",
        "url": "details/geo-biology-phd.html",
    },
    {
        "id": "notre-biosci-phd",
        "s": "notre",
        "n": "生物科学博士",
        "en": "PhD in Biological Sciences (University of Notre Dame College of Science, Department of Biological Sciences; research in biomedical sciences, global health, ecology/evolution & the environment [EEE])",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; minimum 2 years residency; 159 graduate students, 63 faculty, 30+ countries represented; interdisciplinary with Indiana University School of Medicine at South Bend",
        "ddl": "Fall 2027: December 1, 2026. Suggest submitting by mid-November to ensure all materials (including LORs) arrive by deadline; no spring admission.",
        "lang": "TOEFL iBT / IELTS Academic / Duolingo English Test required for non-native English speakers; ETS Notre Dame code 1841 (no dept code); English-medium undergraduate exempts.",
        "test": {"cls": "GRE GENERAL OPTIONAL (Notre Dame Biological Sciences: 'GRE General Test optional'. Subject test not required. Scores older than 5 years not accepted. 3 LOR; Statement of Intent (1-3 double-spaced pages); CV; unofficial transcripts from each post-secondary institution; official transcript showing bachelor's conferral due upon enrollment)."},
        "tui": "Full funding for admitted PhD students through Notre Dame Graduate School (tuition + stipend + health insurance) via research/teaching assistantships and fellowships; April 15 CGS resolution applies.",
        "url": "details/notre-biosci-phd.html",
    },
    {
        "id": "unc-biology-phd",
        "s": "unc",
        "n": "生物科学博士（EEOB/QBio 直接申请）",
        "en": "PhD in Biology (UNC Chapel Hill Department of Biology; direct application track for Ecology, Ecology & Organismal Biology [EEOB] and Quantitative Biology [QBio]; MCDB track applies separately through BBSP umbrella)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; campus visit/interviews late January-early February; faculty-advisor match is critical (must identify and contact at least one prospective advisor before applying); written exam before end of 3rd year",
        "ddl": "Fall 2027: **Priority Deadline November 10, 2026; Final Deadline November 17, 2026** (earlier than typical Dec 1; applications NOT accepted after Nov 17). Application fee $95.",
        "lang": "TOEFL iBT minimum 90 or IELTS Academic minimum 7.0; scores no more than 2 years old; English-medium degree / US citizen exempts; ETS UNC-CH code 2177.",
        "test": {"cls": "GRE NOT REQUIRED (UNC Biology: 'The GREs are not required for applications to our program but can be included if the applicant desires; scores within 5 years considered in holistic review'). 3 LOR; Statement of Purpose (1-3 pages); research experience essay; list 1+ prospective faculty advisors (must have contacted them before applying); list research area(s) via Area of Interest drop-down; unofficial transcripts."},
        "tui": "Full funding for admitted PhD students through UNC Graduate School and Department of Biology (tuition + stipend + health insurance) via research/teaching assistantships; Fall Graduate School Fellowships recommended by December 15, 2026.",
        "url": "details/unc-biology-phd.html",
    },
    {
        "id": "uva-biology-phd",
        "s": "uva",
        "n": "生物科学博士",
        "en": "PhD in Biology (University of Virginia College of Arts & Sciences, Department of Biology; 72 credits total including 24 graded coursework; 2 first-year lab rotations; research ethics course; teaching assistantship required)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission (October 1 - December 1 application window); 72 total credits (24 graded coursework including 3 intro courses in research methods/ethics + 2 rotation courses + colloquium/journal club); primary research advisor identified by end of Year 1; qualifying exam by end of Year 2; one first-author peer-reviewed paper required by private defense",
        "ddl": "Fall 2027: December 1, 2026 (application portal opens October 1, 2026). Admissions Committee begins review early December; offers generally made by late February.",
        "lang": "TOEFL iBT minimum 90 (pre-1/21/26; sectional minimums 22 speaking, 22 writing, 23 reading, 23 listening) or 4.5 (post-1/21/26); IELTS Academic 7.0 each section; Duolingo English Test 130 (sectional minimums 125/130/130/125); scores within 2 years; English-medium undergraduate exempts.",
        "test": {"cls": "GRE NOT REQUIRED (UVA Biology does not list GRE as required; UVA BIMS explicitly states 'GRE scores are no longer required for admission.' Biology Department PhD follows same policy. **Only 2 LOR required** (not 3); SOP 500-1000 words; CV/resume; transcripts; application fee $85)."},
        "tui": "Full funding for admitted PhD students through UVA Graduate School of Arts & Sciences (tuition + stipend + health insurance); students serve as Graduate Teaching Assistant for minimum one term with formal pedagogy training; Mountain Lake Biological Station summer courses available.",
        "url": "details/uva-biology-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 = {
    "rice-bcb-phd": {
        "school": "Rice University Department of BioSciences (Wiess School of Natural Sciences)",
        "en": "PhD in Biochemistry and Cell Biology (BCB track)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; minimum 6 semesters residency; 3 rotations before selecting thesis advisor in second semester",
        "ddl": "Fall 2027: Priority Dec 1, 2026 (early evaluation); Final Dec 31, 2026 (intl/domestic). Opens Sep 1, 2026.",
        "lang": "TOEFL iBT 90 (paper 600, computer 250); ETS 6609 dept 0202 (BCB); IELTS accepted; English-medium undergrad exempts.",
        "test_cls": "GRE OPTIONAL (BCB: optional; scores reviewed holistically; non-submitters not disadvantaged; subject tests not required). 3-4 LOR; Personal Statement; CV; transcripts; GPA 3.0/4.0.",
        "tui": "Full funding: annual stipend $39,500 + tuition + health insurance; application covers admission + research stipend (no separate aid application). Fee $85 (domestic waived).",
        "overview": "The Rice University PhD in Biochemistry and Cell Biology (BCB) is offered through the Department of BioSciences in the Wiess School of Natural Sciences. The BCB program trains students in modern biochemistry and cell biology with critical thought and independence. Entering students conduct three research rotations before selecting a thesis advisor in the second semester. Faculty research spans biochemistry, biophysics and structural biology, cancer biology, cell and developmental biology, computational biology, genetics, microbiology, neurobiology, plant biology, signal transduction, and synthetic and systems biology. The program is designed for PhD students only (no terminal MS).",
        "requirements": "<ul><li>Bachelor's degree or equivalent; GPA 3.0/4.0 minimum</li><li>GRE OPTIONAL (holistic review; subject tests not required)</li><li>TOEFL iBT 90 / IELTS (non-native English); ETS 6609 dept 0202; English-medium undergrad exempts</li><li>Rice Graduate and Postdoctoral Studies online application (opens September 1, 2026)</li><li>Personal Statement</li><li>3-4 letters of recommendation (applications not reviewed until at least 3 received)</li><li>Official/unofficial transcripts</li><li>CV required</li><li>Priority Deadline December 1, 2026 (early evaluation)</li><li>Final Deadline December 31, 2026 (international and domestic)</li><li>Fall matriculation only; on-campus</li><li>Application fee $85 (waived for all domestic applicants)</li></ul>",
        "research": "<ul><li>Biochemistry and biophysics</li><li>Structural biology</li><li>Cancer biology</li><li>Cell and developmental biology</li><li>Computational biology and systems biology</li><li>Genetics and microbiology</li><li>Neurobiology</li><li>Plant biology</li><li>Signal transduction</li><li>Synthetic biology</li></ul>",
        "source": '<a href="https://biosciences.rice.edu/biochemistry-and-cell-biology-graduate-program" target="_blank">Rice BCB Graduate Program (Dec 1 priority / Dec 31 final; stipend $39,500; 5-6 years; 3 rotations; fall-only; on-campus PhD)</a> | <a href="https://biosciences.rice.edu/how-apply-bcb" target="_blank">Rice BCB How to Apply (GRE optional; ETS 6609 dept 0202; TOEFL 90; 3-4 LOR; $85 fee; application covers admission + stipend)</a> | <a href="https://graduate.rice.edu/admissions/application-faq" target="_blank">Rice Graduate Studies FAQ (GRE not generally required for 2026; April 15 CGS resolution; programs may recommend/strongly recommend/require)</a>',
    },
    "geo-biology-phd": {
        "school": "Georgetown University Department of Biology (Graduate School of Arts & Sciences)",
        "en": "PhD in Biology (GSAS)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall primary; 16 credit hours coursework; qualifying/comprehensive exams; dissertation defense; 1-3 first-year rotations (MCB foci: Microbes & Infectious Disease, Neurodevelopment)",
        "ddl": "Fall 2027: December 1, 2026 (11:59 PM EST). Spring/summer applications accepted year-round but contingent on funding; interview weekend February; decisions Feb/Mar; April 15 reply.",
        "lang": "TOEFL iBT 80 (old) / 4.0 (new post-1/21/26) or IELTS 7.0; ETS Georgetown 5244; English-medium exempts; test must be taken by Dec 15 (score may arrive after deadline).",
        "test_cls": "GRE OPTIONAL / NOT REQUIRED (Biology Department does not require GRE; BMCB track: 'GRE/MCAT optional but recommended for Ph.D.'). 3 LOR; Academic Statement of Purpose; optional Diversity Statement; CV; transcripts; WES highly encouraged for international.",
        "tui": "Full funding through Georgetown Graduate School (tuition + stipend + health insurance) via RA/TA/fellowships; PI fit critical - email prospective PIs before applying.",
        "overview": "The Georgetown University PhD in Biology is offered through the Graduate School of Arts & Sciences (GSAS) and the Department of Biology. The department provides graduate students with an introduction to graduate-level biology across diverse fields, expert guidance in research, training in scientific communication, and a foundation in teaching pedagogy. Research emphases include biochemistry/cell/molecular biology, ecology/evolution/behavioral biology, parasitology, developmental biology, and neurosciences. The MCB area has two foci: Microbes & Infectious Disease and Neurodevelopment, where students perform 1-3 lab rotations in their first year. Students are encouraged to email prospective PIs before applying, as research fit and working style are critical admissions components.",
        "requirements": "<ul><li>Bachelor's degree or equivalent; minimum undergraduate GPA 3.0 (4.0 scale; 3.5+ preferred)</li><li>GRE OPTIONAL / not required (Biology Department does not list GRE as required)</li><li>TOEFL iBT 80 (old) / 4.0 (new) or IELTS 7.0 (non-native English); ETS 5244; English-medium exempts; test taken by Dec 15</li><li>Georgetown GSAS online application</li><li>Academic Statement of Purpose (academic/professional goals and fit with program)</li><li>Optional: Statement on Diversity, Personal Background & Contributions</li><li>3 letters of recommendation</li><li>Transcripts from all undergraduate and graduate institutions</li><li>Resume/CV</li><li>WES evaluation highly encouraged for international applicants</li><li>December 1, 2026 (11:59 PM EST) deadline</li><li>Fall admission primary; spring/summer contingent on funding</li><li>Email prospective PIs before applying (research fit critical)</li></ul>",
        "research": "<ul><li>Biochemistry, cell biology, and molecular biology</li><li>Ecology, evolution, and behavioral biology</li><li>Parasitology</li><li>Developmental biology</li><li>Neurosciences</li><li>Microbes & Infectious Disease (MCB focus)</li><li>Neurodevelopment (MCB focus)</li><li>Science communication and teaching pedagogy</li></ul>",
        "source": '<a href="https://grad.georgetown.edu/biology/" target="_blank">Georgetown GSAS: Biology PhD (Dec 1; 16 credit hours; qualifying/comprehensive exams; TOEFL 80/IELTS 7.0; 3 LOR)</a> | <a href="https://biology.georgetown.edu/phd-program/applicants/" target="_blank">Georgetown Biology PhD Applicants (Dec 1 deadline; interview weekend February; email PIs before applying; TOEFL taken by Dec 15)</a> | <a href="https://grad.georgetown.edu/admissions/application-deadlines/" target="_blank">Georgetown Application Deadlines (Fall: PhD in Biology Dec 1, 11:59 PM EST)</a>',
    },
    "notre-biosci-phd": {
        "school": "University of Notre Dame Department of Biological Sciences (College of Science)",
        "en": "PhD in Biological Sciences",
        "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); minimum 2 years residency; 159 graduate students, 63 faculty, 30+ countries; interdisciplinary with Indiana University School of Medicine at South Bend",
        "ddl": "Fall 2027: December 1, 2026. Suggest submitting by mid-November to ensure all materials (including LORs) arrive by deadline.",
        "lang": "TOEFL iBT / IELTS Academic / Duolingo English Test for non-native English; ETS Notre Dame 1841 (no dept code); English-medium exempts.",
        "test_cls": "GRE GENERAL OPTIONAL (Notre Dame: 'GRE General Test optional.' Subject test not required; scores within 5 years. 3 LOR; Statement of Intent (1-3 double-spaced pages); CV; unofficial transcripts; official transcript showing bachelor's conferral due upon enrollment).",
        "tui": "Full funding through Notre Dame Graduate School (tuition + stipend + health insurance) via RA/TA/fellowships; April 15 CGS resolution applies.",
        "overview": "The University of Notre Dame PhD in Biological Sciences is the focal point for research in the life sciences at Notre Dame. The doctoral program encompasses the broad scope of biological inquiry with several areas of study in the biomedical sciences, global health, and ecology, evolution & the environment (EEE). The department provides a wide choice of faculty advisers, many of whom lead their disciplines by serving as officers of professional societies, on journal editorial boards, study sections, scientific advisory boards, and as consultants. The department includes 63 faculty and 159 graduate students from 30+ countries, with associated faculty at the Indiana University School of Medicine at South Bend adjacent to the Notre Dame campus.",
        "requirements": "<ul><li>Bachelor's degree or equivalent</li><li>GRE General Test OPTIONAL (subject test not required; scores within 5 years)</li><li>TOEFL iBT / IELTS Academic / Duolingo English Test (non-native English); ETS 1841; English-medium exempts</li><li>Notre Dame Graduate School online application</li><li>Statement of Intent (1-3 double-spaced pages; intellectual development, interests, fit with faculty)</li><li>3 letters of recommendation</li><li>Curriculum vitae</li><li>Unofficial transcripts from each post-secondary institution (official showing bachelor's conferral due upon enrollment)</li><li>December 1, 2026 deadline</li><li>Fall admission only; no spring</li><li>Minimum 2 years residency</li></ul>",
        "research": "<ul><li>Biomedical sciences</li><li>Global health</li><li>Ecology, evolution & the environment (EEE)</li><li>Environmental change and sustainability</li><li>Microbiology and immunology</li><li>Genetics and molecular biology</li><li>Physiology and organismal biology</li><li>Interdisciplinary work with Notre Dame Environmental Change Initiative and Indiana University School of Medicine</li></ul>",
        "source": '<a href="https://graduateschool.nd.edu/degree-programs/biological-sciences-phd---doctoral/" target="_blank">Notre Dame Biological Sciences PhD (Dec 1; GRE optional; TOEFL/IELTS/Duolingo; 3 LOR; Statement of Intent; 2-year residency; 159 grad students, 63 faculty)</a> | <a href="https://biology.nd.edu/" target="_blank">Notre Dame Department of Biological Sciences (63 faculty; 159 grad students; 30+ countries; biomedical/global health/EEE focus)</a> | <a href="https://graduateschool.nd.edu/degree-programs/?id=program-78377" target="_blank">Notre Dame Graduate Degree Programs (Biological Sciences PhD Fall: Dec 1; ETS 1841)</a>',
    },
    "unc-biology-phd": {
        "school": "UNC Chapel Hill Department of Biology",
        "en": "PhD in Biology (direct EEOB/QBio track; MCDB applies via BBSP umbrella)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; campus visit/interviews late Jan-early Feb; faculty-advisor match critical (must contact prospective advisor before applying); written exam before end of 3rd year",
        "ddl": "Fall 2027: **Priority November 10, 2026; Final November 17, 2026** (earlier than typical Dec 1; applications NOT accepted after Nov 17). Fee $95.",
        "lang": "TOEFL iBT 90 or IELTS 7.0; scores no more than 2 years old; English-medium/US citizen exempts; ETS UNC-CH 2177.",
        "test_cls": "GRE NOT REQUIRED (UNC Biology: 'The GREs are not required for applications to our program but can be included if the applicant desires; scores within 5 years considered in holistic review'). 3 LOR; SOP 1-3 pages; research experience essay; list 1+ prospective faculty (must have contacted them); list research area(s) via Area of Interest drop-down; transcripts.",
        "tui": "Full funding through UNC Graduate School and Department of Biology (tuition + stipend + health insurance) via RA/TA; Fall Graduate School Fellowships recommended by Dec 15, 2026.",
        "overview": "The UNC Chapel Hill PhD in Biology offers two application paths: (1) Molecular, Cellular and Developmental Biology (MCDB) track applies through the BBSP umbrella (Biological and Biomedical Sciences Program); (2) Ecology, Ecology & Organismal Biology (EEOB) and Quantitative Biology (QBio) tracks apply directly to the Biology Department. This entry covers the direct-application track (EEOB/QBio). Admissions to EEOB/QBio are primarily driven by faculty interest, so applicants must identify and contact at least one prospective advisor before applying. Campus visits and interviews occur in late January or early February; final decisions by March.",
        "requirements": "<ul><li>Bachelor's degree or equivalent; GPA minimum 3.0/4.0</li><li>GRE NOT required (optional; scores within 5 years considered in holistic review)</li><li>TOEFL iBT 90 / IELTS 7.0 (non-native English; scores no more than 2 years old); ETS 2177; English-medium/US citizen exempts</li><li>UNC Graduate School online application</li><li>Statement of Purpose (1-3 pages; research interests, proposed approaches, career goals)</li><li>Research experience essay (1 page)</li><li>3 letters of recommendation</li><li>Transcripts</li><li>**List 1+ prospective faculty advisors (must have contacted them before applying - admissions contingent on faculty willingness to advise)**</li><li>List research area(s) via Area of Interest/Specialization drop-down</li><li>**Priority Deadline November 10, 2026; Final Deadline November 17, 2026 (applications NOT accepted after Nov 17)**</li><li>Fall admission only; application fee $95</li><li>Note: MCDB track applies separately through BBSP (bbsp.unc.edu), not this direct path</li></ul>",
        "research": "<ul><li>Ecology, Ecology & Organismal Biology (EEOB) - direct track</li><li>Quantitative Biology (QBio) - direct track or via BBSP</li><li>Molecular, Cellular and Developmental Biology (MCDB) - via BBSP umbrella (separate application)</li><li>Evolutionary biology</li><li>Organismal biology and behavior</li><li>Computational and quantitative biology</li><li>Plant and microbial biology</li><li>Interdisciplinary with UNC Medical School, Gillings School of Global Public Health, and NC State</li></ul>",
        "source": '<a href="http://bio.unc.edu/graduate/" target="_blank">UNC Biology Graduate Program (PhD BIOL Fall: Nov 17 final / Nov 10 priority; GRE not required; 3 LOR; TOEFL 90/IELTS 7.0; list faculty; MCDB via BBSP)</a> | <a href="http://bio.unc.edu/graduate/eeob/" target="_blank">UNC EEOB How to Apply (Nov 10 priority / Nov 17 final; contact faculty before applying; GRE optional; TOEFL 90/IELTS 7.0; $95 fee; campus visit late Jan-early Feb)</a> | <a href="http://bio.unc.edu/graduate/qbio/" target="_blank">UNC QBio Graduate Track (direct application or via BBSP; contact faculty before applying; Nov 10/17 deadlines; GRE optional; holistic review)</a>',
    },
    "uva-biology-phd": {
        "school": "University of Virginia Department of Biology (College of Arts & Sciences)",
        "en": "PhD in Biology (A&S)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only (Oct 1 - Dec 1 application window); 72 total credits (24 graded coursework including 3 intro courses in research methods/ethics + 2 first-year rotation courses + colloquium/journal club); primary advisor by end of Year 1; qualifying exam by end of Year 2; one first-author peer-reviewed paper by private defense",
        "ddl": "Fall 2027: December 1, 2026 (application portal opens October 1, 2026). Admissions Committee begins review early December; offers generally made by late February.",
        "lang": "TOEFL iBT 90 (pre-1/21/26; sectional 22/22/23/23) or 4.5 (post-1/21/26); IELTS 7.0 each section; Duolingo DET 130 (sectional 125/130/130/125); scores within 2 years; English-medium exempts.",
        "test_cls": "GRE NOT REQUIRED (UVA Biology does not list GRE as required; UVA BIMS explicitly states 'GRE scores are no longer required for admission.' Biology PhD follows same policy. **Only 2 LOR required**; SOP 500-1000 words; CV; transcripts; fee $85).",
        "tui": "Full funding through UVA Graduate School of Arts & Sciences (tuition + stipend + health insurance); GTA for minimum one term with formal pedagogy training; Mountain Lake Biological Station summer courses available.",
        "overview": "The University of Virginia PhD in Biology is offered through the Department of Biology in the College of Arts & Sciences (note: this is distinct from the BIMS - Biomedical Sciences Graduate Program at the UVA School of Medicine). The degree requires 72 total credits including 24 graded coursework credits. First-year students complete three introductory courses in research methods and ethics (BIOL 8240, BIOL 8250, BIOL 8260, and BIMS 7100 or GSCI 8000) plus two laboratory rotation courses. By the end of the first year, students identify a primary research advisor; by the end of the second year, they pass qualifying exams including defense of a research proposal. Students must serve as a Graduate Teaching Assistant for at least one term and have at least one first-author or co-first-author peer-reviewed publication by the time of private dissertation defense.",
        "requirements": "<ul><li>Bachelor's degree or equivalent; B average in undergraduate program</li><li>GRE NOT required (UVA Biology follows university-wide no-GRE policy; BIMS explicitly states no longer required)</li><li>TOEFL iBT 90 / IELTS 7.0 / DET 130 (non-native English; scores within 2 years; sectional minimums apply); English-medium exempts</li><li>UVA Graduate School of Arts & Sciences online application (opens October 1, 2026)</li><li>Statement of Purpose (500-1000 words; address program-specific questions)</li><li>**2 letters of recommendation (note: only 2, not 3)**</li><li>CV/resume</li><li>Transcripts</li><li>December 1, 2026 deadline</li><li>Fall admission only</li><li>Application fee $85</li><li>Note: MS program requires faculty sponsorship before application; PhD does not</li></ul>",
        "research": "<ul><li>Molecular and cell biology</li><li>Ecology and evolutionary biology</li><li>Animal behavior and neurobiology</li><li>Plant biology and botany</li><li>Computational biology and systems biology</li><li>Physiology and biomechanics</li><li>Mountain Lake Biological Station field research</li><li>Interdisciplinary with UVA School of Medicine BIMS program</li></ul>",
        "source": '<a href="http://bio.as.virginia.edu/how-apply-graduate-program" target="_blank">UVA Biology How to Apply (Dec 1; Oct 1 opening; SOP 500-1000 words; 2 LOR; TOEFL 90/IELTS 7.0/DET 130; $85 fee; offers by late February)</a> | <a href="https://graduate.as.virginia.edu/deadlines" target="_blank">UVA Graduate School Deadlines (PhD Biology Dec 1; application portal opens October 1)</a> | <a href="https://records.ureg.virginia.edu/preview_program.php?catoid=73&poid=12173" target="_blank">UVA Record: Biology PhD (72 credits; 24 graded coursework; 2 rotations; GTA requirement; first-author paper by defense; advisor by end of Year 1)</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)}")
