Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Could you help with the code and explanation of how it works?

[画像: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 seg %3D "CGTATАСТААААСGGACGTTACGATATTGTСТСАСТТСАТСТТАССАСССТСТАТСТТАТTGCTGATAGAACACTAACCCСТСAGCTTTATTTСТА" def linear(seq, sub): positions [] return( positions ) print( linear( seq, 'ATG')) print( linear( seq, 'CAT')) print( linear( seq, 'TAGG') ) ]
expand button
Transcribed Image Text: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 seg %3D "CGTATАСТААААСGGACGTTACGATATTGTСТСАСТТСАТСТТАССАСССТСТАТСТТАТTGCTGATAGAACACTAACCCСТСAGCTTTATTTСТА" def linear(seq, sub): positions [] return( positions ) print( linear( seq, 'ATG')) print( linear( seq, 'CAT')) print( linear( seq, 'TAGG') )
Expert Solution
Check Mark
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
    • return position list
  • It calls the function linear with seq and sub string and display list

2) Save program in python file and run

Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY