def run_orcajob(e, jobdetails, info): jobtype = 'orca' # info = inputs.load_json(e) smi = info["FILTERED"][0]["SMI"] pname = inputs.get_name_file(e) print("%s : SMILES: %s" % (pname, smi)) #print len(info['conformers']) if jobtype in info: print "no" print ("%s: there are %s %s conformers" % (pname, jobtype, len(info[jobtype]))) return -1 calc_orca = [] inpname = inputs.get_name_file(e) +'.inp' bestconf = inputs.get_bestconf(e, info) if None == bestconf: print("%s: there are not %s mopac conformers" % (pname)) return False mols = {} mols['inchikey'] = info['inchikey'] mols['coords'] = info["FILTERED"][0]['mopac'][bestconf]['coords'] mols['charge'] = 0.0 inputs.create_input(e,'config.json','.inp', mols) outfile = 'zindo.out' # # implement Signal catcher # handler = functools.partial(early_dead, outfile, e, info) signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) callorca.run_orca(inpname) calc = {} if isfile(join(inputs.get_outpath(e),outfile)): try: print inputs.get_outpath(e) calc = orcaloader.load_calc_list(inputs.get_outpath(e)) print calc except: info['lock']= 'ready' info["FILTERED"][0][jobtype]= 'fail' inputs.store_json(e,info) return True info["FILTERED"][0][jobtype] = calc # readey may be gone of there is jobtype info['lock']= 'ready' inputs.store_json(e,info) return True
def run_nwchemjob(e): info = inputs.load_json(e) smi = info["smiles"] pname = inputs.get_name(e) print("%s : SMILES: %s" % (pname, smi)) if 'mopac' in info: print("%s: there are %s mopac conformers" % (pname, len(info['mopac']))) else: print("%s: there are not %s mopac conformers" % (pname)) return False if 'nwchem' in info: print("%s: there are %s nwchem conformers" % (pname, len(info['nwchem']))) return True calc_mop = [] for cc in range(len(info['conformers'])): mols = {} mols['inchikey'] = info['inchikey'] mols['coords'] = info['mopac'][cc]['coords'] mols['charge'] = 0.0 #print mols print("%s: Processing CONF %s" % (pname, cc)) fname = '_CONF_' + str(cc) inputs.create_input(e, 'config_nw.json', fname + '.nw', mols) inpname = inputs.get_name_file(e) + fname + '.nw' copyfile(inpname, 'nwchem') callnw.run_nwchem('nwchem') outfile = 'nwchem.out' if isfile(outfile): calc = loader.load_calc_list(inputs.get_outpath(e), 'nwchem.out') calc_mop.append(calc) info['nwchem'] = calc_mop inputs.store_json(e, info)
def run_nwchemjob_best(e, job): info = inputs.load_json(e) smi = info["smiles"] pname = inputs.get_name(e) print("%s : SMILES: %s" % (pname, smi)) bestconf = inputs.get_bestconf(e) if None == bestconf: print("%s: there are not %s mopac conformers" % (pname)) return False mols = {} mols['inchikey'] = info['inchikey'] mols['coords'] = info['mopac'][bestconf]['coords'] mols['charge'] = 0.0 inputs.create_input(e,'config_nw.json','.nw', mols) inpname = inputs.get_name_file(e) +'.nw' copyfile(inpname, 'nwchem.nw') print job callnwbg.run_nwchem('nwchem', job) outfile = 'nwchem.out' calc_mop = [] if isfile(outfile): calc = loader.load_calc_list(inputs.get_outpath(e), 'nwchem.out') calc_mop.append(calc) info['nwchem'] = calc_mop info['lock']= 'ready' inputs.store_json(e,info) return True
def run_nwchemjob_best(e, job, info): # info = inputs.load_json(e) smi = info["FILTERED"][0]["SMI"] pname = inputs.get_name_file(e) print("%s : SMILES: %s" % (pname, smi)) need_restart = False outfile = 'nwchem.out' print outfile # if isfile(outfile): # prevcalc = loader.load_calc_list(inputs.get_outpath(e), outfile, 'opt') # optdone = prevcalc['optdone'] # if prevcalc['optdone'] == True: # inputs.put_lock(e,'ready') # return False # elif prevcalc['optdone'] == False: # need_restart = True # rename_w_num(outfile) # else: # print ('%s: WARNING did something did not go further' % pname) # return False try: if 'optdone' in info["FILTERED"][0]['nwchem']: if info["FILTERED"][0]['nwchem']['optdone'] == True: inputs.put_lock(e, 'ready', info) return True # else: elif info["FILTERED"][0]['nwchem']['optdone'] == False: need_restart = True elif info["FILTERED"][0]['nwchem']['optdone'] == None: need_restart = False if isfile(outfile): rename_w_num(outfile) # elif info['nwchem']['optdone'] == False: # need_restart = True # if isfile(outfile): # rename_w_num(outfile) # else: # print ('%s: WARNING did something did not go further' % pname) # return False except: print("%s: no nwchem optdone info" % pname) mols = {} inpname = inputs.get_name_file(e) + '.nw' if need_restart: if isfile(inpname): rename_w_num(inpname) #we could restar with mols from prevcalc mols['inchikey'] = info['inchikey'] mols['charge'] = 0.0 mols['coords'] = info["FILTERED"][0]['nwchem']['coords'] inputs.create_input(e, 'config_nwres.json', '.nw', mols) else: bestconf = inputs.get_bestconf(e, info) if None == bestconf: print("%s: there are not best mopac conformers" % (pname)) return False # mols = {} mols['inchikey'] = info['inchikey'] mols['coords'] = info["FILTERED"][0]['mopac'][bestconf]['coords'] mols['charge'] = 0.0 inputs.create_input(e, 'config_nw.json', '.nw', mols) copyfile(inpname, 'nwchem.nw') outfile = 'nwchem.out' print outfile # # implement Signal catcher # handler = functools.partial(early_dead, outfile, e, info) signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) # Do calculation callnwbg.run_nwchem_sub('nwchem', job) ##debug print ("callnwbg My PID is: %s \n" % getpid()) ##debug time.sleep(4000) # calc_mop = [] calc = {} if isfile(join(inputs.get_outpath(e), outfile)): try: calc = loader.load_calc_list(inputs.get_outpath(e), outfile) except: # it fails but just move on info['lock'] = 'ready' info["FILTERED"][0]['nwchem'] = 'fail' inputs.store_json(e, info) return True # calc_mop.append(calc) # info['nwchem'] = calc_mop else: info['lock'] = 'no' inputs.store_json(e, info) return True if calc['optdone'] == True: info['lock'] = 'ready' else: info['lock'] = 'no' info["FILTERED"][0]['nwchem'] = calc inputs.store_json(e, info) return True
def run_nwchemjob_best(e): info = inputs.load_json(e) smi = info["smiles"] pname = inputs.get_name(e) print("%s : SMILES: %s" % (pname, smi)) need_restart = False outfile = 'nwchem.out' # if isfile(outfile): # prevcalc = loader.load_calc_list(inputs.get_outpath(e), outfile, 'opt') # optdone = prevcalc['optdone'] # if prevcalc['optdone'] == True: # inputs.put_lock(e,'ready') # return False # elif prevcalc['optdone'] == False: # need_restart = True # rename_w_num(outfile) # else: # print ('%s: WARNING did something did not go further' % pname) # return False try: if 'optdone' in info['nwchem']: if info['nwchem']['optdone'] == True: inputs.put_lock(e, 'ready') return True elif info['nwchem']['optdone'] == False: need_restart = True if isfile(outfile): rename_w_num(outfile) else: print('%s: WARNING did something did not go further' % pname) return False except: print("%s no nwcheminfo" % pname) mols = {} inpname = inputs.get_name_file(e) + '.nw' if need_restart: if isfile(inpname): rename_w_num(inpname) #we could restar with mols from prevcalc mols['inchikey'] = info['inchikey'] mols['charge'] = 0.0 mols['coords'] = info['nwchem']['coords'] inputs.create_input(e, 'config_nwres.json', '.nw', mols) else: bestconf = inputs.get_bestconf(e) if None == bestconf: print("%s: there are not %s mopac conformers" % (pname)) return False # mols = {} mols['inchikey'] = info['inchikey'] mols['coords'] = info['mopac'][bestconf]['coords'] mols['charge'] = 0.0 inputs.create_input(e, 'config_nw.json', '.nw', mols) copyfile(inpname, 'nwchem.nw') callnw.run_nwchem('nwchem') # calc_mop = [] calc = {} if isfile(outfile): try: calc = loader.load_calc_list(inputs.get_outpath(e), 'nwchem.out') except: # it fails but just move on info['lock'] = 'ready' info['nwchem'] = 'fail' inputs.store_json(e, info) return True # calc_mop.append(calc) #info['nwchem'] = calc_mop if calc['optdone'] == True: # info['nwchem'] = calc_mop info['lock'] = 'ready' else: info['lock'] = 'no' info['nwchem'] = calc inputs.store_json(e, info) return True