Beispiel #1
0
 def __init__(self, f_choices, sigf_choices, sg_num, *args, **kwargs):
     super(MRForm, self).__init__(*args, **kwargs)
     self.fields['f_value'].choices = f_choices
     self.fields['sigf_value'].choices = sigf_choices
     sgroups = utils.getGroupNumbersFromNumber(sg_num)
     sg_choices = []
     for sg in sgroups:
         sg_choices.append((sg, utils.sgNumNameTrans(number=sg)))
     self.fields['space_group'].choices = sg_choices
     self.fields['space_group'].initial = \
         (sg_num, utils.sgNumNameTrans(number=sg_num))
Beispiel #2
0
 def makeJobScripts(self, request):
     """
     create PBS/OGE job submission files, one for
     each rmsd, pdb file and spacegroup
     """
     time = "12:0:0"
     pbs_prefix = "#$ "
     pbs_head = "#!/bin/sh\n"
     pbs_head += "%s-m abe\n" % pbs_prefix
     pbs_head += "%s-S /bin/bash\n" % pbs_prefix
     pbs_head += "%s-cwd\n" % pbs_prefix
     pbs_head += "%s-l h_rt=%s\n" % (pbs_prefix, time)
     pbs_commands = "\n. /etc/profile\n"
     pbs_commands += "module load phenix\n"
     pbs_commands += ". $PHENIX/build/$PHENIX_MTYPE/setpaths.sh\n"
     pingurl = request.build_absolute_uri(
         reverse('tardis.apps.mrtardis.views.jobfinished',
                 args=[self.dataset.id]))
     wget_command = "wget -O - %s?jobid=$JOB_ID" % pingurl
     ## ping server ten times with more and more delay
     pbs_footer = "touch jobid-$JOB_ID.finished\n"
     pbs_footer += "I=0; while [[ \"true\" != `%s`" % wget_command
     pbs_footer += "&& $I -lt 10 ]];"
     pbs_footer += "do echo yes; sleep $(($I*2)); I=$(($I+1)); done"
     #pbs_footer = wget_command
     phaser_command = "phenix.phaser"
     spacegroups = [utils.sgNumNameTrans(number=sgnum)
                    for sgnum in self.get_params("space_group", value=True)]
     if self.get_param("sg_all", value=True) == "True":
         spacegroups.append("ALL")
     rmsds = self.get_params("rmsd", value=True)
     for pdbfile in self.get_params("PDBfile", value=True):
         for sg in spacegroups:
             for rmsd in rmsds:
                 parameters = self.getPhaserCommands(sg,
                                                     rmsd,
                                                     pdbfile)
                 output = pbs_head + pbs_commands
                 output += "echo -e \"" + parameters + "\"|" +\
                     phaser_command + " \n"
                 output += pbs_footer
                 jobfilename = pdbfile + "_" + sg + "_" + \
                     str(rmsd) + ".jobfile"
                 ofile = open(os.path.join(
                         get_full_staging_path(request.user.username),
                         jobfilename), 'w')
                 ofile.write(output)
                 ofile.close()
                 utils.add_staged_file_to_dataset(
                     jobfilename,
                     self.dataset.id,
                     request.user.username,
                     mimetype="application/x-shellscript")
                 self.new_param("jobscript", jobfilename)
Beispiel #3
0
    def makeJobScripts(self):
        """create PBS/OGE job submission files, one for
        each pdb file and spacegroup"""
        time = "12:0:0"
        pbs_prefix = "#$ "
        pbs_head = "#!/bin/sh\n"
        pbs_head += pbs_prefix + "-m abe\n"
        pbs_head += pbs_prefix + "-S /bin/bash\n"
        pbs_head += pbs_prefix + "-cwd\n"
        pbs_commands = """
. /etc/profile
module load phenix
. $PHENIX/build/$PHENIX_MTYPE/setpaths.sh
"""
        pbs_options = pbs_prefix + "-l h_rt=" + time + "\n"
        phaser_command = "phenix.phaser"
        for pdbfile in glob.glob(self.tmpdir + "/*.pdb"):
            pdbfile = os.path.basename(pdbfile)
            if type(self.parameters["space_group"]).__name__ == 'string':
                # ie. not list or tuple
                spacegroups = [self.parameters["space_group"]]
            else:
                spacegroups = self.parameters["space_group"]
            for sg_num in spacegroups:
                if sg_num == "ALL":
                    space_group = "ALL"
                else:
                    from tardis.apps.mrtardis.utils import sgNumNameTrans
                    space_group = sgNumNameTrans(number=sg_num)
                if type(self.parameters["rmsd"]).__name__ != 'list':
                    # ie. not list or tuple
                    rmsds = [self.parameters["rmsd"]]
                else:
                    rmsds = self.parameters["rmsd"]
                for rmsd in rmsds:
                    #print pdbfile
                    parameters = self.preparePhaserInput(space_group,
                                                         rmsd, pdbfile)
                    output = pbs_head + pbs_options + pbs_commands
                    output += "echo -e \"" + parameters + "\"|" +\
                        phaser_command + " \n"
                    jobfilename = pdbfile + "_" + space_group + "_" + \
                        repr(rmsd) + ".jobfile"
                    ofile = open(self.tmpdir + "/" + jobfilename, 'w')
                    ofile.write(output)
                    ofile.close()
                    self.jobfiles.append(jobfilename)
Beispiel #4
0
 def __init__(self, f_choices, sigf_choices, sg_num, *args, **kwargs):
     """
     A custom initialiser which translates between spacegroup numbers
     and names, and sets up choices for F and SIGF columns.
     :param f_choices: list of choices for the F column
         as taken from MTZ parser.
     :type f_choices: list of strings
     :param sigf_choices: list of choices for the SIGF column
         as taken from MTZ parser.
     :type sigf_choices: list of strings
     :param sg_num: space group number taken from the MTZ parser
     :type sg_num: integer
     """
     super(ParamForm, self).__init__(*args, **kwargs)
     self.fields["f_value"].choices = f_choices
     self.fields["sigf_value"].choices = sigf_choices
     sgroups = utils.getGroupNumbersFromNumber(sg_num)
     sg_choices = [(sg, utils.sgNumNameTrans(number=sg)) for sg in sgroups]
     self.fields["space_group"].choices = sg_choices
Beispiel #5
0
def MRParams(request, dataset_id):
    """
    shows the parameter entry form,
    takes request.GET["dataset_id"] as input.
    """
#    return True
    #dataset_id = request.GET["dataset_id"]
    #getMTZfile
    mtz_file = utils.get_mtz_file(dataset_id)
    mtz_params = utils.processMTZ(mtz_file.get_storage_path())
    tochoice = lambda x: (x, x)
    f_choices = map(tochoice, mtz_params["f_value"])
    sigf_choices = map(tochoice, mtz_params["sigf_value"])
    sg_num = mtz_params["spacegroup"]
    pdbfilelist = utils.get_pdb_files(dataset_id)
    rmsd_formfactory = formset_factory(RmsdForm)
    if request.method == 'POST':
        logger.debug("we're POSTing")
        param_form = MRForm(f_choices,
                            sigf_choices,
                            sg_num,
                            request.POST)
        rmsd_formset = rmsd_formfactory(request.POST)
        logger.debug(repr(param_form.is_valid()) +
                     repr(rmsd_formset.is_valid()) +
                     repr(rmsd_formset.errors) +
                     repr(request.POST))
        if param_form.is_valid() and rmsd_formset.is_valid():
            hpcUsername = MrTUser.objects.get(user=request.user).hpc_username
            newJob = hpcjob.HPCJob(hpcUsername)
            jobparameters = {
                "f_value": param_form.cleaned_data['f_value'],
                "sigf_value": param_form.cleaned_data['sigf_value'],
                "num_in_asym": param_form.cleaned_data['num_in_asym'],
                "ensemble_number": param_form.cleaned_data['ensemble_number'],
                "packing": param_form.cleaned_data['packing'],
                "space_group": param_form.cleaned_data['space_group'],
                }
            if "sg_all" in param_form.cleaned_data:
                if param_form.cleaned_data["sg_all"] == True:
                    jobparameters["space_group"].append("ALL")
            jobparameters["rmsd"] = []
            for form in rmsd_formset.forms:
                jobparameters["rmsd"].append(form.cleaned_data['rmsd'])
            jobparameters["mol_weight"] = param_form.cleaned_data['mol_weight']
            filepaths = utils.get_pdb_files(dataset_id,
                         storagePaths=True) + [mtz_file.get_storage_path()]
            logger.debug("params: " + repr(jobparameters))
            logger.debug("files: " + repr(filepaths))
            newJob.stage(jobparameters, filepaths)
            newJob.submit()
            dataset = Dataset.objects.get(pk=dataset_id)
            newJob.dbSave(dataset.experiment_id, dataset,
                          request.user)
            c = Context({})
            return render_to_response("mrtardis/running_job.html", c)
    else:
        param_form = MRForm(f_choices=f_choices,
                            sigf_choices=sigf_choices,
                            sg_num=sg_num)
        rmsd_formset = rmsd_formfactory()
    c = Context({
            'dataset_id': dataset_id,
            'mtz_params': mtz_params,
            'rmsd_formset': rmsd_formset,
            'paramForm': param_form,
            'fileName': mtz_file.filename,
            'pdbfilelist': pdbfilelist,
            'spacegroupname': utils.sgNumNameTrans(number=sg_num),
            })
    return render_to_response("mrtardis/parameters.html", c)