From eb0fe440f89d894cc90bf5eb27845348f6b72052 Mon Sep 17 00:00:00 2001 From: bc118 Date: Thu, 22 Aug 2024 21:13:37 -0400 Subject: [PATCH 1/7] added all the functions, but with warnings, saying input tests correctness is not checked. --- docs/index.rst | 1 + docs/topic_guides/data_structures.rst | 5 +- docs/topic_guides/secondary_structures.rst | 50 ++ ...GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp | 2 +- .../tests/test_file_read_write.py | 11 +- .../tests/test_math_operation.py | 405 ++++++++++++++- .../utils/file_read_and_write.py | 476 +++++++++--------- mosdef_dihedral_fit/utils/math_operations.py | 329 +++++++----- 8 files changed, 905 insertions(+), 374 deletions(-) create mode 100644 docs/topic_guides/secondary_structures.rst diff --git a/docs/index.rst b/docs/index.rst index e44a3b0..5c1c337 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -117,6 +117,7 @@ The official VMD web page is http://www.ks.uiuc.edu/Research/vmd :maxdepth: 2 topic_guides/data_structures + topic_guides/secondary_structures .. toctree:: :caption: Reference diff --git a/docs/topic_guides/data_structures.rst b/docs/topic_guides/data_structures.rst index 403d3e7..f2f36ef 100644 --- a/docs/topic_guides/data_structures.rst +++ b/docs/topic_guides/data_structures.rst @@ -10,10 +10,13 @@ Calculate a Dihedral Angle .. automodule:: mosdef_dihedral_fit.utils.math_operations :members: dihedral_angle - + Fit a Dihedral -------------- .. automodule:: mosdef_dihedral_fit.dihedral_fit.fit_dihedral_with_gomc :members: fit_dihedral_with_gomc + + + diff --git a/docs/topic_guides/secondary_structures.rst b/docs/topic_guides/secondary_structures.rst new file mode 100644 index 0000000..beac5f8 --- /dev/null +++ b/docs/topic_guides/secondary_structures.rst @@ -0,0 +1,50 @@ +.. _secondary_data_structures: + +========================= +Secondary Data Structures +========================= + +.. warning:: + These secondary functions, mostly from the **utils** folder,= + **do not contain Type or Value Input Checks**. Therefore, they are being + listed with a warning that only advanced users should use these functions, as + they were not designed with input error checks. + + Advanced users who wish to use these functions can find them + `here `_. + + +Read and Write Functions (For Advanded Users) +--------------------------------------------- + +.. warning:: + These secondary functions, mostly from the **utils** folder,= + **do not contain Type or Value Input Checks**. Therefore, they are being + listed with a warning that only advanced users should use these functions, as + they were not designed with input error checks. + + Advanced users who wish to use these functions can find them + `here `_. + + +.. automodule:: mosdef_dihedral_fit.utils.file_read_and_write + :members: get_atom_names_and_elements_from_mol2, get_atom_names_and_elements_from_pdb, write_xyz_file_from_gaussian_coordinates, write_restart_coor_from_xyz_file, check_gaussian_angle_energy_file_correct, check_gaussian_optimized_coordinate_file_correct, get_final_gaussian_output_file_data, get_gaussian_log_file_data, write_qm_data_files, get_matching_dihedral_info_and_opls_fitting_data + + +Math and Operation Functions (For Advanded Users) +------------------------------------------------- + +.. warning:: + These secondary functions, mostly from the **utils** folder,= + **do not contain Type or Value Input Checks**. Therefore, they are being + listed with a warning that only advanced users should use these functions, as + they were not designed with input error checks. + + Advanced users who wish to use these functions can find them + `here `_. + + +.. automodule:: mosdef_dihedral_fit.utils.math_operations + :noindex: dihedral_angle + :members: round_to_sig_figs, normalize_vector, angle_between_2_vectors, check_previous_qm_values_match, sum_opls_const_1_plus_or_minus_cos_n_values, periodic_dihedral_n_1_2_3_4_5, RB_torsion_n_1_2_3_4_5, opls_dihedral_n_1_2_3_4 + diff --git a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp index e791c11..050b317 100644 --- a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp +++ b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp @@ -57,7 +57,7 @@ DIHEDRALS * CHARMM ! Boltzmann = 0.0019872041 kcal / (mol * K) ! ! type_1 type_2 type_3 type_4 Kchi n delta ! extended_type_1 extended_type_2 extended_type_3 extended_type_4 -HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 +HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 ! The input dihedral to periodic dihedral conversion error is OK [error <= 10^(-10)] ! Maximum( |(input dihedral calc)-(periodic dihedral calc)| ) = 3.608224830031759e-16 diff --git a/mosdef_dihedral_fit/tests/test_file_read_write.py b/mosdef_dihedral_fit/tests/test_file_read_write.py index 7687b38..3dccd36 100644 --- a/mosdef_dihedral_fit/tests/test_file_read_write.py +++ b/mosdef_dihedral_fit/tests/test_file_read_write.py @@ -276,7 +276,7 @@ def test_write_qm_data_files(self): out_indices = [] write_qm_data_files({full_path: out_indices}) assert os.path.exists("extracted_gaussian_data/dihedral.txt") - + def test_get_matching_dihedral_info_and_opls_fitting_data(self): out = get_matching_dihedral_info_and_opls_fitting_data( fit_dihedral_atom_types=["HC", "CT", "CT", "HC"], @@ -304,7 +304,7 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): [4, 1, 2, 8], [5, 1, 2, 6], [5, 1, 2, 7], - [5, 1, 2, 8], + [5, 1, 2, 8] ] assert dihedral_numsList == expected_dihedralnumsList @@ -327,7 +327,7 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): [-1.012159, 1.156346, 0.0], [0.0, 0.76376, 0.0], [-0.0, -0.76376, 0.0], - [1.012159, -1.156346, 0.0], + [1.012159, -1.156346, 0.0] ] assert np.allclose(coordsList[0][0], expected_coords) assert np.shape(coordsList) == (37, 9, 4, 3) @@ -351,10 +351,10 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): 8.999999999999845, 8.99999999999938, 2.780442542871242e-12, - 8.99999999999753, + 8.99999999999753 ] assert np.allclose(opls_paramsList[0], expected_opls_params) - + def test_change_gomc_ff_file_dihedral_values(self): new_file = self.get_fn( "gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp" @@ -379,3 +379,4 @@ def test_change_gomc_ff_file_dihedral_values(self): break assert checkFile + diff --git a/mosdef_dihedral_fit/tests/test_math_operation.py b/mosdef_dihedral_fit/tests/test_math_operation.py index 2911657..735b091 100644 --- a/mosdef_dihedral_fit/tests/test_math_operation.py +++ b/mosdef_dihedral_fit/tests/test_math_operation.py @@ -9,7 +9,6 @@ class TestMathOperations(BaseTest): # ******************************************** # test the mdf_math.round_to_sig_figs (START) # ******************************************** - def test_round_to_sig_figs(self): assert mdf_math.round_to_sig_figs(0) == 0 @@ -450,6 +449,407 @@ def test_dihedral_angle_error_3(self): test_vectors_input_value[3], ) + def test_dihedral_angle_error_coord_1_not_list(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + '[1, 2, 3]', + [4, 5, 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_2_not_list(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + '[4, 5, 6]', + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_3_not_list(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + '[7, 8, 9]', + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_4_not_list(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + '[10, 11, 12]', + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_1_entry_1_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \['1', 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + ['1', 2, 3], + [4, 5, 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_1_entry_2_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, '2', 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, '2', 3], + [4, 5, 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_1_entry_3_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, '3'\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, '3'], + [4, 5, 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_2_entry_1_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \['4', 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + ['4', 5, 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_2_entry_2_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, '5', 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, '5', 6], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_2_entry_3_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, '6'\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, '6'], + [7, 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_3_entry_1_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \['7', 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + ['7', 8, 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_3_entry_2_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, '8', 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, '8', 9], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_3_entry_3_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, '9'\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, 8, '9'], + [10, 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_4_entry_1_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \['10', 11, 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + ['10', 11, 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_4_entry_2_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, '11', 12\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + [10, '11', 12], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): + # Test case 1 + with pytest.raises( + ValueError, + match=f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three \(3\) ints or floats. \n" + f"Example: \[1.2, 3.4, 5.6\] \n " + f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" + f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" + f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" + f"atom_xyz_coord_4 = \[10, 11, '12'\] and type = . " + ): + test_vectors_input_value = [ + [1, 2, 3], + [4, 5, 6], + [7, 8, 9], + [10, 11, '12'], + ] + test_return_value = mdf_math.dihedral_angle( + test_vectors_input_value[0], + test_vectors_input_value[1], + test_vectors_input_value[2], + test_vectors_input_value[3], + ) + + # ******************************************** # test the dihedral_angle (END) # ******************************************** @@ -457,7 +857,7 @@ def test_dihedral_angle_error_3(self): # ******************************************** # test the mdf_math.check_previous_qm_values_match (START) # ******************************************** - + ''' def test_check_previous_qm_values_match(self): # Without error all_value_list = [[1], [2], [3]] @@ -478,3 +878,4 @@ def test_check_previous_qm_values_match(self): check_return = mdf_math.check_previous_qm_values_match( all_value_list, [4], "value_name", "qm_engine", "log_file" ) + ''' \ No newline at end of file diff --git a/mosdef_dihedral_fit/utils/file_read_and_write.py b/mosdef_dihedral_fit/utils/file_read_and_write.py index f1db4e4..ee7b7b1 100755 --- a/mosdef_dihedral_fit/utils/file_read_and_write.py +++ b/mosdef_dihedral_fit/utils/file_read_and_write.py @@ -12,20 +12,19 @@ def get_atom_names_and_elements_from_mol2(mol2_directory_and_filename): """Get the atom names and element names from the mol2 file. - This gets the atom names and elements from the mol2 file, - outputting them as lists. + This gets the atom names and elements from the Mol2 file, outputting them as lists. Parameters ---------- mol2_directory_and_filename: str - The mol2 path/directory and the filename + The Mol2 path/directory and the filename. Returns ------- - atom_name_list: list, Example = [atom_name_0, atom_name_1, ..., atom_name_n] - A list of atom names in the mol2 file, in order. - element_name_list: list, Example = [element_name_0, element_name_1, ..., element_name_n] - A list of element names in the mol2 file, in order. + atom_name_list: list of str, Example = [atom_name_0, atom_name_1, ..., atom_name_n] + A list of atom names in the Mol2 file, in order. + element_name_list: list of str, Example = [element_name_0, element_name_1, ..., element_name_n] + A list of element names in the Mol2 file, in order. """ atom_name_list = [] element_name_list = [] @@ -65,20 +64,21 @@ def get_atom_names_and_elements_from_pdb(pdb_directory_and_filename): This gets the atom names and elements from the pdb file, outputting them as lists. - NOTE: This only works if the first column for all atoms/beads is - labeled 'ATOM' or 'HETATM', which is currently the only output for the PDB - files via MoSDeF-GOMC. + .. note:: + This only works if the first column for all atoms/beads is + labeled 'ATOM' or 'HETATM', which is currently the only output for the PDB + files via MoSDeF-GOMC. Parameters ---------- pdb_directory_and_filename: str - The PDB path/directory and the filename + The PDB path/directory and the filename. Returns ------- - atom_name_list: list, Example = [atom_name_0, atom_name_1, ..., atom_name_n] + atom_name_list: list of str, Example = [atom_name_0, atom_name_1, ..., atom_name_n] A list of atom names in the PDB file, in order. - element_name_list: list, Example = [element_name_0, element_name_1, ..., element_name_n] + element_name_list: list of str, Example = [element_name_0, element_name_1, ..., element_name_n] A list of element names in the PDB file, in order. """ atom_name_list = [] @@ -117,7 +117,6 @@ def get_atom_names_and_elements_from_pdb(pdb_directory_and_filename): if len(split_line_m) > 0 and str(split_line_m[0]) in ["CRYST1"]: get_atom_type_bool = True - print(element_name_list) if len(element_name_list) == 0: raise TypeError( "ERROR: The provided pdb format is not the required PDB format " @@ -141,7 +140,7 @@ def write_xyz_file_from_gaussian_coordinates( Parameters ---------- - atom_name_list: list, Example = [atom_name_0, atom_name_1, ..., atom_name_n] + atom_name_list: list of str, Example = [atom_name_0, atom_name_1, ..., atom_name_n] A list of atom names in the PDB file, in order. qm_parital_coordinate_file_starting_dir_and_name: str The first part of the QM directory and file name. There are many files or @@ -163,7 +162,7 @@ def write_xyz_file_from_gaussian_coordinates( Outputs ------- - Writes the xyz file in the file in the selected 'xyz_files_directory' directory, + Writes the xyz file in the file in the selected 'xyz_files_directory' directory, with the file name 'dihedral_coords_position_n.xyz'. """ # check if file extension starts with a "." or not remove for correct insertion later @@ -233,8 +232,9 @@ def write_restart_coor_from_xyz_file(coor_files_directory, total_qm_scans): This function utilized VMD to write the restart coor files from the xyz file. - NOTE: NAMD or GOMC need to be restarted from the restart coor file to have - more coordinate precision than the PDB file format provides. + .. note:: + NAMD or GOMC need to be restarted from the restart coor file to have + more coordinate precision than the PDB file format provides. Parameters ---------- @@ -303,7 +303,7 @@ def check_gaussian_angle_energy_file_correct(gaussian_energy_file_dir_and_name): This checks the gaussian/Gausview containing the angle and energy is formatted correctly. - The proper header format for the GausView/Gaussian output is as follows: + | The proper header format for the GausView/Gaussian output is as follows: | # Scan of Total Energy | # X-Axis: Scan Coordinate @@ -397,9 +397,8 @@ def check_gaussian_optimized_coordinate_file_correct( """Check that the gaussian/Gausview file containing the optimized coordinates is formatted correctly. This checks the gaussian/Gausview containing the optimized coordinates is formatted correctly. - - The proper header format for the GausView/Gaussian output is as follows: - + | The proper header format for the GausView/Gaussian output is as follows: + | Row Highlight Display Tag Symbol X Y Z Parameters @@ -452,7 +451,7 @@ def get_final_gaussian_output_file_data( This gets the gaussian/Gausview log file data for all the optimized configurations, moving it to the folder that will be analyzed. - The proper header format for the GausView/Gaussian output is as follows: + | The proper header format for the GausView/Gaussian output is as follows: | Row Highlight Display Tag Symbol X Y Z @@ -466,12 +465,13 @@ def get_final_gaussian_output_file_data( order of the dictionary file name (strings). These removed parameters allow users to remove any bad or repeated data points for the QM log file when needed. - Example 1: {'path/gaussian_log_file.log': []} - Uses all the optimized data points from the 'path/gaussian_log_file_data_path' file. + | Example 1: {'path/gaussian_log_file.log': []} + | Uses all the optimized data points from the 'path/gaussian_log_file_data_path' file. + + | Example 2: {'path/gaussian_log_file.log': [0, 23]} + | Uses all data points from the 'path/gaussian_log_file_data_path' file, except points + | 0 and 23. NOTE: Python counting starts at 0. - Example 2: {'path/gaussian_log_file.log': [0, 23]} - Uses all data points from the 'path/gaussian_log_file_data_path' file, except points - 0 and 23. NOTE: Python counting starts at 0. manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) This is a list of the dihedral atom numbers in order that were used for the dihedral fit. This information needs to be correct and in order to produce correct results. @@ -479,35 +479,34 @@ def get_final_gaussian_output_file_data( Returns ------- - list of: - all_dihedral_angle_degrees_list: list (nested list) - This is the list of the optimized Gaussian dihedral angles (degrees) with the - specific angles removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_energy_hartree_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_coordinates_ang_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - element_names_list: list - This is the list of the Gaussian element names per the - 'qm_log_file_dict' list (value) input. - The list length is dependant on the number of elements in the Gaussian log file - These values are confirmed to be the same for all entered Gaussian log files. - number_of_atoms: int - This is the number of atoms in the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. - manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) - This is a list of the dihedral atom numbers in order that were used for the dihedral - fit. This information needs to be correct and in order to produce correct results. - The values must be the same in all the combined files. + all_dihedral_angle_degrees_list: list (nested list) + This is the list of the optimized Gaussian dihedral angles (degrees) with the + specific angles removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + all_energy_hartree_list: list (nested list) + This is the list of the optimized Gaussian energies with the specific energies + (hartree) removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + all_coordinates_ang_list: list (nested list) + This is the list of the optimized Gaussian energies with the specific energies + (hartree) removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + element_names_list: list + This is the list of the Gaussian element names per the + 'qm_log_file_dict' list (value) input. + The list length is dependant on the number of elements in the Gaussian log file + These values are confirmed to be the same for all entered Gaussian log files. + number_of_atoms: int + This is the number of atoms in the Gaussian + 'qm_log_file_dict' list (value) input. + These values are confirmed to be the same for all entered Gaussian log files. + manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) + This is a list of the dihedral atom numbers in order that were used for the dihedral + fit. This information needs to be correct and in order to produce correct results. + The values must be the same in all the combined files. """ if not isinstance(qm_log_file_dict, dict): raise TypeError( @@ -736,12 +735,12 @@ def get_final_gaussian_output_file_data( def get_gaussian_log_file_data( qm_log_file_dict, ): - """Get the gaussian/Gausview file data from the log filefor all the optimized configurations. + """Get the gaussian/Gausview file data from the log file for all the optimized configurations. This gets the gaussian/Gausview log file data for all the optimized configurations, allowing the data to be analyzed further. - The proper header format for the GausView/Gaussian output is as follows: + | The proper header format for the GausView/Gaussian output is as follows: | Row Highlight Display Tag Symbol X Y Z @@ -754,46 +753,44 @@ def get_gaussian_log_file_data( order of the dictionary file name (strings). These removed parameters allow users to remove any bad or repeated data points for the QM log file when needed. - Example 1: {'path/gaussian_log_file.log': []} - Uses all the optimized data points from the 'path/gaussian_log_file.log' file. + | Example 1: {'path/gaussian_log_file.log': []} + | Uses all the optimized data points from the 'path/gaussian_log_file.log' file. - Example 2: {'path/gaussian_log_file.log': [0, 23]} - Uses all data points from the 'path/gaussian_log_file.log' file, except points - 0 and 23. NOTE: Python counting starts at 0. + | Example 2: {'path/gaussian_log_file.log': [0, 23]} + | Uses all data points from the 'path/gaussian_log_file.log' file, except points + | 0 and 23. NOTE: Python counting starts at 0. Returns ------- - list of: - all_dihedral_angle_degrees_list: list (nested list) - This is the list of the optimized Gaussian dihedral angles (degrees) with the - specific angles removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_energy_hartree_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_coordinates_ang_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - element_names_list: list - This is the list of the Gaussian element names per the - 'qm_log_file_dict' list (value) input. - The list length is dependant on the number of elements in the Gaussian log file - These values are confirmed to be the same for all entered Gaussian log files. - number_of_atoms: int - This is the number of atoms in the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. - dihedral_atom_numbers_list: list of 4 integers - This is the list of the dihedral atom numbers used in the Gaussian - dihedral scan, which are taken from the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. - + all_dihedral_angle_degrees_list: list (nested list of str) + This is the list of the optimized Gaussian dihedral angles (degrees) with the + specific angles removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + all_energy_hartree_list: list (nested list of str) + This is the list of the optimized Gaussian energies with the specific energies + (hartree) removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + all_coordinates_ang_list: list (nested list of float) + This is the list of the optimized Gaussian energies with the specific energies + (hartree) removed per the 'qm_log_file_dict' list + (value) input. This is a nested list, with an inner list for every + Gaussian log file or 'qm_log_file_dict' (key). + element_names_list: list of str + This is the list of the Gaussian element names per the + 'qm_log_file_dict' list (value) input. + The list length is dependant on the number of elements in the Gaussian log file + These values are confirmed to be the same for all entered Gaussian log files. + number_of_atoms: int + This is the number of atoms in the Gaussian + 'qm_log_file_dict' list (value) input. + These values are confirmed to be the same for all entered Gaussian log files. + dihedral_atom_numbers_list: list of 4 int + This is the list of the dihedral atom numbers used in the Gaussian + dihedral scan, which are taken from the Gaussian + 'qm_log_file_dict' list (value) input. + These values are confirmed to be the same for all entered Gaussian log files. """ if not isinstance(qm_log_file_dict, dict): raise TypeError( @@ -1179,89 +1176,97 @@ def write_qm_data_files( Parameters ---------- qm_log_file_dict: dict, {str: [int, ..., int]} - * qm_engine="gaussian" - This is a dictionary comprised of a key (string) of the QM log file path and name, - and a list of integers, which are the QM optimization parameters to remove from - the written data, in order of reading from each file. These can be seen in the - order of the dictionary file name (strings). These removed parameters allow - users to remove any bad or repeated data points for the QM log file when needed. - - Example 1: {'path/gaussian_log_file.log': []} - - Uses all the optimized data points from the 'path/gaussian_log_file.log' file. - - Example 2: {'path/gaussian_log_file.log': [0, 23]} - Uses all data points from the 'path/gaussian_log_file.log' file, except points - 0 and 23. NOTE: Python counting starts at 0. - - * qm_engine="gaussian_style_final_files" - This is a dictionary comprised of a key (string) of the file paths to the - Gaussian style final formatted files, and a list of integers, which are the - QM optimization parameters to remove from the written data, in order of reading - from each folder. These can be seen in the order of the dictionary file name (strings). - These removed parameters allow users to remove any bad or repeated data points - for the QM log file when needed. - NOTE: The energy and dihedral angle file in this directory need to be - named 'dihedral.txt' for the energy and dihedral angle values (one 1 per directory). - - Example of energy and dihedral angle file ('dihedral.txt'): - - | # Scan of Total Energy - | # X-Axis: Scan Coordinate - | # Y-Axis: Total Energy (Hartree) - | # X Y - | 0.0 -267.0062955742 - | 10.0 -267.0062900424 - - NOTE: The coordinate files in this directory need to be - named 'dihedral_coords_position_XXXX.txt' for the each angles coordinate values. - There are as XXX file in this directory where XXX is the number of dihedral angles. - The file numbering starts at 1 so the files are named 'dihedral_coords_position_1.txt' - to 'dihedral_coords_position_XXXX.txt' - - Example of coordinate file ('dihedral_coords_position_1.txt'): - - | Row Highlight Display Tag Symbol X Y Z - | 1 No Show 1 C 0.077153 -0.010211 0.106889 - | 2 No Show 2 C -1.455163 0.076994 0.364648 - | 3 No Show 3 C -2.162794 1.205823 -0.378912 - | 4 No Show 4 O 0.614863 1.022719 -0.303596 - | 5 No Show 5 O 0.581656 -1.105138 0.370604 - | 6 No Show 6 H -1.703737 2.157201 -0.140757 - | 7 No Show 7 H -2.079381 1.073202 -1.454515 - | 8 No Show 8 H -1.898266 -0.885627 0.121028 - | 9 No Show 9 H -1.593015 0.205080 1.439694 - | 10 No Show 10 H -3.224767 1.255506 -0.130085 - - Example 1: {'path_to_gaussian_style_final_files': []} - Uses all the optimized data points from the 'path/gaussian_log_file.log' file. - - Example 2: {'path_to_gaussian_style_final_files': [0, 23]} - Uses all data points from the 'path/gaussian_log_file.log' file, except points - 0 and 23. NOTE: Python counting starts at 0. - - manual_dihedral_atom_numbers_list: list of 4 integers, default=None - NOTE: Only needed for qm_engine="gaussian_style_final_files" + qm_engine="gaussian" + + | This is a dictionary comprised of a key (string) of the QM log file path and name, + | and a list of integers, which are the QM optimization parameters to remove from + | the written data, in order of reading from each file. These can be seen in the + | order of the dictionary file name (strings). These removed parameters allow + | users to remove any bad or repeated data points for the QM log file when needed. + + | Example 1: {'path/gaussian_log_file.log': []} + | Uses all the optimized data points from the 'path/gaussian_log_file.log' file. + + | Example 2: {'path/gaussian_log_file.log': [0, 23]} + | Uses all data points from the 'path/gaussian_log_file.log' file, except points + | 0 and 23. NOTE: Python counting starts at 0. + + + | qm_engine="gaussian_style_final_files" + + | This is a dictionary comprised of a key (string) of the file paths to the + | Gaussian style final formatted files, and a list of integers, which are the + | QM optimization parameters to remove from the written data, in order of reading + | from each folder. These can be seen in the order of the dictionary file name (strings). + | These removed parameters allow users to remove any bad or repeated data points + | for the QM log file when needed. + | NOTE: The energy and dihedral angle file in this directory need to be + | named 'dihedral.txt' for the energy and dihedral angle values (one 1 per directory). + + | Example of energy and dihedral angle file ('dihedral.txt'): + + | # Scan of Total Energy + | # X-Axis: Scan Coordinate + | # Y-Axis: Total Energy (Hartree) + | # X Y + | 0.0 -267.0062955742 + | 10.0 -267.0062900424 + + | NOTE: The coordinate files in this directory need to be + | named 'dihedral_coords_position_XXXX.txt' for the each angles coordinate values. + | There are as XXX file in this directory where XXX is the number of dihedral angles. + | The file numbering starts at 1 so the files are named 'dihedral_coords_position_1.txt' + | to 'dihedral_coords_position_XXXX.txt' + + | Example of coordinate file ('dihedral_coords_position_1.txt'): + + | Row Highlight Display Tag Symbol X Y Z + | 1 No Show 1 C 0.077153 -0.010211 0.106889 + | 2 No Show 2 C -1.455163 0.076994 0.364648 + | 3 No Show 3 C -2.162794 1.205823 -0.378912 + | 4 No Show 4 O 0.614863 1.022719 -0.303596 + | 5 No Show 5 O 0.581656 -1.105138 0.370604 + | 6 No Show 6 H -1.703737 2.157201 -0.140757 + | 7 No Show 7 H -2.079381 1.073202 -1.454515 + | 8 No Show 8 H -1.898266 -0.885627 0.121028 + | 9 No Show 9 H -1.593015 0.205080 1.439694 + | 10 No Show 10 H -3.224767 1.255506 -0.130085 + + | Example 1: {'path_to_gaussian_style_final_files': []} + | Uses all the optimized data points from the 'path/gaussian_log_file.log' file. + + | Example 2: {'path_to_gaussian_style_final_files': [0, 23]} + | Uses all data points from the 'path/gaussian_log_file.log' file, except points + | 0 and 23. + + | NOTE: Python counting starts at 0. + + manual_dihedral_atom_numbers_list: list of 4 int, default=None + .. note:: + Only needed for qm_engine="gaussian_style_final_files" This is a list of the dihedral atom numbers in order that were used for the dihedral fit. This information needs to be correct and in order to produce correct results. The values must be the same in all the combined files. - qm_engine: str, default='gaussian' (options = 'gaussian') + qm_engine: str, default='gaussian' (options = 'gaussian' or 'gaussian_style_final_files') The QM simulation engine that was utilized also tells the log file readers what QM log file read to use for the analysis. Notes ------- files are written to the created 'extracted_gaussian_data' folder: - - 'dihedral.txt' file is in the standard Gaussian/Gausview format and + + 'dihedral.txt' file is in the standard Gaussian/Gausview format and contains the optimized scanned/rotated dihedral angle and energy in Hartree energy units. - - 'dihedral_coords_position_n.txt' file is in the standard Gaussian/Gausview + + 'dihedral_coords_position_n.txt' file is in the standard Gaussian/Gausview format. There are n coordinate files written (n starts at 1), one for each optimized dihedral angle/energy, wwhose output is numbered in the same order as the 'dihedral.txt' file data. The coordinate file distances are in Angstrom units. + """ # delete any existing directories and make a new one gaussian_directory_name = "extracted_gaussian_data" @@ -1379,7 +1384,8 @@ def get_matching_dihedral_info_and_opls_fitting_data( If they are not accounted for, then all dihedrals will add the forces to the single dihedral fit, which will overfit the energy of a single dihedral. - NOTE: In the PSF file and Gaussian, all atom numbers start at one (1). + .. note:: + In the PSF file and Gaussian, all atom numbers start at one (1). Parameters @@ -1389,10 +1395,10 @@ def get_matching_dihedral_info_and_opls_fitting_data( like a proper dihedral is written. The code will also check the reverse order of the dihedral. - Example 1: Ethane dihedral = ['HC', 'CT', 'CT', 'CH'] + | Example 1: Ethane dihedral = ['HC', 'CT', 'CT', 'CH'] - Example 2: Ethane dihedral with wildcards = ['X', 'CT', 'CT', 'X'] - or ['*', CT, 'CT', '*'] or ['', CT, 'CT', ''] + | Example 2: Ethane dihedral with wildcards = ['X', 'CT', 'CT', 'X'] + | or ['*', CT, 'CT', '*'] or ['', CT, 'CT', ''] psf_path_and_filename: str The path and filename of the PSF file, which shall be used to extract and map the @@ -1403,48 +1409,54 @@ def get_matching_dihedral_info_and_opls_fitting_data( This is required to know the MM bonding in the atoms, because QM simulations do not explictly specify the system bonds. qm_log_file_dict: dict, {str: [int, ..., int]} - * qm_engine="gaussian" - This is a dictionary comprised of a key (string) of the QM log file path and name, - and a list of integers, which are the QM optimization parameters to remove from - the written data, in order of reading from each file. These can be seen in the - order of the dictionary file name (strings). These removed parameters allow - users to remove any bad or repeated data points for the QM log file when needed. - - Example 1: {'path/gaussian_log_file.log': []} - - Uses all the optimized data points from the 'path/gaussian_log_file.log' file. - - Example 2: {'path/gaussian_log_file.log': [0, 23]} - Uses all data points from the 'path/gaussian_log_file.log' file, except points - 0 and 23. NOTE: Python counting starts at 0. - - * qm_engine="gaussian_style_final_files" - This is a dictionary comprised of a key (string) of the file paths to the - Gaussian style final formatted files, and a list of integers, which are the - QM optimization parameters to remove from the written data, in order of reading - from each folder. These can be seen in the order of the dictionary file name (strings). - These removed parameters allow users to remove any bad or repeated data points - for the QM log file when needed. - NOTE: The energy and dihedral angle file in this directory need to be - named 'dihedral.txt' for the energy and dihedral angle values (one 1 per directory). - - Example of energy and dihedral angle file ('dihedral.txt'): - - | # Scan of Total Energy - | # X-Axis: Scan Coordinate - | # Y-Axis: Total Energy (Hartree) - | # X Y - | 0.0 -267.0062955742 - | 10.0 -267.0062900424 - - NOTE: The coordinate files in this directory need to be - named 'dihedral_coords_position_XXXX.txt' for the each angles coordinate values. - There are as XXX file in this directory where XXX is the number of dihedral angles. - The file numbering starts at 1 so the files are named 'dihedral_coords_position_1.txt' - to 'dihedral_coords_position_XXXX.txt' + qm_engine="gaussian" + + | This is a dictionary comprised of a key (string) of the QM log file path and name, + | and a list of integers, which are the QM optimization parameters to remove from + | the written data, in order of reading from each file. These can be seen in the + | order of the dictionary file name (strings). These removed parameters allow + | users to remove any bad or repeated data points for the QM log file when needed. + + | Example 1: {'path/gaussian_log_file.log': []} + | Uses all the optimized data points from the 'path/gaussian_log_file.log' file. + + | Example 2: {'path/gaussian_log_file.log': [0, 23]} + | Uses all data points from the 'path/gaussian_log_file.log' file, except points + | 0 and 23. + + | NOTE: Python counting starts at 0. + + + qm_engine="gaussian_style_final_files" + + | This is a dictionary comprised of a key (string) of the file paths to the + | Gaussian style final formatted files, and a list of integers, which are the + | QM optimization parameters to remove from the written data, in order of reading + | from each folder. These can be seen in the order of the dictionary file name (strings). + | These removed parameters allow users to remove any bad or repeated data points + | for the QM log file when needed. + + | NOTE: The energy and dihedral angle file in this directory need to be + | named 'dihedral.txt' for the energy and dihedral angle values (one 1 per directory). + + | Example of energy and dihedral angle file ('dihedral.txt'): + + | # Scan of Total Energy + | # X-Axis: Scan Coordinate + | # Y-Axis: Total Energy (Hartree) + | # X Y + | 0.0 -267.0062955742 + | 10.0 -267.0062900424 + + | NOTE: The coordinate files in this directory need to be + | named 'dihedral_coords_position_XXXX.txt' for the each angles coordinate values. + | There are as XXX file in this directory where XXX is the number of dihedral angles. + | The file numbering starts at 1 so the files are named 'dihedral_coords_position_1.txt' + | to 'dihedral_coords_position_XXXX.txt' manual_dihedral_atom_numbers_list: list of 4 integers, default=None - NOTE: Only needed for qm_engine="gaussian_style_final_files" + .. note:: + Only needed for qm_engine="gaussian_style_final_files" This is a list of the dihedral atom numbers in order that were used for the dihedral fit. This information needs to be correct and in order to produce correct results. @@ -1452,14 +1464,14 @@ def get_matching_dihedral_info_and_opls_fitting_data( Returns ------- - matching_dihedral_types_by_atom_numbers_list: nested list + matching_dihedral_types_by_atom_numbers_list: nested list of 4 int A list of the four atom numbers (integers) that match the selected 'fit_dihedral_atom_types', extracted from the PSF file, including the dihedral being fit. The list length is the number of dihedrals which match the QM scanned atom/bead types, with the nested list has four (4) integers - matching_dihedral_types_by_atom_type_list: nested list + matching_dihedral_types_by_atom_type_list: nested list A list of the four atom numbers that match the selected 'fit_dihedral_atom_types', extracted from the PSF file, including the dihedral being fit. @@ -1477,18 +1489,18 @@ def get_matching_dihedral_info_and_opls_fitting_data( The last (3rd) nested list is the x, y, and z coordinates [x, y, z], with a list length of three (3) - Example: - [ - [ - [qm_scan_1_dih_1_coor_x, qm_scan_1_dih_1_coor_y, qm_scan_1_dih_1_coor_z], - [qm_scan_1_dih_2_coor_x, qm_scan_1_dih_2_coor_y, qm_scan_2_dih_1_coor_z], - ] - ... - [ - [qm_scan_n_dih_1_coor_x, qm_scan_n_dih_1_coor_y, qm_scan_n_dih_1_coor_z], - [qm_scan_n_dih_2_coor_x, qm_scan_n_dih_2_coor_y, qm_scan_n_dih_1_coor_z], - ] - ] + | Example: + | [ + | [ + | [qm_scan_1_dih_1_coor_x, qm_scan_1_dih_1_coor_y, qm_scan_1_dih_1_coor_z], + | [qm_scan_1_dih_2_coor_x, qm_scan_1_dih_2_coor_y, qm_scan_2_dih_1_coor_z], + | ] + | ... + | [ + | [qm_scan_n_dih_1_coor_x, qm_scan_n_dih_1_coor_y, qm_scan_n_dih_1_coor_z], + | [qm_scan_n_dih_2_coor_x, qm_scan_n_dih_2_coor_y, qm_scan_n_dih_1_coor_z], + | ] + | ] all_matching_dihedral_phi_degrees_added_to_k_values_list: nested list The angles/phis, in degrees, from all dihedrals, which match the fitted dihedral, @@ -1512,27 +1524,26 @@ def get_matching_dihedral_info_and_opls_fitting_data( const_1_plus_Cos_3_phi, const_1_minus_Cos_4_phi ] + + | Example 0: + | const_1_minus_Cos_0_phi = 0 , since k0 is not used in this form - Example 0: - const_1_minus_Cos_0_phi = 0 , since k0 is not used in this form - - Example 1: - const_1_plus_Cos_1_phi = sum of all phis in the list [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) + | Example 1: + | const_1_plus_Cos_1_phi = sum of all phis in the list [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) - Example 2: - const_1_minus_Cos_2_phi = sum of all phis in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) + | Example 2: + | const_1_minus_Cos_2_phi = sum of all phis in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) - Example 3: - const_1_plus_Cos_3_phi = sum of all phis in the list [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) + | Example 3: + | const_1_plus_Cos_3_phi = sum of all phis in the list [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) - Example 4: - const_1_minus_Cos_4_phi = sum of all phis in the list [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) + | Example 4: + | const_1_minus_Cos_4_phi = sum of all phis in the list [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) The list length is the number of dihedrals which match the QM scanned atom/bead types, with the next nested list being the 'all_sum_opls_const_1_plus_or_minus_cos_n_list' as described. """ - if isinstance(fit_dihedral_atom_types, list): if len(fit_dihedral_atom_types) != 4: raise TypeError( @@ -1885,7 +1896,7 @@ def change_gomc_ff_file_dihedral_values( The nests list(s) of the other dihedrals, that need to have their k-values zeroed to properly fit the the 'fit_dihedral_atom_types' dihedral. - Example: [['CT', 'CT, 'CT, 'HC'], ['NT', 'CT, 'CT, 'HC']] + | Example: [['CT', 'CT, 'CT, 'HC'], ['NT', 'CT, 'CT, 'HC']] Notes ------- @@ -1896,7 +1907,6 @@ def change_gomc_ff_file_dihedral_values( dihedrals that need to be zeroed out ('zero_dihedral_atom_types') for the 'fit_dihedral_atom_types' dihedral to be fit. """ - # check if the fitted dihedral is input correctly if ( not isinstance(fit_dihedral_atom_types, list) diff --git a/mosdef_dihedral_fit/utils/math_operations.py b/mosdef_dihedral_fit/utils/math_operations.py index 8956f81..53c0e29 100755 --- a/mosdef_dihedral_fit/utils/math_operations.py +++ b/mosdef_dihedral_fit/utils/math_operations.py @@ -1,5 +1,4 @@ import math - import numpy as np @@ -39,7 +38,6 @@ def round_to_sig_figs(value, sig_figs=3): # (START) # ************************************************************** - def normalize_vector(vector): """Generates the normalized vector from a given vector. @@ -123,7 +121,7 @@ def dihedral_angle( atom_xyz_coord_1, atom_xyz_coord_2, atom_xyz_coord_3, - atom_xyz_coord_4, + atom_xyz_coord_4 ): """Gets the dihedral angle between the four (4) atom coordinates given in cartesian coordinates. @@ -149,6 +147,47 @@ def dihedral_angle( dihedral_angle_degrees: float (in degrees) The dihedral angle, in degrees, between the four (4) atoms. """ + # check if any atom coordinates are 3 ints or floats in lists + if ( + ( + not isinstance(atom_xyz_coord_1, list) + or not isinstance(atom_xyz_coord_2, list) + or not isinstance(atom_xyz_coord_3, list) + or not isinstance(atom_xyz_coord_4, list) + ) + or + ( + len(atom_xyz_coord_1) != 3 + or len(atom_xyz_coord_2) != 3 + or len(atom_xyz_coord_3) != 3 + or len(atom_xyz_coord_4) != 3 + ) + or + ( + not isinstance(atom_xyz_coord_1[0], (int, float)) + or not isinstance(atom_xyz_coord_1[1], (int, float)) + or not isinstance(atom_xyz_coord_1[2], (int, float)) + or not isinstance(atom_xyz_coord_2[0], (int, float)) + or not isinstance(atom_xyz_coord_2[1], (int, float)) + or not isinstance(atom_xyz_coord_2[2], (int, float)) + or not isinstance(atom_xyz_coord_3[0], (int, float)) + or not isinstance(atom_xyz_coord_3[1], (int, float)) + or not isinstance(atom_xyz_coord_3[2], (int, float)) + or not isinstance(atom_xyz_coord_4[0], (int, float)) + or not isinstance(atom_xyz_coord_4[1], (int, float)) + or not isinstance(atom_xyz_coord_4[2], (int, float)) + ) + ): + raise ValueError( + f"ERROR: The one or more of the atom coordinates are not in the form of a " + f"list with three (3) ints or floats. \n" + f"Example: [1.2, 3.4, 5.6] \n " + f"atom_xyz_coord_1 = {atom_xyz_coord_1} and type = {type(atom_xyz_coord_1)}; \n" + f"atom_xyz_coord_2 = {atom_xyz_coord_2} and type = {type(atom_xyz_coord_2)}; \n" + f"atom_xyz_coord_3 = {atom_xyz_coord_3} and type = {type(atom_xyz_coord_3)}; \n" + f"atom_xyz_coord_4 = {atom_xyz_coord_4} and type = {type(atom_xyz_coord_4)}. " + ) + # check if any atom coordinates are the same if ( list(atom_xyz_coord_1) == list(atom_xyz_coord_2) @@ -220,7 +259,6 @@ def dihedral_angle( # (End) # ************************************************************** - def check_previous_qm_values_match( all_value_list, current_value, value_name, qm_engine, log_file_name ): @@ -274,43 +312,47 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): dihedrals of the same atom types/classes exist in the molecule that the dihedral is fit too. - Example 0: - const_1_minus_Cos_0_phi = 1 , since k0 is a constant + | Example 0: + | const_1_minus_Cos_0_phi = 1 , since k0 is a constant - Example 1: - const_1_plus_Cos_1_phi = sum of the list using all phis [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) + | Example 1: + | const_1_plus_Cos_1_phi = sum of the list using all phis [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) - Example 2: - const_1_minus_Cos_2_phi = sum of the list using all phis [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) + | Example 2: + | const_1_minus_Cos_2_phi = sum of the list using all phis [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) - Example 3: - const_1_plus_Cos_3_phi = sum of the list using all phis [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) + | Example 3: + | const_1_plus_Cos_3_phi = sum of the list using all phis [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) - Example 4: - const_1_minus_Cos_4_phi = sum of the list using all phis [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) + | Example 4: + | const_1_minus_Cos_4_phi = sum of the list using all phis [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) - NOTE: These values are used to simplify the diheral fitting process, - allowing the user to deal with four (4) OPLS constants (see below). + .. note:: + These values are used to simplify the diheral fitting process, + allowing the user to deal with four (4) OPLS constants (see below). Standard OPLS dihedral form + .. math:: - opls_dihedral &= 1/2 *( - &= k0 - &= + k1 * (1 + cos(1 * phi)) - &= + k2 * (1 - cos(2 * phi)) - &= + k3 * (1 + cos(3 * phi)) - &= + k4 * (1 - cos(4 * phi)) - &= ) + U_{opls-dihedral} = 1/2 * ( + k0 + k1 * [1 + cos[1 * phi] + + k2 * [1 - cos[2 * phi] + + + k3 * [1 + cos[3 * phi] + + k4 * [1 - cos[4 * phi] + ) Modified OPLS dihedral form for all dihedrals with the same atom types/classes exist in the molecule. - opls_dihedral_n_1 &= 1/2 *( - &= k0 - &= + k1 * const_1_plus_Cos_1_phi - &= + k2 * const_1_minus_Cos_2_phi - &= + k3 * const_1_plus_Cos_3_phi - &= + k4 * const_1_minus_Cos_4_phi - &= ) + + .. math:: + U_{opls-dihedral-mod} = 1/2 * ( + k0 + k1 * [const1plusCos1phi] + + k2 * [const1minusCos2phi] + + + k3 * [const1plusCos3phi] + + k4 * [const1minusCos4phi] + ) Parameters ---------- @@ -320,16 +362,16 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): Returns ------- List of: - const_1_minus_Cos_0_phi: float (unitless) - This values is always zero, since k0 is not used this standard OPLS form. - const_1_plus_Cos_1_phi: float (unitless) - The sum of all phi values in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) - const_1_minus_Cos_2_phi: float (unitless) - The sum of all phi values in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) - const_1_plus_Cos_3_phi: float (unitless) - The sum of all phi values in the list [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) - const_1_minus_Cos_4_phi: float (unitless) - The sum of all phi values in the list [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) + | const_1_minus_Cos_0_phi: float (unitless) + | This values is always zero, since k0 is not used this standard OPLS form. + | const_1_plus_Cos_1_phi: float (unitless) + | The sum of all phi values in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) + | const_1_minus_Cos_2_phi: float (unitless) + | The sum of all phi values in the list [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) + | const_1_plus_Cos_3_phi: float (unitless) + | The sum of all phi values in the list [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) + | const_1_minus_Cos_4_phi: float (unitless) + | The sum of all phi values in the list [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) """ const_1_minus_Cos_0_phi = 1 const_1_plus_Cos_1_phi = 0 @@ -355,8 +397,6 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): # opls dihedral function using for all combinations - - def opls_dihedral(cos_powers_phi_and_constants_data, k0, k1, k2, k3, k4): """OPLS dihedral energy calculation with only the selected k-values. @@ -369,92 +409,95 @@ def opls_dihedral(cos_powers_phi_and_constants_data, k0, k1, k2, k3, k4): and the output ' dihedral_energy' energy are output in the same energy units. - NOTE: THIS WILL FIT THE FORM IT IS FED, REGARDLESS IF IT IS THE CORRECT - ANALYTICAL SOLUTION. MEANING SOMETIMES YOU CAN NOT USE A K-VALUE BECAUSE - OF MOLECULE SYMMETREY. THEREFORE, THIS IS MUST BE ACCOUNTED FOR OUTSIDE - OF THIS FUNCTION. + .. note:: + THIS WILL FIT THE FORM IT IS FED, REGARDLESS IF IT IS THE CORRECT + ANALYTICAL SOLUTION. MEANING SOMETIMES YOU CAN NOT USE A K-VALUE BECAUSE + OF MOLECULE SYMMETREY. THEREFORE, THIS IS MUST BE ACCOUNTED FOR OUTSIDE + OF THIS FUNCTION. - NOTE: ALL THE K-VALUE ENERGY UNITS MUST BE THE SAME. + .. note:: + ALL THE K-VALUE ENERGY UNITS MUST BE THE SAME. .. math:: - opls_dihedral_n_1 &= 1/2 *( - &= k0 - &= + k1 * (1 + cos(1 * phi)) - &= + k2 * (1 - cos(2 * phi)) - &= + k3 * (1 + cos(3 * phi)) - &= + k4 * (1 - cos(4 * phi)) - &= ) + U_{opls-dihedral} = 1/2 * ( + k0 + k1 * (1 + cos[1 * phi]) + + k2 * (1 - cos[2 * phi]) + + .. math:: + + k3 * (1 + cos[3 * phi]) + + k4 * (1 - cos[4 * phi]) + ) Parameters ---------- cos_powers_phi_and_constants_data: list or tuple of (cos_powers, scanned_phi, all_sum_opls_const_1_plus_or_minus_cos_n_list) - cos_powers: str, int, or float, - The str options are: '1', '1_3', '2', '2_4', '1_2', '1_2_3', and '1_2_3_4' - The int options are: '1', '13', '2', '24', '12', '123', and '1234' - The float options are: '1.', '13.', '2.', '24.', '12.', '123.', and '1234.' - The type type of powers in the cosine series to use. + | cos_powers: str, int, or float, + | The str options are: '1', '1_3', '2', '2_4', '1_2', '1_2_3', and '1_2_3_4' + | The int options are: '1', '13', '2', '24', '12', '123', and '1234' + | The float options are: '1.', '13.', '2.', '24.', '12.', '123.', and '1234.' + | The type type of powers in the cosine series to use. - Example 1: '1' only set the k1 to a non-zero value - Example 2: '1_2_3' only set the k1, k2, and k3 to a non-zero value + | Example 1: '1' only set the k1 to a non-zero value + | Example 2: '1_2_3' only set the k1, k2, and k3 to a non-zero value - Example 3: '1' only set the k1 to a non-zero value - Example 4: '123' only set the k1, k2, and k3 to a non-zero value + | Example 3: '1' only set the k1 to a non-zero value + | Example 4: '123' only set the k1, k2, and k3 to a non-zero value - Example 5: '1' only set the k1 to a non-zero value - Example 6: '123.' only set the k1, k2, and k3 to a non-zero value + | Example 5: '1' only set the k1 to a non-zero value + | Example 6: '123.' only set the k1, k2, and k3 to a non-zero value - scanned_phi: floats, int, nest list or tuple of floats/int - The 'phi_data' angle of the dihedral is in degrees + | scanned_phi: floats, int, nest list or tuple of floats/int + | The 'phi_data' angle of the dihedral is in degrees - The floats, int options: the phi_data from a single point + | The floats, int options: the phi_data from a single point - The nest list of floats/int: This nested list include the dihedral angle - being rotated in QM, and all the other identical dihedral angles from - the same atom typed/classed atoms in the test molecule/fragment. + | The nest list of floats/int: This nested list include the dihedral angle + | being rotated in QM, and all the other identical dihedral angles from + | the same atom typed/classed atoms in the test molecule/fragment. - all_sum_opls_const_1_plus_or_minus_cos_n_list: list or tuple, default=None + | all_sum_opls_const_1_plus_or_minus_cos_n_list: list or tuple, default=None - all_sum_opls_const_1_plus_or_minus_cos_n_list = [ - const_1_minus_Cos_0_phi, - const_1_plus_Cos_1_phi, - const_1_minus_Cos_2_phi, - const_1_plus_Cos_3_phi, - const_1_minus_Cos_4_phi - ] + | all_sum_opls_const_1_plus_or_minus_cos_n_list = [ + | const_1_minus_Cos_0_phi, + | const_1_plus_Cos_1_phi, + | const_1_minus_Cos_2_phi, + | const_1_plus_Cos_3_phi, + | const_1_minus_Cos_4_phi + | ] - A list of the OPLS k0 data, which is always 0 or 1 in this case. - If all 0 values --> (0, 0, .., 0), then k0=0. - If all 1 values --> (1, 1, .., 1), then k0=constant + | A list of the OPLS k0 data, which is always 0 or 1 in this case. + | If all 0 values --> (0, 0, .., 0), then k0=0. + | If all 1 values --> (1, 1, .., 1), then k0=constant - # It is critical that 'const_1_minus_Cos_0_phi' be all (0, 0, .., 0) for k0=0 - # and all (1, 1, .., 1) 'const_1_minus_Cos_0_phi' for k0=constant + | # It is critical that 'const_1_minus_Cos_0_phi' be all (0, 0, .., 0) for k0=0 + | # and all (1, 1, .., 1) 'const_1_minus_Cos_0_phi' for k0=constant - const_1_plus_Cos_1_phi: values for all k-values, which - is required to fit the data, especially when multiple dihedrals of the same - atom types/classes exist in the molecule that the dihedral is fit too. + | const_1_plus_Cos_1_phi: values for all k-values, which + | is required to fit the data, especially when multiple dihedrals of the same + | atom types/classes exist in the molecule that the dihedral is fit too. - Example 0: - const_1_minus_Cos_0_phi = k0 + | Example 0: + | const_1_minus_Cos_0_phi = k0 - Example 1: - const_1_plus_Cos_1_phi = sum of all phi values in the list - [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) + | Example 1: + | const_1_plus_Cos_1_phi = sum of all phi values in the list + | [(1 + cos(1 * phi))] in k1 * (1 + cos(1 * phi)) - Example 2: - const_1_minus_Cos_2_phi = sum of all phi values in the list - [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) + | Example 2: + | const_1_minus_Cos_2_phi = sum of all phi values in the list + | [(1 - cos(2 * phi))] in k2 * (1 - cos(2 * phi)) - Example 3: - const_1_plus_Cos_3_phi = sum of all phi values in the list - [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) + | Example 3: + | const_1_plus_Cos_3_phi = sum of all phi values in the list + | [(1 + cos(3 * phi))] in k3 * (1 + cos(3 * phi)) - Example 4: - const_1_minus_Cos_4_phi = sum of all phi values in the list - [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) + | Example 4: + | const_1_minus_Cos_4_phi = sum of all phi values in the list + | [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) - The list length is the number of dihedrals which match the QM scanned atom/bead types, - with the next nested list being the 'all_sum_opls_const_1_plus_or_minus_cos_n_list' - as described. + | The list length is the number of dihedrals which match the QM scanned atom/bead types, + | with the next nested list being the 'all_sum_opls_const_1_plus_or_minus_cos_n_list' + | as described. k0: int, or float, in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...) The 'k0' value is the k-value for the opls dihedral where n=0, @@ -483,7 +526,7 @@ def opls_dihedral(cos_powers_phi_and_constants_data, k0, k1, k2, k3, k4): Returns ------- - dihedral_energy; float or list of floats, same as the k-value energy units + dihedral_energy: float or list of floats, same as the k-value energy units The OPLS dihedral energy from the valid phi_data and k-values (i.e., k1 in this case). """ @@ -906,18 +949,24 @@ def periodic_dihedral_n_1_2_3_4_5( the cosine power representation, where n_x and d_x match the K_x x-values. The 'd_x' values is the d-value cosine phase angle or phase shift. - NOTE: ALL THE K_x-VALUE ENERGY UNITS MUST BE THE SAME. + .. note:: + ALL THE K_x-VALUE ENERGY UNITS MUST BE THE SAME. - NOTE: All the K_x, n_x, and d_x x-values are a pair (i.e., K_1, n_1, and d_1) + + .. note:: + All the K_x, n_x, and d_x x-values are a pair (i.e., K_1, n_1, and d_1) + .. math:: - periodic_dihedral &= K_0 * (1 + cos(n_0*t - d_0)) + \\ - &= K_1 * (1 + cos(n_1*t - d_1)) + \\ - &= K_2 * (1 + cos(n_2*t - d_2)) + \\ - &= K_3 * (1 + cos(n_3*t - d_3)) + \\ - &= K_4 * (1 + cos(n_4*t - d_4)) + \\ - &= K_5 * (1 + cos(n_5*t - d_5)) + U_{periodic-dihedral} = K_0 * (1 + cos[n_0*t - d_0]) + + K_1 * (1 + cos[n_1*t - d_1]) + K_2 * (1 + cos[n_2*t - d_2]) + + + K_3 * (1 + cos[n_3*t - d_3]) + K_4 * (1 + cos[n_4*t - d_4]) + + + K_5 * (1 + cos[n_5*t - d_5]) + + Parameters ---------- phi_data: float, int, or list of floats/int, in degrees @@ -957,19 +1006,28 @@ def RB_torsion_n_1_2_3_4_5(phi_data, k_0, k_1, k_2, k_3, k_4, k_5): """Ryckaert-Bellemans (RB) torsion energy calculation from n=1 to n=5. This is the Ryckaert-Bellemans (RB) torsion style energy calculation. - The K_x-values are in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...), - and the output ' dihedral_energy' energy are output in the same energy units. - NOTE: ALL THE k_x-VALUE ENERGY UNITS MUST BE THE SAME. + This is the Ryckaert-Bellemans (RB) torsion style energy calculation. + + The K_x-values are in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...), + + and the output 'dihedral_energy' energy are output in the same energy units. + .. note:: + ALL THE k_x-VALUE ENERGY UNITS MUST BE THE SAME. + .. math:: - RB_torsions &= k_0 + k_1*cos(psi) + k_2*cos(psi)^2 + k_3*cos(psi)^3 + \\ - &= k_4*cos(psi)^4 + k_5*cos(psi)^5 - + U_{RB-torsions} = k_0 + k_1*cos(psi) + + + k_2*cos(psi)^2 + k_3*cos(psi)^3 + + + k_4*cos(psi)^4 + k_5*cos(psi)^5 + Parameters ---------- phi_data: float, int, or list of floats/int, in degrees The 'phi_data' angle of the dihedral is in degrees + k_0, k_1, k_2, k_3, k_4, and k_5: int or float, in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...) The 'k_x' values is the k-value constant scalar for the Ryckaert-Bellemans (RB) torsion style. @@ -1009,13 +1067,14 @@ def opls_dihedral_n_1_2_3_4(phi_data, k_0, k_1, k_2, k_3, k_4): NOTE: ALL THE K-VALUE ENERGY UNITS MUST BE THE SAME. .. math:: - opls_dihedral_n_1 &= 1/2 *( - &= k0 - &= + k1 * (1 + cos(1 * phi)) - &= + k2 * (1 - cos(2 * phi)) - &= + k3 * (1 + cos(3 * phi)) - &= + k4 * (1 - cos(4 * phi)) - &= ) + U_{opls-dihedral} = 1/2 * ( + k0 + k1 * (1 + cos[1 * phi]) + + k2 * (1 - cos[2 * phi]) + + .. math:: + + k3 * (1 + cos[3 * phi]) + + k4 * (1 - cos[4 * phi]) + ) Parameters ---------- @@ -1032,18 +1091,24 @@ def opls_dihedral_n_1_2_3_4(phi_data, k_0, k_1, k_2, k_3, k_4): k_2: int, or float, in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...) The 'k2' value is the k-value for the opls dihedral where n=2 in the cosine multiple. - NOTE: In this case, it is set to zero (0) regardless of the - user entered value, because it is not in the equation form. + + .. note:: + In this case, it is set to zero (0) regardless of the + user entered value, because it is not in the equation form. k_3: int, or float, in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...) The 'k3' value is the k-value for the opls dihedral where n=3 in the cosine multiple. - NOTE: In this case, it is set to zero (0) regardless of the - user entered value, because it is not in the equation form. + + .. note:: + In this case, it is set to zero (0) regardless of the + user entered value, because it is not in the equation form. k_4: int, or float, in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...) The 'k4' value is the k-value for the opls dihedral where n=4 in the cosine multiple. - NOTE: In this case, it is set to zero (0) regardless of the - user entered value, because it is not in the equation form. + + .. note:: + In this case, it is set to zero (0) regardless of the + user entered value, because it is not in the equation form. Returns ------- From bd0ca770757826713af9584f3a7f210666b9feec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 01:16:28 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/topic_guides/data_structures.rst | 1 - ...GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp | 2 +- .../tests/test_file_read_write.py | 11 +-- .../tests/test_math_operation.py | 91 +++++++++---------- .../utils/file_read_and_write.py | 28 +++--- mosdef_dihedral_fit/utils/math_operations.py | 64 +++++++------ 6 files changed, 96 insertions(+), 101 deletions(-) diff --git a/docs/topic_guides/data_structures.rst b/docs/topic_guides/data_structures.rst index f2f36ef..c67bc0d 100644 --- a/docs/topic_guides/data_structures.rst +++ b/docs/topic_guides/data_structures.rst @@ -19,4 +19,3 @@ Fit a Dihedral :members: fit_dihedral_with_gomc - diff --git a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp index 050b317..e791c11 100644 --- a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp +++ b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp @@ -57,7 +57,7 @@ DIHEDRALS * CHARMM ! Boltzmann = 0.0019872041 kcal / (mol * K) ! ! type_1 type_2 type_3 type_4 Kchi n delta ! extended_type_1 extended_type_2 extended_type_3 extended_type_4 -HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 +HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 ! The input dihedral to periodic dihedral conversion error is OK [error <= 10^(-10)] ! Maximum( |(input dihedral calc)-(periodic dihedral calc)| ) = 3.608224830031759e-16 diff --git a/mosdef_dihedral_fit/tests/test_file_read_write.py b/mosdef_dihedral_fit/tests/test_file_read_write.py index 3dccd36..7687b38 100644 --- a/mosdef_dihedral_fit/tests/test_file_read_write.py +++ b/mosdef_dihedral_fit/tests/test_file_read_write.py @@ -276,7 +276,7 @@ def test_write_qm_data_files(self): out_indices = [] write_qm_data_files({full_path: out_indices}) assert os.path.exists("extracted_gaussian_data/dihedral.txt") - + def test_get_matching_dihedral_info_and_opls_fitting_data(self): out = get_matching_dihedral_info_and_opls_fitting_data( fit_dihedral_atom_types=["HC", "CT", "CT", "HC"], @@ -304,7 +304,7 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): [4, 1, 2, 8], [5, 1, 2, 6], [5, 1, 2, 7], - [5, 1, 2, 8] + [5, 1, 2, 8], ] assert dihedral_numsList == expected_dihedralnumsList @@ -327,7 +327,7 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): [-1.012159, 1.156346, 0.0], [0.0, 0.76376, 0.0], [-0.0, -0.76376, 0.0], - [1.012159, -1.156346, 0.0] + [1.012159, -1.156346, 0.0], ] assert np.allclose(coordsList[0][0], expected_coords) assert np.shape(coordsList) == (37, 9, 4, 3) @@ -351,10 +351,10 @@ def test_get_matching_dihedral_info_and_opls_fitting_data(self): 8.999999999999845, 8.99999999999938, 2.780442542871242e-12, - 8.99999999999753 + 8.99999999999753, ] assert np.allclose(opls_paramsList[0], expected_opls_params) - + def test_change_gomc_ff_file_dihedral_values(self): new_file = self.get_fn( "gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp" @@ -379,4 +379,3 @@ def test_change_gomc_ff_file_dihedral_values(self): break assert checkFile - diff --git a/mosdef_dihedral_fit/tests/test_math_operation.py b/mosdef_dihedral_fit/tests/test_math_operation.py index 735b091..4130f87 100644 --- a/mosdef_dihedral_fit/tests/test_math_operation.py +++ b/mosdef_dihedral_fit/tests/test_math_operation.py @@ -459,10 +459,10 @@ def test_dihedral_angle_error_coord_1_not_list(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ - '[1, 2, 3]', + "[1, 2, 3]", [4, 5, 6], [7, 8, 9], [10, 11, 12], @@ -473,7 +473,7 @@ def test_dihedral_angle_error_coord_1_not_list(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_2_not_list(self): # Test case 1 with pytest.raises( @@ -484,11 +484,11 @@ def test_dihedral_angle_error_coord_2_not_list(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], - '[4, 5, 6]', + "[4, 5, 6]", [7, 8, 9], [10, 11, 12], ] @@ -509,12 +509,12 @@ def test_dihedral_angle_error_coord_3_not_list(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], - '[7, 8, 9]', + "[7, 8, 9]", [10, 11, 12], ] test_return_value = mdf_math.dihedral_angle( @@ -534,13 +534,13 @@ def test_dihedral_angle_error_coord_4_not_list(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], - '[10, 11, 12]', + "[10, 11, 12]", ] test_return_value = mdf_math.dihedral_angle( test_vectors_input_value[0], @@ -548,7 +548,7 @@ def test_dihedral_angle_error_coord_4_not_list(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_1_entry_1_not_int_float(self): # Test case 1 with pytest.raises( @@ -559,10 +559,10 @@ def test_dihedral_angle_error_coord_1_entry_1_not_int_float(self): f"atom_xyz_coord_1 = \['1', 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ - ['1', 2, 3], + ["1", 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], @@ -573,7 +573,7 @@ def test_dihedral_angle_error_coord_1_entry_1_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_1_entry_2_not_int_float(self): # Test case 1 with pytest.raises( @@ -584,10 +584,10 @@ def test_dihedral_angle_error_coord_1_entry_2_not_int_float(self): f"atom_xyz_coord_1 = \[1, '2', 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ - [1, '2', 3], + [1, "2", 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], @@ -598,7 +598,7 @@ def test_dihedral_angle_error_coord_1_entry_2_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_1_entry_3_not_int_float(self): # Test case 1 with pytest.raises( @@ -609,10 +609,10 @@ def test_dihedral_angle_error_coord_1_entry_3_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, '3'\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ - [1, 2, '3'], + [1, 2, "3"], [4, 5, 6], [7, 8, 9], [10, 11, 12], @@ -623,7 +623,7 @@ def test_dihedral_angle_error_coord_1_entry_3_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_2_entry_1_not_int_float(self): # Test case 1 with pytest.raises( @@ -634,11 +634,11 @@ def test_dihedral_angle_error_coord_2_entry_1_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \['4', 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], - ['4', 5, 6], + ["4", 5, 6], [7, 8, 9], [10, 11, 12], ] @@ -648,7 +648,7 @@ def test_dihedral_angle_error_coord_2_entry_1_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_2_entry_2_not_int_float(self): # Test case 1 with pytest.raises( @@ -659,11 +659,11 @@ def test_dihedral_angle_error_coord_2_entry_2_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, '5', 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], - [4, '5', 6], + [4, "5", 6], [7, 8, 9], [10, 11, 12], ] @@ -673,7 +673,7 @@ def test_dihedral_angle_error_coord_2_entry_2_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_2_entry_3_not_int_float(self): # Test case 1 with pytest.raises( @@ -684,11 +684,11 @@ def test_dihedral_angle_error_coord_2_entry_3_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, '6'\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], - [4, 5, '6'], + [4, 5, "6"], [7, 8, 9], [10, 11, 12], ] @@ -709,12 +709,12 @@ def test_dihedral_angle_error_coord_3_entry_1_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \['7', 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], - ['7', 8, 9], + ["7", 8, 9], [10, 11, 12], ] test_return_value = mdf_math.dihedral_angle( @@ -723,7 +723,7 @@ def test_dihedral_angle_error_coord_3_entry_1_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_3_entry_2_not_int_float(self): # Test case 1 with pytest.raises( @@ -734,12 +734,12 @@ def test_dihedral_angle_error_coord_3_entry_2_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, '8', 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], - [7, '8', 9], + [7, "8", 9], [10, 11, 12], ] test_return_value = mdf_math.dihedral_angle( @@ -748,7 +748,7 @@ def test_dihedral_angle_error_coord_3_entry_2_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_3_entry_3_not_int_float(self): # Test case 1 with pytest.raises( @@ -759,12 +759,12 @@ def test_dihedral_angle_error_coord_3_entry_3_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, '9'\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], - [7, 8, '9'], + [7, 8, "9"], [10, 11, 12], ] test_return_value = mdf_math.dihedral_angle( @@ -784,13 +784,13 @@ def test_dihedral_angle_error_coord_4_entry_1_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \['10', 11, 12\] and type = . " + f"atom_xyz_coord_4 = \['10', 11, 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], - ['10', 11, 12], + ["10", 11, 12], ] test_return_value = mdf_math.dihedral_angle( test_vectors_input_value[0], @@ -798,7 +798,7 @@ def test_dihedral_angle_error_coord_4_entry_1_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_4_entry_2_not_int_float(self): # Test case 1 with pytest.raises( @@ -809,13 +809,13 @@ def test_dihedral_angle_error_coord_4_entry_2_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, '11', 12\] and type = . " + f"atom_xyz_coord_4 = \[10, '11', 12\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], - [10, '11', 12], + [10, "11", 12], ] test_return_value = mdf_math.dihedral_angle( test_vectors_input_value[0], @@ -823,7 +823,7 @@ def test_dihedral_angle_error_coord_4_entry_2_not_int_float(self): test_vectors_input_value[2], test_vectors_input_value[3], ) - + def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): # Test case 1 with pytest.raises( @@ -834,13 +834,13 @@ def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): f"atom_xyz_coord_1 = \[1, 2, 3\] and type = ; \n" f"atom_xyz_coord_2 = \[4, 5, 6\] and type = ; \n" f"atom_xyz_coord_3 = \[7, 8, 9\] and type = ; \n" - f"atom_xyz_coord_4 = \[10, 11, '12'\] and type = . " + f"atom_xyz_coord_4 = \[10, 11, '12'\] and type = . ", ): test_vectors_input_value = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], - [10, 11, '12'], + [10, 11, "12"], ] test_return_value = mdf_math.dihedral_angle( test_vectors_input_value[0], @@ -849,7 +849,6 @@ def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): test_vectors_input_value[3], ) - # ******************************************** # test the dihedral_angle (END) # ******************************************** @@ -857,7 +856,7 @@ def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): # ******************************************** # test the mdf_math.check_previous_qm_values_match (START) # ******************************************** - ''' + """ def test_check_previous_qm_values_match(self): # Without error all_value_list = [[1], [2], [3]] @@ -878,4 +877,4 @@ def test_check_previous_qm_values_match(self): check_return = mdf_math.check_previous_qm_values_match( all_value_list, [4], "value_name", "qm_engine", "log_file" ) - ''' \ No newline at end of file + """ diff --git a/mosdef_dihedral_fit/utils/file_read_and_write.py b/mosdef_dihedral_fit/utils/file_read_and_write.py index ee7b7b1..6d602d5 100755 --- a/mosdef_dihedral_fit/utils/file_read_and_write.py +++ b/mosdef_dihedral_fit/utils/file_read_and_write.py @@ -162,7 +162,7 @@ def write_xyz_file_from_gaussian_coordinates( Outputs ------- - Writes the xyz file in the file in the selected 'xyz_files_directory' directory, + Writes the xyz file in the file in the selected 'xyz_files_directory' directory, with the file name 'dihedral_coords_position_n.xyz'. """ # check if file extension starts with a "." or not remove for correct insertion later @@ -232,7 +232,7 @@ def write_restart_coor_from_xyz_file(coor_files_directory, total_qm_scans): This function utilized VMD to write the restart coor files from the xyz file. - .. note:: + .. note:: NAMD or GOMC need to be restarted from the restart coor file to have more coordinate precision than the PDB file format provides. @@ -398,7 +398,7 @@ def check_gaussian_optimized_coordinate_file_correct( This checks the gaussian/Gausview containing the optimized coordinates is formatted correctly. | The proper header format for the GausView/Gaussian output is as follows: - + | Row Highlight Display Tag Symbol X Y Z Parameters @@ -1191,7 +1191,7 @@ def write_qm_data_files( | Uses all data points from the 'path/gaussian_log_file.log' file, except points | 0 and 23. NOTE: Python counting starts at 0. - + | qm_engine="gaussian_style_final_files" | This is a dictionary comprised of a key (string) of the file paths to the @@ -1237,12 +1237,12 @@ def write_qm_data_files( | Example 2: {'path_to_gaussian_style_final_files': [0, 23]} | Uses all data points from the 'path/gaussian_log_file.log' file, except points - | 0 and 23. - + | 0 and 23. + | NOTE: Python counting starts at 0. manual_dihedral_atom_numbers_list: list of 4 int, default=None - .. note:: + .. note:: Only needed for qm_engine="gaussian_style_final_files" This is a list of the dihedral atom numbers in order that were used for the dihedral @@ -1410,7 +1410,7 @@ def get_matching_dihedral_info_and_opls_fitting_data( do not explictly specify the system bonds. qm_log_file_dict: dict, {str: [int, ..., int]} qm_engine="gaussian" - + | This is a dictionary comprised of a key (string) of the QM log file path and name, | and a list of integers, which are the QM optimization parameters to remove from | the written data, in order of reading from each file. These can be seen in the @@ -1422,10 +1422,10 @@ def get_matching_dihedral_info_and_opls_fitting_data( | Example 2: {'path/gaussian_log_file.log': [0, 23]} | Uses all data points from the 'path/gaussian_log_file.log' file, except points - | 0 and 23. - + | 0 and 23. + | NOTE: Python counting starts at 0. - + qm_engine="gaussian_style_final_files" @@ -1435,7 +1435,7 @@ def get_matching_dihedral_info_and_opls_fitting_data( | from each folder. These can be seen in the order of the dictionary file name (strings). | These removed parameters allow users to remove any bad or repeated data points | for the QM log file when needed. - + | NOTE: The energy and dihedral angle file in this directory need to be | named 'dihedral.txt' for the energy and dihedral angle values (one 1 per directory). @@ -1471,7 +1471,7 @@ def get_matching_dihedral_info_and_opls_fitting_data( The list length is the number of dihedrals which match the QM scanned atom/bead types, with the nested list has four (4) integers - matching_dihedral_types_by_atom_type_list: nested list + matching_dihedral_types_by_atom_type_list: nested list A list of the four atom numbers that match the selected 'fit_dihedral_atom_types', extracted from the PSF file, including the dihedral being fit. @@ -1524,7 +1524,7 @@ def get_matching_dihedral_info_and_opls_fitting_data( const_1_plus_Cos_3_phi, const_1_minus_Cos_4_phi ] - + | Example 0: | const_1_minus_Cos_0_phi = 0 , since k0 is not used in this form diff --git a/mosdef_dihedral_fit/utils/math_operations.py b/mosdef_dihedral_fit/utils/math_operations.py index 53c0e29..50d46a9 100755 --- a/mosdef_dihedral_fit/utils/math_operations.py +++ b/mosdef_dihedral_fit/utils/math_operations.py @@ -1,4 +1,5 @@ import math + import numpy as np @@ -38,6 +39,7 @@ def round_to_sig_figs(value, sig_figs=3): # (START) # ************************************************************** + def normalize_vector(vector): """Generates the normalized vector from a given vector. @@ -118,10 +120,7 @@ def angle_between_2_vectors(vector_1, vector_2): def dihedral_angle( - atom_xyz_coord_1, - atom_xyz_coord_2, - atom_xyz_coord_3, - atom_xyz_coord_4 + atom_xyz_coord_1, atom_xyz_coord_2, atom_xyz_coord_3, atom_xyz_coord_4 ): """Gets the dihedral angle between the four (4) atom coordinates given in cartesian coordinates. @@ -147,23 +146,21 @@ def dihedral_angle( dihedral_angle_degrees: float (in degrees) The dihedral angle, in degrees, between the four (4) atoms. """ - # check if any atom coordinates are 3 ints or floats in lists - if ( - ( - not isinstance(atom_xyz_coord_1, list) - or not isinstance(atom_xyz_coord_2, list) + # check if any atom coordinates are 3 ints or floats in lists + if ( + ( + not isinstance(atom_xyz_coord_1, list) + or not isinstance(atom_xyz_coord_2, list) or not isinstance(atom_xyz_coord_3, list) or not isinstance(atom_xyz_coord_4, list) - ) - or - ( + ) + or ( len(atom_xyz_coord_1) != 3 or len(atom_xyz_coord_2) != 3 or len(atom_xyz_coord_3) != 3 or len(atom_xyz_coord_4) != 3 ) - or - ( + or ( not isinstance(atom_xyz_coord_1[0], (int, float)) or not isinstance(atom_xyz_coord_1[1], (int, float)) or not isinstance(atom_xyz_coord_1[2], (int, float)) @@ -259,6 +256,7 @@ def dihedral_angle( # (End) # ************************************************************** + def check_previous_qm_values_match( all_value_list, current_value, value_name, qm_engine, log_file_name ): @@ -328,7 +326,7 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): | const_1_minus_Cos_4_phi = sum of the list using all phis [(1 - cos(4 * phi))] in k4 * (1 - cos(4 * phi)) .. note:: - These values are used to simplify the diheral fitting process, + These values are used to simplify the diheral fitting process, allowing the user to deal with four (4) OPLS constants (see below). @@ -338,7 +336,7 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): U_{opls-dihedral} = 1/2 * ( k0 + k1 * [1 + cos[1 * phi] + k2 * [1 - cos[2 * phi] - + + k3 * [1 + cos[3 * phi] + k4 * [1 - cos[4 * phi] ) @@ -349,7 +347,7 @@ def sum_opls_const_1_plus_or_minus_cos_n_values(phi_list): U_{opls-dihedral-mod} = 1/2 * ( k0 + k1 * [const1plusCos1phi] + k2 * [const1minusCos2phi] - + + k3 * [const1plusCos3phi] + k4 * [const1minusCos4phi] ) @@ -409,20 +407,20 @@ def opls_dihedral(cos_powers_phi_and_constants_data, k0, k1, k2, k3, k4): and the output ' dihedral_energy' energy are output in the same energy units. - .. note:: + .. note:: THIS WILL FIT THE FORM IT IS FED, REGARDLESS IF IT IS THE CORRECT ANALYTICAL SOLUTION. MEANING SOMETIMES YOU CAN NOT USE A K-VALUE BECAUSE OF MOLECULE SYMMETREY. THEREFORE, THIS IS MUST BE ACCOUNTED FOR OUTSIDE OF THIS FUNCTION. - .. note:: + .. note:: ALL THE K-VALUE ENERGY UNITS MUST BE THE SAME. .. math:: U_{opls-dihedral} = 1/2 * ( k0 + k1 * (1 + cos[1 * phi]) + k2 * (1 - cos[2 * phi]) - + .. math:: + k3 * (1 + cos[3 * phi]) + k4 * (1 - cos[4 * phi]) @@ -952,10 +950,10 @@ def periodic_dihedral_n_1_2_3_4_5( .. note:: ALL THE K_x-VALUE ENERGY UNITS MUST BE THE SAME. - + .. note:: All the K_x, n_x, and d_x x-values are a pair (i.e., K_1, n_1, and d_1) - + .. math:: U_{periodic-dihedral} = K_0 * (1 + cos[n_0*t - d_0]) @@ -966,7 +964,7 @@ def periodic_dihedral_n_1_2_3_4_5( + K_5 * (1 + cos[n_5*t - d_5]) - + Parameters ---------- phi_data: float, int, or list of floats/int, in degrees @@ -1008,21 +1006,21 @@ def RB_torsion_n_1_2_3_4_5(phi_data, k_0, k_1, k_2, k_3, k_4, k_5): This is the Ryckaert-Bellemans (RB) torsion style energy calculation. This is the Ryckaert-Bellemans (RB) torsion style energy calculation. - + The K_x-values are in energy units (i.e., kcal/mol, kJ/mol, Kelvin, ...), - + and the output 'dihedral_energy' energy are output in the same energy units. - .. note:: + .. note:: ALL THE k_x-VALUE ENERGY UNITS MUST BE THE SAME. - + .. math:: - U_{RB-torsions} = k_0 + k_1*cos(psi) - - + k_2*cos(psi)^2 + k_3*cos(psi)^3 - + U_{RB-torsions} = k_0 + k_1*cos(psi) + + + k_2*cos(psi)^2 + k_3*cos(psi)^3 + + k_4*cos(psi)^4 + k_5*cos(psi)^5 - + Parameters ---------- phi_data: float, int, or list of floats/int, in degrees @@ -1070,7 +1068,7 @@ def opls_dihedral_n_1_2_3_4(phi_data, k_0, k_1, k_2, k_3, k_4): U_{opls-dihedral} = 1/2 * ( k0 + k1 * (1 + cos[1 * phi]) + k2 * (1 - cos[2 * phi]) - + .. math:: + k3 * (1 + cos[3 * phi]) + k4 * (1 - cos[4 * phi]) From dc03e4d42b907577de0311437607c20ab21a4f5a Mon Sep 17 00:00:00 2001 From: bc118 Date: Thu, 22 Aug 2024 21:22:01 -0400 Subject: [PATCH 3/7] added all the functions, but with warnings, saying input tests correctness is not checked. --- .../output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp | 2 +- mosdef_dihedral_fit/tests/test_file_read_write.py | 5 ----- mosdef_dihedral_fit/tests/test_math_operation.py | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp index e791c11..050b317 100644 --- a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp +++ b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp @@ -57,7 +57,7 @@ DIHEDRALS * CHARMM ! Boltzmann = 0.0019872041 kcal / (mol * K) ! ! type_1 type_2 type_3 type_4 Kchi n delta ! extended_type_1 extended_type_2 extended_type_3 extended_type_4 -HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 +HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 ! The input dihedral to periodic dihedral conversion error is OK [error <= 10^(-10)] ! Maximum( |(input dihedral calc)-(periodic dihedral calc)| ) = 3.608224830031759e-16 diff --git a/mosdef_dihedral_fit/tests/test_file_read_write.py b/mosdef_dihedral_fit/tests/test_file_read_write.py index 7687b38..44b260c 100644 --- a/mosdef_dihedral_fit/tests/test_file_read_write.py +++ b/mosdef_dihedral_fit/tests/test_file_read_write.py @@ -1,13 +1,8 @@ import os - import numpy as np import pytest -import unyt as u import mosdef_dihedral_fit.utils.math_operations as mdf_math -from mosdef_dihedral_fit.dihedral_fit.fit_dihedral_with_gomc import ( - fit_dihedral_with_gomc, -) from mosdef_dihedral_fit.tests.base_test import BaseTest from mosdef_dihedral_fit.utils.file_read_and_write import ( change_gomc_ff_file_dihedral_values, diff --git a/mosdef_dihedral_fit/tests/test_math_operation.py b/mosdef_dihedral_fit/tests/test_math_operation.py index 4130f87..fb14ab6 100644 --- a/mosdef_dihedral_fit/tests/test_math_operation.py +++ b/mosdef_dihedral_fit/tests/test_math_operation.py @@ -856,7 +856,7 @@ def test_dihedral_angle_error_coord_4_entry_3_not_int_float(self): # ******************************************** # test the mdf_math.check_previous_qm_values_match (START) # ******************************************** - """ + def test_check_previous_qm_values_match(self): # Without error all_value_list = [[1], [2], [3]] @@ -877,4 +877,4 @@ def test_check_previous_qm_values_match(self): check_return = mdf_math.check_previous_qm_values_match( all_value_list, [4], "value_name", "qm_engine", "log_file" ) - """ + From f839bacc7bb0fbe869bc4051b5c2f3403ec9f876 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 01:22:13 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp | 2 +- mosdef_dihedral_fit/tests/test_file_read_write.py | 1 + mosdef_dihedral_fit/tests/test_math_operation.py | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp index 050b317..e791c11 100644 --- a/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp +++ b/mosdef_dihedral_fit/tests/files/gaussian/HC_CT_CT_HC/output/GOMC_pdb_psf_ff_files_dihedrals_zeroed.inp @@ -57,7 +57,7 @@ DIHEDRALS * CHARMM ! Boltzmann = 0.0019872041 kcal / (mol * K) ! ! type_1 type_2 type_3 type_4 Kchi n delta ! extended_type_1 extended_type_2 extended_type_3 extended_type_4 -HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 +HC CT CT HC 0.5 0 90.0 ! TMP_opls_140 TMP_opls_135 TMP_opls_135 TMP_opls_140 ! The input dihedral to periodic dihedral conversion error is OK [error <= 10^(-10)] ! Maximum( |(input dihedral calc)-(periodic dihedral calc)| ) = 3.608224830031759e-16 diff --git a/mosdef_dihedral_fit/tests/test_file_read_write.py b/mosdef_dihedral_fit/tests/test_file_read_write.py index 44b260c..8b8ca45 100644 --- a/mosdef_dihedral_fit/tests/test_file_read_write.py +++ b/mosdef_dihedral_fit/tests/test_file_read_write.py @@ -1,4 +1,5 @@ import os + import numpy as np import pytest diff --git a/mosdef_dihedral_fit/tests/test_math_operation.py b/mosdef_dihedral_fit/tests/test_math_operation.py index fb14ab6..85f6fe2 100644 --- a/mosdef_dihedral_fit/tests/test_math_operation.py +++ b/mosdef_dihedral_fit/tests/test_math_operation.py @@ -877,4 +877,3 @@ def test_check_previous_qm_values_match(self): check_return = mdf_math.check_previous_qm_values_match( all_value_list, [4], "value_name", "qm_engine", "log_file" ) - From c55002e0420412d184eb73fb879d61c1644b22c9 Mon Sep 17 00:00:00 2001 From: bc118 Date: Thu, 22 Aug 2024 21:26:29 -0400 Subject: [PATCH 5/7] added all the functions, but with warnings, saying input tests correctness is not checked. --- .../utils/file_read_and_write.py | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/mosdef_dihedral_fit/utils/file_read_and_write.py b/mosdef_dihedral_fit/utils/file_read_and_write.py index 6d602d5..0830992 100755 --- a/mosdef_dihedral_fit/utils/file_read_and_write.py +++ b/mosdef_dihedral_fit/utils/file_read_and_write.py @@ -479,34 +479,35 @@ def get_final_gaussian_output_file_data( Returns ------- - all_dihedral_angle_degrees_list: list (nested list) - This is the list of the optimized Gaussian dihedral angles (degrees) with the - specific angles removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_energy_hartree_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_coordinates_ang_list: list (nested list) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - element_names_list: list - This is the list of the Gaussian element names per the - 'qm_log_file_dict' list (value) input. - The list length is dependant on the number of elements in the Gaussian log file - These values are confirmed to be the same for all entered Gaussian log files. - number_of_atoms: int - This is the number of atoms in the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. - manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) - This is a list of the dihedral atom numbers in order that were used for the dihedral - fit. This information needs to be correct and in order to produce correct results. - The values must be the same in all the combined files. + | list of: + | all_dihedral_angle_degrees_list: list (nested list) + | This is the list of the optimized Gaussian dihedral angles (degrees) with the + | specific angles removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_energy_hartree_list: list (nested list) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_coordinates_ang_list: list (nested list) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | element_names_list: list + | This is the list of the Gaussian element names per the + | 'qm_log_file_dict' list (value) input. + | The list length is dependant on the number of elements in the Gaussian log file + | These values are confirmed to be the same for all entered Gaussian log files. + | number_of_atoms: int + | This is the number of atoms in the Gaussian + | 'qm_log_file_dict' list (value) input. + | These values are confirmed to be the same for all entered Gaussian log files. + | manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) + | This is a list of the dihedral atom numbers in order that were used for the dihedral + | fit. This information needs to be correct and in order to produce correct results. + | The values must be the same in all the combined files. """ if not isinstance(qm_log_file_dict, dict): raise TypeError( From e669c16637d94197c360c5cd3749cc7583f996c6 Mon Sep 17 00:00:00 2001 From: bc118 Date: Thu, 22 Aug 2024 21:34:45 -0400 Subject: [PATCH 6/7] added all the functions, but with warnings, saying input tests correctness is not checked. --- .../utils/file_read_and_write.py | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/mosdef_dihedral_fit/utils/file_read_and_write.py b/mosdef_dihedral_fit/utils/file_read_and_write.py index 0830992..a5a21bf 100755 --- a/mosdef_dihedral_fit/utils/file_read_and_write.py +++ b/mosdef_dihedral_fit/utils/file_read_and_write.py @@ -479,35 +479,35 @@ def get_final_gaussian_output_file_data( Returns ------- - | list of: - | all_dihedral_angle_degrees_list: list (nested list) - | This is the list of the optimized Gaussian dihedral angles (degrees) with the - | specific angles removed per the 'qm_log_file_dict' list - | (value) input. This is a nested list, with an inner list for every - | Gaussian log file or 'qm_log_file_dict' (key). - | all_energy_hartree_list: list (nested list) - | This is the list of the optimized Gaussian energies with the specific energies - | (hartree) removed per the 'qm_log_file_dict' list - | (value) input. This is a nested list, with an inner list for every - | Gaussian log file or 'qm_log_file_dict' (key). - | all_coordinates_ang_list: list (nested list) - | This is the list of the optimized Gaussian energies with the specific energies - | (hartree) removed per the 'qm_log_file_dict' list - | (value) input. This is a nested list, with an inner list for every - | Gaussian log file or 'qm_log_file_dict' (key). - | element_names_list: list - | This is the list of the Gaussian element names per the - | 'qm_log_file_dict' list (value) input. - | The list length is dependant on the number of elements in the Gaussian log file - | These values are confirmed to be the same for all entered Gaussian log files. - | number_of_atoms: int - | This is the number of atoms in the Gaussian - | 'qm_log_file_dict' list (value) input. - | These values are confirmed to be the same for all entered Gaussian log files. - | manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) - | This is a list of the dihedral atom numbers in order that were used for the dihedral - | fit. This information needs to be correct and in order to produce correct results. - | The values must be the same in all the combined files. + list of: + | all_dihedral_angle_degrees_list: list (nested list) + | This is the list of the optimized Gaussian dihedral angles (degrees) with the + | specific angles removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_energy_hartree_list: list (nested list) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_coordinates_ang_list: list (nested list) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | element_names_list: list + | This is the list of the Gaussian element names per the + | 'qm_log_file_dict' list (value) input. + | The list length is dependant on the number of elements in the Gaussian log file + | These values are confirmed to be the same for all entered Gaussian log files. + | number_of_atoms: int + | This is the number of atoms in the Gaussian + | 'qm_log_file_dict' list (value) input. + | These values are confirmed to be the same for all entered Gaussian log files. + | manual_dihedral_atom_numbers_list: list, list of four (4) int (example: [3,2,1,5]) + | This is a list of the dihedral atom numbers in order that were used for the dihedral + | fit. This information needs to be correct and in order to produce correct results. + | The values must be the same in all the combined files. """ if not isinstance(qm_log_file_dict, dict): raise TypeError( @@ -763,35 +763,36 @@ def get_gaussian_log_file_data( Returns ------- - all_dihedral_angle_degrees_list: list (nested list of str) - This is the list of the optimized Gaussian dihedral angles (degrees) with the - specific angles removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_energy_hartree_list: list (nested list of str) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - all_coordinates_ang_list: list (nested list of float) - This is the list of the optimized Gaussian energies with the specific energies - (hartree) removed per the 'qm_log_file_dict' list - (value) input. This is a nested list, with an inner list for every - Gaussian log file or 'qm_log_file_dict' (key). - element_names_list: list of str - This is the list of the Gaussian element names per the - 'qm_log_file_dict' list (value) input. - The list length is dependant on the number of elements in the Gaussian log file - These values are confirmed to be the same for all entered Gaussian log files. - number_of_atoms: int - This is the number of atoms in the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. - dihedral_atom_numbers_list: list of 4 int - This is the list of the dihedral atom numbers used in the Gaussian - dihedral scan, which are taken from the Gaussian - 'qm_log_file_dict' list (value) input. - These values are confirmed to be the same for all entered Gaussian log files. + list of: + | all_dihedral_angle_degrees_list: list (nested list of str) + | This is the list of the optimized Gaussian dihedral angles (degrees) with the + | specific angles removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_energy_hartree_list: list (nested list of str) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | all_coordinates_ang_list: list (nested list of float) + | This is the list of the optimized Gaussian energies with the specific energies + | (hartree) removed per the 'qm_log_file_dict' list + | (value) input. This is a nested list, with an inner list for every + | Gaussian log file or 'qm_log_file_dict' (key). + | element_names_list: list of str + | This is the list of the Gaussian element names per the + | 'qm_log_file_dict' list (value) input. + | The list length is dependant on the number of elements in the Gaussian log file + | These values are confirmed to be the same for all entered Gaussian log files. + | number_of_atoms: int + | This is the number of atoms in the Gaussian + | 'qm_log_file_dict' list (value) input. + | These values are confirmed to be the same for all entered Gaussian log files. + | dihedral_atom_numbers_list: list of 4 int + | This is the list of the dihedral atom numbers used in the Gaussian + | dihedral scan, which are taken from the Gaussian + | 'qm_log_file_dict' list (value) input. + | These values are confirmed to be the same for all entered Gaussian log files. """ if not isinstance(qm_log_file_dict, dict): raise TypeError( From 0d065c121f235064d2ea6d22c4f2f9a08c4b9c04 Mon Sep 17 00:00:00 2001 From: bc118 Date: Sat, 24 Aug 2024 16:41:00 -0400 Subject: [PATCH 7/7] renamed 'other_functions' to 'additional_utilities' in the docs' --- docs/index.rst | 6 +++--- ...ary_structures.rst => additional_utilities.rst} | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) rename docs/topic_guides/{secondary_structures.rst => additional_utilities.rst} (87%) diff --git a/docs/index.rst b/docs/index.rst index 5c1c337..0976c30 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -110,14 +110,14 @@ The official VMD web page is http://www.ks.uiuc.edu/Research/vmd :maxdepth: 2 getting_started/installation/installation - getting_started/quick_start/quick_start + getting_started/quick_start/quick_start .. toctree:: :caption: Topic Guides :maxdepth: 2 - topic_guides/data_structures - topic_guides/secondary_structures + topic_guides/data_structures + topic_guides/additional_utilities .. toctree:: :caption: Reference diff --git a/docs/topic_guides/secondary_structures.rst b/docs/topic_guides/additional_utilities.rst similarity index 87% rename from docs/topic_guides/secondary_structures.rst rename to docs/topic_guides/additional_utilities.rst index beac5f8..c276f07 100644 --- a/docs/topic_guides/secondary_structures.rst +++ b/docs/topic_guides/additional_utilities.rst @@ -1,11 +1,11 @@ -.. _secondary_data_structures: +.. _additional_utilities: -========================= -Secondary Data Structures -========================= +==================== +Additional Utilities +==================== .. warning:: - These secondary functions, mostly from the **utils** folder,= + These additional utilities, mostly from the **utils** folder,= **do not contain Type or Value Input Checks**. Therefore, they are being listed with a warning that only advanced users should use these functions, as they were not designed with input error checks. @@ -18,7 +18,7 @@ Read and Write Functions (For Advanded Users) --------------------------------------------- .. warning:: - These secondary functions, mostly from the **utils** folder,= + These additional utilities, mostly from the **utils** folder,= **do not contain Type or Value Input Checks**. Therefore, they are being listed with a warning that only advanced users should use these functions, as they were not designed with input error checks. @@ -35,7 +35,7 @@ Math and Operation Functions (For Advanded Users) ------------------------------------------------- .. warning:: - These secondary functions, mostly from the **utils** folder,= + These additional utilities, mostly from the **utils** folder,= **do not contain Type or Value Input Checks**. Therefore, they are being listed with a warning that only advanced users should use these functions, as they were not designed with input error checks.