README.md CHANGED
@@ -13,7 +13,7 @@ tags:
13
  - cheminformatics
14
  - open-data
15
  size_categories:
16
- - 10K<n<100K
17
  pretty_name: IRexp
18
  configs:
19
  - config_name: commercial
@@ -28,51 +28,74 @@ configs:
28
  data_files: data/irexp_non_commercial.jsonl.gz
29
  - config_name: other
30
  data_files: data/irexp_other.jsonl.gz
 
 
31
  ---
32
 
33
- # IRexp — experimental IR band lists
34
 
35
- IRexp is an openly redistributable collection of **experimental infrared band lists** mined from open-access chemistry literature, often with co-reported ¹H/¹³C shift lists and resolved structures (SMILES / InChIKey).
36
 
37
- > **Important:** IRexp contains **band lists** (peak positions in cm⁻¹), not digitised absorbance traces. This is the form reported in publication text and is not directly comparable to SDBS or NIST full spectra.
38
 
39
- This Hugging Face repository is the Scientific Data **dataset of record (DoR)** for the commercial (CC-BY / CC0) pool, plus separately licensed companions on the same revision. It is a **data release only** — no model accuracy tables, leaderboards, or benchmark scores are shipped here.
40
 
41
- ## Files on this Hub revision
42
 
43
  | Config / file | Records | Role |
44
  |---|---:|---|
45
- | `commercial` / `data/irexp_commercial.jsonl.gz` | **88,519** | **Dataset of record** — CC-BY + CC0; CC-BY-4.0 packaging |
46
- | `resolved_commercial` / `data/irexp_resolved_commercial.jsonl.gz` | 29,255 | Structure-linked commercial subset |
47
- | `train_no_bench_commercial` / `data/train_no_bench_commercial.jsonl.gz` | 29,109 | Commercial subset with held-out benchmark InChIKey-14 identities |
48
- | `sharealike` / `data/irexp_sharealike.jsonl.gz` | 1,897 | **Companion** — Chemotion + rare PMC ShareAlike; CC-BY-SA-4.0; **excluded from** the CC-BY DoR |
49
- | `non_commercial` / `data/irexp_non_commercial.jsonl.gz` | 21,823 | **Companion** — NC* (per-record policy licences, including CC-BY-NC-ND); **excluded from** the CC-BY DoR |
50
- | `other` / `data/irexp_other.jsonl.gz` | 5 | **Companion** — CC-BY-ND; **excluded from** the CC-BY DoR |
 
51
 
52
- Also present: `data/f1_commercial_build_stats.json`, `NOTICE`, `LICENCE_REMEDIATION.md`, `scripts/release_check.py`.
53
 
54
- **Release note (this revision).** The commercial DoR was 88,545 on the prior Hub revision. After correcting thousands-separators in band lists, the ≥3-band inclusion rule was reapplied (−26 rows). Duplicate integer band positions within a list were removed in place (row count unchanged). The structure-linked subset was rebuilt as commercial records with a non-empty SMILES string (29,255). Six commercial rows with non-empty SMILES had `has_structure=false`; flags were set to `true` to match Table 1 (True when SMILES present). The five CC-BY-ND rows are published as the `other` companion for licence-pool symmetry with published NC-ND; empty/unknown (8,963) remain off this Hub revision.
55
 
56
- **Not on this Hub revision:** the multi-licence research total (`irexp.jsonl.gz`, n=121,233), empty/unknown (8,963), harvest snapshots, and quarantine lists. Those remain research-corpus material.
57
 
58
- The research corpus (construction / licence-pool accounting) is 121,233 records (119,345 PMC + 1,888 Chemotion). Only the commercial pool is the public DoR.
 
 
59
 
60
- ## Licence
 
 
 
 
 
 
 
 
 
61
 
62
- - Commercial DoR: Hub YAML `cc-by-4.0` packaging; per-record source licences stamped.
63
- - ShareAlike companion: source licence CC-BY-SA-4.0 — do not relicense as CC-BY.
64
- - Non-commercial companion: Hub YAML also lists `cc-by-nc-4.0` so the card reflects the NC pool; **policy licences on each NC row still apply** (CC-BY-NC, CC-BY-NC-ND, CC-BY-NC-SA as stamped). Honour NC terms; not part of the CC-BY DoR.
65
- - Other companion: five CC-BY-ND rows (`license_pool=other`); not part of the CC-BY DoR.
66
- - Every row carries `license`, `license_pool`, `license_raw`, `license_source` (plus source DOI / PMCID where available).
67
 
68
- ## Quality flags (commercial DoR)
 
 
 
69
 
70
- Flag-only fields; flagged rows are retained in the commercial n=88,519:
71
 
72
- - `ir_shared_in_paper` — identical IR list shared by ≥2 records in one paper.
73
- - `ir_table_flatten_suspect` — suspected table-flatten / column-misread list.
 
 
 
 
 
74
 
75
- Filter locally if needed. Audit fields `ir_bands_old_cm-1`, `ir_refetch_confirmed`, and `ir_refetch_merged` document reparse and refetch history.
 
 
 
 
 
76
 
77
  ## Load
78
 
@@ -80,14 +103,17 @@ Filter locally if needed. Audit fields `ir_bands_old_cm-1`, `ir_refetch_confirme
80
  from datasets import load_dataset
81
 
82
  dor = load_dataset("ilkhamfy/IRexp", "commercial", split="train")
83
- sa = load_dataset("ilkhamfy/IRexp", "sharealike", split="train")
84
  nc = load_dataset("ilkhamfy/IRexp", "non_commercial", split="train")
85
- other = load_dataset("ilkhamfy/IRexp", "other", split="train") # CC-BY-ND (n=5)
86
  ```
87
 
 
 
 
 
88
  ## Citation
89
 
90
- Cite the Scientific Data Data Descriptor (when published) and this Hub revision. Zenodo archival DOI for the commercial primary file: https://doi.org/10.5281/zenodo.22822285.
91
 
92
  ## Links
93
 
@@ -95,3 +121,7 @@ Cite the Scientific Data Data Descriptor (when published) and this Hub revision.
95
  - Manuscript / figures: https://github.com/IlkhamFY/IRexp
96
  - Extraction tooling: https://github.com/IlkhamFY/spectro-agent
97
  - Licence details: `NOTICE`, `LICENCE_REMEDIATION.md`
 
 
 
 
 
13
  - cheminformatics
14
  - open-data
15
  size_categories:
16
+ - 100K<n<1M
17
  pretty_name: IRexp
18
  configs:
19
  - config_name: commercial
 
28
  data_files: data/irexp_non_commercial.jsonl.gz
29
  - config_name: other
30
  data_files: data/irexp_other.jsonl.gz
31
+ - config_name: structure_quarantine
32
+ data_files: data/structure_quarantine.jsonl.gz
33
  ---
34
 
35
+ # IRexp: experimental IR band lists
36
 
37
+ IRexp is an openly redistributable collection of **experimental infrared band lists** mined from open-access chemistry literature (PMC Open Access main text and supporting information) and a Chemotion deposit, often with co-reported ¹H/¹³C NMR strings and resolved structures (SMILES / InChIKey / SELFIES).
38
 
39
+ > **Important:** IRexp contains **band lists** (peak positions in cm⁻¹), not digitised absorbance traces.
40
 
41
+ This repository is the Scientific Data **dataset of record (DoR)** for the commercial (CC-BY / CC0) pool, plus separately licensed companions on the same revision. It is a data release only: no model scores are shipped here.
42
 
43
+ ## Files on this revision
44
 
45
  | Config / file | Records | Role |
46
  |---|---:|---|
47
+ | `commercial` / `data/irexp_commercial.jsonl.gz` | **163,931** | **Dataset of record**: CC-BY + CC0; CC-BY-4.0 packaging |
48
+ | `resolved_commercial` / `data/irexp_resolved_commercial.jsonl.gz` | 67,235 | Commercial rows with a structure (tiers A–D) |
49
+ | `train_no_bench_commercial` / `data/train_no_bench_commercial.jsonl.gz` | 67,093 | That subset without the 248 benchmark InChIKey-14 keys |
50
+ | `sharealike` / `data/irexp_sharealike.jsonl.gz` | 1,897 | Companion: Chemotion + rare PMC ShareAlike; CC-BY-SA-4.0; **excluded from** the CC-BY DoR |
51
+ | `non_commercial` / `data/irexp_non_commercial.jsonl.gz` | 65,007 | Companion: NC* (CC-BY-NC, CC-BY-NC-ND, CC-BY-NC-SA, stamped per row); **excluded from** the CC-BY DoR |
52
+ | `other` / `data/irexp_other.jsonl.gz` | 5 | Companion: CC-BY-ND; **excluded from** the CC-BY DoR |
53
+ | `structure_quarantine` / `data/structure_quarantine.jsonl.gz` | 8,431 | Ids only: tier-X structures withheld (8,132) plus formula–NMR diagnostic flags (299) |
54
 
55
+ Also present: `data/seen_papers.txt.gz` (220,159 PMC identifiers scanned), `data/irexp_release_build_stats.json`, `data/SHA256SUMS.txt`, `NOTICE`, `LICENCE_REMEDIATION.md`, `scripts/release_check.py`, `scripts/build_release.py`.
56
 
57
+ Public downloadable total (commercial + non-commercial + ShareAlike + ND): **230,840**. The research corpus is **239,735** records; the 8,895 rows with an empty or unknown licence are not redistributed.
58
 
59
+ ## What changed in this release
60
 
61
+ 1. **IR-attachment fix (v4 parser).** IR blocks are assigned within each compound's own section of the experimental text instead of to the nearest NMR block. Rows whose IR belonged to a neighbouring compound were repaired or removed. The PMC main-text part is now 116,320 research rows (previously 119,345).
62
+ 2. **Supporting-information expansion.** 121,527 new band lists from the SI files of 5,688 PMC Open Access papers, parsed with the same rules (≥3 bands, 400–4000 cm⁻¹, within-list integer-band dedup, dedup against existing rows, licence join per article). Rows from articles without a redistributable licence were not kept.
63
+ 3. **Strict structure tiers.** Every structure now carries `structure_tier`:
64
 
65
+ | Tier | Rule | Research corpus (239,735) |
66
+ |---|---|---:|
67
+ | A | formula/HRMS match in the compound's own block **plus** an independent second method (PubChem name lookup or OCSR drawing) agreeing on InChIKey-14 | 7,366 |
68
+ | B | formula/HRMS match in the own block | 48,669 |
69
+ | C | no formula; the source passed a ≥97% held-out agreement check | 21,455 |
70
+ | D | IR-only rows, OCSR without a formula, or the Chemotion deposit structure on IR-only rows | 24,134 |
71
+ | X | contradiction (for example IR and NMR from two different compounds, invalid or salt structure): **structure withheld**, row kept | 8,473 |
72
+ | none | no structure | 129,638 |
73
+
74
+ Tiers A–B: 56,035 (23.4%). Tiers A–D (rows with a released structure): 101,624 (42.4%). OCSR alone is never tier A. Methods ship only at ≥97% held-out precision.
75
 
76
+ ## New and changed columns
 
 
 
 
77
 
78
+ - `structure_tier` (A/B/C/D/X/null), `structure_method`, `structure_second_method` (tier A only), `formula_match`, `structure_flags` (`formula_conflict`, `pubchem_conflict`, IR plausibility flags; flag-only).
79
+ - `source_set`: `pmc_v4` (main text), `si_2026` (supporting information), `chemotion`.
80
+ - SI rows also carry `si_label`, `si_name`, `ir_raw` (author IR string) and `parser`.
81
+ - `ir_bands_old_cm-1` on SI rows is the list before within-list integer dedup. `ir_table_flatten_suspect` is null on SI rows (not computed for that set).
82
 
83
+ ## Quality checks (automated and AI audits; not human audits)
84
 
85
+ - SI band lists, AI audit of 150 random rows: bands correct 149/150, compound attribution 149/150, experimental IR 150/150.
86
+ - SI structures before strict tiers, AI audit of 150 random resolved rows: 146/150 correct (Wilson 95% CI 93.3–99.0%).
87
+ - Formula-check promotions on the main text, AI audit: 40/40 correct (Wilson 91.2–100%).
88
+ - OCSR label-B rule on 100 held-out papers: 104/104 (Wilson 96.4–100%). On the full main-text OCSR run the same rule scored 95.1%, below the 97% bar, so those structures were shipped as tier D only.
89
+ - IR/NMR split headings: 12/12 verified as genuine separate compounds (these rows are tier X).
90
+
91
+ ## Licence
92
 
93
+ - Commercial DoR: YAML `cc-by-4.0` packaging; per-record source licences stamped.
94
+ - ShareAlike companion: CC-BY-SA-4.0. Do not relicense as CC-BY.
95
+ - Non-commercial companion: YAML lists `cc-by-nc-4.0` so the card reflects the NC pool; **the per-row policy licences apply** (CC-BY-NC, CC-BY-NC-ND, CC-BY-NC-SA). Not part of the CC-BY DoR.
96
+ - Other companion: five CC-BY-ND rows; not part of the CC-BY DoR.
97
+ - Every row carries `license`, `license_pool`, `license_raw`, `license_source`, plus `source_doi` / `pmcid` / `doi`.
98
+ - Only extracted numbers and identifiers are redistributed; no article text, figures or PDFs.
99
 
100
  ## Load
101
 
 
103
  from datasets import load_dataset
104
 
105
  dor = load_dataset("ilkhamfy/IRexp", "commercial", split="train")
106
+ res = dor.filter(lambda r: r["structure_tier"] in ("A", "B")) # formula-verified structures
107
  nc = load_dataset("ilkhamfy/IRexp", "non_commercial", split="train")
 
108
  ```
109
 
110
+ ## Training without benchmark leakage
111
+
112
+ `train_no_bench_commercial` withholds the 248 InChIKey-14 keys of the locked benchmark rounds (locked 194 and electrolyte). Keys of later expansion rounds are not filtered, so fine-tuned models should be scored on the locked 194.
113
+
114
  ## Citation
115
 
116
+ Cite the Scientific Data Data Descriptor (when published) and this Hub revision. Zenodo version DOI for the commercial files of this release: https://doi.org/10.5281/zenodo.23463965 (concept DOI, always the latest version: https://doi.org/10.5281/zenodo.22822284).
117
 
118
  ## Links
119
 
 
121
  - Manuscript / figures: https://github.com/IlkhamFY/IRexp
122
  - Extraction tooling: https://github.com/IlkhamFY/spectro-agent
123
  - Licence details: `NOTICE`, `LICENCE_REMEDIATION.md`
124
+
125
+ ## Previous revision
126
+
127
+ `4312254c279300f881ad12671476e877027ed3da`: commercial DoR 88,519 (archived at https://doi.org/10.5281/zenodo.23023528).
data/SHA256SUMS.txt CHANGED
@@ -1,8 +1,9 @@
1
- a9403e7b6f6c1d6181f40fd78d66a7c3f202cc15d363bcb25869db5ed59c8eb5 f1_commercial_build_stats.json
2
- d1e363fafe7d29985eb80bf17e1c218ad826268ee4cfa76ab5895be3da011798 irexp_commercial.jsonl.gz
3
- 8c60800c9222eb48f2e1256c13380ab6a7c4680f7bac515f45a2373d0a3e8c8b irexp_non_commercial.jsonl.gz
4
- b8710a52aa97537f708e358751783a1ea8ab927eb24b68ef584326276aaa6def irexp_other.jsonl.gz
5
- 145adcc29b597774f4d0134e5dc42cdc4acc459a906f6e406b69c3e5fb6232a7 irexp_resolved_commercial.jsonl.gz
6
- 21af64a91fb51e0694a3f4c665b89349de86ce3826197ecd6f6357fb26501e6e irexp_sharealike.jsonl.gz
7
- b7c05953558c0e6b48655e01792294823d866c58ee64a5cc32ae626c50cc531d patch_meta_presubmit.json
8
- 509fbd9eaff073f0c313424df62ce0794ee76c8c014fbb3d7860e96e544cc418 train_no_bench_commercial.jsonl.gz
 
 
1
+ 3c784a3b1b5aba753127c25ff256097bba6e3dd17e864af6671b6d68ccd66b2f irexp_commercial.jsonl.gz
2
+ 6d777812ce6625880040998bfd43fc421a4f215ba7e46519ebf478625da8b2be irexp_resolved_commercial.jsonl.gz
3
+ 00069af9bb4b3e5f5615d3db605d72bb6b837e78127deb6aed643d9cfc80e52d train_no_bench_commercial.jsonl.gz
4
+ 6dfb27544a3b87feb2909e66614c884fde0c9ad61046eff9999c048a09fc220c irexp_non_commercial.jsonl.gz
5
+ 494d306dce39ced51089a3a3728054f993b220d282c77ce115c5305beea73596 irexp_sharealike.jsonl.gz
6
+ 52e4a0a6ba1ba7136896df0015812973bffdf4b90c855af98a642b767cebcf25 irexp_other.jsonl.gz
7
+ 29808d9d7a9ff8cd8be25295db3d5eed3e95272ce945331784314133c2534f51 structure_quarantine.jsonl.gz
8
+ ad0c91414f8a85463ae847a688ece35f5b5b4c87cb47e5896027114fd6587282 seen_papers.txt.gz
9
+ b4930118e4b8cae62705b197694a61dc9db65687565e4e7aef513c78001211da irexp_release_build_stats.json
data/f1_commercial_build_stats.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "commercial": {
3
- "label": "commercial",
4
- "n_commercial": 88519,
5
- "n_previous_hub": 88545,
6
- "dropped_lt3": 26,
7
- "deduped_integer_bands": 1432,
8
- "note": "Reapplied \u22653-band filter after thousands-separator reparse; order-preserving unique of integer cm\u22121 within each list. ND (5) published separately as other companion (not merged into commercial).",
9
- "bytes_approx": 10853218
10
- },
11
- "resolved_commercial": {
12
- "label": "resolved_commercial",
13
- "n_commercial": 29255,
14
- "n_previous_hub": 28899,
15
- "invariant": "resolved_commercial = commercial \u2229 nonempty(smiles)",
16
- "bytes_approx": 4646831
17
- },
18
- "train_no_bench_commercial": {
19
- "label": "train_no_bench_commercial",
20
- "n_commercial": 29109,
21
- "n_previous_hub": 28753,
22
- "skipped_benchmark_ids": 146,
23
- "invariant": "train_no_bench_commercial \u2286 resolved_commercial",
24
- "bytes_approx": 4626653
25
- },
26
- "non_commercial": {
27
- "n": 21823,
28
- "deduped_integer_bands": 319
29
- },
30
- "sharealike": {
31
- "n": 1897
32
- },
33
- "patched_from_hub_rev": "50d615533563e5071efd27bd7a0f93aa1025b69b",
34
- "has_structure_presubmit": {
35
- "flipped_to_true": 6,
36
- "ids": [
37
- "ABWOQVYUYOZDPM-UHFFFAOYSA-N",
38
- "HEKOVRRPURYUEM-UHFFFAOYSA-N",
39
- "MFQSCMXWQUQCBL-UHFFFAOYSA-N",
40
- "NWIJCILLNNWXQP-UHFFFAOYSA-N",
41
- "SSVMNDFIYNDYTJ-UHFFFAOYSA-N",
42
- "VFSNNVLONLFMCD-UHFFFAOYSA-N"
43
- ],
44
- "note": "Aligned with Table 1: has_structure True when SMILES present."
45
- },
46
- "other_nd": {
47
- "n": 5,
48
- "published_on_hub": true,
49
- "file": "data/irexp_other.jsonl.gz"
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/irexp_commercial.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d1e363fafe7d29985eb80bf17e1c218ad826268ee4cfa76ab5895be3da011798
3
- size 10853220
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c784a3b1b5aba753127c25ff256097bba6e3dd17e864af6671b6d68ccd66b2f
3
+ size 23256461
data/irexp_non_commercial.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8c60800c9222eb48f2e1256c13380ab6a7c4680f7bac515f45a2373d0a3e8c8b
3
- size 2419718
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dfb27544a3b87feb2909e66614c884fde0c9ad61046eff9999c048a09fc220c
3
+ size 9055476
data/irexp_other.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b8710a52aa97537f708e358751783a1ea8ab927eb24b68ef584326276aaa6def
3
- size 700
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52e4a0a6ba1ba7136896df0015812973bffdf4b90c855af98a642b767cebcf25
3
+ size 823
data/irexp_release_build_stats.json ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "counts": {
3
+ "commercial": 163931,
4
+ "resolved_commercial": 67235,
5
+ "train_no_bench_commercial": 67093,
6
+ "non_commercial": 65007,
7
+ "sharealike": 1897,
8
+ "other": 5,
9
+ "structure_quarantine": 8431
10
+ },
11
+ "files": {
12
+ "commercial": {
13
+ "records": 163931,
14
+ "structure_linked": 67235,
15
+ "unique_inchikey": 64107,
16
+ "bands": 1916743,
17
+ "papers": 15390,
18
+ "tiers": {
19
+ "none": 90526,
20
+ "B": 31800,
21
+ "C": 15791,
22
+ "X": 6170,
23
+ "D": 15146,
24
+ "A": 4498
25
+ },
26
+ "by_set": {
27
+ "pmc_v4": 85878,
28
+ "si_2026": 78053
29
+ },
30
+ "full_quadruple": 36927,
31
+ "lt3": 0,
32
+ "band_out_of_range": 0
33
+ },
34
+ "non_commercial": {
35
+ "records": 65007,
36
+ "structure_linked": 27917,
37
+ "unique_inchikey": 27170,
38
+ "bands": 780919,
39
+ "papers": 4451,
40
+ "tiers": {
41
+ "B": 13986,
42
+ "none": 35214,
43
+ "C": 4871,
44
+ "D": 6507,
45
+ "X": 1876,
46
+ "A": 2553
47
+ },
48
+ "by_set": {
49
+ "pmc_v4": 21533,
50
+ "si_2026": 43474
51
+ },
52
+ "full_quadruple": 13739,
53
+ "lt3": 0,
54
+ "band_out_of_range": 0
55
+ },
56
+ "sharealike": {
57
+ "records": 1897,
58
+ "structure_linked": 1804,
59
+ "unique_inchikey": 1804,
60
+ "bands": 72717,
61
+ "papers": 2,
62
+ "tiers": {
63
+ "none": 7,
64
+ "B": 2,
65
+ "D": 1802,
66
+ "X": 86
67
+ },
68
+ "by_set": {
69
+ "pmc_v4": 9,
70
+ "chemotion": 1888
71
+ },
72
+ "full_quadruple": 2,
73
+ "lt3": 0,
74
+ "band_out_of_range": 0
75
+ },
76
+ "other": {
77
+ "records": 5,
78
+ "structure_linked": 0,
79
+ "unique_inchikey": 0,
80
+ "bands": 100,
81
+ "papers": 2,
82
+ "tiers": {
83
+ "none": 5
84
+ },
85
+ "by_set": {
86
+ "pmc_v4": 5
87
+ },
88
+ "full_quadruple": 0,
89
+ "lt3": 0,
90
+ "band_out_of_range": 0
91
+ }
92
+ },
93
+ "resolved_commercial": {
94
+ "records": 67235,
95
+ "structure_linked": 67235,
96
+ "unique_inchikey": 64107,
97
+ "bands": 758501,
98
+ "papers": 7022,
99
+ "tiers": {
100
+ "B": 31800,
101
+ "C": 15791,
102
+ "D": 15146,
103
+ "A": 4498
104
+ },
105
+ "by_set": {
106
+ "pmc_v4": 37116,
107
+ "si_2026": 30119
108
+ },
109
+ "full_quadruple": 36927,
110
+ "lt3": 0,
111
+ "band_out_of_range": 0
112
+ },
113
+ "train_no_bench_commercial": {
114
+ "records": 67093,
115
+ "structure_linked": 67093,
116
+ "unique_inchikey": 63971,
117
+ "bands": 756907,
118
+ "papers": 7019,
119
+ "tiers": {
120
+ "B": 31710,
121
+ "C": 15749,
122
+ "D": 15146,
123
+ "A": 4488
124
+ },
125
+ "by_set": {
126
+ "pmc_v4": 36974,
127
+ "si_2026": 30119
128
+ },
129
+ "full_quadruple": 36786,
130
+ "lt3": 0,
131
+ "band_out_of_range": 0
132
+ },
133
+ "released_total": 230840,
134
+ "research_corpus": {
135
+ "n": 239735,
136
+ "tiers": {
137
+ "none": 129638,
138
+ "B": 48669,
139
+ "C": 21455,
140
+ "X": 8473,
141
+ "D": 24134,
142
+ "A": 7366
143
+ },
144
+ "AB": 56035,
145
+ "AB_pct": 23.37,
146
+ "AD": 101624,
147
+ "AD_pct": 42.39
148
+ },
149
+ "released_tiers": {
150
+ "none": 125752,
151
+ "B": 45788,
152
+ "C": 20662,
153
+ "X": 8132,
154
+ "D": 23455,
155
+ "A": 7051
156
+ },
157
+ "tiers_by_pool": {
158
+ "commercial/A": 4498,
159
+ "commercial/B": 31800,
160
+ "commercial/C": 15791,
161
+ "commercial/D": 15146,
162
+ "commercial/X": 6170,
163
+ "commercial/none": 90526,
164
+ "non_commercial/A": 2553,
165
+ "non_commercial/B": 13986,
166
+ "non_commercial/C": 4871,
167
+ "non_commercial/D": 6507,
168
+ "non_commercial/X": 1876,
169
+ "non_commercial/none": 35214,
170
+ "other/none": 5,
171
+ "sharealike/B": 2,
172
+ "sharealike/D": 1802,
173
+ "sharealike/X": 86,
174
+ "sharealike/none": 7
175
+ },
176
+ "stats": {
177
+ "v4_x_structure_removed_commercial": 4278,
178
+ "v4_structure_added_commercial": 2310,
179
+ "v4_structure_added_non_commercial": 533,
180
+ "v4_x_structure_removed_non_commercial": 815,
181
+ "v4_x_structure_removed_sharealike": 86,
182
+ "v4_rows": 109313,
183
+ "si_dup_int_band_rows_commercial": 537,
184
+ "si_dup_int_band_rows_non_commercial": 349,
185
+ "si_rows_in": 121527,
186
+ "si_rows_out": 121527
187
+ },
188
+ "seen_papers": {
189
+ "v4": 188016,
190
+ "total": 220159
191
+ },
192
+ "quarantine_reasons": {
193
+ "tier_X": 8132,
194
+ "c13_peaks_gt_carbons": 163,
195
+ "h1_integration_gt_formula_plus_2": 136
196
+ },
197
+ "benchmark_ik14": 248
198
+ }
data/irexp_resolved_commercial.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:145adcc29b597774f4d0134e5dc42cdc4acc459a906f6e406b69c3e5fb6232a7
3
- size 4646811
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d777812ce6625880040998bfd43fc421a4f215ba7e46519ebf478625da8b2be
3
+ size 11633640
data/irexp_sharealike.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:21af64a91fb51e0694a3f4c665b89349de86ce3826197ecd6f6357fb26501e6e
3
- size 258270
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:494d306dce39ced51089a3a3728054f993b220d282c77ce115c5305beea73596
3
+ size 264884
data/patch_meta.json DELETED
@@ -1,240 +0,0 @@
1
- {
2
- "commercial_old": 88545,
3
- "commercial_new": 88519,
4
- "dropped": [
5
- {
6
- "id": "82543b9311ceb3f6216d",
7
- "pmcid": "PMC6271600",
8
- "n_bands": 1,
9
- "bands": [
10
- 471.5
11
- ],
12
- "in_drop_list": true
13
- },
14
- {
15
- "id": "CRTKEGAHXINQAO-MKMNVTDBSA-N",
16
- "pmcid": "PMC6271600",
17
- "n_bands": 0,
18
- "bands": [],
19
- "in_drop_list": true
20
- },
21
- {
22
- "id": "UFFZJOLWCBNFJJ-UHFFFAOYSA-N",
23
- "pmcid": "PMC6271600",
24
- "n_bands": 0,
25
- "bands": [],
26
- "in_drop_list": true
27
- },
28
- {
29
- "id": "WLNOTYKLRHLKIX-MKMNVTDBSA-N",
30
- "pmcid": "PMC6271600",
31
- "n_bands": 1,
32
- "bands": [
33
- 3811.0
34
- ],
35
- "in_drop_list": true
36
- },
37
- {
38
- "id": "VVBDJRNCALMXCU-UHFFFAOYSA-N",
39
- "pmcid": "PMC6271600",
40
- "n_bands": 0,
41
- "bands": [],
42
- "in_drop_list": true
43
- },
44
- {
45
- "id": "HFOOPPBDVOOJGT-UHFFFAOYSA-N",
46
- "pmcid": "PMC6271600",
47
- "n_bands": 1,
48
- "bands": [
49
- 520.43
50
- ],
51
- "in_drop_list": true
52
- },
53
- {
54
- "id": "2918cf238a7345c9990e",
55
- "pmcid": "PMC6271600",
56
- "n_bands": 2,
57
- "bands": [
58
- 484.4,
59
- 548.0
60
- ],
61
- "in_drop_list": true
62
- },
63
- {
64
- "id": "6be8723d27f7aead89e7",
65
- "pmcid": "PMC11701777",
66
- "n_bands": 0,
67
- "bands": [],
68
- "in_drop_list": true
69
- },
70
- {
71
- "id": "BYSCDXUVBHRSJZ-UHFFFAOYSA-N",
72
- "pmcid": "PMC11625556",
73
- "n_bands": 2,
74
- "bands": [
75
- 2908.0,
76
- 1725.0
77
- ],
78
- "in_drop_list": true
79
- },
80
- {
81
- "id": "KNQPSCBYHORSRO-UHFFFAOYSA-N",
82
- "pmcid": "PMC10552108",
83
- "n_bands": 2,
84
- "bands": [
85
- 1655.0,
86
- 1485.0
87
- ],
88
- "in_drop_list": true
89
- },
90
- {
91
- "id": "LANOVFBPKPZBSX-UHFFFAOYSA-N",
92
- "pmcid": "PMC10552108",
93
- "n_bands": 2,
94
- "bands": [
95
- 1669.0,
96
- 1303.0
97
- ],
98
- "in_drop_list": true
99
- },
100
- {
101
- "id": "a495b878d51ec42a6ad6",
102
- "pmcid": "PMC10833406",
103
- "n_bands": 0,
104
- "bands": [],
105
- "in_drop_list": true
106
- },
107
- {
108
- "id": "e280d5487f1c8913cb3d",
109
- "pmcid": "PMC8819441",
110
- "n_bands": 0,
111
- "bands": [],
112
- "in_drop_list": true
113
- },
114
- {
115
- "id": "6b8bc59f4b554ea17b32",
116
- "pmcid": "PMC9010074",
117
- "n_bands": 1,
118
- "bands": [
119
- 2315.0
120
- ],
121
- "in_drop_list": true
122
- },
123
- {
124
- "id": "b84dd30e882130a2d1ef",
125
- "pmcid": "PMC9688225",
126
- "n_bands": 2,
127
- "bands": [
128
- 2700.0,
129
- 1709.33
130
- ],
131
- "in_drop_list": true
132
- },
133
- {
134
- "id": "0406f3ebb3d9753f1ce5",
135
- "pmcid": "PMC8303174",
136
- "n_bands": 0,
137
- "bands": [],
138
- "in_drop_list": true
139
- },
140
- {
141
- "id": "245d841904ba9d33a218",
142
- "pmcid": "PMC8707475",
143
- "n_bands": 0,
144
- "bands": [],
145
- "in_drop_list": true
146
- },
147
- {
148
- "id": "513ba0e6d6a9227f0df8",
149
- "pmcid": "PMC7054417",
150
- "n_bands": 0,
151
- "bands": [],
152
- "in_drop_list": true
153
- },
154
- {
155
- "id": "ad98381d8f119ca8d637",
156
- "pmcid": "PMC6727057",
157
- "n_bands": 0,
158
- "bands": [],
159
- "in_drop_list": true
160
- },
161
- {
162
- "id": "8abe447b7a282f6be2f2",
163
- "pmcid": "PMC6099295",
164
- "n_bands": 2,
165
- "bands": [
166
- 819.0,
167
- 428.0
168
- ],
169
- "in_drop_list": true
170
- },
171
- {
172
- "id": "be20e932e87ac1a73e55",
173
- "pmcid": "PMC6099295",
174
- "n_bands": 1,
175
- "bands": [
176
- 400.0
177
- ],
178
- "in_drop_list": true
179
- },
180
- {
181
- "id": "a1b91bf246ef651d0f90",
182
- "pmcid": "PMC6099295",
183
- "n_bands": 1,
184
- "bands": [
185
- 445.0
186
- ],
187
- "in_drop_list": true
188
- },
189
- {
190
- "id": "e5d62449112ccad5f58e",
191
- "pmcid": "PMC5209758",
192
- "n_bands": 0,
193
- "bands": [],
194
- "in_drop_list": true
195
- },
196
- {
197
- "id": "0228d5168d65c201c5d7",
198
- "pmcid": "PMC4598625",
199
- "n_bands": 2,
200
- "bands": [
201
- 420.0,
202
- 3700.0
203
- ],
204
- "in_drop_list": true
205
- },
206
- {
207
- "id": "5a2ddff7c25ccc89770f",
208
- "pmcid": "PMC4174874",
209
- "n_bands": 0,
210
- "bands": [],
211
- "in_drop_list": true
212
- },
213
- {
214
- "id": "181bf87501cfe43138fd",
215
- "pmcid": "PMC4257448",
216
- "n_bands": 0,
217
- "bands": [],
218
- "in_drop_list": true
219
- }
220
- ],
221
- "deduped_commercial": 1432,
222
- "resolved_old": 28899,
223
- "resolved_new": 29255,
224
- "tnb_old": 28753,
225
- "tnb_new": 29109,
226
- "tnb_skip_id": 146,
227
- "tnb_skip_extra_ik14": 0,
228
- "held_ik14_n": 142,
229
- "deduped_nc": 319,
230
- "nc_n": 21823,
231
- "sa_n": 1897,
232
- "hs_false_with_smiles_in_comm": [
233
- "HEKOVRRPURYUEM-UHFFFAOYSA-N",
234
- "MFQSCMXWQUQCBL-UHFFFAOYSA-N",
235
- "NWIJCILLNNWXQP-UHFFFAOYSA-N",
236
- "VFSNNVLONLFMCD-UHFFFAOYSA-N",
237
- "ABWOQVYUYOZDPM-UHFFFAOYSA-N",
238
- "SSVMNDFIYNDYTJ-UHFFFAOYSA-N"
239
- ]
240
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/patch_meta_presubmit.json DELETED
@@ -1,30 +0,0 @@
1
- {
2
- "base_hub_rev": "fc238e3b600f556045bc9a3f7a37738734620cd8",
3
- "fixes": {
4
- "has_structure_flip_ids": [
5
- "ABWOQVYUYOZDPM-UHFFFAOYSA-N",
6
- "HEKOVRRPURYUEM-UHFFFAOYSA-N",
7
- "MFQSCMXWQUQCBL-UHFFFAOYSA-N",
8
- "NWIJCILLNNWXQP-UHFFFAOYSA-N",
9
- "SSVMNDFIYNDYTJ-UHFFFAOYSA-N",
10
- "VFSNNVLONLFMCD-UHFFFAOYSA-N"
11
- ],
12
- "decision": "flip has_structure=true (Table 1: True when SMILES present); RDKit parses + InChIKey match",
13
- "nd_publish": "add data/irexp_other.jsonl.gz (5 CC-BY-ND) as Hub companion; commercial DoR N unchanged 88519"
14
- },
15
- "counts": {
16
- "commercial": 88519,
17
- "resolved_commercial": 29255,
18
- "train_no_bench_commercial": 29109,
19
- "sharealike": 1897,
20
- "non_commercial": 21823,
21
- "other_nd": 5
22
- },
23
- "public_bands": {
24
- "commercial": 953310,
25
- "non_commercial": 230596,
26
- "sharealike": 72717,
27
- "sum": 1256623,
28
- "other_nd": 101
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/seen_papers.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad0c91414f8a85463ae847a688ece35f5b5b4c87cb47e5896027114fd6587282
3
+ size 586158
data/structure_quarantine.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29808d9d7a9ff8cd8be25295db3d5eed3e95272ce945331784314133c2534f51
3
+ size 134274
data/train_no_bench_commercial.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:509fbd9eaff073f0c313424df62ce0794ee76c8c014fbb3d7860e96e544cc418
3
- size 4626635
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00069af9bb4b3e5f5615d3db605d72bb6b837e78127deb6aed643d9cfc80e52d
3
+ size 11613493
scripts/build_release.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build the combined IRexp release (v4 IR-attachment fix + 2026 SI expansion) with strict structure tiers.
2
+ Inputs are the final local artifacts; nothing is fetched. Output: ../data (chmod 600)."""
3
+ import gzip,json,os,re,collections,hashlib
4
+ from rdkit import Chem, RDLogger; RDLogger.DisableLog('rdApp.*')
5
+ import selfies as sf
6
+ OUT='/workspace/irexp_release_237k/data/'
7
+ V4R='/workspace/irexp_v4_build/release/data/'
8
+ V4T='/workspace/irexp_growth/RESOLVE_237k/work/v4_tiers_final.jsonl.gz'
9
+ SIH='/workspace/irexp_growth/harvest/out/'
10
+ SIT='/workspace/irexp_growth/audit_rudra/new_tiers_final.jsonl'
11
+ SIS='/workspace/irexp_growth/structures/'
12
+ BENCH=set(json.load(open('/workspace/irexp_v4_build/work/bench_ik14.json')))
13
+ LIC={'CC BY':'CC-BY','CC BY-NC':'CC-BY-NC','CC BY-NC-ND':'CC-BY-NC-ND','CC BY-NC-SA':'CC-BY-NC-SA','CC BY-SA':'CC-BY-SA','CC0':'CC0'}
14
+ def mol_fields(smi):
15
+ m=Chem.MolFromSmiles(smi) if smi else None
16
+ if m is None: return None
17
+ can=Chem.MolToSmiles(m)
18
+ try: s=sf.encoder(can)
19
+ except Exception: s=None
20
+ return dict(smiles=can,inchikey=Chem.MolToInchiKey(m),selfies=s,_mol=m)
21
+ import sys as _sys
22
+ _sys.path.insert(0,'/workspace/irexp_v4_build/spectro-agent'); _sys.path.insert(0,'/workspace/irexp_v4_build/spectro-agent/scripts')
23
+ from quarantine_structure_nmr import gate_record as _gate_record
24
+ def nmr_check(m,h,c):
25
+ """spectro-agent scripts/quarantine_structure_nmr.py gate_record (same rules as the 2026-08-26 quarantine)."""
26
+ return [x for x in _gate_record({'smiles':Chem.MolToSmiles(m),'h_nmr':h,'c_nmr':c,'ir_bands_cm-1':[]}) if x!='no_smiles']
27
+ def bands_ok(b):
28
+ return all(350<=float(x)<=4000 for x in b)
29
+ pools=collections.defaultdict(list); quar=[]; stats=collections.Counter(); tiers=collections.Counter(); tiers_pool=collections.Counter()
30
+ # ---------- v4 rows ----------
31
+ T={}
32
+ for l in gzip.open(V4T,'rt'):
33
+ d=json.loads(l); T[d['id']]=d
34
+ for f,pool in [('irexp_commercial','commercial'),('irexp_non_commercial','non_commercial'),('irexp_sharealike','sharealike'),('irexp_other','other')]:
35
+ for l in gzip.open(V4R+f+'.jsonl.gz','rt'):
36
+ d=json.loads(l); t=T[d['id']]; tier=t['tier_final']
37
+ d['source_set']='pmc_v4' if pool!='sharealike' or d.get('pmcid') else 'chemotion'
38
+ if pool=='sharealike' and d.get('source'): d['source_set']='chemotion' if 'hemotion' in str(d.get('source')) else 'pmc_v4'
39
+ flags=[]
40
+ if t.get('formula_conflict'): flags.append('formula_conflict')
41
+ if t.get('pubchem_conflict'): flags.append('pubchem_conflict')
42
+ mf=None
43
+ if tier in 'ABCD' and t.get('smiles'):
44
+ mf=mol_fields(t['smiles'])
45
+ if mf is None: stats['v4_unparseable']+=1; tier='none'
46
+ if tier=='X':
47
+ if d.get('smiles'): stats['v4_x_structure_removed_'+pool]+=1
48
+ quar.append(dict(id=d['id'],license_pool=pool,source_set=d['source_set'],reasons=['tier_X:'+(t.get('x_reason') or t.get('base_why') or 'contradiction')]))
49
+ if mf:
50
+ if d.get('smiles') and Chem.MolToSmiles(Chem.MolFromSmiles(d['smiles']))==mf['smiles'] and d.get('selfies'):
51
+ mf['selfies']=d['selfies']
52
+ if not d.get('smiles'): stats['v4_structure_added_'+pool]+=1
53
+ d.update(smiles=mf['smiles'],inchikey=mf['inchikey'],selfies=mf['selfies'],has_structure=True)
54
+ else:
55
+ d.update(smiles=None,inchikey=None,selfies=None,has_structure=False)
56
+ d['structure_tier']=tier if tier in 'ABCD' else ('X' if tier=='X' else None)
57
+ d['structure_method']=(('ocsr:'+str(t['src_ocsr'].get('method'))) if t.get('src_ocsr') else t.get('method')) if mf else None
58
+ d['formula_match']=t.get('fm') if mf else None
59
+ d['structure_second_method']=('pubchem' if t.get('a_strict') else None) if tier=='A' else None
60
+ d['structure_flags']=flags
61
+ if mf:
62
+ q=nmr_check(mf['_mol'],d.get('h_nmr'),d.get('c_nmr'))
63
+ if q: quar.append(dict(id=d['id'],license_pool=pool,source_set=d['source_set'],inchikey=mf['inchikey'],reasons=q))
64
+ tiers[d['structure_tier'] or 'none']+=1; tiers_pool[(pool,d['structure_tier'] or 'none')]+=1
65
+ pools[pool].append(d)
66
+ stats['v4_rows']=sum(len(v) for v in pools.values())
67
+ # ---------- SI expansion ----------
68
+ NT={}
69
+ for l in open(SIT):
70
+ d=json.loads(l); NT[d['id']]=d
71
+ SFL={}
72
+ for f in ['structures_commercial.jsonl.gz','structures_non_commercial.jsonl.gz']:
73
+ for l in gzip.open(SIS+f,'rt'):
74
+ r=json.loads(l); SFL[r['id']]=r.get('ir_flags') or []
75
+ nsi=0
76
+ for p in ['commercial','non_commercial']:
77
+ for l in gzip.open(SIH+f'irexp_si_{p}.jsonl.gz','rt'):
78
+ s=json.loads(l); nsi+=1; t=NT[s['id']]; tier=t['tier']
79
+ b0=s['ir_bands_cm-1']; seenb=set(); nb=[]
80
+ for x in b0:
81
+ k=int(round(float(x)))
82
+ if k not in seenb: seenb.add(k); nb.append(x)
83
+ if len(nb)!=len(b0): stats['si_dup_int_band_rows_'+p]+=1
84
+ if len(nb)<3: stats['si_dropped_lt3_after_dedup_'+p]+=1; continue
85
+ lic=LIC.get(s['license'],s['license'])
86
+ d=dict(id=s['id'],**{'ir_bands_cm-1':nb,'ir_bands_old_cm-1':b0},ir_source=s['ir_source'],h_nmr=s.get('h_nmr'),c_nmr=s.get('c_nmr'),
87
+ smiles=None,selfies=None,inchikey=None,has_structure=False,source_doi='PMC:'+s['pmcid'][3:],license=lic,license_raw=s['license'],
88
+ license_pool=p,license_source='pmc_oa_s3',pmcid=s['pmcid'],doi=s.get('doi'),source_set='si_2026',si_label=s.get('label'),si_name=s.get('name'),
89
+ ir_raw=s.get('ir'),parser=s.get('parser'),ir_shared_in_paper=False,ir_table_flatten_suspect=None,ir_refetch_confirmed=False,ir_refetch_merged=False)
90
+ mf=None
91
+ if tier in ('A','B','C','D') and t.get('smiles'):
92
+ mf=mol_fields(t['smiles'])
93
+ if mf is None: stats['si_unparseable']+=1; tier='none'
94
+ if mf:
95
+ d.update(smiles=mf['smiles'],inchikey=mf['inchikey'],selfies=mf['selfies'],has_structure=True)
96
+ q=nmr_check(mf['_mol'],d.get('h_nmr'),d.get('c_nmr'))
97
+ if q: quar.append(dict(id=d['id'],license_pool=p,source_set='si_2026',inchikey=mf['inchikey'],reasons=q))
98
+ if tier=='X': quar.append(dict(id=d['id'],license_pool=p,source_set='si_2026',reasons=['tier_X:'+(t.get('x_reason') or 'contradiction')]))
99
+ d['structure_tier']=tier if tier in ('A','B','C','D','X') else None
100
+ meth=t.get('method')
101
+ if t.get('src')=='ocsr': meth='ocsr:'+str(meth)
102
+ d['structure_method']=meth if mf else None
103
+ d['formula_match']=t.get('formula_match') if mf else None
104
+ sm=[c for c in t.get('confirm',[]) if 'DISAGREES' not in c]
105
+ d['structure_second_method']=('; '.join(sm) or None) if d['structure_tier']=='A' else None
106
+ fl=list(SFL.get(s['id'],[]))
107
+ if any('DISAGREES' in c for c in t.get('confirm',[])): fl.append('pubchem_conflict')
108
+ d['structure_flags']=fl
109
+ tiers[d['structure_tier'] or 'none']+=1; tiers_pool[(p,d['structure_tier'] or 'none')]+=1
110
+ pools[p].append(d)
111
+ stats['si_rows_in']=nsi
112
+ grp=collections.Counter((r['pmcid'],tuple(int(round(float(x))) for x in r['ir_bands_cm-1'])) for p in ('commercial','non_commercial') for r in pools[p] if r['source_set']=='si_2026')
113
+ for p in ('commercial','non_commercial'):
114
+ for r in pools[p]:
115
+ if r['source_set']=='si_2026' and grp[(r['pmcid'],tuple(int(round(float(x))) for x in r['ir_bands_cm-1']))]>1: r['ir_shared_in_paper']=True; stats['si_ir_shared_in_paper']+=1
116
+ stats['si_rows_out']=sum(1 for p in ('commercial','non_commercial') for r in pools[p] if r['source_set']=='si_2026')
117
+ # ---------- write ----------
118
+ def w(name,rows):
119
+ path=OUT+name
120
+ with gzip.open(path,'wt',compresslevel=9) as g:
121
+ for r in rows: g.write(json.dumps(r,ensure_ascii=False)+'\n')
122
+ os.chmod(path,0o600); return len(rows)
123
+ counts={}
124
+ counts['commercial']=w('irexp_commercial.jsonl.gz',pools['commercial'])
125
+ res=[r for r in pools['commercial'] if r['has_structure']]
126
+ counts['resolved_commercial']=w('irexp_resolved_commercial.jsonl.gz',res)
127
+ tnb=[r for r in res if r['inchikey'][:14] not in BENCH]
128
+ counts['train_no_bench_commercial']=w('train_no_bench_commercial.jsonl.gz',tnb)
129
+ counts['non_commercial']=w('irexp_non_commercial.jsonl.gz',pools['non_commercial'])
130
+ counts['sharealike']=w('irexp_sharealike.jsonl.gz',pools['sharealike'])
131
+ counts['other']=w('irexp_other.jsonl.gz',pools['other'])
132
+ counts['structure_quarantine']=w('structure_quarantine.jsonl.gz',quar)
133
+ # seen papers: v4 list + SI list
134
+ seen=set(l.strip() for l in gzip.open('/workspace/irexp_v4_build/IRexp/data/seen_papers.txt.gz','rt') if l.strip())
135
+ n4=len(seen); seen|=set(l.strip() for l in open('/workspace/irexp_growth/harvest/seen_papers_si.txt') if l.strip())
136
+ with gzip.open(OUT+'seen_papers.txt.gz','wt') as g: g.write('\n'.join(sorted(seen))+'\n')
137
+ os.chmod(OUT+'seen_papers.txt.gz',0o600)
138
+ def agg(rows):
139
+ st=[r for r in rows if r['has_structure']]
140
+ return dict(records=len(rows),structure_linked=len(st),unique_inchikey=len({r['inchikey'] for r in st}),
141
+ bands=sum(len(r['ir_bands_cm-1']) for r in rows),papers=len({r.get('pmcid') or r.get('source_doi') for r in rows}),
142
+ tiers=dict(collections.Counter(r['structure_tier'] or 'none' for r in rows)),
143
+ by_set=dict(collections.Counter(r['source_set'] for r in rows)),
144
+ full_quadruple=sum(1 for r in st if r.get('h_nmr') and r.get('c_nmr')),
145
+ lt3=sum(1 for r in rows if len(r['ir_bands_cm-1'])<3),
146
+ band_out_of_range=sum(1 for r in rows if not bands_ok(r['ir_bands_cm-1'])))
147
+ # research corpus (incl. empty/unknown licence pool, not redistributed)
148
+ rc=collections.Counter();
149
+ for l in gzip.open(V4T,'rt'): rc[json.loads(l)['tier_final']]+=1
150
+ for d in NT.values(): rc[d['tier'] or 'none']+=1
151
+ N=sum(rc.values())
152
+ rep=dict(counts=counts,files={k:agg(v) for k,v in pools.items()},resolved_commercial=agg(res),train_no_bench_commercial=agg(tnb),
153
+ released_total=sum(len(v) for v in pools.values()),
154
+ research_corpus=dict(n=N,tiers=dict(rc),AB=rc['A']+rc['B'],AB_pct=round(100*(rc['A']+rc['B'])/N,2),AD=sum(rc[k] for k in 'ABCD'),AD_pct=round(100*sum(rc[k] for k in 'ABCD')/N,2)),
155
+ released_tiers=dict(tiers),tiers_by_pool={'%s/%s'%k:v for k,v in sorted(tiers_pool.items())},
156
+ stats=dict(stats),seen_papers=dict(v4=n4,total=len(seen)),quarantine_reasons=dict(collections.Counter(r['reasons'][0].split(':')[0] for r in quar)),
157
+ benchmark_ik14=len(BENCH))
158
+ json.dump(rep,open(OUT+'irexp_release_build_stats.json','w'),indent=1); os.chmod(OUT+'irexp_release_build_stats.json',0o600)
159
+ print(json.dumps(rep,indent=1))