# -*- coding: utf-8 -*-
"""Round 233: batch add 5 Biology PhD (Harvard MCB / Stanford Bio / UCSD BioSci / Princeton MolBio / MIT Bio)
Key finding: Top-tier Biology PhD programs at Harvard, MIT, and UCSD have all moved to GRE-free
(Harvard MCB 'Not Accepted', MIT Biology 'does not accept GRE scores', UCSD BioSci optional since 2018).
Princeton MolBio is 'Optional/Not Required'. Stanford Biology is independent of the 14 Biosciences home
programs and varies. All five admit fall-only, full-time, and provide full funding.
Deadlines: Dec 1 (Harvard/Princeton/MIT); Dec 1 11:59pm PST (Stanford); Dec 2 (UCSD).
"""
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": "harvard-mcb-phd",
        "s": "harvard",
        "n": "分子与细胞生物学博士",
        "en": "PhD in Molecular and Cellular Biology (Harvard University Department of Molecular and Cellular Biology; part of Harvard Integrated Life Sciences, HILS)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; Harvard Griffin GSAS application; rotations in first year; thesis mentor identified at end of G1",
        "ddl": "Fall 2027: December 1, 2026, 5:00 PM EST (application opens September 2026). Interviews late January/early February; decisions mid-February; April 15 reply.",
        "lang": "TOEFL iBT minimum 100 or IELTS Academic minimum 7; required for non-native English speakers (undergraduate degree from English-language institution exempts).",
        "test": {"cls": "GRE NOT ACCEPTED (Harvard MCB: 'Please note that GRE scores are not accepted.'). GSAS HILS programs uniformly do not review GRE. No minimum score; holistic review. Recommended coursework: biology (general + 2 advanced terms), biochemistry, organic chemistry, physical chemistry, physics, calculus."},
        "tui": "Full funding for admitted PhD students through Harvard Griffin GSAS (tuition + stipend + health insurance) for 5+ years, contingent on satisfactory academic progress.",
        "url": "details/harvard-mcb-phd.html",
    },
    {
        "id": "stanford-bio-phd",
        "s": "stanford",
        "n": "生物学博士",
        "en": "PhD in Biology (Stanford University Department of Biology, School of Humanities and Sciences; independent of the 14 Stanford Biosciences home programs)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Autumn-quarter entry only; full-time residential; Bachelor's degree or equivalent required; rotations and thesis research",
        "ddl": "Autumn 2027-28 matriculation: Tuesday, December 1, 2026, 11:59:59 PM PST (application opens September 2026). Knight-Hennessy Scholars separate deadline early October.",
        "lang": "TOEFL iBT or IELTS Academic required unless exempt (US/English-medium undergraduate degree or criteria on Personal Background page). No university minimum score published; holistic review.",
        "test": {"cls": "GRE varies by home program. Stanford Biology (independent department admission) does not require GRE; the 14 Stanford Biosciences home programs list individual GRE requirements (some 'Optional', some 'Not Considered'). Consult biology.stanford.edu for current cycle. No minimum; holistic review. Required: SOP, 3 LOR (max 4), transcripts, CV."},
        "tui": "Full funding for admitted PhD students (tuition + stipend + health insurance) through Stanford School of Humanities and Sciences and departmental fellowships/assistantships.",
        "url": "details/stanford-bio-phd.html",
    },
    {
        "id": "ucsd-biosci-phd",
        "s": "ucsd",
        "n": "生物科学博士",
        "en": "PhD in Biological Sciences (UC San Diego School of Biological Sciences; tracks: General BioSci [non-EBE] and Ecology, Behavior, Evolution [EBE])",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Fall-only admission; full-time residential; ~30% international cohort; EBE track requires contacting faculty of interest before applying",
        "ddl": "Fall 2027: December 2, 2026, 11:59 PM PST (application opens September 2, 2026). Zoom interviews January 14-25, 2027; in-person recruitment March 4, 2027.",
        "lang": "TOEFL iBT / IELTS / Duolingo DET accepted; UCSD minimum iBT 85 (higher for selected programs); ETS institution code 4836.",
        "test": {"cls": "GRE NOT REQUIRED (UCSD BioSci PhD and Biomedical Sciences: 'As of 2018, applicants are no longer required to submit scores for either the GRE General or Subject Tests. Scores optional; self-reported.'), ETS 4836. Minimum GPA 3.0. Recommended: calculus, biochemistry, organic and physical chemistry, biology, cell/molecular biology, mammalian physiology."},
        "tui": "Full funding for admitted PhD students (tuition + stipend + benefits) through UCSD School of Biological Sciences and graduate fellowships/assistantships.",
        "url": "details/ucsd-biosci-phd.html",
    },
    {
        "id": "princeton-molbio-phd",
        "s": "princeton",
        "n": "分子生物学博士",
        "en": "PhD in Molecular Biology (Princeton University Department of Molecular Biology; interdisciplinary with chemistry, CS, EEB, CBE, physics, neuroscience)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5 years full-time residential; fall-only admission; research rotations in MOL and associated departments; general exam in year 2; no terminal master's offered",
        "ddl": "Fall 2027: December 1, 2026, 11:59 PM EST. Interviews January/February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT or IELTS Academic required for non-native English speakers; ETS Princeton institution code 2672. No minimum published; departmental review.",
        "test": {"cls": "GRE OPTIONAL / NOT REQUIRED (Princeton Graduate School GRE table: 'Molecular Biology - Optional/Not required for fall 2023 admission'; scores not reviewed if not submitted). No rigid prerequisites; diverse backgrounds (chemistry, physics, math) encouraged. 3 LOR, transcripts, statement."},
        "tui": "Full funding for admitted PhD students (tuition + health insurance + stipend); 2022-23 stipend ~$48,000. China Scholarship Council (CSC)/Princeton Joint Funding Program available for Chinese students.",
        "url": "details/princeton-molbio-phd.html",
    },
    {
        "id": "mit-bio-phd",
        "s": "mit",
        "n": "生物学博士",
        "en": "PhD in Biology (MIT Department of Biology; doctoral program only, no master's offered; interdisciplinary with WHOI, Computational and Systems Biology, Brain and Cognitive Sciences)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5.5-6 years full-time residential; fall-only admission; required: calculus, 1 year college physics, organic chemistry, biochemistry, genetics; ELP waiver requests due November 18, 2026",
        "ddl": "Fall 2027: December 1, 2026, 5:00 PM EST (application opens October 1, 2026). Interview invitations mid-January; open house/interviews February; decisions following interviews.",
        "lang": "TOEFL iBT minimum 100 (iBT 26 minimum 5) or IELTS Academic minimum 7; Cambridge C1/C2 accepted; ETS MIT code 3514; scores current within 2 years; ELP waiver case-by-case (deadline November 18, 2026).",
        "test": {"cls": "GRE NOT ACCEPTED (MIT Biology: 'The Department of Biology does not accept GRE scores and will not consider GRE scores during the evaluation of your application.'). No minimum score; holistic review. STEM Eligible (NSF GRFP field: Life Sciences)."},
        "tui": "Full funding for admitted PhD students (tuition + stipend + health insurance) through MIT School of Science and departmental research/teaching assistantships.",
        "url": "details/mit-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 = {
    "harvard-mcb-phd": {
        "school": "Harvard University Department of Molecular and Cellular Biology",
        "en": "PhD in Molecular and Cellular Biology (MCB)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; HILS; rotations; thesis mentor end of G1",
        "ddl": "Fall 2027: December 1, 2026, 5:00 PM EST. Interviews late Jan/early Feb; decisions mid-Feb; April 15 reply.",
        "lang": "TOEFL iBT 100 or IELTS 7 minimum; English-medium undergraduate exempts.",
        "test_cls": "GRE NOT ACCEPTED (MCB: 'Please note that GRE scores are not accepted.'). HILS programs uniformly do not review GRE. Recommended coursework: bio, biochem, o-chem, p-chem, physics, calculus.",
        "tui": "Full funding through Harvard Griffin GSAS (tuition + stipend + insurance) for 5+ years.",
        "overview": "The Harvard PhD in Molecular and Cellular Biology (MCB) is part of the Harvard Integrated Life Sciences (HILS) consortium within the Kenneth C. Griffin Graduate School of Arts and Sciences. The program trains future scientific leaders in basic science across the molecules, cells, and organisms (MCO) scope. Graduates have secured positions in industry (Genentech, Novartis, Google) and academia (Harvard, Caltech, Stanford, MIT). Students complete first-year research rotations across MCB faculty labs before declaring a thesis mentor at the end of their G1 year.",
        "requirements": "<ul><li>Bachelor's degree (prior graduate degree not required)</li><li>Recommended coursework: biology (general + 2 advanced terms), biochemistry, organic chemistry, physical chemistry, physics, calculus; programming competence strongly encouraged</li><li>GRE NOT accepted (no scores reviewed; HILS-wide policy)</li><li>TOEFL iBT 100 or IELTS 7 (non-native English; English-medium undergraduate exempts)</li><li>Harvard Griffin GSAS online application</li><li>Statement of Purpose (3 short prompts: motivations, impact example, research interest + 3 faculty; SOP limited to 500 words total across prompts)</li><li>3 letters of recommendation</li><li>Transcripts (unofficial at application; official only from admitted students)</li><li>Application fee $105 (fee waivers available)</li><li>December 1, 2026, 5:00 PM EST deadline</li><li>Fall entry only; full-time residential</li></ul>",
        "research": "<ul><li>Biochemistry and structural biology</li><li>Cell biology, development, and stem cell biology</li><li>Genetics, genomics, and epigenetics</li><li>Microbiology, virology, and immunology</li><li>Neurobiology and behavior</li><li>Biophysics and computational biology</li><li>Cross-disciplinary work with Harvard Medical School, FAS, and Broad Institute</li></ul>",
        "source": '<a href="https://www.mcb.harvard.edu/graduate/application-requirements/" target="_blank">Harvard MCB Application Requirements (Dec 1, 5pm EST; GRE not accepted; TOEFL 100/IELTS 7)</a> | <a href="https://gsas.harvard.edu/program/molecular-and-cellular-biology" target="_blank">Harvard GSAS: MCB PhD (GRE Not Accepted; Dec 1, 2025/2026 5pm)</a> | <a href="https://bbsphd.hms.harvard.edu/apply" target="_blank">Harvard HILS Timeline (Dec 1; interviews Feb 5-8; decisions mid-Feb)</a>',
    },
    "stanford-bio-phd": {
        "school": "Stanford University Department of Biology",
        "en": "PhD in Biology",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "Autumn-quarter entry only; full-time residential; rotations and thesis research",
        "ddl": "Autumn 2027-28: Tuesday, December 1, 2026, 11:59:59 PM PST (opens September 2026). Knight-Hennessy deadline early October.",
        "lang": "TOEFL iBT or IELTS Academic required unless exempt (US/English-medium undergraduate). No university minimum; holistic.",
        "test_cls": "GRE varies by home program. Stanford Biology (independent admission) does not require GRE; 14 Biosciences home programs list individual requirements (some Optional, some Not Considered). No minimum; holistic. SOP + 3 LOR (max 4) + CV + transcripts.",
        "tui": "Full funding through Stanford School of Humanities and Sciences and departmental fellowships/assistantships.",
        "overview": "The Stanford PhD in Biology is run directly by the Department of Biology in the School of Humanities and Sciences (separate from the 14 Stanford Biosciences home programs administered through the School of Medicine). Faculty with 100% appointments in Biology recruit through the Biology application; Ecology/Evolutionary Biology faculty with 50/50 appointments in Biology and the Stanford Doerr School of Sustainability (SDSS) recruit through either Biology or Earth Systems Science; Oceans faculty recruit through the Oceans application. The program admits only for Autumn Quarter entry.",
        "requirements": "<ul><li>Bachelor's degree or foreign equivalent</li><li>GRE not required for Biology department admission (consult current cycle page)</li><li>TOEFL iBT / IELTS Academic required unless exempt (US/English-medium undergraduate degree or criteria on Personal Background page)</li><li>Stanford Graduate Admissions online application</li><li>Statement of Purpose</li><li>3 letters of recommendation (max 4 accepted)</li><li>Unofficial transcripts from all institutions attended 1+ year</li><li>Current CV/resume</li><li>Application fee $125 (fee waivers available)</li><li>December 1, 2026, 11:59:59 PM PST deadline</li><li>Autumn entry only; full-time</li></ul>",
        "research": "<ul><li>Molecular and cellular biology</li><li>Ecology and evolutionary biology (joint with SDSS)</li><li>Marine biology / Oceans (joint with Stanford Doerr School of Sustainability)</li><li>Plant biology and developmental biology</li><li>Neurobiology and behavior</li><li>Biophysics and computational biology</li><li>Cross-disciplinary work with Stanford School of Medicine, Hopkins Marine Station, and Bio-X</li></ul>",
        "source": '<a href="https://biology.stanford.edu/academics/phd-program/graduate-admissions" target="_blank">Stanford Biology PhD Graduate Admissions (Dec 1, 2026 11:59:59pm PST; fee $125; 3 LOR)</a> | <a href="https://biosciences.stanford.edu/how-to-apply/" target="_blank">Stanford Biosciences How to Apply (Dec 1, 2026; GRE varies by home program)</a>',
    },
    "ucsd-biosci-phd": {
        "school": "UC San Diego School of Biological Sciences",
        "en": "PhD in Biological Sciences (General BioSci / EBE tracks)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "Fall-only admission; full-time; ~30% international cohort; EBE track requires contacting faculty before applying",
        "ddl": "Fall 2027: December 2, 2026, 11:59 PM PST (opens September 2, 2026). Zoom interviews Jan 14-25, 2027; in-person recruitment March 4, 2027.",
        "lang": "TOEFL iBT / IELTS / Duolingo DET accepted; UCSD minimum iBT 85; ETS 4836.",
        "test_cls": "GRE NOT REQUIRED (UCSD BioSci/BMS: 'As of 2018, applicants are no longer required to submit scores for either the GRE General or Subject Tests. Scores optional; self-reported.'). ETS 4836. Min GPA 3.0. Recommended: calculus, biochem, o-chem, p-chem, bio, cell/molecular bio, mammalian physiology.",
        "tui": "Full funding through UCSD School of Biological Sciences and graduate fellowships/assistantships.",
        "overview": "The UCSD PhD in Biological Sciences is offered through the School of Biological Sciences with two tracks: General BioSci (non-EBE) and Ecology, Behavior, Evolution (EBE). Admission is highly competitive with a limited cohort each Fall. Approximately 30% of the incoming class is international. For the General BioSci track, students do not need to contact faculty before applying; for the EBE track, students must contact EBE faculty of interest before applying. The Biomedical Sciences (BMS) program at UCSD uses the same graduate application and similarly went GRE-optional in 2018.",
        "requirements": "<ul><li>Bachelor's degree; minimum GPA 3.0</li><li>Recommended coursework: calculus, biochemistry, organic and physical chemistry, biology, cell and molecular biology, mammalian physiology</li><li>GRE NOT required since 2018 (optional self-submission; ETS 4836)</li><li>TOEFL iBT / IELTS / Duolingo DET (non-native English; UCSD iBT minimum 85)</li><li>UCSD Slate online application (select Doctor of Philosophy, Biological Sciences PhD, Fall 2027)</li><li>Statement of Purpose (1500 word limit for BMS; BioSci similar)</li><li>3 letters of recommendation (recommended to have submitted by deadline)</li><li>Unofficial transcripts (official required only from admitted students)</li><li>CV/resume</li><li>Application fee $135 (international $155; fee waivers available)</li><li>December 2, 2026, 11:59 PM PST deadline</li><li>Fall entry only; full-time</li><li>EBE track: contact EBE faculty of interest before applying</li><li>AI policy: application materials must be written by applicant; LORs must represent recommender's own thoughts (no AI-generated content)</li></ul>",
        "research": "<ul><li>Molecular, cellular, and developmental biology</li><li>Genetics, genomics, and bioinformatics</li><li>Ecology, behavior, and evolution (EBE track)</li><li>Neurobiology and physiology</li><li>Plant systems biology</li><li>Marine biology and biological oceanography</li><li>Cross-disciplinary work with Salk Institute, Scripps Institution of Oceanography, and Sanford Burnham Prebys</li></ul>",
        "source": '<a href="https://biology.ucsd.edu/education/grad/phd/admissions/index.html" target="_blank">UCSD BioSci PhD Admissions (Dec 2, 2026; Fall 2027; ~30% international)</a> | <a href="https://biology.ucsd.edu/education/grad/phd/admissions/faq/general-application.html" target="_blank">UCSD BioSci General FAQ (opens Sept 2; closes Dec 2; EBE contact faculty)</a> | <a href="https://biomedsci.ucsd.edu/how-to-apply/phd-program1.html" target="_blank">UCSD BMS (GRE optional since 2018; ETS 4836; fee $135/$155)</a>',
    },
    "princeton-molbio-phd": {
        "school": "Princeton University Department of Molecular Biology",
        "en": "PhD in Molecular Biology",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5 years full-time residential; fall-only; rotations in MOL + associated departments; general exam year 2; no terminal master's",
        "ddl": "Fall 2027: December 1, 2026, 11:59 PM EST. Interviews January/February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT or IELTS Academic required for non-native English; ETS Princeton code 2672. No minimum published; departmental review.",
        "test_cls": "GRE OPTIONAL / NOT REQUIRED (Princeton Grad School GRE table: 'Molecular Biology - Optional/Not required'). No rigid prerequisites; diverse backgrounds (chemistry, physics, math) encouraged. 3 LOR, transcripts, statement. No terminal master's offered.",
        "tui": "Full funding (tuition + health insurance + stipend); 2022-23 stipend ~$48,000. CSC/Princeton Joint Funding available for Chinese students.",
        "overview": "The Princeton PhD in Molecular Biology is a tightly knit, cohesive program that spans biochemistry, biophysics, cancer, cell biology, computation and modeling, development, evolution, genetics, genomics, microbiology and virology, policy, and structural biology. Students choose research rotations with faculty in molecular biology and associated departments (chemistry, computer science, ecology and evolutionary biology, chemical and biological engineering, physics, and neuroscience). There is no terminal master's degree offered. The program also participates in interdisciplinary options including Neuroscience and Quantitative and Computational Biology (QCB), as well as Biology@Princeton for cross-program consideration.",
        "requirements": "<ul><li>Bachelor's degree (any major; no rigid prerequisites)</li><li>GRE OPTIONAL / NOT REQUIRED (scores not reviewed if not submitted)</li><li>TOEFL iBT / IELTS Academic (non-native English; ETS 2672)</li><li>Princeton Graduate School online application</li><li>Statement of purpose (optional diversity statement up to 500 words)</li><li>3 letters of recommendation</li><li>Transcripts (scanned version)</li><li>Application fee $75</li><li>December 1, 2026, 11:59 PM EST deadline</li><li>Fall entry only; full-time</li><li>No spring admission; no terminal master's</li><li>MD/PhD option available through separate application</li></ul>",
        "research": "<ul><li>Biochemistry, biophysics, and structural biology</li><li>Cell biology, development, and cancer</li><li>Genetics and genomics</li><li>Microbiology and virology</li><li>Neuroscience (interdisciplinary)</li><li>Quantitative and computational biology (QCB, interdisciplinary)</li><li>Policy (science policy dimension)</li><li>Cross-disciplinary work with Princeton Physics, CS, Chemistry, and Lewis-Sigler Institute</li></ul>",
        "source": '<a href="https://gradschool.princeton.edu/academics/degrees-requirements/fields-study/molecular-biology" target="_blank">Princeton Grad School: Molecular Biology (Dec 1; 5 years; fee $75; GRE optional/not required)</a> | <a href="https://molbio.princeton.edu/graduate/admission" target="_blank">Princeton MOL Admission & Financial Support (3 LOR; ETS 2672; stipend ~$48,000; CSC joint funding)</a> | <a href="https://molbio.princeton.edu/admission-faq" target="_blank">Princeton MOL Admission FAQ (no master\'s; fall only; diverse backgrounds encouraged)</a>',
    },
    "mit-bio-phd": {
        "school": "MIT Department of Biology",
        "en": "PhD in Biology",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (NSF GRFP field: Life Sciences / CIP 26.xx)",
        "dur": "5.5-6 years full-time residential; fall-only; doctoral only (no master's); ELP waiver requests due November 18, 2026",
        "ddl": "Fall 2027: December 1, 2026, 5:00 PM EST (application opens October 1, 2026). Interview invitations mid-January; open house/interviews February; decisions following.",
        "lang": "TOEFL iBT 100 (iBT 26 minimum 5) or IELTS 7; Cambridge C1/C2 accepted; ETS MIT code 3514; scores current within 2 years; ELP waiver case-by-case (deadline Nov 18, 2026).",
        "test_cls": "GRE NOT ACCEPTED (MIT Biology: 'The Department of Biology does not accept GRE scores and will not consider GRE scores during the evaluation of your application.'). STEM Eligible. Required: calculus, 1 year physics, organic chemistry, biochemistry, genetics.",
        "tui": "Full funding through MIT School of Science and departmental research/teaching assistantships (tuition + stipend + insurance).",
        "overview": "The MIT Department of Biology offers a doctoral program only (no master's degree). The average length of time to degree is 5.5 to 6 years. The department also participates in interdisciplinary and joint degree programs including the Molecular and Cellular Neuroscience graduate program, the joint MD/PhD program, the Biophysics Certificate program, and the joint program with the Woods Hole Oceanographic Institution (WHOI) in biological oceanography and microbiology. Required preparation includes calculus, one year of college physics, organic chemistry, general biochemistry, and genetics.",
        "requirements": "<ul><li>Bachelor's degree (doctoral only; no master's offered)</li><li>Required preparation: calculus, 1 year college physics, organic chemistry, biochemistry, genetics</li><li>GRE NOT accepted (scores not reviewed; do not submit)</li><li>TOEFL iBT 100 (iBT 26 sub-score minimum 5) or IELTS Academic 7; Cambridge C1/C2 accepted; ETS 3514; scores current within 2 years</li><li>MIT Slate online application</li><li>Statement of objectives</li><li>3 letters of recommendation</li><li>Unofficial transcripts (PDF) from each college/university attended</li><li>Application fee $90 (credit card on Slate)</li><li>December 1, 2026, 5:00 PM EST deadline</li><li>Fall entry only; full-time</li><li>ELP waiver requests due November 18, 2026 (case-by-case)</li><li>All test scores must be verified by testing agency by April 15, 2027</li></ul>",
        "research": "<ul><li>Biochemistry</li><li>Bioengineering and synthetic biology</li><li>Bioinformatics and computational biology</li><li>Biological oceanography (joint with WHOI)</li><li>Human genetics and molecular medicine</li><li>Microbiology (joint with WHOI)</li><li>Neurobiology and physiology</li><li>Molecular medicine and human disease</li><li>Cross-disciplinary work with MIT CSAIL, Broad Institute, Whitehead Institute, and WHOI</li></ul>",
        "source": '<a href="https://oge.mit.edu/programs/biology/" target="_blank">MIT OGE: Biology (Dec 1, 11:59pm ET; fee $90; STEM Eligible; GRE not accepted; TOEFL 100/IELTS 7)</a> | <a href="https://biology.mit.edu/graduate/prospective-students/application-process/" target="_blank">MIT Biology Application Process (5.5-6 yrs; no master\'s; 3 LOR; ELP waiver Nov 18)</a> | <a href="https://oge.mit.edu/graduate-admissions/programs/doctoral-degrees/" target="_blank">MIT Doctoral Degrees (Biology Oct 1 opens / Dec 1 deadline)</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)}")
