# HG changeset patch
# User devteam
# Date 1429648150 14400
# Node ID c6fdfe3331d69b741ede3d76bcdd39d92b6fbb64
# Parent  973fea5b4bdfd28ada8cfaf7f62394774331ce48
Uploaded
diff -r 973fea5b4bdf -r c6fdfe3331d6 macros.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,70 @@
+
+    
+        
+            samtools
+            
+        
+    
+    
+        
+            
+                @misc{SAM_def,
+                title={Definition of SAM/BAM format},
+                url = {https://samtools.github.io/hts-specs/SAMv1.pdf},}
+            
+            10.1093/bioinformatics/btp352
+            10.1093/bioinformatics/btr076
+            10.1093/bioinformatics/btr509
+            
+                @misc{Danecek_et_al,
+                Author={Danecek, P., Schiffels, S., Durbin, R.},
+                title={Multiallelic calling model in bcftools (-m)},
+                url = {http://samtools.github.io/bcftools/call-m.pdf},}
+            
+            
+                @misc{Durbin_VCQC,
+                Author={Durbin, R.},
+                title={Segregation based metric for variant call QC},
+                url = {http://samtools.github.io/bcftools/rd-SegBias.pdf},}
+            
+            
+                @misc{Li_SamMath,
+                Author={Li, H.},
+                title={Mathematical Notes on SAMtools Algorithms},
+                url = {http://www.broadinstitute.org/gatk/media/docs/Samtools.pdf},}
+            
+            
+                @misc{SamTools_github,
+                title={SAMTools GitHub page},
+                url = {https://github.com/samtools/samtools},}
+            
+        
+    
+    
+        samtools --version | head -n 1 | awk '{ print $2 }'
+    
+    
+        
+            
+        
+    
+    
+-----
+
+.. class:: warningmark
+
+**No options available? How to re-detect metadata**
+
+If you see a "No options available" within the "**Select references (chromosomes and contigs) you would like to restrict bam to**" 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 "**Select references (chromosomes and contigs) you would like to restrict bam to**" drop-down.
+
+    
+
+
diff -r 973fea5b4bdf -r c6fdfe3331d6 samtools_mpileup.xml
--- a/samtools_mpileup.xml	Thu Mar 27 15:27:36 2014 -0400
+++ b/samtools_mpileup.xml	Tue Apr 21 16:29:10 2015 -0400
@@ -1,213 +1,371 @@
-
-  SNP and indel caller
-  
-      samtools
-  
-  samtools_wrapper.py
-    -p 'samtools mpileup'
-    --stdout "${output_log}"
+
+    call variants
+    
+        macros.xml
+    
+    
+    
+    
+    
+    
-  
-    
-      
-        
-        
-      
-      
-        
-          
-            
-             
-          
-        
-        
-          
-            
-          
-        
-      
-       
-        
-          
-            
-          
-        
-        
-      
-    
-
-    
-    
-      
-        
-        
-      
-      
-          
-          
-          
-            
-              
-              
+    --output "$output_mpileup" 2> "$output_log"
+    ]]>
+    
+    
+        
+            
+                
+                
+            
+            
+                
+                    
+                        
+                        
+                    
+                
+                
+                    
+                
+            
+            
+                
+                    
+                        
+                    
+                
+                
+            
+        
+        
+            
+                
+                
             
-            
-              
+            
+                
+                    
+                    
+                
+                
+                
+                    
+                    
+                    
+                    
+                    
+                    
+                
+                
+                    
+                        
+                        
+                        
+                    
+                    
+                    
+                        
+                        
+                        
+                        
+                        
+                        
+                        
+                        
+                        
+                            
+                        
+                    
+                    
+                
+                
+            
+            
+                
+                
             
-            
-          
-          
-          
-            
-          
-      
-      
-          
-      
-    
-    
-      
-        
-        
-      
-      
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-      
-      
-    
-  
-  
-    
-      
-        
-      
-    
-    
-  
-  
-      
-          
-          
-          
-          
-          
-           
-          
-      
-      
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-           
-          
-      
-  
-  
+        
+        
+            
+                
+                
+            
+            
+                
+                    
+                        
+                        
+                    
+                    
+                        
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                        
+                        
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                            
+                        
+                    
+                    
+                
+                
+                    
+                        
+                        
+                        
+                    
+                    
+                        
+                            
+                        
+                    
+                    
+                        
+                    
+                    
+                
+                
+                    
+                        
+                        
+                        
+                    
+                    
+                        
+                            
+                        
+                    
+                    
+                        
+                    
+                    
+                
+                
+                
+                
+                
+                
+                
+                
+                
+            
+            
+        
+    
+    
+        
+            
+                
+                
+            
+        
+        
+    
+    
+        
+            
+            
+            
+            
+            
+            
+            
+            
+            
+        
+        
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+        
+    
+    
+
+**Notes**: Assuming diploid individuals.
+]]>
+    
+    
+        
+
+        
+        
+
+        
+    
+    
 
diff -r 973fea5b4bdf -r c6fdfe3331d6 samtools_wrapper.py
--- a/samtools_wrapper.py	Thu Mar 27 15:27:36 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-#!/usr/bin/env python
-#Dan Blankenberg
-
-"""
-A wrapper script for running SAMTools commands.
-"""
-
-import sys, optparse, os, tempfile, subprocess, shutil
-from string import Template
-
-GALAXY_EXT_TO_SAMTOOLS_EXT = { 'bam_index':'bam.bai', } #items not listed here will use the galaxy extension as-is
-GALAXY_EXT_TO_SAMTOOLS_FILE_TYPE = GALAXY_EXT_TO_SAMTOOLS_EXT #for now, these are the same, but could be different if needed
-DEFAULT_SAMTOOLS_PREFIX = "SAMTools_file"
-CHUNK_SIZE = 2**20 #1mb
-
-
-def cleanup_before_exit( tmp_dir ):
-    if tmp_dir and os.path.exists( tmp_dir ):
-        shutil.rmtree( tmp_dir )
-
-def SAMTOOLS_filename_from_galaxy( galaxy_filename, galaxy_ext, target_dir = None, prefix = None ):
-    suffix = GALAXY_EXT_TO_SAMTOOLS_EXT.get( galaxy_ext, galaxy_ext )
-    if prefix is None:
-        prefix = DEFAULT_SAMTOOLS_PREFIX
-    if target_dir is None:
-        target_dir = os.getcwd()
-    SAMTools_filename = os.path.join( target_dir, "%s.%s" % ( prefix, suffix ) )
-    os.symlink( galaxy_filename, SAMTools_filename )
-    return SAMTools_filename
-
-def SAMTOOLS_filetype_argument_substitution( argument, galaxy_ext ):
-    return argument % dict( file_type = GALAXY_EXT_TO_SAMTOOLS_FILE_TYPE.get( galaxy_ext, galaxy_ext ) )
-
-def open_file_from_option( filename, mode = 'rb' ):
-    if filename:
-        return open( filename, mode = mode )
-    return None
-
-def html_report_from_directory( html_out, dir ):
-    html_out.write( '\n\nGalaxy - SAMTOOLS Output\n\n\n\n\n' )
-    for fname in sorted( os.listdir( dir ) ):
-        html_out.write(  '- %s
 \n' % ( fname, fname ) )
-    html_out.write( '
\n\n\n' )
-
-def __main__():
-    #Parse Command Line
-    parser = optparse.OptionParser()
-    parser.add_option( '-p', '--pass_through', dest='pass_through_options', action='append', type="string", help='These options are passed through directly to SAMTOOLS, without any modification.' )
-    parser.add_option( '-d', '--dataset', dest='datasets', action='append', type="string", nargs=4, help='"-argument" "original_filename" "galaxy_filetype" "name_prefix"' )
-    parser.add_option( '', '--stdout', dest='stdout', action='store', type="string", default=None, help='If specified, the output of stdout will be written to this file.' )
-    parser.add_option( '', '--stderr', dest='stderr', action='store', type="string", default=None, help='If specified, the output of stderr will be written to this file.' )
-    parser.add_option( '', '--html_report_from_directory', dest='html_report_from_directory', action='append', type="string", nargs=2, help='"Target HTML File" "Directory"')
-    (options, args) = parser.parse_args()
-    
-    tmp_dir = tempfile.mkdtemp( prefix='tmp-SAMTOOLS-' )
-    
-    #set up stdout and stderr output options
-    stdout = open_file_from_option( options.stdout, mode = 'wb' )
-    stderr = open_file_from_option( options.stderr, mode = 'wb' )
-    #if no stderr file is specified, we'll use our own
-    if stderr is None:
-        stderr = tempfile.NamedTemporaryFile( prefix="SAMTOOLS-stderr-", dir=tmp_dir )
-    
-    if options.pass_through_options:
-        cmd = ' '.join( options.pass_through_options )
-    else:
-        cmd = ''
-    return_code = None
-    if options.datasets:
-        for ( dataset_arg, filename, galaxy_ext, prefix ) in options.datasets:
-            SAMTools_filename = SAMTOOLS_filename_from_galaxy( filename, galaxy_ext, target_dir = tmp_dir, prefix = prefix )
-            if dataset_arg:
-                if '>' in cmd:
-                    cmd = cmd.replace( '>', '  %s "%s" >' % ( SAMTOOLS_filetype_argument_substitution( dataset_arg, galaxy_ext ), SAMTools_filename ), 1 )
-                else:
-                    cmd = '%s %s "%s"' % ( cmd, SAMTOOLS_filetype_argument_substitution( dataset_arg, galaxy_ext ), SAMTools_filename )
-            #auto index fasta files:
-            if galaxy_ext == 'fa':
-                index_cmd = 'samtools faidx %s' % ( SAMTools_filename )
-                proc = subprocess.Popen( args=index_cmd, stdout=stdout, stderr=stderr, shell=True, cwd=tmp_dir )
-                return_code = proc.wait()
-                if return_code:
-                    break
-    if return_code is None or not return_code:
-        proc = subprocess.Popen( args=cmd, stdout=stdout, stderr=stderr, shell=True, cwd=tmp_dir )
-        return_code = proc.wait()
-    if return_code:
-        stderr_target = sys.stderr
-    else:
-        if stdout:
-            stderr_target = stdout
-        else:
-            stderr_target = sys.stdout
-    stderr.flush()
-    stderr.seek(0)
-    while True:
-        chunk = stderr.read( CHUNK_SIZE )
-        if chunk:
-            stderr_target.write( chunk )
-        else:
-            break
-    stderr.close()
-    #generate html reports
-    if options.html_report_from_directory:
-        for ( html_filename, html_dir ) in options.html_report_from_directory:
-            html_report_from_directory( open( html_filename, 'wb' ), html_dir )
-    
-    cleanup_before_exit( tmp_dir )
-
-if __name__=="__main__": __main__()
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/gatk/gatk_table_recalibration/gatk_table_recalibration_out_1.bam
Binary file test-data/gatk/gatk_table_recalibration/gatk_table_recalibration_out_1.bam has changed
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/phiX.bam
Binary file test-data/phiX.bam has changed
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/phiX_1.bam
Binary file test-data/phiX_1.bam has changed
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_in_1.bam
Binary file test-data/samtools_mpileup_in_1.bam has changed
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_1.log
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_1.log	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,3 @@
+[fai_load] build FASTA index.
+[mpileup] 1 samples in 1 input files
+ Set max per-file depth to 8000
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_1.pileup
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_1.pileup	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,43 @@
+phiX174	1411	A	0				1
+phiX174	1412	G	0				2,1,1
+phiX174	1413	C	0				3,2,2,1,1
+phiX174	1414	G	0				4,3,3,2,2,1
+phiX174	1415	C	0				5,4,4,3,3,2,1
+phiX174	1416	C	0				6,5,5,4,4,3,2,1
+phiX174	1417	G	0				7,6,6,5,5,4,3,2,1
+phiX174	1418	T	0				8,7,7,6,6,5,4,3,2,1
+phiX174	1419	G	0				9,8,8,7,7,6,5,4,3,2
+phiX174	1420	G	0				10,9,9,8,8,7,6,5,4,3
+phiX174	1421	A	0				11,10,10,9,9,8,7,6,5,4
+phiX174	1422	T	0				12,11,11,10,10,9,8,7,6,5
+phiX174	1423	G	0				13,12,12,11,11,10,9,8,7,6
+phiX174	1424	C	0				14,13,13,12,12,11,10,9,8,7
+phiX174	1425	C	0				15,14,14,13,13,12,11,10,9,8
+phiX174	1426	T	0				16,15,15,14,14,13,12,11,10,9
+phiX174	1427	G	0				17,16,16,15,15,14,13,12,11,10
+phiX174	1428	A	0				18,17,17,16,16,15,14,13,12,11
+phiX174	1429	C	0				19,18,18,17,17,16,15,14,13,12
+phiX174	1430	C	0				20,19,19,18,18,17,16,15,14,13
+phiX174	1431	G	0				21,20,20,19,19,18,17,16,15,14
+phiX174	1432	T	0				22,21,21,20,20,19,18,17,16,15
+phiX174	1433	A	0				23,22,22,21,21,20,19,18,17,16
+phiX174	1434	C	0				24,23,23,22,22,21,20,19,18,17
+phiX174	1435	C	0				25,24,24,23,23,22,21,20,19,18
+phiX174	1436	G	0				26,25,25,24,24,23,22,21,20,19
+phiX174	1437	A	0				27,26,26,25,25,24,23,22,21,20
+phiX174	1438	G	0				28,27,27,26,26,25,24,23,22,21
+phiX174	1439	G	0				29,28,28,27,27,26,25,24,23,22
+phiX174	1440	C	0				30,29,29,28,28,27,26,25,24,23
+phiX174	1441	T	0				31,30,30,29,29,28,27,26,25,24
+phiX174	1442	A	0				32,31,31,30,30,29,28,27,26,25
+phiX174	1443	A	0				33,32,32,31,31,30,29,28,27,26
+phiX174	1444	C	0				34,33,33,32,32,31,30,29,28,27
+phiX174	1445	C	0				34,33,34,32,33,32,31,30,29,28
+phiX174	1446	C	0				35,34,35,33,34,33,32,31,30,29
+phiX174	1447	T	0				36,35,36,34,35,34,33,32,31,30
+phiX174	1448	A	0				36,35,36,35,34,33,32,31
+phiX174	1449	A	0				36,36,35,34,33,32
+phiX174	1450	T	0				36,35,34,33
+phiX174	1451	G	0				36,35,34
+phiX174	1452	A	0				36,35
+phiX174	1453	G	0				36
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_2.log
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_2.log	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,3 @@
+[fai_load] build FASTA index.
+[mpileup] 1 samples in 1 input files
+ Set max per-file depth to 8000
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_2.vcf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_2.vcf	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,22 @@
+##fileformat=VCFv4.2
+##FILTER=
+##samtoolsVersion=1.1+htslib-1.1
+##samtoolsCommand=samtools mpileup --VCF --uncompressed -f /tmp/tmpId8vOP/tmp3bubIE/database/files/000/dataset_735.dat -g -e 20 -h 100 -L 250 -m 1 --open-prob 40 -F 0.002 -e 40 --output /tmp/tmpId8vOP/tmp3bubIE/database/files/000/dataset_736.dat /tmp/tmpId8vOP/tmp3bubIE/database/files/000/dataset_734.dat
+##reference=file:///tmp/tmpId8vOP/tmp3bubIE/database/files/000/dataset_735.dat
+##contig=
+##ALT=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##FORMAT=
+#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	/tmp/tmpId8vOP/tmp3bubIE/database/files/000/dataset_734.dat
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_3.log
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_3.log	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,2 @@
+[mpileup] 1 samples in 1 input files
+ Set max per-file depth to 8000
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_4.log
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_4.log	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,2 @@
+[mpileup] 1 samples in 1 input files
+ Set max per-file depth to 8000
diff -r 973fea5b4bdf -r c6fdfe3331d6 test-data/samtools_mpileup_out_4.vcf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/samtools_mpileup_out_4.vcf	Tue Apr 21 16:29:10 2015 -0400
@@ -0,0 +1,22 @@
+##fileformat=VCFv4.2
+##FILTER=
+##samtoolsVersion=1.1+htslib-1.1
+##samtoolsCommand=samtools mpileup --VCF --uncompressed -f /var/galaxy/workspace/CleanGalaxy/tool-data/phiX/sam_indexes/phiX/phiX.fa -C 0 -d 200 -E -q 0 -Q 43 -g -e 20 -h 100 -L 250 -m 1 --open-prob 40 -F 0.002 -e 40 --output /tmp/tmp5TzrZC/tmpDtGVov/database/files/000/dataset_756.dat /tmp/tmp5TzrZC/tmpDtGVov/database/files/000/dataset_755.dat
+##reference=file:///var/galaxy/workspace/CleanGalaxy/tool-data/phiX/sam_indexes/phiX/phiX.fa
+##contig=
+##ALT=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##INFO=
+##FORMAT=
+#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	/tmp/tmp5TzrZC/tmpDtGVov/database/files/000/dataset_755.dat
diff -r 973fea5b4bdf -r c6fdfe3331d6 tool_dependencies.xml
--- a/tool_dependencies.xml	Thu Mar 27 15:27:36 2014 -0400
+++ b/tool_dependencies.xml	Tue Apr 21 16:29:10 2015 -0400
@@ -1,6 +1,6 @@
 
 
-    
-        
+    
+