def testReadPDBDict(self): test_type = ' HY1 ' test_elem = ' H' test_dict = read_csv_dict(ELEM_DICT_FILE, pdb_dict=True) self.assertTrue(test_type in test_dict) self.assertEquals(test_elem, test_dict[test_type]) self.assertEquals(31, len(test_dict))
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret # Read template and data files cfg = args.config try: chk_file_list = file_rows_to_list(cfg[CHK_FILE_LIST]) if len(cfg[REL_E_SEC]) > 0: extracted_data = get_ene_data(cfg, chk_file_list) ref_e_dict = read_csv_dict(cfg[REF_E_FILE], one_to_one=False, str_float=True) find_rel_e(extracted_data, cfg, ref_e_dict) else: for chK_file in chk_file_list: get_evb_atoms(cfg, chK_file) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA # print(psf_data_content[ATOMS_CONTENT]) return GOOD_RET # success
def testStringDictCheckDups(self): # Check that fails elegantly try: test_dict = read_csv_dict(ELEM_DICT_FILE, ints=False, ) self.assertFalse(test_dict) except InvalidDataError as e: self.assertTrue("Did not find a 1:1 mapping" in e.args[0])
def testStringDictAsInt(self): # Check that fails elegantly by passing returning value error try: test_dict = read_csv_dict(ELEM_DICT_FILE, one_to_one=False) self.assertFalse(test_dict) except ValueError as e: self.assertTrue("invalid literal for int()" in e.message)
def testStringDictCheckDups(self): # Check that fails elegantly try: test_dict = read_csv_dict(ELEM_DICT_FILE, ints=False, ) self.assertFalse(test_dict) except InvalidDataError as e: self.assertTrue("Did not find a 1:1 mapping" in e.message)
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET: return ret # Read template and data files cfg = args.config try: data_tpl_content = process_data_tpl(cfg) old_new_atom_num_dict = {} old_new_atom_type_dict = {} # Will return an empty dictionary for one of them if that one is not true if cfg[MAKE_ATOM_NUM_DICT] or cfg[MAKE_ATOM_TYPE_DICT]: make_atom_dict(cfg, data_tpl_content, old_new_atom_num_dict, old_new_atom_type_dict) # Will return empty dicts if no file if not cfg[MAKE_ATOM_TYPE_DICT]: old_new_atom_type_dict = read_csv_dict(cfg[ATOM_TYPE_DICT_FILE]) process_data_files(cfg, data_tpl_content, old_new_atom_type_dict) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret # Read template and dump files cfg = args.config try: atom_num_dict = read_csv_dict(cfg[ATOM_REORDER_FILE]) atom_type_dict = read_csv_dict(cfg[ATOM_TYPE_FILE], one_to_one=False) mol_num_dict = read_csv_dict(cfg[MOL_RENUM_FILE], one_to_one=False) process_dump_files(cfg, atom_num_dict, atom_type_dict, mol_num_dict) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret cfg = args.config # Read and process pdb files try: atom_num_dict = read_csv_dict(cfg[ATOM_REORDER_FILE]) mol_num_dict = read_csv_dict(cfg[MOL_RENUM_FILE], one_to_one=False) element_dict = create_element_dict(cfg[ELEMENT_DICT_FILE]) process_pdb(cfg, atom_num_dict, mol_num_dict, element_dict) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except (InvalidDataError, ValueError) as e: warning("Problems with input:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret # Read template and data files cfg = args.config if cfg[DATA_FILE] is None: if not (os.path.isfile(cfg[DATA_FILES])): warning( "Did not find a list of data files at the path: {}\n" "In the configuration file, specify a location of a single data file with the keyword {}\n" "and/or a single data file with the keyword {}".format( cfg[DATA_FILES], DATA_FILES, DATA_FILE)) return INVALID_DATA type_dicts = { SEC_ATOMS: {}, SEC_BONDS: {}, SEC_ANGLS: {}, SEC_DIHES: {}, SEC_IMPRS: {}, } try: atom_id_dict = read_csv_dict(cfg[ATOM_ID_DICT_FILE], one_to_one=False) type_dicts[SEC_ATOMS] = read_csv_dict(cfg[ATOM_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_BONDS] = read_csv_dict(cfg[BOND_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_ANGLS] = read_csv_dict(cfg[ANGL_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_DIHES] = read_csv_dict(cfg[DIHE_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_IMPRS] = read_csv_dict(cfg[IMPR_TYPE_DICT_FILE], one_to_one=False) if cfg[DATA_COMP] is None: process_data_files(cfg, atom_id_dict, type_dicts) else: comp_files(cfg, atom_id_dict, type_dicts) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret # Read template and data files cfg = args.config try: data_tpl_content = process_data_tpl(cfg) old_new_atom_num_dict = {} old_new_atom_type_dict = {} # Will return an empty dictionary for one of them if that one is not true if cfg[MAKE_ATOM_NUM_DICT] or cfg[MAKE_ATOM_TYPE_DICT]: make_atom_dict(cfg, data_tpl_content, old_new_atom_num_dict, old_new_atom_type_dict) # Will return empty dicts if no file if not cfg[MAKE_ATOM_TYPE_DICT]: old_new_atom_type_dict = read_csv_dict(cfg[ATOM_TYPE_DICT_FILE]) if cfg[ADJUST_ATOM] is None and len(cfg[ATOMS_DIST]) == 0: process_data_files(cfg, data_tpl_content, old_new_atom_type_dict) elif len(cfg[ATOMS_DIST]) == 0: adjust_atom_xyz(cfg, data_tpl_content) else: adjust_atom_dist(cfg, data_tpl_content) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret cfg = args.config try: out_field_names = gather_out_field_names(cfg) extracted_data = process_evb_files(cfg, out_field_names) if len(cfg[REL_E_SEC]) > 0: ref_e_dict = read_csv_dict(cfg[REF_E_FILE], one_to_one=False, str_float=True) find_rel_e(extracted_data, cfg, out_field_names, ref_e_dict) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except (InvalidDataError, ValueError) as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def main(argv=None): # Read input args, ret = parse_cmdline(argv) if ret != GOOD_RET or args is None: return ret # Read template and data files cfg = args.config if cfg[DATA_FILE] is None: if not(os.path.isfile(cfg[DATA_FILES])): warning("Did not find a list of data files at the path: {}\n" "In the configuration file, specify a location of a single data file with the keyword {}\n" "and/or a single data file with the keyword {}".format(cfg[DATA_FILES], DATA_FILES, DATA_FILE)) return INVALID_DATA type_dicts = {SEC_ATOMS: {}, SEC_BONDS: {}, SEC_ANGLS: {}, SEC_DIHES: {}, SEC_IMPRS: {}, } try: atom_id_dict = read_csv_dict(cfg[ATOM_ID_DICT_FILE], one_to_one=False) type_dicts[SEC_ATOMS] = read_csv_dict(cfg[ATOM_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_BONDS] = read_csv_dict(cfg[BOND_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_ANGLS] = read_csv_dict(cfg[ANGL_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_DIHES] = read_csv_dict(cfg[DIHE_TYPE_DICT_FILE], one_to_one=False) type_dicts[SEC_IMPRS] = read_csv_dict(cfg[IMPR_TYPE_DICT_FILE], one_to_one=False) if cfg[DATA_COMP] is None: process_data_files(cfg, atom_id_dict, type_dicts) else: comp_files(cfg, atom_id_dict, type_dicts) except IOError as e: warning("Problems reading file:", e) return IO_ERROR except InvalidDataError as e: warning("Problems reading data:", e) return INVALID_DATA return GOOD_RET # success
def testReadAtomNumDict(self): # Will renumber atoms and then sort them test_dict = read_csv_dict(ATOM_DICT_FILE) self.assertEqual(test_dict, GOOD_ATOM_DICT)