Skip to content

🐸 Idiomatic conversion between URIs and compact URIs (CURIEs)

License

Notifications You must be signed in to change notification settings

cthoyt/curies4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

curies4j

A Java implementation of the curies Python package, which enables idiomatic conversion between URIs and compact URIs (CURIEs).

import org.biopragmatics.curies.Converter;
import org.biopragmatics.curies.Reference;

class CuriesDemo1 {
    public static void main(String[] args) {
        Converter converter = Converter.getExampleConverter();

        String curie = "CHEBI:1234";
        String uri = "https://purl.obolibrary.org/obo/CHEBI_1234";

        String reference = new Reference("CHEBI", "1234");
        String prefix = reference.getPrefix();  // "CHEBI"
        String identifier = reference.getIdentfier();  // "1234"

        // 2 ways to expand a CURIE into a URI
        String uri1 = converter.expand("CHEBI:1234");
        String uri2 = converter.expand("CHEBI", "1234");
        // "https://purl.obolibrary.org/obo/CHEBI_1234"

        // Expand a reference into a URI
        String uri3 = converter.expand(reference);
        // "https://purl.obolibrary.org/obo/CHEBI_1234"

        // Compress a URI to a CURIE string
        String curie1 = converter.compress(uri);
        // CHEBI:1234

        // Parse a URI into a reference
        Reference reference1 = converter.parseURI(uri);
        // new Reference("CHEBI", "1234")

        // Parse a CURIE into a reference
        Reference reference2 = converter.parseCURIE(curie);
        // new Reference("CHEBI", "1234")
    }
}

Bioregistry Integration

The Bioregistry can be loaded over the web.

import org.biopragmatics.curies.Converter;

class CuriesDemo2 {
    public static void main(String[] args) {
        Converter converter = Converter.loadBioregistry();
        converter.compress("https://www.ebi.ac.uk/ols/ontologies/doid/terms?obo_id=DOID:1234");
        // doid:1234
    }
}

About

🐸 Idiomatic conversion between URIs and compact URIs (CURIEs)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages