Exemplo n.º 1
0
    def _get_splice_site_coordinates(self, t, start, end, exon_i):
        """Returns distance from exon."""

        left_diff, right_diff = TranscriptProviderUtils.determine_closest_distance_from_exon(start, end, exon_i,  t)

        if abs(left_diff) < abs(right_diff):
            dist_from_exon = left_diff * -1
            if dist_from_exon > -1: dist_from_exon = -1
        elif abs(right_diff) < abs(left_diff):
            dist_from_exon = right_diff * -1
            if dist_from_exon < 1: dist_from_exon = 1
        else:
            dist_from_exon = 0

        if t.get_strand() == "-":
            dist_from_exon *= -1
        return dist_from_exon
Exemplo n.º 2
0
    def _get_splice_site_coordinates(self, t, start, end, exon_i):
        """Returns distance from exon."""

        left_diff, right_diff = TranscriptProviderUtils.determine_closest_distance_from_exon(
            start, end, exon_i, t)

        if abs(left_diff) < abs(right_diff):
            dist_from_exon = left_diff * -1
            if dist_from_exon > -1: dist_from_exon = -1
        elif abs(right_diff) < abs(left_diff):
            dist_from_exon = right_diff * -1
            if dist_from_exon < 1: dist_from_exon = 1
        else:
            dist_from_exon = 0

        if t.get_strand() == "-":
            dist_from_exon *= -1
        return dist_from_exon
    def _extract_exon_info(self, position, tx):
        """
        Create basic information about the given position relative to the transcript.

        :param int position: in genomic space
        :param Transcript tx:
         :return tuple:
            [0]: closest exon index of the position (0-based),
             [1]: whether the distance was left in genomic space (false for overlap)
             [2]: whether the position overlaps an exon

        """
        exon_index = TranscriptProviderUtils.determine_closest_exon(tx, position, position)
        if exon_index is None:
            return exon_index, None, None, None
        left_distance, right_distance = TranscriptProviderUtils.determine_closest_distance_from_exon(position, position,
                                                                                                     exon_index, tx)
        is_in_exon = (left_distance <= 0) and (right_distance >= 0)
        is_diff_is_positive = (left_distance > 0) and (right_distance > 0)
        is_negative_strand = (tx.get_strand() == "-")
        return exon_index, is_diff_is_positive, is_in_exon, is_negative_strand
    def _extract_exon_info(self, position, tx):
        """
        Create basic information about the given position relative to the transcript.

        :param int position: in genomic space
        :param Transcript tx:
         :return tuple:
            [0]: closest exon index of the position (0-based),
             [1]: whether the distance was left in genomic space (false for overlap)
             [2]: whether the position overlaps an exon

        """
        exon_index = TranscriptProviderUtils.determine_closest_exon(tx, position, position)
        if exon_index is None:
            return exon_index, None, None, None
        left_distance, right_distance = TranscriptProviderUtils.determine_closest_distance_from_exon(position, position,
                                                                                                     exon_index, tx)
        is_in_exon = (left_distance <= 0) and (right_distance >= 0)
        is_diff_is_positive = (left_distance > 0) and (right_distance > 0)
        is_negative_strand = (tx.get_strand() == "-")
        return exon_index, is_diff_is_positive, is_in_exon, is_negative_strand
    def test_determine_closest_distance_from_exon_in_exon(self):
        tx = self.retrieve_test_transcript_MAPK1()

        # Right in exon 1
        left_diff, right_diff = TranscriptProviderUtils.determine_closest_distance_from_exon(22162000, 22162005, 1,  tx)
        self.assertTrue(left_diff < 0 and right_diff > 0, "left distance should be negative while right distance should be positive.")