Commit 5eba0ed7 authored by rebelCoder's avatar rebelCoder
Browse files

Lesson 1: Validate DNA and Count Nucleotides

\ No newline at end of file
# DNA Toolkit file
import collections
Nucleotides = ["A", "C", "G", "T"]
# Check the sequence to make sure it is a DNA String
def validateSeq(dna_seq):
tmpseq = dna_seq.upper()
for nuc in tmpseq:
if nuc not in Nucleotides:
return False
return tmpseq
def countNucFrequency(seq):
tmpFreqDict = {"A": 0, "C": 0, "G": 0, "T": 0}
for nuc in seq:
tmpFreqDict[nuc] += 1
return tmpFreqDict
# return dict(collections.Counter(seq))
# DNA Toolset/Code testing file
from DNAToolkit import *
import random
# Creating a random DNA sequence for testing:
randDNAStr = ''.join([random.choice(Nucleotides)
for nuc in range(50)])
DNAStr = validateSeq(randDNAStr)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment