示例#1
0
    def test_contains(self):
        # empty list
        blank = uniprot_kb.UniProtRecordList()
        self.assertFalse(uniprot_kb.UniProtRecord() in blank)
        self.assertFalse(self.list[0] in blank)

        # non-empty list
        self.assertFalse(uniprot_kb.UniProtRecord() in self.list)
        self.assertTrue(self.list[0] in self.list)
        self.assertTrue(copy.copy(self.list[0]) in self.list)
示例#2
0
 def test_extend(self):
     cpy = copy.deepcopy(self.list)
     self.assertEquals(len(cpy), 2)
     item = uniprot_kb.UniProtRecord()
     cpy.extend([item])
     self.assertEquals(len(cpy), 3)
     self.assertEquals(cpy[2], item)
示例#3
0
 def setUp(self):
     self.record = uniprot_kb.UniProtRecord(
         3, 1, 35780, 333, "GAPDH", "P46406", "G3P_RABIT",
         "Glyceraldehyde-3-phosphate dehydrogenase",
         "Oryctolagus cuniculus", "UP000001811",
         "MVKVGVNGFGRIGRLVTRAAFNSGKVDVVAINDPFIDLHYMVYMFQYDSTHGKFHGTVKAENGKLVINGKAITIFQERDPANIKWGDAGAEYVVESTGVFTTMEKAGAHLKGGAKRVIISAPSADAPMFVMGVNHEKYDNSLKIVSNASCTTNCLAPLAKVIHDHFGIVEGLMTTVHAITATQKTVDGPSGKLWRDGRGAAQNIIPASTGAAKAVGKVIPELNGKLTGMAFRVPTPNVSVVDLTCRLEKAAKYDDIKKVVKQASEGPLKGILGYTEDQVVSCDFNSATHSSTFDAGAGIALNDHFVKLISWYDNEFGYSNRVVDLMVHMASKE",
         "9986")
示例#4
0
    def test_copy(self):
        # test shallow copy (actually a deepcopy)
        cpy = copy.copy(self.list)
        self.assertEquals(self.list, cpy)
        cpy[1].id = "P04797"
        self.assertEquals(self.list, cpy)
        cpy.append(uniprot_kb.UniProtRecord())
        self.assertNotEquals(self.list, cpy)

        # test deep copy
        cpy = copy.deepcopy(self.list)
        self.assertEquals(self.list, cpy)
        cpy[1].id = "P02769"
        self.assertNotEquals(self.list, cpy)
        cpy.append(uniprot_kb.UniProtRecord())
        self.assertNotEquals(self.list, cpy)
示例#5
0
    def test_len(self):
        blank = uniprot_kb.UniProtRecordList()
        self.assertEquals(len(blank), 0)

        cpy = copy.copy(self.list)
        self.assertEquals(len(cpy), 2)
        cpy.append(uniprot_kb.UniProtRecord())
        self.assertEquals(len(cpy), 3)
示例#6
0
    def setUp(self):
        self.list = uniprot_kb.UniProtRecordList()

        # GAPDH
        self.list.append(
            uniprot_kb.UniProtRecord(
                3, 1, 35780, 333, "GAPDH", "P46406", "G3P_RABIT",
                "Glyceraldehyde-3-phosphate dehydrogenase",
                "Oryctolagus cuniculus", "UP000001811",
                "MVKVGVNGFGRIGRLVTRAAFNSGKVDVVAINDPFIDLHYMVYMFQYDSTHGKFHGTVKAENGKLVINGKAITIFQERDPANIKWGDAGAEYVVESTGVFTTMEKAGAHLKGGAKRVIISAPSADAPMFVMGVNHEKYDNSLKIVSNASCTTNCLAPLAKVIHDHFGIVEGLMTTVHAITATQKTVDGPSGKLWRDGRGAAQNIIPASTGAAKAVGKVIPELNGKLTGMAFRVPTPNVSVVDLTCRLEKAAKYDDIKKVVKQASEGPLKGILGYTEDQVVSCDFNSATHSSTFDAGAGIALNDHFVKLISWYDNEFGYSNRVVDLMVHMASKE",
                "9986"))

        # BSA
        self.list.append(
            uniprot_kb.UniProtRecord(
                4, 1, 69293, 607, "ALB", "P02769", "ALBU_BOVIN",
                "Serum albumin", "Bos taurus", "UP000009136",
                "MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQQCPFDEHVKLVNELTEFAKTCVADESHAGCEKSLHTLFGDELCKVASLRETYGDMADCCEKQEPERNECFLSHKDDSPDLPKLKPDPNTLCDEFKADEKKFWGKYLYEIARRHPYFYAPELLYYANKYNGVFQECCQAEDKGACLLPKIETMREKVLASSARQRLRCASIQKFGERALKAWSVARLSQKFPKAEFVEVTKLVTDLTKVHKECCHGDLLECADDRADLAKYICDNQDTISSKLKECCDKPLLEKSHCIAEVEKDAIPENLPPLTADFAEDKDVCKNYQEAKDAFLGSFLYEYSRRHPEYAVSVLLRLAKEYEATLEECCAKDDPHACYSTVFDKLKHLVDEPQNLIKQNCDQFEKLGEYGFQNALIVRYTRKVPQVSTPTLVEVSRSLGKVGTRCCTKPESERMPCTEDYLSLILNRLCVLHEKTPVSEKVTKCCTESLVNRRPCFSALTPDETYVPKAFDEKLFTFHADICTLPDTEKQIKKQTALVELLKHKPKATEEQLKTVMENFVAFVDKCCAADDKEACFAVEGPKLVVSTQTALA",
                "9913"))
示例#7
0
    def test_richcmp(self):
        blank = uniprot_kb.UniProtRecord()
        cpy = copy.copy(self.record)

        self.assertNotEquals(self.record, blank)
        self.assertEquals(self.record, cpy)
        self.assertLess(blank, self.record)
        self.assertLessEqual(blank, self.record)
        self.assertLessEqual(cpy, self.record)
        self.assertGreater(self.record, blank)
        self.assertGreaterEqual(self.record, blank)
        self.assertGreaterEqual(cpy, self.record)
示例#8
0
    def test_add(self):
        cpy = copy.copy(self.list)
        item = uniprot_kb.UniProtRecord()

        # __add__
        self.assertEquals(len(cpy + [item]), 3)
        self.assertEquals(len(cpy), 2)

        # __radd__
        self.assertEquals(len([item] + cpy), 3)
        self.assertEquals(len(cpy), 2)

        # __iadd__
        cpy += [item]
        self.assertEquals(len(cpy), 3)
示例#9
0
 def test_count(self):
     cpy = copy.copy(self.list)
     self.assertEquals(cpy.count(self.list[0]), 1)
     self.assertEquals(cpy.count(uniprot_kb.UniProtRecord()), 0)
示例#10
0
 def test_index(self):
     cpy = copy.copy(self.list)
     self.assertEquals(cpy.index(self.list[0]), 0)
     with self.assertRaises(IndexError):
         cpy.index(uniprot_kb.UniProtRecord())
示例#11
0
 def test_insert(self):
     cpy = copy.deepcopy(self.list)
     cpy.insert(0, uniprot_kb.UniProtRecord())
     self.assertEquals(len(cpy), 3)
     self.assertEquals(cpy[0], uniprot_kb.UniProtRecord())