Write a function in Python that takes two strings of DNA sequence (say string1 and string2) as input and returns a list of the position(s) where string2 is present as a substring of string1. If there are no positions an empty list should be returned. When printing positions use 1 as the first position, rather than the 0 used by Python. The output using the above string/substring should be [3, 7]. Print the output of your function to search for the three words below. # Insert your code for Question 1 below seq = 'CGTATACTAAAACGGACGTTACGATATTGTCTCACTTCATCTTACCACCCTCTATCTTATTGCTGATAGAACACTAACCCCTCAGCTTTATTTCTA' def linear(seq, sub): positions = () return( positions ) print( linear( seq,'ATG') ) print( linear( seq,'CAT') ) print( linear( seq,'TAGG') )
Write a function in Python that takes two strings of DNA sequence (say string1 and string2) as input and returns a list of the position(s) where string2 is present as a substring of string1. If there are no positions an empty list should be returned. When printing positions use 1 as the first position, rather than the 0 used by Python. The output using the above string/substring should be [3, 7]. Print the output of your function to search for the three words below. # Insert your code for Question 1 below seq = 'CGTATACTAAAACGGACGTTACGATATTGTCTCACTTCATCTTACCACCCTCTATCTTATTGCTGATAGAACACTAACCCCTCAGCTTTATTTCTA' def linear(seq, sub): positions = () return( positions ) print( linear( seq,'ATG') ) print( linear( seq,'CAT') ) print( linear( seq,'TAGG') )
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Could you help with the code and explanation of how it works?
Expert Solution
Explanation
1) Below is Program that take two string of DNA sequence and return the list of positions of string2 present in string1
- It defines a function linear take two string, returns the list of position of second string in first string
- It creates a list to store positions
- Runs a loop to iterate through each character in the seq
- Check if a sub string present in seq string
- Append the index of substring
- Increment index by 1 so it prints position from 1 instead of 0
- Check if a sub string present in seq string
- return position list
- It calls the function linear with seq and sub string and display list
2) Save program in python file and run
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY