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

first steps to toolbox

parent a04a1720
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/openbis/blob/master/pybis/src/python/README.md
%% first check the Python version %% first check the Python version
...@@ -12,7 +12,7 @@ pyversion ...@@ -12,7 +12,7 @@ pyversion
% on Windows: pyversion 3.6 % on Windows: pyversion 3.6
%% enter username and password for openBIS %% enter username and password for openBIS
username = ''; % enter user name username = 'XYZ'; % enter user name
pw = passwordEntryDialog('CheckPasswordLength',0); pw = passwordEntryDialog('CheckPasswordLength',0);
%% connect to openBIS %% connect to openBIS
...@@ -31,7 +31,7 @@ datasets ...@@ -31,7 +31,7 @@ datasets
ds_id = '20101105142049776-6512'; ds_id = '20101105142049776-6512';
ds = obi.get_dataset(ds_id); ds = obi.get_dataset(ds_id);
% download % download
data_dir = '~/Data/Projects/MatlabOpenbis/data'; data_dir = '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
......
function [matlab_cell] = df_to_cell(df)
csv_temp = sprintf('%s.csv', tempname);
df.to_csv(csv_temp);
matlab_cell = readtable(csv_temp);
delete(csv_temp);
end
\ No newline at end of file
function [file_list] = download_ds_files(obi, ds_id, data_dir)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
ds = obi.get_dataset(ds_id);
% download
ds.download(pyargs('destination', data_dir, 'wait_until_finished', false));
% get list and convert to Matlab cell array
file_list = cell(ds.get_file_list);
end
function [datasets] = get_datasets(ds_type)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
global obi
datasets = obi.get_datasets(pyargs('type',ds_type));
datasets = df_to_cell(datasets.df);
end
login.m 0 → 100644
function login(url, user, pw)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
global obi
obi = py.pybis.Openbis(url, pyargs('verify_certificates', 0));
obi.login(user, pw, pyargs('save_token', 1));
end
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