示例#1
0
def test_no_hydrogens():
    
    traj = Trajectory.load(ref_file('ala2.pdb'))
    
    num_molecules = 1
    detector = xray.Detector.generic()
    detector.beam.photons_scattered_per_shot = 1e3

    I_noH = scatter.simulate_shot(traj, num_molecules, detector, 
                                  ignore_hydrogens=True,
                                  dont_rotate=True)
    I_wH  = scatter.simulate_shot(traj, num_molecules, detector, 
                                  ignore_hydrogens=False,
                                  dont_rotate=True)
                                  
    assert not np.all(I_noH == I_wH)
    
    # compute the differece -- we're not setting random numbers here so just
    # looking at radially averaged stuff...
    diff = np.sum(np.abs(I_noH - I_wH) / I_wH) / float(len(I_wH))
    print diff
    assert diff < 1.0, 'ignoring hydrogens makes too big of a difference...'
示例#2
0
    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
示例#3
0
    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 ))
示例#4
0
文件: cdi.py 项目: jadeshi/odin
    def __call__(self, trajectory):
        """
        Return the system 'energy'.
        
        Parameters
        ----------
        """

        self._check_is_traj(trajectory)
        
        energies = np.zeros(trajectory.n_frames)
        
        for i in range(trajectory.n_frames):
            prediction = scatter.simulate_shot(trajectory[i], 1, self.qxyz,
                                               force_no_gpu=self._no_gpu, 
                                               device_id=self._device_id)
        
            energies[i] = np.sum( np.square(prediction - self.intensities) / 
                                  (2.0 * self.sigma) ) / float(len(prediction))
        
        return energies
示例#5
0
test_system = 'ala'  # 'ala' OR 'lyz'
prior = 'amber99min.xml'
num_moves = 1000
sigma = 1000.0  # hmmmm
# ------------------------------------------

if test_system == 'ala':
    structure_file = 'ala2.pdb'
    dtc = thor.Detector.generic()

elif test_system == 'lyz':
    structure_file = '3lyz.clean.pdb'
    dtc = thor.Detector.load('lcls_test.dtc')

else:
    raise KeyError('no known test system: %s' % test_system)

starting_structure = mdtraj.load(structure_file)
qxyz = dtc.reciprocal
intensities = scatter.simulate_shot(starting_structure, 1, qxyz)

potential = cdi.CdiPotential(intensities, qxyz, sigma)

sampler = sample.MDMC(potential, prior, starting_structure.top,
                      starting_structure.xyz[0])

sampler.sample(num_moves, 'test_traj.h5')

t = mdtraj.load('test_traj.h5')
t.save_pdb('test_traj.pdb')
示例#6
0
 def _compute_Sq( self, traj, q_values, dont_rotate):
     qxyz = self._get_qxyz_on_unit_sphere()
     self.S_q = np.zeros( (self.q_values.shape[0], qxyz.shape[0]) )
     for i,q in enumerate(self.q_values):
         self.S_q[i,:] = simulate_shot(self.model, 1, q*qxyz, dont_rotate=dont_rotate, force_no_gpu=True)
     self.S_q = self.S_q.reshape( self.n_q, self.n_theta, self.n_phi )
示例#7
0
sigma       = 1000.0 # hmmmm
# ------------------------------------------

if test_system == 'ala':
    structure_file = 'ala2.pdb'
    dtc = thor.Detector.generic()
    
elif test_system == 'lyz':
    structure_file = '3lyz.clean.pdb'
    dtc = thor.Detector.load('lcls_test.dtc')
    
else:
    raise KeyError('no known test system: %s' % test_system)
    
    
starting_structure = mdtraj.load(structure_file)
qxyz = dtc.reciprocal
intensities = scatter.simulate_shot(starting_structure, 1, qxyz)

potential = cdi.CdiPotential(intensities, qxyz, sigma)

sampler = sample.MDMC(potential, prior, 
                      starting_structure.top, 
                      starting_structure.xyz[0])
               
sampler.sample(num_moves, 'test_traj.h5')

t = mdtraj.load('test_traj.h5')
t.save_pdb('test_traj.pdb')