コード例 #1
0
 def lol_sequence(self):
     """ Returns sequence as a list of lists, without the '+' separator.
     
      Example:
       ['d1', 'd2', '+', 'd3'] ==> [['d1', 'd2'], ['d3']]
     """
     return make_lol_sequence(self._sequence)
コード例 #2
0
 def size(self):
     """Size of the complex is the number of strands."""
     if not self._strand_lengths :
         if not self._lol_sequence:
             self._lol_sequence = make_lol_sequence(self._sequence)
         self._strand_lengths = list(map(len, self._lol_sequence))
     return len(self._strand_lengths)
コード例 #3
0
 def canonical_form(self):
     """ Sort Sequences in a unique way for each complex.
     """
     if not self._canonical_form:
         all_variants = dict()
         if not self._lol_sequence:
             self._lol_sequence = make_lol_sequence(self._sequence)
         for e in range(0, self.size):
             canon = tuple(map(lambda x: tuple(map(str, x)), 
                 self._lol_sequence[e:] + self._lol_sequence[:e]))
             if canon not in all_variants:
                 all_variants[canon] = e
                 if self._memorycheck:
                     self.do_memorycheck(canon, e)
         self._canonical_form = sorted(all_variants)[0]
         self._rotations = abs(all_variants[self._canonical_form] - self.size)
     return self._canonical_form
コード例 #4
0
    def test_split_complex(self):
        se = list('CCCTTTGGG')
        ss = list('(((...)))')
        ps = utils.make_lol_sequence(se)
        pt = utils.make_pair_table(ss)
        exp = [(se, ss)]
        self.assertEqual(utils.split_complex(ps, pt), exp)

        se = list('CCCT+TTGGG')
        ss = list('(((.+..)))')
        ps = utils.make_lol_sequence(se)
        self.assertEqual(ps, [['C', 'C', 'C', 'T'], ['T', 'T', 'G', 'G', 'G']])
        pt = utils.make_pair_table(ss)
        exp = [(se, ss)]
        self.assertEqual(utils.split_complex(ps, pt), exp)

        se = list('CCCT+AAA+TTGGG')
        ss = list('(((.+...+..)))')
        ps = utils.make_lol_sequence(se)
        self.assertEqual(
            ps,
            [['C', 'C', 'C', 'T'], ['A', 'A', 'A'], ['T', 'T', 'G', 'G', 'G']])
        pt = utils.make_pair_table(ss)
        exp = [(list('CCCT+TTGGG'), list('(((.+..)))')),
               (list('AAA'), list('...'))]
        self.assertEqual(sorted(utils.split_complex(ps, pt)), sorted(exp))

        se = list('CCCT+AAA+TTTT+TTGGG')
        ss = list('(((.+...+....+..)))')
        ps = utils.make_lol_sequence(se)
        pt = utils.make_pair_table(ss)
        exp = [(list('CCCT+TTGGG'), list('(((.+..)))')),
               (list('AAA'), list('...')), (list('TTTT'), list('....'))]
        self.assertEqual(sorted(utils.split_complex(ps, pt)), sorted(exp))

        se = list('CCCT+AAA+GCGC+TTTT+TTGGG')
        ss = list('(((.+...+)()(+....+..)))')
        ps = utils.make_lol_sequence(se)
        pt = utils.make_pair_table(ss)
        exp = [(list('CCCT+GCGC+TTGGG'), list('(((.+)()(+..)))')),
               (list('AAA'), list('...')), (list('TTTT'), list('....'))]
        self.assertEqual(sorted(utils.split_complex(ps, pt)), sorted(exp))

        se = list('CCCT+AAA+GCGC+TTTT+TTGGG')
        ss = list('(((.+.(.+)()(+.)..+..)))')
        ps = utils.make_lol_sequence(se)
        pt = utils.make_pair_table(ss)
        exp = [(list('CCCT+TTGGG'), list('(((.+..)))')),
               (list('AAA+GCGC+TTTT'), list('.(.+)()(+.)..'))]
        self.assertEqual(sorted(utils.split_complex(ps, pt)), sorted(exp))
コード例 #5
0
 def get_domain(self, loc):
     if not self._lol_sequence:
         self._lol_sequence = make_lol_sequence(self._sequence)
     return self._lol_sequence[loc[0]][loc[1]]
コード例 #6
0
 def strand_length(self, pos):
     if not self._strand_lengths :
         if not self._lol_sequence:
             self._lol_sequence = make_lol_sequence(self._sequence)
         self._strand_lengths = list(map(len, self._lol_sequence))
     return self._strand_lengths[pos]