/usr/share/kronatools/updateTaxonomy.sh is in radiant 2.7+dfsg-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | #! /bin/bash
# Copyright © 2011, Battelle National Biodefense Institute (BNBI);
# all rights reserved. Authored by: Brian Ondov, Nicholas Bergman, and
# Adam Phillippy
#
# See the LICENSE.txt file included with this software for license information.
if [ "$(uname)" == "Darwin" ]
then
MD5="md5 -r"
else # Assume linux
MD5=md5sum
fi
makefileAcc2taxid="scripts/accession2taxid.make"
makefileTaxonomy="scripts/taxonomy.make"
command -v curl >/dev/null 2>&1 || \
{ echo >&2 "ERROR: Curl (http://curl.haxx.se) is required."; exit 1; }
while [ "$#" -ne 0 ]
do
if [ $1 == "--help" ] || [ $1 == "-h" ]
then
echo
echo "updateTaxonomy.sh [options...] [/custom/dir]"
echo
echo " [/custom/dir] Taxonomy will be built in this directory instead of the"
echo " directory specified during installation. This custom"
echo " directory can be referred to with -tax in import scripts."
echo
echo " --only-fetch Only download source files; do not build."
echo
echo " --only-build Assume source files exist; do not fetch."
echo
echo " --preserve Do not remove source files after build."
echo
exit
elif [ $1 == "--only-fetch" ]
then
localPull=1
elif [ $1 == "--only-build" ]
then
local=1
elif [ $1 == "--preserve" ]
then
preserve=1
elif [ $1 == "--accessions" ]
then
accessions=1
elif [ "${1:0:1}" == "-" ]
then
echo "Unrecognized option: \"$1\". See help (--help or -h)"
exit
else
taxonomyPath=$1
fi
shift
done
function die
{
echo
echo "Update failed."
echo " $1"
echo
exit 1
}
function clean
{
aFile=$1
if [ -e $aFile ]
then
rm $aFile
fi
}
function fetch
{
name="$1"
description="$2"
prefix="$3"
timeDependencies="$4"
retry="$5"
timestring=""
depDesc=""
if [ "$retry" != "1" ]
then
for dep in $name $timeDependencies
do
if [ -s "$dep" ]
then
timestring=" -z $dep"
depDesc=" (if newer than $dep)"
break
fi
done
fi
echo "Fetching $description$depDesc..."
curl$timestring -s -R --retry 1 -o $name ftp://ftp.ncbi.nih.gov/pub/taxonomy/$prefix/$name
return=$?
if [ $return == "23" ]
then
die "Could not write '$taxonomyPath/$name'. Do you have permission?"
fi
if [ $return != "0" ]
then
die "Is your internet connection okay?"
fi
if [ -e "$name" ]
then
echo " Fetching checksum..."
curl -s -R --retry 1 -o $name.md5 ftp://ftp.ncbi.nih.gov/pub/taxonomy/$prefix/$name.md5
checksum=$($MD5 $name | cut -d ' ' -f 1)
checksumRef=$(cut -d ' ' -f 1 $name.md5)
rm $name.md5
if [ $checksum == $checksumRef ]
then
echo " Checksum for $name matches server."
else
if [ "$retry" == "1" ]
then
die "Checksum for $name still does not match server after retry."
else
echo "Checksum for $name does not match server. Retrying..."
fetch "$name" "$description" "$prefix" "$timeDependcies" 1
fi
fi
fi
}
if [ "$local" == "1" ] && [ "$localPull" == "1" ]
then
die "Cannot use --only-fetch with --only-build."
fi
ktPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
if [ "$taxonomyPath" == "" ]
then
taxonomyPath="$ktPath/taxonomy";
else
if [ ! -d "$taxonomyPath" ]
then
if [ $local == "1" ]
then
die "Could not find $taxonomyPath."
fi
echo
echo "Creating $taxonomyPath..."
echo
mkdir -p "$taxonomyPath"
if [ "$?" != "0" ]
then
die "Could not create '$taxonomyPath'. Do you have permission?"
fi
fi
fi
if [ "$accessions" == "1" ] && [ ! -d "$taxonomyPath/accession2taxid" ]
then
mkdir "$taxonomyPath/accession2taxid"
if [ "$?" != "0" ]
then
die "Could not create '$taxonomyPath/accession2taxid'. Do you have permission?"
fi
fi
cd $taxonomyPath
if [ "$?" != "0" ]
then
die "Could not enter '$taxonomyPath'."
fi
ACC2TAXID="
accession2taxid/dead_nucl.accession2taxid
accession2taxid/dead_prot.accession2taxid
accession2taxid/dead_wgs.accession2taxid
accession2taxid/nucl_est.accession2taxid
accession2taxid/nucl_gb.accession2taxid
accession2taxid/nucl_gss.accession2taxid
accession2taxid/nucl_wgs.accession2taxid
accession2taxid/prot.accession2taxid
"
if [ "$local" != "1" ]
then
if [ "$accessions" == "1" ]
then
fetchAll="$localPull"
if [ "$fetchAll" == "" ] && [ ! -e all.accession2taxid.sorted ]
then
fetchAll=1
fi
# if any are fetched by timestamp of all.accession2taxid.sorted, all
# others must be fetched to rebuild it
#
if [ "$fetchAll" == "" ]
then
for unzipped in $ACC2TAXID
do
fetch $unzipped.gz $unzipped.gz "" "$unzipped all.accession2taxid.sorted"
if [ -e $unzipped.gz ]
then
if [ ! -e all.accession2taxid.sorted ] || [ $unzipped.gz -nt all.accession2taxid.sorted ]
then
fetchAll=1
fi
fi
done
fi
#
if [ "$fetchAll" == "1" ]
then
for unzipped in $ACC2TAXID
do
if [ "$localPull" == "1" ] || [ ! -e $unzipped.gz ] && [ ! -e $unzipped ]
then
fetch $unzipped.gz $unzipped.gz "" $unzipped
fi
done
fi
else
fetch taxdump.tar.gz "taxdump.tar.gz" "" "taxdump.tar names.dmp taxonomy.tab"
fi
fi
if [ "$localPull" == "1" ]
then
echo
echo "Fetching finished."
echo
exit
fi
if [ "$accessions" == "1" ]
then
for base in $ACC2TAXID
do
if [ ! -e $base ] && [ ! -e $base.gz ]
then
if [ "$local" == "1" ]
then
die "Could not find accession2taxid source files in $taxonomyPath."
else
echo "Accessions up to date."
exit 0
fi
fi
done
cd accession2taxid
make -j 4 PRESERVE="$preserve" -f $ktPath/$makefileAcc2taxid
if [ "$?" != "0" ]
then
die "Building accession2taxid failed (see errors above). Issues can be tracked and reported at https://github.com/marbl/Krona/issues."
fi
else
if [ -e taxdump.tar ] || [ -e taxdump.tar.gz ] || [ -e names.dmp ]
then
make KTPATH="$ktPath" PRESERVE="$preserve" -f $ktPath/$makefileTaxonomy
if [ "$?" != "0" ]
then
die "Building taxonomy table failed (see errors above). Issues can be tracked and reported at https://github.com/marbl/Krona/issues."
fi
elif [ "$local" == "1" ]
then
die "Could not find taxonomy source files in $taxonomyPath."
fi
fi
if [ "$preserve" != "1" ]
then
echo
echo "Cleaning up..."
if [ "$accessions" != "1" ]
then
make -f $ktPath/$makefileTaxonomy clean
else
rmdir $ktPath/taxonomy/accession2taxid 2> /dev/null
fi
fi
echo
echo "Finished."
echo
|