-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·197 lines (180 loc) · 4.66 KB
/
install.sh
File metadata and controls
executable file
·197 lines (180 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
CURRDIR=$(pwd)
################
# User-modifiable variables
# Directory where the program is installed
#SCRIPTDIR="$CURRDIR/snpfilt"
SCRIPTDIR=${HOME}/snpfilt
OSTYPE=$(uname -s)
# Dependent programs
# By default, the script will look for versions on the path
# Paths can be manually changed by user before running install.sh
# If they are not found (or invalid path supplied) then a new version be installed inside SCRIPTDIR
# (source code inside third_party)
SAMTOOLS="samtools" # look for system version (will install into snpfilt directory if not found)
BCFTOOLS="bcftools"
SPADES="spades.py"
LASTZ="lastz"
BWA="bwa"
#################
# Starting script
for rqcmd in perl R zgrep gunzip cut
do
echo -n "Looking for $rqcmd"
res=$(type -P $rqcmd)
if [ -n $res ]
then
echo " ... $res [OK]"
else
echo "Didn't find $rqcmd. Please install and put in path before continuing"
exit 1
fi
done
for module in Getopt::Long
do
echo -n "Looking for $module"
res=$(perldoc -lm "Getopt::Long")
if [ -n $res ]
then
echo " ... $res [OK]"
else
echo " Module $module not found. Please install before continuing"
exit 1
fi
done
if [ ! -d $SCRIPTDIR ]
then
mkdir -p $SCRIPTDIR
fi
echo -n "Checking LASTZ ..."
res=$(type -P $LASTZ)
if [ -z $res ]
then
echo -n "installing into $SCRIPTDIR"
cd third_party
tar -xvzf lastz-distrib-1.02.00.tgz
cd lastz-distrib-1.02.00/src
export LASTZ_INSTALL=$SCRIPTDIR
make
make install
if [ $? -eq 0 ]
then
LASTZ="${SCRIPTDIR}/lastz"
echo " [OK]"
cd $CURRDIR
rm -r third_party/lastz-distrib-1.02.00
else
echo "Could not install LASTZ"
exit 1
fi
unset LASTZ_INSTALL
else
echo " $LASTZ [OK]"
fi
# SAMtools and BCFtools are now always installed
# to avoid problems between versions
echo -n "Checking samtools ..."
#res=$(type -P $SAMTOOLS)
#if [ -z $res ]
#then
echo "installing into $SCRIPTDIR"
cd third_party
tar xvjf samtools-1.2.tar.bz2
cd samtools-1.2
make
make prefix=$SCRIPTDIR install
if [ $? -eq 0 ]
then
SAMTOOLS="${SCRIPTDIR}/bin/samtools"
echo " [OK]"
cd $CURRDIR
rm -r third_party/samtools-1.2
else
echo "Could not install samtools"
exit 1
fi
#else
# SAMTOOLS=$res
# echo " $SAMTOOLS [OK]"
#fi
echo -n "Checking bcftools ..."
#res=$(type -P $BCFTOOLS)
#if [ -z $res ]
#then
echo "installing into $SCRIPTDIR"
cd third_party
tar xvjf bcftools-1.2.tar.bz2
cd bcftools-1.2
make
make prefix=$SCRIPTDIR install
if [ $? -eq 0 ]
then
BCFTOOLS="${SCRIPTDIR}/bin/bcftools"
echo " [OK]"
cd $CURRDIR
rm -r third_party/bcftools-1.2
else
echo "Could not install samtools"
exit 1
fi
#else
# BCFTOOLS=$res
# echo " $BCFTOOLS [OK]"
#fi
echo -n "Checking spades ..."
res=$(type -P $SPADES)
if [ -z $res ]
then
echo "installing into $SCRIPTDIR"
cd third_party
tar -xvzf SPAdes-3.9.0-${OSTYPE}.tar.gz
mv SPAdes-3.9.0-${OSTYPE} $SCRIPTDIR
SPADES="${SCRIPTDIR}/SPAdes-3.9.0-${OSTYPE}/bin/spades.py"
cd $CURRDIR
else
SPADES=$res
echo " $SPADES [OK]"
fi
echo -n "Checking BWA ..."
res=$(type -P $BWA)
if [ -z $res ]
then
echo "installing into $SCRIPTDIR"
cd third_party
tar -xvjf bwa-0.7.15.tar.bz2
mv bwa-0.7.15 $SCRIPTDIR
cd ${SCRIPTDIR}/bwa-0.7.15
make
BWA="${SCRIPTDIR}/bwa-0.7.15/bwa"
cd $CURRDIR
else
BWA=$res
echo " $BWA [OK]"
fi
# Install required R-package inside SnpFilt directory
# We don't use default user libraries to avoid problems
# when installing for in multi-user environments
mkdir $SCRIPTDIR/rlib
R CMD BATCH --vanilla "--args RLIB='$SCRIPTDIR/rlib'" install_rpckg.R
if [ $? -ne 0 ]
then
echo "error: could not install R package - check install_rpckg.Rout"
exit 1
fi
cd src
cp best_match.pl convert_fasta.pl filter_contigs.R find_ctgpos.pl format_bcf.pl get_seqvar_pos.pl get_SNPtable.pl *.scores merge_snptable.pl plot_context.R $SCRIPTDIR
outscript="$SCRIPTDIR/snpfilt.pl"
echo "#!/bin/env perl" > $outscript
echo "" >> $outscript
echo "\$SCRIPTDIR = \"${SCRIPTDIR}\";" >> $outscript
echo "\$SAMTOOLS = \"${SAMTOOLS}\";" >> $outscript
echo "\$BCFTOOLS = \"${BCFTOOLS}\";" >> $outscript
echo "\$LASTZ = \"${LASTZ}\";" >> $outscript
echo "\$SPADES = \"${SPADES}\";" >> $outscript
echo "\$BWA = \"${BWA}\";" >> $outscript
cat snpfilt_stem.pl >> $outscript
chmod a+x $SCRIPTDIR
chmod a+x $SCRIPTDIR/snpfilt.pl
echo ""
echo "Install complete!"
echo "To place snpfilt into PATH, append $SCRIPTDIR into path or symlink to $SCRIPTDIR/snpfilt.pl"