Exemplo n.º 1
0
    def test_2(self):
        try:
            subprocess.Popen('ipcluster start --cluster-id=testclusterid --n=1 --daemonize', shell=True)
            time.sleep(5)
            
            args = self.Args()
            args.output_dir = tempfile.mkdtemp()
            args.cluster_id = 'testclusterid'

            logger = AssignParallel.setup_logger()
            AssignParallel.main(args, self.metric, logger)

            assignments = Serializer.load_data(os.path.join(args.output_dir, 'Assignments.h5'))
            r_assignments = Serializer.load_data(os.path.join(fixtures_dir(), 'Assignments.h5'))
            distances = Serializer.load_data(os.path.join(args.output_dir, 'Assignments.h5.distances'))
            r_distances = Serializer.load_data(os.path.join(fixtures_dir(), 'Assignments.h5.distances')) 

            npt.assert_array_equal(assignments, r_assignments)
            npt.assert_array_almost_equal(distances, r_distances)
        
        except:
            raise
        finally:
            shutil.rmtree(args.output_dir)
            subprocess.Popen('ipcluster stop', shell=True).wait()
Exemplo n.º 2
0
    def test_2(self):
        try:
            subprocess.Popen(
                'ipcluster start --cluster-id=testclusterid --n=1 --daemonize',
                shell=True)
            time.sleep(5)

            args = self.Args()
            args.output_dir = tempfile.mkdtemp()
            args.cluster_id = 'testclusterid'

            logger = AssignParallel.setup_logger()
            AssignParallel.main(args, self.metric, logger)

            assignments = io.loadh(
                os.path.join(args.output_dir, 'Assignments.h5'), 'arr_0')
            r_assignments = io.loadh(
                os.path.join(fixtures_dir(), 'Assignments.h5'), 'Data')
            distances = io.loadh(
                os.path.join(args.output_dir, 'Assignments.h5.distances'),
                'arr_0')
            r_distances = io.loadh(
                os.path.join(fixtures_dir(), 'Assignments.h5.distances'),
                'Data')

            npt.assert_array_equal(assignments, r_assignments)
            npt.assert_array_almost_equal(distances, r_distances)

        except:
            raise
        finally:
            shutil.rmtree(args.output_dir)
            subprocess.Popen('ipcluster stop --cluster-id=testclusterid',
                             shell=True).wait()
 def setup(self):
     self.metric = metrics.Dihedral()
     self.pdb_fn = os.path.join(fixtures_dir(), 'native.pdb')
     self.trj_fn = os.path.join(fixtures_dir(), 'trj0.lh5')
     self.project = Project({'NumTrajs': 1, 'TrajLengths': [501], 'TrajFileBaseName': 'trj', 'TrajFileType': '.lh5',
                        'ConfFilename': self.pdb_fn,
                        'TrajFilePath': fixtures_dir()})
     self.vtraj = partition(self.project, chunk_size=501)[0]
Exemplo n.º 4
0
 def setup(self):
     self.metric = metrics.Dihedral()
     self.pdb_fn = os.path.join(fixtures_dir(), 'native.pdb')
     self.trj_fn = os.path.join(fixtures_dir(), 'trj0.lh5')
     self.project = Project({'traj_lengths': [501], 'traj_paths': [self.trj_fn],
                        'conf_filename': self.pdb_fn, 'traj_converted_from': [None],
                        'traj_errors': [None]})
     self.vtraj = partition(self.project, chunk_size=501)[0]
Exemplo n.º 5
0
def test_asa_3():

    traj_ref = np.loadtxt( os.path.join(reference_dir(),'g_sas_ref.dat'))
    Conf = Trajectory.load_from_pdb(os.path.join( fixtures_dir(), 'native.pdb'))

    traj = Trajectory.load_trajectory_file( os.path.join(fixtures_dir(), 'trj0.xtc') , Conf=Conf)
    traj_asa = calculate_asa(traj, probe_radius=0.14, n_sphere_points = 960)
    
    # the algorithm used by gromacs' g_sas is slightly different than the one
    # used here, so the results are not exactly the same -- see the comments
    # in src/python/geomtry/asa.py or the readme file src/ext/asa/README.txt
    # for details
    npt.assert_array_almost_equal(traj_asa, traj_ref, decimal=2)    
Exemplo n.º 6
0
 def setup(self):
     self.metric = metrics.Dihedral()
     self.pdb_fn = os.path.join(fixtures_dir(), 'native.pdb')
     self.trj_fn = os.path.join(fixtures_dir(), 'trj0.lh5')
     self.project = Project({
         'NumTrajs': 1,
         'TrajLengths': [501],
         'TrajFileBaseName': 'trj',
         'TrajFileType': '.lh5',
         'ConfFilename': self.pdb_fn,
         'TrajFilePath': fixtures_dir()
     })
     self.vtraj = partition(self.project, chunk_size=501)[0]
Exemplo n.º 7
0
def test_asa_2():
    t = Trajectory.load_trajectory_file(os.path.join(fixtures_dir(), 'trj0.lh5'))
    val1 = np.sum(calculate_asa(t[0])) # calculate only frame 0
    val2 = np.sum(calculate_asa(t)[0]) # calculate on all frames
    true_frame_0_asa = 2.859646797180176
    
    npt.assert_approx_equal(true_frame_0_asa, val1)
    npt.assert_approx_equal(true_frame_0_asa, val2)
Exemplo n.º 8
0
def test_rg_1():
    project = Project.load_from(os.path.join(fixtures_dir(), 'ProjectInfo.h5'))
    traj = project.load_traj(0)
    xyzlist = traj['XYZList']

    a = rgcalc.calculate_rg(xyzlist)
    b = reference_rg(xyzlist)
    
    npt.assert_array_almost_equal(a, b)
Exemplo n.º 9
0
def test_rg_1():
    project = Project.load_from(os.path.join(fixtures_dir(), 'ProjectInfo.h5'))
    traj = project.load_traj(0)
    xyzlist = traj['XYZList']

    a = rgcalc.calculate_rg(xyzlist)
    b = reference_rg(xyzlist)

    npt.assert_array_almost_equal(a, b)
Exemplo n.º 10
0
def test_traj_0():
    
    aind = np.unique( np.random.randint( 22, size=4) )
    stride = np.random.randint(1, 100 )
    
    r_traj = Trajectory.load_from_lhdf( os.path.join( fixtures_dir(), 'trj0.lh5' ), Stride=1 )

    r_traj.restrict_atom_indices( aind )

    r_traj['XYZList'] = r_traj['XYZList'][ ::stride ]

    traj = Trajectory.load_from_lhdf( os.path.join( fixtures_dir(), 'trj0.lh5' ), Stride = stride, AtomIndices = aind )

    for key in traj.keys():
        if key in ['SerializerFilename'] :
            continue
        
        if key in ['IndexList']:
            for row, r_row in zip( traj[key], r_traj[key] ):
                npt.assert_array_equal( row, r_row )
        elif key == 'XYZList':
            npt.assert_array_almost_equal( traj[key], r_traj[key])
        else:
            npt.assert_array_equal( traj[key], r_traj[key] )
Exemplo n.º 11
0
 class Args:
     project = os.path.join(fixtures_dir(), 'ProjectInfo.h5')
     generators = os.path.join(fixtures_dir(), 'Gens.lh5')
     profile = 'default'
     cluster_id = ''
     chunk_size = 10