Skip to main content

RO-Crate metadata generator/parser

Project description

Python package


Create/parse rocrate_ (Research Object Crate) metadata.

Note: Under development


Source code:

Feel free to raise a pull request at or an issue at

Submitted contributions are assumed to be covered by section 5 of the Apache License 2.0.


You will need Python 3.6 or later (Recommended: 3.7).

If you want to install manually from this code base, then try:

pip install .

..or if you use don't use pip:

python install

.. _rocrate: .. _pip:

General usage

The package contains a The standard use case is by instantiating ROCrate class. This can be a new one: crate = ROCrate() or an existing RO-crate package can be load from a directory or zip file:

crate = ROCrate('/path/to/crate/')
crate = ROCrate('/path/to/crate/')

In addition, there is a set of higher level functions in the form of an interface to help users create some predefined types of crates. As an example here is the code to create a workflow RO-Crate, containing a workflow template. This is a good starting point if you want to wrap up a workflow template to register at

from rocrate import rocrate_api

wf_path = "test/test-data/"
files_list = ["test/test-data/test_file_galaxy.txt"]

# Create base package
wf_crate = rocrate_api.make_workflow_rocrate(workflow_path=wf_path,wf_type="Galaxy",include_files=files_list)

# Write to zip file
out_path = "/home/test_user/wf_crate"

Independently of the initialization method, once an instance of ROCrate is created it can be manipulated to extend the content and metadata.

Data entities can be added with:

## adding a File entity:
sample_file = '/path/to/sample_file.txt'
file_entity = crate.add_file(sample_file)

# Adding a File entity with a reference to an external (absolute) URI
remote_file = crate.add_file('', fetch_remote = False)

# adding a Dataset
sample_dir = '/path/to/dir'
dataset_entity = crate.add_directory(sample_dir, 'relative/rocrate/path')

Contextual entities are used in a ro-crate to adequately describe a Data Entity. The following example shows how to add them to the RO-Crate root:

# Add authors info
joe_metadata = {'name': 'Joe Bloggs'}
crate.add_person('#joe', joe_metadata)

In order to write the crate object contents to a zip file package or a decompressed directory, there are 2 write methods that can be used:

# Write to zip file
out_path = "/home/test_user/crate"

# write crate to disk
out_path = "/home/test_user/crate_base"


  • © 2019-2020 The University of Manchester, UK
  • © 2020 Vlaams Instituut voor Biotechnologie (VIB), BE
  • © 2020 Barcelona Supercomputing Center (BSC), ES

Licensed under the Apache License, version 2.0, see the file LICENSE.txt for details.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rocrate, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size rocrate-0.1.0-py3-none-any.whl (169.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rocrate-0.1.0.tar.gz (154.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page