MCPcopy
hub / github.com/google-deepmind/alphagenome / __post_init__

Method __post_init__

src/alphagenome/data/transcript.py:400–440  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

398 return splice_sites
399
400 def __post_init__(self):
401 if not self.exons:
402 raise ValueError('Transcript must contain at least one exon.')
403
404 for exon in self.exons:
405 if exon.strand != self.strand or exon.chromosome != self.chromosome:
406 raise ValueError(
407 'Transcript intervals are inconsistent. All intervals of a '
408 'transcript should have same strand and chromosome.'
409 )
410
411 if self.cds:
412 # first exons can be part of UTR. Searching for the first coding exon.
413 index = 0
414 for exon in self.exons:
415 # if overlaps, will check whether exon contains it in the latter loop.
416 if exon.overlaps(self.cds[0]):
417 break
418 index += 1
419 if index == len(self.exons) or len(self.cds) + index > len(self.exons):
420 raise ValueError(
421 'The number of coding exons must be the same as CDS '
422 'and CDS cannot be outside of the exon intervals.'
423 )
424
425 # checks each subsequent exon is coding
426 for seq, exon in zip(self.cds, self.exons[index : index + len(self.cds)]):
427 if not exon.contains(seq):
428 raise ValueError(
429 'The number of coding exons must be the same as CDS '
430 'and CDS cannot be outside of the exon intervals.'
431 )
432 if seq.strand != self.strand:
433 raise ValueError(
434 'Transcript intervals are inconsistent. All intervals of a '
435 'transcript should have same strand and chromosome.'
436 )
437
438 for sc in self.selenocysteines: # pylint:disable=not-an-iterable
439 sc_pos = sc.end - 1 if sc.negative_strand else sc.start
440 sc.info['cds_offset'] = self.offset_in_cds(sc_pos)
441
442 def __len__(self):
443 return self.transcript_interval.width

Callers

nothing calls this directly

Calls 3

offset_in_cdsMethod · 0.95
overlapsMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected