Using Python Write Function Called Gcpercent Takes Dna Sequence Argument Returns Percentag Q37027416

Using Python, write a function called ‘gc_percent’that takes a DNA sequence as an argument and returns the percentageof the sequence that are ‘G’ or ‘C’ nucleotides. For example, ifthe DNA sequence is:
tagtacta
Then the function will return 0.25. For this problem, your programmust read the DNA sequence from a file called “fasta.txt”. Thecontents of the file are:
>monkey
tatagctacgtagcaatagcgccgatacg


Solution


def gc_percent(dna): count = 0 for i in dna: if i in ‘gc’: count = count + 1

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.