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])
    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
    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)
 def test_call_empty(self):
     """Empty Filter should return True when called on anything"""
     f = Filter('', {})
     data = ['aa', 'bb', 'cc']
     self.assertEqual(f(data), True)