示例#1
0
    def moveSystem(self, moveVector):
        """move all the atoms in the loaded file

        Args:
            moveVector (np.array, 3, float): the vector of moving
        """

        allAtoms = self.uObject.select_atoms('all')
        transformations.translate(moveVector)(allAtoms)
示例#2
0
def test_translate_coords(translate_universes):
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    vector = np.float32([1, 2, 3])
    ref.positions += vector
    trans = translate(vector)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
示例#3
0
def test_translate_coords(translate_universes):
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    vector = np.float32([1, 2, 3])
    ref.positions += vector
    trans = translate(vector)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
示例#4
0
def test_translate_transformations_api(translate_universes):
    # test if the translate transformation works when using the 
    # on-the-fly transformations API
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    vector = np.float32([1, 2, 3])
    ref.positions += vector
    trans_u.trajectory.add_transformations(translate(vector))
    assert_array_almost_equal(trans_u.trajectory.ts.positions, ref.positions, decimal=6)
示例#5
0
def test_translate_transformations_api(translate_universes):
    # test if the translate transformation works when using the
    # on-the-fly transformations API
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    vector = np.float32([1, 2, 3])
    ref.positions += vector
    trans_u.trajectory.add_transformations(translate(vector))
    assert_array_almost_equal(trans_u.trajectory.ts.positions,
                              ref.positions,
                              decimal=6)
示例#6
0
文件: base.py 项目: zemanj/mdanalysis
 def transformed(ref):
     transformed = ref.reader(ref.trajectory)
     transformed.add_transformations(translate([1, 1, 1]),
                                     translate([0, 0, 0.33]))
     return transformed
示例#7
0
 def transformed(ref):
     return mda.Universe(PSF,
                         [DCD, CRD, DCD, CRD, DCD, CRD, CRD],
                         transformations=[translate([10,10,10])])
示例#8
0
 def transformed(ref):
     transformed = ref.reader(ref.trajectory, convert_units=False)
     transformed.add_transformations(translate([1, 1, 1]),
                                     translate([0, 0, 0.33]))
     return transformed
示例#9
0
def test_translate_vector(translate_universes, vector):
    # what happens if the vector argument is of wrong size?
    ts = translate_universes[0].trajectory.ts
    with pytest.raises(ValueError):
        translate(vector)(ts)
示例#10
0
 def test_add_another_transformations_raises_ValueError(self, transformed):
     # After defining the transformations, the workflow cannot be changed
     with pytest.raises(ValueError):
         transformed.add_transformations(translate([2,2,2]))
示例#11
0
 def test_list(self):
     workflow = [translate([10, 10, 0]), translate([0, 0, 10])]
     u = mda.Universe(PSF, DCD, transformations=workflow)
     uref = mda.Universe(PSF, DCD)
     ref = translate([10, 10, 10])(uref.trajectory.ts)
     assert_almost_equal(u.trajectory.ts.positions, ref, decimal=6)
示例#12
0
def test_translate_vector(translate_universes, vector):
    # what happens if the vector argument is of wrong size?
    ts = translate_universes[0].trajectory.ts
    with pytest.raises(ValueError):
        translate(vector)(ts)
示例#13
0
 def test_list(self):
     workflow = [translate([10,10,0]), translate([0,0,10])]
     u = mda.Universe(PSF,DCD, transformations=workflow)
     uref = mda.Universe(PSF,DCD)
     ref = translate([10,10,10])(uref.trajectory.ts)
     assert_almost_equal(u.trajectory.ts.positions, ref, decimal=6)
示例#14
0
 def test_callable(self):
     u = mda.Universe(PSF,DCD, transformations=translate([10,10,10]))
     uref = mda.Universe(PSF,DCD)
     ref = translate([10,10,10])(uref.trajectory.ts)
     assert_almost_equal(u.trajectory.ts.positions, ref, decimal=6)
示例#15
0
文件: wrap.py 项目: YouriRan/bpoc
import sys
import numpy as np

import MDAnalysis as mda
from MDAnalysis.analysis import align
import MDAnalysis.transformations as trans
from MDAnalysis.analysis.leaflet import LeafletFinder

u = mda.Universe(sys.argv[1] + '.data', sys.argv[1] + '.xtc')
ref = mda.Universe(sys.argv[1] + '.data')

# Get box dimensions from first frame
b = u.trajectory[0].dimensions[0:3]
bbox = np.array([0, 0, 0, b[0], b[1], b[2]]).reshape(2, 3)

# Align all frames to first frame on PH beads
alignment = mda.analysis.align.AlignTraj(u, ref, select='type 2')
alignment.run()

# Translate box to centre buckle
translator = [0.5 * bbox[1, 0], 0.5 * bbox[1, 1], 0.5 * bbox[1, 2]]

# Feed transformations to trajectory
wf = [trans.translate(translator), trans.wrap(u.atoms, compound='residues')]
u.trajectory.add_transformations(*wf)

# Write output
u.atoms.write(sys.argv[1] + '_wrap.xtc', frames=u.trajectory[:])
示例#16
0
文件: base.py 项目: zemanj/mdanalysis
 def test_add_another_transformations_raises_ValueError(self, transformed):
     # After defining the transformations, the workflow cannot be changed
     with pytest.raises(ValueError):
         transformed.add_transformations(translate([2, 2, 2]))
示例#17
0
 def test_callable(self):
     u = mda.Universe(PSF, DCD, transformations=translate([10, 10, 10]))
     uref = mda.Universe(PSF, DCD)
     ref = translate([10, 10, 10])(uref.trajectory.ts)
     assert_almost_equal(u.trajectory.ts.positions, ref, decimal=6)
示例#18
0
 def transformed(ref):
     transformed = ref.reader(ref.trajectory, convert_units=False)
     transformed.add_transformations(translate([1,1,1]), translate([0,0,0.33]))
     return transformed
示例#19
0
 def transformed(ref):
     return mda.Universe(PSF,
                         [DCD, CRD, DCD, CRD, DCD, CRD, CRD],
                         transformations=[translate([10,10,10])])
示例#20
0
 def transformed(ref):
     transformed = ref.reader(ref.trajectory)
     transformed.add_transformations(translate([1,1,1]), translate([0,0,0.33]))
     return transformed