Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Student 22 branch #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bootcamp/contrib/student_22.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions bootcamp/core/student_22.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions bootcamp/core/tests/test_student_22.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,17 +13,26 @@ 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)
assert expected_count == observed_count


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
Loading