diff --git a/bootcamp/contrib/student_22.py b/bootcamp/contrib/student_22.py new file mode 100644 index 0000000..42dba56 --- /dev/null +++ b/bootcamp/contrib/student_22.py @@ -0,0 +1,20 @@ +def sequence_fasta(sequence, name='sequence'): + """Prints a sequence in fasta format + + Parameters + ---------- + sequence : str + The string to count within + name : str + The name of your sequence + + Returns + ------- + str + The fasta formatted sequence + + """ + + fasta = '>' + name + '\n' + sequence + '\n' + + return fasta diff --git a/bootcamp/core/student_22.py b/bootcamp/core/student_22.py index b904827..51bc76f 100644 --- a/bootcamp/core/student_22.py +++ b/bootcamp/core/student_22.py @@ -16,6 +16,9 @@ def count_substring(string, substring): """ count = 0 + string = string.upper() + substring = substring.upper() + string_length = len(string) substring_length = len(substring) n_subsequences = string_length - substring_length + 1 diff --git a/bootcamp/core/tests/test_student_22.py b/bootcamp/core/tests/test_student_22.py index 7e6e004..1d87780 100644 --- a/bootcamp/core/tests/test_student_22.py +++ b/bootcamp/core/tests/test_student_22.py @@ -1,8 +1,9 @@ from bootcamp.core.student_22 import count_substring # noqa +from bootcamp.contrib.student_22 import sequence_fasta def test_count_substring_single(): - test_string = "CGCTAGCGT" + test_string = "CgCtAGCGt" test_substring = "TAG" expected_count = 1 @@ -12,7 +13,7 @@ def test_count_substring_single(): def test_count_substring_repeated(): test_string = "AGCTAGCAGT" - test_substring = "AGC" + test_substring = "agc" expected_count = 2 observed_count = count_substring(test_string, test_substring) @@ -20,9 +21,18 @@ def test_count_substring_repeated(): def test_count_substring_none(): - test_string = "AGTCCCCTAGA" + test_string = "agtcccctaga" test_substring = "AAA" expected_count = 0 observed_count = count_substring(test_string, test_substring) assert expected_count == observed_count + + +def test_fasta_fun(): + test_string = "agtcccctaga" + test_name = "test1" + + expected_out = ">test1\nagtcccctaga\n" + observed_out = sequence_fasta(sequence=test_string, name=test_name) + assert expected_out == observed_out