Skip to content
Snippets Groups Projects
Commit ed6b642a authored by Henry Luetcke's avatar Henry Luetcke Committed by Adam Laskowski
Browse files

manage spaces

parent ddb4e7b6
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
function delete_space(code, reason)
% DELETE_SPACE
% Delete space in the openBIS instance. A reason has to be specified.
global obi
% test connection
test_connection(obi)
space = obi.get_space(code);
space.delete(reason);
end
\ No newline at end of file
function spaces = get_spaces
% GET_SPACES
% Get a list of all available spaces (DataFrame object). To create a sample or a
% dataset, you need to specify in which space it should live.
global obi
% test connection
test_connection(obi)
spaces = obi.get_spaces();
spaces = df_to_table(spaces.df);
end
function new_space(code, description)
% NEW_SPACE
% Creates a new space in the openBIS instance.
global obi
% test connection
test_connection(obi)
space = obi.new_space(pyargs('code', code, 'description', description));
space.save;
end
\ No newline at end of file
%% Cell type:code id: tags:
``` python
from pybis import Openbis
import getpass
import matplotlib.pyplot as plt
%matplotlib inline
```
%% Cell type:markdown id: tags:
### Connecting to openBIS
%% Cell type:code id: tags:
``` python
o = Openbis('https://limb.ethz.ch/openbis:8443', verify_certificates=False)
```
%% Cell type:code id: tags:
``` python
username = 'hluetcke'
pw = getpass.getpass()
```
%% Output
·····················
%% Cell type:code id: tags:
``` python
o.login(username, pw, save_token=True) # saves the session token in ~/.pybis/example.com.token
del pw
```
%% Cell type:code id: tags:
``` python
o.token
```
%% Output
'hluetcke-181024154540290xCA25DBE8ED8C9FB138503F6C3F0C8D69'
%% Cell type:code id: tags:
``` python
o.is_session_active()
```
%% Output
True
%% Cell type:code id: tags:
``` python
o.get_datastores()
```
%% Output
code downloadUrl hostUrl
0 DSS1 https://limb.ethz.ch:443/datastore_server https://limb.ethz.ch:443
%% Cell type:markdown id: tags:
### Masterdata
%% Cell type:code id: tags:
``` python
o.get_experiment_types()
```
%% Output
code description modificationDate
-- ---------- ----------------------------------------------- -------------------
0 IHC Immunohistochemistry 2010-10-01 15:27:15
1 LACZ Experiments with lacZ staining. 2010-10-06 16:24:22
2 CULTURE Culture 2010-08-19 08:49:11
3 ISH in situ hybridization 2010-08-19 08:49:25
4 SKELETAL Skeletal 2010-08-19 08:49:34
5 METHODS Folder to store protocols 2016-05-24 16:36:12
6 PAPER Experiments from a paper. 2010-11-12 12:08:37
7 LIGHTSHEET Lightsheet imaging 2018-05-31 13:29:04
8 SAMPLE For Sample registration. 2010-11-22 10:28:53
9 MATERIALS Folder to store biological and chemical samples 2016-05-24 16:35:51
%% Cell type:code id: tags:
``` python
o.get_sample_types()
```
%% Cell type:code id: tags:
``` python
o.get_sample_type('PLATE')
```
%% Cell type:code id: tags:
``` python
o.get_material_types()
```
%% Cell type:code id: tags:
``` python
o.get_dataset_types()
```
%% Cell type:code id: tags:
``` python
o.get_terms()
```
%% Cell type:markdown id: tags:
### List and get datasets
%% Cell type:code id: tags:
``` python
datasets = o.get_datasets(type='HISTOLOGY')
```
%% Cell type:code id: tags:
``` python
counter = 0
for ds in datasets:
print(ds)
counter += 1
if counter > 10:
break
```
%% Cell type:code id: tags:
``` python
ds = o.get_dataset('20101105142920015-6525')
```
%% Cell type:code id: tags:
``` python
ds.get_files(start_folder='original')
```
%% Cell type:code id: tags:
``` python
space = o.get_space('MATLAB_TEST')
```
%% Cell type:code id: tags:
``` python
space.delete
```
%% Output
attribute value
---------------- ---------------------------------------
code MATLAB_TEST
permId MATLAB_TEST
description test space for Matlab access to openBIS
registrator hluetcke
registrationDate 2018-08-17 10:39:05
modificationDate 2018-08-17 10:39:05
%% Cell type:markdown id: tags:
### Download and import files
%% Cell type:code id: tags:
``` python
ds.download(files='original/441_x40001.tif', destination='data', wait_until_finished=True)
```
%% Cell type:code id: tags:
``` python
plt.imshow(plt.imread('data/20101105142920015-6525/original/441_x40001.tif'))
```
%% Cell type:code id: tags:
``` python
o.logout()
```
%% Cell type:code id: tags:
``` python
o.get_experiment_types()
```
%% Cell type:code id: tags:
``` python
o.get_dataset_types()
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment