77import os .path
88import json
99
10- import numpy as np
1110
11+ import numpy as np
12+ from .cutils import open_ambiguities , create_hap_list , deepcopy_list
1213from .cypher_plan_b import CypherQueryPlanB
1314from .cypher_query import CypherQuery
1415
@@ -118,6 +119,31 @@ def clean_up_gl(gl):
118119
119120
120121class Imputation (object ):
122+ __slots__ = (
123+ "logger" ,
124+ "verbose" ,
125+ "populations" ,
126+ "netGraph" ,
127+ "priorMatrix" ,
128+ "full_hapl" ,
129+ "index_dict" ,
130+ "full_loci" ,
131+ "factor" ,
132+ "_factor_missing_data" ,
133+ "cypher" ,
134+ "cypher_plan_b" ,
135+ "matrix_planb" ,
136+ "count_by_prob" ,
137+ "number_of_options_threshold" ,
138+ "plan" ,
139+ "option_1" ,
140+ "option_2" ,
141+ "haplotypes_number_in_phase" ,
142+ "save_space_mode" ,
143+ "nodes_for_plan_A" ,
144+ "unk_priors" ,
145+ )
146+
121147 def __init__ (self , net = None , config = None , count_by_prob = None , verbose = False ):
122148 """Constructor
123149 Intialize an instance of `Imputation` with a py2neo graph
@@ -914,8 +940,8 @@ def open_phases(self, haps, N_Loc, gl_string):
914940 fq = []
915941
916942 for k in range (2 ):
917- hap_list = []
918- hap_list . append ( haps [ j ][ k ])
943+ hap_list = [haps [ j ][ k ] ]
944+ hap_list_splits = [ tuple ( allele . split ( "/" )) for allele in hap_list [ 0 ]]
919945
920946 # compute the number of options:
921947 options = 1
@@ -1590,12 +1616,12 @@ def comp_cand(
15901616 # probabilties and accumulate cartesian productEpsilon=0.0001
15911617 chr = self .gl2haps (gl_string )
15921618 if chr == []:
1593- return
1619+ return None , None
15941620 # if we in 9-loci, check if the type input in valid format
15951621 if self .nodes_for_plan_A :
15961622 geno_type = self .input_type (chr ["Genotype" ][0 ])
15971623 if not geno_type in self .nodes_for_plan_A :
1598- return
1624+ return None , None
15991625
16001626 n_loci = chr ["N_Loc" ]
16011627
@@ -1604,7 +1630,7 @@ def comp_cand(
16041630
16051631 # return if the result is empty (why would that be?)
16061632 if pmags == []:
1607- return
1633+ return None , None
16081634
16091635 # res_muugs = {'Haps': 'NaN', 'Probs': 0}
16101636 res_muugs = {"MaxProb" : 0 , "Haps" : {}, "Pops" : {}}
@@ -1713,7 +1739,7 @@ def call_comp_phase_prob(self, epsilon, n, phases, chr, MUUG_output, planb):
17131739 epsilon /= 10
17141740 if epsilon < min_epsilon :
17151741 epsilon = 0.0
1716- phases_planb = copy . deepcopy (phases )
1742+ phases_planb = deepcopy_list (phases )
17171743 # Find the option according to plan b
17181744 if MUUG_output :
17191745 res = self .comp_phase_prob_plan_b (
0 commit comments