Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DNA sequences are strings made up of the letters: A, T, G, C; they stand for the names of the 4 nucleobases (often shortened

imageimageimageimage

DNA sequences are strings made up of the letters: A, T, G, C; they stand for the names of the 4 nucleobases (often shortened to just bases) that may appear in naturally occurring DNA molecules. The nucleobases bind to each other in complementary pairs: A and T form a complementary pair and C and G form the other. The complement of a sequence is a sequence of the complements of each nucleobase, taken one at a time. For example, the complement of ATTAGTC is TAATCAG. Some researchers are investigating whether a drug that has been tagged with a short DNA sequence, t, would be able to bind to a longer DNA sequence, s, from a cell. To do this, they want to know the maximum distance between two consecutive binding sites of the drug. In this case, a binding site for t is any consecutive substring of s where the complement of t appears. (Note that binding sites can overlap). They define the distance between two binding sites as the number of bases lying strictly between the last base of of one binding site and the first base of the next. Help these researchers with their experiment by writing a program to read in s and t and determine the maximum distance between consecutive binding sites. If there is only 1 binding site, it should output the number of bases that appear before it in the source. If there are no binding sites, then it should output -1. Input Format Line 1: s The DNA sequence from the cell Line 2: t The DNA sequence tagging the drug Constraints 1 s 105 1 t 100 Output Format Output the length of the longest gap between any two binding sites for t in s. If there is only one binding site, output its distance from the start of s. If there are no binding sites, output -1. Sample Input 0 TATAGGGATAGGCTAGTATTT TC Sample Output 0 4 Explanation 0 The tag string is TC, so its binding sites will be where its complement (AG) occurs. We see that in the source string, AG occurs at indexes 3-4, 9-10, and 14-15. The longest gap between two successive binding sites occurs between indexes 4 and 9, specifically indexes 5 to 8, giving us a length of 4 nucleobases Sample Input 1 GGGAAAGGGG ding/problem CC Sample Output 1 Sample Output 1 3 Explanation 1 The tag sequence is 'CC', so its complement is 'GG', and we can find that particular sequence at indexes 0, 1, 6, 7, and 8 (some of those overlap). The overlapping consecutive sequences technically have a negative distance between them, so they are not in contention for the longest gap. The sequence starting at index 1, ends at index 2, so the gap to the next binding site, starting at index 6, consists of the 3 A's at indexes 3 to 5. 1 2345 600 import math 4 import os 5 import random import re 7 import sys 9 10 11 12 13 14 #! /bin/python3 15 # # # # # # # # Complete the 'bindings' function below. # The function is expected to return an INTEGER. # The function accepts following parameters: 1. STRING S 2. STRING t 11 13 14 12 15 16 17 8987232 10 21 9 NANG 24 25 26 27 28 29 30 31 32 33 5 8 2 4 6 3 7 import sys #!/bin/python3 import math import os import random import re # # # Complete the 'bindings' function below. 20 if __name__ fptr # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. STRING S # 2. STRING t # def bindings (s, t): # write code here = '__main__': open (os.environ ['OUTPUT_PATH'], 'w') == s = input() t = input() answer bindings (s, t) fptr.write(str(answer) + ' ") fptr.close() Python 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

What would you do if the bullies and victim were girls?

Answered: 1 week ago

Question

In a system with light damping (c Answered: 1 week ago

Answered: 1 week ago