diff htseq-count.xml @ 20:3b3601a2a7c7 draft

planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/htseq_count commit 8a40cf16ce0b48cdfda88a505869e77e8826cb23
author lparsons
date Mon, 22 Jun 2015 17:01:05 -0400
parents d5edaf8dc974
children a6dcb86af112
line wrap: on
line diff
--- a/htseq-count.xml	Mon Oct 13 14:07:30 2014 -0400
+++ b/htseq-count.xml	Mon Jun 22 17:01:05 2015 -0400
@@ -1,69 +1,96 @@
-<tool id="htseq_count" name="htseq-count" version="0.4.1">
+<tool id="htseq_count" name="htseq-count" version="0.6.1galaxy1">
     <description> - Count aligned reads in a BAM file that overlap features in a GFF file</description>
-    <version_command>htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/'</version_command>
     <requirements>
-        <requirement type="package" version="1.7.1">numpy</requirement>
         <requirement type="package" version="0.6.1">htseq</requirement>
         <requirement type="package" version="0.1.19">samtools</requirement>
         <requirement type="package" version="0.7.7">pysam</requirement>
     </requirements>
-    <command>
+
+    <stdio>
+        <exit_code range="1:" level="fatal" description="Unknown error occurred" />
+        <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="Error" source="stderr" level="fatal" description="Unknown error occured" />
+        <regex match="Warning: Read (.+) claims to have an aligned mate which could not be found. \(Is the SAM file properly sorted\?\)" source="stderr" level="warning" description="PAIRED DATA MISSING OR NOT PROPERLY SORTED. Try reruning and selecting the option to 'Force sorting of SAM/BAM file by NAME'. See stderr output of this dataset for more information." />
+    </stdio>
+
+    <version_command>htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/'</version_command>
+
+    <command><![CDATA[
     ##set up input files
     #set $reference_fasta_filename = "localref.fa"
     #if $samout_conditional.samout:
         #if str( $samout_conditional.reference_source.reference_source_selector ) == "history":
-            ln -s "${samout_conditional.reference_source.ref_file}" "${reference_fasta_filename}" &amp;&amp;
-            samtools faidx "${reference_fasta_filename}" 2&gt;&amp;1 || echo "Error running samtools faidx for htseq-count" &gt;&amp;2 &amp;&amp;
+            ln -s "${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( $samout_conditional.reference_source.ref_file.fields.path )
         #end if
     #end if
-    htseq-count 
-    --format=$samfile.extension
-    --order=pos
-    --mode=$mode 
-    --stranded=$stranded 
-    --minaqual=$minaqual 
-    --type=$featuretype 
-    --idattr=$idattr 
+    #if $force_sort:
+        #if $samfile.extension == 'bam':
+            samtools sort -n "$samfile" "name_sorted_alignment" &&
+        #else
+            samtools view -Su -t ${reference_fasta_filename}.fai "$samfile" | samtools sort -n - "name_sorted_alignment" &&
+        #end if
+    #end if
+    htseq-count
+    --mode=$mode
+    --stranded=$stranded
+    --minaqual=$minaqual
+    --type="$featuretype"
+    --idattr="$idattr"
     #if $samout_conditional.samout:
         --samout=$__new_file_path__/${samoutfile.id}_tmp
     #end if
-    $samfile
-    $gfffile 
-    | awk '{if ($1 ~ "no_feature|ambiguous|too_low_aQual|not_aligned|alignment_not_unique") print $0 | "cat 1>&amp;2"; else print $0}' &gt; $counts 2&gt;$othercounts
+    #if $force_sort:
+        --order=name
+        --format=bam
+        name_sorted_alignment.bam
+    #else
+        --order=pos
+        --format=$samfile.extension
+        $samfile
+    #end if
+    "$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
     #if $samout_conditional.samout:
-        &amp;&amp; samtools view -Su -t ${reference_fasta_filename}.fai $__new_file_path__/${samoutfile.id}_tmp | samtools sort -o - sorted > $samoutfile
-    #end if</command>
+        && samtools view -Su -t ${reference_fasta_filename}.fai $__new_file_path__/${samoutfile.id}_tmp | samtools sort -o - sorted > $samoutfile
+    #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">
+        <param name="mode" type="select" label="Mode" help="(--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">
+        <param name="stranded" type="select" label="Stranded" help="(--stranded)">
             <help>Specify whether the data is from a strand-specific assay. 'Reverse' means yes with reversed strand interpretation.</help>
             <option value="yes" selected="true">Yes</option>
             <option value="no">No</option>
             <option value="reverse">Reverse</option>
         </param>
         <param name="minaqual" type="integer" value="10" label="Minimum alignment quality">
-            <help>Skip all reads with alignment quality lower than the given minimum value</help>
+            <help>Skip all reads with alignment quality lower than the given minimum value. (-minaqual)</help>
         </param>
         <param name="featuretype" type="text" value="exon" label="Feature 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>
+            <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. (--type)</help>
         </param>
         <param name="idattr" type="text" value="gene_id" label="ID Attribute">
-            <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>
+            <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>
         <conditional name="samout_conditional">
             <param name="samout" type="boolean" value="False" truevalue="True" falsevalue="False" 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>
             </param>
-            <when value="True">       
+            <when value="True">
                 <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>
@@ -83,6 +110,9 @@
                 </conditional>
             </when>
         </conditional>
+        <param name="force_sort" type="boolean" value="False" truevalue="True" falsevalue="False" label="Force sorting of SAM/BAM file by NAME">
+            <help>This option can be used for for paired-end data that has many unmapped mates. Use this if you get the warning about paired end data missing or not being properly sorted.</help>
+        </param>
     </inputs>
 
     <outputs>
@@ -93,16 +123,6 @@
         </data>
     </outputs>
 
-    <stdio>
-        <exit_code range="1:" level="fatal" description="Unknown error occurred" />
-        <regex match="htseq-count: command not found" source="stderr" level="fatal" description="The HTSeq python package is not properly installed, contact Galaxy administrators" />
-        <regex match="samtools: command 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="Error" source="stderr" level="fatal" description="Unknown error occured" />
-        <regex match="Warning: Read (.+) claims to have an aligned mate which could not be found. \(Is the SAM file properly sorted\?\)" source="stderr" level="warning" description="PAIRED DATA MISSING OR NOT PROPERLY SORTED. Try reruning and selecting the paired-end option. See stderr output of this dataset for more information." />
-    </stdio>
-
     <tests>
         <test>
             <param name="samfile" value="htseq-test.sam" />
@@ -112,6 +132,14 @@
             <output name="othercounts" file="htseq-test_othercounts.tsv" />
         </test>
         <test>
+            <param name="samfile" value="htseq-test.sam" />
+            <param name="gfffile" value="htseq-test.gff" />
+            <param name="samout" value="False" />
+            <param name="force_sort" value="True" />
+            <output name="counts" file="htseq-test_counts.tsv" />
+            <output name="othercounts" file="htseq-test_othercounts.tsv" />
+        </test>
+        <test>
             <param name="samfile" value="htseq-test.bam" />
             <param name="gfffile" value="htseq-test.gff" />
             <param name="samout" value="False" />
@@ -126,6 +154,16 @@
             <output name="counts" file="htseq-test-paired_counts.tsv" />
             <output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
         </test>
+        <test>
+            <param name="samfile" value="htseq-test-paired.bam" />
+            <param name="singlepaired" value="paired" />
+            <param name="gfffile" value="htseq-test.gff" />
+            <param name="samout" value="False" />
+            <param name="force_sort" value="True" />
+            <output name="counts" file="htseq-test-paired_counts.tsv" />
+            <output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
+        </test>
+
         <!-- Seems to be an issue setting the $reference_fasta_filename variable during test
         <test>
             <param name="samfile" value="htseq-test.sam" />
@@ -141,26 +179,27 @@
     </tests>
 
     <help>
+<![CDATA[
 Overview
 --------
 
 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* 
+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.
 
 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 
-each gene is considered here as the union of all its exons. One may also consider 
-each exon as a feature, e.g., in order to check for alternative splicing. For 
-comparative ChIP-Seq, the features might be binding regions from a pre-determined 
+such intervals.  In the case of RNA-Seq, the features are typically genes, where
+each gene is considered here as the union of all its exons. One may also consider
+each exon as a feature, e.g., in order to check for alternative splicing. For
+comparative ChIP-Seq, the features might be binding regions from a pre-determined
 list.
 
 
 Overlap Modes
 -------------
 
-Special care must be taken to decide how to deal with reads that overlap more than one feature. 
+Special care must be taken to decide how to deal with reads that overlap more than one feature.
 
 The htseq-count script allows to choose between three modes: *union*, *intersection-strict*, and *intersection-nonempty*.
 
@@ -230,5 +269,32 @@
 Written by Simon Anders (sanders@fs.tum.de), European Molecular Biology
 Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General
 Public License v3. Part of the 'HTSeq' framework.
+]]>
     </help>
+
+    <citations>
+        <citation type="bibtex">
+@article{anders_htseqpython_2015,
+    title = {{HTSeq}—a {Python} framework to work with high-throughput sequencing data},
+    volume = {31},
+    issn = {1367-4803, 1460-2059},
+    url = {http://bioinformatics.oxfordjournals.org/content/31/2/166},
+    doi = {10.1093/bioinformatics/btu638},
+    abstract = {Motivation: A large choice of tools exists for many standard tasks in the analysis of high-throughput sequencing (HTS) data. However, once a project deviates from standard workflows, custom scripts are needed.
+Results: We present HTSeq, a Python library to facilitate the rapid development of such scripts. HTSeq offers parsers for many common data formats in HTS projects, as well as classes to represent data, such as genomic coordinates, sequences, sequencing reads, alignments, gene model information and variant calls, and provides data structures that allow for querying via genomic coordinates. We also present htseq-count, a tool developed with HTSeq that preprocesses RNA-Seq data for differential expression analysis by counting the overlap of reads with genes.
+Availability and implementation: HTSeq is released as an open-source software under the GNU General Public Licence and available from http://www-huber.embl.de/HTSeq or from the Python Package Index at https://pypi.python.org/pypi/HTSeq.
+Contact: sanders\{at\}fs.tum.de},
+    language = {en},
+    number = {2},
+    urldate = {2015-04-21},
+    journal = {Bioinformatics},
+    author = {Anders, Simon and Pyl, Paul Theodor and Huber, Wolfgang},
+    month = jan,
+    year = {2015},
+    pmid = {25260700},
+    pages = {166--169},
+    file = {Full Text PDF:/Users/lparsons/Library/Application Support/Firefox/Profiles/thd2t4je.default/zotero/storage/84XQB8V6/Anders et al. - 2015 - HTSeq—a Python framework to work with high-through.pdf:application/pdf;Snapshot:/Users/lparsons/Library/Application Support/Firefox/Profiles/thd2t4je.default/zotero/storage/JKUAUCKB/166.html:text/html}
+}
+        </citation>
+    </citations>
 </tool>