@@ -759,3 +759,67 @@ def _select_atoms(q):
759759 molcount = molcount ,
760760 )
761761 assert mol .select_atoms .call_count == 3
762+
763+
764+ def test_build_ua_vectors_multiple_residues_first_residue ():
765+ node = FrameCovarianceNode ()
766+ axes_manager = MagicMock ()
767+ axes_manager .get_UA_axes .return_value = (
768+ np .eye (3 ),
769+ 2.0 * np .eye (3 ),
770+ np .ones (3 ),
771+ np .array ([1.0 , 2.0 , 3.0 ]),
772+ )
773+ node ._ft .get_weighted_forces = MagicMock (return_value = np .array ([1.0 , 0.0 , 0.0 ]))
774+ node ._ft .get_weighted_torques = MagicMock (return_value = np .array ([0.0 , 1.0 , 0.0 ]))
775+
776+ with patch ("CodeEntropy.levels.nodes.covariance.make_whole" ) as make_whole :
777+ force_vecs , torque_vecs = node ._build_ua_vectors (
778+ u = FakeUniverse ([]),
779+ mol_id = 0 ,
780+ local_res_i = 0 ,
781+ bead_groups = [FakeAtomGroup ("ua" )],
782+ residue_group = FakeMolecule (n_residues = 2 ),
783+ axes_manager = axes_manager ,
784+ axes_topology = None ,
785+ box = None ,
786+ force_partitioning = 0.5 ,
787+ customised_axes = True ,
788+ is_highest = True ,
789+ res_position = - 1 ,
790+ )
791+
792+ assert make_whole .call_count == 2
793+ axes_manager .get_UA_axes .assert_called_once ()
794+
795+
796+ def test_build_ua_vectors_multiple_residues_middle_residue ():
797+ node = FrameCovarianceNode ()
798+ axes_manager = MagicMock ()
799+ axes_manager .get_UA_axes .return_value = (
800+ np .eye (3 ),
801+ 2.0 * np .eye (3 ),
802+ np .ones (3 ),
803+ np .array ([1.0 , 2.0 , 3.0 ]),
804+ )
805+ node ._ft .get_weighted_forces = MagicMock (return_value = np .array ([1.0 , 0.0 , 0.0 ]))
806+ node ._ft .get_weighted_torques = MagicMock (return_value = np .array ([0.0 , 1.0 , 0.0 ]))
807+
808+ with patch ("CodeEntropy.levels.nodes.covariance.make_whole" ) as make_whole :
809+ force_vecs , torque_vecs = node ._build_ua_vectors (
810+ u = FakeUniverse ([]),
811+ mol_id = 0 ,
812+ local_res_i = 0 ,
813+ bead_groups = [FakeAtomGroup ("ua" )],
814+ residue_group = FakeMolecule (n_residues = 3 ),
815+ axes_manager = axes_manager ,
816+ axes_topology = None ,
817+ box = None ,
818+ force_partitioning = 0.5 ,
819+ customised_axes = True ,
820+ is_highest = True ,
821+ res_position = 0 ,
822+ )
823+
824+ assert make_whole .call_count == 2
825+ axes_manager .get_UA_axes .assert_called_once ()
0 commit comments