def test_with_quotation_mark_atom(self, mock_get_color): '''Handle repeated atoms indicated by `{"}`.''' mock_get_color.return_value = 'colorname' inp = ['''{AAAABCCCDDDDEFF}colorname 'G' 0.0,1.0,2.0''', '''{"}colorname 'G' -0.0,-1.0,-2.0'''] res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, res[1].atom)
def test_with_quotation_mark_atom(self, mock_get_color): '''Handle repeated atoms indicated by `{"}`.''' mock_get_color.return_value = 'colorname' inp = [ '''{AAAABCCCDDDDEFF}colorname 'G' 0.0,1.0,2.0''', '''{"}colorname 'G' -0.0,-1.0,-2.0''' ] res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, res[1].atom)
def test_with_question_mark_in_atom_desc(self, mock_get_color): '''Should handle ? in atom name e.g. "H?" for water hydrogen.''' mock_get_color.return_value = 'colorname' inp = ["{ H? HOH 293 A}colorname 'G' 0.0,1.0,2.0"] ref_atom = {'name': 'H', 'alt': '', 'resn': 'HOH', 'resi': '293', 'chain': 'A'} res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom)
def test_with_spaces_in_atom_desc(self, mock_get_color): '''Should handle spaces in atom name, alt, resn, resi, and chain.''' mock_get_color.return_value = 'colorname' inp = ["{ CA SER 26 A}colorname 'G' 0.0,1.0,2.0"] ref_atom = {'name': 'CA', 'alt': '', 'resn': 'SER', 'resi': '26', 'chain': 'A'} res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom)
def test_general_form(self, mock_get_color): mock_get_color.return_value = 'colorname' inp = ["{AAAABCCCDDDDEFF}colorname 'G' 0.0,1.0,2.0"] ref_atom = {'name': 'AAAA', 'alt': 'B', 'resn': 'CCC', 'resi': 'DDDDE', 'chain': 'FF'} res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom) self.assertEqual(res[0].color, 'colorname') self.assertEqual(res[0].pm, 'G') self.assertEqual(res[0].coords, [0.0, 1.0, 2.0])
def test_with_question_mark_in_atom_desc(self, mock_get_color): '''Should handle ? in atom name e.g. "H?" for water hydrogen.''' mock_get_color.return_value = 'colorname' inp = ["{ H? HOH 293 A}colorname 'G' 0.0,1.0,2.0"] ref_atom = { 'name': 'H', 'alt': '', 'resn': 'HOH', 'resi': '293', 'chain': 'A' } res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom)
def test_with_spaces_in_atom_desc(self, mock_get_color): '''Should handle spaces in atom name, alt, resn, resi, and chain.''' mock_get_color.return_value = 'colorname' inp = ["{ CA SER 26 A}colorname 'G' 0.0,1.0,2.0"] ref_atom = { 'name': 'CA', 'alt': '', 'resn': 'SER', 'resi': '26', 'chain': 'A' } res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom)
def test_general_form(self, mock_get_color): mock_get_color.return_value = 'colorname' inp = ["{AAAABCCCDDDDEFF}colorname 'G' 0.0,1.0,2.0"] ref_atom = { 'name': 'AAAA', 'alt': 'B', 'resn': 'CCC', 'resi': 'DDDDE', 'chain': 'FF' } res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].atom, ref_atom) self.assertEqual(res[0].color, 'colorname') self.assertEqual(res[0].pm, 'G') self.assertEqual(res[0].coords, [0.0, 1.0, 2.0])
def test_with_negative_coords(self, mock_get_color): '''Handle negative coordinates.''' mock_get_color.return_value = 'colorname' inp = ["{AAAABCCCDDDDEFF}colorname 'G' -0.0,-1.0,-2.0"] res = pt._parse_dotlist_body(inp) self.assertEqual(res[0].coords, [-0.0, -1.0, -2.0])