-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGC_content.py
More file actions
29 lines (21 loc) · 755 Bytes
/
GC_content.py
File metadata and controls
29 lines (21 loc) · 755 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
#!/usr/local/bin/env python3.4
# 2015-7-5
dna = 'gatgacgttattaccggactctgtcacgccgcggtgcgagctgaggcgtggcgtctgctggg'
print (dna.count('c'))
print (dna.count('g'))
print (len(dna))
GC_content = (dna.count('c') + dna.count('g')) / len(dna)
print (GC_content)
# 0.6451612903225806
GC_content_float = (dna.count('c') + dna.count('g'))/float(len(dna))
print (GC_content_float)
# 0.6451612903225806
GC_content_100 = (dna.count('c') + dna.count('g'))* 100.0/len(dna)
print (GC_content_100)
# 64.51612903225806
GC_content_100_2 = (dna.count('c') + dna.count('g'))/len(dna)* 100.0
print (GC_content_100_2)
# 64.51612903225806
GC_content_100_2_dicimal = (dna.count('c') + dna.count('g'))/float(len(dna))* 100.0
print ("%.2f" %GC_content_100_2_dicimal)
# 64.52