Skip to content
Commit 5eba0ed7 authored by rebelCoder's avatar rebelCoder ☣️
Browse files

Lesson 1: Validate DNA and Count Nucleotides

parents
Loading
Loading
Loading
Loading
  • Dyuthi-shree @Dyuthi-shree ·
    
    # 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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment