コード例 #1
0
    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)
コード例 #2
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()
コード例 #3
0
ファイル: noe_restraints.py プロジェクト: pombredanne/relax
    def rna_seq(self):
        """Generate the RNA sequence of the noe_rna_hbond.dat restraint file."""

        # Info.
        mol_names = ["A", "B"]
        res_nums = [[1, 2, 3, 4], [4, 3, 2, 1]]
        spin_names = [
            [["N1", "N6", "H62"], ["H3", "N3", "O4"], ["H1", "N1", "H22", "N2", "O6"], ["N3", "O2", "H42", "N4"]],
            [["H3", "N3", "O4"], ["N1", "N6", "H62"], ["N3", "O2", "H42", "N4"], ["H1", "N1", "H22", "N2", "O6"]],
        ]

        # Loop over the molecules.
        for i in range(len(mol_names)):
            # Create the molecule.
            create_molecule(mol_names[i])

            # Loop over the residues.
            for j in range(len(res_nums[i])):
                # Create the residue.
                create_residue(res_nums[i][j], mol_name=mol_names[i])

                # Loop over the atoms.
                for k in range(len(spin_names[i][j])):
                    # Create the spin.
                    create_spin(spin_names[i][j][k], res_num=res_nums[i][j], mol_name=mol_names[i])

        # Display the sequence for debugging.
        self.interpreter.sequence.display()
コード例 #4
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()
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
ファイル: sequence.py プロジェクト: pombredanne/relax
def generate(mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, pipe=None, select=True, verbose=True):
    """Generate the sequence item-by-item by adding a single molecule/residue/spin container as necessary.

    @keyword mol_name:  The molecule name.
    @type mol_name:     str or None
    @keyword res_num:   The residue number.
    @type res_num:      int or None
    @keyword res_name:  The residue name.
    @type res_name:     str or None
    @keyword spin_num:  The spin number.
    @type spin_num:     int or None
    @keyword spin_name: The spin name.
    @type spin_name:    str or None
    @keyword pipe:      The data pipe in which to generate the sequence.  This defaults to the current data pipe.
    @type pipe:         str
    @keyword select:    The spin selection flag.
    @type select:       bool
    @keyword verbose:   A flag which if True will cause info about each spin to be printed out as the sequence is generated.
    @type verbose:      bool
    """

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

    # A new molecule.
    if not return_molecule(generate_spin_id(mol_name=mol_name), pipe=pipe):
        create_molecule(mol_name=mol_name, pipe=pipe)

    # A new residue.
    curr_res = return_residue(generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name), pipe=pipe)
    if not curr_res or ((res_num != None and curr_res.num != res_num) or (res_name != None and curr_res.name != res_name)):
        create_residue(mol_name=mol_name, res_num=res_num, res_name=res_name, pipe=pipe)

    # A new spin.
    curr_spin = return_spin(generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name), pipe=pipe)
    if not curr_spin or ((spin_num != None and curr_spin.num != spin_num) or (spin_name != None and curr_spin.name != spin_name)):
        # Add the spin.
        curr_spin = create_spin(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name, pipe=pipe)

    # Set the selection flag.
    curr_spin.select = select
コード例 #8
0
def generate(mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, pipe=None, select=True, verbose=True):
    """Generate the sequence item-by-item by adding a single molecule/residue/spin container as necessary.

    @keyword mol_name:  The molecule name.
    @type mol_name:     str or None
    @keyword res_num:   The residue number.
    @type res_num:      int or None
    @keyword res_name:  The residue name.
    @type res_name:     str or None
    @keyword spin_num:  The spin number.
    @type spin_num:     int or None
    @keyword spin_name: The spin name.
    @type spin_name:    str or None
    @keyword pipe:      The data pipe in which to generate the sequence.  This defaults to the current data pipe.
    @type pipe:         str
    @keyword select:    The spin selection flag.
    @type select:       bool
    @keyword verbose:   A flag which if True will cause info about each spin to be printed out as the sequence is generated.
    @type verbose:      bool
    """

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

    # A new molecule.
    if not return_molecule(generate_spin_id(mol_name=mol_name), pipe=pipe):
        create_molecule(mol_name=mol_name, pipe=pipe)

    # A new residue.
    curr_res = return_residue(generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name), pipe=pipe)
    if not curr_res or ((res_num != None and curr_res.num != res_num) or (res_name != None and curr_res.name != res_name)):
        create_residue(mol_name=mol_name, res_num=res_num, res_name=res_name, pipe=pipe)

    # A new spin.
    curr_spin = return_spin(spin_id=generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name), pipe=pipe)
    if not curr_spin or ((spin_num != None and curr_spin.num != spin_num) or (spin_name != None and curr_spin.name != spin_name)):
        # Add the spin.
        curr_spin = create_spin(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name, pipe=pipe)[0]

    # Set the selection flag.
    curr_spin.select = select
コード例 #9
0
    def test_copy_molecule_between_pipes_fail_no_pipe(self):
        """Test the failure of 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 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 to the second data pipe.
        self.assertRaises(RelaxNoPipeError, self.molecule_fns.copy, mol_from='#Old mol', pipe_to='test2')
コード例 #10
0
    def rna_seq(self):
        """Generate the RNA sequence of the noe_rna_hbond.dat restraint file."""

        # Info.
        mol_names = ['A', 'B']
        res_nums = [
                [1, 2, 3, 4],
                [4, 3, 2, 1]
        ]
        spin_names = [
                [['N1', 'N6', 'H62'],
                 ['H3', 'N3', 'O4'],
                 ['H1', 'N1', 'H22', 'N2', 'O6'],
                 ['N3', 'O2', 'H42', 'N4']],
                [['H3', 'N3', 'O4'],
                 ['N1', 'N6', 'H62'],
                 ['N3', 'O2', 'H42', 'N4'],
                 ['H1', 'N1', 'H22', 'N2', 'O6']]
        ]
        
        # Loop over the molecules.
        for i in range(len(mol_names)):
            # Create the molecule.
            create_molecule(mol_names[i])

            # Loop over the residues.
            for j in range(len(res_nums[i])):
                # Create the residue.
                create_residue(res_nums[i][j], mol_name=mol_names[i])

                # Loop over the atoms.
                for k in range(len(spin_names[i][j])):
                    # Create the spin.
                    create_spin(spin_names[i][j][k], res_num=res_nums[i][j], mol_name=mol_names[i])

        # Display the sequence for debugging.
        self.interpreter.sequence.display()
コード例 #11
0
    def test_copy_molecule_between_pipes_fail_no_pipe(self):
        """Test the failure of 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 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 to the second data pipe.
        self.assertRaises(RelaxNoPipeError,
                          self.molecule_fns.copy,
                          mol_from='#Old mol',
                          pipe_to='test2')
コード例 #12
0
    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)