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

Rev Complement DNA + string insensitivity #73

Open
wants to merge 3 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
19 changes: 19 additions & 0 deletions bootcamp/contrib/student_02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def get_complement(string):
"""Reverse complements the DNA string input

Parameters
----------
string : str
The DNA string to reverse complement

Returns
-------
string_reverse
The reverse complement of the DNA string

"""
string = string.upper()
rev_dna = string[::-1]
dna_dict = {"A": "T", "G": "C", "C": "G", "T": "A"}
string_reverse = ''.join([dna_dict[x] for x in rev_dna if x in dna_dict])
return string_reverse
2 changes: 2 additions & 0 deletions bootcamp/core/student_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def count_substring(string, substring):

"""
count = 0
string = string.upper()
substring = substring.upper()

string_length = len(string)
substring_length = len(substring)
Expand Down
8 changes: 8 additions & 0 deletions bootcamp/core/tests/test_student_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ def test_count_substring_none():
expected_count = 0
observed_count = count_substring(test_string, test_substring)
assert expected_count == observed_count


def test_count_substring_case_insensitive():
test_string = "AGCTAGCAGT"
test_substring = "agC"
expected_count = 2
observed_count = count_substring(test_string, test_substring)
assert expected_count == observed_count
Loading