doAnalysis.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import analysis
  2. import sys
  3. import os
  4. import getData
  5. import json
  6. import config
  7. def main(configFile):
  8. with open(configFile,'r') as f:
  9. xsetup=json.load(f)
  10. db,fb=getData.connectDB(xsetup['network'])
  11. qfilter=config.getFilter(xsetup)
  12. rows=getData.getPatients(db,xsetup,qfilter)
  13. for r in rows:
  14. getData.downloadCenters(fb,r,xsetup)
  15. mode=['global','IVF']
  16. tempDir=config.getTempDir(xsetup)
  17. for r in rows:
  18. code=config.getCode(r,xsetup)
  19. for m in mode:
  20. #check if we need to run analysis
  21. files=config.printFitParFinalRowNames(r,xsetup,m)
  22. fullFiles=[os.path.join(tempDir,code,f) for f in files]
  23. filesPresent=[os.path.isfile(f) for f in fullFiles]
  24. doRun=not all(filesPresent)
  25. print(f'{code} mode {m} doRun: {doRun}')
  26. #for i in range(len(filesPresent)):
  27. # print('{} {}'.format(filesPresent[i],fullFiles[i]))
  28. #continue
  29. if doRun:
  30. analysis.doAnalysisRow(r,xsetup,m)
  31. print(f'{code} mode {m} done')
  32. getData.uploadFitParFinal(fb,r,xsetup,m)
  33. getData.updateStatus(db,r,xsetup,'doAnalysis')
  34. if __name__=="__main__":
  35. main(sys.argv[1])