Monday, August 3, 2015
Bioinformatics in Python: GC content
Abstract: calculate GC content with a given DNA sequence
The script:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 3 14:29:46 2015
@author: yuan
"""
def GC_content(DNA, digits=1):
base_len=float(len(DNA))
G=DNA.count('G')
C=DNA.count('C')
#
GC_ratio=(G+C)*100/base_len
#print GC_ratio
GC_content=round(GC_ratio, digits)
return GC_content
if __name__=='__main__':
#GC content
DNA='TTTTTTGTTTTGAATACGTGTCAACCCCGGCGCTATGCTAGTCTGTAAAAA'
print 'GC content:', GC_content(DNA, 3)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment