Ejemplo n.º 1
0
def handle_batch_file_task(f_record, sid, model):
    # 只添加成功的任务,对失败的输入直接过滤掉
    path = join(settings.SETTINGS_ROOT, f_record.file_obj.path)
    with open(path, 'r') as f:
        for line in f.readlines():
            line = line.strip().strip('\n')
            try:
                # TODO: 需要检测是否符合格式
                if f_record.file_type.lower() == 'cas':
                    smile = get_smile_by_cas(line)
                else:
                    smile = line

                handle_smile_task(smile, model, sid)
            except:
                chemistry_logger.error('failed to submit %s' % line)
Ejemplo n.º 2
0
def fetch_polarizability(name, model):
    path = os.path.join(config.GAUSSIAN_PATH, model, name, '%s.log' % name)

    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch Polarizability %s' % path)
        return path

    with open(path, 'r') as f:
        for line in f.readlines():
            if P_RE.search(line):
                try:
                    v = float(line.split()[-2])
                except:
                    chemistry_logger.error('Cannot get Polarizability value %s' % line)
                    v = 0
                else:
                    break

    return v
Ejemplo n.º 3
0
def fetch_ehomo_by_mopac(name, model):
    path = os.path.join(config.MOPAC_PATH, model, name, '%s.out' % name)
    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch H**O %s by mopac' % path)
        return 0.0

    with open(path, 'r') as f:
        for line in f.readlines():
            if EHOMO_MOPAC_RE.search(line):
                try:
                    v = line.split('=')[1].strip().strip('\t').split()[0]
                    v = float(v)
                except:
                    chemistry_logger.exception('Cannot get EHOMO value %s ' % line)
                    v = 0.0
                finally:
                    return v

    chemistry_logger.error('%s no H**O' % path)
    return 0.0
Ejemplo n.º 4
0
def fetch_polarizability(name, model):
    path = os.path.join(config.GAUSSIAN_PATH, model, name, '%s.log' % name)

    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch Polarizability %s' % path)
        return path

    with open(path, 'r') as f:
        for line in f.readlines():
            if P_RE.search(line):
                try:
                    v = float(line.split()[-2])
                except:
                    chemistry_logger.error(
                        'Cannot get Polarizability value %s' % line)
                    v = 0
                else:
                    break

    return v
Ejemplo n.º 5
0
def cnt_batch_file_task(f_record):
    # 只添加成功的任务,对失败的输入直接过滤掉
    #TODO: 计算需要优化
    cnt = 0
    path = join(settings.SETTINGS_ROOT, f_record.file_obj.path)
    with open(path, 'r') as f:
        for line in f.readlines():
            line = line.strip().strip('\n')
            try:
                # TODO: 需要检测是否符合格式
                if f_record.file_type.lower() == 'cas':
                    smile = get_smile_by_cas(line)
                else:
                    smile = line

            except:
                chemistry_logger.error('failed to submit %s' % line)
            else:
                cnt += 1

    return cnt - 1
Ejemplo n.º 6
0
def fetch_ehomo(name, model):
    path = os.path.join(config.GAUSSIAN_PATH, model, name, '%s.log' % name)

    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch H**O %s' % path)
        return 0.0

    ret = []

    with open(path, 'r') as f:
        for line in f.readlines():
            if EHOMO_RE.search(line):
                chemistry_logger.info(line)
                ret.append(line)
    try:
        v = float(ret[-1].split()[-1])
    except Exception as e:
        chemistry_logger.exception('Cannot get EHOMO value %s ' % line)
        v = 0

    return v
Ejemplo n.º 7
0
def fetch_ehomo_by_mopac(name, model):
    path = os.path.join(config.MOPAC_PATH, model, name, '%s.out' % name)
    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch H**O %s by mopac' % path)
        return 0.0

    with open(path, 'r') as f:
        for line in f.readlines():
            if EHOMO_MOPAC_RE.search(line):
                try:
                    v = line.split('=')[1].strip().strip('\t').split()[0]
                    v = float(v)
                except:
                    chemistry_logger.exception('Cannot get EHOMO value %s ' %
                                               line)
                    v = 0.0
                finally:
                    return v

    chemistry_logger.error('%s no H**O' % path)
    return 0.0
Ejemplo n.º 8
0
def fetch_ehomo(name, model):
    path = os.path.join(config.GAUSSIAN_PATH, model, name, '%s.log' % name)

    if not os.path.exists(path):
        chemistry_logger.error('Cannot fetch H**O %s' % path)
        return 0.0

    ret = []

    with open(path, 'r') as f:
        for line in f.readlines():
            if EHOMO_RE.search(line):
                chemistry_logger.info(line)
                ret.append(line)
    try:
        v = float(ret[-1].split()[-1])
    except Exception as e:
        chemistry_logger.exception('Cannot get EHOMO value %s ' % line)
        v = 0

    return v