Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def gcContent(DNA): '''This function calculates the proportion of bases that are G's and C's of a DNA string to be used to calculate the GC

def gcContent(DNA):

'''This function calculates the proportion of bases that are G's and C's of a DNA string to be used to calculate the GC content in pathogenecity islands'''

gcCounter=0

lengthDNA=len(DNA)

for nuc in DNA:

if nuc=='G' or nuc=='C':

gcCounter=gcCounter+1 #increment the gcCounter

return (float(gcCounter)/lengthDNA)

def gcWin(DNA,steplen):

'''This function takes a DNA string and steplen as input and for each piece of DNA of length stepLen, it calculates the gcContent value from an existing gcContent function and prints the results'''

lengthOfDNA=len(DNA)

for i in range(0,lengthOfDNA,steplen): #range is from initial index to length of DNA and step size for range in stepLen

low=i #set lower index of DNA string as i

if i+steplen>=lengthOfDNA: #check if i+steplen is greater than length of DNA

upper=lengthOfDNA #then set upper index as lengthOfDNA

else: #otherwise

upper=i+steplen #upper index is i+steplen

subDNA=DNA[low:upper] #set the substring of DNA from lower index to upper inde

print(gcContent(subDNA)) #call the gcContent function on given substring DNA and print the result

#Ch2gcContentWindowstesting

DNA = input("Enter the original DNA string : ")

steplen = int(input("Enter the step length : ")) #call the gcWin function with a given DNA string and step size

print (gcWin('ATCCGAGGTC',2)

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions