-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_blat_dockerless
72 lines (58 loc) · 2.06 KB
/
start_blat_dockerless
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
#!/bin/bash
if [[ -z $DOMAIN ]]; then
DOMAIN=local
fi
tmpPath=${HOME}/cruize/tmp
mkdir -p ${HOME}/cruize $tmpPath
# get dbDb spreadsheet
echo "downloading dbDb spreadsheet from https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="$DBDBID"&hl=en&exportFormat=tsv"
curl -sL "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="$DBDBID"&hl=en&exportFormat=tsv" | \
tr -d "\r" | sed 's/^\t/NA\t/g' | sed 's/\t$/\tNA/g' | sed 's/\t\t/\tNA\t/g' | \
awk -F '\t' -v header=active '
BEGIN {
split(header,cols,",")
}
{
if(NR==1){
for (i=1; i<=NF; i++){cols[$i]=i}
print $0
}
if(NR>1 && $cols["active"]==1){
print $0
}
}' OFS='\t' > $tmpPath/dbDb.tsv
grep "^<" $tmpPath/dbDb.tsv
if [[ $? -eq 0 ]]; then
>&2 echo "spreadsheet does not exist or is not publicly-accessible"
exit 1
fi
numGenomes=$(grep -v "^name" $tmpPath/dbDb.tsv | wc -l)
echo "found" $numGenomes "activated genomes"
if [ "$numGenomes" -lt 2 ]; then
>&2 echo "no active genomes in spreadsheet"
exit 1
fi
pkill gfServer || :
echo "processing genomes"
cols=$(head -n 1 $tmpPath/dbDb.tsv)
tail -n+2 $tmpPath/dbDb.tsv | while IFS=$'\t' read -r $cols
do
if [ $active -eq 1 ]; then
twoBitPath=${HOME}/cruize/${nibPath}/genome.2bit
if [[ $(hostname) == $nBlatHost ]] && [[ $nBlatPort != "NA" ]]; then
if [[ ! -f $twoBitPath ]]; then
>&2 echo "downloading $name 2bit from ${FQDN}/${nibPath}/genome.2bit to $twoBitPath"
mkdir -p ${HOME}/cruize/${nibPath}
curl -so $twoBitPath ${FQDN}/${nibPath}/genome.2bit
else
>&2 echo "$name 2bit already present in $twoBitPath"
fi
echo "starting nucleotide blat service for $name"
gfServer -tileSize=7 -canStop start $(hostname).$DOMAIN $nBlatPort -stepSize=5 $twoBitPath &
fi
if [[ $(hostname) == $pBlatHost ]] && [[ $pBlatPort != "NA" ]]; then
echo "starting protein blat service for $name"
gfServer -trans -canStop start $(hostname).$DOMAIN $pBlatPort ${HOME}/cruize/${nibPath}/genome.2bit &
fi
fi
done