Files
python/nucleotide-count/example.py

19 lines
373 B
Python
Raw Normal View History

NUCLEOTIDES = 'ATCGU'
2013-07-31 08:38:22 -05:00
def count(strand, abbreviation):
_validate(abbreviation)
return strand.count(abbreviation)
2013-07-31 08:38:22 -05:00
def nucleotide_counts(strand):
return {
abbr: strand.count(abbr)
for abbr in 'ATGC'
}
def _validate(abbreviation):
if abbreviation not in NUCLEOTIDES:
raise ValueError('%s is not a nucleotide.' % abbreviation)