2015-11-30 21:29:11 -05:00
|
|
|
NUCLEOTIDES = 'ATCG'
|
2013-07-31 08:38:22 -05:00
|
|
|
|
|
|
|
|
|
2014-06-28 04:40:36 +02:00
|
|
|
def count(strand, abbreviation):
|
|
|
|
|
_validate(abbreviation)
|
|
|
|
|
return strand.count(abbreviation)
|
2013-07-31 08:38:22 -05:00
|
|
|
|
|
|
|
|
|
2014-06-28 04:40:36 +02:00
|
|
|
def nucleotide_counts(strand):
|
|
|
|
|
return {
|
|
|
|
|
abbr: strand.count(abbr)
|
2015-11-30 21:29:11 -05:00
|
|
|
for abbr in NUCLEOTIDES
|
2014-06-28 04:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _validate(abbreviation):
|
|
|
|
|
if abbreviation not in NUCLEOTIDES:
|
2017-11-23 09:47:33 +00:00
|
|
|
raise ValueError('{} is not a nucleotide.'.format(abbreviation))
|