Lesson 1: Validate DNA and Count Nucleotides
parents
Loading
Loading
Loading
-
# RNA Toolkit file import collections Nucleotides = ["A", "C", "G", "U"] # Check the sequence to make sure it is a RNA String def validateSeq(rna_seq): tmpseq = rna_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, "U": 0} for nuc in seq: tmpFreqDict[nuc] += 1 return tmpFreqDict # return dict(collections.Counter(seq)) # RNA Toolset/Code testing file from RNAToolkit import * import random # Creating a random RNA sequence for testing: randRNAStr = ''.join([random.choice(Nucleotides) for nuc in range(50)]) DNAStr = validateSeq(randRNAStr) print(countNucFrequency(RNAStr))
Please register or sign in to comment