# HG changeset patch
# User gkumar09
# Date 1445179227 14400
# Node ID 87c03e2aeba3dc6332423332a125a09e0e6131ca
# Parent  70e3c4c34a7c25257f376c00329a889eb32db186
Uploaded
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/._alignreads.xml
Binary file trinityrnaseq_protocol/._alignreads.xml has changed
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/EdgeR_differentialExpression.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/EdgeR_differentialExpression.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,38 @@
+
+
+    Identify Differentially Expressed Transcripts Using EdgeR
+    
+        trinity
+    
+    
+
+ 		EdgeR_differentialExpression_wrapper.py 
+			$counts_matrix 
+			$dispersion
+			
+    
+    
+		
+		
+		
+		
+	
+    
+    
+        
+        
+			
+	
+    
+
+		
+			
+
+        
+	
+
+    
+    
+         help info here.
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/EdgeR_differentialExpression_wrapper.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/EdgeR_differentialExpression_wrapper.py	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,40 @@
+import sys, os, subprocess
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit(1)
+
+usage= "usage: " + " $counts_matrix" + " $dispersion"
+
+if len(sys.argv)<2:
+    print "Require atleast two parameters"
+else:
+    print "All good- command going ahead"
+print " "
+
+def run_command(cmd):
+    print "The command used: " + cmd
+    pipe=subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
+    pipe.wait()
+    ret= pipe.returncode
+    if ret:
+        print "command died: " + str(ret)
+        print pipe.stderr.readlines()
+        sys.exit(1)
+    else:
+        return
+print " "
+
+countmatrix= "counts_matrix"
+
+cmd= "cp " + sys.argv[1] + " " + countmatrix 
+run_command(cmd)
+
+cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/run_DE_analysis.pl "+ " --matrix "+ countmatrix + " --method edgeR " + " --output edgeR_results "+ " --dispersion " + sys.argv[2] + " --tar_gz_outdir"
+
+run_command(cmd)
+
+sys.exit(0)
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/RSEM_estimates_to_matrix.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/RSEM_estimates_to_matrix.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,51 @@
+
+
+    Join RSEM estimates from multiple samples into a single matrix
+    
+        trinity
+    
+    
+
+        trinityToolWrapper.py util/RSEM_util/merge_RSEM_counts_and_labels_single_table.pl
+
+		--labels
+        #for $entry in $RSEM_samples:
+        	${entry.column_label}
+        #end for
+
+		--RSEM_counts
+        #for $entry in $RSEM_samples:
+        	${entry.file}
+        #end for
+
+        > RSEM.counts.matrix
+
+    
+    
+
+       
+              
+              
+       
+
+    
+    
+        
+	
+    
+
+
+		
+			
+			
+			
+			
+			
+        
+	
+
+    
+    
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/abundance_estimation_to_matrix.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/abundance_estimation_to_matrix.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,42 @@
+
+
+    Join RSEM estimates from multiple samples into a single matrix
+    
+        trinity
+    
+    
+
+        abundance_estimation_to_matrix_wrapper.py 
+		#for $q in $RSEM_samples
+			${q.file} "${q.column_label}"
+		#end for
+
+    
+    
+
+       
+              
+              
+       
+
+    
+    
+        
+	
+    
+
+
+		
+			
+			
+			
+			
+			
+        
+	
+
+    
+    
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/abundance_estimation_to_matrix_wrapper.py	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+
+import sys, os, string, subprocess
+
+#aliasing the filenames using the labels
+
+
+def run_command(command):
+    print "Running command: " + command
+    
+    err_capture_file = open("my.stderr", 'w') # writing stderr to a file
+    cmd_run = subprocess.Popen(args=command, shell=True, stderr=err_capture_file, stdout=sys.stdout)
+    err = cmd_run.wait() # get exit code from command execution
+    err_capture_file.close()
+
+    if err:
+        # report the error messages we captured, and exit non-zero
+        sys.stderr.write("Error, cmd: " + command + " died with ret: " + `err`)
+        for line in open(err_capture_file):
+            sys.stderr.write(line)
+        sys.exit(err)
+    return
+
+label_list = []  # symlink files to the labels
+for i in range(1, len(sys.argv), 2):
+    filename=sys.argv[i]
+    label= sys.argv[i+1]
+    cmd= "ln -sf " + filename + " " + label
+    label_list.append(label)
+    run_command(cmd)
+
+
+# run the abundance estimation script
+
+cmd = os.path.dirname(sys.argv[0]) + "/trinityToolWrapper.py " + " util/abundance_estimates_to_matrix.pl --est_method RSEM --cross_sample_fpkm_norm TMM " + " ".join(label_list) 
+
+run_command(cmd)
+
+sys.exit(0)
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/align_and_estimate_abundance.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/align_and_estimate_abundance.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,90 @@
+
+
+    run RSEM to estimate transcript abundances
+    
+        trinity
+    
+    
+
+        trinityToolWrapper.py util/align_and_estimate_abundance.pl --transcripts $transcripts --est_method RSEM --aln_method bowtie --trinity_mode --prep_reference
+
+        ## Inputs.
+        #if str($inputs.paired_or_single) == "paired":
+            --left $inputs.left_input --right $inputs.right_input
+            #if  $inputs.left_input.ext == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+            
+        #else:
+            --single $inputs.input
+            #if  str($inputs.input.ext) == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+        #end if
+
+
+    
+    
+		
+
+		
+                    
+                
+                
+            
+            
+                
+                
+                
+                    
+                    
+                    
+                
+
+            
+            
+                
+                
+                    
+                    
+                    
+                
+
+            
+        
+
+	
+    
+    
+        
+		
+
+
+	
+    
+
+
+		
+			
+			
+			
+			
+			
+        
+	
+
+    
+    
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/alignreads.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/alignreads.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,138 @@
+
+
+    alignReads: short read alignment tool wrapper
+    
+        trinity
+    
+    
+
+        trinityToolWrapper.py util/alignReads.pl --target $target -o alignment --aligner $aligner_selection.aligner
+
+
+        ## Inputs.
+        #if str($inputs.paired_or_single) == "paired":
+            --left $inputs.left_input --right $inputs.right_input
+            #if  $inputs.left_input.ext == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+			--max_dist_between_pairs $inputs.max_dist_between_pairs
+        #else:
+            --single $inputs.input
+            #if  str($inputs.input.ext) == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+        #end if
+
+        ## Additional parameters.
+	    ##if str($inputs.use_additional) == "yes":
+		##	-- $inputs.additional_params
+        ##end if
+	
+                
+        ## direct to output
+	    > outCapture.txt  
+
+
+    
+    
+		
+
+        
+		    
+                
+                
+            
+            
+                
+                
+                
+                    
+                    
+                    
+                
+                
+
+
+            
+            
+                
+                
+                    
+                    
+                    
+                
+            
+        
+
+		
+			
+				
+				
+				
+			
+			
+				
+				
+			
+			
+			
+			
+			
+		
+
+
+	
+
+    
+    
+        
+		
+
+		
+
+	
+    
+
+
+		
+			
+			
+			
+			
+			
+        
+	
+
+    
+    
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/analyze_diff_exp.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/analyze_diff_exp.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,41 @@
+
+
+    Analyze differential expression
+    
+        trinity
+    
+    
+
+        analyze_diff_exp_wrapper.py $EdgeRTarGz $TMM_Matrix_FPKM $Pvalue $Cvalue 
+	
+    
+    
+              
+              
+	      
+	      
+      
+    
+    
+        
+	
+	
+	
+    
+    
+
+
+		
+			
+			
+			
+			
+			
+        
+	
+
+    
+    
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/analyze_diff_exp_wrapper.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/analyze_diff_exp_wrapper.py	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,63 @@
+import sys, os, subprocess
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit()
+
+usage= "usage: " + sys.argv[0] + " " + "edgeR.tar.gz " + "TMM_normalized_FPKM_matrix " + "P-value " + "C-value"
+print sys.argv 
+print usage 
+print " "
+
+if len(sys.argv)<5:
+	print "Require atleast two parameters"
+else:
+	print "All good- command going ahead"
+print " "
+
+Normalized_Matrix=sys.argv[2]
+Pvalue=sys.argv[3]
+Cvalue=sys.argv[4]
+
+def run_command(cmd):
+	print "The command used: " + cmd
+	pipe= subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
+        pipe.wait()
+	ret= pipe.returncode
+	if ret:
+		print "command died: " + str(ret)
+                print pipe.stderr.readlines()
+                sys.exit(1)
+	else:
+		return
+print " "
+
+Final_tar_gz= "edgeR.tar.gz"
+run_command("cp "+ sys.argv[1] + " " + "Final_tar_gz")
+run_command("tar -xvf " + "Final_tar_gz")
+run_command("mv " + "edgeR_results" + "/* ." )
+
+# run the analyze command
+cmd= TRINITY_BASE_DIR + "/Analysis/DifferentialExpression/analyze_diff_expr.pl "+ "--matrix " +  Normalized_Matrix + " -P " +  Pvalue + " -C " + Cvalue
+run_command(cmd)
+
+origMatrixName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix"
+# diffExpr.P0.001_C2.0.matrix
+run_command("mv " + origMatrixName + " diffExpr.matrix")
+
+SampleCorName= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor.dat"
+# diffExpr.P0.001_C2.0.matrix.log2.sample_cor.dat
+run_command("mv " + SampleCorName + " diffExpr.matrix.log2.sample_cor.dat")
+
+CorMatrix= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.sample_cor_matrix.pdf"
+# diffExpr.P0.001_C2.0.matrix.log2.sample_cor_matrix.pdf
+run_command("mv " + CorMatrix + " diffExpr.matrix.log2.sample_cor_matrix.pdf")
+
+Heatmap= "diffExpr.P" + Pvalue + "_" + "C" + Cvalue + ".matrix.log2.centered.genes_vs_samples_heatmap.pdf"
+#diffExpr.P0.001_C2.0.matrix.log2.centered.genes_vs_samples_heatmap.pdf
+run_command("mv " + Heatmap + " diffExpr.matrix.log2.centered.genes_vs_samples_heatmap.pdf")
+
+sys.exit(0)
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/cat.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/cat.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,41 @@
+
+    tail-to-head
+    
+        bash_command_executer.py cat
+        $input1
+        #for $q in $queries
+            ${q.input2}
+        #end for
+        > $out_file1 
+    
+    
+        
+        
+            
+        
+    
+    
+        
+    
+    
+        
+            
+            
+            
+        
+        
+    
+    
+
+    no help
+
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/diffExpress_edgeR.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/diffExpress_edgeR.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,47 @@
+
+
+    Identify Differentially Expressed Transcripts Using EdgeR
+    
+        edgeR
+    
+    
+
+ 		trinityToolWrapper.py Analysis/DifferentialExpression/run_EdgeR.pl 
+			--matrix $counts_matrix 
+			--transcripts $transcripts_fasta_file
+			--output edgeR_results
+			--dispersion $dispersion
+
+		> stdout.txt
+
+
+    
+    
+		
+		
+		
+		
+	
+    
+    
+        
+        
+
+        
+
+		
+	
+	
+    
+
+		
+			
+
+        
+	
+
+    
+    
+         help info here.
+    
+
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/trinityToolWrapper.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/trinityToolWrapper.py	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+
+# borrowed from: http://wiki.g2.bx.psu.edu/Future/Job%20Failure%20When%20stderr and modified for use with Trinity tools.
+
+"""
+Wrapper that execute a program and its arguments but reports standard error
+messages only if the program exit status was not 0
+Example: ./stderr_wrapper.py myprog arg1 -f arg2
+"""
+
+import sys, subprocess, os
+
+assert sys.version_info[:2] >= ( 2, 4 )
+
+TRINITY_BASE_DIR = ""
+if os.environ.has_key('TRINITY_HOME'):
+    TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
+else:
+    sys.stderr.write("You must set the environmental variable TRINITY_BASE_DIR to the base installation directory of Trinity before running this");
+    sys.exit()
+
+
+
+# get bindir
+bindir = sys.argv[0]
+bindir = bindir.split("/")
+if len(bindir) > 1:
+    bindir.pop()
+    bindir = "/".join(bindir)
+else:
+    bindir = "."
+
+
+## add locations of tools to path setting.
+TOOL_PATHS_FILE = bindir + "/__add_to_PATH_setting.txt";
+for line in open(TOOL_PATHS_FILE):
+    line = line.rstrip()
+    os.environ['PATH'] += ":" + line
+
+
+def stop_err( msg ):
+    sys.stderr.write( "%s\n" % msg )
+    sys.exit()
+
+def __main__():
+    # Get command-line arguments
+    args = sys.argv
+    # Remove name of calling program, i.e. ./stderr_wrapper.py
+    args.pop(0)
+    # If there are no arguments left, we're done
+    if len(args) == 0:
+        return
+
+    # If one needs to silence stdout 
+    #args.append( ">" )
+    #args.append( "/dev/null" )
+
+    args[0] = "".join([TRINITY_BASE_DIR, '/', args[0]]);
+
+    cmdline = " ".join(args)
+
+    
+
+    try:
+        # Run program
+        err_capture = open("stderr.txt", 'w')
+        proc = subprocess.Popen( args=cmdline, shell=True, stderr=err_capture, stdout=sys.stdout )
+        returncode = proc.wait()
+        err_capture.close()
+
+        
+        if returncode != 0:
+            raise Exception
+
+    except Exception:
+        # Running Grinder failed: write error message to stderr
+        err_text = open("stderr.txt").readlines()
+        stop_err( "ERROR:\n" + "\n".join(err_text))
+
+
+if __name__ == "__main__": __main__()
diff -r 70e3c4c34a7c -r 87c03e2aeba3 trinityrnaseq_protocol/trinityrnaseq.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trinityrnaseq_protocol/trinityrnaseq.xml	Sun Oct 18 10:40:27 2015 -0400
@@ -0,0 +1,127 @@
+
+
+    
+    De novo assembly of RNA-Seq data Using Trinity
+    
+        trinity
+    
+    
+        trinityToolWrapper.py Trinity --max_memory $JM --CPU $CPU
+        
+        ## Inputs.
+        #if str($inputs.paired_or_single) == "paired":
+            --left $inputs.left_input --right $inputs.right_input
+    		#if  $inputs.left_input.ext == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+			--group_pairs_distance $inputs.group_pairs_distance
+        #else:
+            --single $inputs.input
+            #if  str($inputs.input.ext) == 'fa':
+                --seqType fa
+            #else:
+                --seqType fq
+            #end if
+            #if str($inputs.library_type) != "None":
+                --SS_lib_type $inputs.library_type
+            #end if
+        #end if
+
+        ## Additional parameters.
+        #if str($additional_params.use_additional) == "yes":
+			--min_kmer_cov $inputs.min_kmer_cov --max_reads_per_graph $inputs.max_reads_per_graph --bflyHeapSpaceMax $input.bflyHeapSpaceMax
+			#if $inputs.bfly_opts != 'None':
+				--bfly_opts " $inputs.bfly_opts "
+			#end if
+        #end if
+	
+                
+        ## direct to output
+        > $trinity_log 
+ 
+    
+    
+      	
+			
+			
+			
+			
+			
+			
+		
+
+		
+
+
+        
+		    
+                
+                
+            
+            
+                
+                
+                
+                    
+                    
+                    
+                
+                
+		            
+
+            
+            
+                
+                
+                    
+                    
+                    
+                
+	                
+            
+        
+    	
+		
+            
+                
+                
+            
+            
+            
+                        
+				
+				
+				
+			
+				
+				
+					
+					
+					
+					
+					
+				
+
+               
+            
+        
+    
+
+    
+    
+        
+        
+    
+    
+    
+    
+        Trinity is a de novo transcript assembler that uses RNA-seq data as input. This tool runs all Trinity_ commands--Inchworm, Chrysalis, and Butterfly--in a single pass.
+        
+        .. _Trinity: http://trinityrnaseq.sourceforge.net
+    
+