Skip to content

Instantly share code, notes, and snippets.

@drio
Created August 21, 2010 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drio/542586 to your computer and use it in GitHub Desktop.
Save drio/542586 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
set -e
check_requirements()
{
[ ! -f $s2f_bin ] && error "bfast solid2fastq not found."
[ ! -f $bwa_s2f ] && error "bwa solid2fastq not found."
[ ! -x $s2f_bin ] && error "bfast solid2fastq not executable."
[ ! -x $bwa_s2f ] && error "bwa solid2fastq not exectutable."
for i in $o_f3 $o_f3q $o_r3 $o_r3q
do
[ ! -f $o_f3 ] && error "data file not found: [$i]"
done
return 0
}
log()
{
echo "$1"
}
error()
{
echo "$1"
exit 1
}
diff_this()
{
f1=$1
f2=$2
[ ! -f $f1 ] && error "File not found: $f1"
[ ! -f $f2 ] && error "File not found: $f2"
if [ ".`diff $f1 $f2`" == "." ]
then
out="OK"
else
out="ERROR: diff != 0"
fi
log " diff: [$out] $f1 $f2"
}
clean()
{
rm -rf drd* bf bwa* input*
}
prep()
{
head -$nl $o_f3 > $f3
head -$nl $o_r3 > $r3
head -$nl $o_f3q > $fq3
head -$nl $o_r3q > $rq3
}
compile()
{
cd $sdir
make > /dev/null
cd - > /dev/null
}
run_bf()
{
sp=""
[ ".$2" != "." ] && sp="$2"
mkdir bf
cp $1 bf/
cd bf
$s2f_bin -b $sp -o prefix $1
cd ..
}
run_bwa()
{
mkdir bwa
cp $1 bwa/
cd bwa
$bwa_s2f "input_" prefix
gzip -d *.gz
cd ..
}
check_split_sizes()
{
cd bf
for i in *.fastq
do
[ ! -s $i ] && error " $i: ZERO size!!"
done
echo " size: [OK] (`ls *.fastq | wc -l | sed 's/ //g'`)"
cd ..
}
# Testing one end
test_one()
{
log "TEST: No splits. ONE end."
run_bf "$f3 $fq3"
run_bwa "$f3 $fq3"
diff_this bf/prefix.single.fastq bwa/prefix.single.fastq
}
# Testing two ens
test_two()
{
log "TEST: No splits. TWO ends."
run_bf "$f3 $r3 $fq3 $rq3"
run_bwa "$f3 $r3 $fq3 $rq3"
diff_this bf/prefix.single.fastq bwa/prefix.single.fastq
diff_this bf/prefix.read1.fastq bwa/prefix.read1.fastq
diff_this bf/prefix.read2.fastq bwa/prefix.read2.fastq
}
# Testing one end (split)
test_one_split()
{
log "TEST: SPLITS, ONE end."
run_bf "$f3 $fq3" "-n$n"
run_bwa "$f3 $fq3"
cat bf/*.fastq > ./bf.merged.fastq
diff_this ./bf.merged.fastq bwa/prefix.single.fastq
rm -f ./bf.merged.fastq
check_split_sizes
}
test_two_split()
{
log "TEST: SPLITS, TWO end."
run_bf "$f3 $r3 $fq3 $rq3" "-n$n"
run_bwa "$f3 $r3 $fq3 $rq3"
cat bf/*read1*fastq > ./bf.r1.fastq
cat bf/*read2*fastq > ./bf.r2.fastq
cat bf/*single*fastq > ./bf.single.fastq
diff_this ./bf.r1.fastq bwa/prefix.read1.fastq
diff_this ./bf.r2.fastq bwa/prefix.read2.fastq
diff_this ./bf.single.fastq bwa/prefix.single.fastq
rm -f ./bf.*
check_split_sizes
}
# main
#
sdir="/Users/drio/projects/bfast_related/versions/dev/bfast/scripts"
s2f_bin="$sdir/solid2fastq"
bwa_s2f="/Users/drio/projects/bwa_related/bio-bwa/trunk/bwa/solid2fastq.pl"
o_f3="./data/bifxTrainingData_10panels_auto/reads/SHIRAZ_20080320_MP_2_Sample1_F3_10panel.csfasta"
o_f3q="./data/bifxTrainingData_10panels_auto/reads/SHIRAZ_20080320_MP_2_Sample1_F3_QV_10panel.qual"
o_r3="./data/bifxTrainingData_10panels_auto/reads/SHIRAZ_20080320_MP_2_Sample1_R3_10panel.csfasta"
o_r3q="./data/bifxTrainingData_10panels_auto/reads/SHIRAZ_20080320_MP_2_Sample1_R3_QV_10panel.qual"
f3="./input_F3.csfasta"
r3="./input_R3.csfasta"
fq3="./input_F3_QV.qual"
rq3="./input_R3_QV.qual"
nl="10001"
n="1000"
check_requirements
compile
clean; prep; test_one
clean; prep; test_two
clean; prep; test_one_split
clean; prep; test_two_split
echo "ALL tests Passed."
clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment