2
* ===========================================================================
5
* National Center for Biotechnology Information (NCBI)
7
* This software/database is a "United States Government Work" under the
8
* terms of the United States Copyright Act. It was written as part of
9
* the author's official duties as a United States Government employee and
10
* thus cannot be copyrighted. This software/database is freely available
11
* to the public for use. The National Library of Medicine and the U.S.
12
* Government do not place any restriction on its use or reproduction.
13
* We would, however, appreciate having the NCBI and the author cited in
14
* any work or product based on this material
16
* Although all reasonable efforts have been taken to ensure the accuracy
17
* and reliability of the software and data, the NLM and the U.S.
18
* Government do not and cannot warrant the performance or results that
19
* may be obtained by using this software or data. The NLM and the U.S.
20
* Government disclaim all warranties, express or implied, including
21
* warranties of performance, merchantability or fitness for any particular
24
* ===========================================================================
26
* File Name: vastlocl.c
28
* Author: Christopher Hogue
30
* Version Creation Date: 21 February 97
34
* File Description: Used to provide VAST data to MMDB-API when
35
* VAST files are on a local filesystem in standard VAST ftp-site format.
38
* --------------------------------------------------------------------------
39
* $Log: vastlocl.c,v $
40
* Revision 6.6 2000/06/21 21:40:07 lewisg
41
* change to using gzip
43
* Revision 6.5 1998/07/27 16:07:40 madej
44
* Pipe the results of gunzip when we get a BAS.
46
* Revision 6.4 1998/05/19 20:13:21 madej
47
* Gunzip needed to run vastsrv on Suns.
49
* Revision 6.3 1998/03/30 19:28:55 madej
50
* Changes to enable subset filtering.
52
* Revision 6.2 1998/03/16 15:41:34 lewisg
53
* got rid of gunzip in config file
55
* Revision 6.1 1998/03/06 01:14:12 lewisg
60
* ==========================================================================
64
/******** NOTE - .mmdbrc (UNIX) mmdb.ini (Win) mmdb.cnf (Mac) required *******/
65
/* containing paths to database VAST *****/
68
Database = /net/dorothy/export/home/hogue/mmdb/Oct96/vastdata/
78
#define MMDB_UNIXCOMPRESSED 1
82
static Char database[PATH_MAX];
83
static Char gunzip[PATH_MAX];
87
BiostrucAnnotSetPtr LIBCALL VASTBsAnnotSetGet (Int4 uid)
90
AsnTypePtr atp = NULL;
92
Char compath[PATH_MAX];
93
Char tempfile[PATH_MAX];
96
BiostrucAnnotSetPtr pbsa = NULL;
100
sprintf(pcId, "%ld", (long) uid);
102
StringCpy(path, database);
103
StringCat(path, pcId);
104
StringCat(path, ".bas");
106
#ifdef MMDB_UNIXCOMPRESSED
108
sprintf(compath, "%s -d -c %s.gz ", gunzip, path);
109
pipe = popen(compath, "rb");
112
ErrPostEx(SEV_FATAL,0,0, "VASTBsAnnotSetGet failed: Can't find gunzip in path.\n");
116
aip = AsnIoNew(ASNIO_BIN_IN, pipe, NULL, NULL, NULL);
118
iFileExists = FileLength(path);
119
if (iFileExists == 0)
124
aip = AsnIoOpen(path, "rb");
129
pbsa = BiostrucAnnotSetAsnRead(aip, NULL);
133
#ifdef MMDB_UNIXCOMPRESSED
137
if (!pbsa) return NULL;
142
Boolean LIBCALL IsVASTData(Int4 uid)
145
AsnTypePtr atp = NULL;
149
sprintf(pcId, "%ld", (long) uid);
151
StringCpy(path, database);
152
StringCat(path, pcId);
153
StringCat(path, ".bas");
155
#ifdef MMDB_UNIXCOMPRESSED
156
StringCat(path, ".gz");
157
if (FileLength(path) != 0)
161
if (FileLength(path) != 0)
170
Boolean LIBCALL VASTInit (void)
172
Char fname[PATH_MAX];
174
database[0] = gunzip[0] = '\0';
175
GetAppParam("vast", "VASTSRV", "Database", "", database, PATH_MAX);
176
if (database[0] == '\0')
178
ErrPostEx(SEV_FATAL,0,0, "MMDB config file / path to VAST data missing.\n");
181
GetAppParam("vast", "VASTSRV", "Gunzip", "", gunzip, (size_t) 256 * (sizeof(char)));
182
if (gunzip[0] == '\0')
184
ErrPostEx(SEV_FATAL,0,0, "VASTInit failed: gunzip path missing.\n");
188
GetAppParam("vast", "VASTSRV", "SubsetFile", "", fname, PATH_MAX);
190
if (fname[0] == '\0') {
191
ErrPostEx(SEV_FATAL, 0, 0, "VASTInit failed: no subset file name.\n");
195
if (LoadSubsetTable(fname) != 1) {
196
ErrPostEx(SEV_FATAL, 0, 0, "VASTInit failed: can't load subset table.\n");
205
Boolean LIBCALL VASTInit (void)
208
GetAppParam("mmdb", "VAST", "Database", "", database, PATH_MAX);
209
if (database[0] == NULL)
211
ErrPostEx(SEV_FATAL,0,0, "MMDB config file / path to VAST data missing.\n");
218
void LIBCALL VASTFini (void)