Beispiel #1
0
    def __init__(self,
                 master,
                 check=0,
                 molSet=MoleculeSet([]),
                 userPref='cS',
                 vf=None,
                 all=1,
                 crColor=(0., 1., 0),
                 clearButton=True,
                 showButton=True,
                 sets=None,
                 **kw):

        if not kw.get('packCfg'):
            self.packCfg = {'side': 'top', 'anchor': 'w', 'fill': 'x'}

        self.sets = sets
        #all is a shortcut to use all of default values
        if 'all' in kw.keys():
            all = 1
        elif __debug__:
            if check:
                apply(checkKeywords, ('stringSelector', self.entryKeywords),
                      kw)

        Tkinter.Frame.__init__(self, master)
        ##????
        Tkinter.Pack.config(self, side='left', anchor='w')

        #to make a stringSelector need vf, moleculeSet, selString
        self.master = master
        self.molSet = molSet
        self.residueSelector = ResidueSetSelector()
        self.atomSelector = AtomSetSelector()
        self.userPref = userPref
        self.vf = vf
        if not self.vf is None:
            self.addGeom(crColor)
        else:
            self.showCross = None
        self.molCts = {}
        self.chainCts = {}

        # optsDict includes defaults for all possible widgets
        # in practice
        # user can specify which widgets to put into gui
        d = self.optsDict = {}

        #first check for menubuttons:

        llists = [self.entryKeywords, self.menuKeywords, self.buttonKeywords]
        if all:
            if not clearButton:
                self.buttonKeywords.remove("clearBut")
            if not showButton:
                self.buttonKeywords.remove("showBut")
            for l in llists:
                for key in l:
                    d[key] = 1

        else:
            for l in llists:
                for key in l:
                    d[key] = kw.get(key)

        self.flexChildren = {
            'mol': ['molLabel', 'molEntry'],
            'chain': ['chainLabel', 'chainEntry'],
            'res': ['resLabel', 'resEntry'],
            'atom': ['atomLabel', 'atomEntry'],
        }

        for w in ['molWids', 'chainWids', 'resWids', 'atomWids']:
            if kw.get(w):
                lab = w[:-4]
                s = lab + 'Label'
                d[s] = 1
                s1 = lab + 'Entry'
                d[s1] = 1

        # instantiate all Tkinter variables (?)
        #DON"T HAVE ANY???
        self.buildTkVars()

        # only build requested widgets(?)
        self.buildifdDict()

        # build commandDictionary
        self.buildCmdDict()

        self.buildGUI()
Beispiel #2
0
class ResidueSetSelectorTests(ResidueSetSelectorBaseTests):


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

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


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


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


    def test_select_with_invalid_range(self):
        """
         test string with invalid_range returns set with 0 items 
        """
        selString = "64-71"
        result, msg = self.stringSel.select(self.residues, 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.residues, selString)
        #print "result=", result
        self.assertEquals(len(result), 11)


    def test_select_valid_set(self):
        """
         test string with valid set name returns 1 set
        """
        these_sets = Sets()
        new_set = self.residues[:10]
        key = 'first_residues'
        these_sets.add(key, new_set)
        selString = key
        result, msg = self.stringSel.select(self.residues, selString, 
                                        sets=these_sets)
        self.assertEquals(len(result), len(new_set))
        self.assertEquals(result, new_set)
Beispiel #3
0
 def setUp(self):
     self.mols = Read('Data/stringSel.pdb')
     new_mols = Read("Data/1crn.pdb")
     self.mols +=new_mols
     self.residues = self.mols.chains.residues
     self.stringSel = ResidueSetSelector()
Beispiel #4
0
 def test_constructor(self):
     """
     instantiate an ResidueSetSelector
     """
     stringSel = ResidueSetSelector()
     self.assertEquals(stringSel.__class__, ResidueSetSelector)