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

Method split

src/alphagenome/data/genome.py:832–868  ·  view source on GitHub ↗

Splits the variant into two at the anchor point. If the anchor point falls within the variant's reference sequence, the variant is split into two new variants: one upstream of the anchor and one downstream. If the anchor is outside the variant's reference sequence, the original vari

(self, anchor: int)

Source from the content-addressed store, hash-verified

830 )
831
832 def split(self, anchor: int) -> tuple[Self | None, Self | None]:
833 """Splits the variant into two at the anchor point.
834
835 If the anchor point falls within the variant's reference sequence, the
836 variant is split into two new variants: one upstream of the anchor and one
837 downstream. If the anchor is outside the variant's reference sequence,
838 the original variant is returned on the appropriate side, and None on the
839 other.
840
841 Example:
842 position= 3
843 ref: ...[ A C ]...
844 alt: .....T G T C
845 anchor=3 |
846 returns: (chr1:3:A>T, chr1:4:C>GTC)
847
848 Args:
849 anchor: The 0-based anchor point to split the variant.
850
851 Returns:
852 A tuple of the upstream and downstream variants. If the variant is only
853 on one side of the anchorpoint, then None is returned.
854 """
855 if anchor <= self.start:
856 return None, self.copy()
857 elif anchor >= self.end:
858 return self.copy(), None
859 else:
860 mid = anchor - self.start
861 upstream, downstream = self.copy(), self.copy()
862 upstream.reference_bases = self.reference_bases[:mid]
863 upstream.alternate_bases = self.alternate_bases[:mid]
864
865 downstream.position = anchor + 1
866 downstream.reference_bases = self.reference_bases[mid:]
867 downstream.alternate_bases = self.alternate_bases[mid:]
868 return upstream, downstream
869
870
871@dataclasses.dataclass

Callers 12

jaxtypedFunction · 0.80
pack_tensorFunction · 0.80
from_strMethod · 0.80
get_gene_intervalsFunction · 0.80
from_curieFunction · 0.80
_parse_intervalsMethod · 0.80
_parse_intervalsMethod · 0.80
tidy_anndataFunction · 0.80
generate_gtfFunction · 0.80
linkcode_resolveFunction · 0.80

Calls 1

copyMethod · 0.95

Tested by 4

_parse_intervalsMethod · 0.64
_parse_intervalsMethod · 0.64