Skip to content

Commit

Permalink
Update simON_reads_module.py
Browse files Browse the repository at this point in the history
Adjusted the module to handle --enable_homopolymer_error and --enable_sequencing_error
  • Loading branch information
AstraBert authored Dec 19, 2023
1 parent 90582a5 commit e6bbe3b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/simON_reads_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def perform_homopolimer_mutation(seq, hp):
return seq


def seqs_to_file(genomes_dict, snp_string,nreads):
def seqs_to_file(genomes_dict, snp_string,nreads, enabled_hompolymer, enabled_sequencing_error):
"""Write a specified number of reads for each of the provided reference sequences (with a 5% of them being reverse complemented and a 0.5% being chimeric), inserting SNPs and random sequencing errors in them"""
genomes_list = [value for value in list(genomes_dict.values())]
headers = [key for key in list(genomes_dict.keys())]
Expand All @@ -172,17 +172,21 @@ def seqs_to_file(genomes_dict, snp_string,nreads):
for j in range(nreads):
if j in revcomp: ## Create reverse complemented reads
seq=generate_snp(snp_string, genomes_list[i], headers[i])
seq=perform_random_mutation(seq)
seq=perform_homopolimer_mutation(seq,hp)
if enabled_sequencing_error:
seq=perform_random_mutation(seq)
if enabled_hompolymer:
seq=perform_homopolimer_mutation(seq,hp)
seqs.append(reverse_complement(seq))
elif j in chimers: ## Create chimeric reads by merging two sequences
n=ceil(r.random()*(len(genomes_list)-1))
seq=genomes_list[n]+genomes_list[n-1]
seqs.append(seq)
else: ## Create a normal read
seq=generate_snp(snp_string, genomes_list[i], headers[i])
seq=perform_random_mutation(seq)
seq=perform_homopolimer_mutation(seq,hp)
if enabled_sequencing_error:
seq=perform_random_mutation(seq)
if enabled_hompolymer:
seq=perform_homopolimer_mutation(seq,hp)
seqs.append(seq)
means=[] ## Calculate the average base quality
for i in range(len(seqs)):
Expand All @@ -193,4 +197,3 @@ def seqs_to_file(genomes_dict, snp_string,nreads):
print(qt)
means.append(ascii_conv_and_mean(qt))
return means

0 comments on commit e6bbe3b

Please sign in to comment.