Mercurial > repos > lparsons > htseq_count
diff htseq-count.xml @ 29:4418229c501e draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/htseq_count commit 86a6c88d482d19bb7105fb17b933e19cd1e86ece
author | iuc |
---|---|
date | Wed, 31 Jan 2024 12:51:03 +0000 |
parents | 916cb26bd9d3 |
children |
line wrap: on
line diff
--- a/htseq-count.xml Sun Jan 26 23:43:52 2020 -0500 +++ b/htseq-count.xml Wed Jan 31 12:51:03 2024 +0000 @@ -1,40 +1,57 @@ -<tool id="htseq_count" name="htseq-count" version="0.9.1+galaxy1" profile="16.04"> +<tool id="htseq_count" name="htseq-count" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> <description> - Count aligned reads in a BAM file that overlap features in a GFF file</description> + <macros> + <token name="@TOOL_VERSION@">2.0.5</token> + <token name="@VERSION_SUFFIX@">0</token> + <token name="@PROFILE@">23.0</token> + </macros> + <xrefs> + <xref type="bio.tools">htseq</xref> + </xrefs> <requirements> - <requirement type="package" version="0.9.1">htseq</requirement> - <requirement type="package" version="1.7">samtools</requirement> + <requirement type="package" version="@TOOL_VERSION@">htseq</requirement> + <requirement type="package" version="1.19.2">samtools</requirement> + <requirement type="package" version="5.3.0">gawk</requirement> + <requirement type="package" version="9.4">coreutils</requirement> </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> - <version_command>htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/'</version_command> + <version_command>htseq-count --version</version_command> <command><![CDATA[ ##set up input files - #set $reference_fasta_filename = "localref.fa" - #set $name_sorted_alignment_filename = "name_sorted_alignment.sam" - #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": - ln -s "${advanced_options.samout_conditional.reference_source.ref_file}" "${reference_fasta_filename}" && - samtools faidx '${reference_fasta_filename}' 2>&1 || echo "Error running samtools faidx for htseq-count" >&2 && - #else: - #set $reference_fasta_filename = str( $advanced_options.samout_conditional.reference_source.ref_file.fields.path ) - #end if + #set $name_sorted_alignment_filename = "name_sorted.bam" + #set $ref_index = "ref.fai" + #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:-.}" --output-fmt=SAM -o '$name_sorted_alignment_filename' '$samfile' && - #else - samtools view -Su -t '${reference_fasta_filename}.fai' '$samfile' | samtools sort -n -T "\${TMPDIR:-.}" --output-fmt=SAM -o '$name_sorted_alignment_filename' - && + #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 sort -n -T "\${TMPDIR:-.}" -o $name_sorted_alignment_filename '$samfile' && + #end if + + #if $gfffile.is_of_type('gtf'): + ## htseq-count requires .gtf suffix to recognize GTF-formatted feature files + ## and to handle textual attributes should surrounded by doublequotes correctly + #set $genomic_features = 'features.gtf' + ln -s '$gfffile' $genomic_features && + #else: + #set $genomic_features = $gfffile #end if htseq-count @@ -48,40 +65,39 @@ --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 --order=name - --format=sam - '$name_sorted_alignment_filename' + $name_sorted_alignment_filename + + '$genomic_features' | csplit -q - /^__/ && - "$gfffile" | awk '{if ($1 ~ "no_feature|ambiguous|too_low_aQual|not_aligned|alignment_not_unique") print $0 | "cat 1>&2"; else print $0}' - > '$counts' - 2> '$othercounts' + ## csplit above creates two files, + ## xx00 with the feature counts and xx01 with category counts. + ## Now we calculate the sum over all feature counts in xx00 and append that + ## sum as the __aligned count to xx01. + 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 '${reference_fasta_filename}.fai' - samout.sam - | samtools sort -T "\${TMPDIR:-.}" -o '$samoutfile' - + #if $advanced_options.samout: + && samtools sort -T "\${TMPDIR:-.}" -o out.bam samout.sam #end if #end if ]]> </command> - <inputs> <param format="sam,bam" name="samfile" type="data" label="Aligned SAM/BAM File"/> - <param format="gff" name="gfffile" type="data" label="GFF File"/> - <param name="mode" type="select" label="Mode" argument="--mode"> + <param format="gff" name="gfffile" type="data" label="GFF/GTF File"/> + <param type="select" label="Mode" argument="--mode"> <help>Mode to handle reads overlapping more than one feature.</help> <option value="union" selected="True">Union</option> <option value="intersection-strict">Intersection (strict)</option> <option value="intersection-nonempty">Intersection (nonempty)</option> </param> - <param name="stranded" type="select" label="Stranded" argument="--stranded"> + <param type="select" label="Stranded" argument="--stranded"> <help>Specify whether the data is from a strand-specific assay. **Be sure to choose the correct value** (see help for more information).</help> @@ -89,13 +105,13 @@ <option value="no">No</option> <option value="reverse">Reverse</option> </param> - <param name="minaqual" type="integer" value="10" label="Minimum alignment quality" argument="--minaqual"> + <param type="integer" value="10" label="Minimum alignment quality" argument="--minaqual"> <help>Skip all reads with alignment quality lower than the given minimum value.</help> </param> <param name="featuretype" type="text" value="exon" label="Feature type" argument="--type"> <help>Feature type (3rd column in GFF file) to be used. All features of other types are ignored. The default, suitable for RNA-Seq and Ensembl GTF files, is exon.</help> </param> - <param name="idattr" type="text" value="gene_id" label="ID Attribute" argument="--idattr"> + <param type="text" value="gene_id" label="ID Attribute" argument="--idattr"> <help>GFF attribute to be used as feature ID. Several GFF lines with the same feature ID will be considered as parts of the same feature. The feature ID is used to identity the counts in the output table. All features of the specified type MUST have a value for this attribute. The default, suitable for RNA-Seq and Ensembl GTF files, is gene_id.</help> </param> @@ -104,106 +120,104 @@ <option value="simple" selected="true">Default settings</option> <option value="advanced">Set advanced options</option> </param> - <when value="simple"> - </when> + <when value="simple" /> <when value="advanced"> <param argument="--nonunique" type="select" label="How to count nonunique or ambiguous mapping reads"> <option value="none" selected="true">None - do not count nonuniquely or ambiguously mapped reads for any features</option> <option value="all">All - count nonuniquely or ambiguously mapped reads in BOTH in the nonunique or ambiguous category AND for any features they overlap</option> </param> - <param argument="--secondary-alignments" name="secondary_alignments" type="boolean" truevalue="ignore" falsevalue="score" checked="false" label="Ignore seconday alignments (0x100 flag)" /> - <param argument="--supplementary-alignments" name="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"> - <!-- Do nothing --> - </when> - </conditional> + <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)" /> + <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> <outputs> - <data format="tabular" name="counts" metadata_source="samfile" label="${tool.name} on ${on_string}"> + <data name="counts" format="tabular" metadata_source="samfile" from_work_dir="xx00" label="${tool.name} on ${on_string}"> <actions> <action name="column_names" type="metadata" default="Geneid,${samfile.element_identifier}" /> </actions> </data> - <data format="tabular" name="othercounts" metadata_source="samfile" label="${tool.name} on ${on_string} (no feature)"> + <data name="allcounts" format="tabular" metadata_source="samfile" from_work_dir="xx01" label="${tool.name} on ${on_string}: summary"> <actions> <action name="column_names" type="metadata" default="Category,${samfile.element_identifier}" /> </actions> </data> - <data format="bam" name="samoutfile" metadata_source="samfile" label="${tool.name} on ${on_string} (BAM)"> - <filter>advanced_options['advanced_options_selector'] == 'advanced' and advanced_options['samout_conditional']['samout'] == "Yes"</filter> + <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']</filter> </data> </outputs> <tests> <test expect_num_outputs="2"> <param name="samfile" value="htseq-test.sam" /> - <param name="gfffile" value="htseq-test.gff" /> + <param name="gfffile" value="htseq-test.gtf" /> <output name="counts" file="htseq-test_counts.tsv" /> - <output name="othercounts" file="htseq-test_othercounts.tsv" /> + <output name="allcounts" file="htseq-test_allcounts.tsv" /> </test> <test expect_num_outputs="2"> + <!-- same as before, but with gff3 input instead of gtf --> <param name="samfile" value="htseq-test.sam" /> <param name="gfffile" value="htseq-test.gff" /> <output name="counts" file="htseq-test_counts.tsv" /> - <output name="othercounts" file="htseq-test_othercounts.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" /> <output name="counts" file="htseq-test_counts.tsv" /> - <output name="othercounts" file="htseq-test_othercounts.tsv" /> + <output name="allcounts" file="htseq-test_allcounts.tsv" /> </test> <test expect_num_outputs="2"> <param name="samfile" value="htseq-test-paired.bam" /> <param name="gfffile" value="htseq-test.gff" /> <output name="counts" file="htseq-test-paired_counts.tsv" /> - <output name="othercounts" file="htseq-test-paired_othercounts.tsv" /> + <output name="allcounts" file="htseq-test-paired_allcounts.tsv" /> </test> <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="othercounts" file="htseq-test-paired_othercounts.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="othercounts" file="htseq-test_othercounts.tsv" /> - <output name="samoutfile" file="htseq-test_samout.bam" /> + <output name="allcounts" file="htseq-test_allcounts.tsv" /> + <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" /> @@ -213,7 +227,7 @@ <param name="secondary_alignments" value="ignore" /> <param name="supplementary_alignments" value="ignore" /> <output name="counts" file="htseq-test_counts_nonunique.tsv" /> - <output name="othercounts" file="htseq-test_othercounts.tsv" /> + <output name="allcounts" file="htseq-test_allcounts.tsv" /> </test> </tests> @@ -225,7 +239,7 @@ This tool takes an alignment file in SAM or BAM format and feature file in GFF format and calculates the number of reads mapping to each feature. It uses the *htseq-count* script that is part of the HTSeq python module. See -http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details. +https://htseq.readthedocs.io/en/latest/ for details. A feature is an interval (i.e., a range of positions) on a chromosome or a union of such intervals. In the case of RNA-Seq, the features are typically genes, where @@ -310,7 +324,7 @@ This script takes an alignment file in SAM format and a feature file in GFF format and calculates for each feature the number of reads mapping to it. See -https://htseq.readthedocs.io/en/release_0.9.1/count.html for details. +https://htseq.readthedocs.io/en/latest/ for details. Options: -f <format>, --format=<format> @@ -377,7 +391,7 @@ Show a usage summary and exit -.. _FAQ: https://htseq.readthedocs.io/en/release_0.9.1/count.html#frequenctly-asked-questions +.. _FAQ: https://htseq.readthedocs.io/en/master/index.html ]]> </help>