changeset 9:17bed26ad17e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/samtools/samtools_sort commit 9f6dd28ae31897068c9f8b5d842750d5d7cd600c
author iuc
date Wed, 19 Sep 2018 09:53:20 -0400
parents 71d5c34fef4e
children c15c63771494
files macros.xml samtools_sort.xml test-data/name.sort.expected.bam test-data/name.sort.expected.sam test-data/pos.sort.expected.bam test-data/pos.sort.expected.sam test-data/tag.as.sort.expected.bam test-data/tag.as.sort.expected.sam test-data/tag.fi.sort.expected.bam test-data/tag.fi.sort.expected.sam test-data/tag.rg.n.sort.expected.bam test-data/tag.rg.n.sort.expected.sam test-data/tag.rg.sort.expected.bam test-data/tag.rg.sort.expected.sam test-data/test_input_1_a.bam
diffstat 15 files changed, 382 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/macros.xml	Tue May 09 11:16:15 2017 -0400
+++ b/macros.xml	Wed Sep 19 09:53:20 2018 -0400
@@ -1,11 +1,93 @@
 <macros>
     <xml name="requirements">
         <requirements>
-            <requirement type="package" version="1.3.1">samtools</requirement>
+            <requirement type="package" version="@TOOL_VERSION@">samtools</requirement>
             <yield/>
         </requirements>
     </xml>
-    <token name="@TOOL_VERSION@">1.3.1</token>
+    <token name="@TOOL_VERSION@">1.9</token>
+    <token name="@FLAGS@">#set $flags = sum(map(int, str($filter).split(',')))</token>
+    <token name="@PREPARE_IDX@"><![CDATA[
+        ##prepare input and indices 
+        ln -s '$input' infile &&
+        #if $input.is_of_type('bam'):
+            #if str( $input.metadata.bam_index ) != "None":
+                ln -s '${input.metadata.bam_index}' infile.bai &&
+            #else:
+                samtools index infile infile.bai &&
+            #end if
+        #elif $input.is_of_type('cram'):
+            #if str( $input.metadata.cram_index ) != "None":
+                ln -s '${input.metadata.cram_index}' infile.crai &&
+            #else:
+                samtools index infile infile.crai &&
+            #end if
+        #end if
+    ]]></token>
+    <token name="@PREPARE_IDX_MULTIPLE@"><![CDATA[
+        ##prepare input and indices 
+        #for $i, $bam in enumerate( $input_bams ):
+            ln -s '$bam' '${i}' &&
+            #if $bam.is_of_type('bam'):
+                #if str( $bam.metadata.bam_index ) != "None":
+                    ln -s '${bam.metadata.bam_index}' '${i}.bai' &&
+                #else:
+                    samtools index '${i}' '${i}.bai' &&
+                #end if
+            #elif $bam.is_of_type('cram'):
+                #if str( $bam.metadata.cram_index ) != "None":
+                    ln -s '${bam.metadata.cram_index}' '${i}.crai' &&
+                #else:
+                    samtools index '${i}' '${i}.crai' &&
+                #end if
+            #end if
+        #end for
+    ]]></token>
+    <token name="@PREPARE_FASTA_IDX@"><![CDATA[
+        ##checks for reference data ($addref_cond.addref_select=="history" or =="cached")
+        ##and sets the -t/-T parameters accordingly:
+        ##- in case of history a symbolic link is used because samtools (view) will generate
+        ##  the index which might not be possible in the directory containing the fasta file
+        ##- in case of cached the absolute path is used which allows to read the cram file
+        ##  without specifying the reference
+        #if $addref_cond.addref_select == "history":
+            ln -s '${addref_cond.ref}' reference.fa &&
+            samtools faidx reference.fa &&
+            #set reffa=str($addref_cond.ref)
+            #set reffai="reference.fa.fai"
+        #elif $addref_cond.addref_select == "cached":
+            #set reffa=str($addref_cond.ref.fields.path)
+            #set reffai=str($addref_cond.ref.fields.path)
+        #else
+            #set reffa=None
+            #set reffai=None
+        #end if
+    ]]></token>
+    <token name="@ADDTHREADS@"><![CDATA[
+        ##compute the number of ADDITIONAL threads to be used by samtools (-@)
+        addthreads=\${GALAXY_SLOTS:-1} && (( addthreads-- )) &&
+    ]]></token>
+
+    <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=addmemory*75/100)) &&
+    ]]></token>
+    <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 reverse strand</option>
+        <option value="32">mate reverse strand</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 or 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">supplementary alignment</option>
+    </xml>
     <xml name="citations">
         <citations>
             <citation type="bibtex">
@@ -49,21 +131,4 @@
             <exit_code range="1:" level="fatal" description="Error" />
         </stdio>
     </xml>
-    <token name="@no-chrom-options@">
------
-
-.. class:: warningmark
-
-**No options available? How to re-detect metadata**
-
-If you see a &quot;No options available&quot; within the &quot;**Select references (chromosomes and contigs) you would like to restrict bam to**&quot; drop down, you need to re-detect metadata for the dataset you are trying to process. To do this follow these steps:
-
-1. Click on the **pencil** icon adjacent to the dataset in the history
-2. A new menu will appear in the center pane of the interface
-3. Click **Datatype** tab
-4. Set **New Type** to **BAM**
-5. Click **Save**
-
-The medatada will be re-detected and you will be able to see the list of reference sequences in the &quot;**Select references (chromosomes and contigs) you would like to restrict bam to**&quot; drop-down.
-    </token>
 </macros>
--- a/samtools_sort.xml	Tue May 09 11:16:15 2017 -0400
+++ b/samtools_sort.xml	Wed Sep 19 09:53:20 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="samtools_sort" name="Sort" version="2.0.1">
+<tool id="samtools_sort" name="Samtools sort" version="2.0.2">
     <description>order of storing aligned sequences</description>
     <macros>
         <import>macros.xml</import>
@@ -7,39 +7,163 @@
     <expand macro="stdio"/>
     <expand macro="version_command"/>
     <command><![CDATA[
+        @ADDTHREADS@
+	@ADDMEMORY@
         samtools sort
-            $sort_mode
-            -@ \${GALAXY_SLOTS:-1}
-            -o '${output1}'
+            -@ \$addthreads
+            -m \$addmemory"M"
+            ###if str(compression):
+            ##    -l '$compression'
+            ###end if
+            $prim_key_cond.prim_key_select
+            #if $prim_key_cond.prim_key_select == '-t':
+                $prim_key_cond.tag
+                $prim_key_cond.sec_key_select
+            #end if
             -O bam
-            -T dataset
+            -T sorttmp
             '${input1}'
+             > '${output1}'
     ]]></command>
     <inputs>
-        <param name="input1" type="data" format="bam" label="BAM File" />
-        <param name="sort_mode" type="select" label="Sort by ">
-            <option value="" selected="True">Chromosomal coordinates</option>
-            <option value="-n">Read names (-n)</option>
-        </param>
+        <param name="input1" type="data" format="sam,bam,cram" label="BAM File" />
+        <conditional name="prim_key_cond">
+            <param name="prim_key_select" type="select" label="Primary sort key">
+                <option value="">coordinate</option>
+                <option value="-n">name (-n)</option>
+                <option value="-t">tag (-t)</option>
+            </param>
+            <when value=""/>
+            <when value="-n"/>
+            <when value="-t">
+                <param name="tag" type="text" optional="false" argument="-t" label="Alignment tag"/>
+                <param name="sec_key_select" type="select" label="Secondary sort key">
+                    <option value="">coordinate</option>
+                    <option value="-n">name (-n)</option>
+                </param>
+           </when>
+        </conditional>
+        <!--<param name="compression" type="integer" argument="-l" optional="True" min="0" max="9" label="compression level" help="0 (uncompressed) to 9 (best)"/>-->
     </inputs>
     <outputs>
-        <data name="output1" format="bam" />
+       <data name="output1" format="bam">
+            <change_format>
+                <when input="prim_key_cond.prim_key_select" value="" format="bam" />
+                <when input="prim_key_cond.prim_key_select" value="-n" format="qname_sorted.bam" />
+                <when input="prim_key_cond.prim_key_select" value="-t" format="unsorted.bam" />
+            </change_format>
+        </data>
     </outputs>
     <tests>
+        <!-- tests from https://github.com/samtools/samtools/blob/9ce8c64493f7ea3fa69bc5c1ac980b1a8e3dcf1f/test/test.pl#L2464 -->
+        <!-- # Pos sort -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <output name="output1" file="pos.sort.expected.bam" ftype="bam"/>
+        </test>
+    	<!-- test_cmd($opts, out=>"sort/pos.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads}  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -"); -->
+
+        <!-- # Name sort -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-n"/>
+            </conditional>
+            <output name="output1" file="name.sort.expected.bam" ftype="qname_sorted.bam"/>
+        </test>
+	<!--    test_cmd($opts, out=>"sort/name.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -n  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->
+
+        <!-- # Tag sort (RG) (considers output and name sorted) -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-t"/>
+                <param name="tag" value="RG"/>
+            </conditional>
+            <output name="output1" file="tag.rg.sort.expected.bam" ftype="unsorted.bam"/>
+        </test>
+    <!--test_cmd($opts, out=>"sort/tag.rg.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t RG  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->
+
+        <!-- # Tag sort (RG); secondary by name -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-t"/>
+                <param name="tag" value="RG"/>
+                <param name="sec_key_select" value="-n"/>
+            </conditional>
+            <output name="output1" file="tag.rg.n.sort.expected.bam" ftype="unsorted.bam"/>
+        </test>
+    <!--test_cmd($opts, out=>"sort/tag.rg.n.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -n -t RG  $$opts{path}/dat/test_input_1_a.bam -O SAM -o -");-->
+
+        <!-- # Tag sort (AS) -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-t"/>
+                <param name="tag" value="AS"/>
+                <param name="sec_key_select" value=""/>
+            </conditional>
+            <output name="output1" file="tag.as.sort.expected.bam" ftype="unsorted.bam"/>
+        </test>
+    <!--test_cmd($opts, out=>"sort/tag.as.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t AS $$opts{path}/dat/test_input_1_d.sam -O SAM -o -");-->
+
+        <!-- # Tag sort (FI) -->
+        <test>
+            <param name="input1" value="test_input_1_a.bam" ftype="bam" />
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-t"/>
+                <param name="tag" value="FI"/>
+            </conditional>
+            <output name="output1" file="tag.fi.sort.expected.bam" ftype="unsorted.bam"/>
+        </test>
+    <!--test_cmd($opts, out=>"sort/tag.fi.sort.expected.sam", cmd=>"$$opts{bin}/samtools sort${threads} -t FI $$opts{path}/dat/test_input_1_d.sam -O SAM -o -");-->
+
+        <!-- tests from old version -->
         <test>
             <param name="input1" value="1.bam" ftype="bam" />
             <output name="output1" file="1_sort.bam" ftype="bam" sort="True"/>
         </test>
         <test>
             <param name="input1" value="1.bam" ftype="bam" />
-            <param name="sort_mode" value="-n"/>
-            <output name="output1" file="1_sort_read_names.bam" ftype="bam" sort="True"/>
+            <conditional name="prim_key_cond">
+                <param name="prim_key_select" value="-n"/>
+            </conditional>
+            <output name="output1" file="1_sort_read_names.bam" ftype="qname_sorted.bam"/>
         </test>
     </tests>
     <help>
 **What it does**
 
-This tool uses ``samtools sort`` command to sort BAM datasets in coordinate or read name order.
+Sort alignments by leftmost coordinates, or by read name when -n is used. 
+An appropriate @HD-SO sort order header tag will be added or an existing 
+one updated if necessary. 
+
+**Ordering Rules**
+
+The following rules are used for ordering records.
+
+If option -t is in use, records are first sorted by the value of the given
+alignment tag, and then by position or name (if using -n). For example, “-t RG”
+will make read group the primary sort key. The rules for ordering by tag are:
+
+- Records that do not have the tag are sorted before ones that do.
+- If the types of the tags are different, they will be sorted so that single
+  character tags (type A) come before array tags (type B), then string tags
+  (types H and Z), then numeric tags (types f and i).
+- Numeric tags (types f and i) are compared by value. Note that comparisons of
+  floating-point values are subject to issues of rounding and precision.
+- String tags (types H and Z) are compared based on the binary contents of the
+  tag using the C strcmp(3) function.
+- Character tags (type A) are compared by binary character value.
+- No attempt is made to compare tags of other types — notably type B array values will not be compared. 
+
+When the -n option is present, records are sorted by name. Names are compared so as to give a “natural” ordering — i.e. sections consisting of digits are compared numerically while all other sections are compared based on their binary representation. This means “a1” will come before “b1” and “a9” will come before “a10”. Records with the same name will be ordered according to the values of the READ1 and READ2 flags (see flags).
+
+When the -n option is not present, reads are sorted by reference (according to the order of the @SQ header records), then by position in the reference, and then by the REVERSE flag.
+
+This has now been removed. The previous out.prefix argument (and -f option, if any) should be changed to an appropriate combination of -T PREFIX and -o FILE. The previous -o option should be removed, as output defaults to standard output. 
+
     </help>
     <expand macro="citations"/>
 </tool>
Binary file test-data/name.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/name.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,28 @@
+@HD	VN:1.4	SO:queryname
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@RG	ID:fish	PG:donkey
+@RG	ID:cow	PU:13_&^&&*(:332
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@PG	ID:moose
+@PG	PP:moose	ID:cow
+@CO	
+r000	99	insert	50	30	10M	=	80	30	ATTTAGCTAC	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r000	211	insert	80	30	10M	=	50	-30	CCCAATCATT	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r001	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:fish	PG:Z:colt
+r001	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:fish	PG:Z:colt
+r002	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	PG:Z:colt
+r003	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:cow
+r003	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:cow	PG:Z:colt
+r004	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:colt
+u1	4	*	0	30	23M	*	0	0	TAATTAAGTCTACAGAAAAAAAA	???????????????????????
+x1	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:colt	PG:Z:bull
+x2	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:colt	PG:Z:bull
+x3	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:fish	PG:Z:bull
+x4	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:fish	PG:Z:bull
+x5	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:fish	PG:Z:bull
+x6	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow
Binary file test-data/pos.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pos.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,28 @@
+@HD	VN:1.4	SO:coordinate
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@RG	ID:fish	PG:donkey
+@RG	ID:cow	PU:13_&^&&*(:332
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@PG	ID:moose
+@PG	PP:moose	ID:cow
+@CO	
+r000	99	insert	50	30	10M	=	80	30	ATTTAGCTAC	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r000	211	insert	80	30	10M	=	50	-30	CCCAATCATT	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r001	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:fish	PG:Z:colt
+r002	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	PG:Z:colt
+r003	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:cow
+r004	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:colt
+r003	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:cow	PG:Z:colt
+r001	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:fish	PG:Z:colt
+x1	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:colt	PG:Z:bull
+x2	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:colt	PG:Z:bull
+x3	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:fish	PG:Z:bull
+x4	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:fish	PG:Z:bull
+x5	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:fish	PG:Z:bull
+x6	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow
+u1	4	*	0	30	23M	*	0	0	TAATTAAGTCTACAGAAAAAAAA	???????????????????????
Binary file test-data/tag.as.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/tag.as.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,24 @@
+@HD	VN:1.4	SO:unknown
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@PG	ID:llama
+@RG	ID:fish	PG:llama
+@RG	ID:cow	PU:13_&^&&*(:332	PG:donkey
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@CO	Do you know?
+r006	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:colt	PG:Z:donkey	FI:i:3
+x11	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:cow	PG:Z:bull	FI:Z:a
+r007	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:donkey	AS:i:-5	FI:f:3.5
+x10	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:cow	PG:Z:bull	AS:i:0	FI:A:b
+r007	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:colt	PG:Z:donkey	AS:i:1	FI:i:4
+r005	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:colt	PG:Z:donkey	AS:i:10	FI:i:5
+x8	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:cow	PG:Z:bull	AS:i:10	FI:f:1.5
+r006	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	RG:Z:colt	PG:Z:donkey	AS:i:20	FI:f:4.5
+x9	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:cow	PG:Z:bull	AS:i:20	FI:i:1
+x7	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:cow	PG:Z:bull	AS:i:50	FI:i:2
+r005	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:colt	PG:Z:donkey	AS:i:100	FI:f:2.5
+x12	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow	PG:Z:bull	AS:i:65100
Binary file test-data/tag.fi.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/tag.fi.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,24 @@
+@HD	VN:1.4	SO:unknown
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@PG	ID:llama
+@RG	ID:fish	PG:llama
+@RG	ID:cow	PU:13_&^&&*(:332	PG:donkey
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@CO	Do you know?
+x12	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow	PG:Z:bull	AS:i:65100
+x10	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:cow	PG:Z:bull	AS:i:0	FI:A:b
+x11	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:cow	PG:Z:bull	FI:Z:a
+x9	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:cow	PG:Z:bull	AS:i:20	FI:i:1
+x8	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:cow	PG:Z:bull	AS:i:10	FI:f:1.5
+x7	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:cow	PG:Z:bull	AS:i:50	FI:i:2
+r005	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:colt	PG:Z:donkey	AS:i:100	FI:f:2.5
+r006	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:colt	PG:Z:donkey	FI:i:3
+r007	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:donkey	AS:i:-5	FI:f:3.5
+r007	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:colt	PG:Z:donkey	AS:i:1	FI:i:4
+r006	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	RG:Z:colt	PG:Z:donkey	AS:i:20	FI:f:4.5
+r005	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:colt	PG:Z:donkey	AS:i:10	FI:i:5
Binary file test-data/tag.rg.n.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/tag.rg.n.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,28 @@
+@HD	VN:1.4	SO:unknown
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@RG	ID:fish	PG:donkey
+@RG	ID:cow	PU:13_&^&&*(:332
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@PG	ID:moose
+@PG	PP:moose	ID:cow
+@CO	
+r002	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	PG:Z:colt
+u1	4	*	0	30	23M	*	0	0	TAATTAAGTCTACAGAAAAAAAA	???????????????????????
+r004	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:colt
+x1	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:colt	PG:Z:bull
+x2	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:colt	PG:Z:bull
+r000	99	insert	50	30	10M	=	80	30	ATTTAGCTAC	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r000	211	insert	80	30	10M	=	50	-30	CCCAATCATT	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r003	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:cow
+r003	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:cow	PG:Z:colt
+x6	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow
+r001	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:fish	PG:Z:colt
+r001	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:fish	PG:Z:colt
+x3	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:fish	PG:Z:bull
+x4	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:fish	PG:Z:bull
+x5	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:fish	PG:Z:bull
Binary file test-data/tag.rg.sort.expected.bam has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/tag.rg.sort.expected.sam	Wed Sep 19 09:53:20 2018 -0400
@@ -0,0 +1,28 @@
+@HD	VN:1.4	SO:unknown
+@SQ	SN:insert	LN:599
+@SQ	SN:ref1	LN:45
+@SQ	SN:ref2	LN:40
+@SQ	SN:ref3	LN:4
+@RG	ID:fish	PG:donkey
+@RG	ID:cow	PU:13_&^&&*(:332
+@RG	PU:*9u8jkjjkjd:	ID:colt
+@PG	ID:bull	PP:donkey
+@PG	ID:donkey
+@PG	ID:moose
+@PG	PP:moose	ID:cow
+@CO	
+r002	0	ref1	9	30	1S2I6M1P1I1P1I4M2I	*	0	0	AAAAGATAAGGGATAAA	*	XA:Z:abc	XB:i:-10	PG:Z:colt
+u1	4	*	0	30	23M	*	0	0	TAATTAAGTCTACAGAAAAAAAA	???????????????????????
+r004	0	ref1	16	30	6M14N1I5M	*	0	0	ATAGCTCTCAGC	*	RG:Z:colt	PG:Z:colt
+x1	0	ref2	1	30	20M	*	0	0	AGGTTTTATAAAACAAATAA	*	RG:Z:colt	PG:Z:bull
+x2	0	ref2	2	30	21M	*	0	0	GGTTTTATAAAACAAATAATT	?????????????????????	RG:Z:colt	PG:Z:bull
+r000	99	insert	50	30	10M	=	80	30	ATTTAGCTAC	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r000	211	insert	80	30	10M	=	50	-30	CCCAATCATT	AAAAAAAAAA	RG:Z:cow	PG:Z:bull
+r003	0	ref1	9	30	5H6M	*	0	0	AGCTAA	*	RG:Z:cow
+r003	16	ref1	29	30	6H5M	*	0	0	TAGGC	*	RG:Z:cow	PG:Z:colt
+x6	0	ref2	14	30	23M	*	0	0	TAATTAAGTCTACAGAGCAACTA	???????????????????????	RG:Z:cow
+r001	163	ref1	7	30	8M4I4M1D3M	=	37	39	TTAGATAAAGAGGATACTG	*	XX:B:S,12561,2,20,112	YY:i:100	RG:Z:fish	PG:Z:colt
+r001	83	ref1	37	30	9M	=	7	-39	CAGCGCCAT	*	RG:Z:fish	PG:Z:colt
+x3	0	ref2	6	30	9M4I13M	*	0	0	TTATAAAACAAATAATTAAGTCTACA	??????????????????????????	RG:Z:fish	PG:Z:bull
+x4	0	ref2	10	30	25M	*	0	0	CAAATAATTAAGTCTACAGAGCAAC	?????????????????????????	RG:Z:fish	PG:Z:bull
+x5	0	ref2	12	30	24M	*	0	0	AATAATTAAGTCTACAGAGCAACT	????????????????????????	RG:Z:fish	PG:Z:bull
Binary file test-data/test_input_1_a.bam has changed