summaryrefslogtreecommitdiff
path: root/pm-index
blob: 80aa574db0fa632626e0becb378b999a47051660 (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
52
53
54
55
56
#!/bin/sh

# Public domain notice for all NCBI EDirect scripts is located at:
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice

if [ "$#" -eq 0 ]
then
  echo "Must supply path for indexed files"
  exit 1
fi

target="$1"
shift

target=${target%/}

if [ "$#" -eq 0 ]
then
  echo "Must supply path for extras files"
  exit 1
fi

extras="$1"
shift

extras=${extras%/}

xtras="false"

if [ "$#" -gt 0 ]
then
  xtras="$1"
  shift
fi

find "$target" -name "*.e2x" -delete
find "$target" -name "*.e2x.gz" -delete

for fl in *.xml.gz
do
  base=${fl%.xml.gz}
  echo "$base.e2x"
  if [ -s "$extras/meshtree.txt" ]
  then
    gunzip -c "$fl" |
    xtract -transform "$extras/meshtree.txt" -e2index "$xtras" |
    transmute -format |
    gzip -1 > "$target/$base.e2x.gz"
  else
    gunzip -c "$fl" |
    xtract -e2index "$xtras" |
    transmute -format |
    gzip -1 > "$target/$base.e2x.gz"
  fi
  sleep 1
done