예제 #1
0
    def test_write_list(self):
        """Test the lib.software.sparky.write_list() function."""

        # The data.
        res_names = ['LEU', 'GLY', 'SER', 'MET', 'TRP', 'TRP', 'ASN']
        res_nums = [3, 4, 5, 6, 40, 40, 55]
        atom1_names = ['N', 'N', 'N', 'N', 'N', 'NE1', 'N']
        atom2_names = ['HN', 'HN', 'HN', 'HN', 'HN', 'HE1', 'HN']
        w1 = [122.454, 111.978, 115.069, 120.910, 123.335, 130.204, 116.896]
        w2 = [8.397, 8.720, 8.177, 8.813, 8.005, 10.294, 7.468]
        heights = [2535, 5050, 51643, 53663, -65111, -181131, -105322]

        # The result.
        file_data = [
            '      Assignment         w1         w2   Data Height\n',
            '\n',
            '         LEU3N-HN    122.454      8.397         2535\n',
            '         GLY4N-HN    111.978      8.720         5050\n',
            '         SER5N-HN    115.069      8.177        51643\n',
            '         MET6N-HN    120.910      8.813        53663\n',
            '        TRP40N-HN    123.335      8.005       -65111\n',
            '     TRP40NE1-HE1    130.204     10.294      -181131\n',
            '        ASN55N-HN    116.896      7.468      -105322\n'
        ]

        # Write the data out.
        file = DummyFileObject()
        write_list(file_prefix=file, res_names=res_names, res_nums=res_nums, atom1_names=atom1_names, atom2_names=atom2_names, w1=w1, w2=w2, data_height=heights)

        # Check the file data.
        lines = file.readlines()
        self.assertEqual(len(lines), len(file_data))
        for i in range(len(lines)):
            self.assertEqual(lines[i], file_data[i])
예제 #2
0
    def test_helix(self):
        """Test the lib.structure.pdb_write.helix() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.helix(file,
                        ser_num=1,
                        helix_id='H1',
                        init_res_name='ILE',
                        init_chain_id='A',
                        init_seq_num=23,
                        init_icode=None,
                        end_res_name='GLU',
                        end_chain_id='A',
                        end_seq_num=34,
                        end_icode=None,
                        helix_class=1,
                        comment=None,
                        length=12)

        # Test the record.
        records = file.readlines()
        actual = 'HELIX    1  H1 ILE A   23  GLU A   34  1                                  12    \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #3
0
    def test_atom(self):
        """Test the lib.structure.pdb_write.atom() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.atom(file,
                       serial=158,
                       name='CG',
                       res_name='GLU',
                       res_seq='11',
                       x=9.59,
                       y=-1.041,
                       z=-11.596,
                       occupancy=1.0,
                       temp_factor=0.0,
                       element='C')

        # Test the record.
        records = file.readlines()
        actual = 'ATOM    158 CG   GLU    11       9.590  -1.041 -11.596  1.00  0.00           C  \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #4
0
    def test_sheet(self):
        """Test the lib.structure.pdb_write.sheet() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.sheet(file, strand=1, sheet_id='BET', num_strands=5, init_res_name='GLY', init_chain_id='A', init_seq_num=10, init_icode=None, end_res_name='VAL', end_chain_id='A', end_seq_num=17, end_icode=None, sense=0, cur_atom=None, cur_res_name=None, cur_chain_id=None, cur_res_seq=None, cur_icode=None, prev_atom=None, prev_res_name=None, prev_chain_id=None, prev_res_seq=None, prev_icode=None)

        # Test the record.
        records = file.readlines()
        actual = 'SHEET    1 BET 5 GLY A  10  VAL A  17  0                                        \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #5
0
    def test_model(self):
        """Test the lib.structure.pdb_write.model() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.model(file, serial=1)

        # Test the record.
        records = file.readlines()
        actual = 'MODEL        1                                                                  \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #6
0
    def test_het(self):
        """Test the lib.structure.pdb_write.het() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.het(file, het_id='CA', chain_id='A', seq_num=1000, icode=None, num_het_atoms=1, text=None)

        # Test the record.
        records = file.readlines()
        actual = 'HET     CA  A1000       1                                                       \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #7
0
    def test_helix(self):
        """Test the lib.structure.pdb_write.helix() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.helix(file, ser_num=1, helix_id='H1', init_res_name='ILE', init_chain_id='A', init_seq_num=23, init_icode=None, end_res_name='GLU', end_chain_id='A', end_seq_num=34, end_icode=None, helix_class=1, comment=None, length=12)

        # Test the record.
        records = file.readlines()
        actual = 'HELIX    1  H1 ILE A   23  GLU A   34  1                                  12    \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #8
0
    def test_atom(self):
        """Test the lib.structure.pdb_write.atom() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.atom(file, serial=158, name='CG', res_name='GLU', res_seq='11', x=9.59, y=-1.041, z=-11.596, occupancy=1.0, temp_factor=0.0, element='C')

        # Test the record.
        records = file.readlines()
        actual = 'ATOM    158 CG   GLU    11       9.590  -1.041 -11.596  1.00  0.00           C  \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #9
0
    def test_model(self):
        """Test the lib.structure.pdb_write.model() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.model(file, serial=1)

        # Test the record.
        records = file.readlines()
        actual = 'MODEL        1                                                                  \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #10
0
    def test_subsubsection(self):
        """Test of the lib.text.sectioning.subsubsection() function."""

        # Write out the subsubsection.
        file = DummyFileObject()
        subsubsection(file=file, text='Test subsubsection')

        # Read the results.
        lines = file.readlines()
        print("Formatted subsubsection lines:  %s" % lines)

        # Check the title.
        real_lines = [
            '\n',
            'Test subsubsection\n',
            '~~~~~~~~~~~~~~~~~~\n',
            '\n',
        ]
        self.assertEqual(len(lines), len(real_lines))
        for i in range(len(lines)):
            self.assertEqual(lines[i], real_lines[i])
예제 #11
0
    def test_het(self):
        """Test the lib.structure.pdb_write.het() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.het(file,
                      het_id='CA',
                      chain_id='A',
                      seq_num=1000,
                      icode=None,
                      num_het_atoms=1,
                      text=None)

        # Test the record.
        records = file.readlines()
        actual = 'HET     CA  A1000       1                                                       \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #12
0
    def test_write_list(self):
        """Test the lib.software.sparky.write_list() function."""

        # The data.
        res_names = ['LEU', 'GLY', 'SER', 'MET', 'TRP', 'TRP', 'ASN']
        res_nums = [3, 4, 5, 6, 40, 40, 55]
        atom1_names = ['N', 'N', 'N', 'N', 'N', 'NE1', 'N']
        atom2_names = ['HN', 'HN', 'HN', 'HN', 'HN', 'HE1', 'HN']
        w1 = [122.454, 111.978, 115.069, 120.910, 123.335, 130.204, 116.896]
        w2 = [8.397, 8.720, 8.177, 8.813, 8.005, 10.294, 7.468]
        heights = [2535, 5050, 51643, 53663, -65111, -181131, -105322]

        # The result.
        file_data = [
            '      Assignment         w1         w2   Data Height\n', '\n',
            '         LEU3N-HN    122.454      8.397         2535\n',
            '         GLY4N-HN    111.978      8.720         5050\n',
            '         SER5N-HN    115.069      8.177        51643\n',
            '         MET6N-HN    120.910      8.813        53663\n',
            '        TRP40N-HN    123.335      8.005       -65111\n',
            '     TRP40NE1-HE1    130.204     10.294      -181131\n',
            '        ASN55N-HN    116.896      7.468      -105322\n'
        ]

        # Write the data out.
        file = DummyFileObject()
        write_list(file_prefix=file,
                   res_names=res_names,
                   res_nums=res_nums,
                   atom1_names=atom1_names,
                   atom2_names=atom2_names,
                   w1=w1,
                   w2=w2,
                   data_height=heights)

        # Check the file data.
        lines = file.readlines()
        self.assertEqual(len(lines), len(file_data))
        for i in range(len(lines)):
            self.assertEqual(lines[i], file_data[i])
예제 #13
0
    def test_title(self):
        """Test of the lib.text.sectioning.title() function."""

        # Write out the title.
        file = DummyFileObject()
        title(file=file, text='Test title')

        # Read the results.
        lines = file.readlines()
        print("Formatted title lines:  %s" % lines)

        # Check the title.
        real_lines = [
            '\n',
            '\n',
            '==============\n',
            '= Test title =\n',
            '==============\n',
            '\n',
        ]
        self.assertEqual(len(lines), len(real_lines))
        for i in range(len(lines)):
            self.assertEqual(lines[i], real_lines[i])
예제 #14
0
    def test_sheet(self):
        """Test the lib.structure.pdb_write.sheet() function."""

        # A dummy file to write to.
        file = DummyFileObject()

        # Create the PDB record.
        pdb_write.sheet(file,
                        strand=1,
                        sheet_id='BET',
                        num_strands=5,
                        init_res_name='GLY',
                        init_chain_id='A',
                        init_seq_num=10,
                        init_icode=None,
                        end_res_name='VAL',
                        end_chain_id='A',
                        end_seq_num=17,
                        end_icode=None,
                        sense=0,
                        cur_atom=None,
                        cur_res_name=None,
                        cur_chain_id=None,
                        cur_res_seq=None,
                        cur_icode=None,
                        prev_atom=None,
                        prev_res_name=None,
                        prev_chain_id=None,
                        prev_res_seq=None,
                        prev_icode=None)

        # Test the record.
        records = file.readlines()
        actual = 'SHEET    1 BET 5 GLY A  10  VAL A  17  0                                        \n'
        print(repr(records[0]))
        print(repr(actual))
        self.assertEqual(records[0], actual)
예제 #15
0
파일: data_types.py 프로젝트: tlinnet/relax
DATA_TYPES.append(['dict', {}])
DATA_TYPES.append(['dict', {'a': 0, 'b': 1}])

# Integers.
DATA_TYPES.append(['int', 2])
DATA_TYPES.append(['int', 10])
DATA_TYPES.append(['int', -10])

# Numpy ints.
DATA_TYPES.append(['int', zeros(2, int8)[0]])
DATA_TYPES.append(['int', zeros(2, int16)[0]])
DATA_TYPES.append(['int', zeros(2, int32)[0]])
DATA_TYPES.append(['int', zeros(2, int64)[0]])

# File descriptor.
DATA_TYPES.append(['file', DummyFileObject()])

# Floats.
DATA_TYPES.append(['float', 0.0])
DATA_TYPES.append(['float', 1e-7])
DATA_TYPES.append(['float', 1000000.0])

# Numpy floats.
DATA_TYPES.append(['float', zeros(2, float32)[0]])
DATA_TYPES.append(['float', zeros(2, float64)[0]])

# Functions.
DATA_TYPES.append(['function', dummy_fn])
DATA_TYPES.append(['function', dummy_fn2])

# Lists.