File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
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
19
18
20
19
MAX_QUALITY = 40
21
20
@@ -53,16 +52,19 @@ def simulate_reads(reference: Seq,
53
52
54
53
ref_len = len (reference )
55
54
file_num = 2 if is_reversed else 1
56
- rng = stable_random_distribution (maximum = (ref_len - min_length ))
57
55
58
56
for i in range (n_reads ):
59
57
# Choose a read length uniformly between min_length and max_length.
60
58
read_length = random .randint (min_length , max_length )
61
- # Choose a start index from a fair distribution.
62
- start = next (rng )
63
- end = start + read_length
64
59
65
- # Get the read nucleotides.
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
+
67
+ end = start + read_length
66
68
read_seq_seq = reference [start :end ]
67
69
read_seq_str = str (read_seq_seq )
68
70
read_seq = Seq (read_seq_str )
You can’t perform that action at this time.
0 commit comments