1 /*   pmfapi.h
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *            National Center for Biotechnology Information (NCBI)
6 *
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
15 *
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
22 *  purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name:  pmfapi.h
27 *
28 * Author:  Jonathan Kans
29 *
30 * Version Creation Date:   5/5/00
31 *
32 * $Revision: 1.38 $
33 *
34 * File Description:
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 *
39 * ==========================================================================
40 */
41 
42 #ifndef _PMFAPI_
43 #define _PMFAPI_
44 
45 #include <ncbi.h>
46 #include <asn.h>
47 #include <objmedli.h>
48 #include <objpubme.h>
49 #include <objsset.h>
50 #include <urlquery.h>
51 
52 #undef NLM_EXTERN
53 #ifdef NLM_IMPORT
54 #define NLM_EXTERN NLM_IMPORT
55 #else
56 #define NLM_EXTERN extern
57 #endif
58 
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 
65 /* low-level connection functions */
66 
67 NLM_EXTERN CONN PubMedFetchOpenConnection (
68   Int4 uid
69 );
70 
71 NLM_EXTERN CONN PubSeqFetchOpenConnection (
72   BIG_ID uid,
73   Int2 retcode,
74   Int4 flags
75 );
76 
77 NLM_EXTERN CONN PubSeqFetchOpenConnectionString (
78   CharPtr id,
79   Int2 retcode,
80   Int4 flags
81 );
82 
83 NLM_EXTERN CONN PubSeqFetchTraceOpenConnection (
84   Uint4 tid,
85   Int2 retcode,
86   Int4 flags
87 );
88 
89 NLM_EXTERN CONN PubSeqFetchSRAOpenConnection (
90   CharPtr sraid
91 );
92 
93 NLM_EXTERN CONN GiRevHistOpenConnection (
94   BIG_ID uid,
95   Int4 num,
96   BIG_ID_PNTR uids
97 );
98 
99 NLM_EXTERN CONN GiAccVerOpenConnection (
100   BIG_ID uid,
101   Int4 num,
102   BIG_ID_PNTR uids
103 );
104 
105 NLM_EXTERN CONN AccnRevHistOpenConnection (
106   CharPtr accn
107 );
108 
109 NLM_EXTERN CONN GiSeqIdSetOpenConnection (
110   BIG_ID gi
111 );
112 
113 NLM_EXTERN CONN AccnListOpenConnection (
114   CharPtr PNTR accns
115 );
116 
117 NLM_EXTERN PubmedEntryPtr PubMedWaitForReply (
118   CONN conn
119 );
120 
121 NLM_EXTERN SeqEntryPtr PubSeqWaitForReply (
122   CONN conn
123 );
124 
125 NLM_EXTERN CharPtr GiRevHistWaitForReply (
126   CONN conn
127 );
128 
129 NLM_EXTERN CharPtr GiAccVerWaitForReply (
130   CONN conn
131 );
132 
133 NLM_EXTERN BIG_ID AccnRevHistWaitForReply (
134   CONN conn
135 );
136 
137 NLM_EXTERN SeqIdPtr GiSeqIdSetWaitForReply (
138   CONN conn
139 );
140 
141 NLM_EXTERN CharPtr AccnListWaitForReply (
142   CONN conn
143 );
144 
145 /*
146  PubMedSynchronousQuery and PubSeqSynchronousQuery open a
147  connection, send a uid request, and wait for a reply
148 */
149 
150 NLM_EXTERN PubmedEntryPtr PubMedSynchronousQuery (
151   Int4 uid
152 );
153 
154 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQueryEx (
155   Int4 uid,
156   Int2 retcode,
157   Int4 flags,
158   CharPtr id_str
159 );
160 
161 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQuery (
162   Int4 uid,
163   Int2 retcode,
164   Int4 flags
165 );
166 
167 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQueryId (
168   SeqIdPtr sip,
169   Int2 retcode,
170   Int4 flags
171 );
172 
173 NLM_EXTERN SeqIdPtr SeqIdFromPubSeqString (CharPtr str);
174 
175 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQueryString (
176   CharPtr str,
177   Int2 retcode,
178   Int4 flags
179 );
180 
181 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQueryTI (
182   Uint4 tid,
183   Int2 retcode,
184   Int4 flags
185 );
186 
187 NLM_EXTERN SeqEntryPtr PubSeqSynchronousQuerySRA (
188   CharPtr sraid
189 );
190 
191 NLM_EXTERN CharPtr GiRevHistSynchronousQuery (
192   BIG_ID uid,
193   Int4 num,
194   BIG_ID_PNTR uids
195 );
196 
197 NLM_EXTERN CharPtr GiAccVerSynchronousQuery (
198   BIG_ID uid,
199   Int4 num,
200   BIG_ID_PNTR uids
201 );
202 
203 NLM_EXTERN BIG_ID AccnRevHistSynchronousQuery (
204   CharPtr accn
205 );
206 
207 NLM_EXTERN SeqIdPtr GiSeqIdSetSynchronousQuery (
208   BIG_ID gi
209 );
210 
211 NLM_EXTERN CharPtr AccnListSynchronousQuery (
212   CharPtr PNTR accns
213 );
214 
215 /*
216  PubMedAsynchronousQuery and PubSeqAsynchronousQuery open
217  connection, send request, and queue completion routine
218  using urlquery queueing mechanism.
219 
220  PubMedCheckQueue and PubSeqCheckQueue should be called
221  several times a second with a timer.  They each call
222  QUERY_CheckQueue to poll connection, which calls completion
223  routine when result is available, cleaning up connection
224  afterwards.
225 
226  PubMedReadReply and PubSeqReadReply take conn and status
227  parameters from completion routine and reads PubmedEntryPtr
228  or SeqEntryPtr.
229 */
230 
231 NLM_EXTERN Boolean PubMedAsynchronousQuery (
232   Int4 uid,
233   QUEUE* q,
234   QueryResultProc resultproc,
235   VoidPtr userdata
236 );
237 
238 NLM_EXTERN Int4 PubMedCheckQueue (
239   QUEUE* q
240 );
241 
242 NLM_EXTERN PubmedEntryPtr PubMedReadReply (
243   CONN conn,
244   EIO_Status status
245 );
246 
247 NLM_EXTERN Boolean PubSeqAsynchronousQuery (
248   Int4 uid,
249   Int2 retcode,
250   Int4 flags,
251   QUEUE* q,
252   QueryResultProc resultproc,
253   VoidPtr userdata
254 );
255 
256 NLM_EXTERN Int4 PubSeqCheckQueue (
257   QUEUE* q
258 );
259 
260 NLM_EXTERN SeqEntryPtr PubSeqReadReply (
261   CONN conn,
262   EIO_Status status
263 );
264 
265 NLM_EXTERN Boolean GiRevHistAsynchronousQuery (
266   BIG_ID uid,
267   Int4 num,
268   BIG_ID_PNTR uids,
269   QUEUE* q,
270   QueryResultProc resultproc,
271   VoidPtr userdata
272 );
273 
274 NLM_EXTERN Int4 GiRevHistCheckQueue (
275   QUEUE* q
276 );
277 
278 NLM_EXTERN CharPtr GiRevHistReadReply (
279   CONN conn,
280   EIO_Status status
281 );
282 
283 NLM_EXTERN Boolean GiAccVerAsynchronousQuery (
284   BIG_ID uid,
285   Int4 num,
286   BIG_ID_PNTR uids,
287   QUEUE* q,
288   QueryResultProc resultproc,
289   VoidPtr userdata
290 );
291 
292 NLM_EXTERN Int4 GiAccVerCheckQueue (
293   QUEUE* q
294 );
295 
296 NLM_EXTERN CharPtr GiAccVerReadReply (
297   CONN conn,
298   EIO_Status status
299 );
300 
301 NLM_EXTERN Boolean AccnRevHistAsynchronousQuery (
302   CharPtr accn,
303   QUEUE* q,
304   QueryResultProc resultproc,
305   VoidPtr userdata
306 );
307 
308 NLM_EXTERN Int4 AccnRevHistCheckQueue (
309   QUEUE* q
310 );
311 
312 NLM_EXTERN BIG_ID AccnRevHistReadReply (
313   CONN conn,
314   EIO_Status status
315 );
316 
317 NLM_EXTERN Boolean GiSeqIdSetAsynchronousQuery (
318   BIG_ID gi,
319   QUEUE* queue,
320   QueryResultProc resultproc,
321   VoidPtr userdata
322 );
323 
324 NLM_EXTERN Int4 GiSeqIdSetCheckQueue (
325   QUEUE* queue
326 );
327 
328 NLM_EXTERN SeqIdPtr GiSeqIdSetReadReply (
329   CONN conn,
330   EIO_Status status
331 );
332 
333 NLM_EXTERN Boolean AccnListAsynchronousQuery (
334   CharPtr PNTR accns,
335   QUEUE* queue,
336   QueryResultProc resultproc,
337   VoidPtr userdata
338 );
339 
340 NLM_EXTERN Int4 AccnListCheckQueue (
341   QUEUE* queue
342 );
343 
344 NLM_EXTERN CharPtr AccnListReadReply (
345   CONN conn,
346   EIO_Status status
347 );
348 
349 /* PMID fetch registration function */
350 
351 NLM_EXTERN Boolean PubMedFetchEnable (
352   void
353 );
354 
355 NLM_EXTERN void PubMedFetchDisable (
356   void
357 );
358 
359 /* SeqId fetch registration function */
360 
361 NLM_EXTERN Boolean PubSeqFetchEnable (
362   void
363 );
364 
365 NLM_EXTERN Boolean PubSeqFetchEnableEx (
366   Boolean fetch,
367   Boolean seqidtogi,
368   Boolean gitoseqid,
369   Boolean precache,
370   Boolean seqidset,
371   Int4 flags
372 );
373 
374 NLM_EXTERN void PubSeqFetchDisable (
375   void
376 );
377 
378 /* multiple SeqId preload into cache functions */
379 
380 NLM_EXTERN Int4 GiRevHistPreLoadSeqIdGiCache (
381   Int4 num,
382   BIG_ID_PNTR uids
383 );
384 
385 NLM_EXTERN Int4 GiRevHistPreLoadSeqIdGiCacheEx (
386   Int4 num,
387   BIG_ID_PNTR uids,
388   Boolean filter
389 );
390 
391 NLM_EXTERN Int4 LIBCALLBACK GiRevHistLookupFarSeqIDs (
392   SeqEntryPtr sep,
393   Boolean components,
394   Boolean locations,
395   Boolean products,
396   Boolean alignments,
397   Boolean history,
398   Boolean inference,
399   Boolean others
400 );
401 
402 NLM_EXTERN Int4 AccnListPreLoadSeqIdGiCache (
403   CharPtr PNTR accns
404 );
405 
406 /* SeqId chain fetch function */
407 
408 NLM_EXTERN SeqIdPtr LIBCALLBACK GiRevHistLookupSeqIdSet (
409   BIG_ID gi
410 );
411 
412 /* multiple Accession bulk lookup or preload section */
413 
414 typedef void (LIBCALLBACK *CacheAccnListProc) (
415   BIG_ID gi,
416   CharPtr accnver
417 );
418 
419 /*
420  CacheAccnList takes the AccnList query result, and calls the
421  user callback if it is not NULL, otherwise it preloads the
422  sequence manager gi/accession lookup cache.  Used internally
423  by AccnListPreLoadSeqIdGiCache function.
424 */
425 
426 NLM_EXTERN Int4 CacheAccnList (
427   CharPtr str,
428   CacheAccnListProc userfunc
429 );
430 
431 
432 #ifdef __cplusplus
433 }
434 #endif
435 
436 #undef NLM_EXTERN
437 #ifdef NLM_EXPORT
438 #define NLM_EXTERN NLM_EXPORT
439 #else
440 #define NLM_EXTERN
441 #endif
442 
443 #endif /* _PMFAPI_ */
444 
445