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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
#!/bin/sh
while [ $# -gt 0 ]
do
case "$1" in
-path )
shift
;;
-* )
exec >&2
echo "$0: Unrecognized option $1"
exit 1
;;
* )
break
;;
esac
done
if [ "$#" -gt 0 ]
then
target="$1"
MASTER=$(cd "$target" && pwd)
CONFIG=${MASTER}
shift
else
if [ -z "${EDIRECT_PUBMED_MASTER}" ]
then
echo "Must supply path to master archive area or set EDIRECT_PUBMED_MASTER environment variable"
exit 1
else
MASTER="${EDIRECT_PUBMED_MASTER}"
MASTER=${MASTER%/}
fi
fi
while [ $# -gt 0 ]
do
case "$1" in
-temp | -work | -working )
shift
;;
-* )
exec >&2
echo "$0: Unrecognized option $1"
exit 1
;;
* )
break
;;
esac
done
if [ "$#" -gt 0 ]
then
working="$1"
WORKING=$(cd "$working" && pwd)
shift
else
if [ -z "${EDIRECT_PUBMED_WORKING}" ]
then
WORKING=${MASTER}
else
WORKING="${EDIRECT_PUBMED_WORKING}"
WORKING=${WORKING%/}
fi
fi
for dir in Archive Postings
do
mkdir -p "$MASTER/$dir"
done
for dir in Indexed Inverted Merged Pubmed
do
mkdir -p "$WORKING/$dir"
done
if [ ! -f "$MASTER/Archive/CACHEDIR.TAG" ]
then
pm-prepare "$MASTER/Archive"
fi
seconds_start=$(date "+%s")
echo "Downloading PubMed Files"
cd "$WORKING/Pubmed"
download-pubmed baseline updatefiles
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
DWN=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Populating PubMed Archive"
pm-stash "$MASTER/Archive"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
POP=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Refreshing Versioned Records"
pm-refresh "$MASTER/Archive"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
REF=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Indexing PubMed Records"
pm-index "$MASTER/Archive" "$WORKING/Indexed"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
IDX=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Inverting PubMed Indices"
cd "$WORKING/Indexed"
pm-invert "$WORKING/Inverted"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
INV=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Merging Inverted Indices"
cd "$WORKING/Inverted"
pm-merge "$WORKING/Merged"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
MRG=$seconds
echo ""
seconds_start=$(date "+%s")
echo "Producing Postings Files"
cd "$WORKING/Merged"
pm-promote "$MASTER/Postings"
seconds_end=$(date "+%s")
seconds=$((seconds_end - seconds_start))
echo "$seconds seconds"
PST=$seconds
echo ""
echo "DWN $DWN seconds"
echo "POP $POP seconds"
echo "REF $REF seconds"
echo "IDX $IDX seconds"
echo "INV $INV seconds"
echo "MRG $MRG seconds"
echo "PST $PST seconds"
echo ""
phrase-search -path "$MASTER/Postings" -query "mapping of spatio-temporal pollution status AND 2008 [YEAR]" |
fetch-pubmed -path "$MASTER/Archive" |
xtract -pattern Author -if Affiliation -contains Medicine \
-pfx "Archive and Index are " -element Initials
echo ""
if [ -n "$CONFIG" ]
then
target=bash_profile
if ! grep "$target" "$HOME/.bashrc" >/dev/null 2>&1
then
if [ ! -f $HOME/.$target ] || grep 'bashrc' "$HOME/.$target" >/dev/null 2>&1
then
target=bashrc
fi
fi
echo ""
echo "For convenience, please execute the following to save the archive path to a variable:"
echo ""
echo " echo \"export EDIRECT_PUBMED_MASTER='${CONFIG}'\" >>" "\$HOME/.$target"
echo ""
fi
|