Ejemplo n.º 1
0
    def setUp(self):
        """Define some standard Organizers for testing"""
        self.Empty = Organizer([])
        
        self.a = Filter('a',{None:[find_any('a')]})
        self.b = Filter('b',{None:[find_any('b')]})
        self.Ab_org = Organizer([self.a,self.b])
        
        lsu = Filter('LSU',{None:[exclude_if_more('N',5)],\
                            'Gene':[find_any(['LSU'])]})
        ssu = Filter('SSU',{None:[exclude_if_more('N',5)],\
                            'Gene':[find_any(['SSU'])]})
        self.Gene_org = Organizer([lsu,ssu])
        
        self.Ab_seq = ['aa','bb','abab','cc','']
        self.seq1 = Sequence('ACGU',{'Gene':'LSU'})
        self.seq2 = Sequence('ACGUACGU',{'Gene':'SSU'})
        self.seq3 = Sequence('ACGUNNNNNN',{'Gene':'LSU'})
        self.seq4 = Sequence('ACGUNNNNNN',{'Gene':'SSU'})
        self.seq5 = Sequence('ACGU',{})
        self.seq6 = Sequence('',{})
        self.seq7 = Sequence('ACGU',{'Gene':'unit'})
        
        self.Gene_seq = [self.seq1,self.seq2,self.seq3,self.seq4,\
                self.seq5,self.seq6,self.seq7]

        f = Filter('valid',{None:[find_all('AGCU'),find_no('N')],\
                            'Gene':[find_any(['LSU'])]})
        self.Mult_func_org = Organizer([f])
Ejemplo n.º 2
0
    def test_find_all(self):
        """find_all should be True if all words appear in the string"""

        f = find_all('ab')
        self.assertEqual(f(''),0) #empty
        self.assertRaises(AttributeError,f,None) # none
        self.assertEqual(f('cde'),0) #none of the elements
        self.assertEqual(f('axxx'),0) #one of the elements
        self.assertEqual(f('bxxx'),0) #one of the elements
        self.assertEqual(f('axxxb'),1) #all elements
        self.assertEqual(f('aaaa'),0) #repeated element

        # works on any sequence
        f = find_all(['foo','bar'])
        self.assertEqual(f("joe"),0)
        self.assertEqual(f("only foo"),0)
        self.assertEqual(f("bar and foo"),1)
Ejemplo n.º 3
0
    def test_init(self):
        """Filter should init as expected"""
        empty_filter = Filter('',{})
        named_empty_filter = Filter('Archaea',{})

        self.assertEqual(empty_filter,{})
        self.assertEqual(empty_filter.Name,'')
        self.assertEqual(named_empty_filter,{})
        self.assertEqual(named_empty_filter.Name,'Archaea')
        
        f = find_all('abcd')
        g = keep_if_more_other('ab',7)
        fil = Filter('Archaea',{'Arch':[f,g]})
        assert fil['Arch'][0] is f
        assert fil['Arch'][1] is g
Ejemplo n.º 4
0
 def test_call_full(self):
     """Filter should return True if the object satisfies all criteria"""
     seq1 = Sequence('ACGU',{'Gene':'LSU'})
     seq2 = Sequence('ACGUACGU',{'Gene':'SSU'})
     seq3 = Sequence('ACGUN',{'Gene':'LSU'})
     seq4 = Sequence('ACG',{'Gene':'LSU'})
     seq5 = Sequence('ACGU',{})
     seq6 = Sequence('',{})
     
     f = Filter('valid',{None:[find_all('AGCU'),find_no('N')],\
                         'Gene':[find_any(['LSU'])]})
     self.assertEqual(f(seq1),True)
     self.assertEqual(f(seq2),False)
     self.assertEqual(f(seq3),False)
     self.assertEqual(f(seq4),False)
     self.assertEqual(f(seq5),False)
     self.assertEqual(f(seq6),False)