nanopub-java: A Java Library for Nanopublications

19
nanopub-java: A Java Library for Nanopublications Tobias Kuhn http://www.tkuhn.org @txkuhn VU University Amsterdam 5th Workshop on Linked Science (LISC) 2015 at ISWC 2015, Bethlehem, Pennsylvania, USA 12 October 2015

Transcript of nanopub-java: A Java Library for Nanopublications

Page 1: nanopub-java: A Java Library for Nanopublications

nanopub-java:A Java Library for Nanopublications

Tobias Kuhn

http://www.tkuhn.org

@txkuhn

VU University Amsterdam

5th Workshop on Linked Science (LISC) 2015at ISWC 2015, Bethlehem, Pennsylvania, USA

12 October 2015

Page 2: nanopub-java: A Java Library for Nanopublications

The nanopub-java Library

https://github.com/Nanopublication/nanopub-java

This library can be useful in a number of scenarios:

• To represent and share chunks of data in RDF in aprovenance-aware manner (as nanopublications)

• To make RDF content verifiable and immutable (with trustyURIs)

• To define large or small datasets of RDF content where thedata entries can be individually addressed and recombined innew datasets (with nanopublication indexes)

• To quickly publish RDF snippets in a verifiable and permanentmanner (relying on an existing server network)

• To retrieve existing nanopublications from the network(5 millions and counting)

• To digitally sign RDF snippets (experimental)

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 2 / 19

Page 3: nanopub-java: A Java Library for Nanopublications

Nanopublications: Linked Data Containers forProvenance-Aware Semantic Publishing

assertion

provenance

publication info

nanopublication

http://nanopub.org / @nanopub org

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 3 / 19

Page 4: nanopub-java: A Java Library for Nanopublications

Nanopublication Example

sub:assertion {

sub:_3 a rdf:Statement ; rdf:subject schem:Adenosine%20triphosphate ;

rdf:predicate belv:decreases ; rdf:object sub:_1 ;

occursIn: obo:UBERON_0001134 , species:9606 .

sub:_1 a go:0003824 ; hasAgent: sub:_2 .

sub:_2 a Protein: ; geneProductOf: hgnc:12517 .

}

sub:provenance {

sub:assertion prov:hadPrimarySource pubmed:9703368 ;

prov:wasDerivedFrom beldoc: , sub:_4 .

beldoc: dce:description "Approximately 61,000 statements." ;

dce:rights "Copyright (c) 2011-2012, Selventa. All rights reserved." ;

dce:title "BEL Framework Large Corpus Document" ;

pav:authoredBy sub:_5 ; pav:version "20131211" .

sub:_4 prov:value "UCP1 contains six potential transmembrane a-helices (72) and acts under the form of a homodimer (73). Its uncoupling activity is increased by FFA (7477) and by long chain fatty acyl CoA esters (78, 79), and decreased by purine nucleotide di- or tri-phosphates (12, 74)." ;

prov:wasQuotedFrom pubmed:9703368 .

sub:_5 rdfs:label "Selventa" .

}

sub:pubinfo {

this: dct:created "2014-07-03T14:34:13.226+02:00"^^xsd:dateTime ;

pav:createdBy orcid:0000-0001-6818-334X , orcid:0000-0002-1267-0234 .

}

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 4 / 19

Page 5: nanopub-java: A Java Library for Nanopublications

Nanopublication Schema

np:Nanopublication rdf:type owl:Class.

np:Assertion rdfs:subClassOf rdfg:Graph.

np:Provenance rdfs:subClassOf rdfg:Graph.

np:PublicationInfo rdfs:subClassOf rdfg:Graph.

np:hasAssertion a owl:FunctionalProperty.

np:hasAssertion rdfs:domain np:Nanopublication.

np:hasAssertion rdfs:range np:Assertion.

np:hasProvenance a owl:FunctionalProperty.

np:hasProvenance rdfs:domain np:Nanopublication.

np:hasProvenance rdfs:range np:Provenance.

np:hasPublicationInfo a owl:FunctionalProperty.

np:hasPublicationInfo rdfs:domain np:Nanopublication.

np:hasPublicationInfo rdfs:range np:PublicationInfo.

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 5 / 19

Page 6: nanopub-java: A Java Library for Nanopublications

Nanopublication Guidelines

We need libraries to enforce and check this!

http://nanopub.org/guidelines/working_draft/

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 6 / 19

Page 7: nanopub-java: A Java Library for Nanopublications

check / CheckNanopub

Reads a nanopublication or several of them and checks whether anyof the well-formedness criteria are violated:

$ np check nanopubfile.trig

Summary: 3 valid (not trusty);

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 7 / 19

Page 8: nanopub-java: A Java Library for Nanopublications

Trusty URIs: Cryptographic Hash Values forNanopublication Identifiers

Nanopublications with Trusty URIs are ...

XVerifiable

+

Immutable

+ �Permanent

.trighttp://example.org/r1. RA 5AbXdpz5DcaYXCh9l3eI9ruBosiL5XDU3rxBbBaUO70

http://trustyuri.net/

Kuhn, Dumontier. Trusty URIs: Verifiable, Immutable, and Permanent Digital Artifacts for Linked Data. ESWC 2014.

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 8 / 19

Page 9: nanopub-java: A Java Library for Nanopublications

mktrusty / MakeTrustyNanopub

Takes a non-trusty nanopublication and transforms it into one witha newly created trusty URI:

$ np mktrusty nanopubfile.trig

or:

$ np mktrusty -v nanopubfile.trig

Nanopub URI: http://example.org/np1#RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7M91ouhojsQ

Nanopub URI: http://example.org/np2#RA4xTdhe2gPctqvAwdgTU4eRiR1aTQlTYJcF3Sohe5Cusv

Nanopub URI: http://example.org/np3#RAEjvXP0xTkeIa2mKmYT66i PAJ-u-k0uRBd6 sMe9qG0

This generates a file trusty.nanopubfile.trig:

$ np check trusty.nanopubfile.trig

Summary: 3 trusty (unsigned);

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 9 / 19

Page 10: nanopub-java: A Java Library for Nanopublications

Decentralized and Reliable Publishing with aNanopublication Server Network

Nanopublicationswith Trusty URIs

Publication

Retrieval

Propagation / Archiving

http://npmonitor.inn.ac

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 10 / 19

Page 11: nanopub-java: A Java Library for Nanopublications

publish / PublishNanopub

Uploads trusty nanopublications to the server network, and theyare then distributed among the servers of the network:

$ np publish trusty.nanopubfile.trig

3 nanopubs published at http://np.inn.ac/

In this way, a nanopublication is made permanent and its publicationcannot be undone.

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 11 / 19

Page 12: nanopub-java: A Java Library for Nanopublications

status / NanopubStatus

Checks whether and how often a given nanopublication (identified byits trusty URI) is found on the server network:

$ np status -a http://example.org/np1#RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7M91ouhojsQ

URL: http://np.inn.ac/RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7M91ouhojsQ

URL: http://ristretto.med.yale.edu:8080/nanopub-server/RAHGB0WzgQijR88g rIwtPCmzYgyO...

URL: http://nanopub-server.ops.labs.vu.nl/RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7M91ouhojsQ

URL: http://nanopubs.stanford.edu/nanopub-server/RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7...

URL: http://nanopubs.semanticscience.org/RAHGB0WzgQijR88g rIwtPCmzYgyO4wRMT7M91ouhojsQ

Found on 5 nanopub servers.

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 12 / 19

Page 13: nanopub-java: A Java Library for Nanopublications

get / GetNanopub

Retrieves given nanopublications from the server network, andverifies them according to their trusty URIs (only verifiednanopublications are returned):

$ np get http://www.tkuhn.ch/bel2nanopub/RAhV9IpiUEjbentzGivp1Lbx0BVegp5sgE3BwS0S2RAYM

or:

$ np get RAhV9IpiUEjbentzGivp1Lbx0BVegp5sgE3BwS0S2RAYM

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 13 / 19

Page 14: nanopub-java: A Java Library for Nanopublications

Defining Datasets with Nanopublication Indexes(which are themselves Nanopublications)

appends

has sub-index

has element

(a) (b)

(c) (f)

(d) (e)

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 14 / 19

Page 15: nanopub-java: A Java Library for Nanopublications

mkindex / MakeIndex

Takes a list of nanopublications and creates an index that refers tothem (which itself consists of one or more nanopublications):

$ np mkindex trusty.nanopubfile.trig

Index URI: http://np.inn.ac/RAFa x4h0ng NXtof35Ie9pQVsAY69Ab3ZQMir2NP8vGc

This creates a new file index.nanopubfile.trig containing theindex nanopublication(s).

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 15 / 19

Page 16: nanopub-java: A Java Library for Nanopublications

Publishing / Retrieving Indexes

As indexes are also nanopublications, we can publish them in thesame way:

$ np publish index.nanopubfile.trig

1 nanopub published at http://np.inn.ac/

Retrieving the content of a nanopublication index (and not just thetop-most index nanopublication) with argument -c:

$ np get -c http://np.inn.ac/RAFa x4h0ng NXtof35Ie9pQVsAY69Ab3ZQMir2NP8vGc

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 16 / 19

Page 17: nanopub-java: A Java Library for Nanopublications

Web Interface: http://nanopub.inn.ac

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 17 / 19

Page 18: nanopub-java: A Java Library for Nanopublications

sign / SignNanopub (experimental)

Takes a nanopublication and digitally signs it with a given privatekey.

Create a key pair:

$ np mkkeys

Digitally sign nanopublications (and make them trusty):

$ np sign nanopubfile.trig

This creates a file signed.nanopubfile.trig, which we can nowcheck:

$ np check signed.nanopubfile.trig

Summary: 3 signed and trusty;

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 18 / 19

Page 19: nanopub-java: A Java Library for Nanopublications

Thank you for your attention!

Questions?

Further information:

• Paper for this talk: http://arxiv.org/abs/1508.04977

• Nanopublications: http://nanopub.org

• Trusty URIs: http://trustyuri.net

Come to my presentation at the main conference: Thursday, 15October, 11:00 in the Scientific Data track: Publishing withoutPublishers: a Decentralized Approach to Dissemination, Retrieval,and Archiving of Data

Tobias Kuhn, VU University Amsterdam nanopub-java: A Java Library for Nanopublications 19 / 19