Mark nucleotied-count as foregone. (#3617)
This commit is contained in:
11
config.json
11
config.json
@@ -2143,15 +2143,6 @@
|
||||
"difficulty": 2,
|
||||
"status": "deprecated"
|
||||
},
|
||||
{
|
||||
"slug": "nucleotide-count",
|
||||
"name": "Nucleotide Count",
|
||||
"uuid": "105f25ec-7ce2-4797-893e-05e3792ebd91",
|
||||
"practices": [],
|
||||
"prerequisites": [],
|
||||
"difficulty": 2,
|
||||
"status": "deprecated"
|
||||
},
|
||||
{
|
||||
"slug": "binary",
|
||||
"name": "Binary",
|
||||
@@ -2234,7 +2225,7 @@
|
||||
"status": "deprecated"
|
||||
}
|
||||
],
|
||||
"foregone": ["lens-person", "parallel-letter-frequency"]
|
||||
"foregone": ["lens-person", "nucleotide-count", "parallel-letter-frequency"]
|
||||
},
|
||||
"concepts": [
|
||||
{
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# Instructions
|
||||
|
||||
Each of us inherits from our biological parents a set of chemical instructions known as DNA that influence how our bodies are constructed.
|
||||
All known life depends on DNA!
|
||||
|
||||
> Note: You do not need to understand anything about nucleotides or DNA to complete this exercise.
|
||||
|
||||
DNA is a long chain of other chemicals and the most important are the four nucleotides, adenine, cytosine, guanine and thymine.
|
||||
A single DNA chain can contain billions of these four nucleotides and the order in which they occur is important!
|
||||
We call the order of these nucleotides in a bit of DNA a "DNA sequence".
|
||||
|
||||
We represent a DNA sequence as an ordered collection of these four nucleotides and a common way to do that is with a string of characters such as "ATTACG" for a DNA sequence of 6 nucleotides.
|
||||
'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' for thymine.
|
||||
|
||||
Given a string representing a DNA sequence, count how many of each nucleotide is present.
|
||||
If the string contains characters that aren't A, C, G, or T then it is invalid and you should signal an error.
|
||||
|
||||
For example:
|
||||
|
||||
```text
|
||||
"GATTACA" -> 'A': 3, 'C': 1, 'G': 1, 'T': 2
|
||||
"INVALID" -> error
|
||||
```
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"blurb": "Given a DNA string, compute how many times each nucleotide occurs in the string.",
|
||||
"authors": [],
|
||||
"contributors": [
|
||||
"behrtam",
|
||||
"cmccandless",
|
||||
"Dog",
|
||||
"ikhadykin",
|
||||
"kytrinyx",
|
||||
"lowks",
|
||||
"mostlybadfly",
|
||||
"N-Parsons",
|
||||
"Oniwa",
|
||||
"orozcoadrian",
|
||||
"pheanex",
|
||||
"sjakobi",
|
||||
"tqa236"
|
||||
],
|
||||
"files": {
|
||||
"solution": [
|
||||
"nucleotide_count.py"
|
||||
],
|
||||
"test": [
|
||||
"nucleotide_count_test.py"
|
||||
],
|
||||
"example": [
|
||||
".meta/example.py"
|
||||
]
|
||||
},
|
||||
"source": "The Calculating DNA Nucleotides_problem at Rosalind",
|
||||
"source_url": "https://rosalind.info/problems/dna/"
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
NUCLEOTIDES = 'ATCG'
|
||||
|
||||
|
||||
def count(strand, abbreviation):
|
||||
_validate(abbreviation)
|
||||
return strand.count(abbreviation)
|
||||
|
||||
|
||||
def nucleotide_counts(strand):
|
||||
return {
|
||||
abbr: strand.count(abbr)
|
||||
for abbr in NUCLEOTIDES
|
||||
}
|
||||
|
||||
|
||||
def _validate(abbreviation):
|
||||
if abbreviation not in NUCLEOTIDES:
|
||||
raise ValueError(f'{abbreviation} is not a nucleotide.')
|
||||
@@ -1,18 +0,0 @@
|
||||
# This is an auto-generated file. Regular comments will be removed when this
|
||||
# file is regenerated. Regenerating will not touch any manually added keys,
|
||||
# so comments can be added in a "comment" key.
|
||||
|
||||
[3e5c30a8-87e2-4845-a815-a49671ade970]
|
||||
description = "empty strand"
|
||||
|
||||
[a0ea42a6-06d9-4ac6-828c-7ccaccf98fec]
|
||||
description = "can count one nucleotide in single-character input"
|
||||
|
||||
[eca0d565-ed8c-43e7-9033-6cefbf5115b5]
|
||||
description = "strand with repeated nucleotide"
|
||||
|
||||
[40a45eac-c83f-4740-901a-20b22d15a39f]
|
||||
description = "strand with multiple nucleotides"
|
||||
|
||||
[b4c47851-ee9e-4b0a-be70-a86e343bd851]
|
||||
description = "strand with invalid nucleotides"
|
||||
@@ -1,6 +0,0 @@
|
||||
def count(strand, nucleotide):
|
||||
pass
|
||||
|
||||
|
||||
def nucleotide_counts(strand):
|
||||
pass
|
||||
@@ -1,46 +0,0 @@
|
||||
"""Tests for the nucleotide-count exercise
|
||||
|
||||
Implementation note:
|
||||
The count function must raise a ValueError with a meaningful error message
|
||||
in case of a bad argument.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from nucleotide_count import count, nucleotide_counts
|
||||
|
||||
|
||||
class NucleotideCountTest(unittest.TestCase):
|
||||
def test_empty_dna_string_has_no_adenosine(self):
|
||||
self.assertEqual(count('', 'A'), 0)
|
||||
|
||||
def test_empty_dna_string_has_no_nucleotides(self):
|
||||
expected = {'A': 0, 'T': 0, 'C': 0, 'G': 0}
|
||||
self.assertEqual(nucleotide_counts(""), expected)
|
||||
|
||||
def test_repetitive_cytidine_gets_counted(self):
|
||||
self.assertEqual(count('CCCCC', 'C'), 5)
|
||||
|
||||
def test_repetitive_sequence_has_only_guanosine(self):
|
||||
expected = {'A': 0, 'T': 0, 'C': 0, 'G': 8}
|
||||
self.assertEqual(nucleotide_counts('GGGGGGGG'), expected)
|
||||
|
||||
def test_counts_only_thymidine(self):
|
||||
self.assertEqual(count('GGGGGTAACCCGG', 'T'), 1)
|
||||
|
||||
def test_validates_nucleotides(self):
|
||||
with self.assertRaisesWithMessage(ValueError):
|
||||
count("GACT", 'X')
|
||||
|
||||
def test_counts_all_nucleotides(self):
|
||||
dna = ('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCT'
|
||||
'CTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC')
|
||||
expected = {'A': 20, 'T': 21, 'G': 17, 'C': 12}
|
||||
self.assertEqual(nucleotide_counts(dna), expected)
|
||||
|
||||
# Utility functions
|
||||
def assertRaisesWithMessage(self, exception):
|
||||
return self.assertRaisesRegex(exception, r".+")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user