def form_valid(self, form): # build command strings, create skylabfile for each file input cluster = form.cleaned_data['mpi_cluster'] input_file = form.cleaned_data['param_input'] exec_string = u"vina_split --input {0:s} ".format(input_file.name) input_filename_without_ext = os.path.splitext(os.path.basename(input_file.name))[0] # if form.cleaned_data.get('param_ligand_prefix'): # exec_string += u"--ligand {0:s} ".format(get_valid_filename(form.cleaned_data['param_ligand_prefix'])) # else: exec_string += u"--ligand {0:s}-ligand ".format(input_filename_without_ext) # if form.cleaned_data.get('param_flex_prefix'): # exec_string += u"--flex {0:s} ".format(get_valid_filename(form.cleaned_data['param_flex_prefix'])) # else: exec_string += u"--flex {0:s}-flex ".format(input_filename_without_ext) #print(exec_string) tool = Tool.objects.get(simple_name="vinasplit") task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user, task_data=json.dumps({'command_list': [exec_string]}) ) self.kwargs['id'] = task.id # pass to get_success_url SkyLabFile.objects.create(type=1, file=input_file, task=task) send_to_queue(task=task) return super(VinaSplitView, self).form_valid(form)
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] input_file = form.cleaned_data['param_input'] exec_string = u"vina_split --input {0:s} ".format(input_file.name) input_filename_without_ext = os.path.splitext(os.path.basename(input_file.name))[0] # if form.cleaned_data.get('param_ligand_prefix'): # exec_string += u"--ligand {0:s} ".format(get_valid_filename(form.cleaned_data['param_ligand_prefix'])) # else: exec_string += u"--ligand {0:s}-ligand ".format(input_filename_without_ext) # if form.cleaned_data.get('param_flex_prefix'): # exec_string += u"--flex {0:s} ".format(get_valid_filename(form.cleaned_data['param_flex_prefix'])) # else: exec_string += u"--flex {0:s}-flex ".format(input_filename_without_ext) #print(exec_string) tool = Tool.objects.get(simple_name="vinasplit") task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user, task_data=json.dumps({'command_list': [exec_string]}) ) self.kwargs['id'] = task.id # pass to get_success_url SkyLabFile.objects.create(type=1, file=input_file, task=task) send_to_queue(task=task) return super(VinaSplitView, self).form_valid(form)
def form_valid(self, form): # build command strings, create skylabfile for file inputs cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='dock6') # -n cluster_size command = "mpirun -np {0:d} -f {1:s} dock6.mpi ".format(cluster.total_node_count, settings.MPIEXEC_NODES_FILE) # command = "mpiexec -np 4 dock6.mpi " task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) self.kwargs['id'] = task.id cluster = form.cleaned_data['mpi_cluster'] input_file = form.cleaned_data['param_input_file'] SkyLabFile.objects.create(type=1, file=input_file, task=task) command += u"-i {0:s} ".format(input_file.name) for f in form.cleaned_data['param_other_files']: SkyLabFile.objects.create(type=1, file=f, task=task) if form.cleaned_data.get('param_output_prefix'): command += u"-o ../output/{0:s}.out ".format(form.cleaned_data['param_output_prefix']) else: command += u"-o ../output/{0:s}.out ".format(os.path.splitext(input_file.name)[0]) task.task_data = json.dumps({'command_list': [command]}) task.save() send_to_queue(task=task) # send signal to queue this task to task queue return super(Dock6View, self).form_valid(form)
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='dock6') # -n cluster_size command = "mpirun -np {0:d} -f {1:s} dock6.mpi ".format(cluster.total_node_count, settings.MPIEXEC_NODES_FILE) # command = "mpiexec -np 4 dock6.mpi " task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) self.kwargs['id'] = task.id cluster = form.cleaned_data['mpi_cluster'] input_file = form.cleaned_data['param_input_file'] SkyLabFile.objects.create(type=1, file=input_file, task=task) command += u"-i {0:s} ".format(input_file.name) for f in form.cleaned_data['param_other_files']: SkyLabFile.objects.create(type=1, file=f, task=task) if form.cleaned_data.get('param_output_prefix'): command += u"-o ../output/{0:s}.out ".format(form.cleaned_data['param_output_prefix']) else: command += u"-o ../output/{0:s}.out ".format(os.path.splitext(input_file.name)[0]) task.task_data = json.dumps({'command_list': [command]}) task.save() send_to_queue(task=task) return super(Dock6View, self).form_valid(form)
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='grid') command = "grid " task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user, ) self.kwargs['id'] = task.id input_file = form.cleaned_data['param_input_file'] SkyLabFile.objects.create(type=1, file=input_file, task=task) command += "-i %s " % input_file.name for f in form.cleaned_data['param_other_files']: SkyLabFile.objects.create(type=1, file=f, task=task) if form.cleaned_data.get('param_output_prefix'): command += "-o ../output/%s.out " % form.cleaned_data['param_output_prefix'] else: command += "-o ../output/%s.out " % os.path.splitext(input_file.name)[0] if form.cleaned_data['param_terse']: command += "-t " if form.cleaned_data['param_verbose']: command += "-v " task.task_data = json.dumps({'command_list': [command]}) task.save() send_to_queue(task=task) return super(GridView, self).form_valid(form)
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] receptor_file = form.cleaned_data['param_receptor_file'] exec_string = "autogrid4 " task = Task.objects.create( mpi_cluster=cluster, tool=Tool.objects.get(simple_name='autogrid4'), user=self.request.user ) self.kwargs['id'] = task.id SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_gpf_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_receptor_file'], task=task) exec_string += u"-p {0:s} ".format(form.cleaned_data['param_gpf_file'].name) if form.cleaned_data.get('param_glg_filename'): exec_string += u"-l ../output/{0:s}.glg ".format(form.cleaned_data['param_glg_filename']) else: exec_string += u'-l ../output/{0:s}.glg '.format( os.path.splitext(form.cleaned_data['param_gpf_file'].name)[0]) if form.cleaned_data['param_d']: exec_string += "-d " exec_string += "; " if form.cleaned_data['param_use_with_autodock']: SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_ligand_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_dpf_file'], task=task) exec_string += "autodock4 -p %s " % form.cleaned_data['param_dpf_file'].name if form.cleaned_data.get('param_dlg_filename'): exec_string += u"-l ../output/{0:s}.dlg ".format(form.cleaned_data['param_dlg_filename']) else: exec_string += u"-l ../output/{0:s}.dlg ".format( os.path.splitext(form.cleaned_data['param_dpf_file'].name)[0]) if form.cleaned_data['param_k']: exec_string += "-k " if form.cleaned_data['param_i']: exec_string += "-i " if form.cleaned_data['param_t']: exec_string += "-t " if form.cleaned_data['param_d_dock']: exec_string += "-d " exec_string += ";" task.task_data = json.dumps({'command_list': [exec_string]}) task.save() send_to_queue(task=task) return super(Autogrid4View, self).form_valid(form)
def post(self, request, *args, **kwargs): # build command, strings, create SkylabFile instances for each input file form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) if select_mpi_form.is_valid() and input_formset.is_valid(): cluster = select_mpi_form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='impi') command_list = [] for input_form in input_formset: operation = input_form.cleaned_data.get('param_operation') # command = {} if operation: # command['operation'] = operation command_list.append(operation) if operation == '3' or operation == '4': value = input_form.cleaned_data.get('param_value') command_list.append(value) # command['value'] = value # command_list.append(command) task = Task.objects.create(mpi_cluster=cluster, tool=tool, user=self.request.user) input_filenames = [] for f in select_mpi_form.cleaned_data['input_files']: SkyLabFile.objects.create(type=1, file=f, task=task) input_filenames.append(f.name) task_data = { 'command_list': command_list, 'input_filenames': input_filenames } task.refresh_from_db() task.task_data = json.dumps(task_data) task.save() # send signal to queue this task to task queue send_to_queue(task=task) return redirect('task_detail_view', pk=task.id) else: return render( request, 'modules/impi/use_impi.html', { 'form': select_mpi_form, 'input_formset': input_formset, 'tool': Tool.objects.get(simple_name='impi'), })
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] # BUILD COMMAND STRING, CREATE SKYLABFILE INSTANCES FOR FILE INPUTS exec_string = "autodock4 " task = Task.objects.create( mpi_cluster=cluster, tool=Tool.objects.get(simple_name='autodock4'), user=self.request.user) self.kwargs['id'] = task.id # SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_receptor_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_ligand_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_dpf_file'], task=task) exec_string += "-p %s " % form.cleaned_data['param_dpf_file'].name for grid_file in form.cleaned_data['param_grid_files']: SkyLabFile.objects.create(type=1, file=grid_file, task=task) if form.cleaned_data.get('param_dlg_filename'): exec_string += "-l ../output/%s.dlg " % ( form.cleaned_data['param_dlg_filename']) else: exec_string += "-l ../output/%s.dlg " % os.path.splitext( form.cleaned_data['param_dpf_file'].name)[0] if form.cleaned_data['param_k']: exec_string += "-k " if form.cleaned_data['param_i']: exec_string += "-i " if form.cleaned_data['param_t']: exec_string += "-t " if form.cleaned_data['param_d']: exec_string += "-d " exec_string += ";" task.task_data = json.dumps({'command_list': [exec_string]}) task.save() send_to_queue(task=task) # send signal to queue this task return super(Autodock4View, self).form_valid(form)
def post(self, request, *args, **kwargs): form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) if select_mpi_form.is_valid() and input_formset.is_valid(): cluster = select_mpi_form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='impi') command_list = [] for input_form in input_formset: operation = input_form.cleaned_data.get('param_operation') # command = {} if operation: # command['operation'] = operation command_list.append(operation) if operation == '3' or operation == '4': value = input_form.cleaned_data.get('param_value') command_list.append(value) # command['value'] = value # command_list.append(command) task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) input_filenames = [] for f in select_mpi_form.cleaned_data['input_files']: SkyLabFile.objects.create(type=1, file=f, task=task) input_filenames.append(f.name) task_data = { 'command_list': command_list, 'input_filenames': input_filenames } task.refresh_from_db() task.task_data = json.dumps(task_data) task.save() send_to_queue(task=task) return redirect('task_detail_view', pk=task.id) else: return render(request, 'modules/impi/use_impi.html', { 'form': select_mpi_form, 'input_formset': input_formset, 'tool':Tool.objects.get(simple_name='impi'), })
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] exec_string = "autodock4 " task = Task.objects.create( mpi_cluster=cluster, tool=Tool.objects.get(simple_name='autodock4'), user=self.request.user ) self.kwargs['id'] = task.id # SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_receptor_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_ligand_file'], task=task) SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_dpf_file'], task=task) exec_string += "-p %s " % form.cleaned_data['param_dpf_file'].name for grid_file in form.cleaned_data['param_grid_files']: SkyLabFile.objects.create(type=1, file=grid_file, task=task) # if form.cleaned_data.get('param_dat_file'): # SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_dat_file'], task=task) if form.cleaned_data.get('param_dlg_filename'): exec_string += "-l ../output/%s.dlg " % (form.cleaned_data['param_dlg_filename']) else: exec_string += "-l ../output/%s.dlg " % os.path.splitext(form.cleaned_data['param_dpf_file'].name)[0] if form.cleaned_data['param_k']: exec_string += "-k " if form.cleaned_data['param_i']: exec_string += "-i " if form.cleaned_data['param_t']: exec_string += "-t " if form.cleaned_data['param_d']: exec_string += "-d " exec_string += ";" task.task_data = json.dumps({'command_list': [exec_string]}) task.save() send_to_queue(task=task) # find a way to know if thread is already running return super(Autodock4View, self).form_valid(form)
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='gamess') task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) command_list = [] for f in form.cleaned_data['input_files']: SkyLabFile.objects.create(type=1, file=f, task=task) filename_without_ext = os.path.splitext(f.name)[0] command = "rungms {0} 01 1 2>&1 | tee ../output/{0}.log".format(filename_without_ext) command_list.append(command) task.refresh_from_db() task.task_data = json.dumps({'command_list': command_list}) task.save() send_to_queue(task=task) self.kwargs['id'] = task.id return super(GamessView, self).form_valid(form)
def form_valid(self, form): # build command strings, create SkylabFiles for form input files cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='gamess') task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) command_list = [] for f in form.cleaned_data['input_files']: SkyLabFile.objects.create(type=1, file=f, task=task) filename_without_ext = os.path.splitext(f.name)[0] command = "rungms {0} 01 1 2>&1 | tee ../output/{0}.log".format(filename_without_ext) command_list.append(command) task.refresh_from_db() task.task_data = json.dumps({'command_list': command_list}) task.save() send_to_queue(task=task) # send signal to queue this task to task queue self.kwargs['id'] = task.id return super(GamessView, self).form_valid(form)
def form_valid(self, form): # build command strings, create skylabfile for file inputs cluster = form.cleaned_data['mpi_cluster'] tool = Tool.objects.get(simple_name='grid') command = "grid " task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user, ) self.kwargs['id'] = task.id input_file = form.cleaned_data['param_input_file'] SkyLabFile.objects.create(type=1, file=input_file, task=task) command += "-i %s " % input_file.name for f in form.cleaned_data['param_other_files']: SkyLabFile.objects.create(type=1, file=f, task=task) if form.cleaned_data.get('param_output_prefix'): command += "-o ../output/%s.out " % form.cleaned_data['param_output_prefix'] else: command += "-o ../output/%s.out " % os.path.splitext(input_file.name)[0] if form.cleaned_data['param_terse']: command += "-t " if form.cleaned_data['param_verbose']: command += "-v " task.task_data = json.dumps({'command_list': [command]}) task.save() send_to_queue(task=task) # send signal to queue this task to task queue return super(GridView, self).form_valid(form)
def post(self, request, *args, **kwargs): form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) other_parameter_form = OtherParameterForm(request.POST, request.FILES) if select_mpi_form.is_valid() and other_parameter_form.is_valid( ) and input_formset.is_valid(): # build command strings, create skylab file for each file input cluster = select_mpi_form.cleaned_data['mpi_cluster'] command_list = [] # -n cluster_size command = "mpiexec -n {0:d} -f {1:s} ".format( cluster.total_node_count, settings.MPIEXEC_NODES_FILE) # -bynode if select_mpi_form.cleaned_data['param_bynode']: command += "-bynode " tool = Tool.objects.get(simple_name="ray") task = Task.objects.create(mpi_cluster=cluster, tool=tool, user=self.request.user) command += "Ray -o task_{0:d}/output ".format(task.id) # k-mer length if other_parameter_form.cleaned_data.get('param_kmer_length'): command += u"-k {0:d}".format( other_parameter_form.cleaned_data["param_kmer_length"]) # -mini-ranks-per-rank if select_mpi_form.cleaned_data.get('param_mini_ranks'): command += u"-mini-ranks-per-rank {0:d} ".format( select_mpi_form.cleaned_data["param_mini_ranks"]) for form in input_formset: parameter = form.cleaned_data.get('parameter') if parameter: # ignore blank parameter value input_file1 = form.cleaned_data['input_file1'] instance = SkyLabFile.objects.create(type=1, file=input_file1, task=task) # filepath1 = create_input_skylab_file(task, 'input', input_file1) filepath1 = instance.file.name if parameter == "-p": input_file2 = form.cleaned_data['input_file2'] instance = SkyLabFile.objects.create(type=1, file=input_file2, task=task) # filepath2 = create_input_skylab_file(task, 'input', input_file2) filepath2 = instance.file.name command += "{0:s} {1:s} {2:s} ".format( parameter, filepath1, filepath2) elif parameter == "-s" or parameter == "-i": command += "{0:s} {1:s} ".format(parameter, filepath1) if other_parameter_form.cleaned_data['param_run_surveyor']: command += "-run-surveyor " if other_parameter_form.cleaned_data['param_read_sample_graph']: for index, f in other_parameter_form.cleaned_data[ 'subparam_graph_files']: instance = SkyLabFile.objects.create( type=1, upload_path='input/graph', file=f, task=task) filepath = instance.file.name # filepath = create_input_skylab_file(task, 'input/graph', f) command += "-read-sample-graph graph-{0:d} {1:s} ".format( index, filepath) if other_parameter_form.cleaned_data['param_search']: command += "-search task_{0:d}/input/search ".format(task.id) for f in other_parameter_form.cleaned_data[ 'subparam_search_files']: SkyLabFile.objects.create(type=1, upload_path='input/search', file=f, task=task) if other_parameter_form.cleaned_data['param_one_color_per_file']: command += "-one-color-per-file " if other_parameter_form.cleaned_data['param_with_taxonomy']: genome_to_taxon_file = other_parameter_form.cleaned_data[ 'subparam_genome_to_taxon_file'] tree_of_life_edges_file = other_parameter_form.cleaned_data[ 'subparam_tree_of_life_edges_file'] taxon_names_file = other_parameter_form.cleaned_data[ 'subparam_taxon_names_file'] instance = SkyLabFile.objects.create( type=1, upload_path='input/taxonomy', file=genome_to_taxon_file, task=task) genome_filepath = instance.file.name instance = SkyLabFile.objects.create( type=1, upload_path='input/taxonomy', file=tree_of_life_edges_file, task=task) tree_filepath = instance.file.name instance = SkyLabFile.objects.create( type=1, upload_path='input/taxonomy', file=taxon_names_file, task=task) taxon_filepath = instance.file.name command += "-with-taxonomy {0:s} {1:s} {2:s} ".format( genome_filepath, tree_filepath, taxon_filepath) if other_parameter_form.cleaned_data['param_gene_ontology']: annotations_file = other_parameter_form.cleaned_data[ 'subparam_annotations_file'] SkyLabFile.objects.create(type=1, upload_path='input/gene_ontology', file=annotations_file, task=task) command += "-gene-ontology task_{0:d}/input/OntologyTerms.txt {1:s} ".format( task.id, annotations_file.name) command_list.append( "wget -q -O task_{0:d}/input/OntologyTerms.txt http://geneontology.org/ontology/obo_format_1_2/gene_ontology_ext.obo" .format(task.id)) # Other Output options if other_parameter_form.cleaned_data[ 'param_enable_neighbourhoods']: command += "-enable-neighbourhoods " if other_parameter_form.cleaned_data['param_amos']: command += "-amos " if other_parameter_form.cleaned_data['param_write_kmers']: command += "-write-kmers " if other_parameter_form.cleaned_data['param_graph_only']: command += "-graph-only " if other_parameter_form.cleaned_data['param_write_read_markers']: command += "-write-read-markers " if other_parameter_form.cleaned_data['param_write_seeds']: command += "-write-seeds " if other_parameter_form.cleaned_data['param_write_extensions']: command += "-write-extensions " if other_parameter_form.cleaned_data['param_write_contig_paths']: command += "-write-contig-paths " if other_parameter_form.cleaned_data['param_write_marker_summary']: command += "-write-marker-summary " # Memory usage if other_parameter_form.cleaned_data['param_show_memory_usage']: command += "-show-memory-usage " if other_parameter_form.cleaned_data[ 'param_show_memory_allocations']: command += "-show-memory-allocations " # Algorithm verbosity if other_parameter_form.cleaned_data[ 'param_show_extension_choice']: command += "-show-extension-choice " if other_parameter_form.cleaned_data['param_show_ending_context']: command += "-show-ending-context " if other_parameter_form.cleaned_data[ "param_show_distance_summary"]: command += "-show-distance-summary " if other_parameter_form.cleaned_data['param_show_consensus']: command += "-show-consensus " command_list.append(command) task.task_data = json.dumps({'command_list': command_list}) task.save() send_to_queue( task=task) # send signal to queue this task to task queue return redirect('task_detail_view', pk=task.id) # return redirect(reverse('task_detailview', kwargs={'pk': task.id})) else: return render( request, 'modules/ray/use_ray.html', { 'form': select_mpi_form, 'other_parameter_form': other_parameter_form, 'input_formset': input_formset, 'tool': Tool.objects.get(simple_name="ray") })
def form_valid(self, form): # build command strings, create skylabfile for each file input cluster = form.cleaned_data['mpi_cluster'] # exec_string_template = "mkdir -p {outpath}; vina " #todo: test if runs properly exec_string_template = "vina " tool = Tool.objects.get(simple_name="vina") task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) instance = SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_receptor'], task=task) receptor_filepath = instance.file.name exec_string_template += u"--receptor {0:s} ".format(receptor_filepath) if form.cleaned_data.get('param_flex'): instance = SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_flex'], task=task) flex_filepath = instance.file.name exec_string_template += "--flex %s " % flex_filepath exec_string_template += "--ligand {filepath} --out {outpath}/vina_out.pdbqt --log {outpath}/log.txt " # if form.cleaned_data['param_score_only']: # search space not required # exec_string_template += "--score_only " # else: # search space required center_x = form.cleaned_data['param_center_x'] center_y = form.cleaned_data['param_center_y'] center_z = form.cleaned_data['param_center_z'] size_x = form.cleaned_data['param_size_x'] size_y = form.cleaned_data['param_size_y'] size_z = form.cleaned_data['param_size_z'] exec_string_template += "--center_x {0} --center_y {1} --center_z {2} --size_x {3} --size_y {4} --size_z {5} ".format( center_x, center_y, center_z, size_x, size_y, size_z) if form.cleaned_data.get('param_seed'): exec_string_template += "--seed {0} ".format(form.cleaned_data['param_seed']) if form.cleaned_data.get('param_exhaustiveness'): exec_string_template += "--exhaustiveness {0} ".format(form.cleaned_data['param_exhaustiveness']) if form.cleaned_data.get('param_num_modes'): exec_string_template += "--num_modes {0} ".format(form.cleaned_data['param_num_modes']) if form.cleaned_data.get('param_energy_range'): exec_string_template += "--energy_range {0} ".format(form.cleaned_data['param_energy_range']) # if form.cleaned_data['param_local_only']: # exec_string_template += "--local_only " # # if form.cleaned_data['param_randomize_only']: # exec_string_template += "--randomize_only " # # if form.cleaned_data.get('param_weight_gauss1'): # exec_string_template += "--weight_gauss1 {0:s} ".format(form.cleaned_data['param_weight_gauss1']) # # if form.cleaned_data.get('param_weight_gauss2'): # exec_string_template += "--weight_gauss2 {0:s} ".format(form.cleaned_data['param_weight_gauss2']) # # if form.cleaned_data.get('param_weight_repulsion'): # exec_string_template += "--weight_repulsion {0:s} ".format( # form.cleaned_data['param_weight_repulsion']) # # if form.cleaned_data.get('param_weight_hydrophobic'): # exec_string_template += "--weight_hydrophobic {0:s} ".format( # form.cleaned_data['param_weight_hydrophobic']) # # if form.cleaned_data.get('param_weight_hydrogen'): # exec_string_template += "--weight_hydrogen {0:s} ".format( # form.cleaned_data['param_weight_hydrogen']) # # if form.cleaned_data.get('param_weight_rot'): # exec_string_template += "--weight_rot {0:s} ".format(form.cleaned_data['param_weight_rot']) exec_string_template += "; " # build commands command_list = [] task_remote_subdirs = ['input', 'output'] for f in form.cleaned_data['param_ligands']: instance = SkyLabFile.objects.create(type=1, upload_path='input/ligands', file=f, task=task) filepath = instance.file.name # filepath = create_input_skylab_file(task, 'input/ligands', f) filename_without_ext = os.path.splitext(f.name)[0] task_remote_subdir = 'output/' + filename_without_ext outpath = os.path.join(task.task_dirname, task_remote_subdir) task_remote_subdirs.append(task_remote_subdir) command_list.append(exec_string_template.format(outpath=outpath, filepath=filepath)) task.task_data = json.dumps({'command_list': command_list, 'task_remote_subdirs': task_remote_subdirs}) task.save() send_to_queue(task=task) self.kwargs['task_id'] = task.id return super(VinaView, self).form_valid(form)
def post(self, request, *args, **kwargs): form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) if select_mpi_form.is_valid() and input_formset.is_valid(): # build command strings, create skylabfile for each file input cluster = select_mpi_form.cleaned_data['mpi_cluster'] # based on intial environment variables config on quantum espresso para_prefix = "mpirun -np {0:d} -f {1:s} ".format( cluster.total_node_count, settings.MPIEXEC_NODES_FILE) para_postfix = "-nk 1 -nd 1 -nb 1 -nt 1 " # copied from espresso's default env var value para_image_prefix = "mpirun -np 4" param_image_postfix = '-ni 2 {0}'.format(para_postfix) tool = Tool.objects.get(simple_name='quantumespresso') task = Task.objects.create(mpi_cluster=cluster, tool=tool, user=self.request.user) # build command list command_list = [] jsmol_output_files = [] # in form clean pseudopotentials field returns json dict task_data = json.loads( select_mpi_form.cleaned_data['param_pseudopotentials']) #location of quantum espresso executables remote_bin_dir = "/mirror/espresso-5.4.0/bin" for form in input_formset: executable = form.cleaned_data.get('param_executable', None) input_file = form.cleaned_data.get("param_input_file", None) if executable and input_file: # ignore blank parameter value instance = SkyLabFile.objects.create(type=1, file=input_file, task=task) # neb.x -inp filename.in # ph.x can be run using images #not supported output_filename = '{0}.out'.format( os.path.splitext(input_file.name)[0]) if executable == "neb.x": command_list.append( '{0} {1} {2} -inp input/{3} > output/{4}'.format( para_prefix, os.path.join(remote_bin_dir, executable), para_postfix, input_file.name, output_filename)) else: # at least for pw.x, cp.x command_list.append( '{0} {1} {2} < input/{3} > output/{4}'.format( para_prefix, os.path.join(remote_bin_dir, executable), para_postfix, input_file.name, output_filename)) if executable == "pw.x": #identify expected output as compatible for jsmol jsmol_output_files.append(output_filename) task_data['command_list'] = command_list task_data['jsmol_output_files'] = jsmol_output_files task.task_data = json.dumps(task_data) task.save() send_to_queue(task=task) # send signal to queue task to task queue return redirect('task_detail_view', pk=task.id) else: return render( request, 'modules/quantum espresso/use_quantum_espresso.html', { 'form': select_mpi_form, 'input_formset': input_formset, 'tool': Tool.objects.get(simple_name='quantumespresso'), })
def post(self, request, *args, **kwargs): form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) other_parameter_form = OtherParameterForm(request.POST, request.FILES) if select_mpi_form.is_valid() and other_parameter_form.is_valid() and input_formset.is_valid(): cluster = select_mpi_form.cleaned_data['mpi_cluster'] command_list = [] # -n cluster_size command = "mpiexec -n {0:d} -f {1:s} ".format(cluster.total_node_count, settings.MPIEXEC_NODES_FILE) # -bynode if select_mpi_form.cleaned_data['param_bynode']: command += "-bynode " tool = Tool.objects.get(simple_name="ray") task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) command += "Ray -o task_{0:d}/output ".format(task.id) # k-mer length if other_parameter_form.cleaned_data.get('param_kmer_length'): command += u"-k {0:d}".format(other_parameter_form.cleaned_data["param_kmer_length"]) # -mini-ranks-per-rank if select_mpi_form.cleaned_data.get('param_mini_ranks'): command += u"-mini-ranks-per-rank {0:d} ".format(select_mpi_form.cleaned_data["param_mini_ranks"]) for form in input_formset: parameter = form.cleaned_data.get('parameter') if parameter: # ignore blank parameter value input_file1 = form.cleaned_data['input_file1'] instance = SkyLabFile.objects.create(type=1, file=input_file1, task=task) # filepath1 = create_input_skylab_file(task, 'input', input_file1) filepath1 = instance.file.name if parameter == "-p": input_file2 = form.cleaned_data['input_file2'] instance = SkyLabFile.objects.create(type=1, file=input_file2, task=task) # filepath2 = create_input_skylab_file(task, 'input', input_file2) filepath2 = instance.file.name command += "{0:s} {1:s} {2:s} ".format(parameter, filepath1, filepath2) elif parameter == "-s" or parameter == "-i": command += "{0:s} {1:s} ".format(parameter, filepath1) if other_parameter_form.cleaned_data['param_run_surveyor']: command += "-run-surveyor " if other_parameter_form.cleaned_data['param_read_sample_graph']: for index, f in other_parameter_form.cleaned_data['subparam_graph_files']: instance = SkyLabFile.objects.create(type=1, upload_path='input/graph', file=f, task=task) filepath = instance.file.name # filepath = create_input_skylab_file(task, 'input/graph', f) command += "-read-sample-graph graph-{0:d} {1:s} ".format(index, filepath) if other_parameter_form.cleaned_data['param_search']: command += "-search task_{0:d}/input/search ".format(task.id) for f in other_parameter_form.cleaned_data['subparam_search_files']: SkyLabFile.objects.create(type=1, upload_path='input/search', file=f, task=task) if other_parameter_form.cleaned_data['param_one_color_per_file']: command += "-one-color-per-file " if other_parameter_form.cleaned_data['param_with_taxonomy']: genome_to_taxon_file = other_parameter_form.cleaned_data['subparam_genome_to_taxon_file'] tree_of_life_edges_file = other_parameter_form.cleaned_data['subparam_tree_of_life_edges_file'] taxon_names_file = other_parameter_form.cleaned_data['subparam_taxon_names_file'] instance = SkyLabFile.objects.create(type=1, upload_path='input/taxonomy', file=genome_to_taxon_file, task=task) genome_filepath = instance.file.name instance = SkyLabFile.objects.create(type=1, upload_path='input/taxonomy', file=tree_of_life_edges_file, task=task) tree_filepath = instance.file.name instance = SkyLabFile.objects.create(type=1, upload_path='input/taxonomy', file=taxon_names_file, task=task) taxon_filepath = instance.file.name command += "-with-taxonomy {0:s} {1:s} {2:s} ".format(genome_filepath, tree_filepath, taxon_filepath) if other_parameter_form.cleaned_data['param_gene_ontology']: annotations_file = other_parameter_form.cleaned_data['subparam_annotations_file'] SkyLabFile.objects.create(type=1, upload_path='input/gene_ontology', file=annotations_file, task=task) command += "-gene-ontology task_{0:d}/input/OntologyTerms.txt {1:s} ".format(task.id, annotations_file.name) command_list.append( "wget -q -O task_{0:d}/input/OntologyTerms.txt http://geneontology.org/ontology/obo_format_1_2/gene_ontology_ext.obo".format( task.id)) # Other Output options if other_parameter_form.cleaned_data['param_enable_neighbourhoods']: command += "-enable-neighbourhoods " if other_parameter_form.cleaned_data['param_amos']: command += "-amos " if other_parameter_form.cleaned_data['param_write_kmers']: command += "-write-kmers " if other_parameter_form.cleaned_data['param_graph_only']: command += "-graph-only " if other_parameter_form.cleaned_data['param_write_read_markers']: command += "-write-read-markers " if other_parameter_form.cleaned_data['param_write_seeds']: command += "-write-seeds " if other_parameter_form.cleaned_data['param_write_extensions']: command += "-write-extensions " if other_parameter_form.cleaned_data['param_write_contig_paths']: command += "-write-contig-paths " if other_parameter_form.cleaned_data['param_write_marker_summary']: command += "-write-marker-summary " # Memory usage if other_parameter_form.cleaned_data['param_show_memory_usage']: command += "-show-memory-usage " if other_parameter_form.cleaned_data['param_show_memory_allocations']: command += "-show-memory-allocations " # Algorithm verbosity if other_parameter_form.cleaned_data['param_show_extension_choice']: command += "-show-extension-choice " if other_parameter_form.cleaned_data['param_show_ending_context']: command += "-show-ending-context " if other_parameter_form.cleaned_data["param_show_distance_summary"]: command += "-show-distance-summary " if other_parameter_form.cleaned_data['param_show_consensus']: command += "-show-consensus " command_list.append(command) task.task_data = json.dumps({'command_list': command_list}) task.save() send_to_queue(task=task) return redirect('task_detail_view', pk=task.id) # return redirect(reverse('task_detailview', kwargs={'pk': task.id})) else: return render(request, 'modules/ray/use_ray.html', { 'form': select_mpi_form, 'other_parameter_form': other_parameter_form, 'input_formset': input_formset, 'tool':Tool.objects.get(simple_name="ray") })
def form_valid(self, form): cluster = form.cleaned_data['mpi_cluster'] # exec_string_template = "mkdir -p {outpath}; vina " #todo: test if runs properly exec_string_template = "vina " tool = Tool.objects.get(simple_name="vina") task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) instance = SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_receptor'], task=task) receptor_filepath = instance.file.name exec_string_template += u"--receptor {0:s} ".format(receptor_filepath) if form.cleaned_data.get('param_flex'): instance = SkyLabFile.objects.create(type=1, file=form.cleaned_data['param_flex'], task=task) flex_filepath = instance.file.name exec_string_template += "--flex %s " % flex_filepath exec_string_template += "--ligand {filepath} --out {outpath}/vina_out.pdbqt --log {outpath}/log.txt " # if form.cleaned_data['param_score_only']: # search space not required # exec_string_template += "--score_only " # else: # search space required center_x = form.cleaned_data['param_center_x'] center_y = form.cleaned_data['param_center_y'] center_z = form.cleaned_data['param_center_z'] size_x = form.cleaned_data['param_size_x'] size_y = form.cleaned_data['param_size_y'] size_z = form.cleaned_data['param_size_z'] exec_string_template += "--center_x {0} --center_y {1} --center_z {2} --size_x {3} --size_y {4} --size_z {5} ".format( center_x, center_y, center_z, size_x, size_y, size_z) if form.cleaned_data.get('param_seed'): exec_string_template += "--seed {0} ".format(form.cleaned_data['param_seed']) if form.cleaned_data.get('param_exhaustiveness'): exec_string_template += "--exhaustiveness {0} ".format(form.cleaned_data['param_exhaustiveness']) if form.cleaned_data.get('param_num_modes'): exec_string_template += "--num_modes {0} ".format(form.cleaned_data['param_num_modes']) if form.cleaned_data.get('param_energy_range'): exec_string_template += "--energy_range {0} ".format(form.cleaned_data['param_energy_range']) # if form.cleaned_data['param_local_only']: # exec_string_template += "--local_only " # # if form.cleaned_data['param_randomize_only']: # exec_string_template += "--randomize_only " # # if form.cleaned_data.get('param_weight_gauss1'): # exec_string_template += "--weight_gauss1 {0:s} ".format(form.cleaned_data['param_weight_gauss1']) # # if form.cleaned_data.get('param_weight_gauss2'): # exec_string_template += "--weight_gauss2 {0:s} ".format(form.cleaned_data['param_weight_gauss2']) # # if form.cleaned_data.get('param_weight_repulsion'): # exec_string_template += "--weight_repulsion {0:s} ".format( # form.cleaned_data['param_weight_repulsion']) # # if form.cleaned_data.get('param_weight_hydrophobic'): # exec_string_template += "--weight_hydrophobic {0:s} ".format( # form.cleaned_data['param_weight_hydrophobic']) # # if form.cleaned_data.get('param_weight_hydrogen'): # exec_string_template += "--weight_hydrogen {0:s} ".format( # form.cleaned_data['param_weight_hydrogen']) # # if form.cleaned_data.get('param_weight_rot'): # exec_string_template += "--weight_rot {0:s} ".format(form.cleaned_data['param_weight_rot']) exec_string_template += "; " # build commands command_list = [] task_remote_subdirs = ['input', 'output'] for f in form.cleaned_data['param_ligands']: instance = SkyLabFile.objects.create(type=1, upload_path='input/ligands', file=f, task=task) filepath = instance.file.name # filepath = create_input_skylab_file(task, 'input/ligands', f) filename_without_ext = os.path.splitext(f.name)[0] task_remote_subdir = 'output/' + filename_without_ext outpath = os.path.join(task.task_dirname, task_remote_subdir) task_remote_subdirs.append(task_remote_subdir) command_list.append(exec_string_template.format(outpath=outpath, filepath=filepath)) task.task_data = json.dumps({'command_list': command_list, 'task_remote_subdirs': task_remote_subdirs}) task.save() send_to_queue(task=task) self.kwargs['task_id'] = task.id return super(VinaView, self).form_valid(form)
def post(self, request, *args, **kwargs): form_class = self.get_form_class() select_mpi_form = self.get_form(form_class) input_formset = self.input_formset(request.POST, request.FILES) if select_mpi_form.is_valid() and input_formset.is_valid(): # do something with the cleaned_data on the formsets. # print select_mpi_form.cleaned_data.get('mpi_cluster') cluster = select_mpi_form.cleaned_data['mpi_cluster'] # based on intial environment variables config on quantum espresso para_prefix = "mpirun -np {0:d} -f {1:s} ".format(cluster.total_node_count, settings.MPIEXEC_NODES_FILE) para_postfix = "-nk 1 -nd 1 -nb 1 -nt 1 " # copied from espresso's default env var value para_image_prefix = "mpirun -np 4" param_image_postfix = '-ni 2 {0}'.format(para_postfix) tool = Tool.objects.get(simple_name='quantumespresso') task = Task.objects.create( mpi_cluster=cluster, tool=tool, user=self.request.user ) # build command list command_list = [] jsmol_output_files = [] # in form clean pseudopotentials field returns json dict task_data = json.loads(select_mpi_form.cleaned_data['param_pseudopotentials']) #location of quantum espresso executables remote_bin_dir = "/mirror/espresso-5.4.0/bin" for form in input_formset: executable = form.cleaned_data.get('param_executable', None) input_file = form.cleaned_data.get("param_input_file", None) if executable and input_file: # ignore blank parameter value instance = SkyLabFile.objects.create(type=1, file=input_file, task=task) # neb.x -inp filename.in # ph.x can be run using images #not supported output_filename = '{0}.out'.format(os.path.splitext(input_file.name)[0]) if executable == "neb.x": command_list.append( '{0} {1} {2} -inp input/{3} > output/{4}'.format(para_prefix, os.path.join(remote_bin_dir,executable), para_postfix, input_file.name, output_filename) ) else: # at least for pw.x, cp.x command_list.append('{0} {1} {2} < input/{3} > output/{4}'.format( para_prefix, os.path.join(remote_bin_dir,executable), para_postfix, input_file.name, output_filename) ) if executable == "pw.x": #identify expected output as compatible for jsmol jsmol_output_files.append(output_filename) task_data['command_list'] = command_list task_data['jsmol_output_files'] = jsmol_output_files task.task_data = json.dumps(task_data) task.save() send_to_queue(task=task) return redirect('task_detail_view', pk=task.id) else: return render(request, 'modules/quantum espresso/use_quantum_espresso.html', { 'form': select_mpi_form, 'input_formset': input_formset, 'tool': Tool.objects.get(simple_name='quantumespresso'), })