コード例 #1
0
ファイル: test_xml.py プロジェクト: gkiss/mdtraj
def test_0():
    t1 = load(get_fn('native2.xml'), top=get_fn('native2.pdb'))
    t2 = load(get_fn('native2.pdb'))

    t1.center_coordinates()
    t2.center_coordinates()

    yield lambda: eq(t1.xyz, t2.xyz)
    yield lambda: eq(t1.unitcell_vectors, t2.unitcell_vectors)
コード例 #2
0
ファイル: test_xray2.py プロジェクト: sdoniach/odin
    def setup(self):

        self.q_values  = np.array([1.0, 2.0])
        self.num_phi   = 360
        self.traj      = trajectory.load(ref_file('ala2.pdb'))
        self.num_shots = 2

        # generate the tables file on disk, then re-open it
        intensities = np.abs( np.random.randn(self.num_shots, len(self.q_values),
                                              self.num_phi) / 100.0 + \
                              np.cos( np.linspace(0.0, 4.0*np.pi, self.num_phi) ) )

        if os.path.exists('tmp_tables.h5'):
            os.remove('tmp_tables.h5')
            
        hdf = tables.File('tmp_tables.h5', 'w')
        a = tables.Atom.from_dtype(np.dtype(np.float64))
        node = hdf.createEArray(where='/', name='data',
                                shape=(0, len(self.q_values), self.num_phi), 
                                atom=a, filters=io.COMPRESSION)
        node.append(intensities)
        hdf.close()

        self.tables_file = tables.File('tmp_tables.h5', 'r+')
        pi = self.tables_file.root.data
        pm = np.random.binomial(1, 0.9, size=(len(self.q_values), self.num_phi))
        k = 1.0
        
        self.rings = xray.Rings(self.q_values, pi, k, pm)

        return
コード例 #3
0
ファイル: test_xray.py プロジェクト: sdoniach/odin
 def setup(self):
     self.q_values  = np.array([1.0, 2.0])
     self.num_phi   = 360
     self.traj      = trajectory.load(ref_file('ala2.pdb'))
     self.num_shots = 2
     self.rings     = xray.Rings.simulate(self.traj, 1, self.q_values,
                                          self.num_phi, self.num_shots) # 1 molec
コード例 #4
0
def test_rm_com():
    t = trajectory.load( ref_file('ala2.pdb') )
    r = structure.remove_COM(t)
    
    masses = [ a.element.mass for a in t.topology.atoms() ]
    
    for i in range(t.n_frames):
        assert_array_almost_equal(np.zeros(3), np.average(t.xyz[i,:,:], weights=masses, axis=0))
コード例 #5
0
 def setup(self):
     self.q_values = np.array([1.0, 2.0])
     self.num_phi = 360
     self.traj = trajectory.load(ref_file('ala2.pdb'))
     self.num_shots = 2
     self.rings = xray.Rings.simulate(self.traj, 1, self.q_values,
                                      self.num_phi,
                                      self.num_shots)  # 1 molec
コード例 #6
0
 def setup(self):
     self.q_values = np.array([1.0, 2.0])
     self.num_phi = 360
     self.l = 50.0
     self.d = xray.Detector.generic(spacing=0.4, l=self.l)
     self.i = np.abs(np.random.randn(self.d.num_pixels))
     self.t = trajectory.load(ref_file('ala2.pdb'))
     self.shot = xray.Shotset(self.i, self.d)
コード例 #7
0
ファイル: test_xray.py プロジェクト: rinkelp/odin
 def setup(self):
     self.q_values = np.array([1.0, 2.0])
     self.num_phi  = 360
     self.l = 50.0
     self.d = xray.Detector.generic(spacing=0.4, l=self.l)
     self.i = np.abs( np.random.randn(self.d.num_pixels) )
     self.t = trajectory.load(ref_file('ala2.pdb'))
     self.shot = xray.Shotset(self.i, self.d)
コード例 #8
0
ファイル: test_structure.py プロジェクト: dermen/odin
def test_rm_com():
    t = trajectory.load( ref_file('ala2.pdb') )
    r = structure.remove_COM(t)
    
    masses = [ a.element.mass for a in t.topology.atoms() ]
    
    for i in range(t.n_frames):
        assert_array_almost_equal(np.zeros(3), np.average(t.xyz[i,:,:], weights=masses, axis=0))
コード例 #9
0
ファイル: test_scatter.py プロジェクト: ratnerd0/odin
    def test_python_call(self):
        print "testing python wrapper fxn..."
        
        traj = trajectory.load(ref_file('ala2.pdb'))
        num_molecules = 512
        detector = Detector.generic()

        py_I = xray.simulate_shot(traj, num_molecules, detector, verbose=True)
コード例 #10
0
def test_replicate():
    if TRAVIS: raise SkipTest
    cmd = 'replicate -i %s -n 10 -d 0.1 > /dev/null 2>&1' % ref_file('goldBenchMark.coor')
    subprocess.check_call(cmd, shell=True)
    if not os.path.exists('replicated.pdb'):
        raise RuntimeError('no output produced')
    else:
        o = trajectory.load('replicated.pdb')
        os.remove('replicated.pdb')
コード例 #11
0
def test_solvate():
    if not OPENMM: raise SkipTest
    if TRAVIS: raise SkipTest
    cmd = 'solvate -i %s > /dev/null 2>&1' % ref_file('ala2.pdb')
    subprocess.check_call(cmd, shell=True)
    if not os.path.exists('solvated.pdb'):
        raise RuntimeError('no output produced')
    else:
        o = trajectory.load('solvated.pdb')
        os.remove('solvated.pdb')
コード例 #12
0
    def setup(self):

        self.t = trajectory.load(ref_file('ala2.pdb'))

        # make a fake restraint array
        self.restraint_array = np.zeros((2, 4))
        self.restraint_array[0, :] = np.array([0, 5, 1.0, 1])
        self.restraint_array[1, :] = np.array([4, 10, 10.0, 0])

        self.dr = exptdata.DistanceRestraint(self.restraint_array)
コード例 #13
0
ファイル: test_scripts.py プロジェクト: dermen/odin
def test_solvate():
    if not OPENMM: raise SkipTest
    if TRAVIS: raise SkipTest
    cmd = 'solvate -i %s > /dev/null 2>&1' % ref_file('ala2.pdb')
    subprocess.check_call(cmd, shell=True)
    if not os.path.exists('solvated.pdb'):
        raise RuntimeError('no output produced')
    else:
        o = trajectory.load('solvated.pdb')
        os.remove('solvated.pdb')
コード例 #14
0
ファイル: test_exptdata.py プロジェクト: dermen/odin
 def setup(self):
     
     self.t = trajectory.load( ref_file('ala2.pdb') )
     
     # make a fake restraint array
     self.restraint_array = np.zeros((2,4))
     self.restraint_array[0,:] = np.array([0, 5,   1.0, 1])
     self.restraint_array[1,:] = np.array([4, 10, 10.0, 0])
     
     self.dr = exptdata.DistanceRestraint(self.restraint_array)
コード例 #15
0
ファイル: test_structure.py プロジェクト: dermen/odin
def test_load_coor():
    
    s = structure.load_coor( ref_file('goldBenchMark.coor') )
    s.save('s.pdb')
    t = trajectory.load('s.pdb')
    
    assert_array_almost_equal(s.xyz, t.xyz, decimal=3)
    
    for a in t.topology.atoms():
        assert a.element.symbol == 'Au'
        
    if os.path.exists('s.pdb'):
        os.remove('s.pdb')
コード例 #16
0
def test_load_coor():
    
    s = structure.load_coor( ref_file('goldBenchMark.coor') )
    s.save('s.pdb')
    t = trajectory.load('s.pdb')
    
    assert_array_almost_equal(s.xyz, t.xyz, decimal=3)
    
    for a in t.topology.atoms():
        assert a.element.symbol == 'Au'
        
    if os.path.exists('s.pdb'):
        os.remove('s.pdb')
コード例 #17
0
ファイル: test_scatter.py プロジェクト: rinkelp/odin
    def test_py_cpu_smoke(self):

        traj = trajectory.load(ref_file('ala2.pdb'))
        
        num_molecules = 1
        detector = xray.Detector.generic()
        detector.beam.photons_scattered_per_shot = 1e3

        I = scatter.simulate_shot(traj, num_molecules, detector, 
                                  finite_photon=True)
                                          
        # simple statistical sanity check
        assert np.abs(I.sum() - detector.beam.photons_scattered_per_shot) < \
                           np.sqrt(detector.beam.photons_scattered_per_shot)*6.0
コード例 #18
0
ファイル: test_scatter.py プロジェクト: rinkelp/odin
    def test_python_call(self):
        """
        Test the GPU scattering simulation interface (scatter.simulate)
        """

        if not GPU: raise SkipTest
        print "testing python wrapper fxn..."
        
        traj = trajectory.load(ref_file('ala2.pdb'))
        num_molecules = 512
        detector = xray.Detector.generic()

        py_I = scatter.simulate_shot(traj, num_molecules, detector)

        assert not np.all( py_I == 0.0 )
        assert not np.isnan(np.sum( py_I ))
コード例 #19
0
ファイル: test_scatter.py プロジェクト: sdoniach/odin
    def test_python_call(self):
        """
        Test the GPU scattering simulation interface (scatter.simulate)
        """

        if not GPU: raise SkipTest
        print "testing python wrapper fxn..."

        traj = trajectory.load(ref_file('ala2.pdb'))
        num_molecules = 512
        detector = xray.Detector.generic()

        py_I = scatter.simulate_shot(traj, num_molecules, detector)

        assert not np.all(py_I == 0.0)
        assert not np.isnan(np.sum(py_I))
コード例 #20
0
ファイル: test_xray2.py プロジェクト: sdoniach/odin
 def setup(self):
     
     self.q_values = np.array([1.0, 2.0])
     self.num_phi  = 360
     self.l = 50.0
     self.d = xray.Detector.generic(spacing=0.4, l=self.l)
     self.t = trajectory.load(ref_file('ala2.pdb'))
     
     self.num_shots = 2
     intensities = np.abs(np.random.randn(self.num_shots, self.d.num_pixels))
     io.saveh('tmp_tables.h5', data=intensities)
     
     self.tables_file = tables.File('tmp_tables.h5')
     self.i = self.tables_file.root.data
     
     self.shot = xray.Shotset(self.i, self.d)
     
     return
コード例 #21
0
ファイル: test_xray.py プロジェクト: ratnerd0/odin
 def setup(self):
     self.d = xray.Detector.generic(spacing=0.3)
     self.t = trajectory.load(ref_file('ala2.pdb'))
コード例 #22
0
def test_m_confs():
    # smoke test
    t = trajectory.load( ref_file('ala2.pdb') )
    m = structure.multiply_conformations(t, 10, 1.0)
コード例 #23
0
ファイル: interp_check.py プロジェクト: tjlane/odin-misc
#!/usr/bin/env python

import numpy as np

from odin import xray
from odin import _cpuscatter
from mdtraj import trajectory

import matplotlib.pyplot as plt

q_values = [1.4]

traj = trajectory.load('3LYZ.pdb')
xyzlist = traj.xyz[0]
atomic_numbers = np.array([ a.element.atomic_number for a in traj.topology.atoms() ])


b = xray.Beam(None, energy=10.) # same as was used to make reference.dtc
pol_q_grid = xray._q_grid_as_xyz(q_values, 360, b.k)

dtc = xray.load('reference.dtc')
dtc_q_grid = dtc.reciprocal


num_molecules = 1

rfloats = np.random.rand(num_molecules, 3)
pol_i = _cpuscatter.simulate(num_molecules, pol_q_grid, xyzlist, 
                             atomic_numbers, rfloats=rfloats)
dtc_i = _cpuscatter.simulate(num_molecules, dtc_q_grid, xyzlist, 
                             atomic_numbers, rfloats=rfloats)
def convert_dcd_xtc(pdb_name, dcd_name, xtc_name):
  t = trajectory.load(dcd_name, top=pdb_name)
  t.save(xtc_name)
コード例 #25
0
def convert_dcd_xtc(pdb_name, dcd_name, xtc_name):
    t = trajectory.load(dcd_name, top=pdb_name)
    t.save(xtc_name)
コード例 #26
0
ファイル: t_polar.py プロジェクト: tjlane/odin-misc
import numpy as np

from odin import xray
from mdtraj import trajectory

import matplotlib.pyplot as plt

t = trajectory.load('reference/ala2.pdb')

dp = xray.Detector.generic_polar(q_lim=0.6)
xp = xray.Shot.simulate(t, 10, dp)

dc = xray.Detector.generic(spacing=0.6)
xc = xray.Shot.simulate(t, 10, dc)

# make sure it matches up decently with non-polar
ref = xc.I_ring(0.4)
pol = xp.I_ring(0.4)
ref = ref * (pol[0]/ref[0]) # scale them to be the same-ish

print np.abs(ref - pol) / ref

plt.figure()
plt.plot(ref, lw=2)
plt.plot(pol, lw=2)
plt.show()
コード例 #27
0
ファイル: test_structure.py プロジェクト: dermen/odin
def test_m_confs():
    # smoke test
    t = trajectory.load( ref_file('ala2.pdb') )
    m = structure.multiply_conformations(t, 10, 1.0)