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:
|
2021-11-18 20:36:34 +01:00
|
|
|
raise ValueError(f'{abbreviation} is not a nucleotide.')
|