Created
April 28, 2026 19:39
-
-
Save nutjob4life/9c59218642e1731a6dc652dbd5fbc78c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Print publication PMID values grouped by RDF subject URI.""" | |
| try: | |
| from rdflib import Graph, URIRef | |
| except ImportError as exc: | |
| raise SystemExit("Missing dependency: install rdflib with `python3 -m pip install rdflib`.") from exc | |
| RDF_URL = "https://edrn.jpl.nasa.gov/cancerdataexpo/rdf-data/publications/@@rdf" | |
| PMID = URIRef("http://edrn.nci.nih.gov/rdf/schema.rdf#pmid") | |
| def main() -> None: | |
| graph = Graph() | |
| graph.parse(RDF_URL) | |
| for subject in sorted(set(graph.subjects(predicate=PMID)), key=str): | |
| pmids = sorted({str(pmid) for pmid in graph.objects(subject, PMID)}) | |
| for pmid in pmids: | |
| print(f"{subject}\t{pmid}") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment