Example #1
0
 def function(seq, category, prefix, suffix, enzymes, with_intron):
     seq = domesticate_for_synthesis(seq, category, prefix, suffix, enzymes,
                                     with_intron)[0]
     protocol = write_synthesis_protocol(seq)
     response = HttpResponse(protocol, content_type='text/plain')
     response['Content-Disposition'] = 'attachment; filename="protocol.txt"'
     return response
Example #2
0
 def function(seq, category, prefix, suffix, enzymes, with_intron):
     seq = domesticate_for_synthesis(seq, category, prefix, suffix, enzymes,
                                     with_intron)[1]
     response = HttpResponse(convert_to_sbol(seq),
                             content_type='xml/plain')
     response['Content-Disposition'] = 'attachment; '
     response['Content-Disposition'] += 'filename="{0}.xml"'.format(seq.id)
     return response
Example #3
0
 def function(seq, category, prefix, suffix, enzymes, with_intron):
     seq = domesticate_for_synthesis(seq, category, prefix, suffix, enzymes,
                                     with_intron)[1]
     response = HttpResponse(seq.format('genbank'),
                             content_type='text/plain')
     response['Content-Disposition'] = 'attachment; '
     response['Content-Disposition'] += 'filename="{0}.gb"'.format(seq.id)
     return response
Example #4
0
def _domestication_view(request, kind):
    context = RequestContext(request)
    context.update(csrf(request))
    if request.method == 'POST':
        request_data = request.POST
    elif request.method == 'GET':
        request_data = request.GET
    else:
        request_data = None
    if request_data:
        form = DomesticationForm(request_data, request.FILES)
        # do domestication
        if form.is_valid():
            seq = form.cleaned_data['seq']
            if seq is None:
                seq = form.cleaned_data['residues']
            category = form.cleaned_data.get('category', None)
            enzymes = form.cleaned_data.get('enzymes', None)
            if category is None:
                prefix = form.cleaned_data.get('prefix')
                suffix = form.cleaned_data.get('suffix')
            else:
                try:
                    prefix = CATEGORIES[category][1]
                    suffix = CATEGORIES[category][2]
                except KeyError:
                    prefix = CRYSPER_CATEGORIES[category][1]
                    suffix = CRYSPER_CATEGORIES[category][2]

            with_intron = form.cleaned_data['with_intron']
            with_intron_str = '1' if with_intron else '0'
            if kind == 'domestication':
                try:
                    pcr = domesticate(seq, category, prefix, suffix, enzymes,
                                      with_intron)[0]
                except RuntimeError as error:
                    return render_to_response('goldenbraid_info.html',
                                              {'title': 'Can not domesticate sequence',
                                               'info': error},
                                              context_instance=RequestContext(request))

                return render_to_response('domestication_result.html',
                                          {'category': category,
                                           'prefix': prefix,
                                           'suffix': suffix,
                                           'pcrs': pcr,
                                           'seq': str(seq.seq),
                                           'seq_name': seq.name,
                                           'enzymes': enzymes,
                                           'with_intron': with_intron_str},
                                      context_instance=RequestContext(request))
            elif kind == 'synthesis':
                try:
                    seq_for_syn, prepared_seq = domesticate_for_synthesis(seq,
                                                                          category,
                                                                          prefix,
                                                                          suffix,
                                                                          enzymes,
                                                                          with_intron)
                except RuntimeError as error:
                    return render_to_response('goldenbraid_info.html',
                                              {'title': 'Can not domesticate sequence',
                                               'info': error},
                                              context_instance=RequestContext(request))
                return render_to_response('synthesis_result.html',
                                          {'category': category,
                                           'prefix': prefix,
                                           'suffix': suffix,
                                           'seq_syn': seq_for_syn,
                                           'seq': str(seq.seq),
                                           'seq_name': prepared_seq.name,
                                           'enzymes': enzymes,
                                           'with_intron': with_intron_str},
                                      context_instance=RequestContext(request))
    else:
        form = DomesticationForm()
    context['form'] = form
    context['kind'] = kind

    template = 'domestication_template.html'
    content_type = None
    return render_to_response(template, context, content_type=content_type)