def do_quality_any(fastq, rnum): sequence = fastq.seq quality = fastq.qual #five possible errors 3 base changes a deletion or insertion seq = '' qual = '' for i in range(0, len(sequence)): rate = phred33_to_rate(quality[i]) if rnum.random() > rate: seq += sequence[i] qual += quality[i] continue type = rnum.choice(['ins', 'del', 'mis', 'mis', 'mis']) if type == 'mis': seq += rnum.different_random_nt(sequence[i]) qual += quality[i] elif type == 'ins': if rnum.random() < 0.5: seq += sequence[i] + rnum.random_nt() qual += quality[i] + quality[i] else: seq += rnum.random_nt() + sequence[i] qual += quality[i] + quality[i] #for del type we do nothing ... cause its not getting added return Fastq([fastq.name, seq, '+', qual])
def do_quality_any(fastq,rnum): sequence = fastq.seq quality = fastq.qual #five possible errors 3 base changes a deletion or insertion seq = '' qual = '' for i in range(0,len(sequence)): rate = phred33_to_rate(quality[i]) if rnum.random() > rate: seq += sequence[i] qual += quality[i] continue type = rnum.choice(['ins','del','mis','mis','mis']) if type == 'mis': seq += rnum.different_random_nt(sequence[i]) qual += quality[i] elif type == 'ins': if rnum.random() < 0.5: seq += sequence[i]+rnum.random_nt() qual += quality[i]+quality[i] else: seq += rnum.random_nt()+sequence[i] qual += quality[i]+quality[i] #for del type we do nothing ... cause its not getting added return Fastq([fastq.name,seq,'+',qual])
def do_quality_mismatch(fastq, rnum): sequence = fastq.seq quality = fastq.qual #five possible errors 3 base changes a deletion or insertion seq = '' qual = '' for i in range(0, len(sequence)): rate = phred33_to_rate(quality[i]) if rnum.random() > rate: seq += sequence[i] qual += quality[i] continue seq += rnum.different_random_nt(sequence[i]) qual += quality[i] #for del type we do nothing ... cause its not getting added return Fastq([fastq.name, seq, '+', qual])
def do_quality_mismatch(fastq,rnum): sequence = fastq.seq quality = fastq.qual #five possible errors 3 base changes a deletion or insertion seq = '' qual = '' for i in range(0,len(sequence)): rate = phred33_to_rate(quality[i]) if rnum.random() > rate: seq += sequence[i] qual += quality[i] continue seq += rnum.different_random_nt(sequence[i]) qual += quality[i] #for del type we do nothing ... cause its not getting added return Fastq([fastq.name,seq,'+',qual])