def read_energy_from_mae(filename): """ Reads energies from *.mae files. Energies are read and saved as kJ/mol. """ path_of_this_file = os.path.dirname(os.path.realpath(__file__)) path_of_q2mm = os.path.join(path_of_this_file, '../q2mm') sys.path.append(path_of_q2mm) import filetypes mae = filetypes.Mae(filename) energies = [float(x.props[ENERGY_LABEL]) for x in mae.structures] return energies
def main(args): parser = return_parser() opts = parser.parse_args(args) # ~~~ STRUCTURE AND CHARGE READING ~~~ mae = ft.Mae(opts.mae) mmo = ft.MacroModel(opts.mmo) # Select 1st structure of .mae. Sure hope your MM charges are there. str_mae = mae.structures[0] # Select 1st structure of .mmo. # This structure should only contain bonds that are particular to our # substructure. str_mmo = mmo.structures[0] substr_bonds = str_mmo.select_stuff('bonds', com_match=opts.subnames) substr_atoms = atom_nums_from_bonds(substr_bonds) # Now that we have the atoms in the substructure, we need to select # every other atom and get those MM charges. non_substr_atoms = [] for atom in str_mae.atoms: if atom.index not in substr_atoms: non_substr_atoms.append(atom) # ~~~ WORKING ON GENERATING THE OUTPUT ~~~ if opts.format == 'jaguar': atomic_lines = gen_atomic_section(non_substr_atoms) # Now we just need to add these to the atomic section. # Read or generate the .in file. if opts.jin: jin = ft.JaguarIn(opts.jin) else: jin = None new_lines = gen_jaguar_output(mae, jin, opts.charge) # Add the charge section. new_lines[0:0] = atomic_lines elif opts.format == 'gaussian': non_substr_atom_indices = [x.index for x in non_substr_atoms] new_lines = gen_gaussian_output( mae, indices_use_charge=non_substr_atom_indices, title=mae.filename.split('.')[0], charge=opts.charge, multiplicity=opts.multiplicity) # ~~~ WRITE OUTPUT ~~~ if opts.output: with open(opts.output, 'w') as f: for line in new_lines: f.write(line + '\n') else: for line in new_lines: print(line)
parser = argparse.ArgumentParser() parser.add_argument('--display', '-d', type=str, default='3d') parser.add_argument('--filename', '-f', type=str) parser.add_argument('--extension', '-e', type=str, nargs='+', default=['jpg']) parser.add_argument('--key', '-k', type=str, nargs='+', default=[]) parser.add_argument('--output', '-o', type=str) opts = parser.parse_args(sys.argv[1:]) path, ext = os.path.splitext(opts.filename) if ext == '.mae': mae = filetypes.Mae(opts.filename) x_data = [] y_data = [] z_data = [] for structure in mae.structures: x_data.append(float(structure.props[X_LABEL])) y_data.append(float(structure.props[Y_LABEL])) z_data.append(float(structure.props[Z_LABEL])) logger.info('x: {} y: {} z: {}'.format(len(x_data), len(y_data), len(z_data))) minimum = min(z_data) z_data = [x - minimum for x in z_data] x_set = np.array(sorted(set(x_data)))