diff --git a/src/read_sequencing.py b/src/read_sequencing.py index 085316d2b9e62aa32ab7afbc82e9cb923422fcbf..6c47005b5f51e6727a6e5bd4ce00d3804c596bbd 100644 --- a/src/read_sequencing.py +++ b/src/read_sequencing.py @@ -75,26 +75,20 @@ def read_sequencing( for i in range(0, num_frag_reads): - # Obtain random first position for the read on the fragment - rand_start = randrange(0, len(frag)) - - # Calculate the difference of start position and length of read - diff_start_end = len(frag)-rand_start - - # If length of read is greater than difference of start to end, then add random nucleotides - if diff_start_end < read_len: + # If the read length is less than the required length given by the parameter, then add random nucleotides + if len(frag) < read_len: # Calculate number of random nucleotides to add to the end of the read - diff = read_len - diff_start_end + diff = read_len - read_len # Select random nucleotides from list of possible rand_samp = choices(nucleotides, k=diff) # Add the random list to the read and save - tmp_read = frag[rand_start:len(frag)] + ''.join(rand_samp) + tmp_read = frag[0:(len(frag)-1)] + ''.join(rand_samp) else: # Save subset of fragment as read - tmp_read = frag[rand_start:(rand_start + read_len)] + tmp_read = frag[0:(read_len-1)] # append read to list fasta_list.append(tmp_read)