Problem

DNA Sequencing:The term DNA sequencing refers to methods for determining the order of the...

DNA Sequencing:

The term DNA sequencing refers to methods for determining the order of the nucleotide bases, adenine, thymine, cytosine, and guanine in a molecule of DNA. The standard representation of the bases is to use their first letters, ATCG, so that DNA is represented as a string using only those four characters. However, DNA strings are millions of bases (characters) long.

Substring matching is the process of determining whether a shorter string (the substring) is contained within a longer string. Substring matching plays important roles in the reconstruction of an unknown DNA string from pieces and in searching for interesting substrings within a known DNA string.

Python provides a find(substring, start, end) string method that returns the lowest index (integer) where the substring is found in the index range start ≤ index < end. The start and end arguments are optional, but for this exercise we will make them required (you will learn later how to handle optional arguments). If the substring is not found, -1 is returned.

(a) Without using the find string method, write a function that behaves exactly like the find string method. As your function is not a string method, the string to search must be an argument—let’s make it the first one. The resulting format of your function will be:

find(some string, substring, start, end)

(b) Biology researchers frequently want to find all the locations where a substring is found, not simply the first one. Write a function named multi_find (some string, substring, start, end) that, instead of returning one integer index, returns a string that contains zero or more indices separated by commas. In this case, the string will contain digits representing the integer indices. If the substring is not found, an empty string is returned. You may use the find method that you wrote earlier.

(c) A nice feature of our multi_find function is that if the substring is not found, an empty string is returned. In particular, if the substring is not found, the returned empty string resolves to be False in a Boolean expression. The returned value will be True otherwise. That feature allows one to use multi_find in an if statement, such as: if multi_find(S,substring,0,20). The Python find string method does not share that characteristic (why?). Write a program that exercises both your find and your multi_find functions including their use in Boolean expressions. Create some strings using only the base letters, ATCG, and search for substrings within them.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT