Example #1
0
def displayResults(request, experiment_id):
    """
    display results of POST submitted dataset in experiment_id
    :param experiment_id: experiment id containing results
    :type experiment_id: integer
    :returns: mrtardis/displayResults.html
    """
    if "dataset" in request.POST:
        thisMR = MRtask(dataset_id=request.POST["dataset"])
    else:
        return HttpResponseNotFound()
    results = thisMR.parseResults()
    c = Context(
        {
            "dataset": thisMR.dataset,
            "results": results,
            "experiment_id": experiment_id,
            "f_value": thisMR.get_param("f_value", value=True),
            "sigf_value": thisMR.get_param("sigf_value", value=True),
            "mol_weight": thisMR.get_param("mol_weight", value=True),
            "num_in_asym": thisMR.get_param("num_in_asym", value=True),
            "packing": thisMR.get_param("packing", value=True),
            "ensemble_number": thisMR.get_param("ensemble_number", value=True),
        }
    )
    return render_to_response("mrtardis/displayResults.html", c)
Example #2
0
def jobfinished(request, dataset_id):
    thisMR = MRtask(dataset_id=dataset_id)
    if "jobid" not in request.GET and thisMR.get_status(value=True) != "running":
        return HttpResponseNotFound()
    jobid = request.GET["jobid"]
    for jid in thisMR.get_params("jobid", value=True):
        if jid == jobid:
            thisMR.new_param("jobidstatus", jobid + "-finished")
    if thisMR.retrievalTrigger():
        hpcusers = HPCUser.objects.filter(hpc_username=thisMR.get_param("hpc_username", value=True))
        for hpcuser in hpcusers:
            if hpcuser.user.email != "":
                thisMR.sendMail(hpcuser.user.get_full_name(), hpcuser.user.email, request.build_absolute_uri("/"))
    return HttpResponse("true")
Example #3
0
def parForm(request, dataset_id):
    """
    shows/saves django form for MR parameters
    :param dataset_id: dataset to find parameters in
    :type dataset_id: integer
    :returns: template mrtardis/parform.html
    """
    contextdict = dict()
    thisMR = MRtask(dataset_id=dataset_id)
    f_choices = [(x.string_value, x.string_value) for x in thisMR.get_params("f_values")]
    sigf_choices = [(x.string_value, x.string_value) for x in thisMR.get_params("sigf_values")]
    try:
        sg_num = int(thisMR.get_param("spacegroup_mtz").string_value)
    except ObjectDoesNotExist:
        sg_num = None
    formerrors = None
    rmsderrors = None
    if request.method == "POST":
        print request.POST
        paramForm = ParamForm(f_choices, sigf_choices, sg_num, request.POST)
        rmsd_formfactory = formset_factory(RmsdForm)
        rmsdForms = rmsd_formfactory(request.POST)
        #        print rmsdForms.is_valid()
        #        print rmsdForms.errors
        #        print paramForm.is_valid()
        #        print paramForm.errors
        if paramForm.is_valid() and rmsdForms.is_valid():
            # print "is validated"
            thisMR.set_params_from_dict(paramForm.cleaned_data)
            thisMR.delete_params("rmsd")
            # print rmsdForms.cleaned_data
            thisMR.set_param_list(
                "rmsd",
                [
                    r.cleaned_data["rmsd"]
                    for r in rmsdForms.forms
                    if "rmsd" in r.cleaned_data and r.cleaned_data["rmsd"]
                ],
            )
            # print thisMR.get_params("rmsd")
            contextdict["saved"] = "Saved successfully"
        else:
            if paramForm.errors:
                formerrors = paramForm.errors
            elif rmsdForms.errors:
                rmsderrors = rmsdForms.errors
    formargs = thisMR.get_form_dictionary()
    if len(formargs["space_group"]) == 0:
        formargs["space_group"] = [sg_num]
    print formargs
    paramForm = ParamForm(f_choices, sigf_choices, sg_num, initial=formargs)
    rmsd_pars = thisMR.get_params("rmsd")
    rmsd_formfactory = formset_factory(RmsdForm, extra=1)
    rmsds = [{"rmsd": r.string_value} for r in rmsd_pars]
    rmsdForms = rmsd_formfactory(initial=rmsds)
    contextdict["paramForm"] = paramForm
    contextdict["rmsdForms"] = rmsdForms
    if formerrors or rmsderrors:
        contextdict["formerrors"] = formerrors
        contextdict["rmsderrors"] = rmsderrors
    c = Context(contextdict)
    return render_to_response("mrtardis/parform.html", c)