# -*- coding: utf-8 -*-
"""Round 265: batch add 5 - Biochemistry/Biophysics PhD (Yale MB&B via BBS BQBS, Harvard Biophysics, UChicago Biochem & Molecular Biophysics, Columbia Biological Sciences subfield, Caltech BMB)
Key findings:
- Yale MB&B: PhD only via BBS Combined Program (BQBS track). Dec 1 11:59pm ET. GRE Not Accepted per GSAS 2026-06-29. TOEFL iBT 100, ETS 3987. Full funding 12-mo stipend + tuition + healthcare.
- Harvard Biophysics: Dec 1 5pm ET. GRE General Not Accepted (GSAS 2026-07-01). GRE Subject not required. HILS member. SOP + 500-word Personal Statement. Virtual interview late Jan/early Feb + in-person March. ETS 3451.
- UChicago Biochem & Molecular Biophysics: Dec 1 2026. GRE optional BUT Biosciences page explicitly lists Biochemistry and Molecular Biophysics among PhD programs that DO consider submitted GRE scores (unlike most BSD programs that ignore them). TOEFL iBT 100 (pre-2026-01-21) or 5/5.5/4.5 (post). IELTS 7. 3 LOR. $90 fee. ETS 1832.
- Columbia Biological Sciences: Dec 2 2026 11:59pm ET. GRE General No (no longer required). Must list 3 potential faculty advisors in application. TOEFL iBT 100/IELTS 7.5. ETS 2162. ~20 admits/year. Subfields include Structural Biology, Biophysics, Chemical Biology and Biochemistry.
- Caltech BMB: Dec 1 2026. GRE optional per CCE (not required, absence not penalized, submitted considered). Note: Biology option says GRE strongly recommended but BMB lives under CCE division with its own GRE policy. TOEFL/PTE/IELTS/Duolingo. 3 LOR + CV + SOP. No minimum GPA. Fall only. One option per cycle.
"""
import os, re

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

DETAIL_TEMPLATE = """<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>{school} - {en}</title>
<style>
body{{font-family:-apple-system,'Segoe UI',sans-serif;max-width:960px;margin:24px auto;padding:0 20px;color:#222;line-height:1.6}}
h1{{color:#1a3a6c;border-bottom:2px solid #1a3a6c;padding-bottom:8px;font-size:22px}}
h2{{color:#1a3a6c;margin-top:28px;font-size:17px}}
.card{{background:#f7f9fc;border-left:4px solid #1a3a6c;padding:14px 18px;margin:12px 0;border-radius:4px}}
.meta{{display:inline-block;background:#e8eef7;color:#1a3a6c;padding:2px 10px;border-radius:12px;font-size:13px;margin-right:6px}}
a{{color:#1a6cc8}}
</style>
</head>
<body>
<h1>{school} - {en}</h1>
<div>
<span class="meta">学位：{deg}</span>
<span class="meta">{stem_label}</span>
</div>
<h2>项目概览</h2>
<div class="card">{overview}</div>
<h2>学制与课程</h2>
<div class="card">{dur}</div>
<h2>申请截止</h2>
<div class="card">{ddl}</div>
<h2>语言要求</h2>
<div class="card">{lang}</div>
<h2>标化与录取要求</h2>
<div class="card">{test_cls}</div>
<h2>学费与资助</h2>
<div class="card">{tui}</div>
<h2>申请材料与研究方向</h2>
<div class="card">{requirements}</div>
<h2>研究领域</h2>
<div class="card">{research}</div>
<h2>来源</h2>
<div class="card">{source}</div>
</body>
</html>"""

PROGRAMS = [
    {
        "id": "yale-mbb-phd",
        "s": "yale",
        "n": "分子生物物理与生物化学博士（经 BBS BQBS 通道）",
        "en": "PhD in Molecular Biophysics and Biochemistry (Yale University, Department of Molecular Biophysics and Biochemistry, Graduate School of Arts and Sciences; located in New Haven, CT; Dec 1, 2026 11:59pm ET; GRE Not Accepted; TOEFL iBT 100; ETS 3987; PhD via Combined Program in Biological and Biomedical Sciences BQBS track; 12-month stipend + tuition + healthcare; 9 BBS tracks)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (New Haven, Connecticut). MB&B participates in the Combined Program in the Biological and Biomedical Sciences (BBS). Applicants select BQBS Track (Biochemistry, Quantitative Biology, Biophysics and Structural Biology) in the application. BQBS first-year students: core coursework + lab rotations. Thesis advisor declared after first year. En route MA available. No terminal MS - PhD only.",
        "ddl": "Fall 2027 matriculation: **December 1, 2026 11:59pm ET** (BBS deadline). Fee waiver request deadline: January 2, 2027. Admissions decisions February-March 2027. Reply deadline April 15, 2027. LORs may arrive after deadline but are encouraged promptly.",
        "lang": "TOEFL iBT minimum: 100 (paper 600 / computer 250). IELTS Academic also accepted. Speaking minimum: 26 (pre-Jan 21, 2026) / 5.5 (on/after Jan 21, 2026) for teaching; IELTS Speaking 8.0 required for teaching appointment. Exemption: undergraduate degree from institution where English is primary language of instruction with 3+ years in residence. ETS institution code 3987 (any department code).",
        "test": {"cls": "GRE GENERAL NOT ACCEPTED (Yale GSAS Standardized Testing Requirements table last updated June 29, 2026: 'Biochemistry, Quantitative Biology, Biophysics and Structural Biology (BBS) | Not Accepted. Do not submit GRE General Test scores. GRE General Test scores will not be considered when applications are reviewed. If you submit scores, they will not be reviewed.' GRE Subject Test: not required. Required for BQBS track: firm foundation in sciences - biochemistry; general, organic and physical chemistry; physics; calculus. Transcripts. LORs (no specific deadline, prompt submission). Statement of Purpose. BBS Track selection. Note: Yale Chemistry PhD remains GRE Required (separate program)."},
        "tui": "Yale PhD students are normally fully-funded. Twelve-month stipend to cover living expenses; fellowship covers full cost of tuition and student healthcare. 9 BBS tracks each with own admissions committee. MB&B research areas: DNA dynamics (replication, recombination, transposition, functional genomics), RNA catalysis, RNA-protein interactions, ribonucleoproteins (spliceosomes, ribosome), protein folding and design, transmembrane signaling, cell cycle control, cytoskeletal dynamics, neuroscience, structural and computational biology. Department contact: Wendy Gilbert DGS; Michelle Pavlik Dept Registrar; Deana Ralston BQBS Registrar bqbs.registrar@yale.edu.",
        "url": "details/yale-mbb-phd.html",
    },
    {
        "id": "harvard-biophysics-phd",
        "s": "harvard",
        "n": "生物物理博士",
        "en": "PhD in Biophysics (Harvard University, Harvard Integrated Life Sciences; located in Cambridge/Boston, MA; Dec 1, 2026 5pm ET; GRE General Not Accepted; GRE Subject not required; TOEFL iBT/IELTS; SOP + 500-word Personal Statement; virtual interview late Jan/early Feb + in-person March; ETS 3451)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Cambridge/Boston, Massachusetts). Harvard Integrated Life Sciences (HILS) member. Interdisciplinary training in biophysical, chemical, and molecular concepts and techniques. Flexibility to use quantitative science background to approach biological problems. MD-PhD option through Harvard/MIT HST. En route AM available.",
        "ddl": "Fall 2027 matriculation: **December 1, 2026 5:00 PM EST**. Late applications not considered. MD-PhD pre-applicants: pre-application by October 15 for Harvard Medical School MD-PhD Program. Interview: Virtual Interview Week in late January/early February; In-Person Recruitment Visit Weekend in March.",
        "lang": "TOEFL iBT or IELTS Academic required for non-native English speakers whose undergraduate degree is from institution where English is not primary language of instruction. Scores no older than 2 years prior to application deadline. Harvard Griffin GSAS accepts only IBT TOEFL or IELTS. ETS institution code 3451 (Harvard Griffin GSAS), no department code required.",
        "test": {"cls": "GRE GENERAL NOT ACCEPTED (Harvard Biophysics Program Requirements page: 'The Biophysics Program no longer requires applicants to report scores from the General Test of the GRE. The Biophysics Program does not require scores from one of the GRE Subject Tests.' GSAS program page confirms: GRE General = Not Accepted. Required: strong background in physical sciences, especially chemistry, physics, mathematics; Statement of Purpose (focus on past research experience and future interests); 500-word Personal Statement (aspects of experience that might be exceptional, challenges overcome); 3 LOR; transcripts. Note: legacy FAQ lists average GRE 2017 entering class Verbal 164/94%, Quant 168/95%, Writing 5/93% (admitted distribution, not minimum threshold; scores no longer required since 2018-19 cycle)."},
        "tui": "Harvard Biophysics is one of 14 HILS PhD programs/faculties/subject areas facilitating cross-disciplinary collaboration. Graduates secure positions at Harvard Medical School, Wesleyan, Caltech (academia); Novartis Oncology, Amgen, Insight Data Science (industry). Research spans: single-molecule biophysics, structural biology, computational biophysics, biophotonics, membrane biophysics, neuroscience biophysics, systems biology. MD/PhD coordination with Harvard/MIT MD-PhD Program at HMS. Contact: Biophysics Program Administrator.",
        "url": "details/harvard-biophysics-phd.html",
    },
    {
        "id": "uchicago-biochem-phd",
        "s": "uchicago",
        "n": "生物化学与分子生物物理博士",
        "en": "PhD in Biochemistry and Molecular Biophysics (University of Chicago, Biological Sciences Division, Molecular Biosciences cluster; located in Chicago, IL; Dec 1, 2026; GRE optional but program considers submitted GRE scores; TOEFL iBT 100 / IELTS 7; 3 LOR; $90 fee; ETS 1832; full funding)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Chicago, Illinois). Part of Molecular Biosciences cluster within Biological Sciences Division (BSD). Other Molecular Biosciences programs: Cell and Molecular Biology; Development, Regeneration, and Stem Cell Biology; Genetics, Genomics, and Systems Biology; Human Genetics. First year: core courses + rotations. Thesis advisor by end of first year. Interdisciplinary research with affiliated labs (Argonne National Lab, Marine Biological Laboratory).",
        "ddl": "Autumn Quarter 2027 entry: application opens early September 2026; **deadline December 1, 2026**. All materials including supplementary and LORs due December 1. Late applications reviewed only at Dean for Graduate Affairs discretion. Responses to offers due April 15. Interview weekends in February.",
        "lang": "TOEFL iBT minimum: 100 overall with subscores no less than 26 in Reading/Writing/Listening and no less than 22 in Speaking (tests taken before January 21, 2026). Revised 1-6 scale (on/after January 21, 2026): no less than 5 in Reading and Writing, 5.5 in Listening, 4.5 in Speaking. IELTS minimum: 7 overall with subscores of 7 each. ETS institution code 1832 (no department code).",
        "test": {"cls": "GRE OPTIONAL BUT SUBMITTED SCORES ARE REVIEWED (UChicago Biosciences How to Apply page: 'The University of Chicago recognizes that standardized test scores may not be good indicators of ability or potential for all candidates; submission of GRE scores is therefore optional. The majority of our graduate programs have elected not to use submitted GRE scores as part of the review process. The PhD programs in Public Health Sciences, Medical Physics, Biochemistry, and Molecular Biophysics DO consider submitted GRE scores.' This is an explicit exception within BSD - most BSD programs ignore GRE, but Biochemistry/Molecular Biophysics will read them. GRE Subject optional. Scores valid within 5 years (Dec 1, 2021 or later for Autumn 2027 entry). Required: Candidate Statement max 2 pages; 3 LOR (electronic via application; Interfolio must support per-letter upload); postsecondary transcripts (scanned, original language with English translation; unofficial acceptable for review, official required before matriculation); $90 fee (waivable)."},
        "tui": "UChicago BSD PhD programs are fully-funded. Stipend + tuition remission + health insurance. 97 students per class, 365 training faculty, 240 undergraduate degree institutions. Affiliated institutions: Argonne National Laboratory, Marine Biological Laboratory (Woods Hole), Enrico Fermi Institute. Research areas: molecular mechanisms of gene regulation, structural biology, biophysics, enzyme mechanisms, chromosome biology, signal transduction, cell cycle, developmental biology. Note: UChicago also has separate Graduate Program in Biophysical Sciences (PSD, not BSD) - this entry is BSD Molecular Biosciences Biochemistry/Molecular Biophysics.",
        "url": "details/uchicago-biochem-phd.html",
    },
    {
        "id": "columbia-biosci-phd",
        "s": "columbia",
        "n": "生物科学博士（含生化/生物物理子方向）",
        "en": "PhD in Biological Sciences (Columbia University, Department of Biological Sciences, Graduate School of Arts and Sciences; located in New York, NY; Dec 2, 2026 11:59pm ET; GRE General No (no longer required); 3 LOR; must list 3 potential faculty advisors; TOEFL iBT 100 / IELTS 7.5; ETS 2162; ~20 admits/year; subfields include Structural Biology, Biophysics, Chemical Biology and Biochemistry)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Morningside campus, 116th St., Manhattan; some labs at Manhattanville 125th St. or CUIMC 168th St.). Interdisciplinary PhD training. First year: intensive core course covering structural biochemistry, cell biology, genetics, neurobiology, molecular biology, developmental biology, immunology, bioinformatics; preresearch seminar; lab rotations. Dissertation sponsor chosen after consultation; intensive research following spring term of first year. PhD advisory committee = sponsor + 2 other faculty. ~20 admits per year.",
        "ddl": "Fall 2027 matriculation: application system reopens September 2026; **deadline December 2, 2026 11:59pm ET**. Open House/Interviews: February 5-6, 2027 (first in-person); February 26-27, 2027 (second in-person). Offers late February-early March. Response deadline April 15, 2027. Note: Columbia CUIMC programs are separate applications - applicants may apply to both Biological Sciences (Morningside) and a CUIMC program, but they are separate applications.",
        "lang": "TOEFL iBT minimum: 100 (paper 600). IELTS minimum: 7.5. Duolingo English Test also accepted. Required for applicants whose undergraduate degree is from institution in country whose official language is not English. Master's degree from US institution does NOT automatically waive TOEFL (must have Bachelor's degree from US institution). ETS institution code 2162 (COLUMBIA U GRAD SCH ART&SCI/MORNG). Department code: GSAS uses no department code (use 99 or 00 if ETS requires).",
        "test": {"cls": "GRE GENERAL NO LONGER REQUIRED (Columbia Biology PhD FAQ: 'The GRE is no longer required.' GSAS Biological Sciences program page: 'GRE General: No.' Required: 3 letters of recommendation (at least 2 from academic recommenders); Statement of Purpose; Resume/CV (required); Writing Sample NOT required; applicants must enter at least 3 names of program faculty who might serve as potential advisor (selected from research faculty list); primary program subfield selection. Subfields: Cancer and Disease Biology; Cell/Developmental/Stem Cell Biology; Evolutionary Biology/Comparative Genomics/Population Genetics; Genome Organization/Maintenance/Expression; Genomics/Computational/Systems Biology; Microbiology; Neuroscience; Structural Biology, Biophysics, Chemical Biology and Biochemistry. Note: legacy 2004 Petersons PDF said GRE Subject (biology/biochemistry/chemistry/physics) required - outdated."},
        "tui": "All accepted PhD students receive tuition exemption + fees + generous stipend + medical insurance. Special fellowships available for women and members of underrepresented groups. Faculty mentors from Department of Biological Sciences + selected faculty from Department of Chemistry + Columbia University Medical School. Labs on Morningside, Manhattanville, and CUIMC campuses. Contact: gsas_apply@columbia.edu with subject 'Question Not Answered on Website'. Address: GSAS Office of Admissions, 108 Low Library, 535 W. 116th St., MC 4303, NY, NY 10027. Email: biology@columbia.edu. Note: no terminal MS - PhD only.",
        "url": "details/columbia-biosci-phd.html",
    },
    {
        "id": "caltech-bmb-phd",
        "s": "caltech",
        "n": "生物化学与分子生物物理博士",
        "en": "PhD in Biochemistry and Molecular Biophysics (Caltech, Division of Chemistry and Chemical Engineering; located in Pasadena, CA; Dec 1, 2026; GRE optional per CCE (absence not penalized, submitted considered); TOEFL/PTE/IELTS/Duolingo; 3 LOR + CV + SOP; no minimum GPA; fall only; one option per cycle)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Pasadena, California). BMB is one of six options within the Division of Biology and Biological Engineering (BBE) but administered by CCE. Other BBE options: Bioengineering, Biology, Computation and Neural Systems, Neurobiology. Each admission cycle: applicant may apply to only ONE academic option. Small cohort, close faculty mentorship. Research rotations, thesis research. No terminal MS admitted in BMB (PhD only).",
        "ddl": "Fall 2027 matriculation: application opens October 15; **deadline December 1, 2026**. Online application: https://apply.graduate.caltech.edu/apply/. Zoom interview invitations: December 10; Zoom interviews: December 11-12; In-person interview invitations: December 22; In-person interviews: January 29-30; Admissions decisions: early-mid February. No winter/spring/summer admission (fall only). Late applications may be considered but at disadvantage for financial aid.",
        "lang": "TOEFL, PTE Academic, IELTS, or Duolingo English Test accepted for non-native English speakers who have not received degree from university where English is primary language of instruction. Self-reported scores accepted. Caltech does not state minimum score. ETS institution code 4034.",
        "test": {"cls": "GRE OPTIONAL PER CCE DIVISION (Caltech CCE Graduate Admissions page: 'GRE scores are not required. Absence of GRE scores will not be negatively considered for otherwise qualified applicants. If an applicant believes that GRE scores strengthen the application and chooses to submit them, submitted GRE scores will be considered. Caltech is reviewing the future use of the GRE at the institution.' Note: Caltech Biology option page separately says 'GRE general test is strongly recommended' and 'encouraged but not required' for Subject - but BMB lives under CCE, which has the more lenient optional policy. Required: bachelor's degree or equivalent; transcripts from each college/university attended; 3 letters of recommendation; CV; Statement of Purpose. No minimum GPA stated (most successful applicants have US GPA 3.5/4.0 or top 5-10% of class - admitted distribution, not minimum). Note: applicants who already hold PhD will not be considered for second PhD."},
        "tui": "Caltech PhD students receive full funding: tuition + stipend + health insurance. 5-year guaranteed support independent of domestic/international. CCE division includes: Biochemistry and Molecular Biophysics; Chemical Engineering; Chemistry. BBE division includes: Bioengineering, Biology, CNS, Neurobiology. Contact: Graduate Office, gradofc@caltech.edu, (626) 395-6346. Research areas: structural biology, single-molecule biophysics, enzymology, molecular genetics, genomics, developmental biology, chemical biology, biophysics of membranes, protein folding. Note: only one application option per cycle - choosing BMB means cannot also apply to Biology/CNS/Neurobiology.",
        "url": "details/caltech-bmb-phd.html",
    },
]

PAGES = {
    "yale-mbb-phd": {
        "school": "耶鲁大学",
        "en": "PhD in Molecular Biophysics and Biochemistry (Yale University, via BBS BQBS track)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biochemistry / Molecular Biophysics / CIP 26.0202)",
        "dur": "Typically 5-6 years. PhD via BBS Combined Program (BQBS Track). Y1: core courses + rotations. Thesis advisor after Y1. En route MA. PhD only (no terminal MS).",
        "ddl": "Fall 2027: **December 1, 2026 11:59pm ET** (BBS deadline). Fee waiver: January 2, 2027. Decisions Feb-Mar. Reply April 15, 2027.",
        "lang": "TOEFL iBT 100 (paper 600). IELTS Academic. Speaking min 26 (pre-2026-01-21) / 5.5 (post) for teaching; IELTS Speaking 8.0 for teaching. ETS 3987 (any dept code). Exemption: 3+ years at English-instruction institution.",
        "test_cls": "GRE GENERAL NOT ACCEPTED per GSAS 2026-06-29 table (BQBS track). GRE Subject not required. Required: firm foundation in biochemistry; general/organic/physical chemistry; physics; calculus. Transcripts. LORs. SOP. BQBS Track selection. Note: Yale Chemistry PhD remains GRE Required (separate program).",
        "tui": "Fully funded. 12-month stipend + tuition fellowship + healthcare. 9 BBS tracks each with own admissions committee. Research: DNA dynamics, RNA catalysis, RNA-protein interactions, ribonucleoproteins (spliceosome, ribosome), protein folding/design, transmembrane signaling, cell cycle, cytoskeletal dynamics, neuroscience, structural/computational biology. Contact: Wendy Gilbert DGS; bqbs.registrar@yale.edu.",
        "overview": "Yale Department of Molecular Biophysics and Biochemistry (MB&B), GSAS. PhD in MB&B administered through the Combined Program in Biological and Biomedical Sciences (BBS) - applicants select BQBS track (Biochemistry, Quantitative Biology, Biophysics and Structural Biology).",
        "requirements": "GSAS online application. Select BBS as program and BQBS Track. SOP. LORs (no specific deadline). Transcripts. TOEFL/IELTS. BQBS prerequisite foundation.",
        "research": "DNA dynamics (replication/recombination/transposition/functional genomics), RNA catalysis, RNA-protein interactions, ribonucleoproteins, protein folding and design, transmembrane signaling, cell cycle control, cytoskeletal dynamics, neuroscience, structural biology, computational biology.",
        "source": "https://gsas.yale.edu/programs-of-study/molecular-biophysics-biochemistry ; https://gsas.yale.edu/programs-of-study/biological-biomedical-sciences-bbs ; https://gsas.yale.edu/admissions/phdmasters-application-process/standardized-testing-requirements ; https://gsas.yale.edu/admissions/phdmasters-application-process/dates-deadlines",
    },
    "harvard-biophysics-phd": {
        "school": "哈佛大学",
        "en": "PhD in Biophysics (Harvard University, Harvard Integrated Life Sciences)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biophysics / CIP 26.0301)",
        "dur": "Typically 5-6 years. HILS member. Interdisciplinary training in biophysical/chemical/molecular concepts. MD-PhD option via Harvard/MIT HST. En route AM. PhD only.",
        "ddl": "Fall 2027: **December 1, 2026 5:00 PM EST**. MD-PhD pre-app October 15. Virtual interview late Jan/early Feb; in-person March.",
        "lang": "TOEFL iBT or IELTS Academic for non-native English speakers (undergrad from non-English-instruction institution). Scores no older than 2 years. ETS 3451 (Harvard Griffin GSAS), no dept code.",
        "test_cls": "GRE GENERAL NOT ACCEPTED (GSAS 2026-07-01). GRE Subject not required. Required: strong physical sciences background (chemistry, physics, math); SOP (research experience + future interests); 500-word Personal Statement; 3 LOR; transcripts. Legacy 2017 admitted distribution V164/Q168/W5 (not minimum threshold).",
        "tui": "Fully funded. HILS member (14 life science PhD programs). Graduates: Harvard Medical School, Wesleyan, Caltech (academia); Novartis Oncology, Amgen, Insight Data Science (industry). Research: single-molecule biophysics, structural biology, computational biophysics, biophotonics, membrane biophysics, neuroscience biophysics, systems biology.",
        "overview": "Harvard Biophysics Graduate Program, part of Harvard Integrated Life Sciences (HILS). Broad training in biophysical, chemical, and molecular concepts applied to outstanding problems in biology. Quantitative science background encouraged.",
        "requirements": "GSAS online application. SOP. 500-word Personal Statement. 3 LOR. Transcripts. TOEFL/IELTS. MD-PhD pre-application via HMS.",
        "research": "Single-molecule biophysics, structural biology, computational biophysics, biophotonics, membrane biophysics, neuroscience biophysics, systems biology, physical chemistry of biomolecules.",
        "source": "https://biophysics.fas.harvard.edu/requirements ; https://gsas.harvard.edu/program/biophysics ; https://biophysics.fas.harvard.edu/faq ; https://gsas.harvard.edu/apply/applying-degree-programs/gre",
    },
    "uchicago-biochem-phd": {
        "school": "芝加哥大学",
        "en": "PhD in Biochemistry and Molecular Biophysics (University of Chicago, Biological Sciences Division)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biochemistry / CIP 26.0202)",
        "dur": "Typically 5-6 years. Molecular Biosciences cluster. Y1: core courses + rotations. Thesis advisor by end of Y1. Interdisciplinary with Argonne National Lab and Marine Biological Laboratory.",
        "ddl": "Autumn 2027: opens early September 2026; **deadline December 1, 2026**. All materials incl. LORs due Dec 1. Late apps at Dean discretion. Responses due April 15. Interview weekends February.",
        "lang": "TOEFL iBT 100 overall (pre-2026-01-21): subscores 26 R/W/L, 22 S. Revised 1-6 scale (post-2026-01-21): 5 R/W, 5.5 L, 4.5 S. IELTS 7 overall (7 each subscore). ETS 1832 (no dept code).",
        "test_cls": "GRE OPTIONAL BUT SUBMITTED SCORES ARE REVIEWED (Biosciences page explicitly names Biochemistry and Molecular Biophysics among BSD programs that DO consider submitted GRE scores - unlike most BSD programs that ignore them). GRE Subject optional. Scores valid 5 years. Required: Candidate Statement max 2 pages; 3 LOR; transcripts; $90 fee (waivable).",
        "tui": "Fully-funded BSD PhD. Stipend + tuition + health insurance. 97 students/class, 365 training faculty. Affiliated: Argonne National Lab, Marine Biological Laboratory (Woods Hole), Enrico Fermi Institute. Note: UChicago also has separate Biophysical Sciences program in PSD (not BSD) - this entry is BSD Molecular Biosciences.",
        "overview": "University of Chicago Biological Sciences Division, Molecular Biosciences cluster. PhD in Biochemistry and Molecular Biophysics. Interdisciplinary research in molecular mechanisms of gene regulation, structural biology, biophysics, enzyme mechanisms, chromosome biology.",
        "requirements": "BSD online application (apply-bsd.uchicago.edu). Candidate Statement max 2 pages. 3 LOR. Transcripts. TOEFL/IELTS. $90 fee. Select Biochemistry and Molecular Biophysics as Molecular Biosciences program.",
        "research": "Molecular mechanisms of gene regulation, structural biology, biophysics, enzyme mechanisms, chromosome biology, signal transduction, cell cycle, developmental biology.",
        "source": "https://biosciences.uchicago.edu/admissions/how-to-apply ; https://biosciences.uchicago.edu/admissions/how-to-apply/faq ; https://apply-bsd.uchicago.edu/apply/ndv/",
    },
    "columbia-biosci-phd": {
        "school": "哥伦比亚大学",
        "en": "PhD in Biological Sciences (Columbia University, Department of Biological Sciences, GSAS)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biological Sciences / Biochemistry / Biophysics / CIP 26.0202)",
        "dur": "Typically 5-6 years. Y1: intensive core course (structural biochemistry, cell biology, genetics, neurobiology, molecular biology, developmental biology, immunology, bioinformatics) + preresearch seminar + rotations. Thesis sponsor after Y1 spring. ~20 admits/year. PhD only.",
        "ddl": "Fall 2027: reopens September 2026; **deadline December 2, 2026 11:59pm ET**. Open House: February 5-6 and 26-27, 2027. Offers late Feb-early March. Response April 15, 2027. CUIMC programs are separate applications.",
        "lang": "TOEFL iBT 100 (paper 600). IELTS 7.5. Duolingo accepted. Required if undergrad from non-English-instruction country. US Master's does NOT waive (must have US Bachelor's). ETS 2162 (no dept code; use 99 or 00 if ETS requires).",
        "test_cls": "GRE GENERAL NO LONGER REQUIRED (Biology FAQ: 'The GRE is no longer required.' GSAS program page: 'GRE General: No.'). Required: 3 LOR (at least 2 academic); SOP; Resume/CV (required); Writing Sample NOT required; must list at least 3 potential faculty advisors; primary subfield selection. 8 subfields incl. Structural Biology, Biophysics, Chemical Biology and Biochemistry.",
        "tui": "All accepted PhD students: tuition + fees + stipend + medical insurance. Special fellowships for women and underrepresented groups. Faculty from Biological Sciences + Chemistry + CUIMC. Labs on Morningside, Manhattanville, CUIMC campuses. Contact: gsas_apply@columbia.edu; biology@columbia.edu. Address: 108 Low Library, MC 4303, NY, NY 10027.",
        "overview": "Columbia University Department of Biological Sciences PhD (Morningside campus). Interdisciplinary PhD training. Subfields include Structural Biology, Biophysics, Chemical Biology and Biochemistry. No separate Biochemistry PhD - Biochemistry is a subfield of Biological Sciences.",
        "requirements": "GSAS online application. SOP. Resume/CV. 3 LOR. List 3 potential faculty advisors. Subfield selection. Transcripts. TOEFL/IELTS/Duolingo.",
        "research": "Cancer and disease biology; cell/developmental/stem cell biology; evolutionary biology; genome organization; genomics/computational/systems biology; microbiology; neuroscience; structural biology, biophysics, chemical biology and biochemistry.",
        "source": "https://www.gsas.columbia.edu/content/biological-sciences ; https://biology.columbia.edu/content/phd-program-faq ; https://biology.columbia.edu/content/apply-now ; https://www.gsas.columbia.edu/content/admissions-deadlines",
    },
    "caltech-bmb-phd": {
        "school": "加州理工学院",
        "en": "PhD in Biochemistry and Molecular Biophysics (Caltech, Division of Chemistry and Chemical Engineering)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biochemistry / Molecular Biophysics / CIP 26.0202)",
        "dur": "Typically 5-6 years. Small cohort, close mentorship. One application option per cycle. BMB administered by CCE division. Research rotations + thesis. PhD only (no terminal MS).",
        "ddl": "Fall 2027: opens October 15; **deadline December 1, 2026**. Zoom interviews December 11-12; in-person January 29-30; decisions early-mid February. Fall only. Late apps at disadvantage.",
        "lang": "TOEFL/PTE Academic/IELTS/Duolingo accepted. Self-reported scores. Caltech states no minimum. ETS 4034.",
        "test_cls": "GRE OPTIONAL PER CCE (CCE page: 'GRE scores are not required. Absence will not be negatively considered. If applicant believes scores strengthen application and chooses to submit, they will be considered.' Note: Biology option says GRE strongly recommended, but BMB is CCE-administered. Required: bachelor's; transcripts; 3 LOR; CV; SOP. No minimum GPA (most admitted GPA 3.5/4.0 or top 5-10% - admitted distribution, not threshold). Existing PhD holders not considered.",
        "tui": "Full funding: tuition + stipend + health insurance. 5-year guaranteed support regardless of domestic/international. CCE division includes BMB/ChE/Chemistry. Contact: gradofc@caltech.edu, (626) 395-6346. Research: structural biology, single-molecule biophysics, enzymology, molecular genetics, genomics, developmental biology, chemical biology, membrane biophysics, protein folding.",
        "overview": "Caltech Biochemistry and Molecular Biophysics (BMB) option, administered by Division of Chemistry and Chemical Engineering (CCE). Small interdisciplinary program. Note: only one application option per admission cycle.",
        "requirements": "Caltech Graduate Office online application. SOP. CV. 3 LOR. Transcripts from every institution. TOEFL/PTE/IELTS/Duolingo. Self-reported GRE (optional).",
        "research": "Structural biology, single-molecule biophysics, enzymology, molecular genetics, genomics, developmental biology, chemical biology, membrane biophysics, protein folding, biophysics of membranes.",
        "source": "https://www.bbe.caltech.edu/academics/applying-to-caltech-2026-2027 ; https://cce.caltech.edu/graduate/graduate-admissions ; https://gradoffice.caltech.edu/admissions/faq-applicants ; https://www.bbe.caltech.edu/academics/biology/graduate-admissions",
    },
}

# 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)}")
