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

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