seq_toolbox_03.py 396 Bytes
Newer Older
Mihai's avatar
Mihai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import sys

def calc_gc_percent(seq):
    at_count, gc_count = 0, 0
    for char in seq.upper():
        if char in ('A', 'T'):
            at_count += 1
        elif char in ('G', 'C'):
            gc_count += 1

    return gc_count * 100.0 / (gc_count + at_count)

input_seq = sys.argv[1]
print("The sequence '{}' has a %GC of {:.2f}".format(
          input_seq, calc_gc_percent(input_seq)))