As I mentioned before its taken a while to sort out a method that can automate a paired-end analysis using BWA but it seems to work now. Feel free to use the scripts below in conjunction with the "create_ngs_directorystructure_v3.sh" script that creates the required directory structure.
The following two scripts can be used to process files using BWA to automate a paired-end analysis from the output "s_x_sequence.txt" files to aligned, indexed, and duplicate removed BAM files. The design of the pipeline has a couple of requirements:
1) You need to have all the required applications in a $PATH directory. As detailed in this thread I personally use "$HOME/local/bin".
2) You will need; MAQ with ill2sanger patch installed, BWA, SAMTOOLS, and PICARD MarkDuplicates.jar in this path directory.
NOTE: If you use a different path directory you need to alter line 623 of BWApe_hg18_v1.sh as MarkDuplicates.jar is being called specifically from this directory while all others are being called through the $PATH directory. ****If you know how to put a directory in the JAVA path on a Mac drop me a line****
3) Both shell scripts are designed to be in your $PATH directory so you can call them from the ngs directory using "BWApe_hg18_v1.sh" for a single sample analysis or "multi_bwape_analysis_v1.sh" for a multiple sample analysis. Alternatively, you can place them in the "/ngs" folder and call them directly using "./BWApe_hg18_v1.sh" or "./multi_bwape_analysis_v1.sh" (NOTE: If you do this you need to modify the lines that launch BWApe_hg18_v1.sh to include the direct launch indicator "./"
4) The input file names must be unique and end with a "_R1.txt" read identifier such as "YourSample_R1.txt" and "YourSample_R2.txt"
NOTE: The name BWApe_hg18_v1.sh only reflects the reference genome used in the development of the script. You can easily change to what ever genome mouse, human you want to use you just need to generate the bwa index and update the BWApe_hg18_v1.sh script as indicated in the script.
NOTE: If using "BWApe_hg18_v1.sh" you need to place the raw illumina files in "ngs/bwape/inputsequences/illumina/read1" and "ngs/bwape/inputsequences/illumina/read2". If using "multi_bwape_analysis_v1.sh" you need to place the raw illumina files in "ngs/bwape/inputsequences/hold/laneX/read1" and "ngs/bwape/inputsequences/hold/laneX/read2" as appropriate to your sample set. The script is only designed for 8 lanes/samples so if you have more you needed to copy/paste to extend the script. After completing each lane/sample it checks to see if there is data for another lane/sample in the next sequential lane/sample folder and process it if available or ends the script if it is empty, so you need to put files in the hold/lane1, 2, 3, 4, 5, 6, 7, and 8 read folders in order.
Code:
#!/bin/sh
# BWApe_hg18_V1.sh
# Created by Jonathan Keats
# Translational Genomics Research Institute
# This script is designed to take a batch of raw Illumina 1.3+ reads to sorted and indexed BAM files with and without duplicates using BWA in paired end mode.
# It is designed to be initiated from a folder called "ngs" in your $HOME folder with a specific subdirectory structure
# To create the directory struture launch "create_ngs_directorystructure_v3.sh" from your "$Home" folder
####################################################################################################
## To Run This Script You Must Have The Following Applications In One Of Your $PATH Directories ##
## 1) MAQ with ill2sanger patch installed ##
## 2) BWA ##
## 3) SAMTOOLS ##
## 4) PICARD - MarkDuplicates.jar (Must be in $HOME/local/bin) ##
####################################################################################################
# To run this script you MUST first place your reference file in ngs/refgenomes/bwa_indexed and have run the "bwa index" command to create the BWT index files
######################################################################################################
# WARNING - YOU MUST ENSURE THE NAME OF YOUR REFERENCE GENOME FILE MATCHES LINES (274, 310, and 367) #
######################################################################################################
# The script is based on having ***RENAMED*** Illumina files in "ngs/bwape/inputsequences/illumina/read1" and "ngs/bwape/inputsequences/illumina/read2"
# The renamed format ***MUST*** be "YourSampleName_R1.txt" and "YourSampleName_R2.txt" otherwise pairing and renaming will not occur correctly
# Multiple lanes should be concatinated together before initiating the script, unless you want to manually merge in samtools
# At each step it queries specific folders for available files and passes them to the next analysis module
# After each step the filename extension of the output files are corrected. (ie. "MySequenceFile_R1.txt.fastq" to "MySequenceFile_R1.fastq")
# Order of Embedded Steps - Converts Illumina 1.3+ fastq files "s_1_sequence.txt" to Sanger fastq files "s_1_sequence.fastq" using "maq ill2sanger" command
# - Aligns created fastq files to reference genome using "bwa aln" command
# - Generates SAM files from alignment files using "bwa sampe" command
# - Converts SAM files to BAM files using "samtools view" command
# - Sorts BAM files using "samtools sort" command
# - Indexes the sorted BAM files for use in IGV browser using "samtools index" command
# - Removes duplicates from the sorted bam files using "picard - MarkDuplicates.jar" command
# - Indexes the no duplicates BAM files for use in IGV browser using "samtools index" command
# - Final output files are archived then the input and analysis directories are cleaned-up and readied for the next analysis batch
# The script creates a log file in /ngs/analysisnotes to track the steps completed and the time each step started and finished
# Some of the log events will print to both the terminal screen and the log file so you can see what is going on
# Much of this would not be possible with out the help of a former colleagues husband who is a Unix programmer in France so I've kept some french terms such as linge instead of line in his honor (thanks Charabelle)
#Starting directory = $HOME/ngs
#In this step - We check that you are lauching the script from the correct location in case you are using it from a path directory
# - We check that the destination directories used by the script are empty to prevent deleting erroneous files and unexpected analysis events
# - Hope to add a check for available disk space
echo ***Checking Diretory Structure***
#List of directoryies to check
var1=$HOME/ngs
var2=$HOME/ngs/bwape/samfiles
var3=$HOME/ngs/bwape/bamfiles/merged
var4=$HOME/ngs/bwape/bamfiles/original
var5=$HOME/ngs/bwape/bamfiles/sorted
var6=$HOME/ngs/bwape/bamfiles/nodups
var7=$HOME/ngs/bwape/inputsequences/sangerfastq/read1
var8=$HOME/ngs/bwape/inputsequences/sangerfastq/read2
#Checking if launch location is correct
if [ "`pwd`" != "$var1" ]
then
echo " The script must be launched from the NGS directory "
echo " The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "1) Launch Location is Correct ($HOME/ngs)"
#Checking if analysis directories are empty
if [ `ls $var2 | wc -l` != 0 ]
then
echo " The bwape/samfiles directory is not empty - Any data in this directory would be deleted by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "2) bwape/samfiles directory is empty as required"
if [ `ls $var3 | wc -l` != 0 ]
then
echo " The bwape/bamfiles/merged directory is not empty - Any data in this directory would be moved by the script to ngs/finaloutputs/bamfiles/merged "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "3) bwape/bamfiles/merged directory is empty as required"
if [ `ls $var4 | wc -l` != 0 ]
then
echo " The bwape/bamfiles/original directory is not empty - Any data in this directory would be deleted by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "4) bwape/bamfiles/original directory is empty as required"
if [ `ls $var5 | wc -l` != 0 ]
then
echo " The bwape/bamfiles/sorted directory is not empty - Any data in this directory would be moved by the script to ngs/finaloutputs/bamfiles/sorted by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "5) bwape/bamfiles/sorted directory is empty as required"
if [ `ls $var6 | wc -l` != 0 ]
then
echo " The bwape/bamfiles/nodups directory is not empty - Any data in this directory would be moved by the script to ngs/finaloutputs/bamfiles/nodups by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "6) bwape/bamfiles/nodups directory is empty as required"
if [ `ls $var7 | wc -l` != 0 ]
then
echo " The bwape/illuminasequences/sangerfastq/read1 directory is not empty - Any data in this directory would be moved by the script to ngs/finaloutputs/bamfiles/nodups by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "7) bwape/illuminasequences/sangerfastq/read1 directory is empty as required"
if [ `ls $var8 | wc -l` != 0 ]
then
echo " The bwape/illuminasequences/sangerfastq/read2 directory is not empty - Any data in this directory would be moved by the script to ngs/finaloutputs/bamfiles/nodups by the script "
echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message"
exit 2
fi
echo "8) bwape/illuminasequences/sangerfastq/read2 directory is empty as required"
echo ***Pre Run Check Completed Successfully***
#Current directory=ngs
echo ***Starting BWA SAMPE Analysis Batch***
date '+%m/%d/%y %H:%M:%S'
#The following step creates the log file in the AnalysisNotes subdirectory the first time the script is run
#On subsequent runs the results are printed at the bottom of the pre-existing log file
echo ***Starting BWA SAMPE Analysis Batch*** >> analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log
#In the next step we convert the "Read1" illumina fastq files to sanger fastq files using the maq ill2sanger script
echo Starting Step1a - Read1 Illumina to Sanger Fastq Conversion with maq ill2sanger
date '+%m/%d/%y %H:%M:%S'
echo Starting Step1a - Illumina to Sanger Fastq Conversion with maq ill2sanger >> AnalysisNotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log
cd bwape/inputsequences/illumina/read1
#Current directory = ngs/bwape/inputsequences/illumina/read1
echo Converting the following Illumina files:
for ligne in `ls *.txt`
do
echo $ligne
done
echo Converting the following Illumina files: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.txt`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.txt`
do
maq ill2sanger $ligne ../../sangerfastq/read1/$ligne.fastq
done
#In the next step we clean up the Illumina Read1 folder so it is ready for the next analysis batch
echo Cleaning up Input Sequences Illumina Read1
date '+%m/%d/%y %H:%M:%S'
echo Cleaning up Input Sequences Illumina Read1 >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo Moving the following Illumina Fastq Files from ngs/bwape/inputsequences/illumina/read1 to ngs/finaloutputs/illumina:
for ligne in `ls *.txt`
do
echo $ligne
done
echo Moving the following Illumina Fastq Files from ngs/bwase/inputsequences/illumina/read1 to ngs/finaloutputs/illumina >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.txt`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.txt`
do
mv $ligne ../../../../finaloutputs/illumina
done
#In the next step we rename the "Read1" sanger format fastq files from ".txt.fastq" extensions to ".fastq"
cd ../../sangerfastq/read1
#Current directory = ngs/bwape/inputsequences/sangerfastq/read1
old_ext=txt.fastq
new_ext=fastq
find . -type f -name "*.$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step1a - Illumina to Sanger Fastq Conversion
date '+%m/%d/%y %H:%M:%S'
echo Finished Step1a - Illumina to Sanger Fastq Conversion >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we convert the "Read2" illumina fastq files to sanger fastq files using the maq ill2sanger script
cd ../../illumina/read2
#Current directory = ngs/bwape/inputsequences/illumina/read2
echo Starting Step1b - Read2 Illumina to Sanger Fastq Conversion with maq ill2sanger
date '+%m/%d/%y %H:%M:%S'
echo Starting Step1b - Read2 Illumina to Sanger Fastq Conversion with maq ill2sanger >> ../../../../AnalysisNotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo Converting the following Illumina files:
for ligne in `ls *.txt`
do
echo $ligne
done
echo Converting the following Illumina files: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.txt`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.txt`
do
maq ill2sanger $ligne ../../sangerfastq/read2/$ligne.fastq
done
#In the next step we clean up the Illumina Read2 folder so it is ready for the next analysis batch
echo Cleaning up Input Sequences Illumina Read2
date '+%m/%d/%y %H:%M:%S'
echo Cleaning up Input Sequences Illumina Read2 >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo Moving the following Illumina Fastq Files from ngs/bwape/inputsequences/illumina/read2 to ngs/finaloutputs/illumina:
for ligne in `ls *.txt`
do
echo $ligne
done
echo Moving the following Illumina Fastq Files from ngs/bwase/inputsequences/illumina/read2 to ngs/finaloutputs/illumina >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.txt`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.txt`
do
mv $ligne ../../../../finaloutputs/illumina
done
#In the next step we rename the "Read2" sanger format fastq files from ".txt.fastq" extensions to ".fastq"
cd ../../sangerfastq/read2
#Current directory = ngs/bwape/inputsequences/sangerfastq/read2
old_ext=txt.fastq
new_ext=fastq
find . -type f -name "*.$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step1b - Illumina to Sanger Fastq Conversion
date '+%m/%d/%y %H:%M:%S'
echo Finished Step1b - Illumina to Sanger Fastq Conversion >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we will align the converted "Read1" sanger fastq format files to the reference genome
echo Starting Step2a - Read1 bwa aln process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step2a - Read1 bwa aln process >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
cd ../read1
#Current directory = ngs/bwape/inputsequences/sangerfastq/read1
echo The following fastq files will be aligned:
for ligne in `ls *.fastq`
do
echo $ligne
done
echo The following fastq files will be aligned: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.fastq`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.fastq`
do
bwa aln ../../../../refgenomes/bwa_indexed/hg18.fasta $ligne > $ligne.sai
done
#In the next step we will rename the "Read1" alignment files
old_ext=.fastq.sai
new_ext=_bwa.sai
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step2a - bwa aln process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step2a - bwa aln process >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we will align the converted "Read2" sanger fastq format files to the reference genome
echo Starting Step2b - Read2 bwa aln process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step2b - Read2 bwa aln process >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
cd ../read2
#Current directory = ngs/bwape/inputsequences/sangerfastq/read2
echo The following fastq files will be aligned:
for ligne in `ls *.fastq`
do
echo $ligne
done
echo The following fastq files will be aligned: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.fastq`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.fastq`
do
bwa aln ../../../../refgenomes/bwa_indexed/hg18.fasta $ligne > $ligne.sai
done
#In the next step we will rename the "Read2" alignment files
old_ext=.fastq.sai
new_ext=_bwa.sai
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step2b - bwa aln process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step2b - bwa aln process >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we will generate SAM files for the alignments using bwa sampe
echo Starting Step3 - bwa sampe process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step3 - bwa sampe process >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo The following alignment files will be converted to SAM files:
cd ../read1
#Current directory = ngs/bwape/inputsequences/sangerfastq/read1
for ligne in `ls *.sai`
do
aln1=`echo $ligne`
done
echo $aln1
for ligne in `ls *.fastq`
do
read1=`echo $ligne`
done
echo $read1
cd ../read2
#Current directory = ngs/bwape/inputsequences/sangerfastq/read2
for ligne in `ls *.sai`
do
aln2=`echo $ligne`
done
echo $aln2
for ligne in `ls *.fastq`
do
read2=`echo $ligne`
done
echo $read2
echo The following alignment files will be converted to SAM files: >> ../../../../analysisnotes/Analysis.log
echo $aln1 >> ../../../../analysisnotes/Analysis.log
echo $read1 >> ../../../../analysisnotes/Analysis.log
echo $aln2 >> ../../../../analysisnotes/Analysis.log
echo $read2 >> ../../../../analysisnotes/Analysis.log
cd ../../../samfiles
#Current directory = ngs/bwape/samfiles
#(bwa sampe <database.fasta> <aln1.sai> <aln2.sai> <input1.fastq> <input2.fastq> > aln.sam)
bwa sampe ../../refgenomes/bwa_indexed/hg18.fasta ../inputsequences/sangerfastq/read1/$aln1 ../inputsequences/sangerfastq/read2/$aln2 ../inputsequences/sangerfastq/read1/$read1 ../inputsequences/sangerfastq/read2/$read2 > $read1.sam
#In the next step we will rename the SAM files generated by bwa sampe analysis of the "Read1" and "Read2" alignment files
old_ext=_R1.fastq.sam
new_ext=_bwape.sam
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step3 - bwa sampe process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step3 - bwa sampe process >> ../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../analysisnotes/Analysis.log
#In the next step we will convert each SAM file to a BAM file
echo Starting Step4 - samtools SAM to BAM conversion
date '+%m/%d/%y %H:%M:%S'
echo Starting Step4 - samtools SAM to BAM conversion >> ../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../analysisnotes/Analysis.log
echo The following SAM files will be converted to BAM files:
for ligne in `ls *.sam`
do
echo $ligne
done
echo The following SAM files will be converted to BAM files: >> ../../analysisnotes/Analysis.log
for ligne in `ls *.sam`
do
echo $ligne >> ../../analysisnotes/Analysis.log
done
for ligne in `ls *.sam`
do
samtools view -bS -o ../bamfiles/original/$ligne.bam $ligne
done
#In the next step we will delete the SAM file to save disc space as the BAM file contains all the data in a binary format
echo Deleting the following SAM Files from ngs/bwape/samfiles:
for ligne in `ls *.sam`
do
echo $ligne
done
echo Deleting the following SAM Files from ngs/bwape/samfiles: >> ../../analysisnotes/Analysis.log
for ligne in `ls *.sam`
do
echo $ligne >> ../../analysisnotes/Analysis.log
done
for ligne in `ls *.sam`
do
rm $ligne
done
echo Deleting SAM Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Deleting SAM Files Complete >> ../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../analysisnotes/Analysis.log
#In the next step we clean up the Sanger Fastq "Read1" folder so it is ready for the next analyis batch
cd ../inputsequences/sangerfastq/read1
#Current directory = ngs/bwape/inputsequences/sangerfastq/read1
echo Moving the following Sanger Format Fastq Files from ngs/bwape/inputsequences/sangerfastq/read1 to ngs/finaloutputs/sangerfastq:
for ligne in `ls *.fastq`
do
echo $ligne
done
echo Moving the following Sanger Format Fastq Files from ngs/bwape/inputsequences/sangerfastq/read1 to ngs/finaloutputs/sangerfastq: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.fastq`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.fastq`
do
mv $ligne ../../../../finaloutputs/sangerfastq/
done
echo Moving Sanger Format Fastq Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Sanger Format Fastq Files Complete >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo Moving the following Alignment .sai Files from ngs/bwape/inputsequences/sangerfastq/read1 to ngs/finaloutputs/alignmentresults_bwa:
for ligne in `ls *.sai`
do
echo $ligne
done
echo Moving the following Alignment .sai Files from ngs/bwape/inputsequences/sangerfastq/read1 to ngs/finaloutputs/alignmentresults_bwa: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.sai`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.sai`
do
mv $ligne ../../../../finaloutputs/alignmentresults_bwa/
done
echo Moving Alignment Results Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Alignment Results Files Complete >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we clean up the Sanger Fastq "Read2" folder so it is ready for the next analyis batch
cd ../read2
#Current directory = ngs/bwape/inputsequences/sangerfastq/read2
echo Moving the following Sanger Format Fastq Files from ngs/bwape/inputsequences/sangerfastq/read2 to ngs/finaloutputs/sangerfastq:
for ligne in `ls *.fastq`
do
echo $ligne
done
echo Moving the following Sanger Format Fastq Files from ngs/bwape/inputsequences/sangerfastq/read2 to ngs/finaloutputs/sangerfastq: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.fastq`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.fastq`
do
mv $ligne ../../../../finaloutputs/sangerfastq/
done
echo Moving Sanger Format Fastq Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Sanger Format Fastq Files Complete >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
echo Moving the following Alignment .sai Files from ngs/bwape/inputsequences/sangerfastq/read2 to ngs/finaloutputs/alignmentresults_bwa:
for ligne in `ls *.sai`
do
echo $ligne
done
echo Moving the following Alignment .sai Files from ngs/bwape/inputsequences/sangerfastq/read2 to ngs/finaloutputs/alignmentresults_bwa: >> ../../../../analysisnotes/Analysis.log
for ligne in `ls *.sai`
do
echo $ligne >> ../../../../analysisnotes/Analysis.log
done
for ligne in `ls *.sai`
do
mv $ligne ../../../../finaloutputs/alignmentresults_bwa/
done
echo Moving Alignment Results Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Alignment Results Files Complete >> ../../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../../analysisnotes/Analysis.log
#In the next step we will rename the BAM files created by the samtools SAM-to-BAM conversion process
cd ../../../bamfiles/original
#Current directory = ngs/bwape/bamfiles/original
old_ext=sam.bam
new_ext=bam
find . -type f -name "*.$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step4 - samtools SAM to BAM conversion
date '+%m/%d/%y %H:%M:%S'
echo Finished Step4 - samtools SAM to BAM conversion >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will sort the BAM file by chromosome coordinate
echo Starting Step5 - samtools BAM sorting process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step5 - samtools BAM sorting process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo The following BAM files will be sorted:
for ligne in `ls *.bam`
do
echo $ligne
done
echo The following BAM files will be sorted: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
samtools sort $ligne ../Sorted/$ligne
done
#In the next step we will delete the original unsorted BAM file to save disc space as the sorted BAM contains all the needed information
echo Deleting the following BAM Files from ngs/bwape/bamfiles/original:
for ligne in `ls *.bam`
do
echo $ligne
done
echo Deleting the following BAM Files from ngs/bwape/bamfiles/original: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
rm $ligne
done
echo Deleting BAM Files from ngs/bwape/bamfiles/original Complete
date '+%m/%d/%y %H:%M:%S'
echo Deleting BAM Files from ngs/bwape/bamfiles/original Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will rename the sort BAM files created by the samtools sort process
cd ../sorted
#Current directory = ngs/bwape/bamfiles/sorted
old_ext=.bam.bam
new_ext=_sorted.bam
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step5 - samtools BAM sorting process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step5 - samtools BAM sorting process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will index the sorted BAM files for fast access and viewing in the IGV browser
echo Starting Step6 - samtools BAM indexing process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step6 - samtools BAM indexing process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo The following BAM files will be indexed:
for ligne in `ls *.bam`
do
echo $ligne
done
echo The following BAM files will be indexed: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
samtools index $ligne
done
echo Finished Step6 - samtools BAM indexing process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step6 - samtools BAM indexing process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will remove the duplicate reads from the sorted bam files
echo Starting Step7 - picard markduplicates process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step7 - picard markduplicates process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo Duplicate reads will be removed from the following sorted BAM files:
for ligne in `ls *.bam`
do
echo $ligne
done
echo Duplicate reads will be removed from the following sorted BAM files: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
java -Xmx2g -jar $HOME/local/bin/MarkDuplicates.jar INPUT=$ligne OUTPUT=../nodups/$ligne METRICS_FILE=../nodups/$ligne.txt REMOVE_DUPLICATES=true ASSUME_SORTED=true VALIDATION_STRINGENCY=SILENT
done
#In the next step we clean up the Sorted BAM files folder so it is ready for the next analyis batch
echo Moving the following Sorted BAM Files from ngs/bwape/bamfiles/sorted to ngs/finaloutputs/bamfiles/sorted:
for ligne in `ls *.bam`
do
echo $ligne
done
echo Moving the following Sorted BAM Files from ngs/bwape/bamfiles/sorted to ngs/finaloutputs/bamfiles/sorted: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
mv $ligne ../../../finaloutputs/bamfiles/sorted/
done
echo Moving Sorted BAM Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Sorted BAM Files Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo Moving the following BAM Index .bai Files from ngs/bwape/bamfiles/sorted to ngs/finaloutputs/bamfiles/sorted:
for ligne in `ls *.bai`
do
echo $ligne
done
echo Moving the following BAM Index .bai Files from ngs/bwape/bamfiles/sorted to ngs/finaloutputs/bamfiles/sorted: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bai`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bai`
do
mv $ligne ../../../finaloutputs/bamfiles/sorted/
done
echo Moving Sorted BAM Index Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving Sorted BAM Index Files Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will rename the BAM files and Metrics files created after duplicate removal by picard
cd ../nodups
#Current directory = ngs/bwape/bamfiles/nodups
old_ext=_sorted.bam
new_ext=_sorted_nodups.bam
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
old_ext=_sorted.bam.txt
new_ext=_sorted_nodups_metrics.txt
find . -type f -name "*$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done
echo Finished Step7 - picard markduplicates process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step7 - picard markduplicates process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we will index the nodups BAM files for fast access and viewing in the IGV browser
echo Starting Step8 - samtools BAM indexing process
date '+%m/%d/%y %H:%M:%S'
echo Starting Step8 - samtools BAM indexing process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo The following BAM files will be indexed:
for ligne in `ls *.bam`
do
echo $ligne
done
echo The following BAM files will be indexed: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
samtools index $ligne
done
#In the next step we clean up the nodups BAM files folder so it is ready for the next analyis batch
echo Moving the following NoDups BAM Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups:
for ligne in `ls *.bam`
do
echo $ligne
done
echo Moving the following NoDups BAM Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bam`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bam`
do
mv $ligne ../../../finaloutputs/bamfiles/nodups/
done
echo Moving NoDups BAM Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving NoDups BAM Files Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo Moving the following NoDups BAM Index .bai Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups:
for ligne in `ls *.bai`
do
echo $ligne
done
echo Moving the following NoDups BAM Index .bai Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.bai`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.bai`
do
mv $ligne ../../../finaloutputs/bamfiles/nodups/
done
echo Moving NoDups BAM Index Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving NoDups BAM Index Files Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo Moving the following MarkDuplicates Metrics Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups:
for ligne in `ls *.txt`
do
echo $ligne
done
echo Moving the following MarkDuplicates Metrics Files from ngs/bwape/bamfiles/nodups to ngs/finaloutputs/bamfiles/nodups: >> ../../../analysisnotes/Analysis.log
for ligne in `ls *.txt`
do
echo $ligne >> ../../../analysisnotes/Analysis.log
done
for ligne in `ls *.txt`
do
mv $ligne ../../../finaloutputs/bamfiles/nodups/
done
echo Moving MarkDuplicates Metrics Files Complete
date '+%m/%d/%y %H:%M:%S'
echo Moving MarkDuplicates Metrics Files Complete >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
echo Finished Step8 - samtools BAM indexing process
date '+%m/%d/%y %H:%M:%S'
echo Finished Step8 - samtools BAM indexing process >> ../../../analysisnotes/Analysis.log
date '+%m/%d/%y %H:%M:%S' >> ../../../analysisnotes/Analysis.log
#In the next step we return to the launch folder $HOME/Documents/ngs
cd ../../..
#Current directory = ngs/
echo ***Analysis Batch Complete***
echo ***Analysis Batch Complete*** >> analysisnotes/Analysis.log
Code:
#!/bin/sh # multi_bwape_analysis_v1.sh # # # Created by Jonathan Keats on 9/5/10. # Translational Genomics Research Institute # This script is designed to allow multiple samples/lanes of paired-end illumina data to be passed into the "BWApe_hg18_v1" pipeline ############################################################################################################################### ## To facilitate its use you must put uniquely named Illumina 1.3+ files in ngs/bwape/inputsequences/hold/lane(X)/read(1-2) # ## It is essential that these file names are uniquely name or overwriting will occur # ## These files MUST have the ".txt" extension characteristic of the Illumina V1.3+ output "s_x_sequences.txt" # ############################################################################################################################### #In this step we check that you are lauching the script from the correct location in case you are using it from a path directory echo ***Checking Current Directory is Correct*** #List of directoryies to check temp1=$HOME/ngs #Checking if launch location is correct if [ "`pwd`" != "$temp1" ] then echo " The script must be launched from the NGS directory " echo " The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Current Directory is Correct*** #Check if files exist in the lane1 hold folder #List of directoryies to check temp2=$HOME/ngs/bwape/inputsequences/hold/lane1/read1 temp3=$HOME/ngs/bwape/inputsequences/hold/lane1/read2 echo ***Checking Lane1 Hold Folder*** if [ `ls $temp2 | wc -l` != 1 ] then echo " The Lane1 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp3 | wc -l` != 1 ] then echo " The Lane1 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** #Current directory=ngs echo ***Starting The Analysis of Lane1*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane1*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane1" data from ngs/bwape/inputsequences/hold/lane1/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane1/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane1/read1 echo Moving Lane1 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane1 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane1 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane1 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane1/read2 echo Moving Lane1 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane1 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane1 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane1 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane1 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample2/lane2 data into the analysis directories #Check if files exist in the lane2 hold folder #List of directoryies to check temp4=$HOME/ngs/bwape/inputsequences/hold/lane2/read1 temp5=$HOME/ngs/bwape/inputsequences/hold/lane2/read2 echo ***Checking Lane2 Hold Folder*** if [ `ls $temp4 | wc -l` != 1 ] then echo " The Lane2 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp5 | wc -l` != 1 ] then echo " The Lane2 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** echo ***Starting The Analysis of Lane2*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane2*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane2" data from ngs/bwape/inputsequences/hold/lane2/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane2/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane2/read1 echo Moving Lane2 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane2 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane2 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane2 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane2/read2 echo Moving Lane2 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane2 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane2 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane2 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane2 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample3/lane3 data into the analysis directories #Check if files exist in the lane3 hold folder #List of directoryies to check temp6=$HOME/ngs/bwape/inputsequences/hold/lane3/read1 temp7=$HOME/ngs/bwape/inputsequences/hold/lane3/read2 echo ***Checking Lane3 Hold Folder*** if [ `ls $temp6 | wc -l` != 1 ] then echo " The Lane3 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp7 | wc -l` != 1 ] then echo " The Lane3 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** #Current directory=ngs echo ***Starting The Analysis of Lane3*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane3*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane3" data from ngs/bwape/inputsequences/hold/lane3/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane3/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane3/read1 echo Moving Lane3 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane3 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane3 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane3 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane3/read2 echo Moving Lane3 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane3 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane3 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane3 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane3 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample4/lane4 data into the analysis directories #Check if files exist in the lane4 hold folder #List of directoryies to check temp8=$HOME/ngs/bwape/inputsequences/hold/lane4/read1 temp9=$HOME/ngs/bwape/inputsequences/hold/lane4/read2 echo ***Checking Lane4 Hold Folder*** if [ `ls $temp8 | wc -l` != 1 ] then echo " The Lane4 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp9 | wc -l` != 1 ] then echo " The Lane4 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** echo ***Starting The Analysis of Lane4*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane4*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane4" data from ngs/bwape/inputsequences/hold/lane4/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane4/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane4/read1 echo Moving Lane4 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane4 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane4 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane4 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane4/read2 echo Moving Lane4 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane4 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane4 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane4 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane4 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample5/lane5 data into the analysis directories #Check if files exist in the lane1 hold folder #List of directoryies to check temp10=$HOME/ngs/bwape/inputsequences/hold/lane5/read1 temp11=$HOME/ngs/bwape/inputsequences/hold/lane5/read2 echo ***Checking Lane1 Hold Folder*** if [ `ls $temp10 | wc -l` != 1 ] then echo " The Lane5 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp11 | wc -l` != 1 ] then echo " The Lane5 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** #Current directory=ngs echo ***Starting The Analysis of Lane5*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane5*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane5" data from ngs/bwape/inputsequences/hold/lane5/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane5/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane5/read1 echo Moving Lane5 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane5 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane5 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane5 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane5/read2 echo Moving Lane5 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane5 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane5 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane5 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane5 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample6/lane6 data into the analysis directories #Check if files exist in the lane6 hold folder #List of directoryies to check temp12=$HOME/ngs/bwape/inputsequences/hold/lane6/read1 temp13=$HOME/ngs/bwape/inputsequences/hold/lane6/read2 echo ***Checking Lane6 Hold Folder*** if [ `ls $temp12 | wc -l` != 1 ] then echo " The Lane6 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp13 | wc -l` != 1 ] then echo " The Lane6 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** echo ***Starting The Analysis of Lane6*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane6*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane6" data from ngs/bwape/inputsequences/hold/lane6/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane6/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane6/read1 echo Moving Lane6 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane6 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane6 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane6 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane6/read2 echo Moving Lane6 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane6 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane6 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane6 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane6 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample7/lane7 data into the analysis directories #Check if files exist in the lane7 hold folder #List of directoryies to check temp14=$HOME/ngs/bwape/inputsequences/hold/lane7/read1 temp15=$HOME/ngs/bwape/inputsequences/hold/lane7/read2 echo ***Checking Lane7 Hold Folder*** if [ `ls $temp14 | wc -l` != 1 ] then echo " The Lane7 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp15 | wc -l` != 1 ] then echo " The Lane7 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** #Current directory=ngs echo ***Starting The Analysis of Lane7*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane7*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane7" data from ngs/bwape/inputsequences/hold/lane7/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane7/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane7/read1 echo Moving Lane7 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane7 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane7 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane7 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane3/read2 echo Moving Lane7 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane7 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane7 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane7 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane7 Analysis Complete*** # The analysis directory should now be empty and we can now load the sample8/lane8 data into the analysis directories #Check if files exist in the lane8 hold folder #List of directoryies to check temp16=$HOME/ngs/bwape/inputsequences/hold/lane8/read1 temp17=$HOME/ngs/bwape/inputsequences/hold/lane8/read2 echo ***Checking Lane8 Hold Folder*** if [ `ls $temp16 | wc -l` != 1 ] then echo " The Lane8 Read1 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi if [ `ls $temp17 | wc -l` != 1 ] then echo " The Lane8 Read2 hold folder does not contain the expect single file " echo " ERROR - The script was automatically killed due to a launch error - See Above Error Message" exit 2 fi echo ***Found Expected Files*** echo ***Starting The Analysis of Lane8*** date '+%m/%d/%y %H:%M:%S' echo ***Starting The Analysis of Lane8*** >> analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> analysisnotes/Analysis.log #In the next step we move the "Lane8" data from ngs/bwape/inputsequences/hold/lane8/(read1-2) to ngs/bwape/inputsequences/illumina/(read1-2) cd bwape/inputsequences/hold/lane8/read1 #Current Directory=ngs/bwape/inputsequences/hold/lane8/read1 echo Moving Lane8 Read1 File to Read1 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane8 Read1 File to Read1 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read1/ done echo Moving Lane8 Read1 File to Read1 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane8 Read1 File to Read1 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../read2 #Current Directory=ngs/bwape/inputsequences/hold/lane8/read2 echo Moving Lane8 Read2 File to Read2 Analysis Directory date '+%m/%d/%y %H:%M:%S' echo Moving Lane8 Read2 File to Read2 Analysis Directory >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log echo Moving the following files: for ligne in `ls *.txt` do echo $ligne done for ligne in `ls *.txt` do echo Moving the following files: >> ../../../../../analysisnotes/Analysis.log done for ligne in `ls *.txt` do mv $ligne ../../../illumina/read2/ done echo Moving Lane8 Read2 File to Read2 Analysis Directory Complete date '+%m/%d/%y %H:%M:%S' echo Moving Lane8 Read2 File to Read2 Analysis Directory Complete >> ../../../../../analysisnotes/Analysis.log date '+%m/%d/%y %H:%M:%S' >> ../../../../../analysisnotes/Analysis.log cd ../../../../../ #Current Directory=ngs/ # Now we call the "BWApe_hg18_v1.sh" script to analyze this sample/lane using bwa sampe BWApe_hg18_v1.sh echo ***Lane8 Analysis Complete***

Leave a comment: