public
Description: repository for the code featured in the blog
Homepage: http://python.genedrift.org
Clone URL: git://github.com/nuin/beginning-python-for-bioinformatics.git
100755 26 lines (19 sloc) 0.526 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
 
'''
very simple script to generate random DNA sequences
'''
 
#random module is needed
import random
import sys
 
#sequence length is a parameter
length = int(sys.argv[1])
 
#template DNA is a list with ACGT repeats
dnaseq = list('ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT')
 
#print the template
print dnaseq
 
result = ''
for i in range(length):
    #for the simulated sequence we use random.choice
    #that randonly selects items of a list
    result += random.choice(dnaseq)
 
print result