1 /*   mmdbentr.c
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:  mmdbentr.c
27 *
28 * Author:  Christopher Hogue
29 *
30 * Version Creation Date:  14 Jan 1997
31 *
32 * $Revision: 6.3 $
33 *
34 * File Description: Used to provide Biostrucs data using
35 * Conventional Entrez subsystems (Network or CDRom)
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 *
40 * $Log: mmdbentr.c,v $
41 * Revision 6.3  2002/06/11 19:13:46  kans
42 * StrucSynchronousQuery returns BiostrucSeqPtr instead of BiostrucPtr
43 *
44 * Revision 6.2  2001/01/26 15:06:39  lewisg
45 * use entrez2 to retrieve structures
46 *
47 * Revision 6.1  1999/04/22 01:59:18  kimelman
48 * MMDB_configuration added
49 *
50 * Revision 6.0  1997/08/25 18:11:23  madden
51 * Revision changed to 6.0
52 *
53 * Revision 1.3  1997/01/15 17:52:30  hogue
54 * Initial Version
55 *
56 *
57 * ==========================================================================
58 */
59 
60 /* This file abstracts the calls to Network Entrez that were previously     */
61 /* embedded in mmdbapi1.c                                                   */
62 /* Use this to make a network MMDB client using network/CDRom Entrez        */
63 /* compile this into ncbimmdb.a and link with Network or CDEntrez libraries */
64 
65 #include <ncbi.h>
66 #include <mmdbapi.h>
67 #include <mmdbdata.h>
68 #include <ent2api.h>
69 #include <strucapi.h>
70 
71 
MMDBInit(void)72 Boolean LIBCALL MMDBInit (void)
73 {
74    /*
75    Boolean bIsNetwork = FALSE;
76    return EntrezInit("MMDBAPI client", FALSE, &bIsNetwork);
77    */
78    return TRUE;
79 }
80 
81 
MMDBFini(void)82 void LIBCALL MMDBFini (void)
83 {
84    /*
85    EntrezFini();
86    return;
87    */
88 }
89 
90 
MMDBBiostrucGet(DocUid uid,Int4 mdlLvl,Int4 maxModels)91 BiostrucPtr LIBCALL MMDBBiostrucGet (DocUid uid, Int4 mdlLvl, Int4 maxModels)
92 {
93    BiostrucSeqPtr  bsqp;
94 
95 /* MMDB - Caching would check here for matching file first */
96 
97    /*
98    return EntrezBiostrucGet(uid,  mdlLvl, maxModels);
99    */
100    bsqp = StrucSynchronousQuery (uid);
101    if (bsqp == NULL) return NULL;
102    return bsqp->structure;
103 
104 /* Caching would also save file here */
105 
106 }
107 
108 
MMDBEvalPDB(CharPtr str)109 DocUid LIBCALL MMDBEvalPDB(CharPtr str)
110 {
111   Entrez2BooleanReplyPtr  e2br;
112   Entrez2IdListPtr        e2id;
113   Entrez2RequestPtr       e2rq;
114   Entrez2ReplyPtr         e2ry;
115   Char                    tmp [61];
116   Uint4                   uid = 0;
117 
118   if (str == NULL) return 0;
119 
120   StringNCpy_0 (tmp, str, sizeof (tmp) - 10);
121   if (StringStr (tmp, "[ACCN]") == NULL) {
122     StringCat (tmp, " [ACCN]");
123   }
124 
125   e2rq = EntrezCreateBooleanRequest (TRUE, FALSE, "Structure", tmp,
126                                      0, 0, NULL, 1, 0);
127   if (e2rq == NULL) return 0;
128   e2ry = EntrezSynchronousQuery (e2rq);
129   e2rq = Entrez2RequestFree (e2rq);
130   if (e2ry == NULL) return 0;
131   e2br = EntrezExtractBooleanReply (e2ry);
132   if (e2br == NULL) return 0;
133 
134   if (e2br->count > 0) {
135     e2id = e2br->uids;
136     if (e2id != NULL && e2id->num > 0 && e2id->uids != NULL) {
137       BSSeek (e2id->uids, 0, SEEK_SET);
138       uid = Nlm_BSGetUint4 (e2id->uids);
139     }
140   }
141 
142   Entrez2BooleanReplyFree (e2br);
143 
144   return uid;
145    /*
146    LinkSetPtr plsLink = NULL;
147    DocUid duUID = 0;
148 
149    if ((!str)) return (DocUid) 0;
150    plsLink = EntrezTLEvalString(str, (DocType) TYP_ST,
151 			  (DocField) FLD_ACCN,  NULL, NULL);
152 
153    if (plsLink != NULL && plsLink->num > 0 && plsLink->uids != NULL)
154 	{
155 	   duUID = plsLink->uids[0];
156         }
157    LinkSetFree(plsLink);
158 
159    return duUID;
160    */
161 }
162 
MMDB_configuration(void)163 CharPtr  LIBCALL MMDB_configuration(void)
164 {
165   return
166     "Version:\t$Id: mmdbentr.c,v 6.3 2002/06/11 19:13:46 kans Exp $\nConfiguration:"
167     " Entrez"
168     "\n";
169 }
170