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_any(self):
        """find_any should be True if one of the words is in the string"""
        
        f = find_any('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'),1) #one of the elements
        self.assertEqual(f('bxxx'),1) #one of the elements
        self.assertEqual(f('axxxb'),1) #all elements
        self.assertEqual(f('aaaa'),1) #repeated element

        # works on any sequence
        f = find_any(['foo','bar'])
        self.assertEqual(f("joe"),0)
        self.assertEqual(f("only foo"),1)
        self.assertEqual(f("bar and foo"),1)
Ejemplo n.º 3
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)