Skip to content

Instantly share code, notes, and snippets.

@SimonGreenhill
Forked from dwinter/simulate_reads.py
Last active December 18, 2015 22:39
Show Gist options
  • Save SimonGreenhill/5856225 to your computer and use it in GitHub Desktop.
Save SimonGreenhill/5856225 to your computer and use it in GitHub Desktop.
import random
def shotgun(iterable, size=12):
""" """
start = random.choice(range(0, len(iterable)-size))
return(start, iterable[start:start+size])
def paired_end(iterable, read_size=10, gap_size=15):
""" """
start = random.choice(range(0, len(iterable)-(read_size+gap_size)))
first_read = iterable[start:start+read_size]
second_read =iterable[start+read_size+gap_size: start+read_size+gap_size+read_size]
return start, first_read + gap_size*"-" + second_read
sentence = """
It has not escaped our notice that the specific pairing we have postulated immediately suggests a possible copying mechanism for the genetic material.
""".strip()
def main():
sequencing_run = [paired_end(sentence, 12) for i in range(25)]
print sentence
for index, chunk in sorted(sequencing_run):
sread = []
for space in range(index):
sread.append(" ")
sread.append(chunk)
print"".join(sread)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment