Example #1
0
def test_randomcodons():
    '''
    This test is pretty basic right now - not sure how much checking
    can be done for a random DNA base generator.

    '''

    reference_seq = RNA('AUGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAG')
    reference_peptide = reaction.translate(reference_seq)
    output = design.random_codons(reference_peptide)
    output_peptide = reaction.translate(reference_seq)

    assert_equal(len(output), len(reference_seq) - 3)
    assert_equal(reference_peptide, output_peptide)
    assert_not_equal(reference_seq, output)

    # Setting too high a threshold should raise ValueError
    assert_raises(ValueError, design.random_codons, reference_peptide,
                  frequency_cutoff=1.5)

    # Weighted should work
    w_output = design.random_codons(reference_peptide, weighted=True)
    w_output_peptide = reaction.translate(reference_seq)

    assert_equal(len(w_output), len(reference_seq) - 3)
    assert_equal(reference_peptide, w_output_peptide)
    assert_not_equal(reference_seq, w_output)
Example #2
0
def test_translation():
    test_rna = RNA('AUGAUGGGCAGUGUCGAAUUAAAUCUGCGUGAGACAGAAUU' +
                   'GUGUUUGGGACUACCAGGCGGUGAUACAGUUGCACCAGUAA' +
                   'CAGGAAACAAAAGAGGAUUCUCUGAAACAGUAGAUUUGAAA' +
                   'CUUAAUUUGAACAAUGAGCCAGCCAACAAGGAAGGUUCCAC' +
                   'CACUCAUGACGUCGUCACAUUUGAUAGUAAAGAAAAGAGUG' +
                   'CGUGUCCAAAAGAUCCAGCUAAGCCACCUGCCAAGGCUCAA' +
                   'GUCGUCGGAUGGCCACCUGUGAGAUCUUAUAGAAAGAACGU' +
                   'AAUGGUUUCUUGUCAGAAGUCCAGUGGUGGUCCUGAAGCAG' +
                   'CGGCUugaaaa')
    reference_peptide = Peptide('MMGSVELNLRETELCLGLPGGDTVAPVTGNK' +
                                'RGFSETVDLKLNLNNEPANKEGSTTHDVVTF' +
                                'DSKEKSACPKDPAKPPAKAQVVGWPPVRSYR' +
                                'KNVMVSCQKSSGGPEAAA')
    # Basic transcription should work
    translation_output = reaction.translate(test_rna)
    assert_equal(translation_output, reference_peptide)

    # Coding peptide should exclude anything after a stop codon
    coding_rna = reaction.coding_sequence(test_rna)
    coding_peptide = reaction.translate(coding_rna)
    assert_equal(coding_peptide, reference_peptide)