Closed harijay closed 5 years ago
Hi there,
Thanks for reporting the broken example, I have fixed it ("Objective" became "Specification" a few months ago).
I am not sure exactly what you end goal is, do you want to study different codon adaptations in your repeats, or do you simply want to minimize repeats in your sequence to avoid recombinations etc. ? In the second case, If you want to minimize kmer repeats you can use the Specification AvoidNonUniqueSegments
:
from dnachisel import (AvoidNonuniqueSegments, EnforceTranslation)
from dnachisel.biotools import reverse_translate, random_protein_sequence
# We create a random protein made of a 50-amino-acid domain repeated 3 times
protein_segment = random_protein_sequence(length=50)
repeated_protein = protein_segment + protein_segment + protein_segment
repeated_protein_gene = reverse_translate(repeated_protein)
# The problem: keep the amino-acid sequence, but make sure the sequence
# uses different amino acids so that each 12-mer in the sequence is unique
problem = DnaOptimizationProblem(
sequence=repeated_protein_gene,
constraints=[EnforceTranslation(),
AvoidNonuniqueSegments(min_length=12)],
)
problem.resolve_constraints()
If the resolution fails in your case you can also pass AvoidNonuniqueSegments as objective:
problem = DnaOptimizationProblem(
sequence=repeated_protein_gene,
constraints=[EnforceTranslation()],
objectives=[AvoidNonuniqueSegments()]
)
Let me know if I got it right and if that works for you.
Hi Zulko, thanks for this tip. When I attempt to run the AvoidNonuniqueSegments method described above I get a KeyError, possibly from EnforceTranslation.py. The full error message is below. Do you know what might be causing this?
Thanks
`KeyError Traceback (most recent call last)
This is a weird one, my best guess is that the sequence you provide to DnaOptimizationProblem
contains a X... are you providing a degenerate DNA sequence ?
Yup, cleaning up the input string seemed to do the trick. Thanks for the prompt reply
No problem ! Let me know if you managed to do what you wanted, so I can close this thread.
The problem was resolved, you can close the thread
:+1:
I was trying to understand the example included in ".//examples/non_unique_kmers_minimization.py" and they mention two classes "ObjectiveEvaluation" and Objective. I couldnt find these anywhere in the source, can someone point me in the right direction.
Alternatively I am looking to write DNAOptimization objective that will design protein coding repeats without using the same codons for each repeat in an expression plasmid.
Any help in this will be greatly appreciated.