Skip to content
Snippets Groups Projects
Commit 9d13669f authored by hluetcke's avatar hluetcke Committed by Adam Laskowski
Browse files

minor changes

parent b4c44e30
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
% demo script for accessing openBIS from Matlab using Pybis % demo script for accessing openBIS from Matlab using Pybis
% we use Matlab's capability to call Python libraries % we use Matlab's capability to call Python libraries
% Pybis documentation is available here: % Pybis documentation is available here:
% https://sissource.ethz.ch/sispub/pybis/blob/master/src/python/PyBis/README.md % https://sissource.ethz.ch/sispub/pybis/blob/master/src/python/PyBis/README.md
%% first check the Python version %% first check the Python version
pyversion pyversion
% a different Python version can be selected by specifying the Python % a different Python version can be selected by specifying the Python
% executable, e.g. pyversion /Users/Henry/miniconda3/bin/python % executable, e.g. pyversion /Users/Henry/miniconda3/bin/python
%% enter username and password for openBIS %% enter username and password for openBIS
username = 'hluetcke'; username = 'hluetcke';
pw = passwordEntryDialog('CheckPasswordLength',0); pw = passwordEntryDialog('CheckPasswordLength',0);
%% connect to openBIS %% connect to openBIS
obi = py.pybis.Openbis('https://limb.ethz.ch/openbis:8443', pyargs('verify_certificates', 0)); obi = py.pybis.Openbis('https://limb.ethz.ch/openbis:8443', pyargs('verify_certificates', 0));
obi.login(username, pw, pyargs('save_token', 1)); obi.login(username, pw, pyargs('save_token', 1));
clear pw clear pw
obi obi
%% select datasets %% select datasets
datasets = obi.get_datasets(pyargs('type','HISTOLOGY')); datasets = obi.get_datasets(pyargs('type','HISTOLOGY'));
datasets datasets
%% download dataset %% download dataset
% get specific dataset % get specific dataset
ds_id = '20101105142049776-6512'; ds_id = '20101105142049776-6512';
ds = obi.get_dataset(ds_id); ds = obi.get_dataset(ds_id);
% download % download
data_dir = '/Users/Henry/Data/Projects/MatlabOpenbis/data'; data_dir = '/Users/Henry/Data/Projects/MatlabOpenbis/data';
ds.download(pyargs('destination', data_dir, 'wait_until_finished', false)); ds.download(pyargs('destination', data_dir, 'wait_until_finished', false));
%% list files / directories in dataset %% list files / directories in dataset
% get list and convert to Matlab cell array % get list and convert to Matlab cell array
files = cell(ds.get_file_list); files = cell(ds.get_file_list);
for iii = 1:numel(files) for iii = 1:numel(files)
iii_file = files{iii}; iii_file = files{iii};
fprintf('%d - %s - isDir: %d\n', iii, string(iii_file{'pathInDataSet'}), iii_file{'isDirectory'}) fprintf('%d - %s - isDir: %d\n', iii, string(iii_file{'pathInDataSet'}), iii_file{'isDirectory'})
end end
%% Spaces %% Spaces
% list spaces % list spaces
spaces = obi.get_spaces; spaces = obi.get_spaces;
spaces spaces
% create a new space % create a new space
space_id = 'MATLAB_TEST'; space_id = 'MATLAB_TEST';
space = obi.new_space(pyargs('code', space_id, 'description', 'test space for Matlab access to openBIS')); space = obi.new_space(pyargs('code', space_id, 'description', 'test space for Matlab access to openBIS'));
space space
space.save; space.save;
% delete created space afterwards % delete created space afterwards
% space.delete('just a test'); % space.delete('just a test');
%% Projects %% Projects
% list projects in Space % list projects in Space
space.get_projects space.get_projects
% create new project % create new project
project_code = 'test_project'; project_code = 'test_project';
project_description = 'my awsome project'; project_description = 'my awsome project';
project = space.new_project(pyargs('code', project_code, ... project = space.new_project(pyargs('code', project_code, ...
'description' , project_description)); 'description' , project_description));
project = project.save(); project = project.save();
space.get_projects space.get_projects
%% clean up %% clean up
% logout % logout
obi.logout() obi.logout()
This diff is collapsed.
This diff is collapsed.
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