Example #1
0
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
Example #2
0
def process(jobdetails):
    jobtype = 'conformers'
    thisdir = os.getcwd()
    ready_files = os.path.join(thisdir, 'readys')
    print tot_inps
    for e in range(tot_inps):
        if inputs.listofinputs[e].lock == 'ready':
            print inputs.get_name_file(e)
            try:
                move(inputs.listofinputs[e].fullpath, ready_files)
            except:
                print "cannot move"
Example #3
0
def process(job):
    jobtype = 'nwchem'
    ##debug    print jobtype
    readys = 0
    tot_errors = 0
    while readys < tot_inps:
        print readys
        print tot_inps
        for e in range(tot_inps):

            #vama pick one already checks locks
            #           inputs.clean_db_for_job2(e, jobtype)

            status, info = inputs.pick_one(e, jobtype)
            pname = inputs.get_name_file(e)

            if status != -1 and inputs.prepare_outdir(e):
                print(' %s : processing ' % pname)
                if not run_nwchemjob_best(e, job, info):
                    print("%s: FAIL to  nwchem" % pname)
                    tot_errors = tot_errors + 1
                readys = readys + 1
            else:
                if 'lock' in info:
                    if info['lock'] == 'ready':
                        readys = readys + 1
                    else:
                        print("%s:no job " % pname)
                        time.sleep(1)
Example #4
0
def process(job):
    jobtype = 'nwchem'
    ##debug    print jobtype
    locks = 0
    opts = 0
    for e in range(tot_inps):
        pname = inputs.get_name_file(e)
        status, lock = nwchemout_analysis(e, jobtype)
        #status , lock = mopac_analysis(e, jobtype)
        #status , lock = confgen_analysis(e, jobtype)
        locks = locks + lock
        if status == -1:
            opts = opts + 1
    print(" total of structures %d " % tot_inps)
    print(" total of locks %d " % locks)
    print(" total of opts %d " % opts)
    print(" total of opts left %d " % (tot_inps - opts))
Example #5
0
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)
Example #6
0
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
Example #7
0
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
Example #8
0
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