Skip to content
This repository has been archived by the owner on Mar 21, 2020. It is now read-only.

Commit

Permalink
readGen: better error generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bebarino committed May 29, 2009
1 parent 4b02cde commit 9523963
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions readGen.py
Expand Up @@ -14,10 +14,13 @@ def gen_read(seq, l, e):
"""Generates a random read of length 'l' from the sequence 'seq'"""
start = random.choice(xrange(len(seq)-l))
read = list(seq[start:start+l])
if random.random() < e:
# Make an error
pos = random.randrange(l)
read[pos] = random.choice(read)
for i in xrange(len(read)):
if random.random() < e:
# Make an error
choice = read[i]
while choice == read[i]:
choice = random.choice(['A', 'T', 'C', 'G'])
read[i] = choice
return ("".join(read), start)

def write_reads(rs, f):
Expand Down

0 comments on commit 9523963

Please sign in to comment.