-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequence_generator.py
31 lines (27 loc) · 1.07 KB
/
sequence_generator.py
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
27
28
29
30
31
import random as r
import time
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
def generate_dna(length, number):
start = time.time()
Parser = ' >XY'
#whitespace
DNA = 'ATGC ATGC ATGC ATGC ATGCATGCATGCATGCATGCATGCATGCATGC ATGC ATGC ATGC ATGCATGCATGCATGCATGCATGCATGC ATGC ATGC ATGC ATGC ATGCATGCATGCATGCATGCATGCATGCATGC ATGC ATGC ATGC ATGCATGCATGCATGCATGCATGCATGC >'
newsequencefile = open('newsequencefile.txt', '+w')
for i in range(number+1):
sequence = ''
for j in range(length):
sequence = sequence + DNA[r.randint(0,200)]
#Create Random Elements for the File
Inital = Parser[r.randint(0, 3)]
Label = 'Test%05i' % i
wSpace = ' '*r.randint(1,10)
print(Inital, Label, sequence)
#write newsequencefile.txt
newsequencefile.write(Inital+Label+wSpace+sequence+'\n')
newsequencefile.close()
end = time.time()
print('Needed %f s' % (end-start))
generate_dna(50,125)