From 9aa42f91602eabc277817a63ab23f28b9afc3962 Mon Sep 17 00:00:00 2001 From: Ralf Meyer Date: Tue, 31 Jan 2023 14:03:27 -0500 Subject: [PATCH] Add tests for rigorous_rmsd() --- tests/inputs/rmsd/BUWGOQ.xyz | 46 ++++++++++ tests/inputs/rmsd/BUWGOQ_final.xyz | 46 ++++++++++ tests/inputs/rmsd/BUWGOQ_final_reordered.xyz | 46 ++++++++++ tests/inputs/rmsd/BUWGOQ_noH.xyz | 22 +++++ tests/inputs/rmsd/BUWGOQ_noH_final.xyz | 22 +++++ tests/inputs/rmsd/example_1.xyz | 88 ++++++++++++++++++++ tests/inputs/rmsd/example_1_noff.xyz | 88 ++++++++++++++++++++ tests/test_rmsd.py | 36 ++++++++ 8 files changed, 394 insertions(+) create mode 100644 tests/inputs/rmsd/BUWGOQ.xyz create mode 100644 tests/inputs/rmsd/BUWGOQ_final.xyz create mode 100644 tests/inputs/rmsd/BUWGOQ_final_reordered.xyz create mode 100644 tests/inputs/rmsd/BUWGOQ_noH.xyz create mode 100644 tests/inputs/rmsd/BUWGOQ_noH_final.xyz create mode 100644 tests/inputs/rmsd/example_1.xyz create mode 100644 tests/inputs/rmsd/example_1_noff.xyz create mode 100644 tests/test_rmsd.py diff --git a/tests/inputs/rmsd/BUWGOQ.xyz b/tests/inputs/rmsd/BUWGOQ.xyz new file mode 100644 index 00000000..500feff5 --- /dev/null +++ b/tests/inputs/rmsd/BUWGOQ.xyz @@ -0,0 +1,46 @@ +44 +5fad73dd2b6428eefef6b38f +Cu 11.744500 3.786200 3.439900 +Cl 13.835200 4.761600 2.599900 +N 12.257100 3.715000 5.341500 +C 12.347500 5.084500 5.949800 +H 12.113200 5.052800 6.889700 +H 13.250100 5.431200 5.867900 +N 12.204600 1.853300 2.990300 +C 13.471300 2.944000 5.672200 +H 13.596100 2.948500 6.634200 +H 14.240700 3.378100 5.272100 +N 10.514900 4.030900 1.918400 +C 13.411800 1.516700 5.194000 +H 12.600800 1.107900 5.533400 +H 14.164600 1.031100 5.565200 +C 13.435600 1.374600 3.694000 +H 14.197900 1.867700 3.350900 +H 13.570000 0.438700 3.476200 +C 11.060700 0.982700 3.379800 +H 11.310500 0.061800 3.278600 +H 10.306800 1.174300 2.816800 +H 10.827700 1.151700 4.295600 +C 12.492500 1.693100 1.533700 +H 12.710200 0.762700 1.366000 +H 13.278600 2.218900 1.317800 +C 11.378300 2.096800 0.601500 +H 10.576700 1.605400 0.842500 +H 11.619700 1.840500 -0.301700 +C 11.061900 3.578300 0.617900 +H 11.870600 4.077500 0.423200 +H 10.418600 3.773000 -0.081900 +C 10.003600 5.440200 1.784400 +H 10.500600 5.912000 1.099000 +H 9.065300 5.434200 1.537600 +C 10.183100 6.100600 3.093500 +C 11.010800 5.462100 3.983200 +C 11.397300 5.946500 5.209500 +C 10.895500 7.194800 5.571000 +H 11.128500 7.570200 6.389400 +C 10.047600 7.877700 4.714000 +H 9.712200 8.705200 4.972300 +C 9.693200 7.360600 3.491600 +H 9.129500 7.841500 2.927700 +H 9.775200 3.477600 2.130400 +H 11.487700 3.135400 5.649000 diff --git a/tests/inputs/rmsd/BUWGOQ_final.xyz b/tests/inputs/rmsd/BUWGOQ_final.xyz new file mode 100644 index 00000000..171aca87 --- /dev/null +++ b/tests/inputs/rmsd/BUWGOQ_final.xyz @@ -0,0 +1,46 @@ +44 +-1.4066843014153758e+03 frame 35 xyz file generated by TeraChem + Cu 0.2158254167 0.0005950532 0.0851857734 + Cl 0.3566297180 -0.0033428331 -2.4276433566 + N -0.0690154824 1.9813591615 0.4428477162 + C -1.4487927726 2.4159274563 0.0491684329 + H -1.7493953003 3.2833308898 0.6450959947 + H -1.4013273376 2.7237382155 -1.0001996566 + N 2.2441589139 0.0007428913 0.5003923820 + C 0.9640604153 2.8496217766 -0.1720495401 + H 0.7011484912 3.8918565636 0.0475271682 + H 0.8989314900 2.6958614809 -1.2522693640 + N -0.0695676791 -1.9811740382 0.4418830336 + C 2.3672997560 2.5523077443 0.3312183498 + H 2.4225041186 2.6944199208 1.4160066042 + H 3.0314954557 3.3061838451 -0.1050327097 + C 2.9171812408 1.1957284952 -0.0938754794 + H 2.8308348444 1.0931125787 -1.1784138085 + H 3.9813135590 1.1405661305 0.1718375293 + C 2.3990388643 0.0031916786 1.9790215885 + H 1.9271498285 -0.8779245543 2.4124234185 + H 1.9283429303 0.8861766283 2.4098101602 + H 3.4644433583 0.0029201380 2.2426223559 + C 2.9171916591 -1.1964978587 -0.0892598428 + H 3.9813060835 -1.1401270009 0.1762612623 + H 2.8309858104 -1.0977246661 -1.1741684084 + C 2.3674916655 -2.5515331235 0.3407524212 + H 2.4200259692 -2.6886897006 1.4262877702 + H 3.0336340701 -3.3066780187 -0.0903005364 + C 0.9658106438 -2.8521900193 -0.1646858375 + H 0.9039463536 -2.7053289172 -1.2460465574 + H 0.7026830676 -3.8931467346 0.0608029288 + C -1.4468071901 -2.4135808440 0.0384893806 + H -1.3937495659 -2.7089847231 -1.0142144341 + H -1.7494131136 -3.2881344644 0.6228468002 + C -2.3375176111 -1.2289763819 0.1925325901 + C -1.7018807279 0.0004473810 0.1484626222 + C -2.3381522665 1.2293710568 0.1962218177 + C -3.7325513878 1.2187933130 0.3208427123 + H -4.2772805780 2.1574366869 0.3709330992 + C -4.4135014818 -0.0007369744 0.3830240789 + H -5.4940043043 -0.0011810988 0.4894195124 + C -3.7317832619 -1.2198077418 0.3175571948 + H -4.2759182530 -2.1589378140 0.3647816342 + H -0.0107524978 -2.0502524535 1.4609379433 + H -0.0030622640 2.0530119310 1.4612390346 diff --git a/tests/inputs/rmsd/BUWGOQ_final_reordered.xyz b/tests/inputs/rmsd/BUWGOQ_final_reordered.xyz new file mode 100644 index 00000000..4d3dcd88 --- /dev/null +++ b/tests/inputs/rmsd/BUWGOQ_final_reordered.xyz @@ -0,0 +1,46 @@ +44 +-1.4066843014153758e+03 frame 35 xyz file generated by TeraChem + Cu 0.2158254167 0.0005950532 0.0851857734 + Cl 0.3566297180 -0.0033428331 -2.4276433566 + N -0.0690154824 1.9813591615 0.4428477162 + C -1.4487927726 2.4159274563 0.0491684329 + H -1.3937495659 -2.7089847231 -1.0142144341 + H -4.2759182530 -2.1589378140 0.3647816342 + N 2.2441589139 0.0007428913 0.5003923820 + C 0.9640604153 2.8496217766 -0.1720495401 + H 0.7011484912 3.8918565636 0.0475271682 + H 0.8989314900 2.6958614809 -1.2522693640 + N -0.0695676791 -1.9811740382 0.4418830336 + C -4.4135014818 -0.0007369744 0.3830240789 + H 2.4225041186 2.6944199208 1.4160066042 + H 3.0314954557 3.3061838451 -0.1050327097 + C 2.9171812408 1.1957284952 -0.0938754794 + H 2.8308348444 1.0931125787 -1.1784138085 + H 3.9813135590 1.1405661305 0.1718375293 + C 2.3990388643 0.0031916786 1.9790215885 + H 1.9271498285 -0.8779245543 2.4124234185 + H 1.9283429303 0.8861766283 2.4098101602 + H 3.4644433583 0.0029201380 2.2426223559 + C 2.9171916591 -1.1964978587 -0.0892598428 + H 3.9813060835 -1.1401270009 0.1762612623 + H 2.8309858104 -1.0977246661 -1.1741684084 + C 2.3674916655 -2.5515331235 0.3407524212 + H -4.2772805780 2.1574366869 0.3709330992 + H 2.4200259692 -2.6886897006 1.4262877702 + C 0.9658106438 -2.8521900193 -0.1646858375 + H 0.9039463536 -2.7053289172 -1.2460465574 + H 0.7026830676 -3.8931467346 0.0608029288 + C -1.4468071901 -2.4135808440 0.0384893806 + H -1.4013273376 2.7237382155 -1.0001996566 + H -1.7494131136 -3.2881344644 0.6228468002 + C -2.3375176111 -1.2289763819 0.1925325901 + C -1.7018807279 0.0004473810 0.1484626222 + C -2.3381522665 1.2293710568 0.1962218177 + C -3.7325513878 1.2187933130 0.3208427123 + H 3.0336340701 -3.3066780187 -0.0903005364 + C 2.3672997560 2.5523077443 0.3312183498 + H -5.4940043043 -0.0011810988 0.4894195124 + C -3.7317832619 -1.2198077418 0.3175571948 + H -0.0107524978 -2.0502524535 1.4609379433 + H -0.0030622640 2.0530119310 1.4612390346 + H -1.7493953003 3.2833308898 0.6450959947 diff --git a/tests/inputs/rmsd/BUWGOQ_noH.xyz b/tests/inputs/rmsd/BUWGOQ_noH.xyz new file mode 100644 index 00000000..d4a4831d --- /dev/null +++ b/tests/inputs/rmsd/BUWGOQ_noH.xyz @@ -0,0 +1,22 @@ +20 + +Cu 11.744500 3.786200 3.439900 +Cl 13.835200 4.761600 2.599900 +N 12.257100 3.715000 5.341500 +C 12.347500 5.084500 5.949800 +N 12.204600 1.853300 2.990300 +C 13.471300 2.944000 5.672200 +N 10.514900 4.030900 1.918400 +C 13.411800 1.516700 5.194000 +C 13.435600 1.374600 3.694000 +C 11.060700 0.982700 3.379800 +C 12.492500 1.693100 1.533700 +C 11.378300 2.096800 0.601500 +C 11.061900 3.578300 0.617900 +C 10.003600 5.440200 1.784400 +C 10.183100 6.100600 3.093500 +C 11.010800 5.462100 3.983200 +C 11.397300 5.946500 5.209500 +C 10.895500 7.194800 5.571000 +C 10.047600 7.877700 4.714000 +C 9.693200 7.360600 3.491600 diff --git a/tests/inputs/rmsd/BUWGOQ_noH_final.xyz b/tests/inputs/rmsd/BUWGOQ_noH_final.xyz new file mode 100644 index 00000000..4584a261 --- /dev/null +++ b/tests/inputs/rmsd/BUWGOQ_noH_final.xyz @@ -0,0 +1,22 @@ +20 + + Cu 0.2158254167 0.0005950532 0.0851857734 + Cl 0.3566297180 -0.0033428331 -2.4276433566 + N -0.0690154824 1.9813591615 0.4428477162 + C -1.4487927726 2.4159274563 0.0491684329 + N 2.2441589139 0.0007428913 0.5003923820 + C 0.9640604153 2.8496217766 -0.1720495401 + N -0.0695676791 -1.9811740382 0.4418830336 + C 2.3672997560 2.5523077443 0.3312183498 + C 2.9171812408 1.1957284952 -0.0938754794 + C 2.3990388643 0.0031916786 1.9790215885 + C 2.9171916591 -1.1964978587 -0.0892598428 + C 2.3674916655 -2.5515331235 0.3407524212 + C 0.9658106438 -2.8521900193 -0.1646858375 + C -1.4468071901 -2.4135808440 0.0384893806 + C -2.3375176111 -1.2289763819 0.1925325901 + C -1.7018807279 0.0004473810 0.1484626222 + C -2.3381522665 1.2293710568 0.1962218177 + C -3.7325513878 1.2187933130 0.3208427123 + C -4.4135014818 -0.0007369744 0.3830240789 + C -3.7317832619 -1.2198077418 0.3175571948 diff --git a/tests/inputs/rmsd/example_1.xyz b/tests/inputs/rmsd/example_1.xyz new file mode 100644 index 00000000..a1c1c0cc --- /dev/null +++ b/tests/inputs/rmsd/example_1.xyz @@ -0,0 +1,88 @@ +86 +10/18/2018 23:07, XYZ structure generated by mol3D Class, molSimplify +Co 0.000000 0.000000 0.000000 +N -0.000952 2.067750 -0.001425 +N 2.067766 -0.000950 0.001425 +N -2.067764 0.000952 0.001425 +N 0.000950 -2.067751 -0.001425 +C -1.169301 2.841644 -0.016059 +C -0.653312 4.209510 0.004172 +C 0.685140 4.228047 -0.000525 +C 1.064743 2.789017 0.007601 +H -1.262515 5.102310 0.016581 +H 1.341744 5.080824 -0.003000 +C 2.515400 2.424104 0.010956 +C -2.473887 2.494047 -0.031852 +C 4.238750 0.668051 -0.002624 +C 4.240901 -0.662142 -0.043374 +C 2.865249 -1.120152 -0.029335 +C 2.860480 1.115955 0.004315 +H 5.123920 1.280372 0.009955 +H 5.123774 -1.277306 -0.074733 +C 2.533300 -2.439131 -0.027572 +C -2.838763 -1.110143 0.010953 +C -4.179044 -0.742830 0.017696 +C -4.216049 0.629382 -0.036023 +C -2.902117 1.046419 -0.026935 +H -5.038596 -1.400331 0.041565 +H -5.108596 1.240275 -0.065690 +C 0.755456 -4.271578 0.032003 +C -0.574406 -4.276022 0.010552 +C -1.089023 -2.925718 0.008900 +C 1.067790 -2.829968 -0.002817 +H 1.424943 -5.107532 0.056699 +H -1.180939 -5.169721 0.008969 +C -2.393468 -2.569366 0.009123 +C 3.545275 3.492143 0.004788 +C 4.275503 3.768788 -1.160229 +C 5.246250 4.772243 -1.164412 +C 5.481799 5.519316 -0.011071 +C 4.758758 5.254879 1.151709 +C 3.802191 4.237367 1.164299 +H 4.114810 3.171953 -2.056962 +H 5.830894 4.955717 -2.062278 +H 6.244957 6.293588 -0.012985 +H 4.955433 5.826784 2.054718 +H 3.269326 4.015519 2.086004 +C -3.500107 3.576892 -0.019074 +C -4.267211 3.801398 1.135316 +C -5.267961 4.774693 1.138938 +C -5.498798 5.541269 -0.001698 +C -4.737863 5.330598 -1.150668 +C -3.749478 4.344667 -1.165875 +H -4.113992 3.203258 2.032063 +H -5.877154 4.928309 2.027157 +H -4.926037 5.926425 -2.041165 +H -3.186519 4.178327 -2.082448 +C -3.431182 -3.643846 0.001781 +C -3.725850 -4.363552 1.167674 +C -4.751649 -5.310878 1.169914 +C -5.503863 -5.530759 0.015978 +C -5.226343 -4.812354 -1.146042 +C -4.188633 -3.878504 -1.157105 +H -3.157330 -4.182509 2.077877 +H -4.968009 -5.872009 2.075170 +H -6.308321 -6.262033 0.023103 +H -5.820060 -4.975206 -2.041988 +H -3.985808 -3.315398 -2.066450 +C 3.575891 -3.497857 -0.022088 +C 4.337768 -3.743380 1.129965 +C 5.308142 -4.747422 1.136921 +C 5.509975 -5.528805 -0.000139 +C 4.751397 -5.299939 -1.148023 +C 3.797149 -4.280590 -1.163571 +H 4.183410 -3.130725 2.016191 +H 5.908200 -4.912205 2.027429 +H 4.904992 -5.908983 -2.034262 +H 3.213627 -4.097709 -2.063127 +H 6.263684 -6.311140 0.005599 +H -6.281503 6.296906 0.000581 +C 0.471652 -0.537234 4.244156 +C 0.734536 -0.809834 2.920676 +N 0.000000 0.000000 2.069739 +C -0.707789 0.741259 2.904623 +N -0.439044 0.472648 4.213528 +H -0.856890 0.933197 5.008495 +H 0.845073 -0.960338 5.163838 +H 1.415035 -1.547181 2.520716 +H -1.433587 1.485795 2.625365 diff --git a/tests/inputs/rmsd/example_1_noff.xyz b/tests/inputs/rmsd/example_1_noff.xyz new file mode 100644 index 00000000..0f9e9dac --- /dev/null +++ b/tests/inputs/rmsd/example_1_noff.xyz @@ -0,0 +1,88 @@ +86 +10/18/2018 23:08, XYZ structure generated by mol3D Class, molSimplify +Co 0.000000 0.000000 0.000000 +N -0.000952 2.067750 -0.001425 +N 2.067766 -0.000950 0.001425 +N -2.067764 0.000952 0.001425 +N 0.000950 -2.067751 -0.001425 +C -1.151505 2.907978 -0.013935 +C -0.705739 4.299764 -0.002482 +C 0.657261 4.253279 0.015963 +C 1.043916 2.834054 0.022608 +H -1.298321 5.204068 -0.004894 +H 1.302123 5.121101 0.022866 +C 2.476955 2.384874 0.000655 +C -2.449914 2.511026 -0.000467 +C 4.210881 0.682455 -0.014152 +C 4.211760 -0.681088 -0.008162 +C 2.884951 -1.087278 0.004287 +C 2.885123 1.086249 -0.011327 +H 5.098849 1.300339 -0.014828 +H 5.101445 -1.295930 -0.016568 +C 2.479379 -2.387107 -0.006198 +C -2.884809 -1.081421 -0.020975 +C -4.209337 -0.682464 -0.020427 +C -4.209948 0.682076 -0.008816 +C -2.885808 1.082827 0.010121 +H -5.091016 -1.308512 -0.025067 +H -5.092494 1.306504 -0.015087 +C 0.655001 -4.254318 0.011070 +C -0.707363 -4.298556 0.028914 +C -1.151049 -2.906414 0.021514 +C 1.044749 -2.836472 -0.015679 +H 1.296883 -5.124643 0.016491 +H -1.303387 -5.201158 0.043445 +C -2.448455 -2.508549 0.001785 +C 3.512066 3.459953 -0.001934 +C 4.333547 3.653958 -1.126901 +C 5.299237 4.665991 -1.130891 +C 5.464518 5.480493 -0.007764 +C 4.657681 5.291507 1.117557 +C 3.678101 4.291992 1.119270 +H 4.214043 3.031164 -2.004770 +H 5.920813 4.817680 -2.004120 +H 6.218054 6.257992 -0.009555 +H 4.792148 5.919384 1.988974 +H 3.062871 4.153034 1.999354 +C -3.514730 3.552732 -0.001264 +C -4.370635 3.692705 1.104393 +C -5.363534 4.677461 1.106092 +C -5.521460 5.515140 -0.001553 +C -4.681106 5.375575 -1.109329 +C -3.675215 4.404839 -1.107598 +H -4.255391 3.051805 1.970055 +H -6.010811 4.791297 1.966013 +H -4.808771 6.019768 -1.969633 +H -3.032251 4.303679 -1.973349 +C -3.513208 -3.548703 0.006634 +C -3.702704 -4.368471 1.132039 +C -4.709961 -5.338033 1.135050 +C -5.522121 -5.508221 0.010217 +C -5.334334 -4.701965 -1.116142 +C -4.339906 -3.718515 -1.116629 +H -3.081481 -4.242975 2.010309 +H -4.860872 -5.957846 2.009341 +H -6.296306 -6.264279 0.011723 +H -5.959711 -4.839637 -1.988923 +H -4.202095 -3.102311 -1.996409 +C 3.513897 -3.465579 -0.003107 +C 4.374221 -3.625435 1.098381 +C 5.338376 -4.638206 1.100620 +C 5.463505 -5.488475 -0.000980 +C 4.618318 -5.333416 -1.102981 +C 3.640982 -4.332606 -1.102529 +H 4.286007 -2.974934 1.959866 +H 5.989377 -4.763598 1.956249 +H 4.721379 -5.989070 -1.958032 +H 2.995656 -4.220623 -1.965042 +H 6.215450 -6.267292 -0.000513 +H -6.294939 6.272191 -0.001702 +C -0.633538 -0.011661 4.209288 +C -1.066274 -0.020178 2.904658 +N 0.000000 0.000000 2.069739 +C 1.064885 0.017727 2.908749 +N 0.706474 0.009293 4.202519 +H 1.340116 0.024360 5.031973 +H -1.248457 -0.022810 5.099235 +H -2.099632 -0.038118 2.592576 +H 2.093844 0.037843 2.582969 diff --git a/tests/test_rmsd.py b/tests/test_rmsd.py new file mode 100644 index 00000000..c0f67958 --- /dev/null +++ b/tests/test_rmsd.py @@ -0,0 +1,36 @@ +import pytest +from molSimplify.Classes.mol3D import mol3D +from molSimplify.Scripts.rmsd import rigorous_rmsd +from pkg_resources import resource_filename, Requirement + + +@pytest.mark.parametrize( + 'path1,path2,ref_hungarian,ref_none', + [['example_1_noff.xyz', 'example_1.xyz', 0.3991, 0.7749], + ['BUWGOQ', 'BUWGOQ_final', 2.43958, 0.49113], + ['BUWGOQ_noH', 'BUWGOQ_noH_final', 1.74814, 0.11826], + ['BUWGOQ', 'BUWGOQ_final_reordered', 2.43958, 3.02598]] + ) +def test_rigorous_rmsd(path1, path2, ref_hungarian, ref_none, atol=1e-3): + # Reference values calculated using https://pypi.org/project/rmsd/ + # >>> calculate_rmsd --reorder path1.xyz path2.xyz + # >>> calculate_rmsd path1.xyz path2.xyz + xyz_1 = resource_filename( + Requirement.parse("molSimplify"), + f"tests/inputs/rmsd/{path1}.xyz" + ) + mol1 = mol3D() + mol1.readfromxyz(xyz_1) + + xyz_2 = resource_filename( + Requirement.parse("molSimplify"), + f"tests/inputs/rmsd/{path2}.xyz" + ) + mol2 = mol3D() + mol2.readfromxyz(xyz_2) + + r = rigorous_rmsd(mol1, mol2, reorder='hungarian') + assert abs(r - ref_hungarian) < atol + + r = rigorous_rmsd(mol1, mol2, reorder='none') + assert abs(r - ref_none) < atol