doAnalysis.py 958 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. if not all(filesPresent):
  25. analysis.doAnalysisRow(r,xsetup,m)
  26. getData.uploadFitParFinal(fb,r,xsetup,m)
  27. getData.updateStatus(db,r,xsetup,'doAnalysis')
  28. if __name__=="__main__":
  29. main(sys.argv[1])