Example #1
0
 def setUp(self):
     self.mols1 = Read('Data/stringSel.pdb')
     self.mol1 = self.mols1[0]
     self.mols2 = Read('Data/protease.pdb')
     self.mol2 = self.mols2[0]
     self.mols = self.mols1 + self.mols2
     self.stringSel = StringSelector()
Example #2
0
 def test_select_with_empty_string(self):
     """
      test result with empty string returns all molecules
     """
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, "")
     self.assertEquals(result, self.molecules)
     self.assertEquals(result.stringRepr, self.molecules[0].name)
 def test_select_with_bad_key_returns_EmptySet(self):
     """
      test result with bad_key returns EmptySet
     """
     selString = ":::'backbone'"
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 0)
Example #4
0
 def test_select_with_bad_key_returns_EmptySet(self):
     """
      test result with bad_key returns EmptySet
     """
     selString = ":::'backbone'"
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 0)
 def test_select_with_empty_string(self):
     """
      test result with empty string returns all molecules
     """
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, "")
     self.assertEquals(result, self.molecules)
     self.assertEquals(result.stringRepr, self.molecules[0].name)
Example #6
0
 def test_select_with_lambda_molecule_expr(self):
     """
      test result with lambda x:x.name=='stringSel' returns 29 atoms
     """
     selString = "lambda x:x.name=='stringSel':::"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 29)
     self.assertEquals(result.stringRepr, selString)
Example #7
0
 def test_select_with_lambda_chain_expr(self):
     """
      test result with lambda x:x.id=='W' returns 5 atoms
     """
     selString = ":lambda x:x.id=='W'::"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 5)
     self.assertEquals(result.stringRepr, selString)
Example #8
0
 def test_select_with_lambda_residue_expr(self):
     """
      test result with lambda x:x.name==CA returns 9 atoms
     """
     selString = "::lambda x:x.type=='GLN':"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 9)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_hetatm_returns_5atoms(self):
     """
      test result with hetatm returns 5 atoms
     """
     selString = ":::hetatm"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 5)
     self.assertEquals(result.stringRepr, selString)
Example #10
0
 def test_select_with_hetatm_returns_5atoms(self):
     """
      test result with hetatm returns 5 atoms
     """
     selString = ":::hetatm"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 5)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_lambda_residue_expr(self):
     """
      test result with lambda x:x.name==CA returns 9 atoms
     """
     selString = "::lambda x:x.type=='GLN':"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 9)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_simple_Residue_full_name(self):
     """
      test result with simple Residue full_name
     """
     subset = self.molecules.chains.residues[:2]
     selString = subset.full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_compound_Residue_full_name(self):
     """
      test result with compound Residue full_name
     """
     subset = self.molecules.chains.residues[:2]
     selString = subset[0].full_name() + ';' + subset[1].full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #14
0
 def test_select_with_compound_Residue_full_name(self):
     """
      test result with compound Residue full_name
     """
     subset = self.molecules.chains.residues[:2]
     selString = subset[0].full_name() + ';' + subset[1].full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #15
0
 def test_select_with_simple_Residue_full_name(self):
     """
      test result with simple Residue full_name
     """
     subset = self.molecules.chains.residues[:2]
     selString = subset.full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #16
0
 def test_select_with_simple_Atom_full_name(self):
     """
      test result with simple Atom full_name
     """
     subset = self.molecules.allAtoms[:2]
     selString = subset.full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #17
0
 def test_select_with_backbone_returns_no_waters(self):
     """
      test result with backbone returns no waters
     """
     selString = ":::backbone"
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 12)
     self.assertEqual('HOH' not in result.parent.type, True)
     self.assertEquals(result.stringRepr, selString)
Example #18
0
 def test_select_with_CA_returns_3atoms(self):
     """
      test result with CA returns 3 atoms
     """
     selString = ":::CA"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 3)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_backbone_returns_no_waters(self):
     """
      test result with backbone returns no waters
     """
     selString = ":::backbone"
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 12)
     self.assertEqual('HOH' not in result.parent.type, True)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_lambda_chain_expr(self):
     """
      test result with lambda x:x.id=='W' returns 5 atoms
     """
     selString = ":lambda x:x.id=='W'::"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 5)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_simple_Atom_full_name(self):
     """
      test result with simple Atom full_name
     """
     subset = self.molecules.allAtoms[:2]
     selString = subset.full_name()
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #22
0
 def test_select_with_backbone_returns_12atoms(self):
     """
      test result with backbone returns 12 atoms
     """
     selString = ":::backbone"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 12)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_backbone_returns_12atoms(self):
     """
      test result with backbone returns 12 atoms
     """
     selString = ":::backbone"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 12)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_CA_returns_3atoms(self):
     """
      test result with CA returns 3 atoms
     """
     selString = ":::CA"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 3)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_lambda_molecule_expr(self):
     """
      test result with lambda x:x.name=='stringSel' returns 29 atoms
     """
     selString = "lambda x:x.name=='stringSel':::"
     #sanity check
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEquals(len(result), 29)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_lambda_atoms_expr_with_parentheses(self):
     """
      test result with lambda x:len(x.bonds)==1 returns 468 atoms for hsg1.pdb
     """
     selString = ":::lambda x:len(x.bonds)==1"
     stringSel = StringSelector()
     from MolKit import Read
     mol = Read("Data/hsg1.pdb")
     mol[0].buildBondsByDistance()
     result, msg = stringSel.select(mol, selString)
     self.assertEquals(len(result), 468)
     self.assertEquals(result.stringRepr, selString)
Example #27
0
 def test_select_with_lambda_atoms_expr_with_parentheses(self):
     """
      test result with lambda x:len(x.bonds)==1 returns 468 atoms for hsg1.pdb
     """
     selString = ":::lambda x:len(x.bonds)==1"
     stringSel = StringSelector()
     from MolKit import Read
     mol = Read("Data/hsg1.pdb")
     mol[0].buildBondsByDistance()
     result, msg = stringSel.select(mol, selString)
     self.assertEquals(len(result), 468)
     self.assertEquals(result.stringRepr, selString)
 def test_select_with_5_Residue_full_names(self):
     """
      test result with 5 Residue full_names joined with ';'
     """
     subset = self.molecules.chains.residues[:5]
     selString = ''
     for a in subset:
         selString += a.full_name() + ';'
     selString = selString[:-1]
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
 def test_select_all_atoms_from_compound_string(self):
     """
      test result using all the atoms' full_name()
     """
     selString = ''
     subset = self.molecules.allAtoms
     for a in subset:
         selString += a.full_name() + ';'
     selString = selString[:-1]
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #30
0
 def test_select_with_5_Residue_full_names(self):
     """
      test result with 5 Residue full_names joined with ';'
     """
     subset = self.molecules.chains.residues[:5]
     selString = ''
     for a in subset:
         selString += a.full_name() + ';'
     selString = selString[:-1]
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #31
0
 def test_select_all_atoms_from_compound_string(self):
     """
      test result using all the atoms' full_name()
     """
     selString = ''
     subset = self.molecules.allAtoms
     for a in subset:
         selString += a.full_name() + ';'
     selString = selString[:-1]
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #32
0
 def test_select_set_from_string(self):
     """
      test result using string which is key in Sets dict
     """
     sets = Sets()
     subset = self.molecules[0].allAtoms
     set_name = 'first'
     sets.add(set_name, subset)
     selString = ':::' + set_name
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString, sets=sets)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
 def test_select_set_from_string(self):
     """
      test result using string which is key in Sets dict
     """
     sets = Sets()
     subset = self.molecules[0].allAtoms
     set_name = 'first'
     sets.add(set_name, subset)
     selString = ':::' + set_name
     stringSel = StringSelector()
     result, msg = stringSel.select(self.molecules, selString, sets=sets)
     self.assertEqual(result, subset)
     self.assertEquals(result.stringRepr, selString)
Example #34
0
 def get(self, event=None, withMsg=False):
     args = self.buildArgs()
     atArg = self.atomEntry.get()
     #print "atArg=", atArg, "=='' is", atArg==""
     resArg = self.resEntry.get()
     #print "resArg=", resArg, "=='' is", resArg==""
     chainArg = self.chainEntry.get()
     #print "chainArg=", chainArg, "=='' is", chainArg==""
     molArg = self.molEntry.get()
     #print "molArg=", molArg, "=='' is", molArg==""
     if atArg != "":
         args = molArg + ':' + chainArg + ':' + resArg + ':' + atArg
     elif resArg != "":
         args = molArg + ':' + chainArg + ':' + resArg
     elif chainArg != "":
         args = molArg + ':' + chainArg
     else:
         args = molArg
     #print "calling StringSelector.select with args=", args
     selitem, msgStr = StringSelector().select(self.molSet,
                                               args,
                                               sets=self.sets,
                                               caseSensitive=self.userPref)
     #if StringSelector starts returning msgs fix here
     #selitem, msgStr = StringSelector().select(self.molSet, args, self.userPref)
     #return selitem, msgStr
     #if selitem and len(selitem):
     #    print "returning len(selitem)=", len(selitem)
     if withMsg:
         return selitem, msgStr
     else:
         return selitem
Example #35
0
 def setGeomAtomProp(self):
     if not len(self.atomSets): return
     from MolKit.molecule import Atom
     prop = 'colors'
     for actor in self.actors:
         if actor.name.find(prop) > 0:
             obj = actor.object
             if self.atomSets.has_key(obj.fullName):
                 #setstr = self.atomSets[obj.fullName]['atomset']
                 g = obj.mol.geomContainer
                 aset = g.atoms[obj.name].findType(Atom)
                 asetstr = aset.full_name(0)
                 #if len(asetstr) != len(setstr):
                 #    return
                 atList = []
                 func = g.geomPickToAtoms.get(obj.name)
                 if func:
                     atList = func(obj, range(len(obj.vertexSet.vertices)))
                 else:
                     allAtoms = g.atoms[obj.name]
                     if hasattr(obj, "vertexSet") and len(allAtoms) == len(
                             obj.vertexSet):
                         atList = allAtoms
                 if not len(atList): return
                 col = actor.getLastKeyFrame().getValue()
                 oname = None
                 if aset.colors.has_key(obj.name):
                     oname = obj.name
                 elif aset.colors.has_key(obj.parent.name):
                     oname = obj.parent.name
                 if not oname: return
                 if len(col) == 1:
                     for a in atList:
                         a.colors[oname] = tuple(col[0])
                 else:
                     for i, a in enumerate(atList):
                         a.colors[oname] = tuple(col[i])
                 from MolKit.stringSelector import StringSelector
                 selector = StringSelector()
                 #nset, msg = selector.select(atList, setstr)
                 nset, msg = selector.select(atList, asetstr)
 def setGeomAtomProp(self):
     if not len(self.atomSets) : return
     from MolKit.molecule import Atom
     prop = 'colors'
     for actor in self.actors:
         if actor.name.find(prop) > 0:
             obj = actor.object
             if self.atomSets.has_key(obj.fullName):
                 #setstr = self.atomSets[obj.fullName]['atomset']
                 g = obj.mol.geomContainer
                 aset = g.atoms[obj.name].findType(Atom)
                 asetstr = aset.full_name(0)
                 #if len(asetstr) != len(setstr):
                 #    return
                 atList = []
                 func = g.geomPickToAtoms.get(obj.name)
                 if func:
                     atList = func(obj, range(len(obj.vertexSet.vertices)))
                 else:
                     allAtoms = g.atoms[obj.name]
                     if hasattr(obj, "vertexSet") and len(allAtoms) == len(obj.vertexSet):
                         atList = allAtoms
                 if not len(atList): return
                 col = actor.getLastKeyFrame().getValue()
                 oname = None
                 if aset.colors.has_key(obj.name):
                     oname = obj.name
                 elif aset.colors.has_key(obj.parent.name):
                     oname = obj.parent.name
                 if not oname : return
                 if len(col) == 1:
                     for a in atList:
                         a.colors[oname] = tuple(col[0])
                 else:
                     for i, a in enumerate(atList):
                         a.colors[oname] = tuple(col[i])
                 from MolKit.stringSelector import StringSelector
                 selector = StringSelector()
                 #nset, msg = selector.select(atList, setstr)
                 nset, msg = selector.select(atList, asetstr)
Example #37
0
 def setUp(self):
     self.mols = Read('Data/stringSel.pdb')
     self.mol = self.mols[0]
     self.stringSel = StringSelector()
Example #38
0
 def test_constructor(self):
     """
     instantiate a StringSelector
     """
     stringSel = StringSelector()
     self.assertEquals(stringSel.__class__, StringSelector)
Example #39
0
 def setUp(self):
     self.mols = Read('Data/stringSel.pdb')
     self.mol = self.mols[0]
     self.mol.buildBondsByDistance()
     self.stringSel = StringSelector()
Example #40
0
class TwoMoleculeStringReprTests(StringReprBaseTests):

    def setUp(self):
        self.mols1 = Read('Data/stringSel.pdb')
        self.mol1 = self.mols1[0]
        self.mols2 = Read('Data/protease.pdb')
        self.mol2 = self.mols2[0]
        self.mols = self.mols1 + self.mols2
        self.stringSel = StringSelector()
    

    #tests for correction stringRepr initialization below sets
    def test_correct_MoleculeSet_stringRepr(self):
        """
         check moleculeSet stringRepr is correct
        """
        self.assertEquals(self.mols.stringRepr, "stringSel/+/protease")


    def test_correct_ChainSet_stringRepr(self):
        """
         check ChainSet stringRepr is correct
        """
        self.assertEquals(self.mols.chains.stringRepr, "stringSel:/+/protease:")


    def test_correct_ResidueSet_stringRepr(self):
        """
         check ResidueSet stringRepr is correct
        """
        self.assertEquals(self.mols.chains.residues.stringRepr, "stringSel::/+/protease::")


    def test_correct_AtomSet_stringRepr(self):
        """
         check AtomSet stringRepr is correct
        """
        self.assertEquals(self.mols.chains.residues.atoms.stringRepr, "stringSel:::/+/protease:::")


    #tests for correction stringRepr initialization below individual
    def test_correct_Molecule_ChainSet_stringRepr(self):
        """
         check single Molecule's chainSet stringRepr is correct
        """
        self.assertEquals(self.mol1.chains.stringRepr, "stringSel:")


    def test_correct_Chain1_ResidueSet_stringRepr(self):
        """
         check Chain1's residues stringRepr is correct
        """
        self.assertEquals(self.mols.chains[0].residues.stringRepr, "stringSel:A:")


    def test_correct_Chain2_ResidueSet_stringRepr(self):
        """
         check two chain's residues stringRepr is correct
        """
        self.assertEquals(self.mols.chains[1].residues.stringRepr, "stringSel:W:")


    def Qtest_correct_2Chain_ResidueSet_stringRepr(self):
        """
         check two Chains residues stringRepr is correct
        """
        self.assertEquals(self.mols.chains[0-2].residues.stringRepr, "stringSel::")


    def test_correct_last_Chain_ResidueSet_stringRepr(self):
        """
         check last Chain's residues stringRepr is correct
        """
        self.assertEquals(self.mols.chains[-1].residues.stringRepr, "protease:B:")


    def test_correct_Mol0_Chain0_ResidueSet_stringRepr(self):
        """
         check single Mol's single Chain's residues stringRepr 
        """
        self.assertEquals(self.mols[0].chains[0].residues.stringRepr, "stringSel:A:")


    def Xtest_correct_Mol0_Chains1_2_ResidueSet_stringRepr(self):
        """
         check single Mol's two Chain's residues stringRepr 
        """
        self.assertEquals(self.mols[0].chains[0:].residues.stringRepr, "stringSel::")


    def test_correct_Mols_Chains1_residues_atoms_stringRepr(self):
        """
         check single Chain's residues's atoms stringRepr 
        """
        self.assertEquals(self.mols.chains[0].residues.atoms.stringRepr, "stringSel:A::")


    def test_select_with_empty_string(self):
        """
         test result with empty string returns all mols
        """
        result, msg = self.stringSel.select(self.mols, "")
        self.assertEqual(self.mols.stringRepr, "stringSel/+/protease")



    def test_setLevel_protein_protein(self):
        """
         test setting protein level to protein
        """
        mols = self.mols.setLevel(Protein)
        self.assertEqual(mols.stringRepr, "stringSel/+/protease")


    def test_setLevel_protein_chain(self):
        """
         test setting protein level to chain
        """
        chains = self.mols.setLevel(Chain)
        self.assertEqual(chains.stringRepr, "stringSel:/+/protease:")


    def test_setLevel_protein_residue(self):
        """
         test setting protein level to residue
        """
        res = self.mols.setLevel(Residue)
        self.assertEqual(res.stringRepr, "stringSel::/+/protease::")


    def test_setLevel_protein_residue(self):
        """
         test setting protein level to Atom
        """
        ats = self.mols.setLevel(Atom)
        self.assertEqual(ats.stringRepr, "stringSel:::/+/protease:::")


    def test_setLevel_chain_protein(self):
        """
         test setting chain level to protein
        """
        mols = self.mols.chains.setLevel(Protein)
        self.assertEqual(mols.stringRepr, "stringSel/+/protease")


    def test_setLevel_chain_chain(self):
        """
         test setting chain level to chain
        """
        chains = self.mols.chains.setLevel(Chain)
        self.assertEqual(chains.stringRepr, "stringSel:/+/protease:")


    def test_setLevel_chain_residue(self):
        """
         test setting chain level to residue
        """
        res = self.mols.chains.setLevel(Residue)
        self.assertEqual(res.stringRepr, "stringSel::/+/protease::")


    def test_setLevel_chain_atom(self):
        """
         test setting chain level to Atom
        """
        ats = self.mols.chains.setLevel(Atom)
        self.assertEqual(ats.stringRepr, "stringSel:::/+/protease:::")



    def test_setLevel_residues_protein(self):
        """
         test setting residue level to protein
        """
        mols = self.mols.chains.residues.setLevel(Protein)
        self.assertEqual(mols.stringRepr, "stringSel/+/protease")


    def test_setLevel_residues_chain(self):
        """
         test setting residues level to chain
        """
        chains = self.mols.chains.residues.setLevel(Chain)
        self.assertEqual(chains.stringRepr, "stringSel:/+/protease:")


    def test_setLevel_residues_residue(self):
        """
         test setting residues level to residue
        """
        res = self.mols.chains.residues.setLevel(Residue)
        self.assertEqual(res.stringRepr, "stringSel::/+/protease::")


    def test_setLevel_residues_atom(self):
        """
         test setting residue level to Atom
        """
        ats = self.mols.chains.residues.setLevel(Atom)
        self.assertEqual(ats.stringRepr, "stringSel:::/+/protease:::")
Example #41
0
class StringSelectorTests(StringSelectorBaseTests):

    def setUp(self):
        self.mols = Read('Data/stringSel.pdb')
        self.mol = self.mols[0]
        self.mol.buildBondsByDistance()
        self.stringSel = StringSelector()
    

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


    #tests with 1 change of level
    def test_1level_select_with_empty_string(self):
        """
        test result with empty string ":" returns all chains
        """
        #stringSel = MVProteinSetSelector(self.mols, self.selString)
        #result, msg =  stringSel.go()
        result, msg = self.stringSel.select(self.mols, ":")
        self.assertEquals(result, self.mols.chains)
        self.assertEquals(result.__class__, self.mols.chains.__class__)



    def test_1level_select_end(self):
        """
         test select with '$'  returns last molecule.chains
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, "$:")
        self.assertEquals(result, self.mols[-1:].chains)


    def test_1level_select_end_2(self):
        """
         test select with ':$'  returns molecule's last chain
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, ":$")
        self.assertEquals(result[0], self.mols[-1:].chains[-1])


    def test_1level_select_with_valid_index(self):
        """
         test string with valid_index returns set with 1 item 
        """
        selString = "0:"
        #selString = "1:"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), len(self.mols[0].chains))
        self.assertEquals(result.__class__, self.mols.chains.__class__)


    def test_1level_select_with_invalid_index_returns_empty_set(self):
        """
         test string with invalid_index returns empty ChainSet
       FIX THIS: should it be an empty ChainSet?

        """
        selString = "2:"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEqual(result.__class__, ChainSet)
        #self.assertEqual(result.__class__, self.mols.chains.__class__)
        self.assertEqual(len(result), 0)
        self.assertEqual(msg[0], selString[0])


    def test_1level_select_with_valid_range(self):
        """
         test string with valid_range returns ChainSet with 2 items
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "0-1:"
        #selString = "1-2:"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), len(self.mols.chains))


    def test_1level_select_with_invalid_range(self):
        """
         test string with invalid_range returns set with 0 items 
       FIX THIS: should it be an empty ChainSet?
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "4-6:"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), 0)
        self.assertEquals(result.__class__, ChainSet)
        #self.assertEquals(result.__class__, self.mols.chains.__class__)


    def test_1level_select_with_valid_regex(self):
        """
         test string with valid_regex returns set with 1 items
         <this regex is intended to match 1, 2,or 3 followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[1-3]*:"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        #1crn has 1 chain
        self.assertEquals(len(result), 1)
        self.assertEquals(result.__class__, self.mols.chains.__class__)


    def test_1level_select_with_valid_regex_2(self):
        """
         test string with valid_regex returns set with 1 items
         <this regex is intended to match anything in range s-z
         followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[s-z]*:"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        self.assertEquals(len(result), len(self.mols[0].chains))
        self.assertEquals(result.__class__, self.mols.chains.__class__)


    #tests with 2 changes of level
    def test_2level_select_with_empty_string(self):
        """
        test result with empty string "::" returns all residues
        """
        #stringSel = MVProteinSetSelector(self.mols, self.selString)
        #result, msg =  stringSel.go()
        result, msg = self.stringSel.select(self.mols, "::")
        self.assertEquals(result, self.mols.chains.residues)
        self.assertEquals(result.__class__, self.mols.chains.residues.__class__)


    def test_2level_select_end(self):
        """
         test select with '$'  returns last molecule.residues
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, "$::")
        self.assertEquals(result, self.mols[-1:].chains.residues)


    def test_2level_select_end_2(self):
        """
         test select with ':$'  returns molecule's last residue
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, "::$")
        self.assertEquals(result[0], self.mols[-1:].chains.residues[-1])


    def test_2level_select_with_valid_index(self):
        """
        test string with valid_index:: returns residue set of 54 
        """
        selString = "0::"
        #selString = "1::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), len(self.mols.chains.residues))
        self.assertEquals(result.__class__, self.mols.chains.residues.__class__)


    def test_2level_select_with_invalid_index_returns_empty_set(self):
        """
        test string with invalid_index:: returns empty ResidueSet
       FIX THIS: should it be an empty residueSet?

        """
        selString = "2::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEqual(result.__class__, ResidueSet)
        #self.assertEqual(result.__class__, self.mols.chains.residues.__class__)
        self.assertEqual(len(result), 0)
        self.assertEqual(msg[0], selString[0])


    def test_2level_select_with_valid_range(self):
        """
         test string with valid_range returns all residues 
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "0-1::"
        #selString = "1-2::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), len(self.mols.chains.residues))


    def test_2level_select_with_invalid_range(self):
        """
        test string with invalid_range returns set with 0 items 
       FIX THIS: should it be an empty ResidueSet?
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "4-6::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), 0)
        self.assertEquals(result.__class__, ResidueSet)
        #self.assertEquals(result.__class__, self.mols.chains.residues.__class__)


    def test_2level_select_with_valid_regex(self):
        """
         test string with valid_regex:: returns set with 46 residues
         <this regex is intended to match 1, 2,or 3 followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[1-3]*::"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        #result matches 1crn only
        self.assertEquals(len(result), len(self.mols[1].chains.residues))
        self.assertEquals(result.__class__, self.mols.chains.residues.__class__)


    def test_2level_select_with_valid_regex_2(self):
        """
         test string with valid_regex:: returns residueSet of 8
         <this regex is intended to match anything in range s-z
         followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[s-z]*::"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        #result matches mols[0] only
        self.assertEquals(len(result), len(self.mols[0].chains.residues))
        self.assertEquals(result.__class__, self.mols.chains.residues.__class__)


    #tests with 3 changes of level
    def test_3level_select_with_empty_string(self):
        """
        test result with empty string ":::" returns all atoms
        """
        #stringSel = MVProteinSetSelector(self.mols, self.selString)
        #result, msg =  stringSel.go()
        result, msg = self.stringSel.select(self.mols, ":::")
        self.assertEquals(result, self.mols.allAtoms)
        self.assertEquals(result.__class__, self.mols.allAtoms.__class__)


    def test_3level_select_end(self):
        """
         test select with '$'  returns last molecule.atoms
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, "$:::")
        self.assertEquals(result, self.mols[-1:].allAtoms)


    def test_3level_select_end_2(self):
        """
         test select with ':$'  returns molecule's last atom
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        result, msg = self.stringSel.select(self.mols, ":::$")
        self.assertEquals(result[0], self.mols[-1:].allAtoms[-1])


    def test_3level_select_with_valid_index(self):
        """
         test string with valid_index returns set of atoms
        """
        selString = "0:::"
        #selString = "1:::"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        self.assertEquals(len(result), len(self.mols[0].allAtoms))
        self.assertEquals(result.__class__, self.mols.allAtoms.__class__)


    def test_3level_select_with_invalid_index_returns_empty_set(self):
        """
         test string with invalid_index returns empty AtomSet
       FIX THIS: should it be an empty AtomSet?

        """
        selString = "2:::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEqual(result.__class__, AtomSet)
        self.assertEqual(len(result), 0)
        self.assertEqual(msg[0], selString[0])


    def test_3level_select_with_valid_range(self):
        """
         test string with valid_range returns 1crn.allAtoms 
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "0-1:::"
        #selString = "1-2:::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), len(self.mols.allAtoms))


    def test_3level_select_with_invalid_range(self):
        """
         test string with invalid_range returns set with 0 items 
       FIX THIS: should it be an empty AtomSet?
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "4-6:::"
        result, msg = self.stringSel.select(self.mols, selString)
        self.assertEquals(len(result), 0)
        self.assertEquals(result.__class__, AtomSet)
        #self.assertEquals(result.__class__, self.mols.allAtoms.__class__)


    def test_3level_select_with_valid_regex(self):
        """
         test string with valid_regex returns AtomSet 1crn.allAtoms
         <this regex is intended to match 1, 2,or 3 followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[1-3]*:::"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        #result matches 1crn only
        self.assertEquals(len(result), len(self.mols[1].allAtoms))
        self.assertEquals(result.__class__, self.mols.allAtoms.__class__)


    def test_3level_select_with_valid_regex_2(self):
        """
         test string with valid_regex returns set with 1 items
         <this regex is intended to match anything in range s-z
         followed by anything>
        """
        new_mols = Read("Data/1crn.pdb")
        self.mols +=new_mols
        selString = "[s-z]*:::"
        result, msg = self.stringSel.select(self.mols, selString)
        #print "result=", result
        #result matches mols[0] only
        self.assertEquals(len(result), len(self.mols[0].allAtoms))
        self.assertEquals(result.__class__, self.mols.allAtoms.__class__)