|
@@ -1,6 +1,27 @@
|
|
|
import os
|
|
|
import sys
|
|
|
import config
|
|
|
+import analysis
|
|
|
+import json
|
|
|
+
|
|
|
+def connectDB(server):
|
|
|
+ sPath=os.path.join(os.path.expanduser('~'),'.labkey','setup.json')
|
|
|
+ with open(sPath,'r') as f:
|
|
|
+ setup=json.load(f)
|
|
|
+
|
|
|
+ sys.path.append(setup['paths']['nixWrapper'])
|
|
|
+ import nixWrapper
|
|
|
+ nixWrapper.loadLibrary('labkeyInterface')
|
|
|
+ import labkeyInterface
|
|
|
+
|
|
|
+
|
|
|
+ net=labkeyInterface.labkeyInterface()
|
|
|
+ fconfig=os.path.join(os.path.expanduser('~'),'.labkey',server)
|
|
|
+ net.init(fconfig)
|
|
|
+ net.getCSRF()
|
|
|
+ import labkeyDatabaseBrowser
|
|
|
+ import labkeyFileBrowser
|
|
|
+ return labkeyDatabaseBrowser.labkeyDB(net),labkeyFileBrowser.labkeyFileBrowser(net)
|
|
|
|
|
|
def getDataset(db,setup,datasetName,qfilter=[]):
|
|
|
ds=db.selectRows(setup['project'],setup['schemaName'],\
|
|
@@ -62,9 +83,51 @@ def downloadFiles(fb,r,setup):
|
|
|
fileName=config.getNodeName(r,setup,'Dummy')+'.mcsv'
|
|
|
downloadNode(fb,fileName,rPath,lPath)
|
|
|
|
|
|
-def downloadPatientFiles(db,fb,setup):
|
|
|
- rows=getPatients(db,setup)
|
|
|
+def downloadPatientFiles(db,fb,setup,qfilter=[]):
|
|
|
+ rows=getPatients(db,setup,qfilter)
|
|
|
for r in rows:
|
|
|
#download
|
|
|
downloadFiles(fb,r,setup)
|
|
|
+
|
|
|
+def uploadCenters(fb,r,setup):
|
|
|
+ names=config.printRowCenterNames(r,setup)
|
|
|
+ copyToServer(fb,r,setup,names)
|
|
|
+
|
|
|
+def downloadCenters(fb,r,setup):
|
|
|
+ names=config.printRowCenterNames(r,setup)
|
|
|
+ copyFromServer(fb,r,setup,names)
|
|
|
+
|
|
|
+def uploadFitParFinal(fb,r,setup,mode):
|
|
|
+ names=config.printFitParFinalRowNames(r,setup,mode)
|
|
|
+ #copy files to server
|
|
|
+ copyToServer(fb,r,setup,names)
|
|
|
+
|
|
|
+def copyToServer(fb,r,setup,names):
|
|
|
+ tempDir=config.getTempDir(setup)
|
|
|
+ code=config.getCode(r,setup)
|
|
|
+ project=setup['project']
|
|
|
+ remoteDir=fb.buildPathURL(project,config.getPathList(r,setup))
|
|
|
+ for n in names:
|
|
|
+ localPath=os.path.join(tempDir,code,n)
|
|
|
+ remotePath='{}/{}'.format(remoteDir,n)
|
|
|
+ fb.writeFileToFile(localPath,remotePath)
|
|
|
+
|
|
|
+def copyFromServer(fb,r,setup,names):
|
|
|
+ try:
|
|
|
+ forceReload=setup['forceReload']
|
|
|
+ except KeyError:
|
|
|
+ forceReload=False
|
|
|
+
|
|
|
+ tempDir=config.getTempDir(setup)
|
|
|
+ code=config.getCode(r,setup)
|
|
|
+ project=setup['project']
|
|
|
+ remoteDir=fb.buildPathURL(project,config.getPathList(r,setup))
|
|
|
+ for n in names:
|
|
|
+ localPath=os.path.join(tempDir,code,n)
|
|
|
+ if os.path.isfile(localPath) and not forceReload:
|
|
|
+ continue
|
|
|
+ remotePath='{}/{}'.format(remoteDir,n)
|
|
|
+ fb.readFileToFile(localPath,remotePath)
|
|
|
+
|
|
|
+
|
|
|
|