-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lskatz/curtis-dev
Curtis dev
- Loading branch information
Showing
6 changed files
with
299 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
#$ -o prepSample.log | ||
#$ -e prepSample.err | ||
#$ -j y | ||
#$ -N wtdbg2 | ||
#$ -pe smp 2-16 | ||
#$ -V -cwd | ||
set -e | ||
|
||
#This function will check to make sure the directory doesn't already exist before trying to create it | ||
make_directory() { | ||
if [ -e $1 ]; then | ||
echo "Directory "$1" already exists" | ||
else | ||
mkdir $1 | ||
echo "Directory "$1" has been created" | ||
fi | ||
} | ||
|
||
source /etc/profile.d/modules.sh | ||
module purge | ||
|
||
NSLOTS=${NSLOTS:=24} | ||
echo '$NSLOTS is set to:' $NSLOTS | ||
|
||
FASTQDIR=$1 | ||
echo '$FASTQDIR is set to:' $FASTQDIR | ||
|
||
set -u | ||
|
||
if [ "$FASTQDIR" == "" ]; then | ||
echo "" | ||
echo "Usage: $0 barcode-fastq-dir" | ||
echo "" | ||
exit 1; | ||
fi; | ||
|
||
# Setup any debugging information | ||
date | ||
hostname | ||
|
||
# Setup tempdir | ||
tmpdir=$(mktemp -p . -d prepfastq.XXXXXX) | ||
trap ' { echo "END - $(date)"; rm -rf $tmpdir; } ' EXIT | ||
make_directory $tmpdir/log | ||
echo "$0: temp dir is $tmpdir"; | ||
|
||
dir=$FASTQDIR | ||
echo '$dir is set to:' $dir | ||
|
||
BARCODE=$(basename ${dir}) | ||
echo '$BARCODE is set to:' $BARCODE | ||
|
||
# check to see if reads have been compresesd and renamed to all-barcodeXX.fastq.gz | ||
if [[ -e ${dir}/all-${BARCODE}.fastq.gz ]]; then | ||
echo "Reads have been concatenated and renamed by 03_prepSample script already. Exiting...." | ||
exit 0 | ||
fi | ||
|
||
### commented out since gzipping is done by previous script | ||
# Gzip them all | ||
#uncompressed=$(\ls $dir/*.fastq 2>/dev/null || true) | ||
#if [ "$uncompressed" != "" ]; then | ||
# echo "$uncompressed" | xargs -P $NSLOTS gzip | ||
#fi | ||
|
||
# Put all the individual gzip fastqs into a subdir, | ||
# Concatenate them, and then remove them. | ||
# Keep the aggregate fastq file. | ||
echo "concatenating .fastq.gz files in barcode sub-dir..." | ||
mkdir -p ${dir}/fastqChunks | ||
mv ${dir}/*.fastq.gz ${dir}/fastqChunks | ||
cat ${dir}/fastqChunks/*.fastq.gz > ${dir}/all-${BARCODE}.fastq.gz | ||
rm -rf $dir/fastqChunks | ||
|
||
# Combine reads and count lengths in one stream | ||
echo "combining reads and counting read lengths..." | ||
LENGTHS=${dir}/readlengths.txt.gz | ||
zcat ${dir}/all-${BARCODE}.fastq.gz | perl -lne ' | ||
next if($. % 4 != 2); | ||
print length($_); | ||
' | sort -rn | gzip -cf > ${LENGTHS}; | ||
echo "Finished combining reads and counting read lengths." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.