Ejemplo n.º 1
0
 def test_reverse_complement(self):
   self.assertEqual(
     utils.reverse_complement("AUGGCCAUUGUAA"),
     "UACCGGUAACAUU"[::-1]
   )
   self.assertEqual(
     utils.reverse_complement("ATGGCCATTGTAA"),
     "TACCGGTAACATT"[::-1]
   )
Ejemplo n.º 2
0
    def find_potential_targets_with_seed(self):
        """
        Searches for seed(s) in the target sequence.

        Args:

        """
        # Reset
        out = {
            'end_sites': [],
            'seed_lengths': [],
            'nb_mismatches_except_gu_wobbles': [],
            'nb_gu_wobbles': [],
            'pairings': [],
        }
        # Compute
        target_seq_rc = utils.reverse_complement(self.target_seq)

        # Sliding window (step size 1 of course) on the target sequence with all
        # possible target site. Nucleotide(s) before mirna_start_pairing has to
        # be paired and we stop before the target site is shorter than
        # min_target_length (=>sites length equal to min_target_length are
        # included) i is 0-based

        upper = self.mirna_start_pairing - 1
        lower = self.len_target_seq - self.min_target_length + 1
        for i in range(upper, lower):
            # We start with the longest seed and stop as soon as we find one
            for seed_length in self.allowed_lengths[::-1]:
                target_subseq = target_seq_rc[i: i + seed_length]
                p = find_pairings(target_subseq, self.mirna_seq,
                                  self.mirna_start_pairing - 1, True)
                nb_mismatches_except_gu_wobbles = p[0]
                nb_gu_wobbles = p[1]
                pairing = p[2]

                t_o = (nb_mismatches_except_gu_wobbles <=
                       self.allowed_mismatches[seed_length])
                t_t = nb_gu_wobbles <= self.allowed_gu_wobbles[seed_length]

                if t_o and t_t:
                    # end_site is 1-based and is the end of the target site on
                    # the real (=not the reverse-complemented) target sequence
                    end_site = (self.len_target_seq - i +
                                self.mirna_start_pairing - 1)
                    out['end_sites'].append(end_site)
                    out['seed_lengths'].append(seed_length)
                    out['nb_mismatches_except_gu_wobbles'].append(
                        nb_mismatches_except_gu_wobbles)
                    out['nb_gu_wobbles'].append(nb_gu_wobbles)
                    out['pairings'].append(pairing)
                    if self.take_best:
                        break

        self.__dict__.update(out)
        return out