summaryrefslogtreecommitdiff
path: root/pm-index
blob: 38950c105302124f00af254f438ea5606b73bad0 (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
#!/bin/sh

# Public domain notice for all NCBI EDirect scripts is located at:
# https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/scripts/projects/blast/LICENSE   

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 data files"
  exit 1
fi

data="$1"
shift

data=${data%/}

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

for fl in *.xml.gz
do
  base=${fl%.xml.gz}
  echo "$base.e2x"
  seconds_start=$(date "+%s")
  if [ -s "$data/meshtree.txt" ]
  then
    gunzip -c "$fl" |
    xtract -transform "$data/meshtree.txt" -e2index |
    gzip -1 > "$target/$base.e2x.gz"
  else
    gunzip -c "$fl" |
    xtract -e2index |
    gzip -1 > "$target/$base.e2x.gz"
  fi
  seconds_end=$(date "+%s")
  seconds=$((seconds_end - seconds_start))
  echo "$seconds seconds"
  sleep 1
done