%%file calc_gc.py def calc_gc(dna): dna = dna.upper() gc = dna.count('G') + dna.count('C') at = dna.count('A') + dna.count('T') total = gc + at if total == 0: return 0.0 frac = gc / float(total) return frac def test_correct_counting_gc(): x = calc_gc('ATGC') assert x == 0.5, x def test_correct_counting_at(): x = calc_gc('AAAA') assert x == 0.0, x def test_3(): x = calc_gc('atgc') assert x == 0.5, x def test_4(): x = calc_gc('AtgCNN') assert x == 0.5, x def test_5(): x = calc_gc('NNNNNN') assert x == 0.0, x !nosetests -v calc_gc.py !pip install git+https://github.com/ged-lab/screed.git