Skip to content
Snippets Groups Projects
Commit 94cca11a authored by marc's avatar marc
Browse files

Added docstring to cg calculation function

parent b6858cdd
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
import sys
# Python programming course
# Author: Marc van Driel
def calc_gc_perc(seq):
"""
Calculates the GC% of a sequence string
Arguments:
- seq - input sequence (string)
Returns:
- GC percentrage (float)
Example:
calc_gc_perc('CAGG') # returns 75%
"""
atc,gcc = 0, 0
for c in seq.upper():
if c in ('A', 'T'):
atc += 1
elif c in ('C', 'G'):
gcc += 1
return gcc * 100 / (gcc + atc)
return gcc * 100.0 / (gcc + atc)
inpseq = sys.argv[1]
print "the sequence is 'CAGG', and has a GC% of {:.2f}".format( calc_gc_perc(inpseq) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment