Révision fd33bfdb modules/isolated.py

b/modules/isolated.py
11 11
    new mol object and the energies of its conformers.
12 12
run_isolated: directs the execution of functions to achieve the goal
13 13
"""
14
import os
14 15
import logging
15 16

  
16 17
import numpy as np
......
177 178
        return np.array([res[1] for res in results])
178 179

  
179 180

  
181
def prep_run(inp_file, mol: Chem.rdchem.Mol, exemplars):
182
    from shutil import copy
183
    # Checking if 'isolated' directory already exists and if so backing it up.
184
    dir_name = 'isolated'
185
    bak_num = 0
186
    while dir_name in os.listdir("."):
187
        bak_num += 1
188
        dir_name = dir_name.split(".")[0]+f".bak{bak_num}"
189
    if bak_num > 0:
190
        os.rename('isolated', dir_name)
191
        logger.warning("'isolated' directory already present. Moved former "
192
                       f"directory to {dir_name}")
193
    os.mkdir('isolated')
194

  
195
    # Creating
196
    for i, conf in enumerate(exemplars):
197
        os.mkdir(f'isolated/conf_{i}')
198
        copy(inp_file, f'isolated/conf_{i}/')
199
        Chem.MolToXYZFile(mol, f'isolated/conf_{i}/coord.xyz', confId=conf)
200

  
201

  
180 202
def run_isolated(inp_vars):
181 203
    """Directs the execution of functions to obtain the conformers to adsorb
182 204

  
......
190 212
    logger.info('Carrying out procedures for the isolated molecule')
191 213
    rd_mol = adapt_format('rdkit', inp_vars['molec_file'])
192 214
    confs = gen_confs(rd_mol, inp_vars['num_conformers'])
215
    if inp_vars['min_confs']:
216
        confs, confs_ener = mmff_opt_confs(confs)
193 217
    rmsd_mtx = get_rmsd(confs)
194
    confs = clustering(rmsd_mtx)
218
    exemplars = clustering(rmsd_mtx)
219
    prep_run(inp_vars['isol_inp_file'], confs, exemplars)
220
    # run dft
195 221

  
196 222
    if 'moi' in inp_vars['cluster_magns']:
197 223
        confs_moi = get_moments_of_inertia(confs)
198 224

  
199
    if 'energy' in inp_vars['cluster_magns']:
200
        if inp_vars['min_confs']:
201
            confs, confs_eners = mmff_opt_confs(confs)
202
        else:
203
            confs_eners = mmff_opt_confs(confs, max_iters=0)
204

  
205
    # clustering2()
225
    # if 'energy' in inp_vars['cluster_magns']:

Formats disponibles : Unified diff