def generate(data): """ Sets up the database generator depending on the use input provided by the plugin manager. """ import lauescript.database as db from lauescript.types.data import GENERATOR if config.arg('clean'): clean = True else: clean = False temperatures = [] # =========================================================================== # for arg in mo['options']: # try: # temperatures.append(float(arg)) # except: # pass #=========================================================================== if not clean: db.generate_database(data, config.get_frequency_cutoff(), clean=False, temperatures=temperatures, path=config.config.DatabasePath, root=config.get_config_value('Database', 'modelcompountrootdirectory'), newh=config.get_config_value('APD', 'newH')) return if config.arg('save'): save = True else: save = False data = GENERATOR(temperatures, save) db.generate_database(data, config.get_frequency_cutoff(), root=config.get_config_value('Database', 'modelcompountrootdirectory'), frequency_scale=config.get_config_valueFloat('Database', 'frequency_scale'), newh=config.get_config_value('APD', 'newH'))
def FlexLoad(data, loader, dabapath, config, filename='./', noTransfer=False, planarityThreshold=.1): """ A more flexible variation of the 'Load' function. The actual 'loading' is handled by the 'Loader' class which relies on InputOutputProviders to access files independent of their specific file format. FlexLoad itself is only integrating the molecule returned by the 'Loader' in the APD-Toolkit's data structure and subsequently populating the data structure with the necessary model molecules. """ printer = config.get_active_printer() loader.auto_setup(filename) data.register_molecule(loader.load('exp'), 'exp') data['exp'].give_cell(loader.get_cell()) T = config.arg('temp') if not T: T = loader.get_temperature() if not T: printer.highlight('Warning: No temperature specified. Falling back to default.') T = 100 T = int(T) data.give_temperature(T) dabapa = dabapath + '/APD_DABA_{:.1f}_.txt'.format(data.temperature) printer('Crystal temperature: {:.1f} K'.format(data.temperature)) try: dabapointer = open(dabapa) except IOError: printer('inout.py: Error: File {} not found.'.format(dabapa)) printer('Calling database generator to generate appropriate database file.\n\n') import lauescript.database as db frequency_cutoff = config.get_frequency_cutoff() db.generate_database(data, frequency_cutoff, clean=False, temperatures=[data.temperature], path=dabapath, newh=config.get_config_valueBool('APD', 'newH')) dabapointer = open(dabapa) database = dabapointer.readlines() printer() if noTransfer: read_database(data, database, invlist=[], readAll=True) return correctionsPointer = open(dabapath + '/empirical_corrections.txt') for invdict, orientations, compounds in invstring.get_invariom_names(names=[i.name for i in data['exp'].atoms], cart=[i.cart for i in data['exp'].atoms], dictionary=True, orientations=True, compounds=open(dabapath + '/APD_MAP.txt'), corrections=correctionsPointer, dynamic=True, output=printer, verbose=False, newH=config.get_config_valueBool('APD', 'newH'), planarityThreshold=planarityThreshold): invlist = [item for _, item in compounds.items()] read_database(data, database, invlist) kill = False misses = [] for atom in data['exp'].atoms: invname = invdict[atom.name] orientation = orientations[atom.name] atom.add_invariom(invname, orientation) if invname in compounds.keys() and not atom.model_compound: modelname = compounds[invname] atom.model_compound = data[modelname] atom.set_active_invariom(invname) elif invname not in compounds.keys() and not atom.model_compound: misses.append((atom, invname)) kill = True printer('Trying dynamic invariom name for atom {}. {} not available'.format(atom.name, invname)) printer() if kill: for atom in misses: atom = atom[0] neighbours = cg.get_framework_neighbours(atom, useH=False) if len(neighbours) > 1: for atom2 in neighbours: if not atom2.get_active_invariom(): message = 'Error: The following invarioms are missing in the database:\n' message += '\n'.join(['{:<6} <-> {:>}'.format(miss[0].name, miss[1]) for miss in misses]) message += '\n\n!!!Terminating program due to fatal error: MISSING INVARIOMS!!!' core.apd_exit(message=message) atom.tolerate() printer('WARNING: Tolerating missing invariom for {}.'.format(atom.name)) else: message = 'Error: The following invarioms are missing in the database:\n' message += '\n'.join(['{:<6} <-> {:>}'.format(miss[0].name, miss[1]) for miss in misses]) message += '\n\n!!!Terminating program due to fatal error: MISSING INVARIOMS!!!' core.apd_exit(message=message) return message = 'Error: The following invarioms are missing in the database:\n' message += '\n'.join(['{:<6} <-> {:>}'.format(miss[0].name, miss[1]) for miss in misses]) message += '\n\n!!!Terminating program due to fatal error: MISSING INVARIOMS!!!' core.apd_exit(message=message)