Alexander Wirth commited on
Commit
a8ca78f
·
1 Parent(s): 98cc88c

chore: Update documentation for v2.2 release (42.4% SMILES coverage, 76907 records)

Browse files
Files changed (2) hide show
  1. METHODOLOGY.md +35 -15
  2. README.md +11 -10
METHODOLOGY.md CHANGED
@@ -1,6 +1,6 @@
1
- # Methodology — Ethno-API Phytochemical Dataset v2.1
2
 
3
- > **Schema v2.1 · 76,907 records · 24,746 compounds · 2,313 species · 10 fields**
4
 
5
  ---
6
 
@@ -17,7 +17,7 @@
17
 
18
  ---
19
 
20
- ## Schema v2.1
21
 
22
  | Field | Type | Null Count | Description |
23
  |---|---|---|---|
@@ -29,8 +29,8 @@
29
  | `clinical_trials_count_2026` | Int64 | 0 | ClinicalTrials.gov study count mentioning compound |
30
  | `chembl_bioactivity_count` | Int64 | 0 | ChEMBL bioactivity assay count |
31
  | `patent_count_since_2020` | Int64 | 0 | US patent count (USPTO PatentsView, since 2020-01-01) |
32
- | `pubchem_cid` | Int64 | 21,690 | PubChem Compound ID (CID) |
33
- | `canonical_smiles` | string | 21,690 | Canonical SMILES string (PubChem) |
34
 
35
  **Enrichment coverage:**
36
 
@@ -54,13 +54,17 @@
54
  - **Rate limiting:** 3 requests/second (NCBI default without API key)
55
  - **Output:** Integer count of matching PubMed articles
56
 
57
- ### 2. ClinicalTrials.gov (API v2)
58
 
59
- - **Endpoint:** `https://clinicaltrials.gov/api/v2/studies`
60
- - **Query logic:** Free-text search for compound name across study titles and interventions
61
- - **Rate limiting:** 5 requests/second, checkpoint every 100 compounds
62
- - **Runtime:** ~2-3 hours for 24,746 unique compounds
63
- - **Checkpoint:** `ct_checkpoint.json` enables resume after interruption
 
 
 
 
64
 
65
  ### 3. ChEMBL (REST API v35)
66
 
@@ -83,10 +87,23 @@
83
 
84
  ### 5. Merge & Export (`master_export_v2.py`)
85
 
86
- - Merges all 4 enrichment outputs into unified dataset
87
- - Exports: JSON (compact), Parquet (Snappy compressed), MANIFEST (SHA-256 checksums + statistics)
88
  - 3-pass verification: record count, schema validation, checksum match
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ---
91
 
92
  ## Known Limitations
@@ -152,7 +169,8 @@ All enrichment scripts are available in the repository:
152
  |---|---|---|---|---|
153
  | v1.0 | 2026-01 | 5 (chemical, plant_species, application, dosage, pubmed_mentions_2026) | 104,388 | Initial release with PubMed enrichment |
154
  | v2.0 | 2026-03 | 8 (+clinical_trials_count_2026, chembl_bioactivity_count, patent_count_since_2020) | 76,907 | 4-source enrichment, DQA audit (noise compounds + duplicates removed: 104,388 → 76,907), checkpoint system |
155
- | v2.1 | 2026-03 | 10 (+pubchem_cid, canonical_smiles) | 76,907 | PubChem CID + SMILES enrichment (10,484 chemicals resolved, 71.8% record coverage) |
 
156
 
157
  ---
158
 
@@ -163,5 +181,7 @@ All enrichment scripts are available in the repository:
163
  | `ethno_dataset_2026_v2.json` | 16.3 MB | `cf517675c263eefb96c18a74a0238d0e142067eda2175259fde10db66a081bc3` |
164
  | `ethno_dataset_2026_v2.parquet` | 800 KB | `cd152dd830f769a8e86c2661f0650f20bd936452835d6ee4cad60549068c7b40` |
165
  | `ethno_dataset_2026_v2.1_FINAL.json` | 24.5 MB | `ae86ba33d76273dc52330ca5d75234d93f8a6d3a8db106186d39470a3c1a0db0` |
 
 
166
 
167
- Export timestamp: `2026-03-16T21:10:00+00:00` (post-DQA)
 
1
+ # Methodology — Ethno-API Phytochemical Dataset v2.2
2
 
3
+ > **Schema v2.2 · 76,907 records · 24,746 compounds · 2,313 species · 10 fields**
4
 
5
  ---
6
 
 
17
 
18
  ---
19
 
20
+ ## Schema v2.2
21
 
22
  | Field | Type | Null Count | Description |
23
  |---|---|---|---|
 
29
  | `clinical_trials_count_2026` | Int64 | 0 | ClinicalTrials.gov study count mentioning compound |
30
  | `chembl_bioactivity_count` | Int64 | 0 | ChEMBL bioactivity assay count |
31
  | `patent_count_since_2020` | Int64 | 0 | US patent count (USPTO PatentsView, since 2020-01-01) |
32
+ | `pubchem_cid` | Int64 | 44,329 | PubChem Compound ID (CID) — 42.4% of unique compounds resolved |
33
+ | `canonical_smiles` | string | 44,329 | Canonical SMILES string (PubChem) — 42.4% of unique compounds resolved |
34
 
35
  **Enrichment coverage:**
36
 
 
54
  - **Rate limiting:** 3 requests/second (NCBI default without API key)
55
  - **Output:** Integer count of matching PubMed articles
56
 
57
+ ### 2. ClinicalTrials.gov (Local XML Snapshot + Aho-Corasick)
58
 
59
+ - **Source:** AllPublicXML archive, 575,349 studies (March 2026 snapshot)
60
+ - **Indexed studies:** 517,205 studies with non-empty `intervention_name` fields (cached in `ct_intervention_index.json`)
61
+ - **Algorithm:** Aho-Corasick multi-pattern string matching with word-boundary enforcement
62
+ - **Stereo-prefix normalization (v2.2):** Compounds like `(+)-CATECHIN` are indexed as both `(+)-catechin` and `catechin`, covering 18 prefix types: `(+)-`, `(-)-`, `(±)-`, `DL-`, `rac-`, `R-`, `S-`, `RS-`, `cis-`, `trans-`, `alpha-`, `beta-`, `gamma-`, `delta-`, `E-`, `Z-`, `L-`, `D-`
63
+ - **Variants in automaton:** 25,705 (from 24,698 unique compounds after skip filter)
64
+ - **Runtime:** ~5 seconds (cached intervention index)
65
+ - **Output:** Integer count of matching studies per compound
66
+
67
+ > **Why local instead of API:** The ClinicalTrials.gov v2 API rejects IUPAC names containing brackets, arrows, and parentheses with HTTP 400 errors. The local XML approach eliminates rate limits, API failures, and network dependency entirely.
68
 
69
  ### 3. ChEMBL (REST API v35)
70
 
 
87
 
88
  ### 5. Merge & Export (`master_export_v2.py`)
89
 
90
+ - Merges all 4 enrichment outputs + PubChem SMILES/CID into unified dataset
91
+ - Exports: JSON (indent=2), Parquet (Snappy compressed), MANIFEST (SHA-256 checksums + statistics)
92
  - 3-pass verification: record count, schema validation, checksum match
93
 
94
+ ### 6. PubChem (PUG REST API)
95
+
96
+ - **Endpoint:** `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/{name}/JSON`
97
+ - **Query logic:** Name-to-CID resolution, returns `CID` + `CanonicalSMILES`
98
+ - **Queries:** 24,746 unique compound names
99
+ - **Resolved:** 10,484 compounds (42.4% of unique chemicals)
100
+ - **Unresolved:** 14,262 compounds (null in schema)
101
+ - **Rate limit:** 0.35s between requests, checkpoint-resumable
102
+ - **Runtime:** 3.2 hours (24,746 queries)
103
+ - **Output fields:** `canonical_smiles`, `pubchem_cid`
104
+
105
+ > **Why 57.6% are null:** Phytochemical trivial names (e.g. "TANNIN", "RESIN"), plant mixture descriptions (e.g. "ESSENTIAL OIL"), and non-specific ethnobotanical terms are not indexed in PubChem's compound database by name. These are inherent limitations of the source data, not pipeline failures.
106
+
107
  ---
108
 
109
  ## Known Limitations
 
169
  |---|---|---|---|---|
170
  | v1.0 | 2026-01 | 5 (chemical, plant_species, application, dosage, pubmed_mentions_2026) | 104,388 | Initial release with PubMed enrichment |
171
  | v2.0 | 2026-03 | 8 (+clinical_trials_count_2026, chembl_bioactivity_count, patent_count_since_2020) | 76,907 | 4-source enrichment, DQA audit (noise compounds + duplicates removed: 104,388 → 76,907), checkpoint system |
172
+ | v2.1 | 2026-03 | 10 (+pubchem_cid, canonical_smiles) | 76,907 | PubChem CID + SMILES enrichment (10,484 chemicals resolved, 71.8% record coverage — corrected to 42.4% in v2.2) |
173
+ | v2.2 | 2026-03 | 10 (same schema) | 76,907 | Stereo-prefix normalization for CT matching (+2 compounds), corrected SMILES coverage reporting (42.4% of unique chemicals), local CT XML matching replaces API |
174
 
175
  ---
176
 
 
181
  | `ethno_dataset_2026_v2.json` | 16.3 MB | `cf517675c263eefb96c18a74a0238d0e142067eda2175259fde10db66a081bc3` |
182
  | `ethno_dataset_2026_v2.parquet` | 800 KB | `cd152dd830f769a8e86c2661f0650f20bd936452835d6ee4cad60549068c7b40` |
183
  | `ethno_dataset_2026_v2.1_FINAL.json` | 24.5 MB | `ae86ba33d76273dc52330ca5d75234d93f8a6d3a8db106186d39470a3c1a0db0` |
184
+ | `ethno_dataset_2026_v2.2.json` | 25.4 MB | `7cb5719f9763f84f1cb8176b462d51fd9df5750e7cfa78e497263b7631ebba13` |
185
+ | `ethno_dataset_2026_v2.2.parquet` | 1.2 MB | `118d28bf08b784868b60fc1445a0fdd6817d5d8a492015c51d975cf8e8e5a132` |
186
 
187
+ Export timestamp: `2026-03-22T14:29:03Z` (v2.2 final)
README.md CHANGED
@@ -7,7 +7,7 @@ language:
7
  - en
8
  license: cc-by-4.0
9
  multilinguality: monolingual
10
- pretty_name: "USDA Phytochemical & Ethnobotanical Database — Enriched v2.1"
11
  size_categories:
12
  - 100K<n<1M
13
  source_datasets:
@@ -70,12 +70,12 @@ dataset_info:
70
  If you use this dataset in your research, please cite:
71
 
72
  ```
73
- Wirth, A. (2026). USDA Phytochemical Database — Enriched v2.1 (Sample). Zenodo. https://doi.org/10.5281/zenodo.19053087
74
  ```
75
 
76
  ---
77
 
78
- # USDA Phytochemical & Ethnobotanical Database — Enriched v2.1
79
 
80
  **The only phytochemical dataset combining USDA botanical records, PubMed citation counts, ClinicalTrials.gov study counts, ChEMBL bioactivity scores, USPTO patent density, and PubChem CID/SMILES — in production-ready JSON + Parquet.**
81
 
@@ -111,7 +111,7 @@ The full IP Discrepancy Report, including Freedom-to-Operate indicators and comp
111
 
112
  ---
113
 
114
- ## Schema (v2.1)
115
 
116
  | Column | Type | Nulls | Description |
117
  |--------|------|-------|-------------|
@@ -123,8 +123,8 @@ The full IP Discrepancy Report, including Freedom-to-Operate indicators and comp
123
  | `clinical_trials_count_2026` | `int32` | 0% | ClinicalTrials.gov study count per compound (March 2026) |
124
  | `chembl_bioactivity_count` | `int32` | 0% | ChEMBL documented bioactivity measurement count |
125
  | `patent_count_since_2020` | `int32` | 0% | US patents since 2020-01-01 mentioning compound (USPTO PatentsView) |
126
- | `pubchem_cid` | `int64` | ~28% | PubChem Compound ID (CID) — resolved via PubChem PUG REST (March 2026) |
127
- | `canonical_smiles` | `string` | ~28% | Canonical SMILES notation — molecular structure from PubChem |
128
 
129
  ---
130
 
@@ -240,7 +240,7 @@ Below is a real record from the dataset — QUERCETIN, one of the most-studied p
240
  }
241
  ```
242
 
243
- All 76,907 records contain all 10 schema fields. The 4 enrichment columns are always non-null; `pubchem_cid` and `canonical_smiles` are filled for 71.8% of records (10,484 unique chemicals resolved via PubChem); `application` (~50% null) and `dosage` (~87% null) reflect USDA source gaps.
244
  The free 400-row sample contains real, final enrichment values across all four layers.
245
 
246
  ## File Manifest
@@ -288,7 +288,8 @@ Enrichment methodology is documented in [`METHODOLOGY.md`](METHODOLOGY.md). Sour
288
  |---------|--------:|--------|--------|
289
  | v1.0 | 104,388 | 5 columns (USDA baseline) | Deprecated |
290
  | v2.0 | 76,907 | 8 columns (+ PubMed, ClinicalTrials, ChEMBL, Patents) | Superseded |
291
- | **v2.1** | **76,907** | **10 columns (+ PubChem CID, Canonical SMILES)** | **Current** |
 
292
 
293
  The free sample (`ethno_sample_400.json`) uses the v2.0 schema with final enrichment values across all four layers.
294
 
@@ -325,13 +326,13 @@ Ethno-API is the deterministic answer to these pipeline requirements.
325
 
326
  ```bibtex
327
  @misc{ethno_api_v2_2026,
328
- title = {USDA Phytochemical \& Ethnobotanical Database --- Enriched v2.1},
329
  author = {Wirth, Alexander},
330
  year = {2026},
331
  publisher = {Ethno-API},
332
  url = {https://ethno-api.com},
333
  doi = {10.5281/zenodo.19053087},
334
- note = {76,907 records, 24,746 unique chemicals, 2,313 plant species, 8-column schema with PubMed, ClinicalTrials, ChEMBL, and PatentsView enrichment}
335
  }
336
  ```
337
 
 
7
  - en
8
  license: cc-by-4.0
9
  multilinguality: monolingual
10
+ pretty_name: "USDA Phytochemical & Ethnobotanical Database — Enriched v2.2"
11
  size_categories:
12
  - 100K<n<1M
13
  source_datasets:
 
70
  If you use this dataset in your research, please cite:
71
 
72
  ```
73
+ Wirth, A. (2026). USDA Phytochemical Database — Enriched v2.2 (Sample). Zenodo. https://doi.org/10.5281/zenodo.19053087
74
  ```
75
 
76
  ---
77
 
78
+ # USDA Phytochemical & Ethnobotanical Database — Enriched v2.2
79
 
80
  **The only phytochemical dataset combining USDA botanical records, PubMed citation counts, ClinicalTrials.gov study counts, ChEMBL bioactivity scores, USPTO patent density, and PubChem CID/SMILES — in production-ready JSON + Parquet.**
81
 
 
111
 
112
  ---
113
 
114
+ ## Schema (v2.2)
115
 
116
  | Column | Type | Nulls | Description |
117
  |--------|------|-------|-------------|
 
123
  | `clinical_trials_count_2026` | `int32` | 0% | ClinicalTrials.gov study count per compound (March 2026) |
124
  | `chembl_bioactivity_count` | `int32` | 0% | ChEMBL documented bioactivity measurement count |
125
  | `patent_count_since_2020` | `int32` | 0% | US patents since 2020-01-01 mentioning compound (USPTO PatentsView) |
126
+ | `pubchem_cid` | `int64` | ~58% | PubChem Compound ID (CID) — resolved via PubChem PUG REST (March 2026) |
127
+ | `canonical_smiles` | `string` | ~58% | Canonical SMILES notation — molecular structure from PubChem (42.4% of unique compounds resolved) |
128
 
129
  ---
130
 
 
240
  }
241
  ```
242
 
243
+ All 76,907 records contain all 10 schema fields. The 4 enrichment columns are always non-null; `pubchem_cid` and `canonical_smiles` are filled for 42.4% of unique compounds (10,484 of 24,746 resolved via PubChem PUG REST); `application` (~50% null) and `dosage` (~87% null) reflect USDA source gaps. Unresolved compounds are phytochemical trivial names, mixture descriptions, or non-specific ethnobotanical terms not indexed in PubChem by name.
244
  The free 400-row sample contains real, final enrichment values across all four layers.
245
 
246
  ## File Manifest
 
288
  |---------|--------:|--------|--------|
289
  | v1.0 | 104,388 | 5 columns (USDA baseline) | Deprecated |
290
  | v2.0 | 76,907 | 8 columns (+ PubMed, ClinicalTrials, ChEMBL, Patents) | Superseded |
291
+ | v2.1 | 76,907 | 10 columns (+ PubChem CID, Canonical SMILES) | Superseded |
292
+ | **v2.2** | **76,907** | **10 columns (stereo-prefix CT normalization, corrected SMILES coverage)** | **Current** |
293
 
294
  The free sample (`ethno_sample_400.json`) uses the v2.0 schema with final enrichment values across all four layers.
295
 
 
326
 
327
  ```bibtex
328
  @misc{ethno_api_v2_2026,
329
+ title = {USDA Phytochemical \& Ethnobotanical Database --- Enriched v2.2},
330
  author = {Wirth, Alexander},
331
  year = {2026},
332
  publisher = {Ethno-API},
333
  url = {https://ethno-api.com},
334
  doi = {10.5281/zenodo.19053087},
335
+ note = {76,907 records, 24,746 unique chemicals, 2,313 plant species, 10-column schema with PubMed, ClinicalTrials, ChEMBL, PatentsView, PubChem CID/SMILES enrichment}
336
  }
337
  ```
338