#!/bin/sh
#  Get example input files for theseus
#  Copyright (C) 2007 Morten Kjeldgaard <mok@bioxray.dk>
#
#  This script 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 2.1 of the License, or (at your option) any later
#  version.
#
#  This script 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 script; if not, write to the Free
#  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
#  Boston, MA 02110-1301 USA
set -e

pdbs="1s40"

astrals="d1ciha_ d1crja_ d1csua_ d1csxa_ d1kyow_ d1lfma_ d1m60a_ d1u74d_ d1yeba_ d2pcbb_"
#astrals="d1cih__ d1cih__2 d1crj__ d1csu__ d1csx__ d1kyow_ d1lfma_ d1m60a_ d1u74d_ d1yeb__ d2pcbb_"

# function to fetch entries from the pdb
pdb_fetch () {
  for f in $* ; do
      wget -q -O $f.pdb.gz ftp://ftp.wwpdb.org:/pub/pdb/data/structures/all/pdb/pdb${f}.ent.gz 
      gzip -d ${f}.pdb.gz
      echo fetched $f.pdb
  done
}

# function to fetch entries from astral
astral_fetch() {
  for f in $* ; do
    wget -q -O ${f}.pdb http://astral.berkeley.edu/pdbstyle.cgi?id=${f}&output=text 
    echo fetched $f.pdb
  done
}

savedir=$PWD
cd /tmp
echo Downloading to directory /tmp
pdb_fetch $pdbs
astral_fetch $astrals

cd $savedir
