Using nanopub, a high-level, user-friendly python interface to the nanopublication network

For example, if you want to e.g. search for all nanopublications containing the text Picoides*:

which returns two results both pointing to the example nanopublication we just discussed:

{‘np’: ‘http://purl.org/np/RAMzGwLotMRSQTHRCS15B6hvuYSyEupGnxZaFU3EmcItA’, ‘description’: ‘Inter-species interaction of Picoides villosus with Ips’, ‘date’: ‘2020-12-24T10:51:43.931Z’} {‘np’: ‘http://purl.org/np/RAMzGwLotMRSQTHRCS15B6hvuYSyEupGnxZaFU3EmcItA’, ‘description’: ‘Picoides villosus’, ‘date’: ‘2020-12-24T10:51:43.931Z’}You can then fetch a specific nanopublication directly using its URI:

This snippet will fetch the nanopublication we discussed earlier, about the interaction of the bird and the beetle, and print the contents of its assertion. Of course, you are not limited to simple text searches. The library has several search methods, including finding nanopubs with a given triple pattern — you can find detailed documentation here.

Hold on, I want to publish Nanopublications of my own!

To publish to the nanopub server you need to set up your profile. This allows the nanopub server to identify you. Run the following interactive command (on the command line):

setup_nanopub_profileIt will add and store RSA keys to sign your nanopublications, publish a nanopublication with your name and ORCID iD to declare that you are using using these RSA keys, and store your ORCID iD to automatically add as author to the provenance of any nanopublication you will publish using this library.

You can then publish a quick claim:

Published to http://purl.org/np/RA47eJP2UBJCWuJ324c6Qw0OwtCb8wCrprwSk39am7xckView the resulting nanopublication here. Note that the URI of your nanopublication is a signed hash of its contents, making its authorship verifiable and enforcing its immutability — known as a trusty URI.

Or, to leverage the true power of semantic technologies, you can build your own RDF graph of triples and publish that:

The above builds a graph containing a single triple that states (essentially) the concept pointed to by www.example.org/timbernersleeis of type Person. We use the rdflib library to build the graph, but this is already a dependency of nanopub. A Publication object is then created, using that graph as its assertion, and finally published using the NanopubClient as before. The code produces the following output:

Published to http://purl.org/np/RAfk_zBYDerxd6ipfv8fAcQHEzgZcVylMTEkiLlMzsgwQYou can view the resulting nanopublication here.

Outlook

nanopub makes interacting with nanopublications quite intuitive for those with sufficient RDF and python skills. For all others we foresee tools built around nanopub that make it intuitive for domain-experts (but not RDF-experts) to make use of the nanopublication network.

There are a couple of those already in the making:

  • nanotate: Create nanopublications from annotations in PDF-files made with hypothes.is
  • fairworkflows: Support the construction, manipulation and publishing of FAIR scientific workflows using semantic technologies. This is developed as part of the wider FAIR is as FAIR does project at the eScience Center.

Conclusion

The python nanopub library provides a high-level, user-friendly python interface for the nanopub server, making it easy to publish and search small scientific publications. We created this library to bring nanopublishing to python users and we’re keen to help people make use of it.

Consider how nanopublications might fit in with your field, and feel free to try the library out!

Acknowledgements

The quality of this text was greatly improved by the suggestions of Patrick Bos, Tobias Kuhn, Arnold Kuzniar, Lars Ridder, Pablo Rodríguez-Sánchez, and Stefan Verhoeven.