Explain to me here the pythonic significance of the change

Assignment Help Computer Engineering
Reference no: EM133703684

Fix the following issues in the program:

1)Infinite Loop: The while loop in the Find_it method could potentially result in an infinite loop.

2)Incorrect Regular Expression: The backward_pattern regular expression re.compile(r'AAAA') seems incorrect for finding patterns in DNA sequences.

3)Inefficient String Copying: In the while loop, sequence = sequence[:] is attempting to make a copy of the sequence string.

import re

class FindSomething(object):

forward_pattern = re.compile(r'ATG(...)*(TGA|TAA|TAG)')
backward_pattern = re.compile(r'AAAA') # hmmm, this doesn't seem like it could be right

def __init__(self):
pass

def Find_it(self, sequence, mode=True):

found_things = []

if mode:
pattern = FindSomething.forward_pattern
else:
pattern = FindSomething.backward_pattern

count = 0
match = pattern.search(sequence)
while match:

count += 1
if count > 25: # This is here just to avoid inadvertent infinite loops while you are testing
print ('Quitting... too many times through the while loop!') # and getting things figured out!
print ("Here's what I found before quiting:", found_things)
exit()
found_things.append(match.group())
next_position = match.start() + 1
sequence = sequence[:] # Maybe something simple is missing here??
match = pattern.search(sequence)

return found_things

def main():

a = FindSomething()

print (a.Find_it('ggg aug aaa ugu ucc cgg uaa aug aau gcc cgg gaa auu uag ccu gac aug a', mode=True))
print (a.Find_it('ggg aug aaa ugu ucc cgg uaa aug aau gcc cgg gaa auu uag ccu gac aug a', mode=False))

if __name__ == "__main__":
main()

3F) Assuming that you have fixed the above problems, try running the program. Does it behave the way that you expected? Probably, you are getting a message now that it is quitting because it has looped too many times. However, look (very carefully!) to see if it did (repeatedly) find matches what you had predicted based upon your biological analysis of the regular expressions. If not, describe exactly how the sequence you observe varies from your expectations.

3G) Armed with your knowledge of the behavior of the regular expression engine, and what you know of the regular expression mini language, can you suggest a simple fix to the forward_pattern regular expression that will make the result comport more exactly with your biological expectations? If so, make the change, and explain to me here the pythonic significance of the change you made. Further, tell me how the pythonic change correlates with the biological issue you identified in question 3F above.

3H) Our program is still just repeatedly finding a single pattern before bombing out of the while loop. However, the code in the while loop strongly hints at an approach that will allow the identification of multiple hits (why else would we use a loop unless we intended to find multiple things?). Indeed, it turns out that there is just a small problem with the implementation that is preventing the identification of multiple hits here. Look closely, then describe here the approach you think the code is suggesting, but not quite pulling off...

3I) Can you spot and fix the issue with the implementation of the idea above? If so, incorporate it into your code and describe it for me here. What results are you getting now when you run? Describe, especially with respect to number and nature.

3J) If you're still hanging in there - ponder the significance of the mode variable. Given what we've by now groked about forward_pattern, both with respect to biology and Python, and keeping in mind the nature of DNA, what behaviour do you think mode is seeking to control? Describe the relationship between mode and backward_pattern.

3K) Modify backward_pattern so that it does what you think it should (reason by analogy here). Once you are content with your efforts, run the program one last time and describe for me what you think it is now doing.

3L) If you've done everything right, we should now have some reasonable working code. However, thinking in terms of python, cast an eyeball once again at the algorithm we have employed, and describe for me any shortcomings that occur to you, especially with respect to efficiency. Hint: strings are an immutable type.

Reference no: EM133703684

Questions Cloud

Underserved population selected public health problem : Students will develop a community need assessment plan that addresses an underserved population's selected public health problem.
How much time does it take for all 15 peers to get the file : How much time does it take for all 15 peers to get the file? Show the details in a chart similar to that below in which the leftmost column identifies
Develop a short and cohesive program : Develop a short, cohesive program that interacts with the user and does the following using java: KEEP IT SIMPLE (only use code covered in weeks 1 - 5 in ICS
Design a circuit with four inputs : Design a circuit with four inputs i, j, x, y, and two outputs b, c. Each of these values is one bit. Use 4-variable Karnaugh maps with don't cares to minimize
Explain to me here the pythonic significance of the change : Explain to me here the pythonic significance of the change you made. Further, tell me how the pythonic change correlates with the biological issue
Describe several things you did that did not work well : ORGL 450- Describe several things you did that did not work well, explain why they not work and what you would now do differently.
Explain in detail how you can use metasploit to attack : Explain in detail how you can use Metasploit to attack a system and Explain in detail how you can perform at least three of the phases of penetration testing
Constipation and irritable bowel syndrome : A 31-year-old woman presents a family medicine clinic and expresses concern that she has constipation and irritable bowel syndrome.
Which algorithm would be ideal for low memory utilization : Which algorithm would be ideal for low memory utilization? What about a deep graph (few branches, resulting in long paths)? Explain why for each

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd