Skip to content

Commit

Permalink
Merge pull request galaxyproject#2 from wm75/simplify-further
Browse files Browse the repository at this point in the history
Simplify further
  • Loading branch information
drosofff authored Jan 31, 2024
2 parents 49ea1b8 + 09de84c commit 263d1e2
Show file tree
Hide file tree
Showing 3 changed files with 1,746 additions and 51 deletions.
98 changes: 47 additions & 51 deletions tools/htseq_count/htseq-count.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
</requirements>

<stdio>
<exit_code range="1:" level="fatal" description="Unknown error occurred" />
<exit_code range="1:" level="fatal" />
<regex match="htseq-count: (command ){0,1}not found" source="stderr" level="fatal" description="The HTSeq python package is not properly installed, contact Galaxy administrators" />
<regex match="samtools: (command ){0,1}not found" source="stderr" level="fatal" description="The samtools package is not properly installed, contact Galaxy administrators" />
<regex match="Error: Feature (.+) does not contain a '(.+)' attribute" source="both" level="fatal" description="Error parsing the GFF file, at least one feature of the specified 'Feature type' does not have a value for the specified 'ID Attribute'" />
<regex match="Error occured in line (\d+) of file" source="stderr" level="fatal" description="Unknown error parsing the GFF file" />
<regex match="no SQ lines present" source="stderr" level="fatal" description="Input SAM dataset is missing header or SQ header lines. Please provide a FASTA reference sequence as additional input." />
<regex match="Error" source="stderr" level="fatal" description="Unknown error occured" />
</stdio>

Expand All @@ -30,20 +31,18 @@
##set up input files
#set $name_sorted_alignment_filename = "name_sorted.bam"
#set $ref_index = "ref.fai"
#if str( $advanced_options.advanced_options_selector ) == "advanced":
#if str( $advanced_options.samout_conditional.samout ) == "Yes":
#if str( $advanced_options.samout_conditional.reference_source.reference_source_selector ) == "history":
samtools faidx --fai-idx $ref_index '${advanced_options.samout_conditional.reference_source.ref_file}' 2>&1 || echo "Error running samtools faidx for htseq-count" >&2 &&
#else:
ln -s '${advanced_options.samout_conditional.reference_source.ref_file.fields.path}.fai' $ref_index
#end if
#if $samfile.extension == 'sam':
#if str($reference_source.reference_source_selector) == "history":
samtools faidx --fai-idx $ref_index '${reference_source.ref_file}' 2>&1 || echo "Error running samtools faidx for htseq-count" >&2 &&
#elif str($reference_source.reference_source_selector) == "cached":
ln -s '${reference_source.ref_file.fields.path}.fai' $ref_index
#end if
#end if
#if $samfile.extension == 'bam':
samtools sort -n -T "\${TMPDIR:-.}" -o $name_sorted_alignment_filename '$samfile' &&
#if $samfile.extension == 'sam' and str($reference_source.reference_source_selector):
samtools view -u -t $ref_index '$samfile' | samtools sort -n -T "\${TMPDIR:-.}" -o $name_sorted_alignment_filename - &&
#else:
samtools view -Su -t $ref_index '$samfile' | samtools sort -n -T "\${TMPDIR:-.}" -o $name_sorted_alignment_filename - &&
samtools sort -n -T "\${TMPDIR:-.}" -o $name_sorted_alignment_filename '$samfile' &&
#end if
#if $gfffile.is_of_type('gtf'):
Expand All @@ -66,8 +65,8 @@
--nonunique=$advanced_options.nonunique
--secondary-alignments=${advanced_options.secondary_alignments}
--supplementary-alignments=${advanced_options.supplementary_alignments}
#if $advanced_options.samout_conditional.samout == "Yes":
--samout=samout.sam
#if $advanced_options.samout:
-o samout.sam
#end if
#end if
Expand All @@ -83,11 +82,8 @@
echo -e "__aligned\t\$(cut -f2 xx00 | awk '{s+=$1}END{print s}' -)" >> xx01
#if str( $advanced_options.advanced_options_selector ) == "advanced":
#if $advanced_options.samout_conditional.samout == "Yes":
&& samtools view -Su
-t $ref_index
samout.sam
| samtools sort -T "\${TMPDIR:-.}" -o out.bam -
#if $advanced_options.samout:
&& samtools sort -T "\${TMPDIR:-.}" -o out.bam samout.sam
#end if
#end if
]]>
Expand Down Expand Up @@ -132,33 +128,26 @@
</param>
<param argument="--secondary-alignments" type="boolean" truevalue="ignore" falsevalue="score" checked="false" label="Ignore seconday alignments (0x100 flag)" />
<param argument="--supplementary-alignments" type="boolean" truevalue="ignore" falsevalue="score" checked="false" label="Ignore supplementary alignments (0x800 flag)" />
<conditional name="samout_conditional">
<param name="samout" type="select" label="Additional BAM Output">
<help>Write out all SAM alignment records into an output BAM file, annotating each line with its assignment to a feature or a special counter (as an optional field with tag ‘XF’).</help>
<option value="No" selected="True">Do not output additional BAM file</option>
<option value="Yes">Output additional BAM file</option>
</param>
<when value="Yes">
<conditional name="reference_source">
<param name="reference_source_selector" type="select" label="Choose the source for the reference list">
<option value="cached">Locally cached</option>
<option value="history">History</option>
</param>
<when value="cached">
<param name="ref_file" type="select" label="Using reference genome">
<options from_data_table="sam_fa_indexes">
<filter type="data_meta" key="dbkey" ref="samfile" column="value"/>
</options>
<validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
</param>
</when>
<when value="history">
<param name="ref_file" type="data" format="fasta" label="Using reference file" />
</when>
</conditional>
</when>
<when value="No" />
</conditional>
<param argument="--samout" type="boolean" label="Additional BAM Output" help="Write out all SAM alignment records into an output BAM file, annotating each line with its assignment to a feature or a special counter (as an optional field with tag ‘XF’)." />
</when>
</conditional>
<conditional name="reference_source">
<param name="reference_source_selector" type="select" label="Provide a reference sequence?" help="Required for SAM input without @SQ headers, not necessary otherwise and ignored for BAM input.">
<option value="">No</option>
<option value="cached">Locally cached</option>
<option value="history">History</option>
</param>
<when value="" />
<when value="cached">
<param name="ref_file" type="select" label="Using reference genome">
<options from_data_table="sam_fa_indexes">
<filter type="data_meta" key="dbkey" ref="samfile" column="value"/>
</options>
<validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
</param>
</when>
<when value="history">
<param name="ref_file" type="data" format="fasta" label="Using reference file" />
</when>
</conditional>
</inputs>
Expand All @@ -175,7 +164,7 @@
</actions>
</data>
<data name="samoutfile" format="bam" metadata_source="samfile" from_work_dir="out.bam" label="${tool.name} on ${on_string} (BAM)">
<filter>advanced_options['advanced_options_selector'] == 'advanced' and advanced_options['samout_conditional']['samout'] == "Yes"</filter>
<filter>advanced_options['advanced_options_selector'] == 'advanced' and advanced_options['samout']</filter>
</data>
</outputs>

Expand All @@ -193,6 +182,15 @@
<output name="counts" file="htseq-test_counts.tsv" />
<output name="allcounts" file="htseq-test_allcounts.tsv" />
</test>
<test expect_num_outputs="2">
<!-- test SAM with no SQ lines and FASTA reference -->
<param name="samfile" value="htseq-test_nosq.sam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="reference_source_selector" value="history" />
<param name="ref_file" value="htseq-test_reference.fasta" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="allcounts" file="htseq-test_allcounts.tsv" />
</test>
<test expect_num_outputs="2">
<param name="samfile" value="htseq-test.bam" />
<param name="gfffile" value="htseq-test.gff" />
Expand All @@ -208,20 +206,18 @@
<test expect_num_outputs="2">
<param name="samfile" value="htseq-test-paired.bam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<param name="samout" value="true" />
<output name="counts" file="htseq-test-paired_counts.tsv" />
<output name="allcounts" file="htseq-test-paired_allcounts.tsv" />
</test>
<test expect_num_outputs="3">
<param name="samfile" value="htseq-test.sam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="advanced_options_selector" value="advanced" />
<param name="samout" value="Yes" />
<param name="reference_source_selector" value="history" />
<param name="ref_file" value="htseq-test_reference.fasta" />
<param name="samout" value="true" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="allcounts" file="htseq-test_allcounts.tsv" />
<output name="samoutfile" file="htseq-test_samout.bam" ftype="bam" compare="diff" lines_diff="6" />
<output name="samoutfile" file="htseq-test_samout.bam" ftype="bam" compare="diff" lines_diff="4" />
</test>
<test expect_num_outputs="2">
<param name="samfile" value="htseq-test.sam" />
Expand Down
Loading

0 comments on commit 263d1e2

Please sign in to comment.