class AtomSetSelectorTests(AtomSetSelectorBaseTests): def setUp(self): self.mols = Read('Data/stringSel.pdb') new_mols = Read("Data/1crn.pdb") self.mols +=new_mols self.atoms = self.mols.chains.residues.atoms self.stringSel = AtomSetSelector() def tearDown(self): """ clean-up """ del(self.atoms) del(self.mols) def test_select_with_empty_string(self): """ test result with empty string returns all atoms """ result, msg = self.stringSel.select(self.atoms, "") self.assertEquals(result, self.atoms) def test_select_end(self): """ test select with '$' returns last item """ result, msg = self.stringSel.select(self.atoms, "$") self.assertEquals(result, self.atoms[-1:]) def test_select_with_valid_index(self): """ test string with valid_index returns set with 1 item """ selString = "1" result, msg = self.stringSel.select(self.atoms, selString) self.assertEquals(len(result), 1) def test_select_with_invalid_index_returns_empty_set(self): """ test string with invalid_index returns empty set """ selString = "777" result, msg = self.stringSel.select(self.atoms, selString) self.assertEqual(result.__class__, self.atoms.__class__) self.assertEqual(len(result), 0) self.assertEqual(msg[0], selString) def test_select_with_valid_range(self): """ test string with valid_range returns set with 2 items """ selString = "1-2" result, msg = self.stringSel.select(self.atoms, selString) #FIX THIS self.assertEquals(len(result), 2) def test_select_with_invalid_range(self): """ test string with invalid_range returns set with 0 items """ selString = "649-713" result, msg = self.stringSel.select(self.atoms, selString) self.assertEquals(len(result), 0) def test_select_with_valid_regex(self): """ test string with valid_regex returns set with 1 items <this regex is intended to match anything in range A-Z followed by anything> """ selString = "CA" result, msg = self.stringSel.select(self.atoms, selString) #print "result=", result self.assertEquals(len(result), 49) def test_select_valid_set(self): """ test string with valid set name returns 1 set """ these_sets = Sets() new_set = self.atoms[:10] key = 'first_atoms' these_sets.add(key, new_set) selString = key result, msg = self.stringSel.select(self.atoms, selString, sets=these_sets) self.assertEquals(len(result), len(new_set)) self.assertEquals(result, new_set)