File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 15
15
from Bio .SeqRecord import SeqRecord , Seq
16
16
from typing import Sequence , Iterator
17
17
from pathlib import Path
18
+ from micall .utils .stable_random_distribution import stable_random_distribution
18
19
19
20
MAX_QUALITY = 40
20
21
@@ -52,19 +53,16 @@ def simulate_reads(reference: Seq,
52
53
53
54
ref_len = len (reference )
54
55
file_num = 2 if is_reversed else 1
56
+ rng = stable_random_distribution (maximum = (ref_len - min_length ))
55
57
56
58
for i in range (n_reads ):
57
59
# Choose a read length uniformly between min_length and max_length.
58
60
read_length = random .randint (min_length , max_length )
59
-
60
- # Choose a random start index ensuring the read fits within
61
- # the reference.
62
- if ref_len - read_length <= 0 :
63
- start = 0
64
- else :
65
- start = random .randrange (0 , ref_len - read_length + 1 )
66
-
61
+ # Choose a start index from a fair distribution.
62
+ start = next (rng )
67
63
end = start + read_length
64
+
65
+ # Get the read nucleotides.
68
66
read_seq_seq = reference [start :end ]
69
67
read_seq_str = str (read_seq_seq )
70
68
read_seq = Seq (read_seq_str )
You can’t perform that action at this time.
0 commit comments