Beispiel #1
0
 def test_wrap_fragments(self, u, center):
     ag = u.atoms[:250]
     ag.wrap(compound='fragments', center=center)
     if center == 'com':
         ctrpos = ag.center_of_mass(pbc=False, compound='fragments')
     elif center == 'cog':
         ctrpos = ag.center_of_geometry(pbc=False, compound='fragments')
     assert_in_box(ctrpos, u.dimensions)
Beispiel #2
0
 def test_wrap_residues(self, u, center):
     ag = u.atoms[300:400].residues
     ag.wrap(compound='residues', center=center)
     if center == 'com':
         ctrpos = ag.center_of_mass(pbc=False, compound='residues')
     elif center == 'cog':
         ctrpos = ag.center_of_geometry(pbc=False, compound='residues')
     assert_in_box(ctrpos, u.dimensions)
Beispiel #3
0
 def test_wrap_pass(self, level, compound, center, is_triclinic):
     # get a pristine test universe:
     u = UnWrapUniverse(is_triclinic=is_triclinic)
     group = u.atoms
     # select topology level:
     if level == 'residues':
         group = group.residues
     elif level == 'segments':
         group = group.segments
     # store original positions:
     orig_pos = group.atoms.positions
     # get the expected result:
     ref_wrapped_pos = u.wrapped_coords(compound, center)
     # first, do the wrapping out-of-place:
     wrapped_pos = group.wrap(compound=compound, center=center,
                              inplace=False)
     # check for correct result:
     assert_almost_equal(wrapped_pos, ref_wrapped_pos,
                         decimal=self.precision)
     # make sure atom positions are unchanged:
     assert_array_equal(group.atoms.positions, orig_pos)
     # now, do the wrapping inplace:
     wrapped_pos2 = group.wrap(compound=compound, center=center,
                               inplace=True)
     # check that result is the same as for out-of-place computation:
     assert_array_equal(wrapped_pos, wrapped_pos2)
     # check that wrapped positions are applied:
     assert_array_equal(group.atoms.positions, wrapped_pos)
     # check that nobody messed with the reference positions,
     # centers of compounds must lie within the primary unit cell:
     if compound == 'atoms':
         assert_in_box(group.atoms.positions, group.dimensions)
     elif center == 'com':
         compos = group.atoms.center_of_mass(pbc=False, compound=compound)
         assert_in_box(compos, group.dimensions)
     else:
         cogpos = group.atoms.center_of_geometry(pbc=False,
                                                 compound=compound)
         assert_in_box(cogpos, group.dimensions)
Beispiel #4
0
 def test_wrap_atoms(self, u):
     ag = u.atoms[100:200]
     rescom = ag.wrap(compound='atoms', center='com', inplace=False)
     assert_in_box(rescom, u.dimensions)
     rescog = ag.wrap(compound='atoms', center='cog', inplace=False)
     assert_almost_equal(rescom, rescog, decimal=self.precision)
Beispiel #5
0
 def test_wrap_large_box(self, u):
     ag = u.atoms[:100]
     box = u.dimensions
     box[:3] *= 2.0
     ag.wrap(box=box)
     assert_in_box(ag.positions, box)
Beispiel #6
0
 def test_wrap_small_box(self, u):
     ag = u.atoms[:100]
     box = u.dimensions
     box[:3] *= 0.5
     ag.wrap(box=box)
     assert_in_box(ag.positions, box)