Skip to content

Commit 1154fb9

Browse files
committed
Revert "Use stable distribution in fasta_to_fastq"
This reverts commit dfe612d.
1 parent 82e6a3d commit 1154fb9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

micall/utils/fasta_to_fastq.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from Bio.SeqRecord import SeqRecord, Seq
1616
from typing import Sequence, Iterator
1717
from pathlib import Path
18-
from micall.utils.stable_random_distribution import stable_random_distribution
1918

2019
MAX_QUALITY = 40
2120

@@ -53,16 +52,19 @@ def simulate_reads(reference: Seq,
5352

5453
ref_len = len(reference)
5554
file_num = 2 if is_reversed else 1
56-
rng = stable_random_distribution(maximum=(ref_len - min_length))
5755

5856
for i in range(n_reads):
5957
# Choose a read length uniformly between min_length and max_length.
6058
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
6459

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
6668
read_seq_seq = reference[start:end]
6769
read_seq_str = str(read_seq_seq)
6870
read_seq = Seq(read_seq_str)

0 commit comments

Comments
 (0)