Exemplo n.º 1
0
 def chunk_relative_interval_to_cds(self, chr_start: int, chr_end: int, chr_strand: Strand) -> Location:
     """Converts a contiguous interval on the chunk-relative sequence to a relative location within the CDS."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS positions on non-coding transcript")
     return self.cds.chunk_relative_location.parent_to_relative_location(
         SingleInterval(chr_start, chr_end, chr_strand, parent=self.cds.chunk_relative_location.parent)
     )
Exemplo n.º 2
0
 def get_protein_sequence(
     self,
     truncate_at_in_frame_stop: Optional[bool] = False,
     translation_table: Optional[TranslationTable] = TranslationTable.DEFAULT,
 ) -> Sequence:
     """Return the translation of this transcript, if possible."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No translation on non-coding transcript")
     return self.cds.translate(
         truncate_at_in_frame_stop=truncate_at_in_frame_stop, translation_table=translation_table
     )
Exemplo n.º 3
0
    def get_3p_interval(self) -> Location:
        """Returns the 3' UTR as a location, if it exists.

        WARNING: If this is a chunk-relative transcript, the result of this function will also be chunk-relative.
        """
        if not self.is_coding:
            raise NoncodingTranscriptError("No 3' UTR on a non-coding transcript")
        # handle the edge case where the CDS is full length
        if self.cds.chunk_relative_location == self.chunk_relative_location:
            return EmptyLocation()
        cds_inclusive_end_on_transcript = self.cds_pos_to_transcript(len(self.cds.chunk_relative_location) - 1)
        return self.chunk_relative_location.relative_interval_to_parent_location(
            cds_inclusive_end_on_transcript + 1, len(self._location), Strand.PLUS
        )
Exemplo n.º 4
0
 def get_cds_sequence(self) -> Sequence:
     """Returns the in-frame CDS sequence (always multiple of 3)."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS sequence on non-coding transcript")
     return self.cds.extract_sequence()
Exemplo n.º 5
0
 def transcript_pos_to_cds(self, pos: int) -> int:
     """Converts a relative position along this transcript to a relative position along the CDS."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS positions on non-coding transcript")
     chr_pos = self.transcript_pos_to_sequence(pos)
     return self.sequence_pos_to_cds(chr_pos)
Exemplo n.º 6
0
 def cds_interval_to_chunk_relative(self, rel_start: int, rel_end: int, rel_strand: Strand) -> Location:
     """Converts a contiguous interval relative to the CDS to a spliced location on the chunk-relative sequence."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS positions on non-coding transcript")
     return self.cds.chunk_relative_location.relative_interval_to_parent_location(rel_start, rel_end, rel_strand)
Exemplo n.º 7
0
 def chunk_relative_pos_to_cds(self, pos: int) -> int:
     """Converts chunk-relative sequence position to relative position along the CDS."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS positions on non-coding transcript")
     return self.cds.chunk_relative_location.parent_to_relative_pos(pos)
Exemplo n.º 8
0
 def chunk_relative_cds_blocks(self) -> List[Location]:
     """Wrapper for blocks function that reports blocks in chunk-relative coordinates"""
     if self.is_coding:
         return self.cds.chunk_relative_blocks
     else:
         raise NoncodingTranscriptError("No relative CDS blocks for non-coding transcript")
Exemplo n.º 9
0
 def cds_pos_to_chunk_relative(self, pos: int) -> int:
     """Converts a relative position along the CDS to chunk-relative sequence coordinate."""
     if not self.is_coding:
         raise NoncodingTranscriptError("No CDS positions on non-coding transcript")
     return self.cds.chunk_relative_location.relative_to_parent_pos(pos)
Exemplo n.º 10
0
 def chunk_relative_cds_end(self) -> int:
     if self.is_coding:
         return self.cds_chunk_relative_location.end
     else:
         raise NoncodingTranscriptError("No CDS end for non-coding transcript")
Exemplo n.º 11
0
 def cds_blocks(self) -> Iterable[SingleInterval]:
     """Wrapper for blocks function that reports blocks in chromosome coordinates"""
     if self.is_coding:
         yield from self.cds.blocks
     else:
         raise NoncodingTranscriptError("No CDS blocks for non-coding transcript")
Exemplo n.º 12
0
 def chunk_relative_cds_start(self) -> int:
     if self.is_coding:
         return self.cds_chunk_relative_location.start
     else:
         raise NoncodingTranscriptError("No CDS start for non-coding transcript")
Exemplo n.º 13
0
 def cds_end(self) -> int:
     if self.is_coding:
         return self.cds.end
     else:
         raise NoncodingTranscriptError("No CDS end for non-coding transcript")
Exemplo n.º 14
0
 def cds_start(self) -> int:
     if self.is_coding:
         return self.cds.start
     else:
         raise NoncodingTranscriptError("No CDS start for non-coding transcript")
Exemplo n.º 15
0
 def has_in_frame_stop(self) -> bool:
     if not self.is_coding:
         raise NoncodingTranscriptError("Cannot have frameshifts on non-coding transcripts")
     return self.cds.has_in_frame_stop
Exemplo n.º 16
0
 def cds_chunk_relative_location(self) -> Location:
     """Returns the Location of the CDS in *chunk relative coordinates*"""
     if not self.is_coding:
         raise NoncodingTranscriptError("No location on a non-coding transcript")
     return self.cds.chunk_relative_location