Skip to content
Snippets Groups Projects
README.md 4.85 KiB
Newer Older
Swen Vermeul's avatar
Swen Vermeul committed
# Welcome to pyBIS!
Swen Vermeul's avatar
Swen Vermeul committed
pyBIS is a Python module for interacting with openBIS, designed to be used in Jupyter. It offers a sort of IDE for openBIS, supporting TAB completition and input checks, making the life of a researcher hopefully easier.
Swen Vermeul's avatar
Swen Vermeul committed


Swen Vermeul's avatar
Swen Vermeul committed
# SYNOPSIS

```
from pybis import Openbis
o = Openbis('https://example.com:8443', verify_certificates=False)
o.login('username', 'password', save_token=True)   # saves the session token in ~/.pybis/example.com.token
Swen Vermeul's avatar
Swen Vermeul committed
o.token
Swen Vermeul's avatar
Swen Vermeul committed
o.is_session_active()
Swen Vermeul's avatar
Swen Vermeul committed
o.get_datastores()
Swen Vermeul's avatar
Swen Vermeul committed
o.logout()

Swen Vermeul's avatar
Swen Vermeul committed

Swen Vermeul's avatar
Swen Vermeul committed
# Masterdata
o.get_experiment_types()
o.get_sample_types()
o.get_sample_type('YEAST')
o.get_material_types()
o.get_dataset_types()
o.get_dataset_types()[0]
o.get_dataset_type('RAW_DATA')
o.get_terms()
o.get_terms('MATING_TYPE')
o.get_tags()

Swen Vermeul's avatar
Swen Vermeul committed

Swen Vermeul's avatar
Swen Vermeul committed
# Spaces and Projects
Swen Vermeul's avatar
Swen Vermeul committed
o.get_spaces()
o.get_space('MY_SPACE')
o.get_projects(space='MY_SPACE')
space.get_projects()
project.get_experiments()
project.get_attachments()
project.download_attachments()
p.add_attachment(fileName='testfile', description= 'another file', title= 'one more attachment')
p.save()

Swen Vermeul's avatar
Swen Vermeul committed

# Samples
sample = o.new_sample(
    type='YEAST', 
    space='MY_SPACE', 
    parents=[parent_sample, '/MY_SPACE/YEA66'], 
    children=[child_sample]
)
sample.space
sample.code
sample.permId
sample.identifier
sample.type  # once the sample type is defined, you cannot modify it
sample.space
sample.space = 'MY_OTHER_SPACE'
sample.experiment    # a sample can belong to one experiment only
sample.experiment = 'MY_SPACE/MY_PROJECT/MY_EXPERIMENT'
sample.tags
sample.tags = ['guten_tag', 'zahl_tag' ]
sample.get_parents()
sample.get_childeren()
sample.props, sample.p
sample.get_attachments()
sample.download_attachments()
sample.add_attachment('testfile.xls')
samples = o.get_samples(
    space='MY_SPACE',
    type='YEAST'
    tags=['*']  # tags must be present
    NAME = 'some name'   # properties are all uppercase
    props=['name', 'mating_type','show_in_project_overview']    # properties to be displayed in the dataFrame
)
samples.df  # returns a pandas dataframe object
samples.get_datasets(type='ANALYZED_DATA')  # for all found samples get all datasets
# Note: Project samples are not implemented yet.


Swen Vermeul's avatar
Swen Vermeul committed
# Experiments
Swen Vermeul's avatar
Swen Vermeul committed
o.new_experiment
    type='DEFAULT_EXPERIMENT',
    space='MY_SPACE',
    project='YEASTS'
)
Swen Vermeul's avatar
Swen Vermeul committed
o.get_experiments(
Swen Vermeul's avatar
Swen Vermeul committed
    project='YEASTS',
    space='MY_SPACE', 
    type='DEFAULT_EXPERIMENT',
    tags='*', 
    finished_flag=False,
    props=['name', 'finished_flag']
)
Swen Vermeul's avatar
Swen Vermeul committed
exp = o.get_experiment('/MY_SPACE/MY_PROJECT/MY_EXPERIMENT')
Swen Vermeul's avatar
Swen Vermeul committed
exp.props
exp.p     # same as exp.props
exp.p.finished_flag=True
exp.attrs
exp.a     # same as exp.attrs
exp.attrs.tags = ['some', 'extra', 'tags']
exp.tags = ['some', 'extra', 'tags']          # same thing
exp.save()

Swen Vermeul's avatar
Swen Vermeul committed

Swen Vermeul's avatar
Swen Vermeul committed
# Datasets
sample.get_datasets()
ds = o.get_dataset('20160719143426517-259')
ds.get_parents()
ds.get_children()
sample = ds.sample
experiment = ds.experiment
ds.physicalData
ds.status        # AVAILABLE LOCKED ARCHIVED UNARCHIVE_PENDING ARCHIVE_PENDING BACKUP_PENDING
ds.archive()
ds.unarchive()
ds.get_files(start_folder="/")
ds.file_list
ds.add_attachment()
ds.get_attachments()
ds.download_attachments()
ds.download(destination='/tmp', wait_until_finished=False)
Swen Vermeul's avatar
Swen Vermeul committed

Swen Vermeul's avatar
Swen Vermeul committed
ds_new = o.new_dataset(
    type='ANALYZED_DATA', 
    experiment=exp, 
    sample= samp,
    files = ['my_analyzed_data.dat'], 
    props={'name': 'we give this dataset a name', 'notes': 'and we might need some notes, too'})
)
ds_new.save()

Swen Vermeul's avatar
Swen Vermeul committed
```

Swen Vermeul's avatar
Swen Vermeul committed
# Requirements and organization
Swen Vermeul's avatar
Swen Vermeul committed
### Dependencies and Requirements
- pyBIS relies the openBIS API v3; openBIS version 16.05.2 or newer 
- pyBIS uses Python 3.3 and pandas
Swen Vermeul's avatar
Swen Vermeul committed
- pyBIS needs the jupyter-api to be installed, in order to register new datasets
Swen Vermeul's avatar
Swen Vermeul committed

### Installation

- locate the `jupyter-api` folder found in `pybis/src/coreplugins`
- copy this folder to `openbis/servers/core-plugins` in your openBIS installation
Swen Vermeul's avatar
Swen Vermeul committed
- register the plugin by editing `openbis/servers/core-plugins/core-plugins.properties` :
- `enabled-modules = jupyter-api` (separate multiple plugins with comma)
- restart your DSS to activate the plugin
Swen Vermeul's avatar
Swen Vermeul committed

Swen Vermeul's avatar
Swen Vermeul committed
### Project Organization
This project is devided in several parts:
Swen Vermeul's avatar
Swen Vermeul committed
- src/python/**PyBis** Python module which holds all the method to interact with OpenBIS
- src/python/**OBis** a command-line tool to register large datasets in OpenBIS without actually copying the data. Uses git annex for version control and OpenBIS linkedDataSet objects to register the metadata.
Swen Vermeul's avatar
Swen Vermeul committed
- src/python/**JupyterBis** a JupyterHub authenticator module which uses pyBIS for authenticating against openBIS, validating and storing the session token
- src/core-plugins/**jupyter-api**, an ingestion plug-in for openBIS, allowing people to upload new datasets
- src/vagrant/**jupyter-bis/Vagrantfile** to set up JupyterHub on a virtual machine (CentOS 7), which uses the JupyterBis authenticator module
- src/vagrant/**obis/Vagrantfile** to set up a complete OpenBIS instance on a virtual machine (CentOS 7)