Entering edit mode
2.3 years ago
Leya
•
0
Here is the script for converting the fastq files to Bam files. I keep getting The fail to read the header error. The sam file also comes up empty so I'm not sure what the issue is.
#trimming paired-end
#good version
>&2 echo "Trimming file $base ..."
>&2 date
$javabin/java -jar $trimmomaticbin/$trimmomaticjarfile PE -threads 16 -phred33 $dirname/"$base"_R1_001.fastq.gz $dirname/"$base"_R2_001.fastq.gz $trimdir/"$base"_1.paired.fastq.gz $trimdir/"$base"_1.unpaired.fastq.gz $trimdir/"$base"_2.paired.fastq.gz $trimdir/"$base"_2.unpaired.fastq.gz ILLUMINACLIP:$adapterpath/Truseq3.PE.fa:2:15:4:4:true LEADING:20 TRAILING:20 SLIDINGWINDOW:4:15 MINLEN:25
>&2 echo "Second stage trimming $base ..."
>&2 date
$kseqbin/kseq_test $trimdir/"$base"_1.paired.fastq.gz $len $trimdir2/"$base"_1.paired.fastq.gz
$kseqbin/kseq_test $trimdir/"$base"_2.paired.fastq.gz $len $trimdir2/"$base"_2.paired.fastq.gz
>&2 echo "Aligning file $base ..."
>&2 date
$bowtie2bin/bowtie2 -p 16 --dovetail --phred33 -x $bt2idx/GRCh38 -1 $trimdir2/"$base"_1.paired.fastq.gz -2 $trimdir2/"$base"_2.paired.fastq.gz > $aligndir/"$base"_aligned_reads.sam 2> $logdir/"$base".bowtie2
$samtoolsbin/samtools view -bS -@ 16 $aligndir/"$base"_aligned_reads.sam > $aligndir/"$base"_aligned_reads.bam
rm $aligndir/"$base"_aligned_reads.sam
>&2 echo "Finished"
>&2 date
Pro-tip: Always add these lines to the beginning of a shell script for better debugging:
The first line ensures the script fails if any of the commands fail. The second line echoes every command being executed to STDERR so you can ensure variables are not taking unexpected values and breaking code logic.