def test_Exceptions(self, universe): match = "'normals' must be a 3D array containing local membrane normals of each lipi at each frame." with pytest.raises(ValueError, match=match): SCC( universe=universe, **self.kwargs, normals=np.ones(100) # Wrong dimension ) match = "The shape of 'normals' must be \\(n_residues, n_frames, 3\\)" with pytest.raises(ValueError, match=match): SCC( universe=universe, **self.kwargs, normals=np.ones((99, 1, 3)) # Too few molecules ) match = "The frames to analyse must be identical to those used " with pytest.raises(ValueError, match=match): scc = SCC( universe=universe, **self.kwargs, normals=np.ones((100, 2, 3)) # Too many frames ) scc.run()
def test_Exceptions(self, universe): match = "'normals' must either be a 2D array containing leaflet ids " with pytest.raises(ValueError, match=match): SCC( universe=universe, **self.kwargs, normals=np.ones(100) ) match = "The shape of 'normals' must be \\(n_residues,\\)" with pytest.raises(ValueError, match=match): SCC( universe=universe, **self.kwargs, normals=np.ones((99, 1)) ) match = "The frames to analyse must be identical to those used " with pytest.raises(ValueError, match=match): scc = SCC( universe=universe, **self.kwargs, normals=np.ones((100, 2)) ) scc.run()
def scc(self, universe): scc = SCC( universe=universe, tail_sel="not name ROH" ) scc.run() return scc
def test_SCC(self, universe): scc = SCC(universe, **self.kwargs) scc.run() reference = { 'n_residues': 100, 'n_frames': 1, 'scc': np.full((100, 1), fill_value=-0.5) # all bonds are perpendicular to the z-axis } assert scc.SCC.shape == (reference['n_residues'], reference['n_frames']) assert_array_almost_equal(scc.SCC, reference['scc'])
def test_SCC_weighted_average_different_tails(self, universe, sn1_scc): sn2_scc = SCC(universe, "name L") sn2_scc.run() scc = SCC.weighted_average(sn1_scc, sn2_scc) reference = { 'n_residues': 100, 'n_frames': 1, 'scc': np.full( (100, 1), fill_value=-0.5) # all bonds are perpendicular to the z-axis } assert scc.SCC.shape == (reference['n_residues'], reference['n_frames']) assert_array_almost_equal(scc.SCC, reference['scc'])
def test_Exceptions(self, universe, sn1_scc): match = "sn1_scc and sn2_scc must have been run with the same frames" with pytest.raises(ValueError, match=match): sn2_scc = SCC( universe=universe, **self.kwargs, ) sn2_scc.run(stop=0) SCC.weighted_average(sn1_scc, sn2_scc) with pytest.raises(ValueError, match=match): sn2_scc = SCC( universe=universe, **self.kwargs, ) sn2_scc.run(stop=1) sn2_scc.frames = np.array([10]) SCC.weighted_average(sn1_scc, sn2_scc)
def test_SCC_normals_3D(self, universe): # The Scc should be the same whether the normal is the positive or negative z-axis normals = np.zeros((100, 1, 3)) normals[:, :50, 2] = 1.0 normals[:, 50:, 2] = -1.0 scc = SCC(universe, **self.kwargs, normals=normals) scc.run() reference = { 'n_residues': 100, 'n_frames': 1, 'scc': np.full( (100, 1), fill_value=-0.5) # all bonds are perpendicular to the z-axis } assert scc.SCC.shape == (reference['n_residues'], reference['n_frames']) assert_array_almost_equal(scc.SCC, reference['scc'])
def sn1_scc(self, universe): sn1_scc = SCC(universe, "name C") sn1_scc.run() return sn1_scc
def sn1_scc(self, universe): sn1_scc = SCC(universe, **self.kwargs) sn1_scc.run() return sn1_scc