nanopub-py
Python client for searching, publishing and modifying nanopublications.
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Keywords
Repository
Python client for searching, publishing and modifying nanopublications.
Basic Info
- Host: GitHub
- Owner: Nanopublication
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: https://nanopublication.github.io/nanopub-py
- Size: 17 MB
Statistics
- Stars: 31
- Watchers: 15
- Forks: 12
- Open Issues: 15
- Releases: 28
Topics
Metadata Files
README.md
nanopub-py
The nanopub-py library provides a high-level, user-friendly Python interface for searching, publishing and retracting nanopublications.
Nanopublications are a formalized and machine-readable way of communicating the smallest possible units of publishable information. See the documentation for more information.
Documentation
Checkout the user documentation 📖
Setup
Install using pip:
pip install nanopub
To publish to the nanopublication network you need to setup your profile. This allows the nanopublication services to identify you. Run the following command in the terminal:
np setup
This will ask you a few questions, then it will use that information to add and store RSA keys to sign your nanopublications with, (optionally) publish a nanopublication with your name and ORCID iD to declare that you are 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.
Quick Start
Publishing nanopublications
```python from rdflib import Graph from nanopub import Nanopub, NanopubConf, load_profile
1. Create the config
npconf = NanopubConf(
usetestserver=True,
profile=loadprofile(), # Loads the user profile that was created with np setup
addprovgeneratedtime=True,
attributepublicationtoprofile=True,
)
2. Construct a desired assertion (a graph of RDF triples) using rdflib
myassertion = Graph() myassertion.add(( rdflib.URIRef('www.example.org/timbernerslee'), rdflib.RDF.type, rdflib.FOAF.Person ))
2. Make a Nanopub object with this assertion
np = Nanopub( conf=npconf, assertion=myassertion )
3. Publish the Nanopub object
np.publish() print(np) ```
Searching for nanopublications
```python from nanopub import NanopubClient
Search for all nanopublications containing the text 'fair'
client = NanopubClient() results = client.findnanopubswith_text('fair') print(results) ```
Fetching nanopublications and inspecting them
```python
Fetch the nanopublication at the specified URI
publication = client.fetch('http://purl.org/np/RApJG4fwj0szOMBMiYGmYvd5MCtRle6VbwkMJUb1SxxDM')
Print the RDF contents of the nanopublication
print(publication)
Iterate through all triples in the assertion graph
for s, p, o in publication.assertion: print(s, p, o)
```
Development
See the development page on the documentation website.
Tests
To run tests:
Install dependencies (if not already installed):
pip install pytest
Run tests:
pytest
Test coverage
To generate a test coverage report for this library:
Install dependencies (if not already installed):
pip install coverage pytest
Run the tests with coverage tracking:
coverage run -m pytest
View a terminal summary:
coverage report
Or generate a detailed HTML report
coverage html
License
nanopub-py is free software under the Apache License. See LICENSE.
Copyright
- Copyright (C) 2020 Robin Richardson, Sven van der Burg
- Copyright (C) 2020-2025 the nanopub-py contributors (https://github.com/Nanopublication/nanopub-py/graphs/contributors)
- Copyright (C) 2025 Knowledge Pixels
- Copyright (C) 2025 Acatech
Owner
- Name: Nanopublication
- Login: Nanopublication
- Kind: organization
- Website: nanopub.net
- Repositories: 17
- Profile: https://github.com/Nanopublication
Citation (CITATION.cff)
# YAML 1.2
---
abstract: "The nanopub python library provides a client for searching, publishing and modifying nanopublications."
authors:
-
affiliation: "Netherlands eScience Center"
family-names: Burg
given-names: Sven
name-particle: "van der"
-
affiliation: "Netherlands eScience Center"
family-names: Richardson
given-names: Robin
orcid: "https://orcid.org/0000-0002-9984-2720"
-
affiliation: "Netherlands eScience Center"
family-names: Smits
given-names: Djura
-
affiliation: "Maastricht University"
family-names: Emonet
given-names: Vincent
orcid: "https://orcid.org/0000-0002-1501-1082"
cff-version: "1.0.3"
keywords:
- "semantic"
- "RDF"
- "FAIR"
- "nanopublications"
license: "Apache-2.0"
message: "If you use this software, please cite it using these metadata."
title: "nanopub: A python library for searching, publishing and modifying nanopublications"
version: "2.0.0"
date-released: "2022-12-15"
GitHub Events
Total
- Create event: 20
- Issues event: 7
- Watch event: 3
- Delete event: 7
- Member event: 1
- Issue comment event: 5
- Push event: 67
- Pull request review comment event: 5
- Pull request review event: 12
- Pull request event: 47
- Fork event: 1
Last Year
- Create event: 20
- Issues event: 7
- Watch event: 3
- Delete event: 7
- Member event: 1
- Issue comment event: 5
- Push event: 67
- Pull request review comment event: 5
- Pull request review event: 12
- Pull request event: 47
- Fork event: 1
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Sven van der Burg | s****g@e****l | 317 |
| Vincent Emonet | v****t@g****m | 130 |
| Robin Richardson | r****n@g****m | 121 |
| Virginia Balseiro | i****o@v****m | 45 |
| Djura Smits | d****s@g****m | 26 |
| Tobias Kuhn | k****s@g****m | 12 |
| Lourens Veen | l****n@e****l | 9 |
| Shashank Chakravarthy | s****y@g****m | 1 |
| Ruud Steltenpool | g****m@s****m | 1 |
| Piotr Sowiński | o****k@g****m | 1 |
| Faruk D | 1****n | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 4
- Total pull requests: 30
- Average time to close issues: about 22 hours
- Average time to close pull requests: about 14 hours
- Total issue authors: 3
- Total pull request authors: 4
- Average comments per issue: 0.0
- Average comments per pull request: 0.07
- Merged pull requests: 21
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 30
- Average time to close issues: about 22 hours
- Average time to close pull requests: about 14 hours
- Issue authors: 3
- Pull request authors: 4
- Average comments per issue: 0.0
- Average comments per pull request: 0.07
- Merged pull requests: 21
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- cmeesters (2)
- anatoly-scherbakov (1)
- tkuhn (1)
Pull Request Authors
- VirginiaBalseiro (24)
- cmeesters (3)
- anatoly-scherbakov (2)
- ashleycaselli (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- citation-file-format/cffconvert-github-action 2.0.0 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- pycryptodome >=3.15.0
- rdflib >=6.0.2
- requests *
- typer *
- yatiml *