Datasets:
release
Browse files- LICENCE_REMEDIATION.md +0 -134
- NOTICE +42 -45
- README.md +22 -72
- data/SHA256SUMS.txt +4 -8
- data/irexp_commercial.jsonl.gz +2 -2
- data/irexp_non_commercial.jsonl.gz +2 -2
- data/irexp_other.jsonl.gz +0 -3
- data/irexp_release_build_stats.json +0 -198
- data/irexp_resolved_commercial.jsonl.gz +0 -3
- data/irexp_sharealike.jsonl.gz +2 -2
- data/structure_quarantine.jsonl.gz +2 -2
- data/train_no_bench_commercial.jsonl.gz +0 -3
- scripts/build_release.py +0 -159
- scripts/release_check.py +110 -389
LICENCE_REMEDIATION.md
DELETED
|
@@ -1,134 +0,0 @@
|
|
| 1 |
-
# IRexp licence remediation (Track 1)
|
| 2 |
-
|
| 3 |
-
**Date:** 2026-08-26
|
| 4 |
-
**Branch:** `cursor/irexp-licence-remediation-9a67`
|
| 5 |
-
**Audit:** `docs/irexp_scientific_data_audit.md` (§C)
|
| 6 |
-
|
| 7 |
-
## Problem
|
| 8 |
-
|
| 9 |
-
PMC Open Access is **not** uniformly CC-BY. A prior blanket CC-BY claim (~19% NC/empty in a 200-PMCID sample) was incorrect for NOTICE / README / HF / Zenodo framing. Chemotion CC-BY-SA-4.0 was already correct.
|
| 10 |
-
|
| 11 |
-
## What we did
|
| 12 |
-
|
| 13 |
-
1. **`scripts/join_pmc_licences.py`** — extract unique `PMC:*` accessions from `data/irexp/irexp.jsonl.gz`, batch-query Europe PMC (`resultType=core` → `license`), cache hits, classify, stamp every record, write segregated pools.
|
| 14 |
-
2. **`scripts/split_license_pools.py`** — uses stamped `license_pool` / `license` (not DOI-prefix → CC-BY). Keeps `pool_of()` as provenance-only (`pmc` vs `chemotion`) for manuscript gate A.
|
| 15 |
-
3. Stamped full corpus + pool files under `data/irexp/`.
|
| 16 |
-
4. Honest updates: `data/NOTICE`, `README.md`, `.zenodo.json`, `data/irexp_release/README_HF.md`, minimal `docs/PAPER.md`.
|
| 17 |
-
|
| 18 |
-
## Classification policy
|
| 19 |
-
|
| 20 |
-
| Europe PMC / Chemotion | `license` | `license_pool` | Zenodo / Sci Data |
|
| 21 |
-
|---|---|---|---|
|
| 22 |
-
| `cc by`, versioned BY | CC-BY | **commercial** | **Primary redistributable** |
|
| 23 |
-
| `cc0` / public domain | CC0 | **commercial** | Primary |
|
| 24 |
-
| `cc by-nc`, `cc by-nc-nd`, `cc by-nc-sa` | CC-BY-NC* | **non_commercial** | Held-aside file |
|
| 25 |
-
| `cc by-sa` (PMC) | CC-BY-SA | **sharealike** | With Chemotion SA file |
|
| 26 |
-
| Chemotion RADAR4Chem | CC-BY-SA-4.0 | **sharealike** | SA file |
|
| 27 |
-
| `cc by-nd` | CC-BY-ND | **other** | Held aside (ND vs derived extracts) |
|
| 28 |
-
| Missing `license` field | EMPTY | **empty_unknown** | **Exclude from commercial pool** |
|
| 29 |
-
| No EPMC hit | UNKNOWN | **empty_unknown** | **Exclude from commercial pool** |
|
| 30 |
-
|
| 31 |
-
**Recommendation (implemented):** ship Sci Data / Zenodo **commercial-use pool** as the primary artifact; keep NC in a clearly labelled file; exclude empty/unknown from the commercial deposit; keep Chemotion (+ rare PMC SA) as a separate ShareAlike file.
|
| 32 |
-
|
| 33 |
-
## Counts (Europe PMC join + Crossref recovery, 2026-08-27)
|
| 34 |
-
|
| 35 |
-
### Records (n = 121,233)
|
| 36 |
-
|
| 37 |
-
| Pool | Records | % of corpus |
|
| 38 |
-
|---|---:|---:|
|
| 39 |
-
| **commercial** (CC-BY + CC0) | **88,545** | 73.0% |
|
| 40 |
-
| non_commercial (NC*) | 21,823 | 18.0% |
|
| 41 |
-
| sharealike (Chemotion 1,888 + PMC SA 9) | 1,897 | 1.6% |
|
| 42 |
-
| empty_unknown | 8,963 | 7.4% |
|
| 43 |
-
| other (CC-BY-ND) | 5 | <0.1% |
|
| 44 |
-
| **Total** | **121,233** | 100% |
|
| 45 |
-
|
| 46 |
-
### By `license` label (records)
|
| 47 |
-
|
| 48 |
-
| license | Records |
|
| 49 |
-
|---|---:|
|
| 50 |
-
| CC-BY | 87,588 |
|
| 51 |
-
| EMPTY | 10,664 |
|
| 52 |
-
| CC-BY-NC | 10,546 |
|
| 53 |
-
| CC-BY-NC-ND | 9,663 |
|
| 54 |
-
| CC-BY-SA-4.0 (Chemotion) | 1,888 |
|
| 55 |
-
| CC-BY-NC-SA | 729 |
|
| 56 |
-
| UNKNOWN | 117 |
|
| 57 |
-
| CC0 | 29 |
|
| 58 |
-
| CC-BY-SA (PMC) | 9 |
|
| 59 |
-
|
| 60 |
-
### Unique PMCIDs (15,416 articles)
|
| 61 |
-
|
| 62 |
-
| license | Articles |
|
| 63 |
-
|---|---:|
|
| 64 |
-
| CC-BY | 11,967 |
|
| 65 |
-
| CC-BY-NC | 1,235 |
|
| 66 |
-
| CC-BY-NC-ND | 1,190 |
|
| 67 |
-
| EMPTY | 864 |
|
| 68 |
-
| CC-BY-NC-SA | 134 |
|
| 69 |
-
| UNKNOWN | 21 |
|
| 70 |
-
| CC0 | 4 |
|
| 71 |
-
| CC-BY-SA | 1 |
|
| 72 |
-
|
| 73 |
-
Provenance totals unchanged: **119,345** PMC-sourced + **1,888** Chemotion.
|
| 74 |
-
|
| 75 |
-
## Artefacts
|
| 76 |
-
|
| 77 |
-
| Path | Role |
|
| 78 |
-
|---|---|
|
| 79 |
-
| `scripts/join_pmc_licences.py` | Join + stamp + write pools |
|
| 80 |
-
| `scripts/split_license_pools.py` | Report / re-materialise from stamps |
|
| 81 |
-
| `data/irexp/irexp.jsonl.gz` | Full corpus **with** `license*` fields |
|
| 82 |
-
| `data/irexp/pmc_licence_lookup.jsonl.gz` | Per-PMCID cache |
|
| 83 |
-
| `data/irexp/pmc_licence_summary.json` | Machine-readable counts |
|
| 84 |
-
| `data/irexp/licence_pools/irexp_commercial.jsonl.gz` | Zenodo primary (88,545) |
|
| 85 |
-
| `data/irexp/licence_pools/irexp_non_commercial.jsonl.gz` | NC held aside |
|
| 86 |
-
| `data/irexp/licence_pools/irexp_sharealike.jsonl.gz` | Chemotion + PMC SA |
|
| 87 |
-
| `data/irexp/licence_pools/irexp_empty_unknown.jsonl.gz` | Excluded from commercial |
|
| 88 |
-
| `data/irexp/licence_pools/irexp_other.jsonl.gz` | Empty placeholder (0 rows) |
|
| 89 |
-
|
| 90 |
-
Re-run:
|
| 91 |
-
|
| 92 |
-
```bash
|
| 93 |
-
python scripts/join_pmc_licences.py # network; resumable via cache
|
| 94 |
-
python scripts/split_license_pools.py # report
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
## Hugging Face re-upload (no credentials in-repo)
|
| 98 |
-
|
| 99 |
-
Public dataset: https://huggingface.co/datasets/ilkhamfy/IRexp
|
| 100 |
-
|
| 101 |
-
**Status (2026-08-27):** remirrored after Crossref recovery — Hub card + pools show commercial **88,545** / NC **21,823** / empty **8,963** / SA **1,897**. Re-run only if local stamps drift again:
|
| 102 |
-
|
| 103 |
-
```bash
|
| 104 |
-
# Preferred: repo helper (requires HF_TOKEN)
|
| 105 |
-
HF_TOKEN=hf_... python scripts/publish_hf.py
|
| 106 |
-
|
| 107 |
-
# Or huggingface-cli
|
| 108 |
-
huggingface-cli upload ilkhamfy/IRexp \
|
| 109 |
-
data/irexp/licence_pools/irexp_commercial.jsonl.gz \
|
| 110 |
-
data/irexp_commercial.jsonl.gz
|
| 111 |
-
huggingface-cli upload ilkhamfy/IRexp \
|
| 112 |
-
data/irexp/irexp.jsonl.gz data/irexp.jsonl.gz
|
| 113 |
-
huggingface-cli upload ilkhamfy/IRexp \
|
| 114 |
-
data/irexp_release/README_HF.md README.md
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
Set dataset card `license` list to reflect **cc-by-4.0** (commercial primary) **and** **cc-by-sa-4.0** (Chemotion/SA pool); document NC/empty as non-redistributed or separate configs. Card warning: full `irexp.jsonl.gz` is multi-licence; commercial training should use `license_pool == "commercial"` or the commercial file only.
|
| 118 |
-
|
| 119 |
-
## Zenodo
|
| 120 |
-
|
| 121 |
-
`.zenodo.json` at the repo root currently describes a **combined** research deposit
|
| 122 |
-
(IRexp + IRSpectra-Bench). For the **Scientific Data** archival record, mint a
|
| 123 |
-
**separate data-only** Zenodo deposit: primary file = commercial CC-BY pool;
|
| 124 |
-
Chemotion/SA as a second file under CC-BY-SA-4.0; NC and empty/unknown not in the
|
| 125 |
-
commercial artifact (may be uploaded as restricted/supplementary with clear labels).
|
| 126 |
-
Zenodo’s single `license` metadata field should be `cc-by-4.0` for the **primary**
|
| 127 |
-
commercial artifact; description text must state the SA companion and exclusions.
|
| 128 |
-
Do not invent a DOI in the manuscript until the data-only deposit is minted.
|
| 129 |
-
|
| 130 |
-
## Manuscript / gates
|
| 131 |
-
|
| 132 |
-
- Full corpus count remains 121,233; PMC/Chemotion provenance counts unchanged → `check_manuscript.py` gate A still passes via `pool_of` provenance split.
|
| 133 |
-
- Filter commercial rows at release time; do not shrink the on-disk research corpus.
|
| 134 |
-
- `docs/paper.tex` intentionally untouched (Track 1 rule).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOTICE
CHANGED
|
@@ -1,51 +1,48 @@
|
|
| 1 |
-
IRexp —
|
| 2 |
-
=================================
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
Attribution
|
| 39 |
-----------
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
license / license_pool. Commercial ML redistribution should use the commercial
|
| 43 |
-
pool only. ShareAlike remixing requires CC-BY-SA-4.0.
|
| 44 |
|
| 45 |
Code
|
| 46 |
----
|
| 47 |
-
|
| 48 |
-
MIT License.
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
Presubmit note (2026-09-28): five CC-BY-ND records are published as data/irexp_other.jsonl.gz (companion; not merged into the commercial DoR). Six commercial has_structure flags were aligned to nonempty SMILES (Table 1).
|
|
|
|
| 1 |
+
IRexp — licensing and attribution
|
| 2 |
+
=================================
|
| 3 |
+
|
| 4 |
+
IRexp redistributes extracted experimental fields only: IR band lists,
|
| 5 |
+
short NMR report strings, identifiers, and structures where present.
|
| 6 |
+
Article full text, PDFs, and figures are not redistributed.
|
| 7 |
+
|
| 8 |
+
Files
|
| 9 |
+
-----
|
| 10 |
+
data/irexp_commercial.jsonl.gz 190,049 records
|
| 11 |
+
Dataset of record (CC-BY-4.0 packaging, with per-record source licences).
|
| 12 |
+
164,016 CC-BY/CC0 records, and 26,033 records from no-derivatives-
|
| 13 |
+
licensed articles (26,028 CC-BY-NC-ND and 5 CC-BY-ND), marked
|
| 14 |
+
nd_source_licence=true. The source licence on each record is kept.
|
| 15 |
+
data/irexp_non_commercial.jsonl.gz 39,000 records
|
| 16 |
+
CC-BY-NC (38,277) and CC-BY-NC-SA (723). Source licences are kept.
|
| 17 |
+
The 723 CC-BY-NC-SA records carry both NonCommercial and ShareAlike
|
| 18 |
+
conditions and must not be relicensed as CC-BY.
|
| 19 |
+
data/irexp_sharealike.jsonl.gz 1,897 records
|
| 20 |
+
CC-BY-SA (9) and Chemotion CC-BY-SA-4.0 (1,888). Remix only under
|
| 21 |
+
CC-BY-SA-4.0; do not relicense as CC-BY.
|
| 22 |
+
data/structure_quarantine.jsonl.gz 8,457 ids
|
| 23 |
+
8,158 withheld tier-X ids and 299 formula–NMR flagged ids.
|
| 24 |
+
data/seen_papers.txt.gz
|
| 25 |
+
PMC identifiers scanned during harvest.
|
| 26 |
+
data/SHA256SUMS.txt
|
| 27 |
+
SHA256 checksums of the files above.
|
| 28 |
+
|
| 29 |
+
Headline total: 230,946 records. Not deposited: 8,789 harvested records
|
| 30 |
+
without an established licence.
|
| 31 |
+
|
| 32 |
+
Licences
|
| 33 |
+
--------
|
| 34 |
+
The CC-BY file is the dataset of record. Filter on nd_source_licence to
|
| 35 |
+
keep only records whose source licence permits adaptation. The
|
| 36 |
+
non-commercial and ShareAlike files keep their source licences. Every
|
| 37 |
+
record carries license, license_raw, license_source, and license_pool.
|
| 38 |
|
| 39 |
Attribution
|
| 40 |
-----------
|
| 41 |
+
Cite the IRexp Data Descriptor and this deposit. Attribute each record
|
| 42 |
+
through source_doi or pmcid.
|
|
|
|
|
|
|
| 43 |
|
| 44 |
Code
|
| 45 |
----
|
| 46 |
+
Harvest and pipeline code: https://github.com/IlkhamFY/spectro-agent
|
| 47 |
+
(MIT License). A deposit integrity script is at scripts/release_check.py.
|
| 48 |
+
Manuscript and figures: https://github.com/IlkhamFY/IRexp
|
|
|
|
|
|
README.md
CHANGED
|
@@ -18,80 +18,36 @@ pretty_name: IRexp
|
|
| 18 |
configs:
|
| 19 |
- config_name: commercial
|
| 20 |
data_files: data/irexp_commercial.jsonl.gz
|
| 21 |
-
- config_name: resolved_commercial
|
| 22 |
-
data_files: data/irexp_resolved_commercial.jsonl.gz
|
| 23 |
-
- config_name: train_no_bench_commercial
|
| 24 |
-
data_files: data/train_no_bench_commercial.jsonl.gz
|
| 25 |
-
- config_name: sharealike
|
| 26 |
-
data_files: data/irexp_sharealike.jsonl.gz
|
| 27 |
- config_name: non_commercial
|
| 28 |
data_files: data/irexp_non_commercial.jsonl.gz
|
| 29 |
-
- config_name:
|
| 30 |
-
data_files: data/
|
| 31 |
- config_name: structure_quarantine
|
| 32 |
data_files: data/structure_quarantine.jsonl.gz
|
| 33 |
---
|
| 34 |
|
| 35 |
-
# IRexp: experimental
|
| 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 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
|
| 46 |
|---|---:|---|
|
| 47 |
-
| `
|
| 48 |
-
| `
|
| 49 |
-
| `
|
| 50 |
-
| `
|
| 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 |
-
|
| 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 |
-
|
| 75 |
|
| 76 |
-
##
|
| 77 |
|
| 78 |
-
-
|
| 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)
|
| 84 |
-
|
| 85 |
-
- 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.
|
| 86 |
-
|
| 87 |
-
## Licence
|
| 88 |
-
|
| 89 |
-
- Commercial DoR: YAML `cc-by-4.0` packaging; per-record source licences stamped.
|
| 90 |
-
- ShareAlike companion: CC-BY-SA-4.0. Do not relicense as CC-BY.
|
| 91 |
-
- 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.
|
| 92 |
-
- Other companion: five CC-BY-ND rows; not part of the CC-BY DoR.
|
| 93 |
-
- Every row carries `license`, `license_pool`, `license_raw`, `license_source`, plus `source_doi` / `pmcid` / `doi`.
|
| 94 |
-
- Only extracted numbers and identifiers are redistributed; no article text, figures or PDFs.
|
| 95 |
|
| 96 |
## Load
|
| 97 |
|
|
@@ -99,25 +55,19 @@ Tiers A–B: 56,035 (23.4%). Tiers A–D (rows with a released structure): 101,6
|
|
| 99 |
from datasets import load_dataset
|
| 100 |
|
| 101 |
dor = load_dataset("ilkhamfy/IRexp", "commercial", split="train")
|
| 102 |
-
|
|
|
|
| 103 |
nc = load_dataset("ilkhamfy/IRexp", "non_commercial", split="train")
|
| 104 |
```
|
| 105 |
|
| 106 |
-
## Training without benchmark leakage
|
| 107 |
-
|
| 108 |
-
`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.
|
| 109 |
-
|
| 110 |
## Citation
|
| 111 |
|
| 112 |
-
Cite the
|
| 113 |
|
| 114 |
## Links
|
| 115 |
|
| 116 |
- Dataset: https://huggingface.co/datasets/ilkhamfy/IRexp
|
| 117 |
-
-
|
| 118 |
-
-
|
| 119 |
-
-
|
| 120 |
-
|
| 121 |
-
## Previous revision
|
| 122 |
-
|
| 123 |
-
`4312254c279300f881ad12671476e877027ed3da`: commercial DoR 88,519 (archived at https://doi.org/10.5281/zenodo.23023528).
|
|
|
|
| 18 |
configs:
|
| 19 |
- config_name: commercial
|
| 20 |
data_files: data/irexp_commercial.jsonl.gz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
- config_name: non_commercial
|
| 22 |
data_files: data/irexp_non_commercial.jsonl.gz
|
| 23 |
+
- config_name: sharealike
|
| 24 |
+
data_files: data/irexp_sharealike.jsonl.gz
|
| 25 |
- config_name: structure_quarantine
|
| 26 |
data_files: data/structure_quarantine.jsonl.gz
|
| 27 |
---
|
| 28 |
|
| 29 |
+
# IRexp: experimental infrared band lists
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
IRexp is a collection of **230,946 experimental infrared band lists** mined from PMC Open Access main text and supporting information and from Chemotion. The lists are peak positions in cm⁻¹, not absorbance traces. Many records also carry short ¹H or ¹³C NMR strings and a resolved structure.
|
| 32 |
|
| 33 |
+
## Files
|
| 34 |
|
| 35 |
+
Files are under `data/`.
|
| 36 |
|
| 37 |
+
| File | Records | Description |
|
| 38 |
|---|---:|---|
|
| 39 |
+
| `irexp_commercial.jsonl.gz` | 190,049 | Dataset of record (CC-BY-4.0 packaging, with per-record source licences): 164,016 CC-BY/CC0 records and 26,033 records from no-derivatives-licensed articles, marked `nd_source_licence` |
|
| 40 |
+
| `irexp_non_commercial.jsonl.gz` | 39,000 | CC-BY-NC and CC-BY-NC-SA; source licences kept |
|
| 41 |
+
| `irexp_sharealike.jsonl.gz` | 1,897 | CC-BY-SA, including 1,888 Chemotion records under CC-BY-SA-4.0 |
|
| 42 |
+
| `structure_quarantine.jsonl.gz` | 8,457 ids | Withheld tier-X ids (8,158) and formula–NMR flagged ids (299) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
Also present: `data/seen_papers.txt.gz` (PMC identifiers scanned during harvest), `data/SHA256SUMS.txt`, `NOTICE`, and `scripts/release_check.py`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
8,789 harvested records without an established licence are not deposited. Article full text, PDFs, and figures are not redistributed.
|
| 47 |
|
| 48 |
+
## Licences
|
| 49 |
|
| 50 |
+
The CC-BY file is the dataset of record. Filter on `nd_source_licence` to keep only records whose source licence permits adaptation. The non-commercial and ShareAlike files keep their source licences; the 723 CC-BY-NC-SA records carry both conditions, and ShareAlike rows, including all Chemotion rows, may be remixed only under CC-BY-SA-4.0. Attribute each record through `source_doi` or `pmcid`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
## Load
|
| 53 |
|
|
|
|
| 55 |
from datasets import load_dataset
|
| 56 |
|
| 57 |
dor = load_dataset("ilkhamfy/IRexp", "commercial", split="train")
|
| 58 |
+
cc_by = dor.filter(lambda r: not r["nd_source_licence"])
|
| 59 |
+
ab = dor.filter(lambda r: r["structure_tier"] in ("A", "B"))
|
| 60 |
nc = load_dataset("ilkhamfy/IRexp", "non_commercial", split="train")
|
| 61 |
```
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
## Citation
|
| 64 |
|
| 65 |
+
Cite the IRexp Data Descriptor (when published) and this deposit. Zenodo version DOI: https://doi.org/10.5281/zenodo.24117617 (concept DOI: https://doi.org/10.5281/zenodo.22822284).
|
| 66 |
|
| 67 |
## Links
|
| 68 |
|
| 69 |
- Dataset: https://huggingface.co/datasets/ilkhamfy/IRexp
|
| 70 |
+
- Archive: https://doi.org/10.5281/zenodo.24117617 (concept: https://doi.org/10.5281/zenodo.22822284)
|
| 71 |
+
- Manuscript and figures: https://github.com/IlkhamFY/IRexp
|
| 72 |
+
- Harvest and pipeline code: https://github.com/IlkhamFY/spectro-agent
|
| 73 |
+
- Licence details: `NOTICE`
|
|
|
|
|
|
|
|
|
data/SHA256SUMS.txt
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 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
|
|
|
|
| 1 |
+
3c5b29c20e56eefd8736e7cc0909e835dc60e62c7dd74ffe3e3288c1cf9b6d2a irexp_commercial.jsonl.gz
|
| 2 |
+
ec5876b93811ac262f5102375b927ee82305a94b10ffea171fb80c9eefb4f2f1 irexp_non_commercial.jsonl.gz
|
| 3 |
+
2d5e262118772306509b230fc8a5920d02bb5d8355b7ab6ed7af6f458708f457 irexp_sharealike.jsonl.gz
|
| 4 |
+
b160398c4f1c320c56a8cfa9eae3c2c83ca23d05b1146fd9c41c706bdc479d4e structure_quarantine.jsonl.gz
|
|
|
|
|
|
|
|
|
|
| 5 |
ad0c91414f8a85463ae847a688ece35f5b5b4c87cb47e5896027114fd6587282 seen_papers.txt.gz
|
|
|
data/irexp_commercial.jsonl.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c5b29c20e56eefd8736e7cc0909e835dc60e62c7dd74ffe3e3288c1cf9b6d2a
|
| 3 |
+
size 26925632
|
data/irexp_non_commercial.jsonl.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec5876b93811ac262f5102375b927ee82305a94b10ffea171fb80c9eefb4f2f1
|
| 3 |
+
size 5495688
|
data/irexp_other.jsonl.gz
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:52e4a0a6ba1ba7136896df0015812973bffdf4b90c855af98a642b767cebcf25
|
| 3 |
-
size 823
|
|
|
|
|
|
|
|
|
|
|
|
data/irexp_release_build_stats.json
DELETED
|
@@ -1,198 +0,0 @@
|
|
| 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
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d5e262118772306509b230fc8a5920d02bb5d8355b7ab6ed7af6f458708f457
|
| 3 |
+
size 267068
|
data/structure_quarantine.jsonl.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b160398c4f1c320c56a8cfa9eae3c2c83ca23d05b1146fd9c41c706bdc479d4e
|
| 3 |
+
size 137454
|
data/train_no_bench_commercial.jsonl.gz
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:00069af9bb4b3e5f5615d3db605d72bb6b837e78127deb6aed643d9cfc80e52d
|
| 3 |
-
size 11613493
|
|
|
|
|
|
|
|
|
|
|
|
scripts/build_release.py
DELETED
|
@@ -1,159 +0,0 @@
|
|
| 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))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/release_check.py
CHANGED
|
@@ -1,410 +1,131 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
IRexp release_check.py — DoR integrity asserts for Sci Data Hub patch.
|
| 4 |
-
|
| 5 |
-
Skeleton + runnable checks against local jsonl.gz mirrors.
|
| 6 |
-
Default root: /workspace/irexp-opus4/data (Hub rev used for inventory).
|
| 7 |
-
After a patch build, point --data-dir at the patched out/ directory.
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
python3 release_check.py --expect-commercial-n 88519 # post-lt3 drop, pre-ND
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
from __future__ import annotations
|
| 16 |
-
|
| 17 |
-
import argparse
|
| 18 |
-
import gzip
|
| 19 |
-
import json
|
| 20 |
-
import sys
|
| 21 |
from collections import Counter
|
| 22 |
from pathlib import Path
|
| 23 |
-
from typing import Any, Iterable
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
"id",
|
| 32 |
-
BAND_KEY,
|
| 33 |
-
"ir_source",
|
| 34 |
-
"h_nmr",
|
| 35 |
-
"c_nmr",
|
| 36 |
-
"smiles",
|
| 37 |
-
"selfies",
|
| 38 |
-
"inchikey",
|
| 39 |
-
"has_structure",
|
| 40 |
-
"source_doi",
|
| 41 |
-
"license",
|
| 42 |
-
"license_raw",
|
| 43 |
-
"license_pool",
|
| 44 |
-
"license_source",
|
| 45 |
}
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
COMMERCIAL_DOC_FIELDS = {
|
| 51 |
-
OLD_KEY,
|
| 52 |
-
"ir_shared_in_paper",
|
| 53 |
-
"ir_table_flatten_suspect",
|
| 54 |
-
"ir_refetch_confirmed",
|
| 55 |
-
"ir_refetch_merged",
|
| 56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
# Hypervalent I–O exception ids observed on rev 50d6155 (has_structure=False ∧ smiles).
|
| 59 |
-
# Recompute / refresh if the set changes; empty set means enforce strict equivalence.
|
| 60 |
-
KNOWN_HS_FALSE_WITH_SMILES: set[str] = set() # cleared after has_structure flip (presubmit)
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
def load_jsonl_gz(path: Path) -> list[dict[str, Any]]:
|
| 64 |
-
rows: list[dict[str, Any]] = []
|
| 65 |
-
with gzip.open(path, "rt", encoding="utf-8") as f:
|
| 66 |
-
for line in f:
|
| 67 |
-
line = line.strip()
|
| 68 |
-
if line:
|
| 69 |
-
rows.append(json.loads(line))
|
| 70 |
-
return rows
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
def bands(row: dict[str, Any]) -> list[float]:
|
| 74 |
-
b = row.get(BAND_KEY)
|
| 75 |
-
if not b:
|
| 76 |
-
return []
|
| 77 |
-
return [float(x) for x in b]
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
def nonempty_smiles(row: dict[str, Any]) -> bool:
|
| 81 |
-
s = row.get("smiles")
|
| 82 |
-
return s is not None and str(s).strip() != ""
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
def int_bands(vals: Iterable[float]) -> list[int]:
|
| 86 |
-
return [int(round(float(x))) for x in vals]
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
def order_unique_ints(vals: Iterable[float]) -> list[int]:
|
| 90 |
-
out: list[int] = []
|
| 91 |
-
seen: set[int] = set()
|
| 92 |
-
for v in int_bands(vals):
|
| 93 |
-
if v not in seen:
|
| 94 |
-
seen.add(v)
|
| 95 |
-
out.append(v)
|
| 96 |
-
return out
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
class Checker:
|
| 100 |
-
def __init__(self) -> None:
|
| 101 |
-
self.failures: list[str] = []
|
| 102 |
-
self.warnings: list[str] = []
|
| 103 |
-
|
| 104 |
-
def check(self, cond: bool, msg: str) -> None:
|
| 105 |
-
if not cond:
|
| 106 |
-
self.failures.append(msg)
|
| 107 |
-
|
| 108 |
-
def warn(self, cond: bool, msg: str) -> None:
|
| 109 |
-
if not cond:
|
| 110 |
-
self.warnings.append(msg)
|
| 111 |
-
|
| 112 |
-
def section(self, title: str) -> None:
|
| 113 |
-
print(f"\n== {title} ==")
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
def assert_ge3_bands(ck: Checker, name: str, rows: list[dict]) -> None:
|
| 117 |
-
bad = [r["id"] for r in rows if len(bands(r)) < MIN_BANDS]
|
| 118 |
-
ck.check(len(bad) == 0, f"{name}: {len(bad)} rows with len(bands)<{MIN_BANDS} e.g. {bad[:5]}")
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
def assert_band_range(ck: Checker, name: str, rows: list[dict]) -> None:
|
| 122 |
-
bad = []
|
| 123 |
-
for r in rows:
|
| 124 |
-
for v in bands(r):
|
| 125 |
-
if v < BAND_LO or v > BAND_HI:
|
| 126 |
-
bad.append((r["id"], v))
|
| 127 |
-
break
|
| 128 |
-
ck.check(len(bad) == 0, f"{name}: {len(bad)} rows with bands outside [{BAND_LO},{BAND_HI}] e.g. {bad[:5]}")
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
def assert_no_dup_int_bands(ck: Checker, name: str, rows: list[dict]) -> None:
|
| 132 |
-
bad = []
|
| 133 |
-
for r in rows:
|
| 134 |
-
ib = int_bands(bands(r))
|
| 135 |
-
if len(ib) != len(set(ib)):
|
| 136 |
-
bad.append(r["id"])
|
| 137 |
-
ck.check(len(bad) == 0, f"{name}: {len(bad)} rows with duplicate integer bands e.g. {bad[:5]}")
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
) -> None:
|
| 146 |
-
"""has_structure ⇔ nonempty smiles, with optional documented exceptions."""
|
| 147 |
-
allow = allow_exceptions or set()
|
| 148 |
-
true_no_smiles = []
|
| 149 |
-
false_with_smiles = []
|
| 150 |
-
for r in rows:
|
| 151 |
-
hs = r.get("has_structure")
|
| 152 |
-
sm = nonempty_smiles(r)
|
| 153 |
-
rid = r.get("id")
|
| 154 |
-
if hs is True and not sm:
|
| 155 |
-
true_no_smiles.append(rid)
|
| 156 |
-
if hs is False and sm and rid not in allow:
|
| 157 |
-
false_with_smiles.append(rid)
|
| 158 |
-
if hs is False and sm and rid in allow:
|
| 159 |
-
pass # documented exception
|
| 160 |
-
if hs not in (True, False):
|
| 161 |
-
ck.check(False, f"{name}: non-bool has_structure on {rid}: {hs!r}")
|
| 162 |
-
ck.check(
|
| 163 |
-
len(true_no_smiles) == 0,
|
| 164 |
-
f"{name}: {len(true_no_smiles)} has_structure=True without smiles e.g. {true_no_smiles[:5]}",
|
| 165 |
-
)
|
| 166 |
-
ck.check(
|
| 167 |
-
len(false_with_smiles) == 0,
|
| 168 |
-
f"{name}: {len(false_with_smiles)} has_structure=False with smiles "
|
| 169 |
-
f"(not in exception set) e.g. {false_with_smiles[:5]}",
|
| 170 |
-
)
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
def assert_unique_ids(ck: Checker, name: str, rows: list[dict]) -> None:
|
| 174 |
-
ids = [r["id"] for r in rows]
|
| 175 |
-
ck.check(len(ids) == len(set(ids)), f"{name}: duplicate ids within file ({len(ids)-len(set(ids))})")
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
def assert_core_schema(ck: Checker, name: str, rows: list[dict]) -> None:
|
| 179 |
-
if not rows:
|
| 180 |
-
ck.check(False, f"{name}: empty file")
|
| 181 |
-
return
|
| 182 |
-
# Every row must have core keys (presence; nulls allowed where meaningful)
|
| 183 |
-
missing_counts = Counter()
|
| 184 |
-
for r in rows:
|
| 185 |
-
for k in CORE_KEYS:
|
| 186 |
-
if k not in r:
|
| 187 |
-
missing_counts[k] += 1
|
| 188 |
-
ck.check(
|
| 189 |
-
len(missing_counts) == 0,
|
| 190 |
-
f"{name}: core keys missing on some rows: {dict(missing_counts)}",
|
| 191 |
-
)
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
def assert_commercial_doc_fields(ck: Checker, rows: list[dict], require_dense_refetch: bool) -> None:
|
| 195 |
-
"""Documented fields: old bands always present; refetch preferably dense bools."""
|
| 196 |
-
missing_old = sum(1 for r in rows if OLD_KEY not in r)
|
| 197 |
-
ck.check(missing_old == 0, f"commercial: {missing_old} rows missing {OLD_KEY}")
|
| 198 |
-
if require_dense_refetch:
|
| 199 |
-
for field in ("ir_refetch_confirmed", "ir_refetch_merged"):
|
| 200 |
-
missing = sum(1 for r in rows if field not in r)
|
| 201 |
-
ck.check(
|
| 202 |
-
missing == 0,
|
| 203 |
-
f"commercial: {missing} rows missing dense {field} "
|
| 204 |
-
f"(normalize absent→False before Hub patch)",
|
| 205 |
-
)
|
| 206 |
-
else:
|
| 207 |
-
# Soft note for live Hub (sparse refetch)
|
| 208 |
-
sparse_c = sum(1 for r in rows if "ir_refetch_confirmed" not in r)
|
| 209 |
-
sparse_m = sum(1 for r in rows if "ir_refetch_merged" not in r)
|
| 210 |
-
if sparse_c or sparse_m:
|
| 211 |
-
ck.warn(
|
| 212 |
-
False,
|
| 213 |
-
f"commercial: refetch fields sparse "
|
| 214 |
-
f"(confirmed missing={sparse_c}, merged missing={sparse_m}); "
|
| 215 |
-
f"densify on next Hub patch",
|
| 216 |
-
)
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
def assert_subset(ck: Checker, child: str, parent: str, child_ids: set[str], parent_ids: set[str]) -> None:
|
| 220 |
-
extra = child_ids - parent_ids
|
| 221 |
-
ck.check(len(extra) == 0, f"{child} ⊈ {parent}: {len(extra)} ids e.g. {list(extra)[:5]}")
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
def assert_disjoint(ck: Checker, a: str, b: str, a_ids: set[str], b_ids: set[str]) -> None:
|
| 225 |
-
inter = a_ids & b_ids
|
| 226 |
-
ck.check(len(inter) == 0, f"{a} ∩ {b} nonempty: {len(inter)} e.g. {list(inter)[:5]}")
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
def assert_resolved_equals_smiles(
|
| 230 |
-
ck: Checker,
|
| 231 |
-
commercial: list[dict],
|
| 232 |
-
resolved_ids: set[str],
|
| 233 |
-
) -> None:
|
| 234 |
-
"""After rebuild: resolved ids == commercial ids with nonempty smiles."""
|
| 235 |
-
expected = {r["id"] for r in commercial if nonempty_smiles(r)}
|
| 236 |
-
only_exp = expected - resolved_ids
|
| 237 |
-
only_res = resolved_ids - expected
|
| 238 |
-
ck.check(
|
| 239 |
-
len(only_exp) == 0 and len(only_res) == 0,
|
| 240 |
-
f"resolved ≠ commercial∩smiles: missing_from_resolved={len(only_exp)} "
|
| 241 |
-
f"extra_in_resolved={len(only_res)} (sample miss {list(only_exp)[:3]})",
|
| 242 |
-
)
|
| 243 |
|
| 244 |
|
| 245 |
def main() -> int:
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
)
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
type=int,
|
| 256 |
-
default=None,
|
| 257 |
-
help="If set, assert commercial row count equals this (e.g. 88519 after lt3 drop)",
|
| 258 |
-
)
|
| 259 |
-
ap.add_argument(
|
| 260 |
-
"--strict-resolved-smiles",
|
| 261 |
-
action="store_true",
|
| 262 |
-
help="Assert resolved == commercial∩smiles (enable after rebuild)",
|
| 263 |
-
)
|
| 264 |
-
ap.add_argument(
|
| 265 |
-
"--require-dense-refetch",
|
| 266 |
-
action="store_true",
|
| 267 |
-
help="Assert ir_refetch_* present on every commercial row",
|
| 268 |
-
)
|
| 269 |
-
ap.add_argument(
|
| 270 |
-
"--allow-live-defects",
|
| 271 |
-
action="store_true",
|
| 272 |
-
help="Warn instead of fail on known live Hub defects (lt3, dups, resolved sync)",
|
| 273 |
-
)
|
| 274 |
-
args = ap.parse_args()
|
| 275 |
-
d = args.data_dir
|
| 276 |
-
ck = Checker()
|
| 277 |
-
|
| 278 |
-
files = {
|
| 279 |
-
"commercial": d / "irexp_commercial.jsonl.gz",
|
| 280 |
-
"non_commercial": d / "irexp_non_commercial.jsonl.gz",
|
| 281 |
-
"sharealike": d / "irexp_sharealike.jsonl.gz",
|
| 282 |
-
"resolved_commercial": d / "irexp_resolved_commercial.jsonl.gz",
|
| 283 |
-
"train_no_bench_commercial": d / "train_no_bench_commercial.jsonl.gz",
|
| 284 |
-
}
|
| 285 |
-
for name, path in files.items():
|
| 286 |
-
ck.check(path.is_file(), f"missing file: {path}")
|
| 287 |
-
if ck.failures:
|
| 288 |
-
for f in ck.failures:
|
| 289 |
-
print("FAIL:", f)
|
| 290 |
-
return 1
|
| 291 |
-
|
| 292 |
-
data = {name: load_jsonl_gz(path) for name, path in files.items()}
|
| 293 |
-
ids = {name: {r["id"] for r in rows} for name, rows in data.items()}
|
| 294 |
-
|
| 295 |
-
print(f"data-dir: {d}")
|
| 296 |
-
for name, rows in data.items():
|
| 297 |
-
print(f" {name}: n={len(rows)}")
|
| 298 |
-
|
| 299 |
-
# --- counts ---
|
| 300 |
-
ck.section("counts")
|
| 301 |
-
if args.expect_commercial_n is not None:
|
| 302 |
-
ck.check(
|
| 303 |
-
len(data["commercial"]) == args.expect_commercial_n,
|
| 304 |
-
f"commercial n={len(data['commercial'])} != expect {args.expect_commercial_n}",
|
| 305 |
-
)
|
| 306 |
-
|
| 307 |
-
# --- per-file quality ---
|
| 308 |
-
for name, rows in data.items():
|
| 309 |
-
ck.section(f"quality:{name}")
|
| 310 |
-
assert_unique_ids(ck, name, rows)
|
| 311 |
-
assert_core_schema(ck, name, rows)
|
| 312 |
-
if name in PMC_POOLS_REQUIRE_PMCID:
|
| 313 |
-
missing_pmcid = sum(1 for r in rows if "pmcid" not in r)
|
| 314 |
-
ck.check(missing_pmcid == 0, f"{name}: {missing_pmcid} rows missing pmcid")
|
| 315 |
-
if name == "sharealike":
|
| 316 |
-
# Chemotion rows: source present, pmcid often absent; PMC SA: pmcid present
|
| 317 |
-
no_prov = [
|
| 318 |
-
r["id"] for r in rows
|
| 319 |
-
if not r.get("pmcid") and not r.get("source")
|
| 320 |
-
]
|
| 321 |
-
ck.check(len(no_prov) == 0, f"sharealike: {len(no_prov)} rows lack both pmcid and source")
|
| 322 |
-
|
| 323 |
-
if args.allow_live_defects and name in {
|
| 324 |
-
"commercial",
|
| 325 |
-
"resolved_commercial",
|
| 326 |
-
"train_no_bench_commercial",
|
| 327 |
-
"non_commercial",
|
| 328 |
-
}:
|
| 329 |
-
# Report live defects as warnings
|
| 330 |
-
n_lt3 = sum(1 for r in rows if len(bands(r)) < MIN_BANDS)
|
| 331 |
-
n_dup = sum(1 for r in rows if len(int_bands(bands(r))) != len(set(int_bands(bands(r)))))
|
| 332 |
-
if n_lt3:
|
| 333 |
-
ck.warn(False, f"{name}: LIVE defect len<3: {n_lt3}")
|
| 334 |
-
if n_dup:
|
| 335 |
-
ck.warn(False, f"{name}: LIVE defect dup-int bands: {n_dup}")
|
| 336 |
-
assert_band_range(ck, name, rows)
|
| 337 |
-
else:
|
| 338 |
-
assert_ge3_bands(ck, name, rows)
|
| 339 |
-
assert_band_range(ck, name, rows)
|
| 340 |
-
assert_no_dup_int_bands(ck, name, rows)
|
| 341 |
-
|
| 342 |
-
allow = KNOWN_HS_FALSE_WITH_SMILES if name.startswith(
|
| 343 |
-
("commercial", "resolved", "train_no_bench")
|
| 344 |
-
) or name in {"commercial", "resolved_commercial", "train_no_bench_commercial"} else set()
|
| 345 |
-
# Apply exceptions only to commercial family
|
| 346 |
-
if name in {"commercial", "resolved_commercial", "train_no_bench_commercial"}:
|
| 347 |
-
assert_has_structure_smiles(ck, name, rows, allow_exceptions=KNOWN_HS_FALSE_WITH_SMILES)
|
| 348 |
-
else:
|
| 349 |
-
assert_has_structure_smiles(ck, name, rows, allow_exceptions=set())
|
| 350 |
-
|
| 351 |
-
# --- commercial documentation fields ---
|
| 352 |
-
ck.section("commercial documented fields")
|
| 353 |
-
assert_commercial_doc_fields(
|
| 354 |
-
ck, data["commercial"], require_dense_refetch=args.require_dense_refetch
|
| 355 |
-
)
|
| 356 |
-
# Schema notes (non-fatal): companions lack audit columns
|
| 357 |
-
for name in ("non_commercial", "sharealike"):
|
| 358 |
-
for field in ("ir_bands_old_cm-1", "ir_shared_in_paper", "ir_table_flatten_suspect"):
|
| 359 |
-
if any(field in r for r in data[name]):
|
| 360 |
continue
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
# --- cross-file relations ---
|
| 364 |
-
ck.section("subset / disjoint")
|
| 365 |
-
assert_disjoint(ck, "commercial", "non_commercial", ids["commercial"], ids["non_commercial"])
|
| 366 |
-
assert_disjoint(ck, "commercial", "sharealike", ids["commercial"], ids["sharealike"])
|
| 367 |
-
assert_disjoint(ck, "non_commercial", "sharealike", ids["non_commercial"], ids["sharealike"])
|
| 368 |
-
assert_subset(
|
| 369 |
-
ck, "resolved_commercial", "commercial", ids["resolved_commercial"], ids["commercial"]
|
| 370 |
-
)
|
| 371 |
-
assert_subset(
|
| 372 |
-
ck,
|
| 373 |
-
"train_no_bench_commercial",
|
| 374 |
-
"resolved_commercial",
|
| 375 |
-
ids["train_no_bench_commercial"],
|
| 376 |
-
ids["resolved_commercial"],
|
| 377 |
-
)
|
| 378 |
-
|
| 379 |
-
if args.strict_resolved_smiles:
|
| 380 |
-
assert_resolved_equals_smiles(ck, data["commercial"], ids["resolved_commercial"])
|
| 381 |
else:
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
return 1
|
| 405 |
-
print(
|
| 406 |
return 0
|
| 407 |
|
| 408 |
|
| 409 |
if __name__ == "__main__":
|
| 410 |
-
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
+
"""Verify an IRexp deposit directory (data/*.jsonl.gz + SHA256SUMS.txt).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
Checks file checksums, record counts, the nd_source_licence flag, the
|
| 5 |
+
absence of unknown-licence rows, and the absence of InChIKey-shaped
|
| 6 |
+
tier-X identifiers. Exit 0 only if every check passes.
|
|
|
|
| 7 |
"""
|
|
|
|
| 8 |
from __future__ import annotations
|
| 9 |
+
import gzip, hashlib, json, re, sys
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
from collections import Counter
|
| 11 |
from pathlib import Path
|
|
|
|
| 12 |
|
| 13 |
+
EXPECTED_SHA256 = {
|
| 14 |
+
"irexp_commercial.jsonl.gz": "3c5b29c20e56eefd8736e7cc0909e835dc60e62c7dd74ffe3e3288c1cf9b6d2a",
|
| 15 |
+
"irexp_non_commercial.jsonl.gz": "ec5876b93811ac262f5102375b927ee82305a94b10ffea171fb80c9eefb4f2f1",
|
| 16 |
+
"irexp_sharealike.jsonl.gz": "2d5e262118772306509b230fc8a5920d02bb5d8355b7ab6ed7af6f458708f457",
|
| 17 |
+
"structure_quarantine.jsonl.gz": "b160398c4f1c320c56a8cfa9eae3c2c83ca23d05b1146fd9c41c706bdc479d4e",
|
| 18 |
+
"seen_papers.txt.gz": "ad0c91414f8a85463ae847a688ece35f5b5b4c87cb47e5896027114fd6587282",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
+
EXPECTED_COUNTS = {
|
| 21 |
+
"irexp_commercial.jsonl.gz": 190049,
|
| 22 |
+
"irexp_non_commercial.jsonl.gz": 39000,
|
| 23 |
+
"irexp_sharealike.jsonl.gz": 1897,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
+
EXPECTED_TOTAL = 230946
|
| 26 |
+
EXPECTED_ND = 26033
|
| 27 |
+
EXPECTED_QUARANTINE = 8457
|
| 28 |
+
IK_SHAPED = re.compile(r"^[A-Za-z0-9]{14}-[A-Za-z0-9]{10}-[A-Za-z0-9]$")
|
| 29 |
+
UNKNOWN = {None, "", "unknown", "empty", "n/a", "na", "none"}
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
def sha256(p: Path) -> str:
|
| 33 |
+
h = hashlib.sha256()
|
| 34 |
+
with p.open("rb") as f:
|
| 35 |
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
| 36 |
+
h.update(chunk)
|
| 37 |
+
return h.hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def main() -> int:
|
| 41 |
+
root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parents[1] / "data"
|
| 42 |
+
data = root if (root / "irexp_commercial.jsonl.gz").exists() else root / "data"
|
| 43 |
+
problems = []
|
| 44 |
+
|
| 45 |
+
sums_path = data / "SHA256SUMS.txt"
|
| 46 |
+
listed = {}
|
| 47 |
+
if sums_path.exists():
|
| 48 |
+
for line in sums_path.read_text().splitlines():
|
| 49 |
+
if not line.strip():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
continue
|
| 51 |
+
h, name = line.split()
|
| 52 |
+
listed[name] = h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
else:
|
| 54 |
+
problems.append("missing SHA256SUMS.txt")
|
| 55 |
+
|
| 56 |
+
print("== checksums ==")
|
| 57 |
+
for name, expect in EXPECTED_SHA256.items():
|
| 58 |
+
p = data / name
|
| 59 |
+
if not p.exists():
|
| 60 |
+
problems.append(f"missing {name}")
|
| 61 |
+
print("MISSING", name)
|
| 62 |
+
continue
|
| 63 |
+
got = sha256(p)
|
| 64 |
+
ok = got == expect
|
| 65 |
+
print(("OK" if ok else "FAIL"), name)
|
| 66 |
+
if not ok:
|
| 67 |
+
problems.append(f"sha mismatch {name}")
|
| 68 |
+
if listed and listed.get(name) not in (None, expect, got):
|
| 69 |
+
problems.append(f"SHA256SUMS.txt disagrees for {name}")
|
| 70 |
+
|
| 71 |
+
print("== records ==")
|
| 72 |
+
file_n = {}
|
| 73 |
+
nd_n = 0
|
| 74 |
+
unknown = 0
|
| 75 |
+
ik_x = 0
|
| 76 |
+
missing_flag = 0
|
| 77 |
+
for name in EXPECTED_COUNTS:
|
| 78 |
+
p = data / name
|
| 79 |
+
if not p.exists():
|
| 80 |
+
continue
|
| 81 |
+
n = 0
|
| 82 |
+
with gzip.open(p, "rt") as f:
|
| 83 |
+
for line in f:
|
| 84 |
+
rec = json.loads(line)
|
| 85 |
+
n += 1
|
| 86 |
+
lic = rec.get("license")
|
| 87 |
+
if lic is None or str(lic).strip().lower() in UNKNOWN:
|
| 88 |
+
unknown += 1
|
| 89 |
+
if "nd_source_licence" not in rec:
|
| 90 |
+
missing_flag += 1
|
| 91 |
+
if rec.get("nd_source_licence") is True:
|
| 92 |
+
nd_n += 1
|
| 93 |
+
if rec.get("structure_tier") == "X" and IK_SHAPED.match(str(rec.get("id") or "")):
|
| 94 |
+
ik_x += 1
|
| 95 |
+
file_n[name] = n
|
| 96 |
+
exp = EXPECTED_COUNTS[name]
|
| 97 |
+
print(("OK" if n == exp else "FAIL"), name, n)
|
| 98 |
+
if n != exp:
|
| 99 |
+
problems.append(f"count {name}: {n} != {exp}")
|
| 100 |
+
|
| 101 |
+
total = sum(file_n.values())
|
| 102 |
+
print("total", total)
|
| 103 |
+
if total != EXPECTED_TOTAL:
|
| 104 |
+
problems.append(f"total {total} != {EXPECTED_TOTAL}")
|
| 105 |
+
if nd_n != EXPECTED_ND:
|
| 106 |
+
problems.append(f"nd_source_licence true: {nd_n} != {EXPECTED_ND}")
|
| 107 |
+
if unknown:
|
| 108 |
+
problems.append(f"unknown-licence rows: {unknown}")
|
| 109 |
+
if missing_flag:
|
| 110 |
+
problems.append(f"rows missing nd_source_licence: {missing_flag}")
|
| 111 |
+
if ik_x:
|
| 112 |
+
problems.append(f"InChIKey-shaped tier-X ids: {ik_x}")
|
| 113 |
+
|
| 114 |
+
qpath = data / "structure_quarantine.jsonl.gz"
|
| 115 |
+
if qpath.exists():
|
| 116 |
+
qn = sum(1 for _ in gzip.open(qpath, "rt"))
|
| 117 |
+
print("quarantine", qn)
|
| 118 |
+
if qn != EXPECTED_QUARANTINE:
|
| 119 |
+
problems.append(f"quarantine {qn} != {EXPECTED_QUARANTINE}")
|
| 120 |
+
|
| 121 |
+
if problems:
|
| 122 |
+
print("FAIL")
|
| 123 |
+
for p in problems:
|
| 124 |
+
print(" ", p)
|
| 125 |
return 1
|
| 126 |
+
print("ALL CHECKS PASSED")
|
| 127 |
return 0
|
| 128 |
|
| 129 |
|
| 130 |
if __name__ == "__main__":
|
| 131 |
+
raise SystemExit(main())
|