{"id":13318277,"url":"https://github.com/cthoyt/curies4j","last_synced_at":"2025-04-10T14:11:14.030Z","repository":{"id":163474682,"uuid":"637742954","full_name":"cthoyt/curies4j","owner":"cthoyt","description":"🐸 Idiomatic conversion between URIs and compact URIs (CURIEs) ","archived":false,"fork":false,"pushed_at":"2023-10-25T15:38:58.000Z","size":38,"stargazers_count":9,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T12:55:38.705Z","etag":null,"topics":["curies","java","obofoundry","semantic-web","uris"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cthoyt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-08T10:12:07.000Z","updated_at":"2023-11-27T00:31:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"ccfd2f45-1770-4b41-8847-8be7073ef4f8","html_url":"https://github.com/cthoyt/curies4j","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"2ed3fd3744d4657e38b05ccfe0108c4ca98d53e4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cthoyt%2Fcuries4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cthoyt%2Fcuries4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cthoyt%2Fcuries4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cthoyt%2Fcuries4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cthoyt","download_url":"https://codeload.github.com/cthoyt/curies4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248232418,"owners_count":21069487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curies","java","obofoundry","semantic-web","uris"],"created_at":"2024-07-29T18:29:52.037Z","updated_at":"2025-04-10T14:11:13.997Z","avatar_url":"https://github.com/cthoyt.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# curies4j\n\nA Java implementation of the [`curies`](https://github.com/cthoyt/curies/) Python package,\nwhich enables idiomatic conversion between URIs and compact URIs (CURIEs).\n\nNote that this package returns `null` when it gets content it can't handle instead of\nthrowing errors.\n\n```java\nimport org.biopragmatics.curies.Converter;\nimport org.biopragmatics.curies.Reference;\n\nclass CuriesDemo1 {\n    public static void main(String[] args) {\n        Converter converter = Converter.getExampleConverter();\n\n        String curie = \"CHEBI:1234\";\n        String uri = \"http://purl.obolibrary.org/obo/CHEBI_1234\";\n\n        String reference = new Reference(\"CHEBI\", \"1234\");\n        String prefix = reference.getPrefix();  // \"CHEBI\"\n        String identifier = reference.getIdentfier();  // \"1234\"\n\n        // 2 ways to expand a CURIE into a URI\n        String uri1 = converter.expand(\"CHEBI:1234\");\n        String uri2 = converter.expand(\"CHEBI\", \"1234\");\n        // \"http://purl.obolibrary.org/obo/CHEBI_1234\"\n\n        // Expand a reference into a URI\n        String uri3 = converter.expand(reference);\n        // \"http://purl.obolibrary.org/obo/CHEBI_1234\"\n\n        // Compress a URI to a CURIE string\n        String curie1 = converter.compress(uri);\n        // CHEBI:1234\n\n        // Parse a URI into a reference\n        Reference reference1 = converter.parseURI(uri);\n        // new Reference(\"CHEBI\", \"1234\")\n\n        // Parse a CURIE into a reference\n        Reference reference2 = converter.parseCURIE(curie);\n        // new Reference(\"CHEBI\", \"1234\")\n    }\n}\n```\n\n## Loading a Prefix Map\n\n```java\nimport java.util.HashMap;\nimport java.util.Map;\nimport org.biopragmatics.curies.Converter;\nimport org.biopragmatics.curies.Loader;\n\nclass AdHocResourceDemo {\n    public static void main(String[] args) {\n        Map\u003cString, String\u003e prefixMap = new HashMap\u003c\u003e();\n        prefixMap.put(\"OMIM\", \"https://omim.org/entry/\");\n        prefixMap.put(\"OMIMPS\", \"https://omim.org/phenotypicSeries/PS\");\n        prefixMap.put(\"Orphanet\", \"http://www.orpha.net/ORDO/Orphanet_\");\n\n        Converter converter = new Converter(prefixMap);\n        converter.compress(\"http://www.orpha.net/ORDO/Orphanet_85163\");\n        // Orphabet:85163\n    }\n}\n```\n\n## Loading an Extended Prefix Map\n\nIf you have the URL for an extended prefix map, you can do the following:\n\n```java\nimport org.biopragmatics.curies.Converter;\nimport org.biopragmatics.curies.Loader;\n\nclass RemoteResourceDemo {\n    public static void main(String[] args) {\n        String url = \"https://raw.githubusercontent.com/biopragmatics/bioregistry/main/exports/contexts/bioregistry.epm.json\";\n        Converter converter = new Converter(Loader.getRecords(url));\n        converter.compress(\"https://www.ebi.ac.uk/ols/ontologies/doid/terms?obo_id=DOID:1234\");\n        // doid:1234\n    }\n}\n```\n\nSimilarly, if you have a file object, you can do:\n\n```java\nimport java.io.*;\nimport org.biopragmatics.curies.Converter;\nimport org.biopragmatics.curies.Loader;\n\nclass LocalResourceDemo {\n    public static void main(String[] args) {\n        File file = new File(\"/Users/cthoyt/dev/bioregistry/exporst/contexts/bioregistry.epm.json\")\n        Converter converter = new Converter(Loader.getRecords(file));\n        converter.compress(\"https://www.ebi.ac.uk/ols/ontologies/doid/terms?obo_id=DOID:1234\");\n        // doid:1234\n    }\n}\n```\n\n## Bioregistry Integration\n\nThe Bioregistry can be loaded over the web.\n\n```java\nimport org.biopragmatics.curies.Converter;\n\nclass CuriesDemo2 {\n    public static void main(String[] args) {\n        Converter converter = Converter.loadBioregistry();\n        converter.compress(\"https://www.ebi.ac.uk/ols/ontologies/doid/terms?obo_id=DOID:1234\");\n        // doid:1234\n    }\n}\n```\n\n## Installation\n\nSee https://central.sonatype.com/artifact/org.biopragmatics.curies/curies\n\n## Acknowledgements\n\nSpecial thanks to [Jonas Schaub](https://github.com/JonasSchaub) for helping with packaging and deployment to Maven Central.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcthoyt%2Fcuries4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcthoyt%2Fcuries4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcthoyt%2Fcuries4j/lists"}