@@ -59,7 +59,7 @@ class InsertionModel(VariantModel):
59
59
def __init__ (self ,
60
60
insert_len_model : dict [int : float , ...],
61
61
rng : Generator = None ):
62
- # normalize the values
62
+ # Creating probabilities from the weights
63
63
tot = sum (insert_len_model .values ())
64
64
self .insertion_len_model = {key : val / tot for key , val in insert_len_model .items ()}
65
65
self .rng = rng
@@ -92,7 +92,7 @@ class DeletionModel(VariantModel):
92
92
def __init__ (self ,
93
93
deletion_len_model : dict [int : float , ...],
94
94
rng : Generator = None ):
95
- # normalize the values
95
+ # Creating probabilities from the weights
96
96
tot = sum (deletion_len_model .values ())
97
97
self .deletion_len_model = {key : val / tot for key , val in deletion_len_model .items ()}
98
98
self .rng = rng
@@ -284,6 +284,9 @@ def generate_snv(self, trinucleotide: Seq, reference_location: int) -> SingleNuc
284
284
transition_matrix = self .trinuc_trans_matrices [DINUC_IND [trinucleotide [0 ] + "_" + trinucleotide [2 ]]]
285
285
# then determine the trans probs based on the middle nucleotide
286
286
transition_probs = transition_matrix [NUC_IND [trinucleotide [1 ]]]
287
+ # Creating probabilities from the weights
288
+ transition_sum = sum (transition_probs )
289
+ transition_probs = [x / transition_sum for x in transition_probs ]
287
290
# Now pick a random alternate, weighted by the probabilities
288
291
alt = self .rng .choice (ALLOWED_NUCL , p = transition_probs )
289
292
temp_snv = SingleNucleotideVariant (reference_location , alt = alt )
0 commit comments