Question: I am asked yo write a code in python 2 that would do this task. heres the GCcontent function. Your task is to write a
Your task is to write a function called gcWin(DNA, steplen) that takes as input a DNA string and does the following: for each piece of DNA of length steplen, the GC content is calculated using your existing gcContent function) and that value is printed (using print rather than return). For example, imagine that our DNA string has length 13 and the stepLen is 5. Then the first region is the region DNA 0:5), the next one is DNA[5:10], and the last one is DNA[10:15). Notice that the last slice may not be of length steplen because of the length of the DNA sequence, but that's fine. Recall that if the string has length 13 then DNA[10:15] will simply provide a short slice. We can use a for loop to go over the DNA such that after each iteration of our loop we skip forward steplen bases. The following syntax of the range function will be useful here: >>>range(0,100.10) [0, 10, 20, 30, 40, 50, 60, 70, 80, 90] Note how the last number we gave the range function told it how big a step to use. You can loop over the DNA in this way, slicing out each region of size steplen in turn. For each slice, calculate the GC content by calling gcContent(DNA), and print the result to the screen. An example of gcWin at work: >>> Win(ATCCGAGGTC,2) 0.0 1.0 0.5 1.0 Your task is to write a function called gcWin(DNA, steplen) that takes as input a DNA string and does the following: for each piece of DNA of length steplen, the GC content is calculated using your existing gcContent function) and that value is printed (using print rather than return). For example, imagine that our DNA string has length 13 and the stepLen is 5. Then the first region is the region DNA 0:5), the next one is DNA[5:10], and the last one is DNA[10:15). Notice that the last slice may not be of length steplen because of the length of the DNA sequence, but that's fine. Recall that if the string has length 13 then DNA[10:15] will simply provide a short slice. We can use a for loop to go over the DNA such that after each iteration of our loop we skip forward steplen bases. The following syntax of the range function will be useful here: >>>range(0,100.10) [0, 10, 20, 30, 40, 50, 60, 70, 80, 90] Note how the last number we gave the range function told it how big a step to use. You can loop over the DNA in this way, slicing out each region of size steplen in turn. For each slice, calculate the GC content by calling gcContent(DNA), and print the result to the screen. An example of gcWin at work: >>> Win(ATCCGAGGTC,2) 0.0 1.0 0.5 1.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
