summaryrefslogtreecommitdiff
path: root/download-pubmed
blob: d0e3169662f1150283bdb374bca26f8d8ebf1e0a (plain)
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
#!/bin/sh

useasp=`has-asp`

filter() {
  while read fl
  do
    base=${fl%.xml.gz}
    if [ -f "$fl" ]
    then
      continue
    fi
    if [ -f "$base.snt" ]
    then
      continue
    fi
    echo "$fl"
  done
}

download() {
  if [ "$useasp" == "true" ]
  then
    asp-ls "pubmed/$1" |
    grep -v ".md5" | grep "xml.gz" |
    filter |
    asp-cp "pubmed/$1"
  else
    ftp-ls ftp.ncbi.nlm.nih.gov "pubmed/$1" |
    grep -v ".md5" | grep "xml.gz" |
    filter |
    ftp-cp ftp.ncbi.nlm.nih.gov "pubmed/$1"
  fi
}

if [ "$#" -eq 0 ]
then
  echo "Must indicate either baseline or updatefiles"
  exit 1
fi

while [ "$#" -gt 0 ]
do
  sect="$1"
  shift
  download "$sect"
  if [ $? -ne 0 ]
  then
    download "$sect"
  fi
done