diff --git a/df_to_cell.m b/df_to_cell.m deleted file mode 100644 index c2ce512553e68766f60ad6f40865b58ea9e093aa..0000000000000000000000000000000000000000 --- a/df_to_cell.m +++ /dev/null @@ -1,6 +0,0 @@ -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 diff --git a/df_to_table.m b/df_to_table.m new file mode 100644 index 0000000000000000000000000000000000000000..7135acb2bc90939022ed0c6a03e85b0379ed976a --- /dev/null +++ b/df_to_table.m @@ -0,0 +1,10 @@ +function [matlab_table] = df_to_table(df) +%df_to_table +% Returns a Matlab table for a Python dataframe + +csv_temp = sprintf('%s.csv', tempname); +df.to_csv(csv_temp); +matlab_table = readtable(csv_temp); +delete(csv_temp); + +end \ No newline at end of file diff --git a/get_dataset_types.m b/get_dataset_types.m new file mode 100644 index 0000000000000000000000000000000000000000..e11aaddee27f5eed16ad80f08ff8e3e200138c1c --- /dev/null +++ b/get_dataset_types.m @@ -0,0 +1,14 @@ +function dataset_types = get_dataset_types +%get_dataset_types +% Returns a table of all available dataset types + +global obi + +% test connection +test_connection(obi) + +dataset_types = obi.get_dataset_types(); + +dataset_types = df_to_table(dataset_types.df); + +end diff --git a/get_datasets.m b/get_datasets.m index cc1e71fa94c23d8e2b37ee1fdca17ee5cf758aa3..67688f262404f47253a6aa2e2e0e26e6df8cdc4d 100644 --- a/get_datasets.m +++ b/get_datasets.m @@ -5,5 +5,5 @@ function [datasets] = get_datasets(ds_type) global obi datasets = obi.get_datasets(pyargs('type',ds_type)); -datasets = df_to_cell(datasets.df); +datasets = df_to_table(datasets.df); end diff --git a/get_experiment_types.m b/get_experiment_types.m index befeaeccbe9a8f7bf106016f5e918052106ab62d..a2d70f0286fd2420289c98b80db331c8f9a408f1 100644 --- a/get_experiment_types.m +++ b/get_experiment_types.m @@ -1,6 +1,6 @@ function experiment_types = get_experiment_types -%UNTITLED2 Summary of this function goes here -% Detailed explanation goes here +%get_experiment_types +% Returns a table of all available experiment types global obi @@ -8,8 +8,7 @@ global obi test_connection(obi) experiment_types = obi.get_experiment_types(); -experiment_types = df_to_cell(experiment_types.df); +experiment_types = df_to_table(experiment_types.df); end - diff --git a/get_material_types.m b/get_material_types.m new file mode 100644 index 0000000000000000000000000000000000000000..ab92d06d5bc470d09431d77e15d68b76ea1fb553 --- /dev/null +++ b/get_material_types.m @@ -0,0 +1,14 @@ +function material_types = get_material_types +%get_material_types +% Returns a table of all available material types + +global obi + +% test connection +test_connection(obi) + +material_types = obi.get_material_types(); + +material_types = df_to_table(material_types.df); + +end diff --git a/get_sample_types.m b/get_sample_types.m new file mode 100644 index 0000000000000000000000000000000000000000..65f5435dfc9b3aeccdd231c4da8b0e0e2b84f054 --- /dev/null +++ b/get_sample_types.m @@ -0,0 +1,14 @@ +function sample_types = get_sample_types +%get_sample_types +% Returns a table of all available sample types + +global obi + +% test connection +test_connection(obi) + +sample_types = obi.get_sample_types(); + +sample_types = df_to_table(sample_types.df); + +end diff --git a/get_terms.m b/get_terms.m new file mode 100644 index 0000000000000000000000000000000000000000..3114cc7dec61cc9ba872a1c84cfa178b895e7058 --- /dev/null +++ b/get_terms.m @@ -0,0 +1,15 @@ +function terms = get_terms +%get_sample_types +%Returns information about existing vocabulary terms. +%If a vocabulary code is provided, it only returns the terms of that vocabulary + +global obi + +% test connection +test_connection(obi) + +terms = obi.get_terms(); + +terms = df_to_table(terms.df); + +end diff --git a/login.m b/login.m index f49d23f24193f92f059f95916e275f8f937e5c4b..441a746f49ebc2e6b1a178c784a951d52348e183 100644 --- a/login.m +++ b/login.m @@ -1,11 +1,32 @@ -function login(url, user, pw) +function login(varargin) %UNTITLED Summary of this function goes here % Detailed explanation goes here global obi +if nargin + url = varargin{1}; + user = varargin{2}; + pw = varargin{3}; +else + [url, user, pw] = user_url_pw_inputdlg; +end + obi = py.pybis.Openbis(url, pyargs('verify_certificates', 0)); obi.login(user, pw, pyargs('save_token', 1)); end +function [url, user, pw] = user_url_pw_inputdlg + +prompt = {'openBIS URL:', 'openBIS user:'}; +title = 'openBIS connection details'; +definput = {'https://XYZ.ethz.ch/openbis:8443', ''}; +answer = inputdlg(prompt, title, 1, definput); + +url = answer{1}; +user = answer{2}; + +pw = passwordEntryDialog('CheckPasswordLength',0); + +end \ No newline at end of file diff --git a/logout.m b/logout.m new file mode 100644 index 0000000000000000000000000000000000000000..9942dc2aed45b28ab1b417a8091ba132a927acbf --- /dev/null +++ b/logout.m @@ -0,0 +1,13 @@ +function logout +%LOGOUT +% Log out of openBIS. After logout, the session token is no longer valid. + +global obi + +% test connection +test_connection(obi) + +obi.logout; + +end + diff --git a/pybis_example.ipynb b/pybis_example.ipynb index 4008e1d7517dc8108a1930f7aa4e1336c133cbda..ad001d3d1a8f6ec4ac565cc9300a7b8fed6042f6 100644 --- a/pybis_example.ipynb +++ b/pybis_example.ipynb @@ -30,7 +30,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -58,16 +58,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'hluetcke-181024130359554x90E8C39FF84921ECC3D5436AE2ECFD05'" + "'hluetcke-181024154540290xCA25DBE8ED8C9FB138503F6C3F0C8D69'" ] }, - "execution_count": 5, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -87,7 +87,7 @@ "True" ] }, - "execution_count": 6, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -98,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -143,7 +143,7 @@ "0 DSS1 https://limb.ethz.ch:443/datastore_server https://limb.ethz.ch:443" ] }, - "execution_count": 7, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -441,7 +441,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.6.5" } }, "nbformat": 4,