From 6f22dc83ec4fb90217dacf046a49bfe238efda62 Mon Sep 17 00:00:00 2001 From: Tina Hu Date: Thu, 9 Feb 2012 15:01:46 -0500 Subject: [PATCH 1/3] Calling samtools from within the msg directory --- make-pileups.sh | 14 ++++++++------ msg.pl | 14 +++++++------- test_dependencies_executable.sh | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/make-pileups.sh b/make-pileups.sh index 22b9e48..f870165 100755 --- a/make-pileups.sh +++ b/make-pileups.sh @@ -17,6 +17,8 @@ true=0 false="false" all=$false +script_dir=$(dirname $0) + while getopts "ai:d:p:q:" opt do @@ -44,19 +46,19 @@ species=par1 file=$dir/aln_${indiv}_${species}-filtered echo "$file" -[ -e $parent1.fai ] || samtools faidx $parent1 +[ -e $parent1.fai ] || $script_dir/samtools faidx $parent1 [ -e $file-sorted.bam ] || { echo "samtools view -bt $parent1.fai $file.sam | samtools sort - $file-sorted" - samtools view -bt $parent1.fai $file.sam | samtools sort - $file-sorted + $script_dir/samtools view -bt $parent1.fai $file.sam | $script_dir/samtools sort - $file-sorted } -[ -e $file-sorted.bam.bai ] || samtools index $file-sorted.bam +[ -e $file-sorted.bam.bai ] || $script_dir/samtools index $file-sorted.bam for ref in $refs ; do [ -e $file-$ref-sorted.pileup ] || { echo "Making pileup for $species contig $ref" - samtools view -bu $file-sorted.bam $ref | samtools sort - $file-$ref-sorted - samtools index $file-$ref-sorted.bam - samtools pileup -cf $parent1 $file-$ref-sorted.bam > $file-$ref-sorted.pileup + $script_dir/samtools view -bu $file-sorted.bam $ref | samtools sort - $file-$ref-sorted + $script_dir/samtools index $file-$ref-sorted.bam + $script_dir/samtools pileup -cf $parent1 $file-$ref-sorted.bam > $file-$ref-sorted.pileup rm $file-$ref-sorted.bam $file-$ref-sorted.bam.bai } done diff --git a/msg.pl b/msg.pl index 8683a37..548b1e2 100755 --- a/msg.pl +++ b/msg.pl @@ -16,8 +16,8 @@ sub system_call { GetOptions( 'barcodes|b=s' => \$barcodes, - 're_cutter=s' => \$re_cutter, - 'linker_system=s' => \$linker_system, + 're_cutter=s' => \$re_cutter, + 'linker_system=s' => \$linker_system, 'reads|i=s' => \$raw_read_data, 'update|u' => \$update_genomes, 'parent1=s' => \$parent1_genome, @@ -116,7 +116,7 @@ sub system_call { &system_call("bwa", "index", "-a", $genome_index{$sp}, "$genomes_fa{$sp}.msg") unless( -e "$genomes_fa{$sp}.msg.bwt" and -e "$genomes_fa{$sp}.msg.ann" ); - &system_call("samtools", "faidx", "$genomes_fa{$sp}.msg") ; + &system_call("$src/samtools", "faidx", "$genomes_fa{$sp}.msg") ; unless (-e "$out.sam") { &system_call("bwa", "aln", "-t", $update_nthreads, "$genomes_fa{$sp}.msg", $reads_for_updating_fq{$sp}, "> $out.sai") ; @@ -125,10 +125,10 @@ sub system_call { &system_call("$src/filter-sam.py", "-i", "$out.sam", "-o", "$out.filtered.sam") ; - &system_call("samtools", "view", "-bt", "$genomes{$sp}.msg.fai", "-o $out.bam", "$out.filtered.sam") ; - &system_call("samtools", "sort", "$out.bam", "$out.bam.sorted") ; - &system_call("samtools", "index", "$out.bam.sorted.bam") ; - &system_call("samtools", "pileup", "-f", "$genomes_fa{$sp}.msg", "$out.bam.sorted.bam", "-c", "> $out.pileup") ; + &system_call("$src/samtools", "view", "-bt", "$genomes{$sp}.msg.fai", "-o $out.bam", "$out.filtered.sam") ; + &system_call("$src/samtools", "sort", "$out.bam", "$out.bam.sorted") ; + &system_call("$src/samtools", "index", "$out.bam.sorted.bam") ; + &system_call("$src/samtools", "pileup", "-f", "$genomes_fa{$sp}.msg", "$out.bam.sorted.bam", "-c", "> $out.pileup") ; } diff --git a/test_dependencies_executable.sh b/test_dependencies_executable.sh index e8b5029..f0a2da5 100644 --- a/test_dependencies_executable.sh +++ b/test_dependencies_executable.sh @@ -20,8 +20,8 @@ if ! which bwa >/dev/null 2>/dev/null ; then exit 1 fi -if ! which samtools >/dev/null 2>/dev/null ; then - echo "Please install samtools somewhere in your PATH" +if ! [ -e $(dirname $0)/samtools ] ; then + echo "Please install samtools (version 0.1.9) within the msg directory" exit 1 fi From 372a4301841d54028166a4b132103ef842c3ce09 Mon Sep 17 00:00:00 2001 From: Lance Parsons Date: Thu, 9 Feb 2012 18:06:08 -0500 Subject: [PATCH 2/3] Added version checking for samtools dependency --- test_dependencies_executable.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test_dependencies_executable.sh b/test_dependencies_executable.sh index f0a2da5..966970d 100644 --- a/test_dependencies_executable.sh +++ b/test_dependencies_executable.sh @@ -20,9 +20,15 @@ if ! which bwa >/dev/null 2>/dev/null ; then exit 1 fi +samtools_required_version="Version: 0.1.9 (r783)" if ! [ -e $(dirname $0)/samtools ] ; then - echo "Please install samtools (version 0.1.9) within the msg directory" - exit 1 + echo "Please install samtools ($samtools_required_version) within the msg directory" + exit 1 +fi +samtools_version=`$(dirname $0)/samtools 2>&1 | grep 'Version:'` +if [ "$samtools_version" != "$samtools_required_version" ] ; then + echo "The samtools found within the msg directory is $samtools_version. It must be $samtools_required_version" + exit 1 fi echo "All required executables found in PATH" From b891f39262055cd346c7d07c544617450c816414 Mon Sep 17 00:00:00 2001 From: Lance Parsons Date: Wed, 2 May 2012 12:26:08 -0400 Subject: [PATCH 3/3] Updated installation instructions for local samtools installation --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 187232f..6dea733 100755 --- a/README +++ b/README @@ -16,6 +16,7 @@ R packages (HiddenMarkov 1.3-1, zoo 1.6-2, R.methodsS3 1.2.0 and R.oo 1.7.3) ### Installation instructions ### git clone git://github.com/JaneliaSciComp/msg.git cd msg +copy or link version 0.1.9 of samtools into the msg directory make ### Toy Example ###