-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrcsb.sh
More file actions
47 lines (44 loc) · 1.04 KB
/
rcsb.sh
File metadata and controls
47 lines (44 loc) · 1.04 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
#!/bin/bash
usage=$(echo $(tput bold)$(tput setaf 3)"Usage: "$(tput setaf 6)"rcsb pdb_code name || without '.pdb' extension"$(tput sgr0) )
if [ "$1" = "" ]; then
echo $(tput bold)"NO pdb code is provided"
echo ${usage}
proceed=0
else
pdb=`echo $1 | tr '[a-z]' '[A-Z]'`
proceed=1
if [ "$2" = "" ] ; then
name=$1
else
name=$2
if [ -f ${name}.pdb ] ; then
echo $(tput bold)$(tput setaf 1)'Warning: '$(tput setaf 6)"file ${name}.pdb already present"
fi
fi
fi
#
if [ ${proceed} -eq 0 ] ; then
exit 1
fi
#
wget https://www.rcsb.org/pdb/files/${pdb}.pdb > /dev/null 2>&1 &
PID=$!
bar='|/-\'
echo -n $(tput bold)$(tput setaf 5)"Downloading $1 "$(tput sgr0)
while [ -d /proc/$PID ]
do
echo -ne $(tput bold)"\b"${bar:i++%${#bar}:1}
sleep 0.2
done
echo ' '
#
if [ -f ${pdb}.pdb ] ; then
mv ${pdb}.pdb ${name}.pdb
echo 'DONE' $(tput sgr0)
ls ${name}.pdb
else
echo " "$(tput bold)$(tput setaf 1)"ERROR:: "$(tput setaf 6)"Structure ${pdb}.pdb not found at RCSB"$(tput sgr0)
echo ""
echo ${usage}
echo ""
fi