def test_run_cat1(self): history_id = self.gi.histories.create_history( name="test_run_cat1 history")["id"] dataset1_id = self._test_dataset(history_id, contents="1 2 3") dataset2_id = self._test_dataset(history_id, contents="4 5 6") dataset3_id = self._test_dataset(history_id, contents="7 8 9") tool_inputs = inputs().set("input1", dataset(dataset1_id)).set( "queries", repeat().instance(inputs().set( "input2", dataset(dataset2_id))).instance(inputs().set( "input2", dataset(dataset3_id)))) tool_output = self.gi.tools.run_tool(history_id=history_id, tool_id="cat1", tool_inputs=tool_inputs) self.assertEqual(len(tool_output["outputs"]), 1)
def test_run_cat1(self): history_id = self.gi.histories.create_history(name="test_run_cat1 history")["id"] dataset1_id = self._test_dataset(history_id, contents="1 2 3") dataset2_id = self._test_dataset(history_id, contents="4 5 6") dataset3_id = self._test_dataset(history_id, contents="7 8 9") tool_inputs = ( inputs() .set("input1", dataset(dataset1_id)) .set( "queries", repeat() .instance(inputs().set("input2", dataset(dataset2_id))) .instance(inputs().set("input2", dataset(dataset3_id))), ) ) tool_output = self.gi.tools.run_tool(history_id=history_id, tool_id="cat1", tool_inputs=tool_inputs) self.assertEqual(len(tool_output["outputs"]), 1)
def test_wait_for_job(self): tool_inputs = inputs().set("input1", dataset(self.dataset_id)) tool_output = self.gi.tools.run_tool(history_id=self.history_id, tool_id="cat1", tool_inputs=tool_inputs) job_id = tool_output['jobs'][0]['id'] job = self.gi.jobs.wait_for_job(job_id) self.assertEqual(job['state'], 'ok')
def test_conditional(): # Build up example inputs for random_lines1 as_dict = inputs().set("num_lines", 5).set( "input", dataset("encoded1")).set( "seed_source", conditional().set("seed_source_selector", "set_seed").set("seed", "asdf")).to_dict() assert as_dict["num_lines"] == 5 assert as_dict["input"]["src"] == "hda" assert as_dict["input"]["id"] == "encoded1" assert as_dict["seed_source|seed_source_selector"] == "set_seed" assert as_dict["seed_source|seed"] == "asdf"
def test_repeat(): # Build up inputs for cat1 as_dict = inputs().set("input1", dataset("encoded1")).set( "queries", repeat().instance(inputs().set_dataset_param( "input2", "encoded2")).instance(inputs().set_dataset_param( "input2", "encoded3"))).to_dict() assert as_dict["input1"]["src"] == "hda" assert as_dict["input1"]["id"] == "encoded1" assert as_dict["queries_0|input2"]["src"] == "hda" assert as_dict["queries_0|input2"]["id"] == "encoded2" assert as_dict["queries_1|input2"]["src"] == "hda" assert as_dict["queries_1|input2"]["id"] == "encoded3"
def test_run_random_lines(self): # Run second test case from randomlines.xml history_id = self.gi.histories.create_history(name="test_run_random_lines history")["id"] with open(get_abspath(os.path.join("data", "1.bed"))) as f: contents = f.read() dataset_id = self._test_dataset(history_id, contents=contents) tool_inputs = ( inputs() .set("num_lines", "1") .set("input", dataset(dataset_id)) .set("seed_source", conditional().set("seed_source_selector", "set_seed").set("seed", "asdf")) ) tool_output = self.gi.tools.run_tool(history_id=history_id, tool_id="random_lines1", tool_inputs=tool_inputs) self.assertEqual(len(tool_output["outputs"]), 1)
def export_output(request, project, gi, file_id, tool_id="export_sbw"): """Export data in galaxy MetaGenSense output directory""" """add the name of project on file name""" data = gi.datasets.show_dataset(dataset_id=file_id) hist_id = data['history_id'] myinputs = inputs().set("prefix", project).set("input", dataset(file_id)) tool_outputs = gi.tools.run_tool(history_id=hist_id, tool_id=tool_id, tool_inputs=myinputs) if tool_outputs: messages.warning(request, "Export is in progress, your file will be available: " + project + '_' + data['name']) return redirect('galaxy_history_detail', history_id=hist_id)
def test_run_random_lines(self): # Run second test case from randomlines.xml history_id = self.gi.histories.create_history( name="test_run_random_lines history")["id"] with open(test_util.get_abspath(os.path.join("data", "1.bed"))) as f: contents = f.read() dataset_id = self._test_dataset(history_id, contents=contents) tool_inputs = inputs().set("num_lines", "1").set( "input", dataset(dataset_id)).set( "seed_source", conditional().set("seed_source_selector", "set_seed").set("seed", "asdf")) tool_output = self.gi.tools.run_tool(history_id=history_id, tool_id="random_lines1", tool_inputs=tool_inputs) self.assertEqual(len(tool_output["outputs"]), 1)
def test_repeat(): # Build up inputs for cat1 as_dict = inputs().set( "input1", dataset("encoded1") ).set( "queries", repeat().instance( inputs().set_dataset_param("input2", "encoded2") ).instance( inputs().set_dataset_param("input2", "encoded3") ) ).to_dict() assert as_dict["input1"]["src"] == "hda" assert as_dict["input1"]["id"] == "encoded1" assert as_dict["queries_0|input2"]["src"] == "hda" assert as_dict["queries_0|input2"]["id"] == "encoded2" assert as_dict["queries_1|input2"]["src"] == "hda" assert as_dict["queries_1|input2"]["id"] == "encoded3"
def test_conditional(): # Build up example inputs for random_lines1 as_dict = inputs().set( "num_lines", 5 ).set( "input", dataset("encoded1") ).set( "seed_source", conditional().set( "seed_source_selector", "set_seed" ).set( "seed", "asdf" ) ).to_dict() assert as_dict["num_lines"] == 5 assert as_dict["input"]["src"] == "hda" assert as_dict["input"]["id"] == "encoded1" assert as_dict["seed_source|seed_source_selector"] == "set_seed" assert as_dict["seed_source|seed"] == "asdf"
def create_run_definition(dataset_id, tool_dict): '''define jobs for galaxy''' filtering_runs = [{ 'tool': tool_dict['paired_fastq_filtering'], 'inputs': OrderedDict([('A', dataset(dataset_id['fq1'])), ('B', dataset(dataset_id['fq2']))]) }, { 'tool': tool_dict['paired_fastq_filtering'], 'inputs': OrderedDict([('A', dataset(dataset_id['fq1'])), ('B', dataset(dataset_id['fq2'])), ('sampling', conditional().set('sequence_sampling', 'true').set('sample_size', 500))]) }, { 'tool': tool_dict['single_fastq_filtering'], 'inputs': OrderedDict([('A', dataset(dataset_id['fq1'])), ('sampling', conditional().set('sequence_sampling', 'true').set('sample_size', 500))]) }] affixer_runs = [{ 'tool': tool_dict['fasta_affixer'], 'inputs': OrderedDict([('input', dataset(dataset_id['input_fasta'])), ('prefix', "PREFIX"), ('suffix', 'SUFFIX')]) }, { 'tool': tool_dict['names_affixer'], 'inputs': OrderedDict([('input', dataset(dataset_id['fq1'])), ('prefix', "PREFIX"), ('suffix', 'SUFFIX')]) }] various_utils = [{ 'tool': tool_dict['sampler'], 'inputs': OrderedDict([('input', dataset(dataset_id['input_fasta'])), ('number', 500)]) }, { 'tool': tool_dict['fasta_interlacer'], 'inputs': OrderedDict([('A', dataset(dataset_id['fastaA'])), ('B', dataset(dataset_id['fastaB']))]) }, { 'tool': tool_dict['rename_sequences'], 'inputs': OrderedDict([('input', dataset(dataset_id['fastaA'])), ('prefix_length', 3)]) }, { 'tool': tool_dict['chip_seq_ratio'], 'inputs': OrderedDict([('ChipFile', dataset(dataset_id['chip_fasta'])), ('InputFile', dataset(dataset_id['input_fasta'])), ('ContigFile', dataset(dataset_id['clustering_contigs'])) ]) }, { 'tool': tool_dict['pair_scan'], 'inputs': OrderedDict([('fasta_input', dataset(dataset_id['interlaced_fasta']))]) }] dante_runs = [{ 'tool': tool_dict['dante'], 'inputs': OrderedDict([('input_type', conditional().set( 'input_type_selector', 'fasta').set('input_sequences', dataset(dataset_id['gepy_genome'])))]) }, { 'tool': tool_dict['dante'], 'inputs': OrderedDict([ ('input_type', conditional().set('input_type_selector', 'aln').set('input_sequences', dataset(dataset_id['aln_contigs']))) ]) }, { 'tool': tool_dict['domain_filter'], 'inputs': OrderedDict([('DomGff', dataset(dataset_id['gff_dante']))]) }, { 'tool': tool_dict['gff_to_tabular'], 'inputs': OrderedDict([('inputgff', dataset(dataset_id['gff_dante']))]) }, { 'tool': tool_dict['gff_extract'], 'inputs': OrderedDict([('input_dna', dataset(dataset_id['gepy_genome'])), ('domains_gff', dataset(dataset_id['gff_dante']))]) }, { 'tool': tool_dict['gff_summary'], 'inputs': OrderedDict([('group', "Name"), ('inputgff', dataset(dataset_id['gff_dante']))]) }] repex_runs = [{ 'tool': tool_dict['repeatexplorer2'], 'inputs': OrderedDict([('FastaFile', dataset(dataset_id['LAS_interlaced_fasta'])) ]) }, { 'tool': tool_dict['tarean'], 'inputs': OrderedDict([('FastaFile', dataset(dataset_id['LAS_interlaced_fasta'])) ]) }] runs = affixer_runs + filtering_runs + dante_runs + various_utils + repex_runs return runs