changeset 4:1551b0dd2d16 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/samtools/cram_to_bam commit 0f75269223c0821c6c82acf98fde947d0f816f2b"
author iuc
date Tue, 28 Sep 2021 16:11:03 +0000
parents 858ada516d8f
children 634df184b2a8
files macros.xml samtools_cram_to_bam.xml test-data/sam_to_bam_out2.bam test-data/test.bam test-data/test.bed test-data/test.cram test-data/test.fa test-data/test.sam test-data/test2.cram
diffstat 9 files changed, 119 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/macros.xml	Sat Jul 31 07:26:19 2021 +0000
+++ b/macros.xml	Tue Sep 28 16:11:03 2021 +0000
@@ -5,10 +5,16 @@
             <yield/>
         </requirements>
     </xml>
-    <token name="@TOOL_VERSION@">1.9</token>
-    <token name="@FLAGS@">#set $flags = sum(map(int, str($filter).split(',')))</token>
+    <token name="@TOOL_VERSION@">1.13</token>
+    <token name="@PROFILE@">20.05</token>
+    <token name="@FLAGS@"><![CDATA[
+        #set $flags = 0
+        #if $filter
+            #set $flags = sum(map(int, str($filter).split(',')))
+        #end if
+    ]]></token>
     <token name="@PREPARE_IDX@"><![CDATA[
-        ##prepare input and indices 
+        ##prepare input and indices
         ln -s '$input' infile &&
         #if $input.is_of_type('bam'):
             #if str( $input.metadata.bam_index ) != "None":
@@ -25,7 +31,7 @@
         #end if
     ]]></token>
     <token name="@PREPARE_IDX_MULTIPLE@"><![CDATA[
-        ##prepare input and indices 
+        ##prepare input and indices
         #for $i, $bam in enumerate( $input_bams ):
             ln -s '$bam' '${i}' &&
             #if $bam.is_of_type('bam'):
@@ -63,6 +69,51 @@
             #set reffai=None
         #end if
     ]]></token>
+
+    <xml name="optional_reference">
+        <conditional name="addref_cond">
+            <param name="addref_select" type="select" label="Use a reference sequence">
+                <help>@HELP@</help>
+                <option value="no">No</option>
+                <option value="history">Use a genome/index from the history</option>
+                <option value="cached">Use a built-in genome</option>
+            </param>
+            <when value="no"/>
+            <when value="history">
+                <param name="ref" argument="@ARGUMENT@" type="data" format="fasta,fasta.gz" label="Reference"/>
+            </when>
+            <when value="cached">
+                <param name="ref" argument="@ARGUMENT@" type="select" label="Reference">
+                    <options from_data_table="fasta_indexes">
+                        <filter type="data_meta" ref="input" key="dbkey" column="dbkey"/>
+                    </options>
+                    <validator  type="no_options" message="No reference genome is available for the build associated with the selected input dataset"/>
+                </param>
+            </when>
+        </conditional>
+    </xml>
+    <xml name="mandatory_reference" token_help="" token_argument="">
+        <conditional name="addref_cond">
+            <param name="addref_select" type="select" label="Use a reference sequence">
+                <help>@HELP@</help>
+                <option value="history">Use a genome/index from the history</option>
+                <option value="cached">Use a built-in genome</option>
+            </param>
+            <when value="history">
+                <param name="ref" argument="@ARGUMENT@" type="data" format="fasta,fasta.gz" label="Reference"/>
+            </when>
+            <when value="cached">
+                <param name="ref" argument="@ARGUMENT@" type="select" label="Reference">
+                    <options from_data_table="fasta_indexes">
+                        <filter type="data_meta" ref="input" key="dbkey" column="dbkey"/>
+                        <validator message="No reference genome is available for the build associated with the selected input dataset" type="no_options" />
+                    </options>
+                </param>
+            </when>
+        </conditional>
+    </xml>
+
+
     <token name="@ADDTHREADS@"><![CDATA[
         ##compute the number of ADDITIONAL threads to be used by samtools (-@)
         addthreads=\${GALAXY_SLOTS:-1} && (( addthreads-- )) &&
@@ -70,28 +121,28 @@
     <token name="@ADDMEMORY@"><![CDATA[
         ##compute the number of memory available to samtools sort (-m)
         ##use only 75% of available: https://github.com/samtools/samtools/issues/831
-        addmemory=\${GALAXY_MEMORY_MB_PER_SLOT:-768} && 
+        addmemory=\${GALAXY_MEMORY_MB_PER_SLOT:-768} &&
         ((addmemory=addmemory*75/100)) &&
     ]]></token>
     <xml name="seed_input">
-       <param name="seed" type="integer" optional="True" label="Seed for random number generator" help="If empty a random seed is used." /> 
+       <param name="seed" type="integer" optional="True" label="Seed for random number generator" help="If empty a random seed is used." />
     </xml>
-    <xml name="flag_options">
-        <option value="1">Read is paired</option>
-        <option value="2">Read is mapped in a proper pair</option>
-        <option value="4">Read is unmapped</option>
-        <option value="8">Mate is unmapped</option>
-        <option value="16">Read is mapped to the reverse strand of the reference</option>
-        <option value="32">Mate is mapped to the reverse strand of the reference</option>
-        <option value="64">Read is the first in a pair</option>
-        <option value="128">Read is the second in a pair</option>
-        <option value="256">Alignment of the read is not primary</option>
-        <option value="512">Read fails platform/vendor quality checks</option>
-        <option value="1024">Read is a PCR or optical duplicate</option>
-        <option value="2048">Alignment is supplementary</option>
+    <xml name="flag_options" token_s1="false" token_s2="false" token_s4="false" token_s8="false" token_s16="false" token_s32="false" token_s64="false" token_s128="false" token_s256="false" token_s512="false" token_s1024="false" token_s2048="false">
+        <option value="1" selected="@S1@">Read is paired</option>
+        <option value="2" selected="@S2@">Read is mapped in a proper pair</option>
+        <option value="4" selected="@S4@">Read is unmapped</option>
+        <option value="8" selected="@S8@">Mate is unmapped</option>
+        <option value="16" selected="@S16@">Read is mapped to the reverse strand of the reference</option>
+        <option value="32" selected="@S32@">Mate is mapped to the reverse strand of the reference</option>
+        <option value="64" selected="@S64@">Read is the first in a pair</option>
+        <option value="128" selected="@S128@">Read is the second in a pair</option>
+        <option value="256" selected="@S256@">Alignment of the read is not primary</option>
+        <option value="512" selected="@S512@">Read fails platform/vendor quality checks</option>
+        <option value="1024" selected="@S1024@">Read is a PCR or optical duplicate</option>
+        <option value="2048" selected="@S2048@">Alignment is supplementary</option>
     </xml>
 
-    <!-- region specification macros and tokens for tools that allow the specification 
+    <!-- region specification macros and tokens for tools that allow the specification
          of region by bed file / space separated list of regions -->
     <token name="@REGIONS_FILE@"><![CDATA[
         #if $cond_region.select_region == 'tab':
--- a/samtools_cram_to_bam.xml	Sat Jul 31 07:26:19 2021 +0000
+++ b/samtools_cram_to_bam.xml	Tue Sep 28 16:11:03 2021 +0000
@@ -1,4 +1,4 @@
-<tool id="samtools_cram_to_bam" name="samtools CRAM to BAM" version="@TOOL_VERSION@+galaxy1">
+<tool id="samtools_cram_to_bam" name="samtools CRAM to BAM" version="@TOOL_VERSION@" profile="@PROFILE@">
     <description>convert CRAM alignments to BAM format</description>
 
     <macros>
@@ -9,52 +9,31 @@
     <expand macro="version_command"/>
 
     <command><![CDATA[
-        #set input_cram = "input.cram"
-        ln -s '${input_alignment}' '${input_cram}' &&
-        #if str( $input_alignment.metadata.cram_index ) != "None":
-            ln -f -s '${input_alignment.metadata.cram_index}' '${input_cram}.crai' &&
+        @ADDTHREADS@
+        ln -s '$input' input.cram &&
+        #if str( $input.metadata.cram_index ) != "None":
+            ln -f -s '${input.metadata.cram_index}' input.cram.crai &&
         #end if
 
-        #if $reference_source.reference_source_selector == 'history':
-            #set ref_fa = 'ref.fa'
-            ln -s '${reference_source.input_reference}' ref.fa &&
-        #else:
-            #set ref_fa = str( $reference_source.input_reference.fields.path )
-        #end if
+        @PREPARE_FASTA_IDX@
 
         samtools view
             #if $parameter_regions.target_region == "regions_bed_file"
-                -L '${parameter_regions.regions_bed_file}'
+                -L '$parameter_regions.regions_bed_file'
             #end if
-            -@ \${GALAXY_SLOTS:-2}
+            -@ \$addthreads
             -b
-            -T '$ref_fa'
+            -T '$reffa'
             -o '$output_alignment'
-            '$input_cram'
+            input.cram
             #if $parameter_regions.target_region == "region"
-                '${parameter_regions.region_string}'
+                '$parameter_regions.region_string'
             #end if
     ]]></command>
 
     <inputs>
-        <param name="input_alignment" type="data" format="cram" label="CRAM alignment file"/>
-        <conditional name="reference_source">
-            <param name="reference_source_selector" type="select" label="Load reference genome from">
-                <option value="cached">Local cache</option>
-                <option value="history">History</option>
-            </param>
-            <when value="cached">
-                <param name="input_reference" type="select" label="Reference genome">
-                    <options from_data_table="fasta_indexes">
-                        <filter type="data_meta" ref="input_alignment" key="dbkey" column="dbkey" />
-                    </options>
-                    <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
-                </param>
-            </when>
-            <when value="history">
-                <param name="input_reference" type="data" format="fasta" label="Reference FASTA file"/>
-            </when>
-        </conditional>
+        <param name="input" type="data" format="cram" label="CRAM alignment file"/>
+        <expand macro="mandatory_reference" argument="-t"/>
         <conditional name="parameter_regions">
             <param name="target_region" type="select" label="Choose conversion within specific genomic region(s)">
                 <option value="entire_input_file">Entire BAM alignment file</option>
@@ -77,36 +56,33 @@
 
     <tests>
         <test>
-            <param name="input_alignment" value="test.cram" ftype="cram" />
-            <param name="reference_source_selector" value="history" />
-            <param name="input_reference" value="test.fa" />
-
-            <output name="output_alignment" file="test.bam" compare="sim_size" delta="250" />
+            <param name="input" value="test.cram" ftype="cram" />
+            <param name="addref_select" value="history" />
+            <param name="ref" value="test.fa" />
+            <output name="output_alignment" file="test.bam" ftype="bam" lines_diff="4" />
         </test>
         <test>
-            <param name="input_alignment" value="test.cram" ftype="cram" />
-            <param name="reference_source_selector" value="history" />
-            <param name="input_reference" value="test.fa" />
+            <param name="input" value="test.cram" ftype="cram" />
+            <param name="addref_select" value="history" />
+            <param name="ref" value="test.fa" />
             <param name="target_region" value="region" />
             <param name="region_string" value="CHROMOSOME_I" />
-
-            <output name="output_alignment" file="test.bam" compare="sim_size" delta="250" />
+            <output name="output_alignment" file="test.bam" ftype="bam" lines_diff="4" />
         </test>
         <test>
-            <param name="input_alignment" value="test.cram" ftype="cram" />
-            <param name="reference_source_selector" value="history" />
-            <param name="input_reference" value="test.fa" />
+            <param name="input" value="test.cram" ftype="cram" />
+            <param name="addref_select" value="history" />
+            <param name="ref" value="test.fa" />
             <param name="target_region" value="regions_bed_file" />
             <param name="regions_bed_file" value="test.bed" ftype="bed" />
-
-            <output name="output_alignment" file="test.bam" compare="sim_size" delta="250" />
+            <output name="output_alignment" file="test.bam" ftype="bam" lines_diff="4" />
         </test>
         <test>
-            <param name="input_alignment" value="test2.cram" dbkey="equCab2" ftype="cram" />
-            <param name="reference_source_selector" value="cached" />
-            <param name="input_reference" value="equCab2chrM" />
+            <param name="input" value="test2.cram" dbkey="equCab2" ftype="cram" />
+            <param name="addref_select" value="cached" />
+            <param name="ref" value="equCab2chrM" />
             <param name="target_region" value="entire_input_file" />
-            <output name="output_alignment" file="sam_to_bam_out2.bam" compare="sim_size" delta="250" />
+            <output name="output_alignment" file="sam_to_bam_out2.bam" ftype="bam" lines_diff="4" />
         </test>
     </tests>
 
Binary file test-data/sam_to_bam_out2.bam has changed
Binary file test-data/test.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test.bed	Tue Sep 28 16:11:03 2021 +0000
@@ -0,0 +1,1 @@
+CHROMOSOME_I	1	120
Binary file test-data/test.cram has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test.fa	Tue Sep 28 16:11:03 2021 +0000
@@ -0,0 +1,3 @@
+>CHROMOSOME_I
+gcctaagcctaagcctaagcctaagcctaagcctaagcctaagcctaagc
+ctaagcctaagcctaagcctaagcctaagcctaagcctaagcctaagcct
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test.sam	Tue Sep 28 16:11:03 2021 +0000
@@ -0,0 +1,15 @@
+@HD	VN:1.4	SO:unsorted
+@SQ	SN:CHROMOSOME_I	LN:100
+@RG	ID:UNKNOWN	SM:UNKNOWN
+@PG	ID:bowtie2	PN:bowtie2	VN:2.0.0-beta5
+@PG	ID:0	CL:aaaaa/aaa/aaaaa/aaaaaa/aaaaaaaaa/aaa/iuc/package_aaaaaaaaa_x_y/aaaaaaaaaaaa/bin/aaaaaaaaaaaaaaaaa aaaaaaaaaa /aaaa/aaaaa/aaa/aaaaaaaaaaaaaaaaaaa/tools/aaaaaaaaa/test-data/test.cram aa /aaaa/aaaaa/aaa/aaaaaaaaaaaaaaaaaaa/tools/aaaaaaaaa/test-data/test.fa -O test	PN:samtools	VN:1.2
+SRR065390.14978392	16	CHROMOSOME_I	2	1	27M1D73M	*	0	0	CCTAGCCCTAACCCTAACCCTAACCCTAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	#############################@B?8B?BA@@DDBCDDCBC@CDCDCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	RG:Z:UNKNOWN	XG:i:1	XM:i:5	XN:i:0	XO:i:1	AS:i:-18	XS:i:-18	YT:Z:UU
+SRR065390.921023	16	CHROMOSOME_I	3	12	100M	*	0	0	CTAAGCCTAAATCTAAGCCTAACCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	###############################################???88:;98768700000<>:BBA?BBAB?BBBBBBBB>B>BB::;?:00000	RG:Z:UNKNOWN	XG:i:0	XM:i:3	XN:i:0	XO:i:0	AS:i:-6	XS:i:-13	YT:Z:UU
+SRR065390.1871511	16	CHROMOSOME_I	3	1	100M	*	0	0	CTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	<?@<@A8>0:BB@>B<=B@???@=8@B>BB@CA@DACDCBBCCCA@CCCCACCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	RG:Z:UNKNOWN	XG:i:0	XM:i:0	XN:i:0	XO:i:0	AS:i:0	XS:i:0	YT:Z:UU
+SRR065390.3743423	16	CHROMOSOME_I	3	1	100M	*	0	0	CTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	##################?6@:7<=@3=@ABAAB>BDBBABADABDDDBDDBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	RG:Z:UNKNOWN	XG:i:0	XM:i:0	XN:i:0	XO:i:0	AS:i:0	XS:i:0	YT:Z:UU
+SRR065390.4251890	16	CHROMOSOME_I	3	1	100M	*	0	0	CTAAGCCTAAGCCTAAGCCTAA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CCBCCCCCCDCCCCCCCCCCCBCC	RG:Z:UNKNOWN	XG:i:0	XM:i:0	XN:i:0	XO:i:0	AS:i:0	XS:i:0	YT:Z:UU
+SRR065390.6905811	16	CHROMOSOME_I	3	1	100M	*	0	0	CTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	#######################BB@>A<BC>@@BCCB@=BACBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	RG:Z:UNKNOWN	XG:i:0	XM:i:0	XN:i:0	XO:i:0	AS:i:0	XS:i:0	YT:Z:UU
+SRR065390.8289592	16	CHROMOSOME_I	3	1	100M	*	0	0	CTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAAGCCTAA	###############################A?@C9@@BC=AABDD@A@DC@CB=@BA?6@CCAAC@+CCCCCCCCCCCCCCC@CCCCCCCCCCCCCCCC	RG:Z:UNKNOWN	XG:i:0	XM:i:0	XN:i:0	XO:i:0	AS:i:0	XS:i:0	YT:Z:UU
Binary file test-data/test2.cram has changed