From 724ecd45a3622b7ce79d0f8ac641d004a6a90e57 Mon Sep 17 00:00:00 2001
From: s181706 <jonathan.gesell@utsouthwestern.edu>
Date: Thu, 23 Jan 2020 10:33:20 -0600
Subject: [PATCH] Added indexing step to align, verified output files.

---
 workflow/rna-seq.nf | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/workflow/rna-seq.nf b/workflow/rna-seq.nf
index 2928f83..940baa4 100755
--- a/workflow/rna-seq.nf
+++ b/workflow/rna-seq.nf
@@ -243,7 +243,7 @@ process alignReads {
     val referenceDir_alignReads
 
   output:
-    set repRID, file ("${repRID}.unal.gz"), file ("${repRID}.bam"), file ("${repRID}.bai")
+    set repRID, file ("${repRID}.unal.gz"), file ("${repRID}.sorted.bam"), file ("${repRID}.sorted.bai")
 
   script:
     """
@@ -252,6 +252,7 @@ process alignReads {
     else hisat2 -p `nproc` --add-chrname --un-gz ${repRID}.unal.gz -S ${repRID}.sam -x ${referenceDir_alignReads} ${stranded_alignReads} -U ${fqs[0]} 1>${repRID}.align.out 2>${repRID}.align.err;
     fi;
     samtools view -1 --threads `nproc` -o ${repRID}.bam ${repRID}.sam 1>>${repRID}.align.out 2>>${repRID}.align.err;
-    samtools sort -@ `nproc` -O BAM  -o ${repRID}.bam 1>>${repRID}.align.out 2>>${repRID}.align.err;
+    samtools sort -@ `nproc` -O BAM -o ${repRID}.sorted.bam ${repRID}.bam 1>>${repRID}.align.out 2>>${repRID}.align.err;
+    samtools index -@ `nproc` -b ${repRID}.sorted.bam ${repRID}.sorted.bai 1>>${repRID}.align.out 2>>${repRID}.align.err;
     """
 }
-- 
GitLab