|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +## This script will install the tools required for the STRetch pipeline. |
| 4 | +## It will fetched each tool from the web and placed into the tools/ subdirectory. |
| 5 | +## Paths to all installed tools can be found in the file tools.groovy at the |
| 6 | +## end of execution of this script. These paths can be changed if a different |
| 7 | +## version of software is required. Note that R must be installed manually |
| 8 | +## |
| 9 | + |
| 10 | +installdir=$PWD |
| 11 | +refdir=$PWD/reference-data |
| 12 | +toolspec=$PWD/pipelines/pipeline_config.groovy |
| 13 | +template=$PWD/pipelines/config-examples/pipeline_config_template.groovy |
| 14 | + |
| 15 | +mkdir -p tools/bin |
| 16 | +cd tools |
| 17 | + |
| 18 | +#a list of which programs need to be installed |
| 19 | +commands="bpipe python goleft bedtools bwa samtools" |
| 20 | + |
| 21 | +#installation method |
| 22 | +function bpipe_install { |
| 23 | + wget -O bpipe-0.9.9.2.tar.gz https://github.com/ssadedin/bpipe/releases/download/0.9.9.2/bpipe-0.9.9.2.tar.gz |
| 24 | + tar -zxvf bpipe-0.9.9.2.tar.gz ; rm bpipe-0.9.9.2.tar.gz |
| 25 | + ln -s $PWD/bpipe-0.9.9.2/bin/* $PWD/bin/ |
| 26 | +} |
| 27 | + |
| 28 | +# Installs miniconda, Python 3 + required packages, BedTools and goleft |
| 29 | +# (and any other dependancies listed in environment.yml) |
| 30 | +function python_install { |
| 31 | + wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh |
| 32 | + bash miniconda.sh -b -p $PWD/miniconda |
| 33 | + rm miniconda.sh |
| 34 | + $PWD/miniconda/bin/conda env create -f ../environment.yml |
| 35 | + ln -s $PWD/miniconda/envs/STR/bin/* $PWD/bin/ |
| 36 | +# source activate STR |
| 37 | +} |
| 38 | + |
| 39 | +function bwa_install { |
| 40 | + wget -O bwakit-0.7.15_x64-linux.tar.bz2 --no-check-certificate https://github.com/lh3/bwa/releases/download/v0.7.15/bwakit-0.7.15_x64-linux.tar.bz2 |
| 41 | + tar -jxvf bwakit-0.7.15_x64-linux.tar.bz2 |
| 42 | + rm bwakit-0.7.15_x64-linux.tar.bz2 |
| 43 | + ln -s $PWD/bwa.kit/* $PWD/bin/ |
| 44 | +} |
| 45 | + |
| 46 | +function samtools_install { |
| 47 | + wget --no-check-certificate https://sourceforge.net/projects/samtools/files/samtools/1.3.1/samtools-1.3.1.tar.bz2 |
| 48 | + tar -jxvf samtools-1.3.1.tar.bz2 |
| 49 | + rm samtools-1.3.1.tar.bz2 |
| 50 | + make prefix=$PWD install -C samtools-1.3.1/ |
| 51 | +} |
| 52 | + |
| 53 | +function download { |
| 54 | + wget --no-check-certificate -O $refdir/reference-data.zip https://ndownloader.figshare.com/articles/5353399?private_link=be9bde235448e937e468 |
| 55 | + unzip $refdir/reference-data.zip -d $refdir |
| 56 | + rm $refdir/reference-data.zip |
| 57 | + |
| 58 | + mkdir $installdir/test-data |
| 59 | + mv $refdir/*.gz $refdir/*.bam $refdir/*.bai $installdir/test-data |
| 60 | +} |
| 61 | + |
| 62 | +#populate toolspec |
| 63 | +echo "// Bpipe pipeline config file" > $toolspec |
| 64 | +echo "// Paths are relative to the directory the pipeline is running in, so absolute" >> $toolspec |
| 65 | +echo "// paths are recommended." >> $toolspec |
| 66 | +echo >> $toolspec |
| 67 | +echo "// Adjust parameters" >> $toolspec |
| 68 | +echo "PLATFORM='illumina'" >> $toolspec |
| 69 | +echo >> $toolspec |
| 70 | +echo "// Number of threads to use for BWA" >> $toolspec |
| 71 | +echo "threads=8" >> $toolspec |
| 72 | +echo >> $toolspec |
| 73 | +echo "// For exome pipeline only ***Edit before running the exome pipeline***" >> $toolspec |
| 74 | +echo "EXOME_TARGET=\"SCA8_region.bed\"" >> $toolspec |
| 75 | +echo >> $toolspec |
| 76 | + |
| 77 | +#set STRetch base directory |
| 78 | +echo "// STRetch installation location" >> $toolspec |
| 79 | +echo "STRETCH=\"$installdir\"" >> $toolspec |
| 80 | +echo >> $toolspec |
| 81 | + |
| 82 | +echo "// Paths to tools used by the pipeline" >> $toolspec |
| 83 | + |
| 84 | +for c in $commands ; do |
| 85 | + c_path=`which $PWD/bin/$c 2>/dev/null` |
| 86 | + if [ -z $c_path ] ; then |
| 87 | + echo "$c not found, fetching it" |
| 88 | + ${c}_install |
| 89 | + c_path=`which $PWD/bin/$c 2>/dev/null` |
| 90 | + fi |
| 91 | + echo "$c=\"$c_path\"" >> $toolspec |
| 92 | +done |
| 93 | + |
| 94 | +if [ ! -f $refdir/*dedup.sorted.bed ] ; then |
| 95 | + mkdir -p $refdir |
| 96 | + echo "Downloading reference and test data" |
| 97 | + download |
| 98 | +fi |
| 99 | + |
| 100 | +echo >> $toolspec |
| 101 | +echo "// Path to reference data" >> $toolspec |
| 102 | +echo "refdir=\"$refdir\"" >> $toolspec |
| 103 | + |
| 104 | +echo >> $toolspec |
| 105 | +echo "// Decoy reference assumed to have matching .genome file in the same directory" >> $toolspec |
| 106 | +echo "REF=\"$refdir/hg19.chr13.STRdecoys.sorted.fasta\"" >> $toolspec |
| 107 | +echo "STR_BED=\"$refdir/hg19.simpleRepeat_period1-6_dedup.sorted.bed\"" >> $toolspec |
| 108 | +echo "DECOY_BED=\"$refdir/STRdecoys.sorted.bed\"" >> $toolspec |
| 109 | +echo "// By default, uses other samples in the same batch as a control" >> $toolspec |
| 110 | +echo "CONTROL=\"\"" >> $toolspec |
| 111 | +echo "// Uncomment the line below to use a set of WGS samples as controls, or specify your own" >> $toolspec |
| 112 | +echo "CONTROL=\"$refdir/PCRfreeWGS.controls.tsv\"" >> $toolspec |
| 113 | +echo >> $toolspec |
| 114 | + |
| 115 | + |
| 116 | +#loop through commands to check they are all installed |
| 117 | +echo "**********************************************************" |
| 118 | +echo "Checking that all required tools were installed:" |
| 119 | +Final_message="All commands installed successfully!" |
| 120 | +for c in $commands ; do |
| 121 | + c_path=`which $PWD/bin/$c 2>/dev/null` |
| 122 | + if [ -z $c_path ] ; then |
| 123 | + echo -n "WARNING: $c could not be found!!!! " |
| 124 | + echo "You will need to download and install $c manually, then add its path to $toolspec" |
| 125 | + Final_message="WARNING: One or more command did not install successfully. See warning messages above. You will need to correct this before running STRetch." |
| 126 | + else |
| 127 | + echo "$c looks like it has been installed" |
| 128 | + fi |
| 129 | +done |
| 130 | + |
| 131 | +echo "**********************************************************" |
| 132 | + |
| 133 | +#check that R is installed |
| 134 | +R_path=`which R 2>/dev/null` |
| 135 | +if [ -z $R_path ] ; then |
| 136 | + echo "R not found!" |
| 137 | + echo "Please go to http://www.r-project.org/ and follow the installation instructions." |
| 138 | + echo "Please also install the required R packages." |
| 139 | +else |
| 140 | + echo "R seems to be available." |
| 141 | + echo "Make sure you are using the correct version of R and have installed all required packages." |
| 142 | +fi |
| 143 | +echo "R=\"$R_path\"" >> $toolspec |
| 144 | + |
| 145 | +echo "**********************************************************" |
| 146 | + |
| 147 | +#check for reference data |
| 148 | +if [ ! -f $refdir/*dedup.sorted.bed ] ; then |
| 149 | + echo -n "WARNING: reference files could not be found!!!! " |
| 150 | + echo "You will need to download them manually, then add the path to $toolspec" |
| 151 | +else |
| 152 | + echo "It looks like the reference data has been downloaded" |
| 153 | +fi |
| 154 | + |
| 155 | +echo "**********************************************************" |
| 156 | +echo $Final_message |
| 157 | +echo "Please make sure you have installed the required R packages:" |
| 158 | +echo "install.packages(c('optparse','plyr','dplyr','tidyr','reshape2'))" |
0 commit comments