Skip to content

Commit

Permalink
Create codon_optimize_cds_by_proteins_gui.py
Browse files Browse the repository at this point in the history
  • Loading branch information
olgatsiouri1996 committed Aug 2, 2021
1 parent f5aea5e commit 42e8475
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions synbio/codon_optimize_cds_by_proteins_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# python3
from gooey import *
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from dnachisel import *
# imput parameters
@Gooey(required_cols=3, program_name='codon optimize cds by proteins', header_bg_color= '#DCDCDC', terminal_font_color= '#DCDCDC', terminal_panel_color= '#DCDCDC')
def main():
ap = GooeyParser()
ap.add_argument("-fa", "--fasta", required=True, widget='FileChooser', help="input single fasta file with coding sequence")
ap.add_argument("-prot", "--proteins", required=True, widget='FileChooser', help="input multi fasta file with protein sequences")
ap.add_argument("-org","--organism", required=True, help="organism to input(use either the names of the genomes avaliable on dnachisel or use the taxid of the organisms that exist in http://www.kazusa.or.jp/codon/)")
ap.add_argument("-opt","--optimized", required=True, widget='FileSaver', help="optimized fasta file")
args = vars(ap.parse_args())
# main
cds = SeqIO.read(args["fasta"], "fasta")
optimized_seqs = [] # setup an empty list
for record in SeqIO.parse(args['proteins'], "fasta"):
problem = DnaOptimizationProblem(sequence=str(cds.seq),
constraints=[EnforceTranslation(translation=str(record.seq))],
objectives=[CodonOptimize(species= args['organism'])])
problem.optimize()
# add this record to the list
optimized_seqs.append(SeqRecord(Seq(problem.sequence),id=record.id,description=""))
# export to fasta
SeqIO.write(optimized_seqs, args['optimized'], "fasta")

if __name__ == '__main__':
main()

0 comments on commit 42e8475

Please sign in to comment.