Exemple #1
0
 def test008(self):
     """zero-length nucleotides"""
     s = ""
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 0)
     self.assertTrue(translate.translate(s) == "")
     self.assertTrue(translate.translateRaw(s) == "")
Exemple #2
0
 def test005(self):
     """codons"""
     s = "ATGCatTCTNNNTAAAGA"
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(c[0] == "ATG")
     self.assertTrue(c[1] == "Cat")
     self.assertTrue(c[-1] == "AGA")
Exemple #3
0
 def test008(self):
     """zero-length nucleotides"""
     s = ''
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 0)
     self.assertTrue(translate.translate(s) == '')
     self.assertTrue(translate.translateRaw(s) == '')
Exemple #4
0
 def test005(self):
     """codons"""
     s = 'ATGCatTCTNNNTAAAGA'
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(c[0] == 'ATG')
     self.assertTrue(c[1] == 'Cat')
     self.assertTrue(c[-1] == 'AGA')
Exemple #5
0
 def test009(self):
     """odd-length coding sequence"""
     s = "TCTCGTAAGTACGCAGC"
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 5)
     self.assertTrue(c[-1] == "GCA")
     self.assertTrue(translate.translate(s) is None)
     self.assertTrue(translate.translateRaw(s) == "SRKYA")
Exemple #6
0
 def test009(self):
     """odd-length coding sequence"""
     s = 'TCTCGTAAGTACGCAGC'
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 5)
     self.assertTrue(c[-1] == 'GCA')
     self.assertTrue(translate.translate(s) is None)
     self.assertTrue(translate.translateRaw(s) == 'SRKYA')
Exemple #7
0
def makeMutantFromSequence(target_protein_seq, base_dna_seq):
	codons = [x for x in translate.codons(base_dna_seq)]
	base_prot_seq = translate.translate(base_dna_seq)
	assert len(base_prot_seq) == len(target_protein_seq)
	mutant_dna_seq = ''
	for (i, aa) in enumerate(target_protein_seq):
		if aa == base_prot_seq[i]:
			mutant_dna_seq += codons[i]
		else:
			mutant_dna_seq += translate.randomReverseTranslate(aa)
	assert translate.translate(mutant_dna_seq) == target_protein_seq
	return mutant_dna_seq
Exemple #8
0
 def test006(self):
     """zero-length codons"""
     s = "AT"
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 0)
Exemple #9
0
        info_outs.write(line)

    # If optimization is desired, do it.
    if options.optimize:
        info_outs.write("# Optimizing sequences...\n")
        gc = translate.geneticCode(rna=False)
        codons = {}
        opt_codon_dict = dict([(gc[c], c) for c in opt_codons])
        opt_codon_dict['W'] = 'TGG'
        opt_codon_dict['M'] = 'ATG'

        opt_headers = []
        opt_seqs = []
        # optimize the codon sequences
        for (id, seq) in seqs:
            orig_codons = [c for c in translate.codons(seq)]
            prot_seq = translate.translate(seq)
            if not prot_seq is None:
                for aa in translate.AAs():
                    codons[aa] = [
                        c for c in translate.getCodonsForAA(aa, rna=False)
                        if relad_dict[c] >= options.min_rel_adapt
                    ]
                opt_seq = ''
                for (aai, aa) in enumerate(prot_seq):
                    #opt_seq += opt_codon_dict[aa] #random.choice(codons[aa])
                    codons_to_choose_from = codons[aa]
                    # If avoiding codons and we have a choice, eliminate the avoided codon.
                    if options.avoid_sequence and len(
                            codons_to_choose_from) > 1:
                        try:
Exemple #10
0
 def test006(self):
     """zero-length codons"""
     s = 'AT'
     c = [cod for cod in translate.codons(s)]
     self.assertTrue(len(c) == 0)
Exemple #11
0
		info_outs.write(line)

	# If optimization is desired, do it.
	if options.optimize:
		info_outs.write("# Optimizing sequences...\n")
		gc = translate.geneticCode(rna=False)
		codons = {}
		opt_codon_dict = dict([(gc[c],c) for c in opt_codons])
		opt_codon_dict['W'] = 'TGG'
		opt_codon_dict['M'] = 'ATG'

		opt_headers = []
		opt_seqs = []
		# optimize the codon sequences
		for (id, seq) in seqs:
			orig_codons = [c for c in translate.codons(seq)]
			prot_seq = translate.translate(seq)
			if not prot_seq is None:
				for aa in translate.AAs():
					codons[aa] = [c for c in translate.getCodonsForAA(aa, rna=False) if relad_dict[c] >= options.min_rel_adapt]
				opt_seq = ''
				for (aai, aa) in enumerate(prot_seq):
					#opt_seq += opt_codon_dict[aa] #random.choice(codons[aa])
					codons_to_choose_from = codons[aa]
					# If avoiding codons and we have a choice, eliminate the avoided codon.
					if options.avoid_sequence and len(codons_to_choose_from)>1:
						try:
							codons_to_choose_from.remove(orig_codons[aai])
						except ValueError: # codon to be avoided not among codon choices anyway
							pass
					opt_seq += random.choice(codons_to_choose_from)