Пример #1
0
 def get_amberhome():
     ambhome = os.getenv('AMBERHOME')
     if ambhome == None:
         GMXMMPBSA_ERROR('AMBERHOME is not set!')
     return ambhome
Пример #2
0
def find_progs(INPUT):
    """ Find the necessary programs based in the user INPUT """
    # List all of the used programs with the conditions that they are needed
    logging.info('Checking external programs...')

    used_progs = {
        'cpptraj':
        True,
        'tleap':
        True,
        'parmchk2':
        True,
        'mmpbsa_py_energy':
        ((INPUT['pbrun'] or INPUT['gbrun'])
         and not (INPUT['use_sander'] or INPUT['decomprun'])),
        'sander': (INPUT['decomprun'] or INPUT['use_sander']
                   or INPUT['ifqnt'] == 1),
        'sander.APBS':
        INPUT['sander_apbs'] == 1,
        'mmpbsa_py_nabnmode':
        INPUT['nmoderun'],
        'rism3d.snglpnt':
        INPUT['rismrun']
    }
    gro_exe = {
        'gmx5': [
            # look for any available gromacs executable
            'gmx',
            'gmx_mpi',
            'gmx_d',
            'gmx_mpi_d'
        ],
        'gmx4': [
            # look for gromacs 4.x
            'make_ndx',
            'trjconv',
            'editconf'
        ]
    }

    # The returned dictionary:
    my_progs = {}

    search_path = True
    force_path = INPUT['gmx_path']

    for prog in list(used_progs.keys()):
        my_progs[prog] = ExternProg(prog, used_progs[prog],
                                    search_path).full_path
        if used_progs[prog]:
            if not my_progs[prog]:
                GMXMMPBSA_ERROR('Could not find necessary program [%s]' % prog)
            logging.info('%s found! Using %s' % (prog, str(my_progs[prog])))

    if force_path:
        search_path = False
    g5 = False
    for v in gro_exe:
        if v == 'gmx5':
            for prog in gro_exe[v]:
                exe = ExternProg(prog, True, search_path, force_path)
                if exe.full_path:
                    logging.info('Using GROMACS version > 5.x.x!')
                    my_progs['make_ndx'] = [exe.full_path, 'make_ndx']
                    my_progs['editconf'] = [exe.full_path, 'editconf']
                    my_progs['trjconv'] = [exe.full_path, 'trjconv']
                    g5 = True
                    logging.info('%s found! Using %s' % (prog, exe.full_path))
                    break
            if g5:
                break
        else:
            c = 0
            logging.info('Using GROMACS version 4.x.x!')
            for prog in gro_exe[v]:
                exe = ExternProg(prog, True, search_path, force_path)
                if exe.full_path:
                    c += 1
                    my_progs[prog] = [exe.full_path]
                    logging.info('%s found! Using %s' %
                                 (prog, str(my_progs[prog])))

    if 'make_ndx' not in my_progs or 'editconf' not in my_progs or 'trjconv' not in my_progs:
        GMXMMPBSA_ERROR('Could not find necessary program [ GROMACS ]')
    logging.info('Checking external programs...Done.\n')
    return my_progs
Пример #3
0
def selector(selection: str):
    string_list = selection.split()
    dist = None
    exclude = None
    res_selections = []
    if selection.startswith('within'):
        try:
            dist = float(string_list[1])
        except:
            GMXMMPBSA_ERROR(
                f'Invalid dist, we expected a float value but we get "{string_list[1]}"'
            )
        if len(string_list) == 4:
            if string_list[2] != 'not':
                GMXMMPBSA_ERROR(
                    f'We expected "not" but we get {string_list[2]} instead')
            if str(string_list[3]).lower() not in [
                    'receptor', 'ligand', 'rec', 'lig'
            ]:
                GMXMMPBSA_ERROR(
                    f'We expected one of this values: "receptor", "rec", "ligand" or "lig" but we get'
                    f' {(string_list[3]).lower()} instead')
            exclude = 'REC' if str(
                string_list[3]).lower() in ['receptor', 'rec'] else 'LIG'
    else:
        # try to process residue selection
        for s in string_list:
            n = s.split('/')
            if len(n) != 2 or n[0] not in ascii_letters:
                GMXMMPBSA_ERROR(
                    f'We expected something like this: A/2-10,35,41 but we get {s} instead'
                )
            chain = n[0]
            resl = n[1].split(',')
            for r in resl:
                rr = r.split('-')
                if len(rr) == 1:
                    ci = rr[0].split(':')
                    ri = [chain, int(ci[0]), ''] if len(ci) == 1 else [
                        chain, int(ci[0]), ci[1]
                    ]
                    if ri in res_selections:
                        GMXMMPBSA_WARNING(
                            'Found duplicated residue in selection: CHAIN:{} RES_NUM:{} ICODE: '
                            '{}'.format(*ri))
                        continue
                    res_selections.append(ri)
                else:
                    try:
                        start = int(rr[0])
                        end = int(rr[1]) + 1
                    except:
                        GMXMMPBSA_ERROR(
                            f'When residues range is defined, start and end most be integer but we get'
                            f' {rr[0]} and {rr[1]}')
                    for cr in range(start, end):
                        if [chain, cr, ''] in res_selections:
                            GMXMMPBSA_WARNING(
                                'Found duplicated residue in selection: CHAIN:{} RES_NUM:{} ICODE: '
                                '{}'.format(chain, cr, ''))
                            continue
                        res_selections.append([chain, cr, ''])
    return dist, exclude, res_selections