Debian Codegraph @

xtract

raw
1 #!/bin/sh
2
3 # ===========================================================================
4 #
5 # PUBLIC DOMAIN NOTICE
6 # National Center for Biotechnology Information (NCBI)
7 #
8 # This software/database is a "United States Government Work" under the
9 # terms of the United States Copyright Act. It was written as part of
10 # the author's official duties as a United States Government employee and
11 # thus cannot be copyrighted. This software/database is freely available
12 # to the public for use. The National Library of Medicine and the U.S.
13 # Government do not place any restriction on its use or reproduction.
14 # We would, however, appreciate having the NCBI and the author cited in
15 # any work or product based on this material.
16 #
17 # Although all reasonable efforts have been taken to ensure the accuracy
18 # and reliability of the software and data, the NLM and the U.S.
19 # Government do not and cannot warrant the performance or results that
20 # may be obtained by using this software or data. The NLM and the U.S.
21 # Government disclaim all warranties, express or implied, including
22 # warranties of performance, merchantability or fitness for any particular
23 # purpose.
24 #
25 # ===========================================================================
26 #
27 # File Name: xtract
28 #
29 # Author: Jonathan Kans, Aaron Ucko
30 #
31 # Version Creation Date: 11/01/2016
32 #
33 # ==========================================================================
34
35 pth=$( dirname "$0" )
36
37 case "$pth" in
38 /* )
39 ;; # already absolute
40 * )
41 pth=$(cd "$pth" && pwd)
42 ;;
43 esac
44
45 case ":$PATH:" in
46 *:"$pth":* )
47 ;;
48 * )
49 PATH="$PATH:$pth"
50 export PATH
51 ;;
52 esac
53
54 # read command-line arguments to intercept certain commands
55
56 for arg in "$@"
57 do
58 case "$arg" in
59 -format | -filter | -normalize | -outline | -contour | -synopsis | -tokens )
60 # front-ends to functions implemented in transmute
61 transmute "$@"
62 exit
63 ;;
64 -j2x | -a2x | -t2x | -c2x | -g2x )
65 # front-ends to functions implemented in transmute
66 transmute "$@"
67 exit
68 ;;
69 -e2index | -e2invert | -e2join | -e2delete )
70 # front-ends to functions implemented in rchive
71 rchive "$@"
72 exit
73 ;;
74 -insdx )
75 while [ $# -gt 0 ]
76 do
77 case "$1" in
78 -insdx )
79 shift
80 if [ -t 0 ]
81 then
82 xtract -insd-xml "$@"
83 else
84 xtract -insd-xml "$@" |
85 transmute -t2x -set Set -rec Rec -insdx "$@"
86 fi
87 exit
88 ;;
89 * )
90 shift
91 ;;
92 esac
93 done
94 exit
95 ;;
96 * )
97 continue
98 ;;
99 esac
100 done
101
102 # pass remaining commands to precompiled xtract executable
103 PATH=/bin:/usr/bin
104 export PATH
105 osname=`uname -s`
106 cputype=`uname -m`
107 case "$osname-$cputype" in
108 Linux-x86_64 ) platform=Linux ;;
109 Darwin-x86_64 ) platform=Darwin ;;
110 Darwin-*arm* ) platform=Silicon ;;
111 CYGWIN_NT-* | MINGW*-* ) platform=CYGWIN_NT ;;
112 Linux-*arm* ) platform=ARM ;;
113 Linux-aarch64 ) platform=ARM64 ;;
114 * ) platform=UNSUPPORTED ;;
115 esac
116 compiled=$0."$platform"
117 if [ -x "$compiled" ]
118 then
119 exec "$compiled" "$@"
120 else
121 echo ""
122 echo "Unable to locate xtract executable. Please execute the following:"
123 echo ""
124 echo " nquire -dwn ftp.ncbi.nlm.nih.gov entrez/entrezdirect xtract.$platform.gz"
125 echo " gunzip -f xtract.$platform.gz"
126 echo " chmod +x xtract.$platform"
127 echo ""
128 fi