Skip to content

Commit

Permalink
Test cases for renaming datasets based on tool input datasets.
Browse files Browse the repository at this point in the history
Includes test cases for galaxyproject#3197 and galaxyproject#662.
  • Loading branch information
jmchilton committed Jan 5, 2017
1 parent f854a8b commit d9ffbc4
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 1 deletion.
107 changes: 106 additions & 1 deletion test/api/test_workflows.py
Expand Up @@ -214,7 +214,14 @@ def read_test_data(test_dict):
input_type = value["type"]
if input_type == "File":
content = read_test_data(value)
hda = self.dataset_populator.new_dataset( history_id, content=content )
new_dataset_kwds = {
"content": content
}
if "name" in value:
new_dataset_kwds["name"] = value["name"]
if "file_type" in value:
new_dataset_kwds["file_type"] = value["file_type"]
hda = self.dataset_populator.new_dataset( history_id, **new_dataset_kwds )
label_map[key] = self._ds_entry( hda )
has_uploads = True
elif input_type == "raw":
Expand Down Expand Up @@ -1251,6 +1258,104 @@ def test_run_with_pja( self ):
content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True )
assert content[ "name" ] == "foo was replaced"

@skip_without_tool( "cat" )
def test_run_rename_based_on_input( self ):
history_id = self.dataset_populator.new_history()
self._run_jobs("""
class: GalaxyWorkflow
inputs:
- id: input1
steps:
- tool_id: cat
label: first_cat
state:
input1:
$link: input1
outputs:
out_file1:
rename: "#{input1 | basename} suffix"
test_data:
input1:
value: 1.fasta
type: File
name: fasta1
""", history_id=history_id)
content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True )
name = content[ "name" ]
assert name == "fasta1 suffix", name

@skip_without_tool( "cat" )
def test_run_rename_based_on_input_repeat( self ):
history_id = self.dataset_populator.new_history()
self._run_jobs("""
class: GalaxyWorkflow
inputs:
- id: input1
- id: input2
steps:
- tool_id: cat
label: first_cat
state:
input1:
$link: input1
queries:
- input2:
$link: input2
outputs:
out_file1:
rename: "#{queries_0.input2| basename} suffix"
test_data:
input1:
value: 1.fasta
type: File
name: fasta1
input2:
value: 1.fasta
type: File
name: fasta2
""", history_id=history_id)
content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True )
name = content[ "name" ]
assert name == "fasta2 suffix", name

@skip_without_tool( "mapper2" )
def test_run_rename_based_on_input_conditional( self ):
history_id = self.dataset_populator.new_history()
self._run_jobs("""
class: GalaxyWorkflow
inputs:
- id: fasta_input
- id: fastq_input
steps:
- tool_id: mapper2
state:
fastq_input:
fastq_input_selector: single
fastq_input1:
$link: fastq_input
reference:
$link: fasta_input
outputs:
out_file1:
# Wish it was qualified for conditionals but it doesn't seem to be. -John
# rename: "#{fastq_input.fastq_input1 | basename} suffix"
rename: "#{fastq_input1 | basename} suffix"
test_data:
fasta_input:
value: 1.fasta
type: File
name: fasta1
file_type: fasta
fastq_input:
value: 1.fastqsanger
type: File
name: fastq1
file_type: fastqsanger
""", history_id=history_id)
content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True )
name = content[ "name" ]
assert name == "fastq1 suffix", name

@skip_without_tool( "cat1" )
def test_run_with_runtime_pja( self ):
workflow = self.workflow_populator.load_workflow( name="test_for_pja_runtime" )
Expand Down
33 changes: 33 additions & 0 deletions test/functional/tools/for_workflows/mapper2.xml
@@ -0,0 +1,33 @@
<tool id="mapper2" name="mapper2" version="0.1.0">
<command>
cp $__tool_directory__/1.bam $out_file1
</command>
<inputs>
<!-- Conditional input block from bwa-mem. -->
<conditional name="fastq_input">
<param name="fastq_input_selector" type="select" label="Single or Paired-end reads">
<option value="paired">Paired</option>
<option value="single">Single</option>
<option value="paired_collection">Paired Collection</option>
<option value="paired_iv">Paired Interleaved</option>
</param>
<when value="paired">
<param name="fastq_input1" type="data" format="fastqsanger" label="Select first set of reads" />
<param name="fastq_input2" type="data" format="fastqsanger" label="Select second set of reads" />
</when>
<when value="single">
<param name="fastq_input1" type="data" format="fastqsanger" label="Select fastq dataset"/>
</when>
<when value="paired_collection">
<param name="fastq_input1" format="fastqsanger" type="data_collection" collection_type="paired" label="Select a paired collection" />
</when>
<when value="paired_iv">
<param name="fastq_input1" type="data" format="fastqsanger" label="Select fastq dataset" />
</when>
</conditional>
<param name="reference" type="data" format="fasta" label="Fasta Input"/>
</inputs>
<outputs>
<data name="out_file1" format="bam" />
</outputs>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Expand Up @@ -114,6 +114,7 @@
<tool file="for_workflows/cat_interleave.xml" />
<tool file="for_workflows/pileup.xml" />
<tool file="for_workflows/mapper.xml" />
<tool file="for_workflows/mapper2.xml" />
<tool file="for_workflows/split.xml" />
<tool file="for_workflows/create_input_collection.xml" />

Expand Down

0 comments on commit d9ffbc4

Please sign in to comment.