@@ -144,7 +144,7 @@ def __find_genotype_candidates_from_class(
144144 ) -> Tuple [np .ndarray , np .ndarray ]:
145145 """Takes an integer subclass.
146146 Returns the genotypes (ids and values) which are connected to it in the graph"""
147- return self ._graph .class_neighbors (clss , Len = len (self .patients [0 ]))
147+ return self ._graph .class_neighbors (clss , Len = len (list ( self .patients . values ()) [0 ]))
148148
149149 def __find_donor_from_geno (self , geno_id : int ) -> Sequence [int ]:
150150 """Gets the LOL ID of a genotype.
@@ -357,14 +357,9 @@ def find_geno_candidates_by_subclasses(self, subclasses):
357357 ALLELES_IN_CLASS_II = len (geno ) - ALLELES_IN_CLASS_I
358358 # Checks only the locuses that are not certain to match
359359 if subclass .class_num == 0 :
360- allele_range_to_check = np .array (
361- [c for c in range (ALLELES_IN_CLASS_I , ALLELES_IN_CLASS_I + ALLELES_IN_CLASS_I - 2 , 2 )] + [subclass .allele_num ],
362- dtype = np .uint8
363- )
360+ allele_range_to_check = np .array ([x for x in range (0 , len (geno )// 2 + (len (geno )// 2 & 1 ), 2 )], dtype = np .uint8 )
364361 else :
365- allele_range_to_check = np .array (
366- [c for c in range (0 , ALLELES_IN_CLASS_I , 2 )] + [subclass .allele_num ], dtype = np .uint8
367- )
362+ allele_range_to_check = np .array ([x for x in range (len (geno )// 2 + (len (geno )// 2 & 1 ), len (geno ), 2 )], dtype = np .uint8 )
368363
369364 # number of alleles that already match due to match in subclass
370365 matched_alleles : int = (
@@ -388,9 +383,9 @@ def find_geno_candidates_by_classes(self, classes):
388383 desc = "finding classes matching candidates" ,
389384 disable = not self .verbose ,
390385 ):
391- if self ._graph .in_nodes (clss ):
386+ if self ._graph .in_nodes (clss [ 0 ] ):
392387 patient_genos = self ._patients_graph .neighbors (
393- clss
388+ clss [ 0 ]
394389 ) # The patient's genotypes which might be match
395390 (
396391 genotypes_ids ,
@@ -400,12 +395,14 @@ def find_geno_candidates_by_classes(self, classes):
400395 # Checks only the locuses that are not certain to match (the locuses of the other class)
401396 # Class I appearances: 3 locuses = 6 alleles = 23/24 digits
402397 # Class II appearances: 2 locuses = 4 alleles = 15/16 digits
403- if len (str (clss )) > 20 :
404- allele_range_to_check = np .array ([6 , 8 ], dtype = np .uint8 )
405- matched_alleles : int = 6
398+ geno = list (self .patients .values ())[0 ]
399+ if clss [1 ] == 1 :
400+ allele_range_to_check = np .array ([x for x in range (len (geno )// 2 + (len (geno )// 2 & 1 ), len (geno ), 2 )], dtype = np .uint8 )
401+ matched_alleles : int = len (geno )// 2 + (len (geno )// 2 & 1 )
402+
406403 else :
407- allele_range_to_check = np .array ([0 , 2 , 4 ], dtype = np .uint8 )
408- matched_alleles : int = 4
404+ allele_range_to_check = np .array ([x for x in range ( 0 , len ( geno ) // 2 + ( len ( geno ) // 2 & 1 ), 2 ) ], dtype = np .uint8 )
405+ matched_alleles : int = len ( geno ) // 2 - ( len ( geno ) // 2 & 1 )
409406
410407 # Compares the candidate to the patient's genotypes, and adds the match geno candidates to the graph.
411408 self .__add_matched_genos_to_graph (
@@ -512,7 +509,7 @@ def score_matches(
512509 ].items (): # AMIT ADD
513510 for prob , matches in genotype_matches .values (): # AMIT CHANGE
514511 # match_info = (probability of patient's genotype, number of matches to patient's genotype)
515- if matches != len (self .patients [ 1 ]) - mismatch :
512+ if matches != len (list ( self .patients . values ())[ 0 ]) - mismatch :
516513 continue
517514
518515 # add the probabilities multiplication of the patient and all the donors that has this genotype
0 commit comments