Пример #1
0
def multipartite_view_free_sbol(request):
    context = RequestContext(request)
    context.update(csrf(request))
    if request.method == 'POST':
        request_data = request.POST
    else:
        msg = "To get the sequence you need first to assemble parts"
        return HttpResponseBadRequest(msg)

    feats = [request_data['vector']]
    for k in sorted(request_data.keys()):
        if 'part_' in k:
            feats.append(request_data[k])

    form_class = get_multipartite_free_form(feats)
    form = form_class(request_data)
    if form.is_valid():
        last_feat = Feature.objects.get(uniquename=feats[-1])
        last_suffix = last_feat.suffix
        if last_suffix == 'CGCT':
            protocol_data, part_order = _get_fragments_from_request(request)
            assembled_seq = assemble_parts(protocol_data, part_order)
            response = HttpResponse(convert_to_sbol(assembled_seq),
                                    content_type='xml/plain')
            filename = assembled_seq.name + '.xml'
            response['Content-Disposition'] = 'attachment; '
            response['Content-Disposition'] += 'filename="{0}"'.format(filename)
            return response

    return HttpResponseBadRequest('There was an error in the assembly')
Пример #2
0
def multipartite_view_sbol(request, multi_type=None):
    'view of the multipartite tool'

    if multi_type is None:
        return render_to_response('multipartite_initial.html', {},
                                  context_instance=RequestContext(request))
    elif multi_type not in PARTS_TO_ASSEMBLE.keys():
        return Http404
    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
    form_class = get_multipartite_form(multi_type, request.user)
    if request_data:
        form = form_class(request_data)

        if form.is_valid():
            multi_form_data = form.cleaned_data
            part_types = [p[0] for p in PARTS_TO_ASSEMBLE[multi_type]]
            assembled_seq = assemble_parts(multi_form_data, part_types)
            filename = assembled_seq.name + '.xml'
            response = HttpResponse(convert_to_sbol(assembled_seq),
                                    content_type='xml/plain')
            response['Content-Disposition'] = 'attachment; '
            response['Content-Disposition'] += 'filename="{0}"'.format(filename)
            return response
    return HttpResponseBadRequest()
Пример #3
0
 def test_sbol(self):
     # feat = os.path.join(TEST_DATA, 'pEGBAn11.gb')
     # print feat.genbank_file
     seq = read(os.path.join(TEST_DATA, 'pEGBAn11.gb'), 'gb')
     fhand = open('/tmp/sbol.xml', 'w')
     fhand.write(convert_to_sbol(seq))
     fhand.close()
Пример #4
0
 def function(seq, category, prefix, suffix, enzymes, with_intron):
     seq = domesticate(seq, category, prefix, suffix, enzymes,
                       with_intron)[1]
     response = HttpResponse(convert_to_sbol(seq),
                             content_type='text/xml')
     response['Content-Disposition'] = 'attachment; '
     response['Content-Disposition'] += 'filename="{0}.xml"'.format(seq.id)
     return response
Пример #5
0
def feature_sbol(request, uniquename):
    user = request.user
    print(uniquename)
    try:
        feat = Feature.objects.get(uniquename=uniquename)
    except Feature.DoesNotExist:
        feat = None

    if feat is None:
        return Http404
    if (feat.is_public or (user.is_staff or user == feat.owner)):
        seq = read(feat.genbank_file, 'gb')
        response = HttpResponse(convert_to_sbol(seq), content_type='xml/plain')
        filename = seq.name + '.xml'
        response['Content-Disposition'] = 'attachment; '
        response['Content-Disposition'] += 'filename="{0}"'.format(filename)
        return response

    else:
        return HttpResponseForbidden
Пример #6
0
def bipartite_view_sbol(request):
    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 = BipartiteForm3(request_data)
        if form.is_valid():
            seq = assemble_parts(form.cleaned_data, ['part_1', 'part_2'])
            response = HttpResponse(convert_to_sbol(seq),
                                    content_type='xml/plain')
            filename = seq.name + '.xml'
            response['Content-Disposition'] = 'attachment; '
            response['Content-Disposition'] += 'filename="{0}"'.format(filename)
            return response
    return HttpResponseBadRequest()