Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Business Management Expert

For Intro to Python Class

DNA molecules consist of a sequence of the four nucleotide bases: adenine, thymine, cytosine, and guanine. The nucleotide bases are often abbreviated by their first letter, ATCG) so that DNA is represented as a string of these four letters. A DNA string can be millions of bases long.

One important problem on DNA strings is substring matching, which is the task of checking whether a shorter substring is contained within a longer string. Obviously, finding a substring in a long string has many interesting applications, but here we will focus on DNA sequences.

Python strings already provide an s.find(substring) method that returns the index in s at which substring first appears. If the substring does not appear, the method returns -1. For example: "ATCGCGTACT".find("CGCG") returns 2, but "ATCGCGTACT".find("CGAT") returns -1. 

(a) Without using the existing find method of Python strings, write a function find(s, substring).

that does the same thing as the find method. If the substring appears in s, the method should return its index, otherwise it should return -1. Write the function in the file problem2.py. 

(b) Without using the existing find method, write a function find_multi(s, substring).

that returns a list of the indices of all occurrences of the substring. If the substring is not found, the function can return an empty list. Make sure your function can handle overlapping substrings. For example: 

find_multi("ATGCGCGAT", "GCG") should return [2,4].

Add the function in the file problem2.py. 

(c) In the worst case, how many character comparisons are required by your algorithm in part (a)? Does the algorithm in part (b) need to make more comparisons? The answer does not need to be exact. Add your answer as a comment at the top of problem2.py.

Business Management, Management Studies

  • Category:- Business Management
  • Reference No.:- M92484488
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Business Management

A leasing firm operates on the assumption that the annual

A leasing firm operates on the assumption that the annual number of miles driven in its leased cars is normally distributed with mean 13,500 and standard deviation 4,000 miles. To see whether this assumption is valid, a ...

What are the pros and cons of developing a global set of

What are the pros and cons of developing a global set of rules governing MNC (MNE) investment?

What are the general or ordinary causes of issues in human

What are the general or ordinary causes of issues in human relations with regards to any business or organization?

Dinesh manages a division of a sporting goods manufacturer

Dinesh manages a division of a sporting goods manufacturer. He attends a conference and receives advice from four experienced managers. Based on what you have read, which of the following pieces of advice should Dinesh t ...

Help formulate a program python script named mycalcpy which

Help formulate a program (Python script) named mycalc.py, which implements a simple calculator using python. Submit a script file(.py or .txt) and an output file (.doc or .pdf). Don't forget to use comments and readable ...

1 identify one trait characteristic or personality trait

1. Identify one trait, characteristic, or personality trait which does NOT belong to the Trait Theory that you feel you possess which would help you become an effective leader. 2. Based on your analysis, do you feel you ...

Why might an organization decide to outsource all or some

Why might an organization decide to outsource all or some of its logistics activities to a third party?

What happens to the least cost ration if the price of both

What happens to the least cost ration if the price of both of it's feed ingredients doubles?

How does a database that is associated with a mobile device

How does a database that is associated with a mobile device and with mobile apps differ from a database that is stored and created using a more traditional application and server?

We were discussing the concept of systems thinking and how

We were discussing the concept of Systems thinking and how it is essentially learning about oneself in interaction with the surrounding world. How do you applying this concept to the work environment.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As