def calc_gc_content(sequence):
 d = {}
 for nt in ['A', 'T', 'G', 'C']:
  d[nt] = (sequence.count(nt) + sequence.count(nt.lower()))
 gc = (d.get('G', 0) + d.get('C', 0))
 if (gc == 0):
  return 0
 return ((gc * 1.0) / ((d['A'] + d['T']) + gc))

def calc_gc_content ( sequence ) : d = { } for nt in [ 'A' , 'T' , 'G' , 'C' ] : d [ nt ] = ( sequence . count ( nt ) + sequence . count ( nt . lower ( ) ) ) gc = ( d . get ( 'G' , 0 ) + d . get ( 'C' , 0 ) ) if ( gc == 0 ) : return 0 return ( ( gc * 1.0 ) / ( ( d [ 'A' ] + d [ 'T' ] ) + gc ) )
returns the % g+c content in a passed sequence .