From b54812cf50ad27dfd68edb4bb3dc59aead7a4187 Mon Sep 17 00:00:00 2001
From: Brandi Cantarel <brandi.cantarel@utsouthwestern.edu>
Date: Mon, 26 Mar 2018 09:20:34 -0500
Subject: [PATCH] update support single-end

---
 alignment/rnaseqalign.sh    | 11 +++++++----
 preproc_fastq/trimgalore.sh | 10 +++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/alignment/rnaseqalign.sh b/alignment/rnaseqalign.sh
index 52de23a..ecee18b 100644
--- a/alignment/rnaseqalign.sh
+++ b/alignment/rnaseqalign.sh
@@ -40,9 +40,12 @@ if [[ -z $SLURM_CPUS_ON_NODE ]]
 then
     SLURM_CPUS_ON_NODE=1
 fi
+
+diff $fq1 $fq2 > difffile.out
+
 if [ $algo == 'star' ]
 then
-    if ($fq1 != $fq2)
+    if (-s difffile)
     then
 	module load star/2.4.2a
 	STAR --genomeDir ${index_path}/star_index/ --readFilesIn $fq1 $fq2 --readFilesCommand zcat --genomeLoad NoSharedMemory --outFilterMismatchNmax 999 --outFilterMismatchNoverReadLmax 0.04 --outFilterMultimapNmax 20 --alignSJoverhangMin 8 --alignSJDBoverhangMin 1 --alignIntronMin 20 --alignIntronMax 1000000 --alignMatesGapMax 1000000 --outSAMheaderCommentFile COfile.txt --outSAMheaderHD @HD VN:1.4 SO:coordinate --outSAMunmapped Within --outFilterType BySJout --outSAMattributes NH HI AS NM MD --outSAMstrandField intronMotif --outSAMtype BAM SortedByCoordinate --quantMode TranscriptomeSAM --sjdbScore 1 --limitBAMsortRAM 60000000000 --outFileNamePrefix out
@@ -53,11 +56,11 @@ then
     mv outAligned.sortedByCoord.out.bam output.bam
 else
     module load hisat2/2.1.0-intel
-    if [ $fq1 == $fq2 ]
+    if [ -s difffile ]
     then
-	hisat2 -p $SLURM_CPUS_ON_NODE --rg-id ${pair_id} --rg LB:tx --rg PL:illumina --rg PU:barcode --rg SM:${pair_id} --add-chrname --no-unal --dta -x ${index_path}/hisat_index/genome -U $fq1 -S out.sam --summary-file ${pair_id}.alignerout.txt
-    else
 	hisat2 -p $SLURM_CPUS_ON_NODE --rg-id ${pair_id} --rg LB:tx --rg PL:illumina --rg PU:barcode --rg SM:${pair_id} --add-chrname --no-unal --dta -x ${index_path}/hisat_index/genome -1 $fq1 -2 $fq2 -S out.sam --summary-file ${pair_id}.alignerout.txt
+    else
+	hisat2 -p $SLURM_CPUS_ON_NODE --rg-id ${pair_id} --rg LB:tx --rg PL:illumina --rg PU:barcode --rg SM:${pair_id} --add-chrname --no-unal --dta -x ${index_path}/hisat_index/genome -U $fq1 -S out.sam --summary-file ${pair_id}.alignerout.txt
     fi
     samtools view -1 --threads $SLURM_CPUS_ON_NODE -o output.bam out.sam
 fi
diff --git a/preproc_fastq/trimgalore.sh b/preproc_fastq/trimgalore.sh
index b941ef1..1ae8ba1 100644
--- a/preproc_fastq/trimgalore.sh
+++ b/preproc_fastq/trimgalore.sh
@@ -32,13 +32,13 @@ r2base="${fq2%.fastq*}"
 source /etc/profile.d/modules.sh
 module load trimgalore/0.4.1 cutadapt/1.9.1
 
-if [ $fq1 == $fq2 ]
+if [ -s $fq2 ]
 then
-    trim_galore -q 25 --illumina --gzip --length 35 ${fq1}
-    mv ${r1base}_trimmed.fq.gz ${pair_id}.trim.R1.fastq.gz
-    cp ${pair_id}.trim.R1.fastq.gz ${pair_id}.trim.R2.fastq.gz 
-else
     trim_galore --paired -q 25 --illumina --gzip --length 35 ${fq1} ${fq2}
     mv ${r1base}_val_1.fq.gz ${pair_id}.trim.R1.fastq.gz
     mv ${r2base}_val_2.fq.gz ${pair_id}.trim.R2.fastq.gz
+else
+    trim_galore -q 25 --illumina --gzip --length 35 ${fq1}
+    mv ${r1base}_trimmed.fq.gz ${pair_id}.trim.R1.fastq.gz
+    cp ${pair_id}.trim.R1.fastq.gz ${pair_id}.trim.R2.fastq.gz 
 fi
-- 
GitLab