Beispiel #1
0
    def test_copy_spin_between_pipes(self):
        """Test the copying of the spin data between different data pipes.

        The function tested is both pipe_control.mol_res_spin.copy_spin() and
        prompt.spin.copy().
        """

        # Copy the spin data.
        self.spin_fns.copy(spin_from='#Old mol:1@C8', pipe_to='test')

        # Get the data pipes.
        dp = pipes.get_pipe('orig')
        dp_test = pipes.get_pipe('test')

        # Change the first spin's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()

        # Test the original spin.
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new spin.
        self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)
Beispiel #2
0
    def test_copy(self):
        """The user function diffusion_tensor.copy()."""

        # Create three additional data pipes for copying the spherical, spheroidal, and ellipsoidal diffusion data.
        self.interpreter.pipe.create('sphere2', 'mf')
        self.interpreter.pipe.create('spheroid2', 'mf')
        self.interpreter.pipe.create('ellipsoid2', 'mf')

        # Copy the data.
        self.interpreter.diffusion_tensor.copy('sphere', 'sphere2')
        self.interpreter.diffusion_tensor.copy('spheroid', 'spheroid2')
        self.interpreter.diffusion_tensor.copy('ellipsoid', 'ellipsoid2')

        # Get the data pipes.
        sphere_pipe = get_pipe('sphere')
        sphere2_pipe = get_pipe('sphere2')

        # Check that this is indeed a copy.
        self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8)
        self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8))
        sphere_pipe.diff_tensor.set(param='tm', value=8.88e-8, category='sim', sim_index=4)
        self.assertEqual(sphere_pipe.diff_tensor.tm_sim[4], 8.88e-8)
        self.assertEqual(sphere_pipe.diff_tensor.Diso_sim[4], 1/(6*8.88e-8))
        self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8)
        self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8))
Beispiel #3
0
    def test_value_diff(self):
        """S2 difference stored in a new data pipe."""

        # Init.
        pipe_list = ['orig1', 'orig2', 'new']
        s2 = [0.9, 0.7, None]

        # Loop over the data pipes to create and fill.
        for i in range(3):
            # Create the data pipe.
            self.interpreter.pipe.create(pipe_list[i], 'mf')

            # Load the Lupin Ap4Aase sequence.
            self.interpreter.sequence.read(file="Ap4Aase.seq", dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2)

            # Only select residue 8.
            self.interpreter.select.spin(spin_id=':8', change_all=True)

            # Set the order parameter value.
            if s2[i]:
                self.interpreter.value.set(s2[i], 's2', spin_id=':8')

        # Get the data pipes.
        dp_orig1 = pipes.get_pipe('orig1')
        dp_orig2 = pipes.get_pipe('orig2')
        dp_new = pipes.get_pipe('new')

        # Calculate the difference and assign it to residue 8 (located in position 7).
        diff = dp_orig1.mol[0].res[7].spin[0].s2 - dp_orig2.mol[0].res[7].spin[0].s2
        self.interpreter.value.set(diff, 's2', spin_id=':8')

        # Test if the difference is 0.2!
        self.assertAlmostEqual(dp_new.mol[0].res[7].spin[0].s2, 0.2)
Beispiel #4
0
    def test_load_and_modify(self):
        """The modification of an unpickled and restored relax data storage singleton.

        This tests the normal operation of the pipe_control.state.load() function.
        """

        # Test the contents of the empty singleton.
        self.assertEqual(list(ds.keys()), [])
        self.assertEqual(pipes.cdp_name(), None)
        self.assert_(not hasattr(ds, 'y'))

        # Load the state.
        self.state.load_state(state='basic_single_pipe',
                              dir=status.install_path + sep + 'test_suite' +
                              sep + 'shared_data' + sep + 'saved_states')

        # Add a new data pipe and some data to it.
        ds.add('new', 'jw_mapping')
        cdp.z = [None, None]

        # Get the data pipes.
        dp_orig = pipes.get_pipe('orig')
        dp_new = pipes.get_pipe('new')

        # Test the contents of the restored singleton (with subsequent data added).
        self.assert_('orig' in ds)
        self.assert_('new' in ds)
        self.assertEqual(pipes.cdp_name(), 'new')
        self.assertEqual(dp_orig.x, 1)
        self.assertEqual(ds.y, 'Hello')
        self.assertEqual(dp_new.z, [None, None])
Beispiel #5
0
    def duplicate_data(self, pipe_from=None, pipe_to=None, model_info=None, global_stats=False, verbose=True):
        """Duplicate the data specific to a single hybrid data pipe.

        @keyword pipe_from:     The data pipe to copy the data from.
        @type pipe_from:        str
        @keyword pipe_to:       The data pipe to copy the data to.
        @type pipe_to:          str
        @keyword model_info:    The model information from model_loop().
        @type model_info:       unknown
        @keyword global_stats:  The global statistics flag.
        @type global_stats:     bool
        @keyword verbose:       A flag which if True will cause info to be printed out.
        @type verbose:          bool
        """

        # First create the pipe_to data pipe, if it doesn't exist, but don't switch to it.
        if not pipes.has_pipe(pipe_to):
            pipes.create(pipe_to, pipe_type='hybrid', switch=False)

        # Get the data pipes.
        dp_from = pipes.get_pipe(pipe_from)
        dp_to = pipes.get_pipe(pipe_to)

        # Test that the target data pipe has no sequence loaded.
        if not exists_mol_res_spin_data(pipe_to):
            raise RelaxSequenceError(pipe_to)

        # Duplicate the hybrid pipe list data structure.
        dp_to.hybrid_pipes = dp_from.hybrid_pipes
Beispiel #6
0
    def test_copy_spin_between_pipes(self):
        """Test the copying of the spin data between different data pipes.

        The function tested is both pipe_control.mol_res_spin.copy_spin() and
        prompt.spin.copy().
        """

        # Copy the spin data.
        self.spin_fns.copy(spin_from='#Old mol:1@C8', pipe_to='test')

        # Get the data pipes.
        dp = pipes.get_pipe('orig')
        dp_test = pipes.get_pipe('test')

        # Change the first spin's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()

        # Test the original spin.
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new spin.
        self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)
Beispiel #7
0
    def test_value_diff(self):
        """S2 difference stored in a new data pipe."""

        # Init.
        pipe_list = ['orig1', 'orig2', 'new']
        s2 = [0.9, 0.7, None]

        # Loop over the data pipes to create and fill.
        for i in range(3):
            # Create the data pipe.
            self.interpreter.pipe.create(pipe_list[i], 'mf')

            # Load the Lupin Ap4Aase sequence.
            self.interpreter.sequence.read(file="Ap4Aase.seq", dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2)

            # Only select residue 8.
            self.interpreter.select.spin(spin_id=':8', change_all=True)

            # Set the order parameter value.
            if s2[i]:
                self.interpreter.value.set(s2[i], 's2', spin_id=':8')

        # Get the data pipes.
        dp_orig1 = pipes.get_pipe('orig1')
        dp_orig2 = pipes.get_pipe('orig2')
        dp_new = pipes.get_pipe('new')

        # Calculate the difference and assign it to residue 8 (located in position 7).
        diff = dp_orig1.mol[0].res[7].spin[0].s2 - dp_orig2.mol[0].res[7].spin[0].s2
        self.interpreter.value.set(diff, 's2', spin_id=':8')

        # Test if the difference is 0.2!
        self.assertAlmostEqual(dp_new.mol[0].res[7].spin[0].s2, 0.2)
    def test_load_and_modify(self):
        """The modification of an unpickled and restored relax data storage singleton.

        This tests the normal operation of the pipe_control.state.load() function.
        """

        # Test the contents of the empty singleton.
        self.assertEqual(list(ds.keys()), [])
        self.assertEqual(pipes.cdp_name(), None)
        self.assert_(not hasattr(ds, 'y'))

        # Load the state.
        self.state.load_state(state='basic_single_pipe', dir=status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'saved_states')

        # Add a new data pipe and some data to it.
        ds.add('new', 'jw_mapping')
        cdp.z = [None, None]

        # Get the data pipes.
        dp_orig = pipes.get_pipe('orig')
        dp_new = pipes.get_pipe('new')

        # Test the contents of the restored singleton (with subsequent data added).
        self.assert_('orig' in ds)
        self.assert_('new' in ds)
        self.assertEqual(pipes.cdp_name(), 'new')
        self.assertEqual(dp_orig.x, 1)
        self.assertEqual(ds.y, 'Hello')
        self.assertEqual(dp_new.z, [None, None])
Beispiel #9
0
def consistent_interatomic_data(pipe1=None, pipe2=None):
    """Check that the interatomic data is consistent between two data pipes.

    @keyword pipe1:     The name of the first data pipe to compare.
    @type pipe1:        str
    @keyword pipe2:     The name of the second data pipe to compare.
    @type pipe2:        str
    @raises RelaxError: If the data is inconsistent.
    """

    # Get the data pipes.
    dp1 = pipes.get_pipe(pipe1)
    dp2 = pipes.get_pipe(pipe2)

    # Check the data lengths.
    if len(dp1.interatomic) != len(dp2.interatomic):
        raise RelaxInteratomInconsistentError(pipe1, pipe2)

    # Loop over the interatomic data.
    for i in range(len(dp1.interatomic)):
        # Alias the containers.
        interatom1 = dp1.interatomic[i]
        interatom2 = dp2.interatomic[i]

        # Check the spin IDs.
        if interatom1.spin_id1 != interatom2.spin_id1:
            raise RelaxInteratomInconsistentError(pipe1, pipe2)
        if interatom1.spin_id2 != interatom2.spin_id2:
            raise RelaxInteratomInconsistentError(pipe1, pipe2)
Beispiel #10
0
    def test_copy(self):
        """The user function diffusion_tensor.copy()."""

        # Create three additional data pipes for copying the spherical, spheroidal, and ellipsoidal diffusion data.
        self.interpreter.pipe.create('sphere2', 'mf')
        self.interpreter.pipe.create('spheroid2', 'mf')
        self.interpreter.pipe.create('ellipsoid2', 'mf')

        # Copy the data.
        self.interpreter.diffusion_tensor.copy('sphere', 'sphere2')
        self.interpreter.diffusion_tensor.copy('spheroid', 'spheroid2')
        self.interpreter.diffusion_tensor.copy('ellipsoid', 'ellipsoid2')

        # Get the data pipes.
        sphere_pipe = get_pipe('sphere')
        sphere2_pipe = get_pipe('sphere2')

        # Check that this is indeed a copy.
        self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8)
        self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8))
        sphere_pipe.diff_tensor.set(param='tm', value=8.88e-8, category='sim', sim_index=4)
        self.assertEqual(sphere_pipe.diff_tensor.tm_sim[4], 8.88e-8)
        self.assertEqual(sphere_pipe.diff_tensor.Diso_sim[4], 1/(6*8.88e-8))
        self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8)
        self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8))
Beispiel #11
0
def consistent_interatomic_data(pipe1=None, pipe2=None):
    """Check that the interatomic data is consistent between two data pipes.

    @keyword pipe1:     The name of the first data pipe to compare.
    @type pipe1:        str
    @keyword pipe2:     The name of the second data pipe to compare.
    @type pipe2:        str
    @raises RelaxError: If the data is inconsistent.
    """

    # Get the data pipes.
    dp1 = pipes.get_pipe(pipe1)
    dp2 = pipes.get_pipe(pipe2)

    # Check the data lengths.
    if len(dp1.interatomic) != len(dp2.interatomic):
        raise RelaxInteratomInconsistentError(pipe1, pipe2)

    # Loop over the interatomic data.
    for i in range(len(dp1.interatomic)):
        # Alias the containers.
        interatom1 = dp1.interatomic[i]
        interatom2 = dp2.interatomic[i]

        # Check the spin IDs.
        if interatom1.spin_id1 != interatom2.spin_id1:
            raise RelaxInteratomInconsistentError(pipe1, pipe2)
        if interatom1.spin_id2 != interatom2.spin_id2:
            raise RelaxInteratomInconsistentError(pipe1, pipe2)
Beispiel #12
0
    def duplicate_data(self,
                       pipe_from=None,
                       pipe_to=None,
                       model_info=None,
                       global_stats=False,
                       verbose=True):
        """Duplicate the data specific to a single hybrid data pipe.

        @keyword pipe_from:     The data pipe to copy the data from.
        @type pipe_from:        str
        @keyword pipe_to:       The data pipe to copy the data to.
        @type pipe_to:          str
        @keyword model_info:    The model information from model_loop().
        @type model_info:       unknown
        @keyword global_stats:  The global statistics flag.
        @type global_stats:     bool
        @keyword verbose:       A flag which if True will cause info to be printed out.
        @type verbose:          bool
        """

        # First create the pipe_to data pipe, if it doesn't exist, but don't switch to it.
        if not pipes.has_pipe(pipe_to):
            pipes.create(pipe_to, pipe_type='hybrid', switch=False)

        # Get the data pipes.
        dp_from = pipes.get_pipe(pipe_from)
        dp_to = pipes.get_pipe(pipe_to)

        # Test that the target data pipe has no sequence loaded.
        if not exists_mol_res_spin_data(pipe_to):
            raise RelaxSequenceError(pipe_to)

        # Duplicate the hybrid pipe list data structure.
        dp_to.hybrid_pipes = dp_from.hybrid_pipes
Beispiel #13
0
    def nested_params(self, model):
        """Copy the parameters from the simpler nested models for faster optimisation.

        @param model:   The frame order model.
        @type model:    str
        """

        # The average position from the rigid model.
        if model not in []:
            # Get the rigid data pipe.
            rigid_pipe = get_pipe(self.pipe_name_dict['rigid'])

            # Copy the average position parameters from the rigid model.
            if hasattr(rigid_pipe, 'ave_pos_x'):
                cdp.ave_pos_x = rigid_pipe.ave_pos_x
            if hasattr(rigid_pipe, 'ave_pos_y'):
                cdp.ave_pos_y = rigid_pipe.ave_pos_y
            if hasattr(rigid_pipe, 'ave_pos_z'):
                cdp.ave_pos_z = rigid_pipe.ave_pos_z
            if model not in ['free rotor', 'iso cone, free rotor']:
                cdp.ave_pos_alpha = rigid_pipe.ave_pos_alpha
            cdp.ave_pos_beta = rigid_pipe.ave_pos_beta
            cdp.ave_pos_gamma = rigid_pipe.ave_pos_gamma

        # The cone axis from the rotor model.
        if model in ['iso cone']:
            # Get the rotor data pipe.
            rotor_pipe = get_pipe(self.pipe_name_dict['rotor'])

            # Copy the cone axis.
            cdp.axis_theta = rotor_pipe.axis_theta
            cdp.axis_phi = rotor_pipe.axis_phi

        # The cone axis from the free rotor model.
        if model in ['iso cone, free rotor']:
            # Get the rotor data pipe.
            free_rotor_pipe = get_pipe(self.pipe_name_dict['free rotor'])

            # Copy the cone axis.
            cdp.axis_theta = free_rotor_pipe.axis_theta
            cdp.axis_phi = free_rotor_pipe.axis_phi

        # The torsion from the rotor model.
        if model in ['iso cone', 'pseudo-ellipse']:
            # Get the rotor data pipe.
            rotor_pipe = get_pipe(self.pipe_name_dict['rotor'])

            # Copy the cone axis.
            cdp.cone_sigma_max = rotor_pipe.cone_sigma_max

        # The cone angles from from the torsionless isotropic cone model.
        if model in ['pseudo-ellipse, torsionless', 'pseudo-ellipse, free rotor', 'pseudo-ellipse']:
            # Get the rotor data pipe.
            pipe = get_pipe(self.pipe_name_dict['iso cone, torsionless'])

            # Copy the cone axis.
            cdp.cone_theta_x = pipe.cone_theta
            cdp.cone_theta_y = pipe.cone_theta
Beispiel #14
0
    def test_copy_molecule_between_pipes(self):
        """Test the copying of the molecule data between different data pipes.

        The function tested is both pipe_control.mol_res_spin.copy_molecule() and
        prompt.molecule.copy().
        """

        # Get the data pipes.
        dp = pipes.get_pipe('orig')
        dp_test = pipes.get_pipe('test')

        # Create the first molecule and residue and add some data to its spin container.
        self.molecule_fns.create('Old mol')
        create_residue(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111
        dp.mol[0].res[0].spin[0].x = 1

        # Update the metadata.
        metadata_update()

        # Copy the molecule to the second data pipe.
        self.molecule_fns.copy(mol_from='#Old mol', pipe_to='test')
        self.molecule_fns.copy(pipe_from='orig',
                               mol_from='#Old mol',
                               pipe_to='test',
                               mol_to='#New mol')

        # Change the first molecule's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()

        # Test the original molecule.
        self.assertEqual(dp.mol[0].name, 'Old mol')
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new molecule.
        self.assertEqual(dp_test.mol[0].name, 'Old mol')
        self.assertEqual(dp_test.mol[0].res[0].num, 1)
        self.assertEqual(dp_test.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)

        # Test the second new molecule.
        self.assertEqual(dp_test.mol[1].name, 'New mol')
        self.assertEqual(dp_test.mol[1].res[0].num, 1)
        self.assertEqual(dp_test.mol[1].res[0].name, 'Ala')
        self.assertEqual(dp_test.mol[1].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[1].res[0].spin[0].x, 1)
    def test_aic_mod_sel_diff_tensor(self):
        """AIC model selection between two diffusion tensors."""

        # Init.
        pipe_list = ['sphere', 'spheroid']
        tensors = [1e-9, (1e-9, 0, 0, 0)]

        # Path of the files.
        path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'

        # Loop over the data pipes.
        for i in range(2):
            # Create the data pipe.
            self.interpreter.pipe.create(pipe_list[i], 'mf')

            # Read the sequence.
            self.interpreter.sequence.read(file='r1.600.out', dir=path, res_num_col=1, res_name_col=2)

            # Select the model.
            self.interpreter.model_free.select_model(model='m4')

            # Read the relaxation data.
            self.interpreter.relax_data.read(ri_id='R1_600',  ri_type='R1',  frq=600.0*1e6, file='r1.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
            self.interpreter.relax_data.read(ri_id='R2_600',  ri_type='R2',  frq=600.0*1e6, file='r2.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
            self.interpreter.relax_data.read(ri_id='NOE_600', ri_type='NOE', frq=600.0*1e6, file='noe.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
            self.interpreter.relax_data.read(ri_id='R1_500',  ri_type='R1',  frq=500.0*1e6, file='r1.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
            self.interpreter.relax_data.read(ri_id='R2_500',  ri_type='R2',  frq=500.0*1e6, file='r2.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
            self.interpreter.relax_data.read(ri_id='NOE_500', ri_type='NOE', frq=500.0*1e6, file='noe.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)

            # Name the spins, then create all attached protons.
            self.interpreter.spin.name('N')
            self.interpreter.sequence.attach_protons()

            # Set the diffusion tensors.
            self.interpreter.diffusion_tensor.init(tensors[i], fixed=False)

        # Get the data pipes.
        dp_sphere = pipes.get_pipe('sphere')
        dp_spheroid = pipes.get_pipe('spheroid')

        # Set some global stats.
        dp_sphere.chi2 = 200
        dp_spheroid.chi2 = 0

        # Model selection.
        self.interpreter.model_selection(method='AIC', modsel_pipe='aic')

        # Get the AIC data pipe.
        dp_aic = pipes.get_pipe('aic')

        # Test if the spheroid has been selected.
        self.assert_(hasattr(dp_aic, 'diff_tensor'))
        self.assertEqual(dp_aic.diff_tensor.type, 'spheroid')
    def test_copy_molecule_between_pipes(self):
        """Test the copying of the molecule data between different data pipes.

        The function tested is both pipe_control.mol_res_spin.copy_molecule() and
        prompt.molecule.copy().
        """

        # Get the data pipes.
        dp = pipes.get_pipe('orig')
        dp_test = pipes.get_pipe('test')

        # Create the first molecule and residue and add some data to its spin container.
        self.molecule_fns.create('Old mol')
        create_residue(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111
        dp.mol[0].res[0].spin[0].x = 1

        # Update the metadata.
        metadata_update()

        # Copy the molecule to the second data pipe.
        self.molecule_fns.copy(mol_from='#Old mol', pipe_to='test')
        self.molecule_fns.copy(pipe_from='orig', mol_from='#Old mol', pipe_to='test', mol_to='#New mol')

        # Change the first molecule's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()

        # Test the original molecule.
        self.assertEqual(dp.mol[0].name, 'Old mol')
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new molecule.
        self.assertEqual(dp_test.mol[0].name, 'Old mol')
        self.assertEqual(dp_test.mol[0].res[0].num, 1)
        self.assertEqual(dp_test.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)

        # Test the second new molecule.
        self.assertEqual(dp_test.mol[1].name, 'New mol')
        self.assertEqual(dp_test.mol[1].res[0].num, 1)
        self.assertEqual(dp_test.mol[1].res[0].name, 'Ala')
        self.assertEqual(dp_test.mol[1].res[0].spin[0].num, 111)
        self.assertEqual(dp_test.mol[1].res[0].spin[0].x, 1)
    def test_copy_residue_between_molecules(self):
        """Test the copying of the residue data between different molecules.

        The function tested is both pipe_control.mol_res_spin.copy_residue() and
        prompt.residue.copy().
        """

        # Set up some data.
        self.setup_data()

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test the original residue.
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new residue 1.
        self.assertEqual(dp.mol[1].name, 'New mol')
        self.assertEqual(dp.mol[1].res[0].num, 1)
        self.assertEqual(dp.mol[1].res[0].name, 'Ala')
        self.assertEqual(dp.mol[1].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[1].res[0].spin[0].x, 1)

        # Test the new residue 5.
        self.assertEqual(dp.mol[1].res[1].num, 5)
        self.assertEqual(dp.mol[1].res[1].name, 'Ala')
        self.assertEqual(dp.mol[1].res[1].spin[0].num, 111)
        self.assertEqual(dp.mol[1].res[1].spin[0].x, 1)
Beispiel #18
0
def return_interatom_list(spin_hash=None, pipe=None):
    """Return the list of interatomic data containers for the given spin.

    @keyword spin_hash: The unique spin hash.
    @type spin_hash:    str
    @keyword pipe:      The data pipe holding the container.  This defaults to the current data pipe.
    @type pipe:         str or None
    @return:            The list of matching interatomic data containers, if any exist.
    @rtype:             list of data.interatomic.InteratomContainer instances
    """

    # Check.
    if spin_hash == None:
        raise RelaxError("The unique spin hash must be supplied.")

    # The data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # Initialise.
    interatoms = []

    # Find and append all containers.
    for i in range(len(dp.interatomic)):
        if spin_hash in [dp.interatomic[i]._spin_hash1, dp.interatomic[i]._spin_hash2]:
            interatoms.append(dp.interatomic[i])

    # Return the list of containers.
    return interatoms
    def test_init_ellipsoid(self):
        """Test the setting up of a ellipsoid diffusion tensor.

        The functions tested are both pipe_control.diffusion_tensor.init() and
        prompt.diffusion_tensor.init().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(13.9, 1.8, 0.7, 10.6, -23.3,
                                               0.34),
                                       time_scale=1e-9,
                                       d_scale=1e7,
                                       angle_units='rad',
                                       param_types=0,
                                       fixed=True)

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'ellipsoid')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 13.9, 14)
        self.assertEqual(dp.diff_tensor.Da, 1.8e7)
        self.assertEqual(dp.diff_tensor.Dr, 0.7)
        self.assertEqual(dp.diff_tensor.alpha, 1.1752220392306203)
        self.assertEqual(dp.diff_tensor.beta, 1.8327412287183442)
        self.assertEqual(dp.diff_tensor.gamma, 0.34)
        self.assertEqual(dp.diff_tensor.fixed, 1)
    def test_copy_pull_ellipsoid(self):
        """Test the copying of an ellipsoid diffusion tensor (pulling the data from another pipe).

        The functions tested are both pipe_control.diffusion_tensor.copy() and
        prompt.diffusion_tensor.copy().
        """

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(13.9, 1.8, 0.7, 10.6, -23.3,
                                               0.34),
                                       time_scale=1e-9,
                                       d_scale=1e7,
                                       angle_units='rad',
                                       param_types=0,
                                       fixed=True)

        # Change the current data pipe.
        pipes.switch('test')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Copy the tensor to the test pipe.
        self.diffusion_tensor_fns.copy(pipe_from='orig')

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'ellipsoid')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 13.9, 14)
        self.assertEqual(dp.diff_tensor.Da, 1.8e7)
        self.assertEqual(dp.diff_tensor.Dr, 0.7)
        self.assertEqual(dp.diff_tensor.alpha, 1.1752220392306203)
        self.assertEqual(dp.diff_tensor.beta, 1.8327412287183442)
        self.assertEqual(dp.diff_tensor.gamma, 0.34)
        self.assertEqual(dp.diff_tensor.fixed, 1)
Beispiel #21
0
def exists_data(pipe=None):
    """Determine if any interatomic data exists.

    @keyword pipe:      The data pipe in which the interatomic data will be checked for.
    @type pipe:         str
    @return:            The answer to the question about the existence of data.
    @rtype:             bool
    """

    # The current data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Test the data pipe.
    check_pipe(pipe)

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # The interatomic data structure is empty.
    if dp.interatomic.is_empty():
        return False

    # Otherwise.
    return True
Beispiel #22
0
def return_interatom(spin_id1=None, spin_id2=None, pipe=None):
    """Return the list of interatomic data containers for the two spins.

    @keyword spin_id1:  The spin ID string of the first atom.
    @type spin_id1:     str
    @keyword spin_id2:  The spin ID string of the second atom.
    @type spin_id2:     str
    @keyword pipe:      The data pipe holding the container.  Defaults to the current data pipe.
    @type pipe:         str or None
    @return:            The matching interatomic data container, if it exists.
    @rtype:             data.interatomic.InteratomContainer instance or None
    """

    # Checks.
    if spin_id1 == None:
        raise RelaxError("The first spin ID must be supplied.")
    if spin_id2 == None:
        raise RelaxError("The second spin ID must be supplied.")

    # The data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # Return the matching container.
    for i in range(len(dp.interatomic)):
        if id_match(spin_id=spin_id1, interatom=dp.interatomic[i], pipe=pipe) and id_match(spin_id=spin_id2, interatom=dp.interatomic[i], pipe=pipe):
            return dp.interatomic[i]

    # No matchs.
    return None
Beispiel #23
0
def return_interatom_list(spin_id=None, pipe=None):
    """Return the list of interatomic data containers for the given spin.

    @keyword spin_id:   The spin ID string.
    @type spin_id:      str
    @keyword pipe:      The data pipe holding the container.  This defaults to the current data pipe.
    @type pipe:         str or None
    @return:            The list of matching interatomic data containers, if any exist.
    @rtype:             list of data.interatomic.InteratomContainer instances
    """

    # Check.
    if spin_id == None:
        raise RelaxError("The spin ID must be supplied.")

    # The data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # Initialise.
    interatoms = []

    # Find and append all containers.
    for i in range(len(dp.interatomic)):
        if id_match(spin_id=spin_id, interatom=dp.interatomic[i], pipe=pipe) or id_match(spin_id=spin_id, interatom=dp.interatomic[i], pipe=pipe):
            interatoms.append(dp.interatomic[i])

    # Return the list of containers.
    return interatoms
    def test_name_residue_many(self):
        """Test the renaming of multiple residues.

        The function tested is both pipe_control.mol_res_spin.name_residue() and
        prompt.residue.name().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        self.residue_fns.create(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111

        # Copy the residue a few times.
        self.residue_fns.copy(res_from=':1', res_to=':2')
        self.residue_fns.copy(res_from=':1', res_to=':3')

        # Change the first residue's data.
        dp.mol[0].res[0].name = 'His'

        # Copy the residue once more.
        self.residue_fns.copy(res_from=':1', res_to=':4,Met')

        # Rename all alanines.
        self.residue_fns.name(res_id=':Ala', name='Gln', force=True)

        # Test the renaming of alanines.
        self.assertEqual(dp.mol[0].res[1].name, 'Gln')
        self.assertEqual(dp.mol[0].res[2].name, 'Gln')

        # Test that the other residues have not changed.
        self.assertEqual(dp.mol[0].res[0].name, 'His')
        self.assertEqual(dp.mol[0].res[3].name, 'Met')
Beispiel #25
0
def exists_data(pipe=None):
    """Determine if any interatomic data exists.

    @keyword pipe:      The data pipe in which the interatomic data will be checked for.
    @type pipe:         str
    @return:            The answer to the question about the existence of data.
    @rtype:             bool
    """

    # The current data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Test the data pipe.
    pipes.test(pipe)

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # The interatomic data structure is empty.
    if dp.interatomic.is_empty():
        return False

    # Otherwise.
    return True
Beispiel #26
0
    def test_duplicate_data_fail1(self):
        """Test the failure of the model-free duplicate_data() method when the structures are not consistent."""

        # Read a model-free results file.
        results.read(file='final_results_trunc_1.3_v1',
                     dir=status.install_path + sep + 'test_suite' + sep +
                     'shared_data' + sep + 'model_free' + sep + 'OMP')

        # Load a structure.
        structure.main.read_pdb(file='Ap4Aase_res1-12.pdb',
                                dir=status.install_path + sep + 'test_suite' +
                                sep + 'shared_data' + sep + 'structures',
                                read_model=1)

        # Create a new model-free data pipe.
        ds.add(pipe_name='new', pipe_type='mf')

        # Load the structure for the second pipe.
        structure.main.read_pdb(file='Ap4Aase_res1-12.pdb',
                                dir=status.install_path + sep + 'test_suite' +
                                sep + 'shared_data' + sep + 'structures',
                                read_model=1)

        # Modify the structure.
        dp = pipes.get_pipe('new')
        dp.structure.structural_data[0].mol[0].file_name = 'test'

        # Duplicate the data and catch the error.
        self.assertRaises(RelaxError,
                          self.inst.duplicate_data,
                          'orig',
                          'new',
                          model_info=0)
Beispiel #27
0
def check_structure_func(pipe_name=None):
    """Test if structural data is present.

    @return:        The initialised RelaxError object or nothing.
    @rtype:         None or RelaxError instance
    """

    # Defaults.
    if pipe_name == None:
        pipe_name = cdp_name()

    # Get the data pipe.
    dp = get_pipe(pipe_name)

    # Test if the structure exists.
    if not hasattr(dp, 'structure'):
        return RelaxError(
            "No structural data is present in the current data pipe.")

    # Check for models:
    if not dp.structure.num_models():
        return RelaxError(
            "The structural object in the current data pipe contains no models."
        )

    # Check for molecules.
    if not dp.structure.num_molecules():
        return RelaxError(
            "The structural object in the current data pipe contains no molecules."
        )
Beispiel #28
0
    def update(self, pipe_name=None):
        """Update the tree view using the given data pipe."""

        # Acquire the pipe and spin locks.
        status.pipe_lock.acquire('spin viewer window')
        status.spin_lock.acquire('spin viewer window')
        try:
            # The data pipe.
            if not pipe_name:
                pipe = cdp
            else:
                pipe = get_pipe(pipe_name)

            # No data pipe, so delete everything and return.
            if not pipe:
                self.tree.DeleteChildren(self.root)
                return

            # Update the molecules.
            for mol, mol_id in molecule_loop(return_id=True):
                self.update_mol(mol, mol_id)

            # Remove any deleted molecules.
            self.prune_mol()

        # Release the locks.
        finally:
            status.pipe_lock.release('spin viewer window')
            status.spin_lock.release('spin viewer window')
Beispiel #29
0
    def test_delete_molecule(self):
        """Test molecule deletion.

        The function tested is both pipe_control.mol_res_spin.delete_molecule() and
        prompt.molecule.delete().
        """

        # Set up some data.
        self.setup_data()

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Delete the first molecule.
        self.molecule_fns.delete(mol_id='#Old mol')

        # Test that the first molecule is now 'New mol'.
        self.assertEqual(dp.mol[0].name, 'New mol')
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[0].spin[0], 'x'))
        self.assertEqual(dp.mol[0].res[1].num, 5)
        self.assertEqual(dp.mol[0].res[1].name, 'Ala')
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[1].spin[0], 'x'))
    def test_svd_identity(self):
        """Test the SVD and condition number for a 5x5 identity matrix.

        The functions tested are both pipe_control.align_tensor.svd() and
        prompt.align_tensor.svd().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Initialise the 5 tensors.
        self.align_tensor_fns.init(align_id='1', params=(1, 0, 0, 0, 0), param_types=0)
        self.align_tensor_fns.init(align_id='2', params=(0, 1, 0, 0, 0), param_types=0)
        self.align_tensor_fns.init(align_id='3', params=(0, 0, 1, 0, 0), param_types=0)
        self.align_tensor_fns.init(align_id='4', params=(0, 0, 0, 1, 0), param_types=0)
        self.align_tensor_fns.init(align_id='5', params=(0, 0, 0, 0, 1), param_types=0)

        # SVD.
        self.align_tensor_fns.svd(basis_set='unitary 5D')

        # Test the values
        self.assertEqual(dp.align_tensors.singular_vals[0], 1.0)
        self.assertEqual(dp.align_tensors.singular_vals[1], 1.0)
        self.assertEqual(dp.align_tensors.singular_vals[2], 1.0)
        self.assertEqual(dp.align_tensors.singular_vals[3], 1.0)
        self.assertEqual(dp.align_tensors.singular_vals[4], 1.0)
        self.assertEqual(dp.align_tensors.cond_num, 1.0)
    def test_delete_residue_num(self):
        """Test residue deletion using residue number identifiers.

        The function tested is both pipe_control.mol_res_spin.delete_residue() and
        prompt.residue.delete().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create some residues and add some data to the spin containers.
        self.residue_fns.create(1, 'Ala')
        self.residue_fns.create(2, 'Ala')
        self.residue_fns.create(3, 'Ala')
        self.residue_fns.create(4, 'Gly')
        dp.mol[0].res[3].spin[0].num = 111
        dp.mol[0].res[3].spin[0].x = 1

        # Delete the first residue.
        self.residue_fns.delete(res_id=':1')

        # Test that the sequence.
        self.assertEqual(dp.mol[0].res[0].num, 2)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[1].num, 3)
        self.assertEqual(dp.mol[0].res[1].name, 'Ala')
        self.assertEqual(dp.mol[0].res[2].num, 4)
        self.assertEqual(dp.mol[0].res[2].name, 'Gly')
        self.assertEqual(dp.mol[0].res[2].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[2].spin[0], 'x'))
Beispiel #32
0
def model_setup(model=None, equation=None, params=None, spin_id=None):
    """Function for updating various data structures depending on the model selected.

    @param model:       The name of the model.
    @type model:        str
    @param equation:    The equation type to use.  The 3 allowed types are:  'mf_orig' for the original model-free equations with parameters {s2, te}; 'mf_ext' for the extended model-free equations with parameters {s2f, tf, s2, ts}; and 'mf_ext2' for the extended model-free equations with parameters {s2f, tf, s2s, ts}.
    @type equation:     str
    @param params:      A list of the parameters to include in the model.  The allowed parameter names includes those for the equation type as well as chemical exchange 'rex', the bond length 'r', and the chemical shift anisotropy 'csa'.
    @type params:       list of str
    @param spin_id:     The spin identification string.
    @type spin_id:      str
    """

    # Test that no diffusion tensor exists if local tm is a parameter in the model.
    if params:
        for param in params:
            if param == 'local_tm' and hasattr(pipes.get_pipe(),
                                               'diff_tensor'):
                raise RelaxTensorError('diffusion')

    # Loop over the sequence.
    for spin, spin_id in spin_loop(spin_id, return_id=True):
        # Initialise the data structures (if needed).
        api_model_free.data_init(spin_id)

        # Model-free model, equation, and parameter types.
        spin.model = model
        spin.equation = equation
        spin.params = params
    def test_init_spheroid(self):
        """Test the setting up of a spheroidal diffusion tensor.

        The functions tested are both pipe_control.diffusion_tensor.init() and
        prompt.diffusion_tensor.init().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(8.6, 1.3, 600, -20),
                                       time_scale=1e-9,
                                       d_scale=1e7,
                                       angle_units='deg',
                                       param_types=2,
                                       spheroid_type='prolate',
                                       fixed=False)

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'spheroid')
        self.assertEqual(dp.diff_tensor.spheroid_type, 'prolate')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 8.6, 14)
        self.assertEqual(dp.diff_tensor.Da, 5.2854122621564493e6)
        self.assertEqual(dp.diff_tensor.theta, 5.2359877559829879)
        self.assertEqual(dp.diff_tensor.phi, 2.7925268031909276)
        self.assertEqual(dp.diff_tensor.fixed, 0)
    def test_delete_residue_shift(self):
        """Test the deletion of multiple residues.

        The function tested is both pipe_control.mol_res_spin.delete_residue() and
        prompt.residue.delete().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create some residues and add some data to the spin containers.
        self.residue_fns.create(1, 'Ala')
        self.residue_fns.create(2, 'Ala')
        self.residue_fns.create(3, 'Ala')
        self.residue_fns.create(4, 'Ala')
        dp.mol[0].res[3].spin[0].num = 111
        dp.mol[0].res[3].spin[0].x = 1

        # Delete the first and third residues.
        self.residue_fns.delete(res_id=':1,3')

        # Test that the remaining residues.
        self.assertEqual(dp.mol[0].res[0].num, 2)
        self.assertEqual(dp.mol[0].res[1].num, 4)
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[1].spin[0], 'x'))
Beispiel #35
0
def return_interatom(spin_hash1=None, spin_hash2=None, pipe=None):
    """Return the list of interatomic data containers for the two spins.

    @keyword spin_hash1:    The unique spin hash for the first atom.
    @type spin_hash1:       str
    @keyword spin_hash2:    The unique spin hash for the second atom.
    @type spin_hash2:       str
    @keyword pipe:          The data pipe holding the container.  Defaults to the current data pipe.
    @type pipe:             str or None
    @return:                The matching interatomic data container, if it exists.
    @rtype:                 data.interatomic.InteratomContainer instance or None
    """

    # Checks.
    if spin_hash1 == None:
        raise RelaxError("The first spin hash must be supplied.")
    if spin_hash2 == None:
        raise RelaxError("The second spin hash must be supplied.")

    # The data pipe.
    if pipe == None:
        pipe = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe)

    # Return the matching container.
    for i in range(len(dp.interatomic)):
        if spin_hash1 != spin_hash2 and spin_hash1 in [dp.interatomic[i]._spin_hash1, dp.interatomic[i]._spin_hash2] and spin_hash2 in [dp.interatomic[i]._spin_hash1, dp.interatomic[i]._spin_hash2]:
            return dp.interatomic[i]

    # No matchs.
    return None
Beispiel #36
0
    def test_number_spin(self):
        """Test the numbering of a spin.

        The function tested is both pipe_control.mol_res_spin.number_spin() and
        prompt.spin.number().
        """

        # Rename a few spins.
        self.spin_fns.number(spin_id='@C8', number=1, force=True)
        self.spin_fns.number(spin_id='@6', number=2, force=True)
        self.spin_fns.number(spin_id='@7', number=3, force=True)
        self.spin_fns.number(spin_id='@8', number=4, force=True)
        self.spin_fns.number(spin_id='@9', number=5, force=True)
        self.spin_fns.number(spin_id='@78', number=6, force=True)
        self.spin_fns.number(spin_id='@239', number=7, force=True)
        self.spin_fns.number(spin_id='@3239', number=9, force=True)

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test that the spins have been numbered.
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].spin[1].num, 2)
        self.assertEqual(dp.mol[0].res[0].spin[2].num, 3)
        self.assertEqual(dp.mol[0].res[0].spin[3].num, 4)
        self.assertEqual(dp.mol[0].res[0].spin[4].num, 5)
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 6)
        self.assertEqual(dp.mol[1].res[0].spin[0].num, 7)
        self.assertEqual(dp.mol[1].res[1].spin[1].num, 9)
Beispiel #37
0
    def update(self, pipe_name=None):
        """Update the tree view using the given data pipe."""

        # Acquire the pipe and spin locks.
        status.pipe_lock.acquire('spin viewer window')
        status.spin_lock.acquire('spin viewer window')
        try:
            # The data pipe.
            if not pipe_name:
                pipe = cdp
            else:
                pipe = get_pipe(pipe_name)

            # No data pipe, so delete everything and return.
            if not pipe:
                self.tree.DeleteChildren(self.root)
                return

            # Update the molecules.
            for mol, mol_id in molecule_loop(return_id=True):
                self.update_mol(mol, mol_id)

            # Remove any deleted molecules.
            self.prune_mol()

        # Release the locks.
        finally:
            status.pipe_lock.release('spin viewer window')
            status.spin_lock.release('spin viewer window')
    def test_copy_pull_spheroid(self):
        """Test the copying of a spheroidal diffusion tensor (pulling the data from another pipe).

        The functions tested are both pipe_control.diffusion_tensor.copy() and
        prompt.diffusion_tensor.copy().
        """

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(8.6, 1.3, 600, -20),
                                       time_scale=1e-9,
                                       d_scale=1e7,
                                       angle_units='deg',
                                       param_types=2,
                                       spheroid_type='prolate',
                                       fixed=False)

        # Change the current data pipe.
        pipes.switch('test')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Copy the tensor to the test pipe.
        self.diffusion_tensor_fns.copy(pipe_from='orig', pipe_to='test')

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'spheroid')
        self.assertEqual(dp.diff_tensor.spheroid_type, 'prolate')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 8.6, 14)
        self.assertEqual(dp.diff_tensor.Da, 5.2854122621564493e6)
        self.assertEqual(dp.diff_tensor.theta, 5.2359877559829879)
        self.assertEqual(dp.diff_tensor.phi, 2.7925268031909276)
        self.assertEqual(dp.diff_tensor.fixed, 0)
Beispiel #39
0
def model_setup(model=None, equation=None, params=None, spin_id=None):
    """Function for updating various data structures depending on the model selected.

    @param model:       The name of the model.
    @type model:        str
    @param equation:    The equation type to use.  The 3 allowed types are:  'mf_orig' for the original model-free equations with parameters {s2, te}; 'mf_ext' for the extended model-free equations with parameters {s2f, tf, s2, ts}; and 'mf_ext2' for the extended model-free equations with parameters {s2f, tf, s2s, ts}.
    @type equation:     str
    @param params:      A list of the parameters to include in the model.  The allowed parameter names includes those for the equation type as well as chemical exchange 'rex', the bond length 'r', and the chemical shift anisotropy 'csa'.
    @type params:       list of str
    @param spin_id:     The spin identification string.
    @type spin_id:      str
    """

    # Test that no diffusion tensor exists if local tm is a parameter in the model.
    if params:
        for param in params:
            if param == "local_tm" and hasattr(pipes.get_pipe(), "diff_tensor"):
                raise RelaxTensorError("diffusion")

    # Loop over the sequence.
    for spin, spin_id in spin_loop(spin_id, return_id=True):
        # Initialise the data structures (if needed).
        api_model_free.data_init(spin_id)

        # Model-free model, equation, and parameter types.
        spin.model = model
        spin.equation = equation
        spin.params = params
    def test_delete_molecule(self):
        """Test molecule deletion.

        The function tested is both pipe_control.mol_res_spin.delete_molecule() and
        prompt.molecule.delete().
        """

        # Set up some data.
        self.setup_data()

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Delete the first molecule.
        self.molecule_fns.delete(mol_id='#Old mol')

        # Test that the first molecule is now 'New mol'.
        self.assertEqual(dp.mol[0].name, 'New mol')
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[0].spin[0], 'x'))
        self.assertEqual(dp.mol[0].res[1].num, 5)
        self.assertEqual(dp.mol[0].res[1].name, 'Ala')
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[1].spin[0], 'x'))
Beispiel #41
0
    def test_write_read_pipes(self):
        """Test the writing out, and re-reading of data pipes from the state file."""

        # Create a data pipe.
        self.interpreter.pipe.create('test', 'mf')

        # Reset relax.
        reset()

        # The data pipe list.
        pipe_types = deepcopy(VALID_TYPES)
        pipe_types.pop(pipe_types.index("frame order"))

        # Create a few data pipes.
        for i in range(len(pipe_types)):
            self.interpreter.pipe.create('test' + repr(i), pipe_types[i])

        # Write the results.
        self.interpreter.state.save(self.tmpfile)

        # Reset relax.
        reset()

        # Re-read the results.
        self.interpreter.state.load(self.tmpfile)

        # Test the pipes.
        for i in range(len(pipe_types)):
            # Name.
            name = 'test' + repr(i)
            self.assert_(name in ds)

            # Type.
            pipe = get_pipe(name)
            self.assertEqual(pipe.pipe_type, pipe_types[i])
    def test_number_residue_many_fail(self):
        """Test the numbering of multiple residues.

        The function tested is both pipe_control.mol_res_spin.number_residue() and
        prompt.residue.number().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        self.residue_fns.create(1, 'Ala')

        # Copy the residue a few times.
        self.residue_fns.copy(res_from=':1', res_to=':2')
        self.residue_fns.copy(res_from=':1', res_to=':3')

        # Change the first residue's data.
        dp.mol[0].res[0].spin[0].name = 'His'

        # Copy the residue once more.
        self.residue_fns.copy(res_from=':1', res_to=':4,Met')

        # Try numbering all alanines.
        self.assertRaises(RelaxError, self.residue_fns.number, res_id=':Ala', number=10)
    def test_copy_pull(self):
        """Test the copying of an alignment tensor (pulling the data from another pipe).

        The functions tested are both pipe_control.align_tensor.copy() and
        prompt.align_tensor.copy().
        """

        # Initialise the tensor.
        self.align_tensor_fns.init(tensor='Pf1', align_id='Pf1', params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), scale=1.0, angle_units='rad', param_types=0)

        # Change the current data pipe.
        pipes.switch('test')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Copy the tensor to the test pipe.
        self.align_tensor_fns.copy(tensor_from='Pf1', pipe_from='orig', tensor_to='Pf1')

        # Test the alignment tensor.
        self.assertEqual(dp.align_tensors[0].Sxx, -16.6278)
        self.assertEqual(dp.align_tensors[0].Syy, 6.13037)
        self.assertEqual(dp.align_tensors[0].Sxy, 7.65639)
        self.assertEqual(dp.align_tensors[0].Sxz, -1.89157)
        self.assertAlmostEqual(dp.align_tensors[0].Syz, 19.2561)
    def test_copy_pull_spheroid(self):
        """Test the copying of a spheroidal diffusion tensor (pulling the data from another pipe).

        The functions tested are both pipe_control.diffusion_tensor.copy() and
        prompt.diffusion_tensor.copy().
        """

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(8.6, 1.3, 600, -20), time_scale=1e-9, d_scale=1e7, angle_units='deg', param_types=2, spheroid_type='prolate', fixed=False)

        # Change the current data pipe.
        pipes.switch('test')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Copy the tensor to the test pipe.
        self.diffusion_tensor_fns.copy(pipe_from='orig', pipe_to='test')

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'spheroid')
        self.assertEqual(dp.diff_tensor.spheroid_type, 'prolate')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 8.6, 14)
        self.assertEqual(dp.diff_tensor.Da, 5.2854122621564493e6)
        self.assertEqual(dp.diff_tensor.theta, 5.2359877559829879)
        self.assertEqual(dp.diff_tensor.phi, 2.7925268031909276)
        self.assertEqual(dp.diff_tensor.fixed, 0)
Beispiel #45
0
    def test_copy_spin_between_residues(self):
        """Test the copying of the spin data between different residues.

        The function tested is both pipe_control.mol_res_spin.copy_spin() and
        prompt.spin.copy().
        """

        # Copy the spin 'C8' from the first residue to the third residue.
        self.spin_fns.copy(spin_from='#Old mol:1@C8', spin_to='#Old mol:2')

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test the original spin.
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8')
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 1)

        # Test the new spin.
        self.assertEqual(dp.mol[0].res[1].num, 2)
        self.assertEqual(dp.mol[0].res[1].name, 'Arg')
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 78)
        self.assertEqual(dp.mol[0].res[1].spin[0].name, 'NH')
        self.assertEqual(dp.mol[0].res[1].spin[1].num, 111)
        self.assertEqual(dp.mol[0].res[1].spin[1].name, 'C8')
        self.assertEqual(dp.mol[0].res[1].spin[1].x, 1)
    def test_copy_pull_ellipsoid(self):
        """Test the copying of an ellipsoid diffusion tensor (pulling the data from another pipe).

        The functions tested are both pipe_control.diffusion_tensor.copy() and
        prompt.diffusion_tensor.copy().
        """

        # Initialise the tensor.
        self.diffusion_tensor_fns.init(params=(13.9, 1.8, 0.7, 10.6, -23.3, 0.34), time_scale=1e-9, d_scale=1e7, angle_units='rad', param_types=0, fixed=True)

        # Change the current data pipe.
        pipes.switch('test')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Copy the tensor to the test pipe.
        self.diffusion_tensor_fns.copy(pipe_from='orig')

        # Test the diffusion tensor.
        self.assertEqual(dp.diff_tensor.type, 'ellipsoid')
        self.assertAlmostEqual(dp.diff_tensor.tm * 1e9, 13.9, 14)
        self.assertEqual(dp.diff_tensor.Da, 1.8e7)
        self.assertEqual(dp.diff_tensor.Dr, 0.7)
        self.assertEqual(dp.diff_tensor.alpha, 1.1752220392306203)
        self.assertEqual(dp.diff_tensor.beta, 1.8327412287183442)
        self.assertEqual(dp.diff_tensor.gamma, 0.34)
        self.assertEqual(dp.diff_tensor.fixed, 1)
Beispiel #47
0
    def test_name_spin(self):
        """Test the renaming of a spin.

        The function tested is both pipe_control.mol_res_spin.name_spin() and
        prompt.spin.name().
        """

        # Rename some spins.
        self.spin_fns.name(spin_id='@C26', name='C25', force=True)
        self.spin_fns.name(spin_id=':2@78', name='Ca', force=True)
        self.spin_fns.name(spin_id='#New mol:6@3239', name='NHe', force=True)

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test that the spins have been named (and that the others have not).
        self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8')
        self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19')
        self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21')
        self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24')
        self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C25')
        self.assertEqual(dp.mol[0].res[1].spin[0].name, 'Ca')
        self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH')
        self.assertEqual(dp.mol[1].res[1].spin[0].name, None)
        self.assertEqual(dp.mol[1].res[1].spin[1].name, 'NHe')
Beispiel #48
0
    def test_copy_spin_between_residues(self):
        """Test the copying of the spin data between different residues.

        The function tested is both pipe_control.mol_res_spin.copy_spin() and
        prompt.spin.copy().
        """

        # Copy the spin 'C8' from the first residue to the third residue.
        self.spin_fns.copy(spin_from='#Old mol:1@C8', spin_to='#Old mol:2')

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test the original spin.
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8')
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 1)

        # Test the new spin.
        self.assertEqual(dp.mol[0].res[1].num, 2)
        self.assertEqual(dp.mol[0].res[1].name, 'Arg')
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 78)
        self.assertEqual(dp.mol[0].res[1].spin[0].name, 'NH')
        self.assertEqual(dp.mol[0].res[1].spin[1].num, 111)
        self.assertEqual(dp.mol[0].res[1].spin[1].name, 'C8')
        self.assertEqual(dp.mol[0].res[1].spin[1].x, 1)
Beispiel #49
0
    def test_name_spin(self):
        """Test the renaming of a spin.

        The function tested is both pipe_control.mol_res_spin.name_spin() and
        prompt.spin.name().
        """

        # Rename some spins.
        self.spin_fns.name(spin_id='@C26', name='C25', force=True)
        self.spin_fns.name(spin_id=':2@78', name='Ca', force=True)
        self.spin_fns.name(spin_id='#New mol:6@3239', name='NHe', force=True)

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test that the spins have been named (and that the others have not).
        self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8')
        self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19')
        self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21')
        self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24')
        self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C25')
        self.assertEqual(dp.mol[0].res[1].spin[0].name, 'Ca')
        self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH')
        self.assertEqual(dp.mol[1].res[1].spin[0].name, None)
        self.assertEqual(dp.mol[1].res[1].spin[1].name, 'NHe')
Beispiel #50
0
    def test_write_read_pipes(self):
        """Test the writing out, and re-reading of data pipes from the state file."""

        # Create a data pipe.
        self.interpreter.pipe.create('test', 'mf')

        # Reset relax.
        reset()

        # The data pipe list.
        pipe_types = deepcopy(VALID_TYPES)
        pipe_types.pop(pipe_types.index("frame order"))

        # Create a few data pipes.
        for i in range(len(pipe_types)):
            self.interpreter.pipe.create('test' + repr(i), pipe_types[i])

        # Write the results.
        self.interpreter.state.save(self.tmpfile, compress_type=0, force=True)

        # Reset relax.
        reset()

        # Re-read the results.
        self.interpreter.state.load(self.tmpfile)

        # Test the pipes.
        for i in range(len(pipe_types)):
            # Name.
            name = 'test' + repr(i)
            self.assert_(name in ds)

            # Type.
            pipe = get_pipe(name)
            self.assertEqual(pipe.pipe_type, pipe_types[i])
Beispiel #51
0
    def test_delete_residue_num(self):
        """Test residue deletion using residue number identifiers.

        The function tested is both pipe_control.mol_res_spin.delete_residue() and
        prompt.residue.delete().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create some residues and add some data to the spin containers.
        self.residue_fns.create(1, 'Ala')
        self.residue_fns.create(2, 'Ala')
        self.residue_fns.create(3, 'Ala')
        self.residue_fns.create(4, 'Gly')
        dp.mol[0].res[3].spin[0].num = 111
        dp.mol[0].res[3].spin[0].x = 1

        # Delete the first residue.
        self.residue_fns.delete(res_id=':1')

        # Test that the sequence.
        self.assertEqual(dp.mol[0].res[0].num, 2)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[1].num, 3)
        self.assertEqual(dp.mol[0].res[1].name, 'Ala')
        self.assertEqual(dp.mol[0].res[2].num, 4)
        self.assertEqual(dp.mol[0].res[2].name, 'Gly')
        self.assertEqual(dp.mol[0].res[2].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[2].spin[0], 'x'))
Beispiel #52
0
    def setup_data(self):
        """Function for setting up some data for the unit tests."""

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        create_residue(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111
        dp.mol[0].res[0].spin[0].x = 1
        dp.mol[0].name = 'Old mol'

        # Create a second molecule.
        dp.mol.add_item('New mol')

        # Copy the residue to the new molecule.
        copy_residue(res_from=':1', res_to='#New mol')
        copy_residue(res_from='#Old mol:1', res_to='#New mol:5')

        # Change the first residue's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()
Beispiel #53
0
    def test_number_spin(self):
        """Test the numbering of a spin.

        The function tested is both pipe_control.mol_res_spin.number_spin() and
        prompt.spin.number().
        """

        # Rename a few spins.
        self.spin_fns.number(spin_id='@C8', number=1, force=True)
        self.spin_fns.number(spin_id='@6', number=2, force=True)
        self.spin_fns.number(spin_id='@7', number=3, force=True)
        self.spin_fns.number(spin_id='@8', number=4, force=True)
        self.spin_fns.number(spin_id='@9', number=5, force=True)
        self.spin_fns.number(spin_id='@78', number=6, force=True)
        self.spin_fns.number(spin_id='@239', number=7, force=True)
        self.spin_fns.number(spin_id='@3239', number=9, force=True)

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test that the spins have been numbered.
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].spin[1].num, 2)
        self.assertEqual(dp.mol[0].res[0].spin[2].num, 3)
        self.assertEqual(dp.mol[0].res[0].spin[3].num, 4)
        self.assertEqual(dp.mol[0].res[0].spin[4].num, 5)
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 6)
        self.assertEqual(dp.mol[1].res[0].spin[0].num, 7)
        self.assertEqual(dp.mol[1].res[1].spin[1].num, 9)
Beispiel #54
0
    def test_delete_residue_shift(self):
        """Test the deletion of multiple residues.

        The function tested is both pipe_control.mol_res_spin.delete_residue() and
        prompt.residue.delete().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create some residues and add some data to the spin containers.
        self.residue_fns.create(1, 'Ala')
        self.residue_fns.create(2, 'Ala')
        self.residue_fns.create(3, 'Ala')
        self.residue_fns.create(4, 'Ala')
        dp.mol[0].res[3].spin[0].num = 111
        dp.mol[0].res[3].spin[0].x = 1

        # Delete the first and third residues.
        self.residue_fns.delete(res_id=':1,3')

        # Test that the remaining residues.
        self.assertEqual(dp.mol[0].res[0].num, 2)
        self.assertEqual(dp.mol[0].res[1].num, 4)
        self.assertEqual(dp.mol[0].res[1].spin[0].num, 111)
        self.assert_(hasattr(dp.mol[0].res[1].spin[0], 'x'))
    def test_copy_molecule_within_pipe(self):
        """Test the copying of the molecule data within a single data pipe.

        The function tested is both pipe_control.mol_res_spin.copy_molecule() and
        prompt.molecule.copy().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first molecule and residue and add some data to its spin container.
        self.molecule_fns.create('Old mol')
        create_residue(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111
        dp.mol[0].res[0].spin[0].x = 1

        # Update the metadata.
        metadata_update()

        # Copy the molecule a few times.
        self.molecule_fns.copy(mol_from='#Old mol', mol_to='#2')
        self.molecule_fns.copy(mol_from='#Old mol', pipe_to='orig', mol_to='#3')

        # Change the first molecule's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()

        # Copy the molecule once more.
        self.molecule_fns.copy(mol_from='#Old mol', mol_to='#4')

        # Test the original molecule.
        self.assertEqual(dp.mol[0].name, 'Old mol')
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new molecule 2.
        self.assertEqual(dp.mol[1].name, '2')
        self.assertEqual(dp.mol[1].res[0].num, 1)
        self.assertEqual(dp.mol[1].res[0].name, 'Ala')
        self.assertEqual(dp.mol[1].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[1].res[0].spin[0].x, 1)

        # Test the new molecule 3.
        self.assertEqual(dp.mol[2].name, '3')
        self.assertEqual(dp.mol[2].res[0].num, 1)
        self.assertEqual(dp.mol[2].res[0].name, 'Ala')
        self.assertEqual(dp.mol[2].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[2].res[0].spin[0].x, 1)

        # Test the new molecule 4.
        self.assertEqual(dp.mol[3].name, '4')
        self.assertEqual(dp.mol[3].res[0].num, 1)
        self.assertEqual(dp.mol[3].res[0].name, 'Ala')
        self.assertEqual(dp.mol[3].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[3].res[0].spin[0].x, 2)
Beispiel #56
0
    def test_name_residue_many(self):
        """Test the renaming of multiple residues.

        The function tested is both pipe_control.mol_res_spin.name_residue() and
        prompt.residue.name().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        self.residue_fns.create(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111

        # Copy the residue a few times.
        self.residue_fns.copy(res_from=':1', res_to=':2')
        self.residue_fns.copy(res_from=':1', res_to=':3')

        # Change the first residue's data.
        dp.mol[0].res[0].name = 'His'

        # Copy the residue once more.
        self.residue_fns.copy(res_from=':1', res_to=':4,Met')

        # Rename all alanines.
        self.residue_fns.name(res_id=':Ala', name='Gln', force=True)

        # Test the renaming of alanines.
        self.assertEqual(dp.mol[0].res[1].name, 'Gln')
        self.assertEqual(dp.mol[0].res[2].name, 'Gln')

        # Test that the other residues have not changed.
        self.assertEqual(dp.mol[0].res[0].name, 'His')
        self.assertEqual(dp.mol[0].res[3].name, 'Met')
    def setup_data(self):
        """Function for setting up some data for the unit tests."""

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        create_residue(1, 'Ala')
        dp.mol[0].res[0].spin[0].num = 111
        dp.mol[0].res[0].spin[0].x = 1
        dp.mol[0].name = 'Old mol'

        # Create a second molecule.
        dp.mol.add_item('New mol')

        # Copy the residue to the new molecule.
        copy_residue(res_from=':1', res_to='#New mol')
        copy_residue(res_from='#Old mol:1', res_to='#New mol:5')

        # Change the first residue's data.
        dp.mol[0].res[0].spin[0].num = 222
        dp.mol[0].res[0].spin[0].x = 2

        # Update the metadata.
        metadata_update()
Beispiel #58
0
    def test_number_residue_many_fail(self):
        """Test the numbering of multiple residues.

        The function tested is both pipe_control.mol_res_spin.number_residue() and
        prompt.residue.number().
        """

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Create the first residue and add some data to its spin container.
        self.residue_fns.create(1, 'Ala')

        # Copy the residue a few times.
        self.residue_fns.copy(res_from=':1', res_to=':2')
        self.residue_fns.copy(res_from=':1', res_to=':3')

        # Change the first residue's data.
        dp.mol[0].res[0].spin[0].name = 'His'

        # Copy the residue once more.
        self.residue_fns.copy(res_from=':1', res_to=':4,Met')

        # Try numbering all alanines.
        self.assertRaises(RelaxError,
                          self.residue_fns.number,
                          res_id=':Ala',
                          number=10)
Beispiel #59
0
    def test_copy_residue_between_molecules(self):
        """Test the copying of the residue data between different molecules.

        The function tested is both pipe_control.mol_res_spin.copy_residue() and
        prompt.residue.copy().
        """

        # Set up some data.
        self.setup_data()

        # Get the data pipe.
        dp = pipes.get_pipe('orig')

        # Test the original residue.
        self.assertEqual(dp.mol[0].res[0].num, 1)
        self.assertEqual(dp.mol[0].res[0].name, 'Ala')
        self.assertEqual(dp.mol[0].res[0].spin[0].num, 222)
        self.assertEqual(dp.mol[0].res[0].spin[0].x, 2)

        # Test the new residue 1.
        self.assertEqual(dp.mol[1].name, 'New mol')
        self.assertEqual(dp.mol[1].res[0].num, 1)
        self.assertEqual(dp.mol[1].res[0].name, 'Ala')
        self.assertEqual(dp.mol[1].res[0].spin[0].num, 111)
        self.assertEqual(dp.mol[1].res[0].spin[0].x, 1)

        # Test the new residue 5.
        self.assertEqual(dp.mol[1].res[1].num, 5)
        self.assertEqual(dp.mol[1].res[1].name, 'Ala')
        self.assertEqual(dp.mol[1].res[1].spin[0].num, 111)
        self.assertEqual(dp.mol[1].res[1].spin[0].x, 1)
Beispiel #60
0
    def test_copy_push(self):
        """Test the copying of an alignment tensor (pushing the data from another pipe).

        The functions tested are both pipe_control.align_tensor.copy() and
        prompt.align_tensor.copy().
        """

        # Initialise the tensor.
        self.align_tensor_fns.init(tensor='Pf1',
                                   align_id='Pf1',
                                   params=(-16.6278, 6.13037, 7.65639,
                                           -1.89157, 19.2561),
                                   scale=1.0,
                                   angle_units='rad',
                                   param_types=0)

        # Copy the tensor to the test pipe.
        self.align_tensor_fns.copy(tensor_from='Pf1',
                                   pipe_to='test',
                                   tensor_to='Pf1')

        # Get the data pipe.
        dp = pipes.get_pipe('test')

        # Test the alignment tensor.
        self.assertEqual(dp.align_tensors[0].Sxx, -16.6278)
        self.assertEqual(dp.align_tensors[0].Syy, 6.13037)
        self.assertEqual(dp.align_tensors[0].Sxy, 7.65639)
        self.assertEqual(dp.align_tensors[0].Sxz, -1.89157)
        self.assertAlmostEqual(dp.align_tensors[0].Syz, 19.2561)