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()
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)
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 test_constructor(self): """ instantiate an AtomSetSelector """ stringSel = AtomSetSelector() self.assertEquals(stringSel.__class__, AtomSetSelector)