def test_transcription(): test_dna = DNA('ATGATGGGCAGTGTCGAATTAAATCTGCGTGAGACAGAATTGTGTT' + 'TGGGACTACCAGGCGGTGATACAGTTGCACCAGTAACAGGAAACAA' + 'AAGAGGATTCTCTGAAACAGTAGATTTGAAACTTAATTTGAACAAT' + 'GAGCCAGCCAACAAGGAAGGTTCCACCACTCATGACGTCGTCACAT' + 'TTGATAGTAAAGAAAAGAGTGCGTGTCCAAAAGATCCAGCTAAGCC' + 'ACCTGCCAAGGCTCAAGTCGTCGGATGGCCACCTGTGAGATCTTAT' + 'AGAAAGAACGTAATGGTTTCTTGTCAGAAGTCCAGTGGTGGTCCTG' + 'AAGCAGCGGCTtgaaaa') reference_rna = RNA('AUGAUGGGCAGUGUCGAAUUAAAUCUGCGUGAGACAGAAUU' + 'GUGUUUGGGACUACCAGGCGGUGAUACAGUUGCACCAGUAA' + 'CAGGAAACAAAAGAGGAUUCUCUGAAACAGUAGAUUUGAAA' + 'CUUAAUUUGAACAAUGAGCCAGCCAACAAGGAAGGUUCCAC' + 'CACUCAUGACGUCGUCACAUUUGAUAGUAAAGAAAAGAGUG' + 'CGUGUCCAAAAGAUCCAGCUAAGCCACCUGCCAAGGCUCAA' + 'GUCGUCGGAUGGCCACCUGUGAGAUCUUAUAGAAAGAACGU' + 'AAUGGUUUCUUGUCAGAAGUCCAGUGGUGGUCCUGAAGCAG' + 'CGGCUugaaaa') # Basic transcription should work transcription_output = reaction.transcribe(test_dna) assert_equal(transcription_output, reference_rna) # Coding RNA should exclude anything after a stop codon coding_rna_output = reaction.coding_sequence(transcription_output) assert_equal(coding_rna_output, reference_rna[:-3]) # Should fail is sequence lacks start codon or stop codon assert_raises(ValueError, reaction.coding_sequence, reaction.transcribe(DNA('aaatag'))) assert_raises(ValueError, reaction.coding_sequence, reaction.transcribe(DNA('atgaaa')))
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)
def test_utils(): test_DNA = DNA('ATAGCGATACGAT') test_RNA = RNA('AUGCGAUAGCGAU') test_peptide = Peptide('msvkkkpvqg') test_str = 'msvkkkpvgq' assert_equal(analysis.utils.sequence_type(test_DNA), 'dna') assert_equal(analysis.utils.sequence_type(test_RNA), 'rna') assert_equal(analysis.utils.sequence_type(test_peptide), 'peptide') assert_raises(Exception, analysis.utils.sequence_type, test_str)
def test_reverse_transcription(): test_rna = RNA('AUGAUGGGCAGUGUCGAAUUAAAUCUGCGUGAGACAGAAUU' + 'GUGUUUGGGACUACCAGGCGGUGAUACAGUUGCACCAGUAA' + 'CAGGAAACAAAAGAGGAUUCUCUGAAACAGUAGAUUUGAAA' + 'CUUAAUUUGAACAAUGAGCCAGCCAACAAGGAAGGUUCCAC' + 'CACUCAUGACGUCGUCACAUUUGAUAGUAAAGAAAAGAGUG' + 'CGUGUCCAAAAGAUCCAGCUAAGCCACCUGCCAAGGCUCAA' + 'GUCGUCGGAUGGCCACCUGUGAGAUCUUAUAGAAAGAACGU' + 'AAUGGUUUCUUGUCAGAAGUCCAGUGGUGGUCCUGAAGCAG' + 'CGGCUugaaaa') ref_dna = DNA('ATGATGGGCAGTGTCGAATTAAATCTGCGTGAGACAGAATTGTGTT' + 'TGGGACTACCAGGCGGTGATACAGTTGCACCAGTAACAGGAAACAA' + 'AAGAGGATTCTCTGAAACAGTAGATTTGAAACTTAATTTGAACAAT' + 'GAGCCAGCCAACAAGGAAGGTTCCACCACTCATGACGTCGTCACAT' + 'TTGATAGTAAAGAAAAGAGTGCGTGTCCAAAAGATCCAGCTAAGCC' + 'ACCTGCCAAGGCTCAAGTCGTCGGATGGCCACCTGTGAGATCTTAT' + 'AGAAAGAACGTAATGGTTTCTTGTCAGAAGTCCAGTGGTGGTCCTG' + 'AAGCAGCGGCTtgaaaa') # Basic transcription should work r_transcription = reaction.reverse_transcribe(test_rna) assert_equal(r_transcription, ref_dna)
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)
class TestRNA(object): ''' Testing class for sequence.RNA ''' def __init__(self): self.test_rna = RNA('augc') def test_reverse_complement(self): assert_equal(str(self.test_rna.reverse_complement()), 'GCAU') def test_locate(self): assert_equal(self.test_rna.locate('au'), [0]) assert_equal(self.test_rna.locate('gc'), [2]) assert_equal(len(self.test_rna.locate('augg')), 0) def test_copy(self): assert_equal(self.test_rna, self.test_rna.copy()) def test_getitem(self): assert_equal(str(self.test_rna[0]), 'A') assert_equal(str(self.test_rna[1]), 'U') assert_equal(str(self.test_rna[2]), 'G') assert_equal(str(self.test_rna[3]), 'C') assert_equal(str(self.test_rna[-1]), 'C') def test_delitem(self): copy0 = self.test_rna.copy() del copy0[0] assert_equal(str(copy0), 'UGC') copy1 = self.test_rna.copy() del copy1[1] assert_equal(str(copy1), 'AGC') copy2 = self.test_rna.copy() del copy2[2] assert_equal(str(copy2), 'AUC') copy3 = self.test_rna.copy() del copy3[3] assert_equal(str(copy3), 'AUG') copy_1 = self.test_rna.copy() del copy_1[-1] assert_equal(str(copy_1), 'AUG') def test_setitem(self): copy0 = self.test_rna.copy() copy0[0] = 'u' assert_equal(str(copy0), 'UUGC') copy1 = self.test_rna.copy() copy1[1] = 'a' assert_equal(str(copy1), 'AAGC') copy2 = self.test_rna.copy() copy2[2] = 'a' assert_equal(str(copy2), 'AUAC') copy3 = self.test_rna.copy() copy3[3] = 'a' assert_equal(str(copy3), 'AUGA') copy_1 = self.test_rna.copy() copy_1[-1] = 'a' assert_equal(str(copy_1), 'AUGA') def test_str(self): assert_equal(str(self.test_rna), 'AUGC') def test_len(self): assert_equal(len(self.test_rna), 4) def test_add(self): assert_equal(str((self.test_rna + self.test_rna)), 'AUGCAUGC') def test_radd(self): assert_equal(str(sum([self.test_rna, self.test_rna])), 'AUGCAUGC') def radd_800(seq): return 800 + seq assert_raises(TypeError, radd_800, self.test_rna) def test_mul(self): assert_equal(str((self.test_rna * 4)), 'AUGCAUGCAUGCAUGC') def mul_float(seq): return seq * 7.56 assert_raises(TypeError, mul_float, self.test_rna) def test_eq(self): assert_true(self.test_rna == RNA('augc')) def test_ne(self): assert_true(self.test_rna != RNA('aagc')) def test_contains(self): assert_true('a' in self.test_rna) assert_true('u' in self.test_rna) assert_true('g' in self.test_rna) assert_true('c' in self.test_rna) assert_false('t' in self.test_rna)
def __init__(self): self.test_rna = RNA('augc')
def test_ne(self): assert_true(self.test_rna != RNA('aagc'))
def test_eq(self): assert_true(self.test_rna == RNA('augc'))
class TestRNA(object): ''' Testing class for sequence.RNA ''' def __init__(self): self.test_rna = RNA('augc') def test_reverse_complement(self): assert_equal(str(self.test_rna.reverse_complement()), 'GCAU') def test_locate(self): assert_equal(self.test_rna.locate('au'), [0]) assert_equal(self.test_rna.locate('gc'), [2]) assert_equal(len(self.test_rna.locate('augg')), 0) def test_copy(self): assert_equal(self.test_rna, self.test_rna.copy()) def test_getitem(self): assert_equal(str(self.test_rna[0]), 'A') assert_equal(str(self.test_rna[1]), 'U') assert_equal(str(self.test_rna[2]), 'G') assert_equal(str(self.test_rna[3]), 'C') assert_equal(str(self.test_rna[-1]), 'C') def test_delitem(self): copy0 = self.test_rna.copy() del copy0[0] assert_equal(str(copy0), 'UGC') copy1 = self.test_rna.copy() del copy1[1] assert_equal(str(copy1), 'AGC') copy2 = self.test_rna.copy() del copy2[2] assert_equal(str(copy2), 'AUC') copy3 = self.test_rna.copy() del copy3[3] assert_equal(str(copy3), 'AUG') copy_1 = self.test_rna.copy() del copy_1[-1] assert_equal(str(copy_1), 'AUG') def test_setitem(self): copy0 = self.test_rna.copy() copy0[0] = 'u' assert_equal(str(copy0), 'UUGC') copy1 = self.test_rna.copy() copy1[1] = 'a' assert_equal(str(copy1), 'AAGC') copy2 = self.test_rna.copy() copy2[2] = 'a' assert_equal(str(copy2), 'AUAC') copy3 = self.test_rna.copy() copy3[3] = 'a' assert_equal(str(copy3), 'AUGA') copy_1 = self.test_rna.copy() copy_1[-1] = 'a' assert_equal(str(copy_1), 'AUGA') def test_str(self): assert_equal(str(self.test_rna), 'AUGC') def test_len(self): assert_equal(len(self.test_rna), 4) def test_add(self): assert_equal(str((self.test_rna + self.test_rna)), 'AUGCAUGC') def test_radd(self): assert_equal(str(sum([self.test_rna, self.test_rna])), 'AUGCAUGC') def radd_800(seq): return 800 + seq assert_raises(TypeError, radd_800, self.test_rna) def test_mul(self): assert_equal(str((self.test_rna * 4)), 'AUGCAUGCAUGCAUGC') def mul_float(seq): return seq * 7.56 assert_raises(TypeError, mul_float, self.test_rna) def test_eq(self): assert_true(self.test_rna == RNA('augc')) def test_ne(self): assert_true(self.test_rna != RNA('aagc')) def test_contains(self): assert_true(RNA('a') in self.test_rna) assert_true(RNA('u') in self.test_rna) assert_true(RNA('g') in self.test_rna) assert_true(RNA('c') in self.test_rna) assert_false(RNA('a') in RNA('ugc'))
def test_contains(self): assert_true(RNA('a') in self.test_rna) assert_true(RNA('u') in self.test_rna) assert_true(RNA('g') in self.test_rna) assert_true(RNA('c') in self.test_rna) assert_false(RNA('a') in RNA('ugc'))