Skip to content
Snippets Groups Projects
Commit 1e2d0492 authored by BIOPZ-Börsch Anastasiya's avatar BIOPZ-Börsch Anastasiya
Browse files

Update README

parent e8b7584c
No related branches found
No related tags found
1 merge request!8Labkey api
Pipeline #10064 passed
This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
This is the description how to connect to the LabKey through API:
1. Create a file named ".netrc" in your home directory. This file must include the following three lines:
machine <remote-instance-of-labkey-server>
login <user-email>
password <user-password>
E.g.:
machine labkey.scicore.unibas.ch
login eva.pujadas@unibas.ch
password xxxxx
To secure the file, set permissions in a way that only you can see the content of the file
$ chmod 400 .netrc
2. For running the script labkey_api.py libraries "labkey" and "pandas" are required. Either you install them and run the script with the standard python or you use the module "labkey-api-python/1.1.0-foss-2018b-Python-3.6.6" provided by SciCore. Execute the following command:
python labkey_api.py arg1 arg2
Here, arg1 stands for the project name, arg2 stands for the name of the LabKey table.
E.g.:
python labkey_api.py TEST_ABOERSCH RNA_Seq_data_template
The script outputs the complete LabKey table in the form of pandas data frame.
...@@ -14,14 +14,14 @@ import sys ...@@ -14,14 +14,14 @@ import sys
from labkey.query import QueryFilter from labkey.query import QueryFilter
if __name__ == "__main__": if __name__ == "__main__":
#project_name = "TEST_ABOERSCH" # These are values of variables for which the script works
#query_name = "RNA_Seq_data_template" # project_name = "TEST_ABOERSCH"
# query_name = "RNA_Seq_data_template"
project_name = sys.argv[1] project_name = sys.argv[1]
query_name = sys.argv[2] query_name = sys.argv[2]
server_context = labkey.utils.create_server_context('labkey.scicore.unibas.ch', '/Zavolan Group/'+project_name, 'labkey', use_ssl=True) server_context = labkey.utils.create_server_context('labkey.scicore.unibas.ch', '/Zavolan Group/'+project_name, 'labkey', use_ssl=True)
schema_name = "lists" schema_name = "lists"
results = labkey.query.select_rows(server_context,schema_name,query_name) results = labkey.query.select_rows(server_context,schema_name,query_name)
print(results)
table_of_data = pd.DataFrame(results["rows"]) table_of_data = pd.DataFrame(results["rows"])
print(table_of_data) print(table_of_data)
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