Datasets:
Tasks:
Tabular Classification
Formats:
csv
Languages:
English
Size:
1K - 10K
Tags:
laboratory-medicine
pre-analytical
sample-stability
biobanking
dried-blood-spots
clinical-chemistry
License:
Mirror of sample-stability 1.0.0 (Zenodo doi:10.5281/zenodo.24543301, GitHub caraulani/sample-stability)
356ffbd verified Download scripts/search_europepmc.py from lifefrom/sample-stability: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/datasets/lifefrom/sample-stability/resolve/main/scripts/search_europepmc.py
- Command line
-
hf download hf://datasets/lifefrom/sample-stability/scripts/search_europepmc.py
-
curl -L -o search_europepmc.py https://huggingface.co/datasets/lifefrom/sample-stability/resolve/main/scripts/search_europepmc.py
1.12 kB
| """Search Europe PMC for open-access stability studies. Saves raw JSON to _raw/europepmc/search/.""" | |
| import json, sys, hashlib, urllib.parse, urllib.request, pathlib | |
| RAW = pathlib.Path(__file__).resolve().parents[2] / "_raw" / "europepmc" / "search" | |
| RAW.mkdir(parents=True, exist_ok=True) | |
| BASE = "https://www.ebi.ac.uk/europepmc/webservices/rest/search" | |
| def search(q, size=100): | |
| url = BASE + "?" + urllib.parse.urlencode({"query": q, "format": "json", "pageSize": size, "resultType": "core"}) | |
| fn = RAW / (hashlib.sha1(q.encode()).hexdigest()[:12] + ".json") | |
| if not fn.exists(): | |
| with urllib.request.urlopen(url, timeout=60) as r: | |
| fn.write_bytes(r.read()) | |
| return json.loads(fn.read_text()) | |
| if __name__ == "__main__": | |
| for q in sys.argv[1:]: | |
| d = search(q) | |
| print(f"## {q} hits={d.get('hitCount')}") | |
| for r in d.get("resultList", {}).get("result", []): | |
| print(f"{r.get('pmcid','-')}\t{r.get('pubYear')}\t{r.get('journalInfo',{}).get('journal',{}).get('medlineAbbreviation','')}\t{r.get('license','')}\t{r.get('doi','')}\t{r.get('title','')[:150]}") | |