%%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
Overwriting calc_gc.py
!nosetests -v calc_gc.py
calc_gc.test_correct_counting_gc ... ok calc_gc.test_correct_counting_at ... ok calc_gc.test_3 ... ok calc_gc.test_4 ... ok calc_gc.test_5 ... ok ---------------------------------------------------------------------- Ran 5 tests in 0.001s OK
!pip install git+https://github.com/ged-lab/screed.git
Downloading/unpacking git+https://github.com/ged-lab/screed.git Cloning https://github.com/ged-lab/screed.git to /var/folders/y6/s1r3q87933s6gjdrtmts1npc0000gq/T/pip-Ha7xSv-build Running setup.py egg_info for package from git+https://github.com/ged-lab/screed.git Cleaning up...