changeset 10:d82339e37e8e draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/rgrnastar commit 686574b0392e554b75035a9b79bc919dfda9ab97"
author iuc
date Thu, 15 Aug 2019 01:54:13 -0400
parents 0a563fd2f22e
children 41929aa1e7f3
files README.rst macros.xml rg_rnaStar.xml test-data/41737_R1.fastq.sub240k.gz test-data/41737_R2.fastq.sub240k.gz test-data/737K-august-2016.small.txt.gz test-data/SNORD83B.22.fa test-data/SNORD83B.22.gtf test-data/rnastar_index2_versioned.loc test-data/rnastar_test.log test-data/rnastar_test2.log test-data/rnastar_test2_mapped_reads.bam test-data/rnastar_test_mapped_reads.bam test-data/rnastar_test_mapped_reads_twopass.bam test-data/rnastar_test_transcriptome_mapped_reads.bam test-data/rnastar_test_twopass.log test-data/test-cache/tophat-test/Genome test-data/test-cache/tophat-test/SA test-data/test-cache/tophat-test/SAindex test-data/test-cache/tophat-test/chrLength.txt test-data/test-cache/tophat-test/chrName.txt test-data/test-cache/tophat-test/chrNameLength.txt test-data/test-cache/tophat-test/chrStart.txt test-data/test-cache/tophat-test/genomeParameters.txt test-data/test3.chimjunc.tabular tool-data/rnastar_index2.loc.sample tool-data/rnastar_index2_versioned.loc.sample tool_data_table_conf.xml.sample tool_data_table_conf.xml.test
diffstat 29 files changed, 986 insertions(+), 505 deletions(-) [+]
line wrap: on
line diff
--- a/README.rst	Thu Mar 14 16:12:38 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-
-System Requirements
-===================
-
--  **Memory**: To run efficiently, RNA-STAR requires enough free memory to
-   hold the SA-indexed reference genome in RAM. For Human Genome hg19 this
-   index is about 27GB and running RNA-STAR requires approximately ~30GB of RAM.
-   For custom genomes, the rule of thumb is to multiply the size of the 
-   reference FASTA file by 9 to estimate the required amount of RAM.
--- a/macros.xml	Thu Mar 14 16:12:38 2019 -0400
+++ b/macros.xml	Thu Aug 15 01:54:13 2019 -0400
@@ -1,10 +1,39 @@
 <macros>
+    <!-- REMEMBER to bump the version of rna_star_index_builder_data_manager
+    whenever you make changes to the following two version tokens!
+    The data manager uses a symlink to this macro file to keep the versions in
+    sync. -->
+    <!-- STAR version to be used -->
+    <token name="@VERSION@">2.7.2a</token>
+    <!-- STAR index version compatible with this version of STAR
+    This is the STAR version that introduced the index structure expected
+    by the current version.
+    It can be found for any specific version of STAR with:
+    STAR -h | grep versionGenome
+    or by looking for the versionGenome parameter in source/parametersDefault
+    of STAR's source code -->
+    <token name="@IDX_VERSION@">2.7.1a</token>
+
     <xml name="requirements">
         <requirements>
-            <requirement type="package" version="2.6.0b">star</requirement>
-            <requirement type="package" version="1.8">samtools</requirement>
+            <requirement type="package" version="@VERSION@">star</requirement>
+            <requirement type="package" version="1.9">samtools</requirement>
         </requirements>
     </xml>
+
+    <xml name="index_selection" token_with_gene_model="1">
+        <param argument="--genomeDir" name="genomeDir" type="select"
+        label="Select reference genome"
+        help="If your genome of interest is not listed, contact the Galaxy team">
+            <options from_data_table="rnastar_index2_versioned">
+                <filter type="static_value" column="4" value="@WITH_GENE_MODEL@" />
+                <filter type="static_value" column="5" value="@IDX_VERSION@" />
+                <filter type="sort_by" column="2" />
+                <validator type="no_options" message="No indexes are available for the selected input dataset" />
+            </options>
+        </param>
+    </xml>
+
     <token name="@FASTQ_GZ_OPTION@">
         --readFilesCommand zcat
     </token>
@@ -13,8 +42,8 @@
             <citation type="doi">10.1093/bioinformatics/bts635</citation>
         </citations>
     </xml>
-    <xml name="@SJDBOPTIONS@">
-         <param argument="--sjdbGTFfile" type="data" format="gff3,gtf" label="Gene model (gff3,gtf) file for splice junctions" optional="true" help="Exon junction information for mapping splices"/>
+    <xml name="@SJDBOPTIONS@" token_optional="true">
+         <param argument="--sjdbGTFfile" type="data" format="gff3,gtf" label="Gene model (gff3,gtf) file for splice junctions" optional="@OPTIONAL@" help="Exon junction information for mapping splices"/>
          <param argument="--sjdbOverhang" type="integer" min="1" value="100" label="Length of the genomic sequence around annotated junctions" help="Used in constructing the splice junctions database. Ideal value is ReadLength-1"/>
     </xml>
     <xml name="dbKeyActions">
@@ -22,7 +51,7 @@
             <conditional name="refGenomeSource.geneSource">
                 <when value="indexed">
                     <action type="metadata" name="dbkey">
-                        <option type="from_data_table" name="rnastar_index2" column="1" offset="0">
+                        <option type="from_data_table" name="rnastar_index2_versioned" column="1" offset="0">
                             <filter type="param_value" column="0" value="#" compare="startswith" keep="False"/>
                             <filter type="param_value" ref="refGenomeSource.GTFconditional.genomeDir" column="0"/>
                         </option>
@@ -36,4 +65,99 @@
             </conditional>
         </actions>
     </xml>
+    <token name="@TEMPINDEX@"><![CDATA[
+    ## Create temporary index for custom reference
+    #if str($refGenomeSource.geneSource) == 'history':
+        mkdir -p tempstargenomedir &&
+        STAR
+            --runMode genomeGenerate
+            --genomeDir 'tempstargenomedir'
+            --genomeFastaFiles '${refGenomeSource.genomeFastaFiles}'
+            ## Handle difference between indices with/without annotations
+            #if str($refGenomeSource.GTFconditional.GTFselect) == 'with-gtf':
+                --sjdbOverhang '${refGenomeSource.GTFconditional.sjdbOverhang}'
+                --sjdbGTFfile '${refGenomeSource.GTFconditional.sjdbGTFfile}'
+                #if str($refGenomeSource.GTFconditional.sjdbGTFfile.ext) == 'gff3':
+                    --sjdbGTFtagExonParentTranscript Parent
+                #end if
+            #end if
+            #if str($refGenomeSource.genomeSAindexNbases):
+                --genomeSAindexNbases ${refGenomeSource.genomeSAindexNbases}
+            #end if
+            --runThreadN \${GALAXY_SLOTS:-4}
+        &&
+    #end if
+    ]]></token>
+    <token name="@REFGENOMEHANDLING" ><![CDATA[
+    --runThreadN \${GALAXY_SLOTS:-4}
+    --genomeLoad NoSharedMemory
+    --genomeDir
+    #if str($refGenomeSource.geneSource) == 'history':
+        tempstargenomedir
+    #else:
+        '${refGenomeSource.GTFconditional.genomeDir.fields.path}'
+        ## Handle difference between indices with/without annotations
+        #if str($refGenomeSource.GTFconditional.GTFselect) == 'with-gtf':
+            #if $refGenomeSource.GTFconditional.sjdbGTFfile:
+                --sjdbOverhang $refGenomeSource.GTFconditional.sjdbOverhang
+                --sjdbGTFfile '${refGenomeSource.GTFconditional.sjdbGTFfile}'
+                #if str($refGenomeSource.GTFconditional.sjdbGTFfile.ext) == 'gff3':
+                    --sjdbGTFtagExonParentTranscript Parent
+                #end if
+            #end if
+        #end if
+        #end if
+        ]]></token>
+    <xml name="stdio" >
+        <stdio>
+            <regex match="FATAL error" source="both" level="fatal"/>
+            <regex match="EXITING: FATAL INPUT ERROR:" source="both" level="fatal"/>
+            <regex match="EXITING: fatal error trying to allocate genome arrays, exception thrown: std::bad_alloc" source="both" level="fatal"/>
+            <regex match="\[sam_read1\] missing header\? Abort!" source="both" level="fatal"/>
+        </stdio>
+    </xml>
+    <xml name="refgenomehandling" >
+        <conditional name="refGenomeSource">
+            <param name="geneSource" type="select" label="Custom or built-in reference genome" help="Built-ins were indexed using default options">
+                <option value="indexed" selected="true">Use a built-in index</option>
+                <option value="history">Use reference genome from history and create temporary index</option>
+            </param>
+            <when value="indexed">
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" type="select"
+                           label="Reference genome with or without an annotation"
+                           help="Select the '... with builtin gene-model' option to select from the list of available indexes that were built with splice junction information. Select the '... without builtin gene-model' option to select from the list of available indexes without annotated splice junctions.">
+                        <option value="without-gtf">use genome reference with builtin gene-model</option>
+                        <option value="with-gtf">use genome reference without builtin gene-model</option>
+                    </param>
+                    <when value="with-gtf">
+                        <expand macro="index_selection" with_gene_model="0" />
+                        <expand macro="@SJDBOPTIONS@" />
+                    </when>
+                    <when value="without-gtf">
+                        <expand macro="index_selection" with_gene_model="1" />
+                    </when>
+                </conditional>
+            </when>
+            <when value="history">
+                <param argument="--genomeFastaFiles" type="data" format="fasta" label="Select a reference genome" />
+                <!-- Currently, this parameter is not exposed in the wrapper,
+                     but used only in the tests to avoid excessive index sizes for
+                     the tiny test genomes. -->
+                <param name="genomeSAindexNbases" type="hidden" value="" />
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" type="select"
+                           label="Build index with our without known splice junctions annotation"
+                           help="To build an index with known splice junctions annotated, you will have to provide a GTF or GFF3 dataset that describes the gene models (the location of genes, transcripts and exons) known for the reference genome.">
+                        <option value="without-gtf">build index without gene-model</option>
+                        <option value="with-gtf">build index with gene-model</option>
+                    </param>
+                    <when value="with-gtf">
+                        <expand macro="@SJDBOPTIONS@" optional="false"/>
+                    </when>
+                    <when value="without-gtf" />
+                </conditional>
+            </when>
+        </conditional>
+    </xml>
 </macros>
--- a/rg_rnaStar.xml	Thu Mar 14 16:12:38 2019 -0400
+++ b/rg_rnaStar.xml	Thu Aug 15 01:54:13 2019 -0400
@@ -1,16 +1,10 @@
-<tool id="rna_star" name="RNA STAR" version="2.6.0b-2" profile="17.01">
+<tool id="rna_star" name="RNA STAR" version="@VERSION@" profile="17.01">
     <description>Gapped-read mapper for RNA-seq data</description>
     <macros>
         <import>macros.xml</import>
     </macros>
     <expand macro="requirements"/>
-
-    <stdio>
-        <regex match="FATAL error" source="both" level="fatal"/>
-        <regex match="EXITING: FATAL INPUT ERROR:" source="both" level="fatal"/>
-        <regex match="EXITING: fatal error trying to allocate genome arrays, exception thrown: std::bad_alloc" source="both" level="fatal"/>
-        <regex match="\[sam_read1\] missing header\? Abort!" source="both" level="fatal"/>
-    </stdio>
+    <expand macro="stdio" />
 
 <!--
     important quote (https://groups.google.com/forum/#!topic/rna-star/q4zGzlPgwXY):
@@ -23,176 +17,212 @@
     Alex
 -->
     <command><![CDATA[
-    ## Create temporary index for custom reference
-    #if str($refGenomeSource.geneSource) == 'history':
-        mkdir -p tempstargenomedir &&
-        STAR
-            --runMode genomeGenerate
-            --genomeDir 'tempstargenomedir'
-            --genomeFastaFiles '$refGenomeSource.genomeFastaFiles'
-            #if $refGenomeSource.sjdbGTFfile:
-                --sjdbGTFfile '$refGenomeSource.sjdbGTFfile'
-                --sjdbOverhang '$refGenomeSource.sjdbOverhang'
-            #end if
-            --runThreadN \${GALAXY_SLOTS:-4}
-        &&
-    #end if
-
+    @TEMPINDEX@
     STAR
-        --runThreadN \${GALAXY_SLOTS:-4}
-        --genomeLoad NoSharedMemory
-        --genomeDir
-        #if str($refGenomeSource.geneSource) == 'history':
-            'tempstargenomedir'
-            #if $refGenomeSource.sjdbGTFfile:
-                --sjdbGTFfile '$refGenomeSource.sjdbGTFfile'
-                --sjdbOverhang '$refGenomeSource.sjdbOverhang'
-            #end if
-        #else
-            '${refGenomeSource.GTFconditional.genomeDir.fields.path}'
-        #end if
+    @REFGENOMEHANDLING@
 
         --readFilesIn
-        #if str($singlePaired.sPaired) == "paired_collection"
+        #if str($singlePaired.sPaired) == 'paired_collection':
             '$singlePaired.input.forward' '$singlePaired.input.reverse'
 
-            #if $singlePaired.input.forward.is_of_type("fastq.gz", "fastqsanger.gz"):
+            #if $singlePaired.input.forward.is_of_type('fastq.gz', 'fastqsanger.gz'):
                 @FASTQ_GZ_OPTION@
             #end if
         #else
             '$singlePaired.input1'
-            #if str($singlePaired.sPaired) == "paired"
+            #if str($singlePaired.sPaired) == 'paired':
                 '$singlePaired.input2'
             #end if
 
-            #if $singlePaired.input1.is_of_type("fastq.gz", "fastqsanger.gz"):
+            #if $singlePaired.input1.is_of_type('fastq.gz', 'fastqsanger.gz'):
                 @FASTQ_GZ_OPTION@
             #end if
         #end if
 
         --outSAMtype BAM SortedByCoordinate
 
-        ## Handle difference between indices with/without annotations
-        #if str($refGenomeSource.geneSource) == 'indexed':
-            #if str($refGenomeSource.GTFconditional.GTFselect) == 'without-gtf':
-                #if $refGenomeSource.GTFconditional.sjdbGTFfile:
-                    --sjdbOverhang '$refGenomeSource.GTFconditional.sjdbOverhang'
-                    --sjdbGTFfile '${refGenomeSource.GTFconditional.sjdbGTFfile}'
-                    #if str($refGenomeSource.GTFconditional.sjdbGTFfile.ext) == 'gff3':
-                        --sjdbGTFtagExonParentTranscript Parent
-                    #end if
+        ## Two pass mode
+        --twopassMode ${twopass.twopassMode} ${twopass.twopass_read_subset}
+        #for $sj_input in $twopass.sj_precalculated:
+            '$sj_input'
+        #end for
+        #if str($twopass.twopassMode) != 'None':
+            #if str($refGenomeSource.GTFconditional.GTFselect) == 'with-gtf':
+                #if not $refGenomeSource.GTFconditional.sjdbGTFfile:
+                    ## case of cached index without built-in gene model,
+                    ## when user does not supply the optional gtf, but
+                    ## specifies the splice junction overhang
+                    --sjdbOverhang $refGenomeSource.GTFconditional.sjdbOverhang
                 #end if
             #end if
         #end if
 
-        #if $quantMode:
-            --quantMode GeneCounts
+        --quantMode ${quantmode_output.quantMode}
+        #if 'TranscriptomeSAM' in str($quantmode_output.quantMode):
+            --quantTranscriptomeBan ${quantmode_output.quantTranscriptomeBan}
         #end if
 
-        ## Output parameters
-        #if str( $output_params.output_select ) == "yes":
-            --outSAMattributes $output_params.outSAMattributes
-            #if str( $params.settingsType ) != "star_fusion":
-                --outSAMstrandField $output_params.outSAMstrandField
+        ## Output format parameters
+
+        ## Read tags
+        #set read_tags = str($oformat.outSAMattributes).split(',')
+        #if 'XS' in str($oformat.outSAMattributes):
+            ## STAR writes XS tag when --outSAMstrandField intronMotif is used
+            $read_tags.remove('XS')
+            --outSAMstrandField intronMotif
+        #end if
+        #if 'HI' in str($oformat.outSAMattributes):
+            --outSAMattrIHstart ${oformat.HI_offset}
+        #end if
+        #set $tag_names = ' '.join($read_tags)
+        --outSAMattributes $tag_names
+
+        ## Read FLAG
+        --outSAMprimaryFlag ${oformat.outSAMprimaryFlag}
+
+        ## Read MAPQ
+        --outSAMmapqUnique ${oformat.outSAMmapqUnique}
+
+        ## Output filter parameters
+
+        ## Basic Filters
+        #if str($filter.basic_filters) != 'None':
+            #set $filter_options = str($filter.basic_filters).split(',')
+        #else:
+            #set filter_options = []
+        #end if
+        #if 'exclude_unmapped' in $filter_options:
+            $filter_options.remove('exclude_unmapped')
+            --outSAMunmapped None
+        #else:
+            --outSAMunmapped Within
+        #end if
+        #if '--outFilterIntronMotifs RemoveNoncanonical' in $filter_options:
+            ## RemoveNoncanonical excludes a superset of the reads excluded
+            ## with RemoveNoncanonicalUnannotated
+            #if '--outFilterIntronMotifs RemoveNoncanonicalUnannotated' in $filter_options:
+                $filter_options.remove('--outFilterIntronMotifs RemoveNoncanonicalUnannotated')
             #end if
-            --outFilterIntronMotifs $output_params.outFilterIntronMotifs
-            --outFilterIntronStrands $output_params.outFilterIntronStrands
-            #if str( $output_params.output_params2.output_select2 ) == "yes":
-                --outSAMunmapped $output_params.output_params2.outSAMunmapped
-                --outSAMprimaryFlag $output_params.output_params2.outSAMprimaryFlag
-                --outSAMmapqUnique "$output_params.output_params2.outSAMmapqUnique"
-                --outFilterType $output_params.output_params2.outFilterType
-                --outFilterMultimapScoreRange "$output_params.output_params2.outFilterMultimapScoreRange"
-                --outFilterMultimapNmax "$output_params.output_params2.outFilterMultimapNmax"
-                --outFilterMismatchNmax "$output_params.output_params2.outFilterMismatchNmax"
-                --outFilterMismatchNoverLmax "$output_params.output_params2.outFilterMismatchNoverLmax"
-                --outFilterMismatchNoverReadLmax "$output_params.output_params2.outFilterMismatchNoverReadLmax"
-                --outFilterScoreMin "$output_params.output_params2.outFilterScoreMin"
-                --outFilterScoreMinOverLread "$output_params.output_params2.outFilterScoreMinOverLread"
-                --outFilterMatchNmin "$output_params.output_params2.outFilterMatchNmin"
-                --outFilterMatchNminOverLread "$output_params.output_params2.outFilterMatchNminOverLread"
-                --outSAMmultNmax "$output_params.output_params2.outSAMmultNmax"
-                --outSAMtlen "$output_params.output_params2.outSAMtlen"
-                --outBAMsortingBinsN "$output_params.output_params2.outBAMsortingBinsN"
-            #end if
+        #end if
+        #echo ' '.join($filter_options)
+
+        ## Other Filters
+        #if str( $filter.output_params2.output_select2 ) == 'yes':
+            --outFilterType $filter.output_params2.outFilterType
+            --outFilterMultimapScoreRange $filter.output_params2.outFilterMultimapScoreRange
+            --outFilterMultimapNmax $filter.output_params2.outFilterMultimapNmax
+            --outFilterMismatchNmax $filter.output_params2.outFilterMismatchNmax
+            --outFilterMismatchNoverLmax $filter.output_params2.outFilterMismatchNoverLmax
+            --outFilterMismatchNoverReadLmax $filter.output_params2.outFilterMismatchNoverReadLmax
+            --outFilterScoreMin $filter.output_params2.outFilterScoreMin
+            --outFilterScoreMinOverLread $filter.output_params2.outFilterScoreMinOverLread
+            --outFilterMatchNmin $filter.output_params2.outFilterMatchNmin
+            --outFilterMatchNminOverLread $filter.output_params2.outFilterMatchNminOverLread
+            --outSAMmultNmax $filter.output_params2.outSAMmultNmax
+            --outSAMtlen $filter.output_params2.outSAMtlen
         #end if
 
         ## Other parameters
-        #if str( $params.settingsType ) == "star_fusion":
+        #if str( $algo.params.settingsType ) == 'star_fusion':
             ## Preset parameters for STAR-Fusion
-            --outReadsUnmapped None
             --chimSegmentMin 12
             --chimJunctionOverhangMin 12
             --alignSJDBoverhangMin 10
-            --alignMatesGapMax 200000
-            --alignIntronMax 200000
-            --twopassMode Basic
-            --twopass1readsN -1
+            --alignMatesGapMax 100000
+            --alignIntronMax 100000
             --chimSegmentReadGapMax 3
             --alignSJstitchMismatchNmax 5 -1 5 5
-            --outSAMstrandField intronMotif
+            --peOverlapNbasesMin 12
+            --peOverlapMMp 0.1
+            --chimMultimapScoreRange 10
+            --chimMultimapNmax 10
+            --chimNonchimScoreDropMin 10
 
-        #elif str( $params.settingsType ) == "full":
+        #elif str( $algo.params.settingsType ) == 'full':
             ## Extended parameter options
 
             ## Seed parameter options
-            --seedSearchStartLmax "$params.seed.seedSearchStartLmax"
-            --seedSearchStartLmaxOverLread "$params.seed.seedSearchStartLmaxOverLread"
-            --seedSearchLmax "$params.seed.seedSearchLmax"
-            --seedMultimapNmax "$params.seed.seedMultimapNmax"
-            --seedPerReadNmax "$params.seed.seedPerReadNmax"
-            --seedPerWindowNmax "$params.seed.seedPerWindowNmax"
-            --seedNoneLociPerWindow "$params.seed.seedNoneLociPerWindow"
+            --seedSearchStartLmax ${algo.params.seed.seedSearchStartLmax}
+            --seedSearchStartLmaxOverLread ${algo.params.seed.seedSearchStartLmaxOverLread}
+            --seedSearchLmax ${algo.params.seed.seedSearchLmax}
+            --seedMultimapNmax ${algo.params.seed.seedMultimapNmax}
+            --seedPerReadNmax ${algo.params.seed.seedPerReadNmax}
+            --seedPerWindowNmax ${algo.params.seed.seedPerWindowNmax}
+            --seedNoneLociPerWindow ${algo.params.seed.seedNoneLociPerWindow}
 
             ## Alignment parameter options
-            --alignIntronMin "$params.align.alignIntronMin"
-            --alignIntronMax "$params.align.alignIntronMax"
-            --alignMatesGapMax "$params.align.alignMatesGapMax"
-            --alignSJoverhangMin "$params.align.alignSJoverhangMin"
-            --alignSJDBoverhangMin "$params.align.alignSJDBoverhangMin"
-            --alignSplicedMateMapLmin "$params.align.alignSplicedMateMapLmin"
-            --alignSplicedMateMapLminOverLmate "$params.align.alignSplicedMateMapLminOverLmate"
-            --alignWindowsPerReadNmax "$params.align.alignWindowsPerReadNmax"
-            --alignTranscriptsPerWindowNmax "$params.align.alignTranscriptsPerWindowNmax"
-            --alignTranscriptsPerReadNmax "$params.align.alignTranscriptsPerReadNmax"
-            --alignEndsType $params.align.alignEndsType
-
-            ## Two pass mode
-            --twopassMode "$params.twopass.twopassMode"
-            #if str( $params.twopass.twopassMode ) == "Basic":
-                --twopass1readsN "$params.twopass.twopass1readsN"
-                #if not $refGenomeSource.sjdbGTFfile:
-                    --sjdbOverhang '$refGenomeSource.sjdbOverhang'
+            --alignIntronMin ${algo.params.align.alignIntronMin}
+            --alignIntronMax ${algo.params.align.alignIntronMax}
+            --alignMatesGapMax ${algo.params.align.alignMatesGapMax}
+            --alignSJoverhangMin ${algo.params.align.alignSJoverhangMin}
+            --alignSJDBoverhangMin ${algo.params.align.alignSJDBoverhangMin}
+            --alignSplicedMateMapLmin ${algo.params.align.alignSplicedMateMapLmin}
+            --alignSplicedMateMapLminOverLmate ${algo.params.align.alignSplicedMateMapLminOverLmate}
+            --alignWindowsPerReadNmax ${algo.params.align.alignWindowsPerReadNmax}
+            --alignTranscriptsPerWindowNmax ${algo.params.align.alignTranscriptsPerWindowNmax}
+            --alignTranscriptsPerReadNmax ${algo.params.align.alignTranscriptsPerReadNmax}
+            --alignEndsType ${algo.params.align.alignEndsType}
+            --peOverlapNbasesMin ${algo.params.align.peOverlapNbasesMin}
+            --peOverlapMMp ${algo.params.align.peOverlapMMp}
+            ## Chimeric alignment parameter options
+            #if str($chimOutType):
+                --chimSegmentMin ${algo.params.chim_settings.chimSegmentMin}
+                --chimScoreMin ${algo.params.chim_settings.chimScoreMin}
+                --chimScoreDropMax $algo.params.chim_settings.chimScoreDropMax
+                --chimScoreSeparation $algo.params.chim_settings.chimScoreSeparation
+                --chimScoreJunctionNonGTAG $algo.params.chim_settings.chimScoreJunctionNonGTAG
+                --chimSegmentReadGapMax $algo.params.chim_settings.chimSegmentReadGapMax
+                --chimFilter $algo.params.chim_settings.chimFilter
+                --chimJunctionOverhangMin $algo.params.chim_settings.chimJunctionOverhangMin
+                --chimMainSegmentMultNmax $algo.params.chim_settings.chimMainSegmentMultNmax
+                #if str($chimOutType) == 'Junctions':
+                    --chimMultimapNmax $algo.params.chim_settings.chimMultimapNmax
+                #else:
+                    --chimMultimapNmax 0
                 #end if
-            #end if
-
-            ## Chimeric alignment parameter options
-            #if str( $params.chim.chim_select ) == "yes":
-                --chimOutType Junctions SeparateSAMold
-                --chimSegmentMin "$params.chim.chimSegmentMin"
-                --chimScoreMin "$params.chim.chimScoreMin"
-                --chimScoreDropMax "$params.chim.chimScoreDropMax"
-                --chimScoreSeparation "$params.chim.chimScoreSeparation"
-                --chimScoreJunctionNonGTAG "$params.chim.chimScoreJunctionNonGTAG"
-                --chimJunctionOverhangMin "$params.chim.chimJunctionOverhangMin"
-                --chimMainSegmentMultNmax "$params.chim.chimMainSegmentMultNmax"
-                --chimMultimapNmax "$params.chim.chimMultimapNmax"
-                --chimMultimapScoreRange "$params.chim.chimMultimapScoreRange"
+                --chimMultimapScoreRange $algo.params.chim_settings.chimMultimapScoreRange
             #end if
 
             ## Limits
-            --limitBAMsortRAM "$params.limits.limitBAMsortRAM"
-            --limitOutSJoneRead "$params.limits.limitOutSJoneRead"
-            --limitOutSJcollapsed "$params.limits.limitOutSJcollapsed"
-            --limitSjdbInsertNsj "$params.limits.limitSjdbInsertNsj"
-
+            --limitOutSJoneRead $algo.params.limits.limitOutSJoneRead
+            --limitOutSJcollapsed $algo.params.limits.limitOutSJcollapsed
+            --limitSjdbInsertNsj $algo.params.limits.limitSjdbInsertNsj
+        #else:
+            ## Go with STAR's default algorithmic settings,
+            ## but we need to provide a reasonable default
+            ## (taken from STAR-Fusion)
+            ## for --chimSegmentMin in case the user enabled chimeric
+            ## alignments (the STAR default is 0, which disables chimeric
+            ## alignments). For consistency, also set
+            ## --chimMultimapNmax to 1 when chimeric alignments are reported
+            ## in Junctions format only.
+            #if str($chimOutType):
+                --chimSegmentMin 12
+                #if str($chimOutType) == 'Junctions':
+                    --chimMultimapNmax 1
+                #end if
+            #end if
         #end if
 
-    ## Convert chimeric reads.
-    #if str($params.settingsType) == "full" and str($params.chim.chim_select) == "yes" and int($params.chim.chimSegmentMin) > 0:
+        --outBAMsortingThreadN \${GALAXY_SLOTS:-4}
+        --outBAMsortingBinsN $perf.outBAMsortingBinsN
+        --limitBAMsortRAM \$((\${GALAXY_MEMORY_MB:-0}*1000000))
+
+        ## Handle chimeric options and output
+        #if str($chimOutType):
+            --chimOutType $chimOutType
+            #if 'Junctions' in str($chimOutType):
+                --chimOutJunctionFormat 1
+            #end if
+        #end if
         &&
-        samtools sort -@ \${GALAXY_SLOTS:-4} -o ChimericSorted.bam -O BAM Chimeric.out.sam
-    #end if
+        ## recompress BAM output for smaller file size
+        samtools view -b -o '$mapped_reads' Aligned.sortedByCoord.out.bam
+        #if 'TranscriptomeSAM' in str($quantmode_output.quantMode):
+            ## same recompression for optional transcriptome BM
+            &&
+            samtools view -b -o '$transcriptome_mapped_reads' Aligned.toTranscriptome.out.bam
+        #end if
     ]]></command>
 
     <inputs>
@@ -216,187 +246,229 @@
         </conditional>
 
         <!-- Genome source. -->
-        <conditional name="refGenomeSource">
-            <param name="geneSource" type="select" label="Custom or built-in reference genome" help="Built-ins were indexed using default options">
-                <option value="indexed" selected="True">Use a built-in index</option>
-                <option value="history">Use reference genome from history and create temporary index</option>
+        <expand macro="refgenomehandling" />
+
+        <conditional name="twopass">
+            <param argument="--twopassMode" type="select"
+            label="Use 2-pass mapping for more sensitive novel splice junction discovery"
+            help="For a study with multiple samples, multisample 2-pass mapping is the most sensitive approach. It involves two separate runs of STAR for each sample, where, in the second run of each sample, the splice junctions found in any sample in the first runs are treated as additional known junctions. If you plan to use the mapping results as input for STAR-Fusion it is recommended that you use at least single-sample 2-pass mapping of all reads.">
+                <option value="None">No</option>
+                <option value="Basic">Yes, perform single-sample 2-pass mapping of all reads</option>
+                <option value="Basic --twopass1readsN">Yes, but base novel splice junction detection in the first pass on a subset of all reads (faster, but less sensitive than single-sample 2-pass mode)</option>
+                <option value="None --sjdbFileChrStartEnd">Yes, I want to use multi-sample 2-pass mapping and I have obtained splice junctions datasets of all samples through previous 1-pass runs of STAR.</option>
             </param>
-            <when value="indexed">
-                <conditional name="GTFconditional">
-                    <param name="GTFselect" type="select" label="Reference genome with or without an annotation" help="Must the index have been created WITH a GTF file (if not you can specify one afterward).">
-                        <option value="without-gtf">use genome reference without builtin gene-model</option>
-                        <option value="with-gtf">use genome reference with builtin gene-model</option>
-                    </param>
-                    <when value="with-gtf">
-                        <param name="genomeDir" argument="--genomeDir" type="select" label="Select reference genome" help="If your genome of interest is not listed, contact the Galaxy team">
-                            <options from_data_table="rnastar_index2">
-                                <filter type="static_value" column="4" value="1"/>
-                                <filter type="sort_by" column="2" />
-                                <validator type="no_options" message="No indexes are available for the selected input dataset"/>
-                            </options>
-                        </param>
-                    </when>
-                    <when value="without-gtf">
-                        <param argument="--genomeDir" type="select" label="Select reference genome" help="If your genome of interest is not listed, contact the Galaxy team">
-                            <options from_data_table="rnastar_index2">
-                                <filter type="static_value" column="4" value="0"/>
-                                <filter type="sort_by" column="2" />
-                                <validator type="no_options" message="No indexes are available for the selected input dataset"/>
-                            </options>
-                        </param>
-
-                        <expand macro="@SJDBOPTIONS@" />
-                    </when>
-                </conditional>
+            <when value="None">
+                <param name="twopass_read_subset" type="hidden" value="" />
+                <param name="sj_precalculated" type="hidden" value="" />
+            </when>
+            <when value="Basic">
+                <param name="twopass_read_subset" type="hidden" value="" />
+                <param name="sj_precalculated" type="hidden" value="" />
+            </when>
+            <when value="Basic --twopass1readsN">
+                <param name="sj_precalculated" type="hidden" value="" />
+                <param argument="--twopass1readsN" name="twopass_read_subset" type="integer" min="1" value="50000" label="Number of reads to map in the first pass"/>
+            </when>
+            <when value="None --sjdbFileChrStartEnd">
+                <param name="twopass_read_subset" type="hidden" value="" />
+                <param name="sj_precalculated" type="data" multiple="true" format="interval"
+                label="Pregenerated splice junctions datasets of your samples" />
             </when>
-            <when value="history">
-                <param argument="--genomeFastaFiles" type="data" format="fasta" label="Select a reference genome" />
-                <expand macro="@SJDBOPTIONS@" />
+        </conditional>
+        <conditional name="quantmode_output">
+            <param argument="--quantMode" type="select"
+            label="Per gene/transcript output"
+            help="STAR can provide analysis results not only with respect to the reference genome, but also with respect to genes and transcripts described by a gene model. Note: This functionality requires either the selection above of a cached index with a gene model, or a gene model provided alongside the index/reference genome in GTF or GFF3 format!">
+                <option value="-">No per gene or transcript output</option>
+                <option value="GeneCounts">Per gene read counts (GeneCounts)</option>
+                <option value="TranscriptomeSAM">Transcript-based BAM output (TranscriptomeSAM)</option>
+                <option value="TranscriptomeSAM GeneCounts">Both per gene read counts and transcript-based BAM output (TranscriptomeSAM GeneCounts)</option>
+            </param>
+            <when value="-" />
+            <when value="GeneCounts" />
+            <when value="TranscriptomeSAM">
+                <param argument="--quantTranscriptomeBan" type="boolean" truevalue="IndelSoftclipSingleend" falsevalue="Singleend"
+                label="Exclude alignments with indels or soft clipping from the transcriptome BAM output?"
+                help="You will need to exclude alignments with indels and soft-clipped bases from the transcriptome BAM output for compatibility with certain transcript quantification tools, most notably RSEM. If you are using a tool, like eXpress, that can deal with indels and soft-clipped bases, you can achieve better results by leaving this option disabled." />
+            </when>
+            <when value="TranscriptomeSAM GeneCounts">
+                <param argument="--quantTranscriptomeBan" type="boolean" truevalue="IndelSoftclipSingleend" falsevalue="Singleend"
+                label="Exclude alignments with indels or soft clipping from the transcriptome BAM output?"
+                help="You will need to exclude alignments with indels and soft-clipped bases from the transcriptome BAM output for compatibility with certain transcript quantification tools, most notably RSEM. If you are using a tool, like eXpress, that can deal with indels and soft-clipped bases, you can achieve better results by leaving this option disabled." />
             </when>
         </conditional>
-        <param argument="--quantMode" type="boolean" label="Count number of reads per gene" help="column 1: gene ID, column 2: counts for unstranded RNA-seq, column 3: counts for the 1st read strand aligned with RNA , column 4: counts for the 2nd read strand aligned with RNA. This requires either (A) an index that was built with an annotation (GTF or GFF3 file) or (B) having specified an annotation (GTF or GFF3 file above)."/>
-
-        <!-- Output parameter settings. -->
-        <conditional name="output_params">
-            <param name="output_select" type="select" label="Would you like to set output parameters (formatting and filtering)?">
-                <option value="no" selected="true">No</option>
-                <option value="yes">Yes</option>
-            </param>
-            <when value="yes">
-              <param argument="--outSAMattributes" type="select" label="Extra SAM attributes to include" help="See &quot;Extra SAM attributes&quot; below">
-                    <option value="Standard" selected="true">Standard</option>
-                    <option value="All">All</option>
-                    <option value="None">None</option>
-                </param>
-                <param argument="--outSAMstrandField" type="select" label="Include strand field flag XS" help="For Cufflinks compatibility with unstranded RNA-seq data, this option is required">
-                    <option value="None" selected="true">No</option>
-                    <option value="intronMotif">Yes -- and reads with inconsistent and/or non-canonical introns are filtered out</option>
-                </param>
-                <param argument="--outFilterIntronMotifs" type="select" label="Filter alignments containing non-canonical junctions" help="For Cufflinks compatibility, removing alignments with non-canonical junctions is recommended">
-                    <option value="None" selected="true">No</option>
-                    <option value="RemoveNoncanonical">Remove alignments with non-canonical junctions</option>
-                    <option value="RemoveNoncanonicalUnannotated">Remove alignments with unannotated non-canonical junctions</option>
-                </param>
-                <param argument="--outFilterIntronStrands" type="select" label="Filter alignments containing junctions with inconsistent strands">
-                    <option value="RemoveInconsistentStrands" selected="true">Remove alignments that have junctions with inconsistent strands</option>
-                    <option value="None">No filtering</option>
-                </param>
+        <param argument="--chimOutType" type="select"
+        label="Report chimeric alignments?"
+        help="Choose if and how chimeric alignments should be reported. STAR-Fusion users should select the 'Junctions' option and use the resulting tabular dataset as input to STAR-Fusion. Everyone else: note that selecting 'WithinBAM' or 'WithinBAM Junctions' disables the --chimMultimapNmax setting in the algorithmic parameters section below (the tool will only consider uniquely mapped reads in the search for chimeric alignments). If you disable the reporting of chimeric alignments here, then all chimeric alignment settings in the algorithmic parameters section below will be ignored.">
+            <option value="">Don't report chimeric alignments</option>
+            <option value="Junctions">As separate tabular "Junctions" output (Junctions)</option>
+            <option value="WithinBAM">Within the BAM output (together with regular alignments; WithinBAM)</option>
+            <option value="WithinBAM Junctions">In both forms (WithinBAM Junctions)</option>
+        </param>
 
-              <!-- Additional output parameter settings. -->
-              <conditional name="output_params2">
-                  <param name="output_select2" type="select" label="Would you like to set additional output parameters (formatting and filtering)?">
-                      <option value="no" selected="true">No</option>
-                      <option value="yes">Yes</option>
-                  </param>
-                  <when value="yes">
-                      <param argument="--outSAMunmapped" type="boolean" truevalue="Within" falsevalue="None" checked="false" label="Would you like unmapped reads included in the SAM?"/>
-                      <param argument="--outSAMprimaryFlag" type="boolean" truevalue="AllBestScore" falsevalue="OneBestScore" checked="false" label="Would you like all alignments with the best score labeled primary?"/>
-                      <param argument="--outSAMmapqUnique" type="integer" value="255" min="0" max="255" label="MAPQ value for unique mappers"/>
-                      <param argument="--outFilterType" type="boolean" truevalue="BySJout" falsevalue="Normal" checked="false" label="Would you like to keep only reads that contain junctions that passed filtering?"/>
-                      <param argument="--outFilterMultimapScoreRange" type="integer" value="1" min="0" label="Score range below the maximum score for multimapping alignments"/>
-                      <param argument="--outFilterMultimapNmax" type="integer" value="10" min="1" label="Maximum number of alignments to output a read's alignment results, plus 1" help="Reads with at least this number of alignments will have no alignments output"/>
-                      <param argument="--outFilterMismatchNmax" type="integer" value="10" min="0" label="Maximum number of mismatches to output an alignment, plus 1" help="Alignments with at least this number of mismatches will not be output"/>
-                      <param argument="--outFilterMismatchNoverLmax" type="float" value="0.3" min="0" max="1" label="Maximum ratio of mismatches to mapped length" help="Alignments with a mismatch ratio of at least this value will not be output"/>
-                      <param argument="--outFilterMismatchNoverReadLmax" type="float" value="1" min="0" max="1" label="Maximum ratio of mismatches to read length" help="Alignments with a mismatch ratio of at least this value will not be output"/>
-                      <param argument="--outFilterScoreMin" type="integer" value="0" min="0" label="Minimum alignment score" help="Alignments must have scores higher than this value to be output"/>
-                      <param argument="--outFilterScoreMinOverLread" type="float" value="0.66" min="0" max="1" label="Minimum alignment score, normalized to read length" help="Alignments must have (normalized) scores higher than this value to be output"/>
-                      <param argument="--outFilterMatchNmin" type="integer" value="0" min="0" label="Minimum number of matched bases" help="Alignments must have the number of matched bases higher than this value to be output"/>
-                      <param argument="--outFilterMatchNminOverLread" type="float" value="0.66" min="0" max="1" label="Minimum number of matched bases, normalized to read length" help="Alignments must have the (normalized) number of matched bases higher than this value to be output"/>
-                      <param argument="--outSAMmultNmax" type="integer" value="-1" min="-1" label="Maximum number of multimapping alignments to output for a read" help="A value of -1 (the default) results in all alignments (up to –-outFilterMultimapNmax) being output" />
-                      <param argument="--outSAMtlen" type="select" label="Calculation method for TLEN">
-                          <option value="1" selected="true">leftmost base of the (+)strand mate to rightmost base of the (-)mate. (+)sign for the (+)strand mate</option>
-                          <option value="2">leftmost base of any mate to rightmost base of any mate. (+)sign for the mate with the leftmost base. This is different from 1 for overlapping mates with protruding ends</option>
-                      </param>
-                      <param argument="--outBAMsortingBinsN" type="integer" value="50" min="1" label="Number of genome bins for coordinate-sorting" help="Higher values result in lower RAM requirements during the sorting step. The default value is 50."/>
-                  </when>
-                  <when value="no"/>
-              </conditional>
-          </when>
-          <when value="no"/>
-        </conditional>
+        <section name="oformat" title="BAM output format specification" expanded="true">
+            <param argument="--outSAMattributes" type="select" display="checkboxes" multiple="true" optional="true"
+            label="Read alignment tags to include in the BAM output"
+            help="Note on using the XS tag: If the XS tag is used, STAR will filter out alignments with undefined strand (i.e., those containing only non-canonical unannotated junctions). Using this tag is recommended if you plan to use the STAR results with STAR-Fusion. In addition, it is required for compatibility
+with Cufflinks if your sequences come from an unstranded library preparation.">
+                <option value="NH" selected="true">NH (number of reported alignments/hits for the read)</option>
+                <option value="HI" selected="true">HI (query hit index)</option>
+                <option value="AS" selected="true">AS (local alignment score)</option>
+                <option value="nM" selected="true">nM (number of mismatches per (paired) alignment)</option>
+                <option value="XS">XS (strand flag, see parameter help below) </option>
+                <option value="NM">NM (edit distance of the aligned read to the reference)</option>
+                <option value="MD">MD (string for mismatching positions)</option>
+                <option value="MC">MC (CIGAR string for mate/next segment)</option>
+                <option value="jM">jM (intron motifs for all junctions)</option>
+                <option value="jI">jI (1-based start and end of introns for all junctions)</option>
+                <option value="ch" selected="true">ch (used to indicate chimeric alignments)</option>
+            </param>
+            <param argument="--outSAMattrIHstart" name="HI_offset" type="select" display="radio"
+            label="HI tag values should be">
+                <option value="1" selected="true">one-based</option>
+                <option value="0">zero-based</option>
+            </param>
+            <!-- Using - -outSAMprimaryFlag AllBestScore would cause a
+            violation of the SAM/BAM spec, which says:
+            "For each read/contig in a SAM file, it is required that one and
+            only one line associated with the read satisfies
+            ‘FLAG & 0x900 == 0’.
+            This line is called the primary line of the read."
 
-        <!-- Other parameter settings. -->
-        <conditional name="params">
-            <param name="settingsType" type="select" label="Other parameters (seed, alignment, limits and chimeric alignment)">
-                <option value="default" selected="true">Use Defaults</option>
-                <option value="star_fusion">Use parameters suggested for STAR-Fusion</option>
-                <option value="full">Extended parameter list</option>
+            Thus, this parameter has been removed from the tool interface:
+            <param argument="- -outSAMprimaryFlag" type="boolean"
+            truevalue="AllBestScore" falsevalue="OneBestScore" checked="false"
+            label="Would you like all alignments with the best score labeled
+            primary?"/> -->
+            <param name="outSAMprimaryFlag" type="hidden" value="OneBestScore" />
+            <param argument="--outSAMmapqUnique" type="integer" value="60" min="30" max="255"
+            label="MAPQ value for unique mappers"
+            help="STAR bases the mapping quality scores of alignment records in its BAM output on the number of alternative mappings for the read. If a read maps to multiple locations on the reference genome, the following MAPQ scoring scheme is
+used: >=5 mappings => MAPQ=0; 3-4 mappings => MAPQ=1; 2 mappings => MAPQ=3. This setting lets you control the MAPQ used for reads mapped to a single location. Set to 255 for compatibility with Cufflinks." />
+        </section>
+        <section name="filter" title="Output filter criteria" expanded="true">
+            <param name="basic_filters" type="select" display="checkboxes" multiple="true" optional="true"
+            label="Exclude the following records from the BAM output">
+                <option value="exclude_unmapped">Unmapped reads</option>
+                <option value="--outFilterIntronStrands RemoveInconsistentStrands">Alignments that have junctions with inconsistent strands</option>
+                <option value="--outFilterIntronMotifs RemoveNoncanonicalUnannotated">Alignments across unannotated non-canonical junctions</option>
+                <option value="--outFilterIntronMotifs RemoveNoncanonical">All alignments across non-canonical junctions (recommended for compatibility with Cufflinks)</option>
             </param>
-            <when value="default"/>
-            <when value="star_fusion"/><!-- Set STAR-fusion parameters automatically -->
+            <!-- Additional output parameter settings. -->
+            <conditional name="output_params2">
+                <param name="output_select2" type="select" label="Would you like to set additional output filters?">
+                    <option value="no" selected="true">No</option>
+                    <option value="yes">Yes</option>
+                </param>
+                <when value="yes">
+                    <param argument="--outFilterType" type="boolean" truevalue="BySJout" falsevalue="Normal" checked="false" label="Would you like to keep only reads that contain junctions that passed filtering?"/>
+                    <param argument="--outFilterMultimapScoreRange" type="integer" value="1" min="0" label="Score range below the maximum score for multimapping alignments"/>
+                    <param argument="--outFilterMultimapNmax" type="integer" value="10" min="1" label="Maximum number of alignments to output a read's alignment results, plus 1" help="Reads with at least this number of alignments will have no alignments output"/>
+                    <param argument="--outFilterMismatchNmax" type="integer" value="10" min="0" label="Maximum number of mismatches to output an alignment, plus 1" help="Alignments with at least this number of mismatches will not be output"/>
+                    <param argument="--outFilterMismatchNoverLmax" type="float" value="0.3" min="0" max="1" label="Maximum ratio of mismatches to mapped length" help="Alignments with a mismatch ratio of at least this value will not be output"/>
+                    <param argument="--outFilterMismatchNoverReadLmax" type="float" value="1" min="0" max="1" label="Maximum ratio of mismatches to read length" help="Alignments with a mismatch ratio of at least this value will not be output"/>
+                    <param argument="--outFilterScoreMin" type="integer" value="0" min="0" label="Minimum alignment score" help="Alignments must have scores higher than this value to be output"/>
+                    <param argument="--outFilterScoreMinOverLread" type="float" value="0.66" min="0" max="1" label="Minimum alignment score, normalized to read length" help="Alignments must have (normalized) scores higher than this value to be output"/>
+                    <param argument="--outFilterMatchNmin" type="integer" value="0" min="0" label="Minimum number of matched bases" help="Alignments must have the number of matched bases higher than this value to be output"/>
+                    <param argument="--outFilterMatchNminOverLread" type="float" value="0.66" min="0" max="1" label="Minimum number of matched bases, normalized to read length" help="Alignments must have the (normalized) number of matched bases higher than this value to be output"/>
+                    <param argument="--outSAMmultNmax" type="integer" value="-1" min="-1" label="Maximum number of multimapping alignments to output for a read" help="A value of -1 (the default) results in all alignments (up to –-outFilterMultimapNmax) being output" />
+                    <param argument="--outSAMtlen" type="select" label="Calculation method for TLEN">
+                        <option value="1" selected="true">leftmost base of the (+)strand mate to rightmost base of the (-)mate. (+)sign for the (+)strand mate</option>
+                        <option value="2">leftmost base of any mate to rightmost base of any mate. (+)sign for the mate with the leftmost base. This is different from 1 for overlapping mates with protruding ends</option>
+                    </param>
+                </when>
+                <when value="no"/>
+            </conditional>
+        </section>
 
-            <when value="full">
-                <section name="seed" title="Seed parameters" expanded="False">
-                    <param argument="--seedSearchStartLmax" type="integer" min="1" value="50" label="Search start point through the read"/>
-                    <param argument="--seedSearchStartLmaxOverLread" type="float" min="0" value="1.0" label="Search start point through the read, normalized to read length"/>
-                    <param argument="--seedSearchLmax" type="integer" min="0" value="0" label="Maximum length of seeds" help="Default of 0 indicates no maximum length"/>
-                    <param argument="--seedMultimapNmax" type="integer" min="1" value="10000" label="Maximum number of mappings to use a piece in stitching"/>
-                    <param argument="--seedPerReadNmax" type="integer" min="1" value="1000" label="Maximum number of seeds per read"/>
-                    <param argument="--seedPerWindowNmax" type="integer" min="1" value="50" label="Maximum number of seeds per window"/>
-                    <param argument="--seedNoneLociPerWindow" type="integer" min="1" value="10" label="Maximum number of one seed loci per window"/>
-                </section>
-
-                <section name="align" title="Alignment parameters" expanded="False">
-                    <param argument="--alignIntronMin" name="alignIntronMin" type="integer" min="0" value="21" label="Minimum intron size"/>
-                    <param argument="--alignIntronMax" type="integer" min="0" value="0" label="Maximum intron size"/>
-                    <param argument="--alignMatesGapMax" type="integer" min="0" value="0" label="Maximum gap between two mates"/>
-                    <param argument="--alignSJoverhangMin" type="integer" min="1" value="5" label="Minimum overhang for spliced alignments"/>
-                    <param argument="--alignSJDBoverhangMin" type="integer" min="1" value="3" label="Minimum overhang for annotated spliced alignments"/>
-                    <param argument="--alignSplicedMateMapLmin" type="integer" min="0" value="0" label="Minimum mapped length for a read mate that is spliced"/>
-                    <param argument="--alignSplicedMateMapLminOverLmate" type="float" min="0" value="0.66" label="Minimum mapped length for a read mate that is spliced, normalized to mate length"/>
-                    <param argument="--alignWindowsPerReadNmax" type="integer" min="1" value="10000" label="Maximum number of windows per read"/>
-                    <param argument="--alignTranscriptsPerWindowNmax" type="integer" min="1" value="100" label="Maximum number of transcripts per window"/>
-                    <param argument="--alignTranscriptsPerReadNmax" type="integer" min="1" value="10000" label="Maximum number of different alignments per read to consider"/>
-                    <param argument="--alignEndsType" type="boolean" truevalue="EndToEnd" falsevalue="Local" checked="false" label="Use end-to-end read alignments, with no soft-clipping?"/>
-                </section>
+        <!-- Algorithmic settings. -->
+        <section name="algo" title="Algorithmic settings" expanded="true">
+            <conditional name="params">
+                <param name="settingsType" type="select" label="Configure seed, alignment and limits options">
+                    <option value="default" selected="true">Use Defaults</option>
+                    <option value="star_fusion">Use parameters suggested for STAR-Fusion</option>
+                    <option value="full">Extended parameter list</option>
+                </param>
+                <when value="default"/>
+                <!-- Set STAR-fusion parameters in command section -->
+                <when value="star_fusion"/>
 
-                <section name="twopass" title="Two pass mode" expanded="False">
-                    <param argument="--twopassMode" type="boolean" truevalue="Basic" falsevalue="None" checked="false" label="Use two pass mode to better map reads to unknown splice junctions"/>
-                    <param argument="--twopass1readsN" type="integer" min="-1" value="-1" label="Number of reads to map in the first pass (-1: all)"/>
-                </section>
-
-                <section name="limits" title="Limits" expanded="False">
-                    <param argument="--limitBAMsortRAM" type="integer" min="0" value="0" label="Maximum available RAM (in bytes) for sorting" help="If 0, this will be set to the genome index size. This is typically only changed in cases where an error is produced." />
-                    <param argument="--limitOutSJoneRead" type="integer" min="1" value="1000" label="Maximum number of junctions for one read (including all multimappers)" />
-                    <param argument="--limitOutSJcollapsed" type="integer" min="1" value="1000000" label="Maximum number of collapsed junctions" />
-                    <param argument="--limitSjdbInsertNsj" type="integer" min="0" value="1000000" label="Maximum number of inserts to be inserted into the genome on the fly." />
-                </section>
+                <when value="full">
+                    <section name="seed" title="Seed parameters" expanded="false">
+                        <param argument="--seedSearchStartLmax" type="integer" min="1" value="50" label="Search start point through the read"/>
+                        <param argument="--seedSearchStartLmaxOverLread" type="float" min="0" value="1.0" label="Search start point through the read, normalized to read length"/>
+                        <param argument="--seedSearchLmax" type="integer" min="0" value="0" label="Maximum length of seeds" help="Default of 0 indicates no maximum length"/>
+                        <param argument="--seedMultimapNmax" type="integer" min="1" value="10000" label="Maximum number of mappings to use a piece in stitching"/>
+                        <param argument="--seedPerReadNmax" type="integer" min="1" value="1000" label="Maximum number of seeds per read"/>
+                        <param argument="--seedPerWindowNmax" type="integer" min="1" value="50" label="Maximum number of seeds per window"/>
+                        <param argument="--seedNoneLociPerWindow" type="integer" min="1" value="10" label="Maximum number of one seed loci per window"/>
+                    </section>
 
-                <conditional name="chim">
-                    <param name="chim_select" type="select" label="Would you like to set chimeric alignment parameters?">
-                        <option value="no" selected="true">No</option>
-                        <option value="yes">Yes</option>
-                    </param>
-                    <when value="yes">
-                        <param argument="--chimSegmentMin" type="integer" min="0" value="0" label="Minimum length of chimeric segment" help="For small numbers this will cause large number of chimeric alignments. A value of 12 is commonly used. Default of 0 means no chimeric output">
-                            <validator type="in_range" min="1" message="To get chimeric reads this value needs to be larger than 0"/>
-                        </param>
-                        <param argument="--chimScoreMin" type="integer" min="0" value="0" label="Minimum total (summed) score of chimeric segments"/>
-                        <param argument="--chimScoreDropMax" type="integer" min="0" value="20" label="Maximum difference of chimeric score from read length"/>
-                        <param argument="--chimScoreSeparation" type="integer" min="0" value="10" label="Minimum difference between the best chimeric score and the next one"/>
-                        <param argument="--chimScoreJunctionNonGTAG" type="integer" value="-1" label="Penalty for a non-GT/AG chimeric junction"/>
-                        <param argument="--chimJunctionOverhangMin" type="integer" min="0" value="20" label="Minimum overhang for a chimeric junction"/>
-                        <param argument="--chimMainSegmentMultNmax" type="integer" min="1" value="10" label="Maximum number of multi-alignments for the main chimeric segment." help="A value of 1 prohibits multimapping main segments"/>
-                        <param argument="--chimMultimapNmax" type="integer" min="0" value="0" label="Maximum number of chimeric multi-alignments" help="A value of 0 (the default) only considers unique alignments" />
-                        <param argument="--chimMultimapScoreRange" type="integer" min="0" value="1" label="Score range for multi-mapping chimeras" help="The threshold below the best chimeric score that a multimapping chimera must have to be output. This is ignored unless --chimMultimapNmax is above 1" />
-                    </when>
-                    <when value="no"/>
-                </conditional>
-            </when>
-        </conditional>
+                    <section name="align" title="Alignment parameters" expanded="false">
+                        <param argument="--alignIntronMin" name="alignIntronMin" type="integer" min="0" value="21" label="Minimum intron size"/>
+                        <param argument="--alignIntronMax" type="integer" min="0" value="0" label="Maximum intron size"/>
+                        <param argument="--alignMatesGapMax" type="integer" min="0" value="0" label="Maximum gap between two mates"/>
+                        <param argument="--alignSJoverhangMin" type="integer" min="1" value="5" label="Minimum overhang for spliced alignments"/>
+                        <param argument="--alignSJDBoverhangMin" type="integer" min="1" value="3" label="Minimum overhang for annotated spliced alignments"/>
+                        <param argument="--alignSplicedMateMapLmin" type="integer" min="0" value="0" label="Minimum mapped length for a read mate that is spliced"/>
+                        <param argument="--alignSplicedMateMapLminOverLmate" type="float" min="0" value="0.66" label="Minimum mapped length for a read mate that is spliced, normalized to mate length"/>
+                        <param argument="--alignWindowsPerReadNmax" type="integer" min="1" value="10000" label="Maximum number of windows per read"/>
+                        <param argument="--alignTranscriptsPerWindowNmax" type="integer" min="1" value="100" label="Maximum number of transcripts per window"/>
+                        <param argument="--alignTranscriptsPerReadNmax" type="integer" min="1" value="10000" label="Maximum number of different alignments per read to consider"/>
+                        <param argument="--alignEndsType" type="boolean" truevalue="EndToEnd" falsevalue="Local" checked="false" label="Use end-to-end read alignments, with no soft-clipping?"/>
+                        <param argument="--peOverlapNbasesMin" type="integer" min="0" value="0"
+                        label="minimum number of overlap bases to trigger mates merging and realignment" />
+                        <param argument="--peOverlapMMp" type="float" min="0" max="1" value="0.01"
+                        label="maximum proportion of mismatched bases in the overlap area" />
+                    </section>
+                    <section name="chim_settings" title="Chimeric alignment parameters" expanded="false">
+                        <param argument="--chimSegmentMin" type="integer" min="1" value="12"
+                        label="Minimum length of chimeric segment"
+                        help="For small numbers this will cause large number of chimeric alignments. A value of 12 is commonly used." />
+                        <param argument="--chimScoreMin" type="integer" min="0" value="0"
+                        label="Minimum total (summed) score of chimeric segments"/>
+                        <param argument="--chimScoreDropMax" type="integer" min="0" value="20"
+                        label="Maximum difference of chimeric score from read length"/>
+                        <param argument="--chimScoreSeparation" type="integer" min="0" value="10"
+                        label="Minimum difference between the best chimeric score and the next one"/>
+                        <param argument="--chimScoreJunctionNonGTAG" type="integer" value="-1"
+                        label="Penalty for a non-GT/AG chimeric junction"/>
+                        <param argument="--chimJunctionOverhangMin" type="integer" min="0" value="20"
+                        label="Minimum overhang for a chimeric junction"/>
+                        <param argument="--chimSegmentReadGapMax" type="integer" min="0" value="0"
+                        label="Maximum gap in the read sequence between chimeric segments" />
+                        <param argument="--chimFilter" type="boolean" truevalue="banGenomicN" falsevalue="None" checked="true"
+                        label="Discard chimeric alignments with Ns in the genome sequence around the chimeric junction" />
+                        <param argument="--chimMainSegmentMultNmax" type="integer" min="1" value="10"
+                        label="Maximum number of multi-alignments for the main chimeric segment."
+                        help="A value of 1 prohibits multimapping main segments"/>
+                        <param argument="--chimMultimapNmax" type="integer" min="1" value="1"
+                        label="Maximum number of chimeric multi-alignments"
+                        help="The default value of 1 only considers unique alignments. If you chose to report chimeric alignments alongside regular ones in the BAM output, this setting is ignored and only uniquely mapping chimeric reads get reported. " />
+                        <param argument="--chimMultimapScoreRange" type="integer" min="0" value="1"
+                        label="Score range for multi-mapping chimeras"
+                        help="The threshold below the best chimeric score that a multimapping chimera must have to be output. This is ignored unless --chimMultimapNmax is above 1" />
+                    </section>
+                    <section name="limits" title="Limits" expanded="false">
+                        <param argument="--limitOutSJoneRead" type="integer" min="1" value="1000" label="Maximum number of junctions for one read (including all multimappers)" />
+                        <param argument="--limitOutSJcollapsed" type="integer" min="1" value="1000000" label="Maximum number of collapsed junctions" />
+                        <param argument="--limitSjdbInsertNsj" type="integer" min="0" value="1000000" label="Maximum number of inserts to be inserted into the genome on the fly." />
+                    </section>
+                </when>
+            </conditional>
+        </section>
+        <section name="perf" title="Performance tweaks / Troubleshooting" expanded="false">
+            <param argument="--outBAMsortingBinsN" type="integer" value="50" min="1" label="Number of genome bins for coordinate-sorting" help="Higher values result in lower RAM requirements during the sorting step. The default value is 50. Tweak this if you are facing memory-related errors." />
+        </section>
     </inputs>
 
     <outputs>
         <data format="txt" name="output_log" label="${tool.name} on ${on_string}: log" from_work_dir="Log.final.out">
             <expand macro="dbKeyActions" />
         </data>
+
         <data format="interval" name="chimeric_junctions" label="${tool.name} on ${on_string}: chimeric junctions" from_work_dir="Chimeric.out.junction">
-            <filter>params['settingsType'] == "star_fusion" or ( params['settingsType'] == "full" and params['chim']['chim_select'] == "yes" and params['chim']['chimSegmentMin'] > 0 )</filter>
-            <expand macro="dbKeyActions" />
-        </data>
-
-        <data format="bam" name="chimeric_reads" label="${tool.name} on ${on_string}: chimeric.bam" from_work_dir="ChimericSorted.bam">
-            <filter>params['settingsType'] == "full" and params['chim']['chim_select'] == "yes" and params['chim']['chimSegmentMin'] > 0</filter>
+            <filter>('Junctions' in chimOutType)</filter>
             <expand macro="dbKeyActions" />
         </data>
 
@@ -404,188 +476,420 @@
             <expand macro="dbKeyActions" />
         </data>
 
-        <data name="mapped_reads" format="bam" label="${tool.name} on ${on_string}: mapped.bam" from_work_dir="Aligned.sortedByCoord.out.bam">
+        <data name="mapped_reads" format="bam" label="${tool.name} on ${on_string}: mapped.bam">
+            <expand macro="dbKeyActions" />
+        </data>
+
+        <data name="transcriptome_mapped_reads" format="unsorted.bam" label="${tool.name} on ${on_string}: transcriptome-mapped.bam" >
+            <filter>'TranscriptomeSAM' in quantmode_output['quantMode']</filter>
             <expand macro="dbKeyActions" />
         </data>
 
         <data name="reads_per_gene" format="tabular" label="${tool.name} on ${on_string}: reads per gene" from_work_dir="ReadsPerGene.out.tab">
-            <filter>quantMode is True</filter>
+            <filter>'GeneCounts' in quantmode_output['quantMode']</filter>
             <expand macro="dbKeyActions" />
         </data>
     </outputs>
 
     <tests>
-        <test>
-            <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="tophat_test.fa" />
-            <param name="sPaired" value="single" />
-
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="settingsType" value="default" />
-
-            <output name="output_log" file="rnastar_test.log" compare="diff" lines_diff="12"/>
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="default" />
+                </conditional>
+            </section>
+            <output name="output_log" file="rnastar_test.log" compare="re_match_multiline" />
             <output name="splice_junctions" file="rnastar_test_splicejunctions.bed"/>
             <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
         </test>
-        <test><!-- tests gtf file and GeneCounts mode -->
-            <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="tophat_test.fa" />
+        <!-- test with cached genome index -->
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="indexed" />
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" value="with-gtf" />
+                    <param name="genomeDir" value="000" />
+                </conditional>
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="default" />
+                </conditional>
+            </section>
+            <output name="output_log" file="rnastar_test.log" compare="re_match_multiline" />
+            <output name="splice_junctions" file="rnastar_test_splicejunctions.bed"/>
+            <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
+        </test>
+        <!-- test gtf file and GeneCounts mode -->
+        <test expect_num_outputs="4">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" value="with-gtf" />
+                    <param name="sjdbOverhang" value="75"/>
+                    <param name="sjdbGTFfile" value="test1.gtf" ftype="gtf"/>
+                </conditional>
+            </conditional>
+            <conditional name="quantmode_output">
+                <param name="quantMode" value="GeneCounts"/>
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="default" />
+                </conditional>
+            </section>
 
-            <param name="sjdbOverhang" value="75"/>
-            <param name="sjdbGTFfile" value="test1.gtf" ftype="gtf"/>
-            <param name="quantMode" value="True"/>
-
-            <param name="sPaired" value="single" />
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="settingsType" value="default" />
-
-            <output name="output_log" file="rnastar_test.log" compare="diff" lines_diff="12"/>
+            <output name="output_log" file="rnastar_test.log" compare="re_match_multiline" />
             <output name="splice_junctions" file="rnastar_test_splicejunctions.bed"/>
             <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
             <output name="reads_per_gene" file="tophat_test_reads_per_gene.txt" />
         </test>
-        <test>
-            <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="tophat_test.fa" />
-            <param name="sPaired" value="single" />
+        <!-- test gtf file and TranscriptomeSAM mode -->
+        <test expect_num_outputs="4">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" value="with-gtf" />
+                    <param name="sjdbOverhang" value="75"/>
+                    <param name="sjdbGTFfile" value="test1.gtf" ftype="gtf"/>
+                </conditional>
+            </conditional>
+            <conditional name="quantmode_output">
+                <param name="quantMode" value="TranscriptomeSAM"/>
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="default" />
+                </conditional>
+            </section>
 
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="outFilterIntronMotifs" value="RemoveNoncanonical" />
+            <output name="output_log" file="rnastar_test.log" compare="re_match_multiline" />
+            <output name="splice_junctions" file="rnastar_test_splicejunctions.bed"/>
+            <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
+            <output name="transcriptome_mapped_reads" file="rnastar_test_transcriptome_mapped_reads.bam" />
+        </test>
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch,XS" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="filter">
+                <param name="basic_filters" value="exclude_unmapped,--outFilterIntronMotifs RemoveNoncanonical" />
+                <conditional name="output_params2">
+                    <param name="output_select2" value="yes" />
+                    <param name="outFilterScoreMinOverLread" value="0.9" />
+                </conditional>
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="full" />
+                    <section name="seed">
+                        <param name="seed_select" value="yes" />
+                        <param name="seedSearchStartLmax" value="25" />
+                    </section>
+                </conditional>
+            </section>
 
-            <param name="output_select2" value="yes" />
-            <param name="outFilterScoreMinOverLread" value="0.9" />
-            <param name="settingsType" value="full" />
-            <param name="seed_select" value="yes" />
-            <param name="seedSearchStartLmax" value="25" />
-
-            <output name="output_log" file="rnastar_test2.log" compare="diff" lines_diff="12"/>
+            <output name="output_log" file="rnastar_test2.log" compare="re_match_multiline" />
             <output name="splice_junctions" file="rnastar_test2_splicejunctions.bed"/>
             <output name="mapped_reads" file="rnastar_test2_mapped_reads.bam" compare="sim_size" delta="200" />
         </test>
-        <test>
-            <param name="input1" value="test3.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="test3.ref.fa" />
-            <param name="sPaired" value="single" />
-
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="settingsType" value="star_fusion" />
-
-            <output name="chimeric_junctions" file="test3.chimjunc.tabular"/>
-        </test>
-        <test><!-- tests fastqsanger.gz -->
-            <param name="input1" value="test3.fastqsanger.gz" ftype="fastqsanger.gz" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="test3.ref.fa" />
-            <param name="sPaired" value="single" />
+        <test expect_num_outputs="4">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="test3.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="test3.ref.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <param name="chimOutType" value="Junctions" />
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch,XS" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="star_fusion" />
+                </conditional>
+            </section>
 
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="settingsType" value="star_fusion" />
+            <output name="chimeric_junctions" file="test3.chimjunc.tabular" compare="diff" lines_diff="2"/>
+        </test>
+        <test expect_num_outputs="4"><!-- tests fastqsanger.gz -->
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="test3.fastqsanger.gz" ftype="fastqsanger.gz" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="test3.ref.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <param name="chimOutType" value="Junctions" />
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch,XS" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="star_fusion" />
+                </conditional>
+            </section>
 
-            <output name="chimeric_junctions" file="test3.chimjunc.tabular"/>
+            <output name="chimeric_junctions" file="test3.chimjunc.tabular" compare="diff" lines_diff="2"/>
         </test>
-        <test>
-            <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="tophat_test.fa" />
-            <param name="sPaired" value="single" />
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="filter">
+                <param name="basic_filters" value="--outFilterIntronMotifs RemoveNoncanonical" />
+                <conditional name="output_params2">
+                    <param name="output_select2" value="yes" />
+                </conditional>
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="full" />
+                </conditional>
+            </section>
 
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="outFilterIntronMotifs" value="RemoveNoncanonical" />
-
-            <param name="output_select2" value="yes" />
-            <param name="settingsType" value="full" />
-            <param name="chim_select" value="false" />
-
-            <output name="output_log" file="rnastar_test.log" compare="diff" lines_diff="12"/>
+            <output name="output_log" file="rnastar_test.log" compare="re_match_multiline" />
             <output name="splice_junctions" file="rnastar_test_splicejunctions.bed"/>
             <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
         </test>
-        <test>
-            <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
-            <param name="geneSource" value="history" />
-            <param name="genomeFastaFiles" value="tophat_test.fa" />
-            <param name="sPaired" value="single" />
+        <!-- twopass mode tests -->
+        <!-- test Basic twopass -->
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <conditional name="twopass">
+                <param name="twopassMode" value="Basic" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="filter">
+                <param name="basic_filters" value="exclude_unmapped,--outFilterIntronMotifs RemoveNoncanonical" />
+                <conditional name="output_params2">
+                    <param name="output_select2" value="yes" />
+                </conditional>
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="full" />
+                </conditional>
+            </section>
 
-            <param name="output_select" value="yes" />
-            <param name="outSAMattributes" value="All" />
-            <param name="outSAMstrandField" value="intronMotif" />
-            <param name="outFilterIntronMotifs" value="RemoveNoncanonical" />
+            <output name="output_log" file="rnastar_test_twopass.log" compare="re_match_multiline" />
+            <output name="splice_junctions" file="rnastar_test_splicejunctions_twopass.bed"/>
+            <output name="mapped_reads" file="rnastar_test_mapped_reads_twopass.bam" compare="sim_size" delta="634" />
+        </test>
+        <!-- test Basic twopass without a gtf file option -->
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="indexed" />
+                <conditional name="GTFconditional">
+                    <param name="GTFselect" value="without-gtf" />
+                    <param name="genomeDir" value="001" />
+                </conditional>
+            </conditional>
+            <conditional name="twopass">
+                <param name="twopassMode" value="Basic" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="filter">
+                <param name="basic_filters" value="exclude_unmapped,--outFilterIntronMotifs RemoveNoncanonical" />
+                <conditional name="output_params2">
+                    <param name="output_select2" value="yes" />
+                </conditional>
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="full" />
+                </conditional>
+            </section>
 
-            <param name="output_select2" value="yes" />
-            <param name="settingsType" value="full" />
-            <param name="twopass" value="true" />
-            <param name="twopassMode" value="Basic" />
-            <param name="chim_select" value="false" />
+            <output name="output_log" file="rnastar_test_twopass.log" compare="re_match_multiline" />
+            <output name="splice_junctions" file="rnastar_test_splicejunctions_twopass.bed"/>
+            <output name="mapped_reads" file="rnastar_test_mapped_reads_twopass.bam" compare="sim_size" delta="634" />
+        </test>
+        <!-- test "multisample" twopass -->
+        <test expect_num_outputs="3">
+            <conditional name="singlePaired">
+                <param name="sPaired" value="single" />
+                <param name="input1" value="tophat_in2.fastqsanger" ftype="fastqsanger" />
+            </conditional>
+            <conditional name="refGenomeSource">
+                <param name="geneSource" value="history" />
+                <param name="genomeFastaFiles" value="tophat_test.fa" />
+                <param name="genomeSAindexNbases" value="5" />
+            </conditional>
+            <conditional name="twopass">
+                <param name="twopassMode" value="None --sjdbFileChrStartEnd" />
+                <param name="sj_precalculated" value="rnastar_test_splicejunctions_twopass.bed" />
+            </conditional>
+            <section name="oformat">
+                <param name="outSAMattributes" value="NH,HI,AS,nM,NM,MD,jM,jI,MC,ch" />
+                <param name="outSAMmapqUnique" value="255" />
+            </section>
+            <section name="filter">
+                <param name="basic_filters" value="exclude_unmapped,--outFilterIntronMotifs RemoveNoncanonicalUnannotated,--outFilterIntronMotifs RemoveNoncanonical" />
+                <conditional name="output_params2">
+                    <param name="output_select2" value="yes" />
+                </conditional>
+            </section>
+            <section name="algo">
+                <conditional name="params">
+                    <param name="settingsType" value="full" />
+                </conditional>
+            </section>
 
-            <output name="output_log" file="rnastar_test_twopass.log" compare="diff" lines_diff="12"/>
+            <output name="output_log" file="rnastar_test_twopass.log" compare="re_match_multiline" />
             <output name="splice_junctions" file="rnastar_test_splicejunctions_twopass.bed"/>
-            <output name="mapped_reads" file="rnastar_test_mapped_reads.bam" compare="sim_size" delta="634" />
+            <output name="mapped_reads" file="rnastar_test_mapped_reads_twopass.bam" compare="sim_size" delta="634" />
         </test>
     </tests>
-    <help>
+    <help><![CDATA[
 **What it does**
 
-STAR is an ultrafast universal RNA-seq aligner.
+STAR_ is an ultrafast universal RNA-seq aligner.
 
-**Extra SAM attributes**
+**Compatibility Notes**
+
+STAR has a huge amount of options to filter alignments and to configure the
+exact format of its output.
 
-The Standard option includes the following four attributes::
+Some tools you may plan to use in your downstream analysis of the results are known to be sensitive to these settings or combinations of them.
+
+*STAR-Fusion*
 
-  NH: Number of reported alignments that contain the query in the current record.
-  HI: Query hit index, indicating the alignment record is the i-th one stored in SAM
-  AS: Local alignment score (paired for paired-end reads)
-  nM: Number of mismatches per (paired) alignment
+STAR-Fusion_ can use the chimeric junctions output of STAR as input, but you
+need to enable **chimeric alignment detection** by STAR for that dataset to be
+generated. Hence, be sure to select:
 
-The All option includes the Standard attributes, plus the following four::
+**Report chimeric alignments?**: `As separate tabular "Junctions" output (Junctions)`.
+
+In addition, for best results it is recommended_ that you
+
+- use **2-pass mapping** for more sensitive novel splice junction discovery
 
-  NM: Edit distance to the reference, including ambiguous bases but excluding clipping
-  MD: String for mismatching positions
-  jM: Intron motifs for all junctions
-  jI: Start and end of introns for all junctions
+- under *BAM output format specification*,
+  **Read alignment tags to include in the BAM output**: select `XS` as an
+  additional tag to generate (this is the equivalent of using
+  `--outSAMstrandField intronMotif` on the command line)
 
-**STAR-Fusion**
+- under *Algorithmic settings*, **Configure seed, alignment and limits options**:
+  `use parameters suggested for STAR-Fusion`.
 
-STAR-Fusion_ is used to identify candidate fusion transcripts. The recommended_ parameters for running
-STAR prior to STAR-Fusion can be pre-selected.
+*Cufflinks*
 
-**Attributions**
-
-rna_star - see the web site at rna_star_
+.. class:: infomark
 
-For details, please see the rna_starMS_
-"STAR: ultrafast universal RNA-seq aligner"
-A. Dobin et al, Bioinformatics 2012; doi: 10.1093/bioinformatics/bts635
+   Cufflinks is not considered to be the best tool for use downstream of STAR
+   anymore. Consider using *Stringtie* instead, which also should pose no
+   compatibility issues.
 
-Galaxy_ (that's what you are using right now!) for gluing everything together
-
-Most of the work for this wrapper XML is Jeremy Goecks' original STAR wrapper
+To avoid compatibility issues with Cufflinks you should:
 
-Minor tweaks to output names to suit our downstream purposes, toolshed automated dependencies
-and odds and ends of other code and documentation comprising this tool was
-written by Ross Lazarus and that part is licensed_ the same way as other rgenetics artefacts
+- select **XS** as a *Read alignment tag to include in the BAM output* if (and
+  only if) your sequenced reads come from an unstranded library prep
+- *not* select the *jM* and *jI* tags for inclusion
+- keep the **HI** tag selected and
+- select *HI tag values should be* **zero-based**
+- exclude **All alignments across non-canonical junctions** under *Output
+  filter criteria -> Exclude the following records from the BAM output*
+
+-----
 
-.. _licensed: http://creativecommons.org/licenses/by-nc-nd/3.0/
+Attribution
+
+Minor tweaks to output names to suit downstream purposes, toolshed automated
+dependencies and odds and ends of other code and documentation comprising
+this tool were originally written by Ross Lazarus and have been licensed under
+the creative commons
+`BY-NC_ND 3.0 license <http://creativecommons.org/licenses/by-nc-nd/3.0/>`__.
+
+.. _STAR: https://github.com/alexdobin/STAR
 .. _STAR-Fusion: https://github.com/STAR-Fusion/STAR-Fusion
-.. _recommended: https://github.com/STAR-Fusion/STAR-Fusion/wiki#alternatively-running-star-yourself-and-then-running-star-fusion-using-the-existing-outputs
-.. _rna_star: https://github.com/alexdobin/STAR
-.. _rna_starMS: http://bioinformatics.oxfordjournals.org/content/29/1/15.full
-.. _Galaxy: http://getgalaxy.org
-    </help>
+.. _recommended: https://github.com/STAR-Fusion/STAR-Fusion/wiki#alternatively-kickstart-mode-running-star-yourself-and-then-running-star-fusion-using-the-existing-outputs
+    ]]></help>
     <expand macro="citations"/>
 </tool>
Binary file test-data/41737_R1.fastq.sub240k.gz has changed
Binary file test-data/41737_R2.fastq.sub240k.gz has changed
Binary file test-data/737K-august-2016.small.txt.gz has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/SNORD83B.22.fa	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,17 @@
+>22 dna:chromosome chromosome:GRCh38:22:39313740:50818468:1 REF
+CACACTCAAAGCAGCAAACAGCCCAGCAAGGCCAGACTGGGAATTTCCTCATCTCAGGAC
+TTCAAAGCCAGTGTGAAAGGACTGCCAACACCCTCTCCTTCCTTTCCTCTCCCACCACAG
+GGCCACCAGCGTCTGTGGCCTTGGATCCTCCCTCTACAAGAGCCCCCCCATGACAAGTCA
+GGACCTGCCTCACCTTGCGGAGGGTGAGCACCCGCTTCTTGGTTCCCACCACACAGCCTT
+TCAGCATGACAAAGTCATTGGTCACTTCACCATAGTGGACAAAGCCACCCTGGAAAACGA
+GCATCGGATCAGCACAGGCCCAGGAGGGGATTGTCGTGCAGATGACCCCTCCAGGTTCAG
+GCCCTCCCTGACCACAGGGCTGTTCTCAGAAGGAAGGCAACAAGGAACGGTTCCGCAGTC
+TGTCTCGGGCGCTGTGCCCAGCGCACATTCCAGGCCTCATCACTGAACAGCTGAGCCTGA
+GACCCCACTTCTCACCAGCCAACCCCGACGAGTGGACTCAGATGACAACATGCCACTTAC
+AAGGGACACAGCTAGGTGTTGTGTTGGCTTCAGTTAACGATCCTGCTAGCAGCCCCTAGG
+AAGCAGCCTATCCCCAAAAGCACGAGGCCTGGGATGGCCTCACAGAGCAGAACACCCATT
+ACTTACCAGAGGGTTGATGCTCTTGTCAGATAGGTCATAGTCAGTGGAGGCATTGTTCTT
+GATCAGCTTGCCGTCCTTGATAAGGTAGCCCTGGCCAATCTTATAAATCTGAATGAACAA
+GAAGGGTGTAAGGCTGGGGCATTAGGGACAAATAACCCAGACATGCCAGTGTGCTGACCT
+GCAAAGCACGCTAGAAGGCAGCTGAGGCCTCAGTCCCAGTCACAGCGTATCCCAAGGTCA
+GAGCAAAAAGCTGGCTGGCCCTCCAGGTTCCTTTCTGTAAGGCGGCTGGGCTAAAACTAA
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/SNORD83B.22.gtf	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,8 @@
+#!genome-build GRCh38.p12
+#!genome-version GRCh38
+#!genome-date 2013-12
+#!genome-build-accession NCBI:GCA_000001405.27
+#!genebuild-last-updated 2018-11
+22	ensembl	gene	39313819	39313911	.	-	.	gene_id "ENSG00000209480"; gene_version "1"; gene_name "SNORD83B"; gene_source "ensembl"; gene_biotype "snoRNA";
+22	ensembl	transcript	39313819	39313911	.	-	.	gene_id "ENSG00000209480"; gene_version "1"; transcript_id "ENST00000386745"; transcript_version "1"; gene_name "SNORD83B"; gene_source "ensembl"; gene_biotype "snoRNA"; transcript_name "SNORD83B-201"; transcript_source "ensembl"; transcript_biotype "snoRNA"; tag "basic"; transcript_support_level "NA";
+22	ensembl	exon	39313819	39313911	.	-	.	gene_id "ENSG00000209480"; gene_version "1"; transcript_id "ENST00000386745"; transcript_version "1"; exon_number "1"; gene_name "SNORD83B"; gene_source "ensembl"; gene_biotype "snoRNA"; transcript_name "SNORD83B-201"; transcript_source "ensembl"; transcript_biotype "snoRNA"; exon_id "ENSE00001501751"; exon_version "1"; tag "basic"; transcript_support_level "NA";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/rnastar_index2_versioned.loc	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,4 @@
+##STAR versioned indexes
+#build_id	dbkey	display_name	path	with_gene_model	version
+000	?	test_index	${__HERE__}/test-cache/tophat-test	0	2.7.1a
+001	?	test_index2	${__HERE__}/test-cache/tophat-test	1	2.7.1a
--- a/test-data/rnastar_test.log	Thu Mar 14 16:12:38 2019 -0400
+++ b/test-data/rnastar_test.log	Thu Aug 15 01:54:13 2019 -0400
@@ -1,7 +1,7 @@
-                                 Started job on |	Mar 01 15:54:22
-                             Started mapping on |	Mar 01 15:54:25
-                                    Finished on |	Mar 01 15:54:25
-       Mapping speed, Million of reads per hour |	inf
+                                 Started job on |	.*
+                             Started mapping on |	.*
+                                    Finished on |	.*
+       Mapping speed, Million of reads per hour |	.*
 
                           Number of input reads |	100
                       Average input read length |	75
--- a/test-data/rnastar_test2.log	Thu Mar 14 16:12:38 2019 -0400
+++ b/test-data/rnastar_test2.log	Thu Aug 15 01:54:13 2019 -0400
@@ -1,7 +1,7 @@
-                                 Started job on |	Mar 01 15:53:05
-                             Started mapping on |	Mar 01 15:53:08
-                                    Finished on |	Mar 01 15:53:08
-       Mapping speed, Million of reads per hour |	inf
+                                 Started job on |	.*
+                             Started mapping on |	.*
+                                    Finished on |	.*
+       Mapping speed, Million of reads per hour |	.*
 
                           Number of input reads |	100
                       Average input read length |	75
Binary file test-data/rnastar_test2_mapped_reads.bam has changed
Binary file test-data/rnastar_test_mapped_reads.bam has changed
Binary file test-data/rnastar_test_mapped_reads_twopass.bam has changed
Binary file test-data/rnastar_test_transcriptome_mapped_reads.bam has changed
--- a/test-data/rnastar_test_twopass.log	Thu Mar 14 16:12:38 2019 -0400
+++ b/test-data/rnastar_test_twopass.log	Thu Aug 15 01:54:13 2019 -0400
@@ -1,7 +1,7 @@
-                                 Started job on |	Feb 12 11:19:46
-                             Started mapping on |	Feb 12 11:20:03
-                                    Finished on |	Feb 12 11:20:03
-       Mapping speed, Million of reads per hour |	inf
+                                 Started job on |	.*
+                             Started mapping on |	.*
+                                    Finished on |	.*
+       Mapping speed, Million of reads per hour |	.*
 
                           Number of input reads |	100
                       Average input read length |	75
Binary file test-data/test-cache/tophat-test/Genome has changed
Binary file test-data/test-cache/tophat-test/SA has changed
Binary file test-data/test-cache/tophat-test/SAindex has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test-cache/tophat-test/chrLength.txt	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,1 @@
+650
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test-cache/tophat-test/chrName.txt	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,1 @@
+test_chromosome
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test-cache/tophat-test/chrNameLength.txt	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,1 @@
+test_chromosome	650
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test-cache/tophat-test/chrStart.txt	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,2 @@
+0
+262144
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test-cache/tophat-test/genomeParameters.txt	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,16 @@
+### STAR   --runMode genomeGenerate   --genomeDir test-cache/tophat_test/   --genomeFastaFiles tophat_test.fa      --genomeSAindexNbases 5
+### GstrandBit 32
+versionGenome	2.7.1a
+genomeFastaFiles	tophat_test.fa 
+genomeSAindexNbases	5
+genomeChrBinNbits	18
+genomeSAsparseD	1
+sjdbOverhang	0
+sjdbFileChrStartEnd	- 
+sjdbGTFfile	-
+sjdbGTFchrPrefix	-
+sjdbGTFfeatureExon	exon
+sjdbGTFtagExonParentTranscript	transcript_id
+sjdbGTFtagExonParentGene	gene_id
+sjdbInsertSave	Basic
+genomeFileSizes	262144 5366
--- a/test-data/test3.chimjunc.tabular	Thu Mar 14 16:12:38 2019 -0400
+++ b/test-data/test3.chimjunc.tabular	Thu Aug 15 01:54:13 2019 -0400
@@ -1,24 +1,27 @@
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_60	181	60M15S	241	60S15M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_62	183	58M17S	241	58S17M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_64	185	56M19S	241	56S19M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_66	187	54M21S	241	54S21M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_68	189	52M23S	241	52S23M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_70	191	50M25S	241	50S25M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_72	193	48M27S	241	48S27M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_74	195	46M29S	241	46S29M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_76	197	44M31S	241	44S31M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_78	199	42M33S	241	42S33M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_80	201	40M35S	241	40S35M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_82	203	38M37S	241	38S37M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_84	205	36M39S	241	36S39M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_86	207	34M41S	241	34S41M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_88	209	32M43S	241	32S43M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_90	211	30M45S	241	30S45M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_92	213	28M47S	241	28S47M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_94	215	26M49S	241	26S49M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_96	217	24M51S	241	24S51M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_98	219	22M53S	241	22S53M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_100	221	20M55S	241	20S55M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_102	223	18M57S	241	18S57M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_104	225	16M59S	241	16S59M
-chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_106	227	14M61S	241	14S61M
+chr_donorA	brkpt_donorA	strand_donorA	chr_acceptorB	brkpt_acceptorB	strand_acceptorB	junction_type	repeat_left_lenA	repeat_right_lenB	read_name	start_alnA	cigar_alnA	start_alnB	cigar_alnB	num_chim_aln	max_poss_aln_score	non_chim_aln_score	this_chim_aln_score	bestall_chim_aln_score	PEmerged_bool	readgrp
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_60	181	60M15S	241	60S15M	1	75	59	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_62	183	58M17S	241	58S17M	1	75	57	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_64	185	56M19S	241	56S19M	1	75	55	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_66	187	54M21S	241	54S21M	1	75	53	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_68	189	52M23S	241	52S23M	1	75	51	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_70	191	50M25S	241	50S25M	1	75	49	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_72	193	48M27S	241	48S27M	1	75	47	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_74	195	46M29S	241	46S29M	1	75	45	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_76	197	44M31S	241	44S31M	1	75	43	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_78	199	42M33S	241	42S33M	1	75	41	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_80	201	40M35S	241	40S35M	1	75	39	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_82	203	38M37S	241	38S37M	1	75	37	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_84	205	36M39S	241	36S39M	1	75	38	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_86	207	34M41S	241	34S41M	1	75	40	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_88	209	32M43S	241	32S43M	1	75	42	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_90	211	30M45S	241	30S45M	1	75	44	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_92	213	28M47S	241	28S47M	1	75	46	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_94	215	26M49S	241	26S49M	1	75	48	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_96	217	24M51S	241	24S51M	1	75	50	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_98	219	22M53S	241	22S53M	1	75	52	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_100	221	20M55S	241	20S55M	1	75	54	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_102	223	18M57S	241	18S57M	1	75	56	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_104	225	16M59S	241	16S59M	1	75	58	72	72	0
+chr1	241	+	chr2	240	+	0	0	0	test_chimeric_mRNA_106	227	14M61S	241	14S61M	1	75	60	72	72	0
+# 2.7.2a   STAR --runThreadN 1 --genomeLoad NoSharedMemory --genomeDir tempstargenomedir @ --readFilesIn /tmp/tmpTNNe38/files/2/7/0/dataset_2700161e-e03d-4a50-9bc8-1508ff059881.dat --readFilesCommand zcat --outSAMtype BAM SortedByCoordinate --twopassMode None  --quantMode - --outSAMstrandField intronMotif --outSAMattrIHstart 1 --outSAMattributes NH HI AS nM NM MD jM jI MC ch --outSAMprimaryFlag OneBestScore --outSAMmapqUnique 255 --outSAMunmapped Within --chimSegmentMin 12 --chimJunctionOverhangMin 12 --alignSJDBoverhangMin 10 --alignMatesGapMax 100000 --alignIntronMax 100000 --chimSegmentReadGapMax 3 --alignSJstitchMismatchNmax 5 -1 5 5 --peOverlapNbasesMin 12 --peOverlapMMp 0.1 --chimMultimapScoreRange 10 --chimMultimapNmax 10 --chimNonchimScoreDropMin 10 --outBAMsortingThreadN 1 --outBAMsortingBinsN 50 --limitBAMsortRAM 0 --chimOutType Junctions --chimOutJunctionFormat 1
+# Nreads 83	NreadsUnique 72	NreadsMulti 0
--- a/tool-data/rnastar_index2.loc.sample	Thu Mar 14 16:12:38 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#This is a sample file distributed with Galaxy that enables tools
-#to use a directory of rna-star indexed sequences data files. You will
-#need to create these data files and then create a rnastar_index2.loc
-#file similar to this one (store it in this directory) that points to
-#the directories in which those files are stored. The rnastar_index2.loc
-#file has this format (longer white space characters are TAB characters):
-#
-#<unique_build_id>   <dbkey>   <display_name>   <file_base_path>	<withGTF>
-#
-#The <with_gtf> column should be 1 or 0, indicating whether the index was made
-#with an annotation (i.e., --sjdbGTFfile and --sjdbOverhang were used) or not,
-#respecively.
-#
-#Note that STAR indices can become quite large. Consequently, it is only
-#advisable to create indices with annotations if it's known ahead of time that
-#(A) the annotations won't be frequently updated and (B) the read lengths used
-#will also rarely vary. If either of these is not the case, it's advisable to
-#create indices without annotations and then specify an annotation file and
-#maximum read length (minus 1) when running STAR.
-#
-#hg19   hg19    hg19 full   /mnt/galaxyIndices/genomes/hg19/rnastar	0
-#hg19Ensembl   hg19Ensembl    hg19 full with Ensembl annotation   /mnt/galaxyIndices/genomes/hg19Ensembl/rnastar	1
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/rnastar_index2_versioned.loc.sample	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,26 @@
+#This is a sample file distributed with Galaxy that enables tools
+#to use a directory of rna-star indexed sequences data files. You will
+#need to create these data files and then create a rnastar_index2.loc
+#file similar to this one (store it in this directory) that points to
+#the directories in which those files are stored. The rnastar_index2.loc
+#file has this format (longer white space characters are TAB characters):
+#
+#<unique_build_id>   <dbkey>   <display_name>   <file_base_path>	<with_gene_model>	<version>
+#
+#The <with_gene_model> column should be 1 or 0, indicating whether the index
+#was built with annotations (i.e., --sjdbGTFfile and --sjdbOverhang were used)
+#or not.
+#
+#The <version> column indicates the STAR version that introduced the format of
+#the index, i.e., the oldest STAR version that could make use of the index.
+#
+#Note that STAR indices can become quite large. Consequently, it is only
+#advisable to create indices with annotations if it's known ahead of time that
+#(A) the annotations won't be frequently updated and (B) the read lengths used
+#will also rarely vary. If either of these is not the case, it's advisable to
+#create indices without annotations and then specify an annotation file and
+#maximum read length (minus 1) when running STAR.
+#
+#hg19   hg19    hg19 full   /mnt/galaxyIndices/genomes/hg19/rnastar	0	2.7.1a
+#hg19Ensembl   hg19Ensembl    hg19 full with Ensembl annotation   /mnt/galaxyIndices/genomes/hg19Ensembl/rnastar	1	2.7.1a
+
--- a/tool_data_table_conf.xml.sample	Thu Mar 14 16:12:38 2019 -0400
+++ b/tool_data_table_conf.xml.sample	Thu Aug 15 01:54:13 2019 -0400
@@ -1,7 +1,6 @@
-<!-- Use the file tool_data_table_conf.xml.oldlocstyle if you don't want to update your loc files as changed in revision 4550:535d276c92bc-->
 <tables>
-    <table name="rnastar_index2" comment_char="#" allow_duplicate_entries="False">
-        <columns>value, dbkey, name, path, with-gtf</columns>
-        <file path="tool-data/rnastar_index2.loc" />
+    <table name="rnastar_index2_versioned" comment_char="#" allow_duplicate_entries="False">
+        <columns>value, dbkey, name, path, with-gtf, version</columns>
+        <file path="tool-data/rnastar_index2_versioned.loc" />
     </table>
 </tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.test	Thu Aug 15 01:54:13 2019 -0400
@@ -0,0 +1,7 @@
+<tables>
+    <!-- Location of rnastar indexes for testing -->
+    <table name="rnastar_index2_versioned" comment_char="#" allow_duplicate_entries="False">
+        <columns>value, dbkey, name, path, with-gtf, version</columns>
+        <file path="${__HERE__}/test-data/rnastar_index2_versioned.loc" />
+    </table>
+</tables>