Exemplo n.º 1
0
    def _det_pdb_element(self, atom_name):
        """Try to determine the element from the PDB atom name.

        @param atom_name:   The PDB atom name.
        @type atom_name:    str
        @return:            The element name, or None if unsuccessful.
        @rtype:             str or None
        """

        # Strip away the "'" character (for RNA, etc.).
        element = atom_name.strip("'")

        # Strip away atom numbering, from the front and end.
        element = element.strip(digits)

        # Amino acid atom translation table (note, numbers have been stripped already!).
        table = {'C': ['CA', 'CB', 'CG', 'CD', 'CE', 'CH', 'CZ'],
                 'N': ['ND', 'NE', 'NH', 'NZ'],
                 'H': ['HA', 'HB', 'HG', 'HD', 'HE', 'HH', 'HT', 'HZ'],
                 'O': ['OG', 'OD', 'OE', 'OH', 'OT'],
                 'S': ['SD', 'SG']
        }

        # Translate amino acids.
        for key in table:
            if element in table[key]:
                element = key
                break

        # Return the element if it is in the periodic table.
        if periodic_table.has_element(symbol=element):
            return element

        # Else, throw a warning.
        warn(RelaxWarning("Cannot determine the element associated with atom '%s'." % atom_name))
Exemplo n.º 2
0
    def _det_pdb_element(self, atom_name):
        """Try to determine the element from the PDB atom name.

        @param atom_name:   The PDB atom name.
        @type atom_name:    str
        @return:            The element name, or None if unsuccessful.
        @rtype:             str or None
        """

        # Strip away the "'" character (for RNA, etc.).
        element = atom_name.strip("'")

        # Strip away atom numbering, from the front and end.
        element = element.strip(digits)

        # Amino acid atom translation table (note, numbers have been stripped already!).
        table = {
            'C': ['CA', 'CB', 'CG', 'CD', 'CE', 'CH', 'CZ'],
            'N': ['ND', 'NE', 'NH', 'NZ'],
            'H': ['HA', 'HB', 'HG', 'HD', 'HE', 'HH', 'HT', 'HZ'],
            'O': ['OG', 'OD', 'OE', 'OH', 'OT'],
            'S': ['SD', 'SG']
        }

        # NMR Pseudo-atoms (with trailing numbers stripped).
        table['H'] += [
            'QA', 'QB', 'QD', 'QE', 'QG', 'QH', 'QQD', 'QQG', 'QR', 'QZ'
        ]

        # Translate amino acids.
        for key in table:
            if element in table[key]:
                element = key
                break

        # Return the element if it is in the periodic table.
        if periodic_table.has_element(symbol=element):
            return element

        # Else, throw a warning.
        warn(
            RelaxWarning(
                "Cannot determine the element associated with atom '%s'." %
                atom_name))
Exemplo n.º 3
0
    def test_has_element_XYZ(self):
        """Test of the Periodic_table.has_element() method with the symbol 'XYZ'."""

        # Check.
        self.assertTrue(not periodic_table.has_element('XYZ'))
Exemplo n.º 4
0
    def test_has_element_Ni(self):
        """Test of the Periodic_table.has_element() method with the symbol 'Ni'."""

        # Check.
        self.assertTrue(periodic_table.has_element('Ni'))
Exemplo n.º 5
0
    def test_has_element_XYZ(self):
        """Test of the Periodic_table.has_element() method with the symbol 'XYZ'."""

        # Check.
        self.assertTrue(not periodic_table.has_element("XYZ"))
Exemplo n.º 6
0
    def test_has_element_Ni(self):
        """Test of the Periodic_table.has_element() method with the symbol 'Ni'."""

        # Check.
        self.assertTrue(periodic_table.has_element("Ni"))