{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "3749879d-7d4f-443d-a8a1-0b2dc7b379ae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "loadLibrary\n", "remoteSourcesURL https://git0.fmf.uni-lj.si/studen/nixSuite/raw/master/remoteResources/resources.json\n", "{'labkeyInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/labkeyInterface/archive/master.zip', 'branch': 'master', 'modules': []}, 'irAEMM': {'url': 'https://git0.fmf.uni-lj.si/studen/iraemm/archive/master.zip', 'branch': 'master', 'modules': ['iraemmBrowser']}, 'SlicerLabkeyExtension': {'url': 'https://git0.fmf.uni-lj.si/studen/SlicerLabkeyExtension/archive/SlicerExtensionIndex.zip', 'branch': 'SlicerExtensionIndex', 'modules': ['labkeyBrowser']}, 'limfomiPET': {'url': 'https://git0.fmf.uni-lj.si/studen/limfomiPET/archive/master.zip', 'branch': 'master', 'modules': ['imageBrowser']}, 'parseConfig': {'url': 'https://git0.fmf.uni-lj.si/studen/parseConfig/archive/master.zip', 'branch': 'master', 'modules': []}, 'orthancInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/orthancInterface/archive/master.zip', 'branch': 'master', 'modules': []}}\n", "{'url': 'https://git0.fmf.uni-lj.si/studen/labkeyInterface/archive/master.zip', 'branch': 'master', 'modules': []}\n", "File C:\\Users\\studen\\temp\\labkeyInterface.zip: True\n" ] } ], "source": [ "#load required libraries\n", "import sys\n", "import os\n", "import chardet\n", "import json\n", "import re\n", "\n", "#you should get nixSuite via git clone https://git0.fmf.uni-lj.si/studen/nixSuite.git\n", "#if you don't put it to $HOME/software/src/, you should update the path\n", "nixSuite=os.path.join(os.path.expanduser('~'),'software','src','nixSuite')\n", "sys.path.append(os.path.join(nixSuite,'wrapper'))\n", "import nixWrapper\n", "nixWrapper.loadLibrary('labkeyInterface')\n", "import labkeyInterface\n", "import labkeyDatabaseBrowser\n", "import labkeyFileBrowser\n", "\n", "def connectDB(server):\n", " #check connectivity. This checks the configuration in $HOME/.labkey/network.json, \n", " #where paths to certificates are stored\n", " net=labkeyInterface.labkeyInterface()\n", " fconfig=os.path.join(os.path.expanduser('~'),'.labkey','{}.json'.format(server))\n", " net.init(fconfig)\n", " #this reports the certificate used\n", " try:\n", " print('Using: {}'.format(net.connectionConfig['SSL']['user']))\n", " except KeyError:\n", " pass\n", " #This gets a deafult CSRF code; It should report user name plus a long string of random hex numbers\n", " net.getCSRF()\n", " db=labkeyDatabaseBrowser.labkeyDB(net)\n", " fb=labkeyFileBrowser.labkeyFileBrowser(net)\n", " return db,fb" ] }, { "cell_type": "code", "execution_count": 18, "id": "7c8f8fec-bae9-4207-9a60-1b1644939a58", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "User: andrej studen CSRF: f3f644c27eed6bbfdcb06953e8a71142\n", "260/393\n", "270/393\n", "280/393\n", "290/393\n", "300/393\n", "310/393\n", "320/393\n", "330/393\n", "340/393\n", "350/393\n", "360/393\n", "370/393\n", "380/393\n", "390/393\n" ] } ], "source": [ "#check if all entries from a list appear in the matching dataset\n", "db=connectDB('onko-nix')[0]\n", "project='limfomiPET/Study'\n", "query='imageTransferReport'\n", "\n", "dl=db.selectRows(project,'lists',query,[])\n", "\n", "startWith=0\n", "rows=dl['rows'][startWith:]\n", "filterArray=['participantCode','imagingVisitId']\n", "n=len(rows)+startWith\n", "i=startWith\n", "for r in rows:\n", " qfilter=[{'variable':x,'value':'{}'.format(r[x]),'oper':'eq'} for x in filterArray]\n", " ds=db.selectRows(project,'study',query,qfilter)\n", " d=[r[x] for x in filterArray]\n", " if len(ds['rows'])!=1:\n", " print('Got {} rows for {}/{}'.format(len(ds['rows']),d[0],d[1]))\n", " for q in ds['rows']:\n", " print(q)\n", " break\n", " i+=1\n", " if i%10 == 0:\n", " print('{}/{}'.format(i,n))\n", " #else:\n", " # print('Found {}/{}'.format(d[0],d[1]))\n", " " ] }, { "cell_type": "code", "execution_count": null, "id": "2d09b6d0-5ce9-49dc-8690-245f5ea97070", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.0" } }, "nbformat": 4, "nbformat_minor": 5 }