18
18
from ..common import TRINUC_IND , ALLOWED_NUCL , NUC_IND , DINUC_IND
19
19
from .default_mutation_model import *
20
20
from .default_sequencing_error_model import *
21
- from .utils import bin_scores , take_closest
22
21
23
22
__all__ = [
24
23
"MutationModel" ,
@@ -376,11 +375,8 @@ def __init__(self,
376
375
self .insertion_model = insertion_model
377
376
self .uniform_quality_score = None
378
377
if self .is_uniform :
379
- # bin scores returns a list, so we need the first (only) element of the list
380
- converted_avg_err = bin_scores (self .quality_scores ,
381
- [int (- 10. * np .log10 (self .average_error ))])[0 ]
382
- # Set score to the lowest of the max of the quality scores and the bin closest to the input avg error.
383
- self .uniform_quality_score = min ([max (self .quality_scores ), converted_avg_err ])
378
+ # Set score to the lowest of the max of the quality scores and the input avg error.
379
+ self .uniform_quality_score = min ([max (self .quality_scores ), int (- 10. * np .log10 (self .average_error ) + 0.5 )])
384
380
self .rng = rng
385
381
386
382
def get_sequencing_errors (self ,
@@ -498,7 +494,13 @@ def get_quality_scores(self,
498
494
for i in quality_index_map :
499
495
score = self .rng .normal (self .quality_score_probabilities [i ][0 ],
500
496
scale = self .quality_score_probabilities [i ][1 ])
501
- score = take_closest (self .quality_scores , score )
497
+ # make sure score is in range and an int
498
+ score = round (score )
499
+ if score > 42 :
500
+ score = 42
501
+ if score < 1 :
502
+ score = 1
503
+
502
504
temp_qual_array .append (score )
503
505
504
506
if self .rescale_qualities :
@@ -509,9 +511,9 @@ def get_quality_scores(self,
509
511
self .quality_score_error_rate [n ]) + 0.5 )])
510
512
for n in temp_qual_array ]
511
513
# Now rebin the quality scores.
512
- temp_qual_array = np .array (bin_scores ( self . quality_scores , rescaled_quals ) )
514
+ temp_qual_array = np .array (rescaled_quals )
513
515
else :
514
- temp_qual_array = np .array (bin_scores ( self . quality_scores , temp_qual_array ) )
516
+ temp_qual_array = np .array (temp_qual_array )
515
517
516
518
return temp_qual_array [:input_read_length ]
517
519
0 commit comments