4
4
import allel # type: ignore
5
5
6
6
from numpydoc_decorator import doc
7
- from ..util import check_types , _karyotype_tags_n_alt
7
+ from ..util import check_types
8
8
from . import base_params
9
9
from typing import Optional
10
10
11
11
from .snp_data import AnophelesSnpData
12
12
from .karyotype_params import inversion_param
13
13
14
14
15
- class AnophelesKaryotypeData (AnophelesSnpData ):
15
+ def _karyotype_tags_n_alt (gt , alts , inversion_alts ):
16
+ # could be Numba'd for speed but was already quick (not many inversion tag snps)
17
+ n_sites = gt .shape [0 ]
18
+ n_samples = gt .shape [1 ]
19
+
20
+ # create empty array
21
+ inv_n_alt = np .empty ((n_sites , n_samples ), dtype = np .int8 )
22
+
23
+ # for every site
24
+ for i in range (n_sites ):
25
+ # find the index of the correct tag snp allele
26
+ tagsnp_index = np .where (alts [i ] == inversion_alts [i ])[0 ]
27
+
28
+ for j in range (n_samples ):
29
+ # count alleles which == tag snp allele and store
30
+ n_tag_alleles = np .sum (gt [i , j ] == tagsnp_index [0 ])
31
+ inv_n_alt [i , j ] = n_tag_alleles
32
+
33
+ return inv_n_alt
34
+
35
+
36
+ class AnophelesKaryotypeAnalysis (AnophelesSnpData ):
16
37
def __init__ (
17
38
self ,
18
39
inversion_tag_path : Optional [str ] = None ,
@@ -23,13 +44,11 @@ def __init__(
23
44
# to the superclass constructor.
24
45
super ().__init__ (** kwargs )
25
46
26
- # If provided, this analysis version will override the
27
- # default value provided in the release configuration.
28
47
self ._inversion_tag_path = inversion_tag_path
29
48
30
49
@check_types
31
50
@doc (
32
- summary = "Load tag SNPs for a given inversion in Ag ." ,
51
+ summary = "Load tag SNPs for a given inversion." ,
33
52
)
34
53
def load_inversion_tags (self , inversion : inversion_param ) -> pd .DataFrame :
35
54
# needs to be modified depending on where we are hosting
0 commit comments