-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathat_seq.py
More file actions
31 lines (28 loc) · 785 Bytes
/
at_seq.py
File metadata and controls
31 lines (28 loc) · 785 Bytes
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
#!/usr/bin/env python3
import random
#random.seed(1) # comment-out this line to change sequence each time
# Write a program that stores random DNA sequence in a string
# The sequence should be 30 nt long
# On average, the sequence should be 60% AT
# Calculate the actual AT fraction while generating the sequence
# Report the length, AT fraction, and sequence
seq=[]
at_count = 0
for i in range(0,30):
r = random.randint(0,100)
if r <= 60 and r >= 30:
seq.append ('A')
at_count += 1
elif r < 30:
seq.append ('T')
at_count += 1
elif r >= 80:
seq.append ('G')
else:
seq.append ('C')
seq=''.join(seq)
print(f'{"30"} {at_count/30} {seq}')
"""
python3 at_seq.py
30 0.6666666666666666 ATTACCGTAATCTACTATTAAGTCACAACC
"""