Пример #1
0
class ChainSetSelectorTests(ChainSetSelectorBaseTests):


    def setUp(self):
        self.mols = Read('Data/stringSel.pdb')
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        self.chains = self.mols.chains
        self.stringSel = ChainSetSelector()
    

    def tearDown(self):
        """
        clean-up
        """
        del(self.chains)
        del(self.mols)


    def test_select_with_empty_string(self):
        """
         test result with empty string returns all chains
        """
        result, msg = self.stringSel.select(self.chains, "")
        self.assertEquals(result, self.chains)


    def test_select_end(self):
        """
        test select with '$'  returns last item
        """
        result, msg = self.stringSel.select(self.chains, "$")
        self.assertEquals(result, self.chains[-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.chains, 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 = "7"
        result, msg = self.stringSel.select(self.chains, selString)
        self.assertEqual(result.__class__, self.chains.__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.chains, selString)
        self.assertEquals(len(result), 2)


    def test_select_with_invalid_range(self):
        """
         test string with invalid_range returns set with 0 items 
        """
        selString = "4-6"
        result, msg = self.stringSel.select(self.chains, 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 = "A"
        result, msg = self.stringSel.select(self.chains, selString)
        #print "result=", result
        self.assertEquals(len(result), 1)


    def test_select_valid_set(self):
        """
         test string with valid set name returns 1 set
        """
        these_sets = Sets()
        key = 'first'
        these_sets.add(key, self.mols.chains[1:])
        selString = key
        result, msg = self.stringSel.select(self.chains, selString, 
                                        sets=these_sets)
        #print "result=", result
        self.assertEquals(len(result), 2)
        self.assertEquals(result, self.chains[1:])
Пример #2
0
 def setUp(self):
     self.mols = Read('Data/stringSel.pdb')
     new_mols = Read("Data/1crn.pdb")
     self.mols +=new_mols
     self.chains = self.mols.chains
     self.stringSel = ChainSetSelector()
Пример #3
0
 def test_constructor(self):
     """
     instantiate an ChainSetSelector
     """
     stringSel = ChainSetSelector()
     self.assertEquals(stringSel.__class__, ChainSetSelector)