# -*- coding: utf-8 -*-
"""Round 260: batch add 5 Chemistry PhD (third tier: UCSD / UCLA / WashU / Rice / Vanderbilt)
- UCSD Chemistry PhD (Dec 3, 2026; GRE General and Subject not required and not used; TOEFL; 3.0 GPA; Fall only; ETS 4833; 5+ years)
- UCLA Chemistry PhD (Dec 1, 2026 11:59pm PST; GRE not required per grad.ucla.edu 2027-2028 catalog, dept says encouraged; 3 LOR; ETS R4837/4837; dept 62; MS only under exceptional circumstances; average GRE Quant percentile 80-85% admitted distribution)
- WashU Chemistry PhD (Arts & Sciences unified first week of Dec; 72 units; 5 years; 3.0 GPA; 1 year minimum residence; Common Track AI; GRE policy not explicitly listed on dept page)
- Rice Chemistry PhD (Dec 1, 2026 11:59pm EST; GRE optional strongly recommended per Graduate School; 3 LOR; TOEFL iBT 90/paper 620/computer 250; $85 fee waived TX/LA/AR/OK/NM; PhD only; ETS 6609)
- Vanderbilt Chemistry PhD (Priority Dec 1, 2026; Final Dec 15, 2026; GRE optional/not required per dept; 3 LOR; TOEFL/IELTS/Duolingo; applications open Aug 1; Fall only)
Key finding: third tier returns to GRE-free/optional pattern - UCSD explicitly not required and not used, UCLA grad division says not required (dept says encouraged), Rice optional strongly recommended, Vanderbilt optional, WashU dept page silent. This contrasts sharply with second tier where Columbia/Yale/Caltech/Cornell all REQUIRED.
"""
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": "ucsd-chem-phd",
        "s": "ucsd",
        "n": "化学博士",
        "en": "PhD in Chemistry (UC San Diego, Department of Chemistry and Biochemistry; located in La Jolla, CA; GRE General and Subject not required and will not be used in evaluation; 3.0 GPA minimum; Fall quarter only; over 300 graduate students; average just over five years to graduation)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Average just over five years to graduation; Fall quarter entrance only; on-campus residential (La Jolla, CA); during first year students take courses, begin teaching apprenticeships, choose research advisors, and embark on thesis research; students whose native language is not English must pass an English proficiency examination; 300+ graduate students in department",
        "ddl": "Fall 2027 (September quarter matriculation): **Deadline December 3, 2026** per UCSD Department of Chemistry and Biochemistry Doctoral Program Admissions page (PhD Admissions Deadline for Fall 2026 was December 3, 2025; cycle extends to Fall 2027 by same date pattern). Application opens in September and closes in December. Admissions committee reviews files continuously beginning in late November. Invitations to visitation weekends around January; in-person interviews on campus in February or March. Students have until April 15th to accept official admissions offer from GEPA.",
        "lang": "TOEFL iBT, IELTS, PTE, or Duolingo English Test required for international applicants whose native language is not English. Students who have studied full-time for one uninterrupted academic year at a university-level institution in which English is the language of instruction and in a country in which English is a dominant language are exempt. For Joint Doctoral Program with SDSU: TOEFL iBT Speaking subscore 23 and above; IELTS Speaking minimum subscore 7; PTE Speaking minimum subscore 65. ETS institution code 4833 (UC San Diego).",
        "test": {"cls": "GRE GENERAL AND SUBJECT NOT REQUIRED (UCSD Chemistry and Biochemistry Doctoral Program Admissions page: 'The GRE General & GRE Subject are not required and will not be used in the evaluation of your application.' Note: older catalog.ucsd.edu/archive page stating GRE general required for MS and doctoral is outdated and superseded by current department admissions page. Required materials: online application via connect.grad.ucsd.edu/apply, transcripts, letters of recommendation (recommended submitting as soon as complete even if LOR still in transit), statement of purpose, research interests, additional questions about educational experiences (recommended). Minimum GPA 3.0 overall. Solid training in chemical sciences as judged by undergraduate record."},
        "tui": "UCSD Chemistry PhD students receive multi-year fully-funded support. Over 300 bright and talented graduate students with diverse backgrounds from all over the world. Programs of study tailored to individual students based on prior training and research interests. During first year: courses, teaching apprenticeships, research advisor selection, thesis research start. English proficiency exam required for non-native English speakers. Programs offered: Doctoral, Masters, and Joint Doctoral degrees (with San Diego State University). Joint Doctoral Program deadline December 10 (later than standalone PhD December 3). Department located in La Jolla, California. Applications reviewed continuously beginning late November; good news offered to recruited students as soon as possible.",
        "url": "details/ucsd-chem-phd.html",
    },
    {
        "id": "ucla-chem-phd",
        "s": "ucla",
        "n": "化学博士",
        "en": "PhD in Chemistry (University of California Los Angeles, Department of Chemistry and Biochemistry; located in Los Angeles, CA; GRE not required per 2027-2028 grad.ucla.edu catalog but dept encourages for Fall 2027; 3 LOR; ETS R4837/4837 dept 62; MS only under exceptional circumstances; average GRE Quant percentile 80-85% admitted distribution; two separate programs: Chemistry and BMSB)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years; admission limited to Fall; on-campus residential (Los Angeles, CA); applicants admitted to MS program only under exceptional circumstances; two separate PhD programs: Chemistry Graduate Program and Biochemistry, Molecular and Structural Biology (BMSB) Graduate Program; students may apply to either but not both at same time; written and oral qualifying examinations coupled with Chemistry and Biochemistry 258 graduate student seminar (presentation of proposed dissertation research)",
        "ddl": "Fall 2027 (September): **Deadline December 1, 2026 at 11:59 PM Pacific Standard Time** for Chemistry per UCLA Department of Chemistry and Biochemistry How to Apply page. BMSB program deadline is December 5, 2026 at 11:59 PM PST. (Note: grad.ucla.edu 2027-2028 catalog lists Chemistry deadline as December 1, 2026; older 2013-2014 catalog page listed December 15 - superseded.) Fall admission only.",
        "lang": "TOEFL iBT or IELTS Academic per UCLA Graduate Division minimum requirements. ETS TOEFL institution code 4837; Chemistry department code 62; Biochemistry department code 34. GRE institution code R4837 (UCLA); Chemistry department code 0301; BMSB department code 0202. Required for international applicants whose native language is not English and who have not completed undergraduate degree at English-medium institution.",
        "test": {"cls": "GRE NOT REQUIRED PER 2027-2028 CATALOG (grad.ucla.edu 2027-2028 Admission Requirements for Graduate Major in Chemistry major code 0153: 'GRE: Not required.' However department page How to Apply states: 'While not required, GRE scores are encouraged for those applying to the Fall 2027 admission cycle. You may request that all official GRE scores be sent to the Department of Chemistry and Biochemistry.' Self-reported scores accepted on application; official GRE scores accepted after application deadline. Subject GRE not required for domestic applicants (US Citizens and Permanent Residents), but applicants may report if they choose. If taking multiple GRE exams, input best scores per section and upload all unofficial copies. Average GRE Quantitative Percentile score of accepted students is in the 80-85% range (admitted distribution, not minimum threshold). No minimum GRE score. Required materials: UCLA graduate application, transcripts, 3 letters of recommendation, statement of purpose, departmental application. Excellent undergraduate record required of all applicants. Note: older 2013-2014 catalog page stating 'General required for all and Subject required for international, recommended for all' is outdated and superseded by 2027-2028 catalog."},
        "tui": "UCLA Chemistry PhD students receive multi-year fully-funded support. Department offers two separate PhD programs: Biochemistry, Molecular and Structural Biology (BMSB) and Chemistry. Students may apply to either but not both at the same time. Students can also choose to focus on one of many interdisciplinary research areas. Address: 4009 Young Hall, Box 951569, Los Angeles, CA 90095-1569. Phone (310) 825-3150 Fax (310) 267-0204. Email cbgrad@ucla.edu. Major Code 0153. Admission limited to Fall. Applicants admitted to MS program only under exceptional circumstances. Written and oral qualifying examinations required prior to advancement to candidacy; written examination coupled with Chemistry and Biochemistry 258 graduate student seminar requiring presentation of proposed dissertation research.",
        "url": "details/ucla-chem-phd.html",
    },
    {
        "id": "wustl-chem-phd",
        "s": "wustl",
        "n": "化学博士",
        "en": "PhD in Chemistry (Washington University in St. Louis, College of Arts and Sciences, Department of Chemistry; located in St. Louis, MO; Arts & Sciences unified first week of December deadline; 72 units; 5 years; 3.0 GPA; 1 year minimum residence; Common Track Assistant in Instruction; 30 teaching/research faculty; ~100 graduate students)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5 years; Total Units Required 72; one year minimum residence requirement for PhD degree; on-campus residential (St. Louis, MO); most of time ordinarily spent doing research at Washington University; program extension possible with approval from program and Office of Graduate Studies, Arts & Sciences; minimum grade of C required for coursework to count toward degree; overall GPA at least 3.0; PhD students start on Common Track completing four engagements as AI (Assistant in Instruction) in potentially different courses, total 40 MER units (10 per experience) usually during years 1 and 2",
        "ddl": "Fall 2027 (August/September): **Application deadline generally falls during first week of December** per Washington University in St. Louis Bulletin Arts & Sciences Admissions page (Office of Graduate Studies, Arts & Sciences sets one application deadline for all doctoral programs each year; deadline generally falls during first week of December). Master's degree programs set their own deadlines (mid-December or mid-January). Students should use deadline date displayed on application page. Arts & Sciences rarely admits applicants for spring semester. Admitted students can request deferral of admission for up to one year with approval from admitting program and Office of Graduate Studies, Arts & Sciences (additional approval from Office of International Students & Scholars for international applicants).",
        "lang": "TOEFL iBT or IELTS Academic per Washington University in St. Louis Graduate School English proficiency requirement. Required for international applicants whose native language is not English and who have not completed degree at English-medium institution. ETS institution code per Washington University in St. Louis. Bulletin 2025-26 Chemistry PhD page lists minimum grade C required for coursework; overall GPA 3.0. International students requiring English proficiency exam must submit scores by deadline.",
        "test": {"cls": "GRE POLICY NOT EXPLICITLY LISTED ON CURRENT DEPT PAGE (Washington University in St. Louis Department of Chemistry current homepage and bulletin.wustl.edu Chemistry PhD 2025-26 PDF do not explicitly state GRE requirement status. Note: older bulletin 2016-17 page stating 'The Graduate Record Examination (GRE) is required for admission to graduate programs in Arts & Sciences' is legacy and likely superseded; current Arts & Sciences graduate admissions page does not list GRE as universal requirement. Required materials: online application through Office of Graduate Studies, Arts & Sciences, application, letters of recommendation (per program outline), application fee or fee waiver. Recommend applicants complete application and submit all materials well in advance of deadline. Admissions and financial aid awards are for a specific academic year; students who do not matriculate that year must normally reapply. **GRE status pending department page confirmation** - marked as half-verified page; students should verify current GRE policy on chemistry.washu.edu/graduate before applying."},
        "tui": "Washington University in St. Louis Chemistry PhD students receive multi-year fully-funded support. Department of Chemistry has tradition of excellence combining deep commitments to fundamental research and classroom teaching. Department is close-knit group of teacher-scientists providing superior education. Students gain strong foundation in core areas: organic, physical, inorganic, nuclear, and theoretical. Special emphases: organometallic, bioorganic, biophysical, macromolecular, polymer, environmental, and materials chemistry. State-of-the-art facilities include newly renovated Bryan Hall adding 28,000 square feet of research space. 30 teaching and research faculty; roughly 90 undergraduate chemistry majors; 100 graduate students; 20 postdoctoral research associates and research scientists. PhD in Chemistry is five-year program with most of time spent doing research at Washington University. Contact: Barbara Tessmer, Phone 314-935-7316, Email barbara22@wustl.edu. Common Track (AI) with 4 engagements across years 1-2 totaling 40 MER units.",
        "url": "details/wustl-chem-phd.html",
    },
    {
        "id": "rice-chem-phd",
        "s": "rice",
        "n": "化学博士",
        "en": "PhD in Chemistry (Rice University, Wiess School of Natural Sciences, Department of Chemistry; located in Houston, TX; GRE optional strongly recommended per Graduate School; 3 LOR; TOEFL iBT 90/paper 620/computer 250; $85 fee waived TX/LA/AR/OK/NM residents; PhD only - MS awarded in course of doctoral studies; ETS 6609; Fall only)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Directed only at PhD degree; some students choose to receive Master's degrees in course of doctoral studies; typically 5-6 years; Fall admission only; on-campus residential (Houston, TX); entering students should have high aptitude for chemistry, strong motivation to perform original scientific research, Bachelor's or Master's degree in Chemistry or closely related discipline; application typically opens around September 1; Texas/LA/AR/OK/NM residents and permanent address holders qualify for fee waiver",
        "ddl": "Fall 2027 (August): **Deadline December 1, 2026 at 11:59 PM Eastern Standard Time** per Rice University Department of Chemistry How to Apply page. Students wishing to apply after December 1 must contact Chemistry Department directly (gradchem@rice.edu). Application typically opens around September 1. Recommend requesting transcripts and letters of recommendation by October or earlier to allow recommenders time to submit materials before deadline. Fall only admission.",
        "lang": "TOEFL iBT minimum 90 overall; paper-based TOEFL minimum 620; computer-based TOEFL minimum 250. IELTS minimum (equivalent to TOEFL 90 iBT). Duolingo English Test also accepted. Required for applicants whose native language is not English. Exempt if proof of degree from accredited U.S. high school, college, or university. Scores must not be older than two years; official copy must be sent to Graduate School directly from ETS. ETS institution code 6609 (Rice University).",
        "test": {"cls": "GRE OPTIONAL STRONGLY RECOMMENDED (Rice Graduate and Postdoctoral Studies Application FAQ: 'General GRE is strongly recommended but not required: PhD in Chemistry, in Civil Engineering, in Environmental Engineering, and in Statistics.' Department FAQ: 'The GRE is optional and will not negatively impact your application if you do not submit scores. The Graduate Records Examinations (GRE) test is not required for admission; however, GRE scores will be accepted upon submission. Is the GRE Subject Test required? The GRE Subject test is optional and not required.' Required materials: online application, application fee $85 (waived for doctoral applicants who are graduates of institutions in Texas and bordering states Louisiana, Arkansas, Oklahoma and New Mexico, or who have permanent address in these states - does not include programs in Jones School of Business), minimum 3 letters of recommendation, official transcript(s) from all undergraduate and graduate schools attended, statement of purpose, TOEFL/IELTS/Duolingo scores for international applicants. Letters can be requested via email through application system or printed fax coversheet."},
        "tui": "Rice Chemistry PhD students receive multi-year fully-funded support. Rice graduate program in Chemistry is directed only at PhD degree; some students choose to receive Master's degrees in course of doctoral studies. Application fee $85; waived for doctoral applicants graduating from institutions in Texas and bordering states Louisiana, Arkansas, Oklahoma and New Mexico, or with permanent address in these states. Other fee waivers available per Graduate School. Applications generally open on or around September 1. Contact: gradchem@rice.edu. Located in Houston, Texas. Wiess School of Natural Sciences. Recommend starting application as early as possible; requesting transcripts and letters of recommendation by October or earlier allows recommenders time to submit before deadline. Research group rotation system typical of PhD training; original research component central to program.",
        "url": "details/rice-chem-phd.html",
    },
    {
        "id": "vanderbilt-chem-phd",
        "s": "vanderbilt",
        "n": "化学博士",
        "en": "PhD in Chemistry (Vanderbilt University, College of Arts and Science, Department of Chemistry; located in Nashville, TN; priority deadline Dec 1, 2026, final deadline Dec 15, 2026; GRE optional/not required per dept; 3 LOR; TOEFL/IELTS/Duolingo for international; applications open Aug 1; Fall only; holistic review emphasizing research experience)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years; Fall admission only; on-campus residential (Nashville, TN); applications traditionally open August 1 each year; PhD in chemistry is a research degree requiring meaningful research experiences (undergraduate research, summer REUs, internships); four Placement Examinations before coursework; research group rotation reports due Oct 26, Dec 21, Mar 15 for students entering Fall; PhD Qualifying Examination required by Oct 15 of third year (Mar 15 for Spring entrants)",
        "ddl": "Fall 2027 (August): **Priority Deadline December 1, 2026**; **FINAL Application Deadline December 15, 2026** per Vanderbilt Department of Chemistry PhD Admissions page. After December 15 no applications will be accepted. Applications traditionally open August 1 each year. Admissions committee meets regularly throughout fall and sometimes makes early offers of admission soon after application is complete. Note: Graduate School Application Requirements by Program table lists Chemistry PhD Fall Application Date as January 1, but department page explicitly states priority Dec 1 / final Dec 15 - department page is authoritative. Most programs release initial Fall admission offers by March 31 with response due April 15; programs may continue to extend offers after that date.",
        "lang": "TOEFL iBT, IELTS Academic, or Duolingo English Test required for international students. Required for applicants who have not completed degree at English-medium institution. Per Vanderbilt Graduate School: GRE scores valid if earned within five years to month of intended first term at Vanderbilt (e.g., no earlier than August 1 five years prior if applying for fall term). Vanderbilt does not accept expired scores, personal copies of scores, or attested or notarized score reports. Official scores must reach Graduate School by application deadline; scores take 2-3 business days (Monday-Friday) to link after ETS sends.",
        "test": {"cls": "GRE OPTIONAL / NOT REQUIRED (Vanderbilt Department of Chemistry PhD Admissions page: 'The GRE is not required for admission into the program.' Graduate School Application Requirements by Program table lists Chemistry PhD GRE Requirement Status as 'Optional.' Holistic review process takes into account grades (particularly in STEM coursework), GRE scores (if provided), letters of recommendation, and statement of purpose. A Ph.D. in chemistry is a research degree; meaningful research experiences are particularly important: undergraduate research, summer research experiences (such as NSF REUs), or internships. Recommendation letters from research mentors are very valuable. Required materials: up-to-date academic transcripts, minimum 3 letters of recommendation, Statement of Purpose (include previous research experience, current interests), any additional documentation applicant wishes to submit. Transcripts: unofficial accepted for application review. GRE scores valid 5 years; Vanderbilt does not accept expired scores, personal copies, or notarized reports; official scores must reach Graduate School by deadline; 2-3 business days to link."},
        "tui": "Vanderbilt Chemistry PhD students receive multi-year fully-funded support. PhD in chemistry is a research degree; meaningful research experiences are particularly important to review committee. Applications traditionally open August 1 each year. Priority deadline December 1, 2026; final deadline December 15, 2026. Admissions committee meets regularly throughout fall and sometimes makes early offers soon after application complete. Located in Stevenson Center, 7300 Stevenson Center, Nashville, Tennessee 37235-1822. Email: chemgrad@vanderbilt.edu. Per the 2009 PhD Program document (historical reference): First Year - take all four Placement Examinations before coursework; research group rotation reports due Oct 26, Dec 21, Mar 15. PhD Qualifying Examination required by Oct 15 of third year. Minimum formal coursework (with possible exception of one credit hour of seminar). Qualified applicants with bachelor's degrees eligible for admission. Transcripts (unofficial accepted for application review). Contact: chemgrad@vanderbilt.edu.",
        "url": "details/vanderbilt-chem-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> Round 260 - Chemistry PhD third tier sweep (UCSD / UCLA / WashU / Rice / Vanderbilt). Key finding: third tier returns to GRE-free/optional pattern - UCSD explicitly states GRE General and Subject are not required and will not be used in evaluation; UCLA grad division 2027-2028 catalog says GRE not required while dept page says encouraged for Fall 2027; Rice optional strongly recommended per Graduate School; Vanderbilt dept page explicitly says not required with Graduate School table listing optional; WashU dept page does not explicitly list GRE status (half-verified pending dept confirmation). This contrasts sharply with second tier (Columbia/Yale/Caltech/Cornell all REQUIRED) and confirms Chemistry PhD is a divided field with no uniform peer trend. All 5 programs maintain PhD-only or PhD-dominant admissions. All 5 programs offer multi-year fully-funded support.
</div>
</body>
</html>
"""

PAGES = {
    "ucsd-chem-phd": {
        "school": "UC San Diego, Department of Chemistry and Biochemistry",
        "en": "PhD in Chemistry",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Chemistry / CIP 40.0501)",
        "dur": "Average just over five years to graduation; Fall quarter entrance only; on-campus (La Jolla, CA); first year: courses, teaching apprenticeships, research advisor selection, thesis research start; English proficiency exam for non-native speakers; 300+ graduate students",
        "ddl": "Fall 2027 (September quarter): **Deadline December 3, 2026** per UCSD Chemistry Doctoral Admissions page. Application opens September. Visitation weekends around January; on-campus interviews February-March. April 15 reply date.",
        "lang": "TOEFL iBT, IELTS, PTE, or Duolingo. Exempt if 1 year full-time English-medium study in dominant-English country. JDP with SDSU: TOEFL Speaking 23+, IELTS Speaking 7+, PTE Speaking 65+. ETS 4833.",
        "test_cls": "GRE GENERAL AND SUBJECT NOT REQUIRED (dept page: 'The GRE General & GRE Subject are not required and will not be used in the evaluation of your application.'). Required: online application via connect.grad.ucsd.edu/apply, transcripts, LOR, SOP, research interests. Minimum GPA 3.0. Solid chemical sciences training. Older catalog archive page requiring GRE is superseded.",
        "tui": "Multi-year fully-funded support. Over 300 graduate students. Tailored programs of study. First year: courses, teaching apprenticeships, research advisor selection, thesis research. English proficiency exam for non-native speakers. Programs: Doctoral, Masters, Joint Doctoral (with SDSU, deadline Dec 10). Applications reviewed continuously late November onward; offers as soon as possible.",
        "overview": "The University of California San Diego Department of Chemistry and Biochemistry offers the Doctor of Philosophy in Chemistry. Per the Department Doctoral Program Admissions page: Thank you for your interest in the UC San Diego Chemistry Graduate Program. We have over 300 bright and talented graduate students with diverse backgrounds from all over the world. We offer programs for the Doctoral, Masters, and Joint Doctoral degrees. Application Deadline: PhD Admissions Deadline for Fall 2026 is December 3, 2025. General Application Information: To begin your online application or to check the status on your application, please visit connect.grad.ucsd.edu/apply. Information you enter may be saved at any time. The Admissions & Recruitment Committee recommends submitting your application as soon as you complete it, even if we have not yet received all your letters of recommendation. We also highly recommend that you answer some/all of our additional questions about your educational experiences. We review PhD files continuously beginning in late November and try to get the good news out to those we are recruiting to our program as soon as possible. If you have yet to hear from us, your file is still pending a final decision. GRE (not required): The GRE General & GRE Subject are not required and will not be used in the evaluation of your application. Per the Doctoral Program page: The goal of the Chemistry PhD is to prepare students for careers in science as researchers and educators by expanding their knowledge of chemistry while developing their ability for critical analysis, creativity, and independent study. A high graduation rate in an average of just over five years can be attributed to the quality of applicants admitted. Programs of study are tailored to the needs of individual students, based on their prior training and research interests. However, progress to a degree is generally similar for all students. During the first year, students take courses, begin their teaching apprenticeships, choose research advisors, and embark on their thesis research; students whose native language is not English must pass an English proficiency examination. Admissions: Creative, bright, and motivated students from diverse backgrounds are encouraged to apply. We admit for Fall quarter entrance only. Generally, the application will open in September and close is in December. The Admissions Committee reviews files individually and in comparison to others, and invitations to our visitation weekends are made around January. For those invited, in-person interviews will be on campus in either February or March. Those who receive the official admissions offer from the Division of Graduate Education and Postdoctoral Affairs (GEPA) have until April 15th to make a decision. The department is located in La Jolla, California.",
        "requirements": "<ul><li>Bachelor's degree in chemistry or related field</li><li>Solid training in chemical sciences as judged by undergraduate record</li><li>Minimum 3.0 GPA in chemistry courses and overall</li><li>GRE General: NOT REQUIRED and not used in evaluation</li><li>GRE Subject: NOT REQUIRED and not used in evaluation</li><li>Older catalog archive page requiring GRE is superseded by current dept admissions page</li><li>TOEFL iBT, IELTS, PTE, or Duolingo for international applicants</li><li>Exempt if 1 year full-time English-medium study in dominant-English country</li><li>JDP with SDSU: TOEFL Speaking 23+, IELTS Speaking 7+, PTE Speaking 65+</li><li>ETS institution code 4833 (UC San Diego)</li><li>UCSD online application via connect.grad.ucsd.edu/apply</li><li>Transcripts</li><li>Letters of recommendation (recommended submitting as soon as complete)</li><li>Statement of purpose</li><li>Research interests</li><li>Additional questions about educational experiences (recommended)</li><li>**Deadline December 3, 2026** for Fall 2027</li><li>Application opens September</li><li>Fall quarter entrance only</li><li>Applications reviewed continuously beginning late November</li><li>Visitation weekends around January</li><li>On-campus interviews February-March</li><li>April 15 reply date</li><li>First year: courses, teaching apprenticeships, research advisor selection, thesis research</li><li>English proficiency exam required for non-native English speakers</li><li>Average just over five years to graduation</li><li>300+ graduate students</li><li>Multi-year fully-funded support</li><li>On-campus residential (La Jolla, CA)</li></ul>",
        "research": "<ul><li>Analytical Chemistry</li><li>Biochemistry</li><li>Chemical Biology</li><li>Inorganic Chemistry</li><li>Materials Chemistry</li><li>Organic Chemistry</li><li>Physical Chemistry</li><li>Theoretical Chemistry</li><li>Biophysics</li><li>Joint Doctoral Program with San Diego State University (JDP)</li><li>Chemistry with Specialization in Bioinformatics</li><li>Chemistry with Specialization in Computational Science</li><li>Chemistry with Specialization in Interdisciplinary Environmental Research</li><li>Chemistry with Specialization in Multiscale Biology</li><li>Chemistry with Specialization in Quantitative Biology</li><li>Interdisciplinary research with Scripps Institution of Oceanography, School of Medicine, Department of Physics, Bioengineering</li></ul>",
        "source": '<a href="https://chemistry.ucsd.edu/graduate-program/doctoral-program/admissions/" target="_blank">UCSD Chemistry Doctoral Admissions (Dec 3, 2025 deadline for Fall 2026; connect.grad.ucsd.edu/apply; submit application early even if LOR in transit; additional educational experience questions recommended; files reviewed continuously late November; good news offered as soon as possible; GRE General & Subject not required and not used in evaluation)</a> | <a href="https://chemistry.ucsd.edu/graduate-program/doctoral-program/" target="_blank">UCSD Chemistry PhD Program Overview (average just over five years; tailored programs; first year courses + teaching apprenticeships + advisor selection + thesis research; English proficiency exam for non-native speakers; Fall quarter only; application opens September closes December; visitation weekends January; on-campus interviews Feb-Mar; April 15 reply date)</a> | <a href="https://chemistry.ucsd.edu/graduate-program/joint-doctoral-program" target="_blank">UCSD Chemistry Joint Doctoral Program with SDSU (Dec 10 deadline; B 3.0 GPA minimum; quality of undergraduate university; research experience/publications; LOR especially from proposed SDSU Thesis Adviser; neither General nor Subject GRE required; TOEFL Speaking 23+, IELTS Speaking 7+, PTE Speaking 65+; English-medium 1-year exemption)</a> | <a href="https://catalog.ucsd.edu/curric/CHEM-gr.html" target="_blank">UCSD Catalog Chemistry and Biochemistry (legacy: minimum 3.0 GPA in chemistry courses and overall; Plan I Thesis / Plan II Comprehensive for MS; doctoral statement of purpose and research interests; note: current dept page supersedes catalog GRE requirement)</a> | <a href="https://catalog.ucsd.edu/graduate/admission/index.html" target="_blank">UCSD Graduate Admission (minimum B 3.0 GPA upper-division; baccalaureate degree from accredited institution; GRE required for some programs but not all; self-reported scores accepted; only ETS-official scores accepted as official)</a>',
    },
    "ucla-chem-phd": {
        "school": "University of California Los Angeles, Department of Chemistry and Biochemistry",
        "en": "PhD in Chemistry",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Chemistry / CIP 40.0501; Biochemistry)",
        "dur": "Typically 5-6 years; admission limited to Fall; on-campus (Los Angeles, CA); MS only under exceptional circumstances; two separate PhD programs: Chemistry and BMSB (apply to either not both); written and oral qualifying examinations coupled with Chemistry and Biochemistry 258 seminar (presentation of proposed dissertation research)",
        "ddl": "Fall 2027 (September): **Deadline December 1, 2026 at 11:59 PM PST** for Chemistry. BMSB deadline December 5, 2026 at 11:59 PM PST. (Note: grad.ucla.edu 2027-2028 catalog lists December 1, 2026; older 2013-2014 catalog listing December 15 superseded.) Fall only.",
        "lang": "TOEFL iBT or IELTS Academic per UCLA Graduate Division minimum. ETS TOEFL 4837; dept 62 (Chemistry) / 34 (Biochemistry). GRE institution R4837; dept 0301 (Chemistry) / 0202 (BMSB). Required for international applicants not holding English-medium undergraduate degree.",
        "test_cls": "GRE NOT REQUIRED PER 2027-2028 CATALOG (grad.ucla.edu major 0153: 'GRE: Not required.'). Dept How to Apply: 'While not required, GRE scores are encouraged for those applying to the Fall 2027 admission cycle.' Self-reported scores accepted on application; official scores accepted after deadline. Subject not required for domestic (US citizens/permanent residents), optional for international. Average GRE Quant percentile 80-85% admitted distribution (not minimum threshold). No minimum GRE. Required: UCLA graduate application, transcripts, 3 LOR, SOP, departmental application. Excellent undergraduate record required. Older 2013-2014 catalog requiring General for all and Subject for international is superseded.",
        "tui": "Multi-year fully-funded support. Two separate PhD programs: BMSB and Chemistry. Students may apply to either but not both at same time. Interdisciplinary research areas. Address: 4009 Young Hall, Box 951569, Los Angeles, CA 90095-1569. Phone (310) 825-3150 Fax (310) 267-0204. Email cbgrad@ucla.edu. Major Code 0153. Fall admission only. MS only under exceptional circumstances. Written and oral qualifying examinations required prior to candidacy; written exam coupled with Chemistry and Biochemistry 258 seminar requiring presentation of proposed dissertation research.",
        "overview": "The University of California Los Angeles Department of Chemistry and Biochemistry offers two graduate PhD programs: the Biochemistry, Molecular and Structural Biology Graduate Program and the Chemistry Graduate Program. Students may apply to either program, but not both at the same time. Students can also choose to focus on one of the many interdisciplinary research areas. Per the Department Graduate page: Application Deadline: December 5, 2026. Biochemistry, Molecular and Structural Biology (BMSB): Our faculty's cutting-edge research programs span the broad areas of biochemistry and molecular biology, covering both traditional and modern disciplines. Our program is well suited for students interested in biological systems and molecules, particularly those who seek a detailed, mechanistic understanding of biological and biochemical phenomena. Application Deadline: December 1, 2026. Chemistry: Students interested in pursuing a PhD program in Analytical Chemistry... Common Inquiries: Is the Graduate Record Examination (GRE) required? While not required, GRE scores are encouraged for those applying to the Fall 2027 admission cycle. You may request that all official GRE scores be sent to the Department of Chemistry and Biochemistry. GRE Codes: UCLA Code R4837; Chemistry 0301; BMSB 0202. Per the How to Apply page: Application Deadlines: The deadline for Chemistry applications is December 1, 11:59pm Pacific Standard Time. The deadline for BMSB applications is December 5, 11:59pm Pacific Standard Time. How to Apply - US Domestic Students: REQUIRED MATERIALS: Graduate Record Examination (GRE) - While not required, GRE scores are encouraged for those applying to the Fall 2027 admission cycle. If you self-report your test scores on the application, we will accept your official GRE score after the application deadline. The subject GRE test is not required for domestic applicants (i.e. US Citizens and Permanent Residents), but applicants may report their subject exam if they choose to do so. If you take more than one GRE exam, you may input your best scores for each section into the application and upload all unofficial copies. Please request that all official GRE scores be sent to the Department of Chemistry and Biochemistry. Per the grad.ucla.edu 2027-2028 Admission Requirements for the Graduate Major in Chemistry (major 0153): Deadlines to apply: December 1, 2026. Admission Limited to: Fall. Exams & GRE Types: GRE: Not required. Letters of Recommendation: 3. All applicants expected to submit statement of purpose and departmental application. An excellent undergraduate record is required of all applicants. Program Name: Chemistry (Chemistry and Biochemistry), Leading to the degree of M.S., Ph.D. Applicants are admitted to the MS program only under exceptional circumstances. Address: 4009 Young Hall, Box 951569, Los Angeles, CA 90095-1569. Phone (310) 825-3150 Fax (310) 267-0204. Email cbgrad@ucla.edu. Per the Graduate FAQ: What are the school and department codes for the GRE exam? GRE UCLA Code R4837; Chemistry Department 0301; Biochemistry Department 0202. TOEFL Institution Code 4837; TOEFL Chemistry Department 62; TOEFL Biochemistry Department 34. Do you have a minimum GRE score? What is the average GRE score of accepted students? We do not have a minimum GRE score. The average GRE Quantitative Percentile score of accepted students is in the 80-85% range. Is the GRE subject exam required? While not required, GRE scores are encouraged for those applying to the Fall 2026 admission cycle. The department is located in Los Angeles, California.",
        "requirements": "<ul><li>Bachelor's degree in chemistry or related field</li><li>Excellent undergraduate record required of all applicants</li><li>GRE: NOT REQUIRED per grad.ucla.edu 2027-2028 catalog (major 0153)</li><li>Dept page: GRE scores encouraged for Fall 2027 admission cycle</li><li>Self-reported scores accepted on application; official scores accepted after deadline</li><li>Subject GRE not required for domestic (US citizens/permanent residents), optional for international</li><li>If multiple GRE exams, input best scores per section and upload all unofficial copies</li><li>Average GRE Quant percentile 80-85% admitted distribution (not minimum threshold)</li><li>No minimum GRE score</li><li>TOEFL iBT or IELTS Academic per UCLA Graduate Division minimum</li><li>ETS TOEFL institution code 4837; Chemistry dept 62; Biochemistry dept 34</li><li>GRE institution R4837; Chemistry dept 0301; BMSB dept 0202</li><li>UCLA graduate application</li><li>Transcripts</li><li>3 letters of recommendation</li><li>Statement of purpose</li><li>Departmental application</li><li>**Deadline December 1, 2026 at 11:59 PM PST** for Chemistry</li><li>BMSB deadline December 5, 2026 at 11:59 PM PST</li><li>Fall admission only</li><li>Two separate PhD programs: Chemistry and BMSB; apply to either but not both at same time</li><li>Interdisciplinary research areas available</li><li>MS program only under exceptional circumstances</li><li>Written and oral qualifying examinations prior to advancement to candidacy</li><li>Written exam coupled with Chemistry and Biochemistry 258 seminar (presentation of proposed dissertation research)</li><li>Multi-year fully-funded support</li><li>On-campus residential (Los Angeles, CA)</li></ul>",
        "research": "<ul><li>Analytical Chemistry</li><li>Biochemistry</li><li>Biological Chemistry</li><li>Chemical Biology</li><li>Geochemistry</li><li>Inorganic Chemistry</li><li>Materials Chemistry</li><li>Organic Chemistry</li><li>Physical Chemistry</li><li>Theoretical Chemistry</li><li>Biophysics</li><li>BMSB: Biochemistry, Molecular and Structural Biology</li><li>Interdisciplinary research areas (choose one of many)</li><li>Interdisciplinary research with UCLA Medical School, California NanoSystems Institute, Department of Physics, Bioengineering</li></ul>",
        "source": '<a href="https://www.chemistry.ucla.edu/graduate/" target="_blank">UCLA Chemistry Graduate (two PhD programs: BMSB and Chemistry; apply to either not both; interdisciplinary research areas; Chemistry deadline Dec 1, 2026; BMSB deadline Dec 5, 2026; GRE encouraged for Fall 2027; ETS R4837 / dept 0301 Chemistry / 0202 BMSB)</a> | <a href="https://www.chemistry.ucla.edu/how-apply/" target="_blank">UCLA Chemistry How to Apply (Chemistry Dec 1 11:59pm PST; BMSB Dec 5 11:59pm PST; GRE not required but encouraged Fall 2027; self-reported accepted on application; official accepted after deadline; Subject not required for domestic, optional for international; multiple exams best scores per section; ETS R4837 / dept 0301 Chemistry / 0202 BMSB)</a> | <a href="https://grad.ucla.edu/requirements/?app=admission&major=0153" target="_blank">UCLA 2027-2028 Admission Requirements for Chemistry major 0153 (Dec 1, 2026; Fall only; GRE Not required; 3 LOR; SOP + departmental application; excellent undergraduate record; MS only under exceptional circumstances; 4009 Young Hall Box 951569; (310) 825-3150; cbgrad@ucla.edu)</a> | <a href="https://www.chemistry.ucla.edu/graduate-FAQ/" target="_blank">UCLA Chemistry Graduate FAQ (GRE UCLA R4837 / Chemistry 0301 / BMSB 0202; TOEFL 4837 / Chemistry 62 / Biochemistry 34; no minimum GRE; average Quant percentile 80-85% admitted distribution; Subject not required; encouraged for Fall 2026 cycle)</a> | <a href="https://grad.ucla.edu/graduate-program-requirements/program-requirements-for-chemistry-and-biochemistry-chemistry-4/" target="_blank">UCLA Program Requirements for Chemistry and Biochemistry Chemistry (legacy 2013-2014: deadline Dec 15; General required for all; Subject required for international; 3 LOR; MS only under exceptional circumstances; Fall only - superseded by 2027-2028 catalog)</a>',
    },
    "wustl-chem-phd": {
        "school": "Washington University in St. Louis, College of Arts and Sciences, Department of Chemistry",
        "en": "PhD in Chemistry",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Chemistry / CIP 40.0501)",
        "dur": "Typically 5 years; 72 units total; 1 year minimum residence; on-campus (St. Louis, MO); most time spent doing research at Washington University; program extension possible with approval; minimum grade C for coursework; overall GPA 3.0; Common Track AI with 4 engagements years 1-2 totaling 40 MER units",
        "ddl": "Fall 2027 (August/September): **Deadline generally falls during first week of December** per Arts & Sciences unified doctoral deadline. Students should use deadline date displayed on application page. Arts & Sciences rarely admits spring. Deferral up to 1 year possible with program and OGS approval (international additional OISS approval).",
        "lang": "TOEFL iBT or IELTS Academic per Washington University in St. Louis Graduate School English proficiency. Required for international applicants not holding English-medium degree. Bulletin 2025-26: minimum grade C for coursework; overall GPA 3.0. ETS institution code per Washington University in St. Louis.",
        "test_cls": "GRE POLICY NOT EXPLICITLY LISTED ON CURRENT DEPT PAGE (chemistry.washu.edu homepage and bulletin.wustl.edu Chemistry PhD 2025-26 PDF do not explicitly state GRE requirement). Older bulletin 2016-17 page stating GRE required for Arts & Sciences is legacy and likely superseded; current Arts & Sciences graduate admissions page does not list universal GRE requirement. Required: online application through OGS Arts & Sciences, letters of recommendation per program outline, application fee or fee waiver. Recommend completing application well in advance. **GRE status pending department page confirmation - marked as half-verified page.**",
        "tui": "Multi-year fully-funded support. Close-knit group of teacher-scientists. Strong foundation in organic, physical, inorganic, nuclear, theoretical. Special emphases: organometallic, bioorganic, biophysical, macromolecular, polymer, environmental, materials chemistry. Newly renovated Bryan Hall adds 28,000 sq ft research space. 30 teaching/research faculty; ~90 undergraduate majors; 100 graduate students; 20 postdocs. Five-year program. Contact: Barbara Tessmer, 314-935-7316, barbara22@wustl.edu. Common Track (AI) 4 engagements across years 1-2 totaling 40 MER units (10 per experience).",
        "overview": "The Washington University in St. Louis Department of Chemistry, within the College of Arts and Sciences, offers the Doctor of Philosophy in Chemistry. Per the Department homepage: The Department of Chemistry at Washington University has a tradition of excellence, combining deep commitments to fundamental research and classroom teaching. Our department is made up of a close-knit group of teacher-scientists who provide a superior education in chemistry. Our students gain a strong foundation in the core areas of chemistry: organic, physical, inorganic, nuclear, and theoretical. Special emphases in the department include emerging interdisciplinary fields as organometallic, bioorganic, biophysical, macromolecular, polymer, environmental, and materials chemistry. Our state-of-the-art facilities include the newly renovated Bryan Hall, which adds 28,000 square feet of research space to our footprint. The department is home to 30 teaching and research faculty members and roughly 90 undergraduate chemistry majors, 100 graduate students, and 20 postdoctoral research associates and research scientists. Per the Bulletin 2025-26 Chemistry PhD page: To earn a PhD at Washington University, a student must complete all courses required by their department; maintain satisfactory academic progress; pass certain examinations; fulfill residence and Mentored Experience Requirements; write, defend, and submit a dissertation; and apply to graduate via Workday Student. Program Requirements: Total Units Required 72; Degree Length 5 years. There is a one year minimum residence requirement for the PhD degree at Washington University in St. Louis. The PhD in Chemistry is a five-year program, with most of this time ordinarily spent doing research at Washington University in St. Louis. If necessary, a program extension can be requested and requires approval from the program and the Office of Graduate Studies, Arts & Sciences. Grade Requirement: A minimum grade of C is required for course work to count toward the degree with an overall GPA of at least 3.0. PhD in Chemistry Requirements: Dissertation research and preparation of dissertation; Satisfactory performance on a final oral dissertation defense. Assistant in Instruction (AI): PhD students in Chemistry start on the Common Track. Per the Bulletin Arts & Sciences Admissions page: The Office of Graduate Studies, Arts & Sciences, sets one application deadline for all doctoral programs each year. The deadline generally falls during the first week of December. Master's degree programs set their own application deadlines, which generally fall in either mid-December or mid-January. Applicants should use the deadline date that is displayed on their application page. It is generally advantageous to the applicant to complete the application and have all application materials submitted well in advance of the deadline. Admissions and financial aid awards are for a specific academic year. Admitted students can request a deferral of admission for up to one year, but such special requests require approval of the admitting program and of the Office of Graduate Studies, Arts & Sciences (if you are an international applicant, additional approval is needed from the Office of International Students & Scholars). Applicants to whom admission is not offered may reapply after gaining additional evidence of qualification. Degree programs in Arts & Sciences rarely admit applicants for the spring semester. Students interested in beginning graduate study in the spring should consult their prospective program's faculty and staff prior to completing an application. The application is available online through the website of the Office of Graduate Studies, Arts & Sciences. Applications are ready for final consideration after the following items have been submitted: The application, The appropriate letters of recommendation outlined by the program, Application fee or fee waiver. Per the Mentored Experience Implementation Plan: Common Track involves completion of four engagements as an AI in potentially different courses, resulting in total of 40 MER units (10 units per experience). These experiences usually take place during years 1 and 2. Contact: Barbara Tessmer, Phone 314-935-7316, Email barbara22@wustl.edu. The department is located in St. Louis, Missouri.",
        "requirements": "<ul><li>Bachelor's degree in chemistry or related field</li><li>Minimum grade of C required for coursework to count toward degree</li><li>Overall GPA at least 3.0</li><li>GRE: policy not explicitly listed on current dept page (half-verified)</li><li>Older 2016-17 bulletin stating GRE required for Arts & Sciences is legacy and likely superseded</li><li>Current Arts & Sciences graduate admissions page does not list universal GRE requirement</li><li>**GRE status pending department page confirmation**</li><li>TOEFL iBT or IELTS Academic for international applicants not holding English-medium degree</li><li>Online application through Office of Graduate Studies, Arts & Sciences</li><li>Letters of recommendation per program outline</li><li>Application fee or fee waiver</li><li>**Deadline generally falls during first week of December**</li><li>Students should use deadline date displayed on application page</li><li>Arts & Sciences rarely admits spring semester</li><li>Admissions and financial aid awards specific to academic year</li><li>Deferral up to 1 year possible with program and OGS approval</li><li>International applicants need additional OISS approval for deferral</li><li>Unsuccessful applicants may reapply after gaining additional evidence of qualification</li><li>Total Units Required: 72</li><li>Degree Length: 5 years</li><li>1 year minimum residence requirement</li><li>Most time spent doing research at Washington University</li><li>Program extension possible with program and OGS approval</li><li>Common Track (AI) with 4 engagements across years 1-2 totaling 40 MER units (10 per experience)</li><li>Dissertation research and preparation</li><li>Satisfactory performance on final oral dissertation defense</li><li>Multi-year fully-funded support</li><li>On-campus residential (St. Louis, MO)</li></ul>",
        "research": "<ul><li>Analytical Chemistry</li><li>Inorganic Chemistry</li><li>Nuclear Chemistry</li><li>Organic Chemistry</li><li>Physical Chemistry</li><li>Theoretical Chemistry</li><li>Organometallic Chemistry (special emphasis)</li><li>Bioorganic Chemistry (special emphasis)</li><li>Biophysical Chemistry (special emphasis)</li><li>Macromolecular Chemistry (special emphasis)</li><li>Polymer Chemistry (special emphasis)</li><li>Environmental Chemistry (special emphasis)</li><li>Materials Chemistry (special emphasis)</li><li>Interdisciplinary research with Washington University departments of biomedical engineering, physics, earth and planetary sciences, School of Medicine, Institute of Materials Science & Engineering</li><li>Newly renovated Bryan Hall (28,000 sq ft)</li></ul>",
        "source": '<a href="https://chemistry.washu.edu/" target="_blank">Washington University in St. Louis Department of Chemistry (tradition of excellence; close-knit teacher-scientists; strong foundation organic/physical/inorganic/nuclear/theoretical; special emphases organometallic/bioorganic/biophysical/macromolecular/polymer/environmental/materials; newly renovated Bryan Hall 28,000 sq ft; 30 faculty; 90 undergraduate majors; 100 graduate students; 20 postdocs)</a> | <a href="https://bulletin.wustl.edu/grad/artsci/degrees/chemistry-phd/chemistry-phd.pdf" target="_blank">WashU Bulletin 2025-26 Chemistry PhD (72 units; 5 years; 1 year minimum residence; minimum grade C; overall GPA 3.0; dissertation research; final oral defense; Assistant in Instruction Common Track; contact Barbara Tessmer 314-935-7316 barbara22@wustl.edu)</a> | <a href="https://bulletin.wustl.edu/grad/artsci/admissions/" target="_blank">WashU Arts & Sciences Admissions (unified doctoral deadline first week of December; master\'s mid-December or mid-January; use deadline on application page; complete well in advance; awards specific to academic year; deferral up to 1 year with program and OGS approval; international additional OISS approval; rarely spring; online application through OGS; LOR per program; application fee or fee waiver)</a> | <a href="https://wustl-public.courseleaf.com/grad/artsci/degrees/chemistry-phd/chemistry-phd_meip.pdf" target="_blank">WashU Chemistry PhD Mentored Experience Implementation Plan (Common Track: 4 engagements as AI in potentially different courses; total 40 MER units; 10 units per experience; usually years 1 and 2; contact Barbara Tessmer 314-935-7316)</a> | <a href="https://bulletin.wustl.edu/programs/" target="_blank">WashU Programs of Study (Inter-University Exchange Program; McDonnell International Scholars Academy; Institute of Materials Science & Engineering; Division of Biology & Biomedical Sciences; Division of Computational & Data Sciences; Skandalaris Center for Interdisciplinary Innovation and Entrepreneurship)</a>',
    },
    "rice-chem-phd": {
        "school": "Rice University, Wiess School of Natural Sciences, Department of Chemistry",
        "en": "PhD in Chemistry",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Chemistry / CIP 40.0501)",
        "dur": "Directed only at PhD degree; some students choose MS in course of doctoral studies; typically 5-6 years; Fall only; on-campus (Houston, TX); entering students should have high aptitude for chemistry, strong motivation for original scientific research, Bachelor\'s or Master\'s in Chemistry or related discipline; application opens around September 1",
        "ddl": "Fall 2027 (August): **Deadline December 1, 2026 at 11:59 PM EST** per Rice Chemistry How to Apply. After Dec 1 contact gradchem@rice.edu directly. Recommend requesting transcripts and LOR by October or earlier. Applications open around September 1. Fall only.",
        "lang": "TOEFL iBT minimum 90 overall; paper-based 620; computer-based 250. IELTS minimum equivalent. Duolingo accepted. Required for applicants whose native language is not English. Exempt if proof of degree from accredited U.S. high school/college/university. Scores not older than 2 years; official copy sent to Graduate School directly from ETS. ETS 6609 (Rice University).",
        "test_cls": "GRE OPTIONAL STRONGLY RECOMMENDED (Rice Graduate School Application FAQ: 'General GRE is strongly recommended but not required: PhD in Chemistry, in Civil Engineering, in Environmental Engineering, and in Statistics.' Dept FAQ: 'The GRE is optional and will not negatively impact your application if you do not submit scores. GRE scores will be accepted upon submission. Is the GRE Subject Test required? The GRE Subject test is optional and not required.') Required: online application, application fee $85 (waived for doctoral applicants graduating from institutions in Texas and bordering states Louisiana, Arkansas, Oklahoma and New Mexico, or with permanent address in these states - does not include Jones School of Business), minimum 3 LOR, official transcript(s) from all undergraduate/graduate schools attended, SOP, TOEFL/IELTS/Duolingo scores for international. Letters via email request through application system or printed fax coversheet.",
        "tui": "Multi-year fully-funded support. Directed only at PhD; some students choose MS in course of doctoral studies. Application fee $85; waived for doctoral applicants from TX/LA/AR/OK/NM institutions or permanent address in these states. Other fee waivers per Graduate School. Applications open around September 1. Contact: gradchem@rice.edu. Located in Houston, Texas. Wiess School of Natural Sciences. Recommend starting as early as possible; requesting transcripts and LOR by October allows recommenders time to submit before deadline. Research group rotation typical; original research central.",
        "overview": "The Rice University Department of Chemistry, within the Wiess School of Natural Sciences, offers the Doctor of Philosophy in Chemistry. Per the PhD Program FAQ: Program Admissions: What qualifications will I need to be admitted to the Ph.D. program? Entering students should have a high aptitude for chemistry, a strong motivation to perform original scientific research, and a Bachelor\'s or Master\'s degree in Chemistry or a closely related discipline. Rice\'s graduate program in Chemistry is directed only at the Ph.D. degree, although some students choose to receive Master\'s degrees in the course of their doctoral studies. When should I begin the application process? You should begin your application process as early as possible. The GRE is optional and not required for admission. Also, requesting transcripts and letters of recommendation by October or earlier will allow recommenders time to submit their information before the application deadline. When is the application deadline? The Department of Chemistry application deadline for the Ph.D. program is December 1. Can letters of recommendation be submitted online? I have not taken/do not have my GRE or TOEFL scores yet. Can I still apply? The Graduate Records Examinations (GRE) test is not required for admission; however, GRE scores will be accepted upon submission. Applicants who are foreign nationals and those whose native language is not English must provide evidence of English proficiency. This can be shown by any of the following: (1) Proof of degree from an accredited U.S. high school, college, or university, or (2) a qualified score on the TOEFL, IELTS, or Duolingo test. Per the How to Apply page: The application for admission is currently open. View the timeline below for more details about the application process. How to Apply: The Department of Chemistry application deadline for the Ph.D. program is December 1st, 11:59 PM Eastern Standard Time. You should begin applying as early as possible. Students wishing to apply after the December 1st deadline must contact the Chemistry Department directly (gradchem@rice.edu). You may also request more information here. Submission Requirements: To submit your application, you must provide all of the required information. Application Fee: The application fee... Letters of Recommendation: A minimum of three (3) letters of recommendation are required. Once listed, recommendation requests are sent via email to the recommender after the applicant prompts the application system to do so. Alternatively, applicants may print a fax coversheet for a recommender; the recommender then submits their recommendation to Rice University via fax using the coversheet. Standardized Tests (GRE): The GRE is optional and will not negatively impact your application if you do not submit scores. Rice University policies and processes regarding admissions requirements may be found in the General Announcements. Per the Graduate Program How to Apply page: Fall 2026 applications are open; deadline is December 1, 2025. The Department of Chemistry application deadline for the Ph.D. program is December 1st, 11:59 PM Eastern Standard Time. You should begin applying as early as possible. Students wishing to apply after the December 1st deadline must contact the Chemistry Department directly (gradchem@rice.edu). Standardized Tests (GRE): The GRE is optional and will not negatively impact your application if you do not submit scores. Required Standardized Tests: The Test of English as a Foreign Language (TOEFL) is required of any student whose native language is not English. The TOEFL and the IELTS are not required for U.S. Citizens, nor for international students who earned a degree from a university in which English is the official language of communication. Scores must not be older than two years, and an official copy must be sent to the Graduate School directly from ETS. Students must score at least 90 on the iBT (internet-based) TOEFL, at least 620 on the paper-based TOEFL, or at least 250 on the computer-based TOEFL. For students who choose to take the IELTS in lieu of TOEFL, the minimum score is... Per the Graduate School Application FAQ: For 2026 admissions, Rice generally is not requiring the GRE. However, individual degree programs have the option of recommending, strongly recommending, or requiring the general GRE. General GRE is recommended but not required: MEML, MMSNE, MSPE, MStat, MS in Bioscience and Health Policy, in Materials Science and Nanoengineering, and in Space Studies; PhD in Materials Science and NanoEngineering. General GRE is strongly recommended but not required: MCEE, MME, MS in Environmental Analysis, and in Mechanical Engineering; PhD in Chemistry, in Civil Engineering, in Environmental Engineering, and in Statistics. Per the Graduate School How to Apply: $85 application fee. Rice waives application fees for doctoral applicants who are graduates of institutions in Texas and bordering states Louisiana, Arkansas, Oklahoma and New Mexico or who have a permanent address in these states. This does not include programs in the Jones School of Business. The department is located in Houston, Texas.",
        "requirements": "<ul><li>Bachelor\'s or Master\'s degree in Chemistry or closely related discipline</li><li>High aptitude for chemistry and strong motivation to perform original scientific research</li><li>GRE: OPTIONAL strongly recommended per Graduate School</li><li>GRE Subject: optional and not required</li><li>GRE scores accepted upon submission; will not negatively impact application if not submitted</li><li>TOEFL iBT minimum 90 overall; paper-based 620; computer-based 250</li><li>IELTS minimum equivalent to TOEFL 90 iBT</li><li>Duolingo English Test also accepted</li><li>Required for applicants whose native language is not English</li><li>Exempt if proof of degree from accredited U.S. high school, college, or university</li><li>Exempt for international students who earned degree from university where English is official language of communication</li><li>Scores not older than 2 years; official copy sent to Graduate School directly from ETS</li><li>ETS institution code 6609 (Rice University)</li><li>Rice online application</li><li>Application fee $85</li><li>Fee waived for doctoral applicants graduating from institutions in Texas and bordering states Louisiana, Arkansas, Oklahoma and New Mexico, or with permanent address in these states</li><li>Fee waiver does not apply to Jones School of Business programs</li><li>Other fee waivers available per Graduate School</li><li>Minimum 3 letters of recommendation</li><li>LOR requests sent via email through application system or printed fax coversheet</li><li>Official transcript(s) from all undergraduate and graduate schools attended</li><li>Statement of purpose</li><li>**Deadline December 1, 2026 at 11:59 PM EST**</li><li>After Dec 1 contact gradchem@rice.edu directly</li><li>Applications open around September 1</li><li>Recommend requesting transcripts and LOR by October or earlier</li><li>Fall only admission</li><li>Directed only at PhD degree</li><li>Some students choose to receive MS in course of doctoral studies</li><li>Multi-year fully-funded support</li><li>On-campus residential (Houston, TX)</li></ul>",
        "research": "<ul><li>Analytical Chemistry</li><li>Biological Chemistry</li><li>Chemical Biology</li><li>Inorganic Chemistry</li><li>Materials Chemistry (Nanoscale Science)</li><li>Organic Chemistry</li><li>Physical Chemistry</li><li>Theoretical Chemistry</li><li>Biophysics</li><li>Environmental Chemistry</li><li>Interdisciplinary research with Rice departments of physics, materials science and nanoengineering (MSNE), chemical and biomolecular engineering, biosciences, electrical and computer engineering, computer science</li><li>Wiess School of Natural Sciences</li><li>Rice Nanoscale Science and Technology (RSTC)</li><li>Center for Theoretical Biological Physics</li></ul>",
        "source": '<a href="https://chemistry.rice.edu/phd-program/faqs" target="_blank">Rice Chemistry PhD Program FAQs (high aptitude + strong motivation for original research; Bachelor\'s/Master\'s in Chemistry or related; directed only at PhD; MS in course of doctoral studies; GRE optional not required; GRE accepted upon submission; TOEFL/IELTS/Duolingo for foreign nationals; proof of US degree exempt; Dec 1 deadline; request transcripts and LOR by October)</a> | <a href="https://chemistry.rice.edu/phd-program/how-to-apply" target="_blank">Rice Chemistry PhD How to Apply (Dec 1 11:59pm EST; after Dec 1 contact gradchem@rice.edu; application fee; 3 LOR minimum; email requests or fax coversheet; GRE optional not negatively impact if not submitted; Rice General Announcements)</a> | <a href="https://chemistry.rice.edu/graduate-program/prospective-students/how-to-apply" target="_blank">Rice Graduate How to Apply (Fall applications open; Dec 1 11:59pm EST; GRE optional not negatively impact; TOEFL required for non-native English; exempt for US citizens and English-medium degree; scores not older than 2 years; official from ETS; TOEFL iBT 90 / paper 620 / computer 250; IELTS minimum)</a> | <a href="https://chemistry.rice.edu/graduate-program/frequently-asked-questions" target="_blank">Rice Graduate FAQ (high aptitude + strong motivation; Bachelor\'s/Master\'s in Chemistry; directed only at PhD; Dec 1 deadline; GRE optional not required; GRE Subject optional not required; official transcripts from all schools attended; GRE accepted upon submission)</a> | <a href="https://graduate.rice.edu/admissions/application-faq" target="_blank">Rice Graduate and Postdoctoral Studies Application FAQ (for 2026 admissions Rice generally not requiring GRE; individual programs can recommend/strongly recommend/require; PhD in Chemistry strongly recommended but not required; deadline varies by program)</a> | <a href="https://graduate.rice.edu/admissions/how-to-apply" target="_blank">Rice Graduate How to Apply (consult program for exact requirements; $85 fee; fee waived for doctoral applicants from TX/LA/AR/OK/NM institutions or permanent address in these states; does not include Jones School of Business; TOEFL/IELTS/Duolingo for international; LOR; writing sample; portfolio; SOP; applications open around September 1)</a>',
    },
    "vanderbilt-chem-phd": {
        "school": "Vanderbilt University, College of Arts and Science, Department of Chemistry",
        "en": "PhD in Chemistry",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Chemistry / CIP 40.0501)",
        "dur": "Typically 5-6 years; Fall only; on-campus (Nashville, TN); applications open August 1; research degree requiring meaningful research experiences (undergraduate research, REUs, internships); four Placement Examinations before coursework; rotation reports due Oct 26/Dec 21/Mar 15; PhD Qualifying Exam by Oct 15 of third year (Mar 15 for Spring entrants)",
        "ddl": "Fall 2027 (August): **Priority Deadline December 1, 2026**; **FINAL Deadline December 15, 2026** after which no applications accepted. Applications open August 1. Committee meets regularly fall; early offers soon after application complete. Note: Graduate School table lists Chemistry PhD Jan 1 but dept page is authoritative. Most programs release initial offers by March 31; response due April 15; offers may continue after.",
        "lang": "TOEFL iBT, IELTS Academic, or Duolingo English Test for international students. Required for applicants not holding English-medium degree. GRE scores valid 5 years to month of intended first term (e.g., no earlier than August 1 five years prior for fall). Vanderbilt does not accept expired scores, personal copies, or notarized reports. Official scores must reach Graduate School by deadline; 2-3 business days to link after ETS sends.",
        "test_cls": "GRE OPTIONAL / NOT REQUIRED (dept page: 'The GRE is not required for admission into the program.' Graduate School Application Requirements by Program table: Chemistry PhD GRE Requirement Status = Optional. Holistic review: grades particularly STEM coursework, GRE scores (if provided), LOR, SOP. PhD in chemistry is research degree; meaningful research experiences particularly important: undergraduate research, summer REUs, internships. Recommendation letters from research mentors very valuable. Required: up-to-date academic transcripts, minimum 3 LOR, SOP (include previous research experience, current interests), additional documentation. Unofficial transcripts accepted for application review. GRE valid 5 years; no expired/personal/notarized reports; official scores 2-3 business days to link).",
        "tui": "Multi-year fully-funded support. Research degree emphasizing research experience. Applications open August 1. Priority Dec 1, 2026; final Dec 15, 2026. Committee meets regularly fall; early offers soon after complete. Located at 7300 Stevenson Center, Nashville, TN 37235-1822. Email chemgrad@vanderbilt.edu. Four Placement Examinations before coursework. Rotation reports due Oct 26, Dec 21, Mar 15. PhD Qualifying Exam by Oct 15 of third year. Minimum formal coursework (possible exception of one credit hour seminar). Unofficial transcripts accepted for review.",
        "overview": "The Vanderbilt University Department of Chemistry, within the College of Arts and Science, offers the Doctor of Philosophy in Chemistry. Per the Department PhD Admissions page: Applying to the Program: Applications traditionally open on August 1 each year. Our priority deadline is December 1, 2026. The FINAL application deadline is December 15, 2026, after which point no applications will be accepted. We use a holistic review process and take into account your grades (particularly in STEM coursework), GRE scores (if provided), letters of recommendation, and statement of purpose. Our aim is to determine how you and your goals fit into our research environment. A Ph.D. in chemistry is a research degree. As such, meaningful research experiences are particularly important to the review committee. This can be in the form of undergraduate research, summer research experiences (such as NSF REUs), or internships. Recommendation letters from your research mentors are very valuable. Qualifications: Applicants should have worked, or be currently working, towards an undergraduate... Relevant research experience is strongly recommended. Information to Submit: In order to complete your application to join the graduate program of chemistry you will need to include all of your most up-to-date academic transcripts, a minimum of three letters of recommendation, a Statement of Purpose, and any additional documentation you wish to submit. The GRE is not required for admission into the program. For international students, English proficiency (TOEFL/IELTS/DuoLingo) is required. Per the Graduate School Application Requirements by Program table: Chemical and Physical Biology PhD - School of Med Non-M.D. - applications through IGP; Chemical and Biomolecular Engineering MS - Engineering - Exempt - Mar. 15; Chemical Engineering PhD - Engineering - Exempt - Dec. 15; Chemistry PhD - Arts & Science - Optional - Jan. 1 (note: department page lists priority Dec 1 / final Dec 15 - department page authoritative); Economics (Economic Development) MA - Optional - Feb. 15; Mathematics PhD - Optional - Dec. 1; Political Science PhD - Optional - Dec. 1; Quantitative and Chemical Biology PhD - Optional - Dec. 1. Per the Graduate FAQ: When is the application deadline for fall admission? Our priority deadline is December 1, 2025. Our final deadline is December 15, 2025. We encourage you to apply as early as possible. The admissions committee will meet regularly throughout the fall and we sometimes make early offers of admission soon after an application is complete. If you have completed all parts, please encourage your recommenders to upload their supporting letters as early as possible. Which qualifications are most important when evaluating candidates? We use a holistic review process and take into account your grades (particularly in STEM coursework), GRE scores, letters of recommendation, and your statement of purpose. A Ph.D. in Chemistry is a research degree. As such, meaningful research experiences are particularly important to the review committee. This can be in the form of undergraduate research at your home institution, summer research experiences (such as NSF REUs), or internships. Recommendation letters from your research mentors are very valuable. Transcripts (unofficial accepted for application review); Contact information for recommenders; Statement of Purpose (include previous research experience, current...). Per the Graduate School Application Requirements page: Applications open August 1. The Fall application deadlines are different for each academic department. Deadlines range from December 1 to January 15. Most programs release initial Fall admission offers by March 31 with a response due by April 15. The timing of admission offers varies by program, and programs may continue to extend offers after that date. Submitting your GRE scores: Scores are valid if earned within five years to the month of your intended first term at Vanderbilt. Applicants should aim to take the GRE by November to have scores for Fall admissions deadlines. We do not accept expired scores, personal copies of scores, or attested or notarized score reports. Be sure to take the GRE in time for official scores to reach The Graduate School by the application deadline. It will take 2-3 business days (Monday-Friday) for your test scores to link. Per the 2009 PhD Program document (historical reference): First Year - Take all four Placement Examinations before coursework. For students entering in Fall Semester, research group rotation reports will be due 26 October, 21 December, and 15 March. Students must complete their Ph.D. Qualifying Examination requirement by 15 October of their third year of graduate study (15 March for students entering in Spring Semester). Students should complete all of their minimum formal course work (with the possible exception of one credit hour of seminar). The department is located in Nashville, Tennessee. Email: chemgrad@vanderbilt.edu.",
        "requirements": "<ul><li>Bachelor\'s degree in chemistry or related field</li><li>Relevant research experience strongly recommended</li><li>Meaningful research experiences particularly important: undergraduate research, summer REUs, internships</li><li>Recommendation letters from research mentors very valuable</li><li>GRE: NOT REQUIRED per dept page</li><li>Graduate School Application Requirements by Program table: Chemistry PhD = Optional</li><li>Holistic review: grades (particularly STEM), GRE (if provided), LOR, SOP</li><li>TOEFL iBT, IELTS Academic, or Duolingo English Test for international students</li><li>Required for applicants not holding English-medium degree</li><li>GRE scores valid 5 years to month of intended first term</li><li>No expired scores, personal copies, or notarized/notarized reports</li><li>Official scores must reach Graduate School by deadline</li><li>2-3 business days (Mon-Fri) for scores to link after ETS sends</li><li>Vanderbilt online application</li><li>Applications open August 1 each year</li><li>Up-to-date academic transcripts (unofficial accepted for application review)</li><li>Minimum 3 letters of recommendation</li><li>Statement of Purpose (include previous research experience, current interests)</li><li>Any additional documentation applicant wishes to submit</li><li>**Priority Deadline December 1, 2026**</li><li>**FINAL Deadline December 15, 2026** after which no applications accepted</li><li>Note: Graduate School table lists Jan 1 but dept page is authoritative</li><li>Admissions committee meets regularly throughout fall</li><li>Early offers may come soon after application complete</li><li>Most programs release initial offers by March 31; response due April 15</li><li>Offers may continue after April 15</li><li>Fall admission only</li><li>Four Placement Examinations before coursework</li><li>Research group rotation reports due Oct 26, Dec 21, Mar 15 for Fall entrants</li><li>PhD Qualifying Exam by Oct 15 of third year (Mar 15 for Spring entrants)</li><li>Minimum formal coursework (possible exception of one credit hour seminar)</li><li>Multi-year fully-funded support</li><li>On-campus residential (Nashville, TN)</li></ul>",
        "research": "<ul><li>Analytical Chemistry</li><li>Biological Chemistry</li><li>Chemical Biology</li><li>Inorganic Chemistry</li><li>Materials Chemistry</li><li>Organic Chemistry</li><li>Physical Chemistry</li><li>Theoretical Chemistry</li><li>Interdisciplinary research with Vanderbilt departments of biomedical engineering, physics, biological sciences, molecular physiology and biophysics, chemistry, Vanderbilt University Medical Center</li><li>Chemical and Physical Biology (CPB) through IGP</li><li>Quantitative and Chemical Biology (QCB) through IGP</li><li>Nanoscience</li><li>Polymer Chemistry</li></ul>",
        "source": '<a href="https://as.vanderbilt.edu/chemistry/phd-admissions/" target="_blank">Vanderbilt Chemistry PhD Admissions (applications open Aug 1; priority Dec 1, 2026; final Dec 15, 2026; holistic review grades STEM + GRE if provided + LOR + SOP; research degree; undergraduate research/REUs/internships particularly important; research mentor letters valuable; transcripts + 3 LOR + SOP + additional docs; GRE not required; TOEFL/IELTS/Duolingo for international)</a> | <a href="https://gradschool.vanderbilt.edu/admissions/apply/application-requirements-by-program/" target="_blank">Vanderbilt Graduate School Application Requirements by Program (Chemistry PhD Arts & Science Optional Jan 1; Chemical Engineering PhD Engineering Exempt Dec 15; Chemical and Biomolecular Engineering MS Exempt Mar 15; Math PhD Optional Dec 1; Political Science PhD Optional Dec 1; QCB PhD Optional Dec 1; note: dept page lists priority Dec 1 / final Dec 15 - department authoritative)</a> | <a href="https://as.vanderbilt.edu/chemistry/faq/" target="_blank">Vanderbilt Chemistry FAQ (priority deadline Dec 1, 2025; final deadline Dec 15, 2025; apply early; committee meets regularly fall; early offers soon after complete; encourage recommenders to upload early; holistic review STEM grades + GRE + LOR + SOP; research degree; research mentor letters valuable; unofficial transcripts accepted for review; SOP includes previous research experience and current interests)</a> | <a href="https://gradschool.vanderbilt.edu/application-requirements/#h2-language-proficiency" target="_blank">Vanderbilt Graduate School Application Requirements (applications open Aug 1; deadlines Dec 1 to Jan 15; most programs release initial offers by March 31; response due April 15; offers may continue; GRE scores valid 5 years to month of intended first term; aim to take by November; no expired/personal/notarized reports; official scores 2-3 business days to link)</a> | <a href="https://lab.vanderbilt.edu/wp-content/uploads/sites/59/2025/08/VU-PhD-Program-Document-Oct.-2009.pdf" target="_blank">Vanderbilt PhD Program in Chemistry 2009 (historical reference: four Placement Examinations before coursework; rotation reports Oct 26/Dec 21/Mar 15; PhD Qualifying Exam by Oct 15 of third year or Mar 15 for Spring entrants; minimum formal coursework with possible exception of one credit hour seminar)</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)}")
