-
Notifications
You must be signed in to change notification settings - Fork 4
/
set_targets.sh
executable file
·126 lines (115 loc) · 3.27 KB
/
set_targets.sh
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
#!/bin/sh
#
# cuCLARK, CLARK for CUDA-enabled GPUs.
# Copyright 2016, Robin Kobus <[email protected]>
#
# based on CLARK version 1.1.3, CLAssifier based on Reduced K-mers.
# Copyright 2013-2016, Rachid Ounit <[email protected]>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# set_targets.sh: To create targets definition of selected databases
# (Bacteria, Viruses, Human and Custom).
# Differences to CLARK:
# Changed subDB folder name to avoid confusion of CLARK's and cuCLARK's databases.
#
if [ $# -lt 2 ]; then
echo "Usage: $0 <Directory path> <Databases: bacteria, viruses, human or custom>+ <taxonomy rank: --phylum, --class, --order, --family, --genus or --species (default)>"
exit
fi
DBDR=$1
RANK=0
if [ ! -d $DBDR ]; then
echo "Selected directory not found. The program will create it."
mkdir -m 775 $DBDR
if [ ! -d $DBDR ]; then
echo "Failed to create the directory (please check the name of directory $DBDR and whether it exists). The program will abort."
exit
fi
fi
echo $DBDR > .DBDirectory
for var in $@
do
if [ "$var" = "--species" ]; then
RANK=0
break
fi
if [ "$var" = "--genus" ]; then
RANK=1
break
fi
if [ "$var" = "--family" ]; then
RANK=2
break
fi
if [ "$var" = "--order" ]; then
RANK=3
break
fi
if [ "$var" = "--class" ]; then
RANK=4
break
fi
if [ "$var" = "--phylum" ]; then
RANK=5
break
fi
PREF=`echo $var | cut -c1-2`
if [ "$PREF" = "--" ]; then
echo "Failed to recognize this parameter: $var"
exit
fi
done
if [ -f $DBDR/targets.txt ]; then
rm -f $DBDR/targets.txt
fi
touch $DBDR/targets.txt
rm -f $DBDR/.tmp .settings files_excluded.txt $DBDR/files_excluded.txt
subDB=""
us="_"
for db in $@
do
if [ "$db" != "$DBDR" ]; then
PRE=`echo $db | cut -c1-2`
if [ "$PRE" != "--" ]; then
echo -n "Collecting metadata of $db... "
./make_metadata.sh $db $DBDR
if [ ! -s $DBDR/.$db ]; then
exit
fi
if [ ! -f $DBDR/.taxondata ]; then
exit
fi
echo "done."
if [ -s $DBDR/.$db.fileToTaxIDs ]; then
./exe/getTargetsDef $DBDR/.$db.fileToTaxIDs $RANK >> $DBDR/targets.txt
subDB="$subDB$db$us"
cat files_excluded.txt >> $DBDR/.tmp
rm files_excluded.txt
fi
fi
fi
done
subDB="$subDB$RANK"
subDB="${subDB}_canonical"
echo "-T $DBDR/targets.txt" > .settings
if [ ! -d $DBDR/$subDB ]; then
echo "Creating directory to store discriminative k-mers: $DBDR/$subDB"
mkdir -m 775 $DBDR/$subDB
fi
echo "-D $DBDR/$subDB/" >> .settings
if [ -s $DBDR/.tmp ]; then
mv $DBDR/.tmp $DBDR/files_excluded.txt
fi