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: e2docsum.c
28
* Author: Jonathan Kans, Greg Schuler, Jonathan Epstein, Tim Ford
30
* Version Creation Date: 10/30/01
37
* --------------------------------------------------------------------------
39
* ==========================================================================
69
#define MAX_UIDS 30000
71
#define WORST_ID_BUFF_SIZE 256
76
#define NO_AUTHOR_STR "[No Author Available]"
77
#define NO_TITLE_STR "[No Title Available]"
78
#define NO_SOURCE_STR "[No Source Available]"
79
#define NO_DATE_STR "[No Date Available]"
80
#define NO_VOLUME_STR "[No Volume Available]"
81
#define NO_PAGE_STR "[No Page Available]"
82
#define NO_CAPTION_STR "[No Caption Available]"
83
#define NO_UID_STR "[No UID Available]"
85
/*----------------------*/
86
/* Set up static arrays */
87
/*----------------------*/
89
static ParData docsumParFmt = { TRUE, FALSE, FALSE, FALSE, FALSE, 0, 0 };
90
static ColData docsumColFmt [] = {
91
{0, 0, 15, 0, NULL, 'l', TRUE, FALSE, FALSE, FALSE, FALSE}, /* caption */
92
{0, 5, 65, 0, NULL, 'l', TRUE, FALSE, FALSE, FALSE, TRUE} /* term */
94
static ColData textColFmt [] = {
95
{0, 0, 80, 0, NULL, 'l', FALSE, FALSE, FALSE, FALSE, TRUE} /* text */
102
static Uint1 hasabstract [] = {
103
0x07, 0xF8, 0x1F, 0xE0, 0x78, 0x07, 0xE0, 0x1E,
104
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
105
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
106
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
107
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
108
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
109
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
110
0x40, 0x01, 0x80, 0x02, 0x4F, 0xF9, 0x9F, 0xF2,
111
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
112
0x40, 0x01, 0x80, 0x02, 0x47, 0xF9, 0x9F, 0xE2,
113
0x7F, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xFE
116
static Uint1 noabstract [] = {
117
0x07, 0xF8, 0x1F, 0xE0, 0x78, 0x07, 0xE0, 0x1E,
118
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
119
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
120
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
121
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
122
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
123
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
124
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
125
0x40, 0x01, 0x80, 0x02, 0x40, 0x01, 0x80, 0x02,
126
0x40, 0x01, 0x80, 0x02, 0x47, 0xF9, 0x9F, 0xE2,
127
0x7F, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xFE
130
static Uint1 proteinicon [] = {
131
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
132
0x40, 0x00, 0x00, 0x02, 0x43, 0x83, 0x80, 0x02,
133
0x44, 0x44, 0x40, 0x02, 0x43, 0xC3, 0xC0, 0x02,
134
0x44, 0x44, 0x40, 0x02, 0x44, 0x44, 0x40, 0x02,
135
0x44, 0x44, 0x40, 0x02, 0x43, 0xE3, 0xE0, 0x02,
136
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
137
0x40, 0x00, 0x00, 0x02, 0x47, 0xE7, 0xE7, 0xE2,
138
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
139
0x47, 0xE7, 0xE7, 0xE2, 0x40, 0x00, 0x00, 0x02,
140
0x40, 0x00, 0x00, 0x02, 0x47, 0xE7, 0xE7, 0xE2,
141
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
144
static Uint1 dnaicon [] = {
145
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
146
0x40, 0x00, 0x00, 0x02, 0x45, 0x81, 0x00, 0x02,
147
0x46, 0x41, 0x00, 0x02, 0x44, 0x47, 0xC0, 0x02,
148
0x44, 0x41, 0x00, 0x02, 0x44, 0x41, 0x00, 0x02,
149
0x44, 0x41, 0x00, 0x02, 0x44, 0x60, 0xC0, 0x02,
150
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
151
0x40, 0x00, 0x00, 0x02, 0x4F, 0x7B, 0xDE, 0xF2,
152
0x40, 0x00, 0x00, 0x02, 0x4F, 0x7B, 0xDE, 0xF2,
153
0x40, 0x00, 0x00, 0x02, 0x4F, 0x7B, 0xDE, 0xF2,
154
0x40, 0x00, 0x00, 0x02, 0x4F, 0x7B, 0xDE, 0xF2,
155
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
158
static Uint1 threedicon [] = {
159
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
160
0x40, 0x00, 0x00, 0x02, 0x4E, 0x0E, 0x00, 0x02,
161
0x41, 0x09, 0x00, 0x02, 0x40, 0x88, 0x80, 0x02,
162
0x47, 0x08, 0x80, 0x02, 0x40, 0x88, 0x80, 0x02,
163
0x41, 0x09, 0x00, 0x02, 0x4E, 0x0E, 0x00, 0x02,
164
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
165
0x40, 0x00, 0x00, 0x02, 0x47, 0xE0, 0x00, 0x02,
166
0x40, 0x07, 0xE0, 0x02, 0x40, 0x00, 0x07, 0xE2,
167
0x47, 0xE0, 0x00, 0x02, 0x40, 0x07, 0xE0, 0x02,
168
0x40, 0x00, 0x07, 0xE2, 0x47, 0xE0, 0x00, 0x02,
169
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
172
static Uint1 genomeicon [] = {
173
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
174
0x40, 0xF0, 0xF0, 0x02, 0x41, 0x01, 0x08, 0x02,
175
0x41, 0x01, 0x00, 0x02, 0x41, 0x01, 0x00, 0x02,
176
0x41, 0x01, 0x38, 0x02, 0x41, 0x01, 0x10, 0x02,
177
0x40, 0xF0, 0xE0, 0x02, 0x40, 0x00, 0x00, 0x02,
178
#ifdef USE_CHROMOSOME_BANDS_IN_ICON
179
/* chromosome bands */
180
0x40, 0x00, 0x00, 0x02, 0x4F, 0xEF, 0xFF, 0xF2,
181
0x50, 0x10, 0xC4, 0xEA, 0x50, 0x10, 0xC4, 0xEA,
182
0x50, 0x10, 0xC4, 0xEA, 0x50, 0x10, 0xC4, 0xEA,
183
0x50, 0x10, 0xC4, 0xEA, 0x50, 0x10, 0xC4, 0xEA,
184
0x50, 0x10, 0xC4, 0xEA, 0x4F, 0xEF, 0xFF, 0xF2,
185
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
188
0x40, 0x00, 0x00, 0x02, 0x4F, 0xFF, 0xFF, 0xF2,
189
0x48, 0x00, 0x00, 0x12, 0x4F, 0xFF, 0xFF, 0xF2,
190
0x40, 0x00, 0x00, 0x02, 0x40, 0xE0, 0xFF, 0x02,
191
0x40, 0x00, 0x00, 0x02, 0x4F, 0x0F, 0x80, 0x02,
192
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
193
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
197
static Uint1 popseticon [] = {
198
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
199
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
200
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
201
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
202
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
203
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
204
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
205
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
206
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
207
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
208
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
211
static Uint1 omimicon [] = {
212
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
213
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
214
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
215
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
216
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
217
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
218
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
219
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
220
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
221
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
222
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
225
static Uint1 taxonomyicon [] = {
226
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
227
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
228
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
229
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
230
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
231
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
232
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
233
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
234
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
235
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
236
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
239
static Uint1 booksicon [] = {
240
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
241
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
242
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
243
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
244
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
245
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
246
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
247
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
248
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
249
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
250
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
253
static Uint1 probeicon [] = {
254
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
255
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
256
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
257
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
258
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
259
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
260
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
261
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
262
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
263
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
264
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
267
static Uint1 domainicon [] = {
268
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
269
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
270
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
271
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
272
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
273
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
274
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
275
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
276
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
277
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
278
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
281
static Uint1 genericon [] = {
282
0x7F, 0xFF, 0xFF, 0xFE, 0x40, 0x00, 0x00, 0x02,
283
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
284
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
285
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
286
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
287
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
288
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
289
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
290
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
291
0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02,
292
0x40, 0x00, 0x00, 0x02, 0x7F, 0xFF, 0xFF, 0xFE
295
/*-----------------------------------------*/
296
/* Define the possible documents types for */
297
/* each database and the functions used to */
298
/* retrieve these documents. */
299
/*-----------------------------------------*/
301
static CharPtr defaultRadios [] = { "Summary", "Fields", NULL };
302
static CharPtr medRadios [] = { "Summary", "Fields", "Abstract", "Citation", "MEDLINE", "PubMed ID", NULL };
303
static CharPtr prtRadios [] = { "Summary", "Fields", "GenPept", "FASTA", "Protein ID", NULL };
304
static CharPtr nucRadios [] = { "Summary", "Fields", "GenBank", "EMBL", "FASTA", "Nucleotide ID", NULL };
305
static CharPtr strucRadios [] = { "Summary", "Fields", "Report", "Structure ID", NULL };
306
static CharPtr genRadios [] = { "Summary", "Fields", "Genome ID", NULL };
307
static CharPtr popsetRadios [] = { "Summary", "Fields", "Sequence ID", NULL };
308
static CharPtr omimRadios [] = { "Summary", "Fields", "MIM ID", NULL };
309
static CharPtr taxonomyRadios [] = { "Summary", "Fields", "Taxon ID", NULL };
310
static CharPtr bookRadios [] = { "Summary", "Fields", "Book ID", NULL };
311
static CharPtr probeRadios [] = { "Summary", "Fields", "ProbeSet ID", NULL };
312
static CharPtr domainRadios [] = { "Summary", "Fields", "Domain ID", NULL };
313
static CharPtr localBioseqRadios [] = { "FASTA", NULL };
315
static CharPtr medLaunch [] = { "Local", "Web Entrez", NULL };
316
static CharPtr prtLaunch [] = { "Local", "Sequin", "Web Entrez", NULL };
317
static CharPtr nucLaunch [] = { "Local", "Sequin", "Web Entrez", NULL };
318
static CharPtr strucLaunch [] = { "Cn3D", "Web Entrez", NULL };
319
static CharPtr genLaunch [] = { "Local", "Sequin", "Web Entrez", NULL };
320
static CharPtr popsetLaunch [] = { "Local", "Sequin", "Web Entrez", NULL };
321
static CharPtr omimLaunch [] = { "Web Entrez", NULL };
322
static CharPtr taxonomyLaunch [] = { "Web Entrez", NULL };
323
static CharPtr bookLaunch [] = { "Web Entrez", NULL };
324
static CharPtr probeLaunch [] = { "Web Entrez", NULL };
325
static CharPtr domainLaunch [] = { "Web Entrez", NULL };
327
/*-----------------------------------*/
328
/* Data structures used to keep info */
329
/* about the current window. */
330
/*-----------------------------------*/
332
typedef struct docsumstatedata {
333
unsigned int checked:1;
334
unsigned int hasAbstract:1;
335
unsigned int noSuchUid:1;
336
} DocSumStateData, PNTR DocSumStateDataPtr;
338
typedef struct summformdata {
340
E2NamedUidListProc refineUidProc;
343
PopuP formatPopups [MAX_DBS + 1];
344
PopuP launchPopups [MAX_DBS + 1];
351
Boolean wasDoubleClick;
359
EnumFieldAssocPtr dbalist;
363
SimpleSeqPtr PNTR simple;
364
DocSumStateDataPtr state;
377
Int4Ptr historyOffsets;
386
Entrez2DocsumListPtr tempE2DLP;
387
} SummFormData, PNTR SummFormPtr;
390
/*==================================================================*/
392
/* BioseqFindEntityByGi () - */
394
/*==================================================================*/
396
static Uint2 BioseqFindEntityByGi (Int4 uid, Uint2Ptr itemIDptr)
401
if (uid <= 0) return 0;
402
vn.choice = SEQID_GI;
403
vn.data.intvalue = uid;
404
return BioseqFindEntity (&vn, itemIDptr);
407
/*==================================================================*/
409
/* SetDefaultFailureMessage () - */
411
/*==================================================================*/
413
static CharPtr SetDefaultFailureMessage (SummFormPtr sfp, Int2 item, CharPtr prefix)
417
CharPtr dbname = NULL;
427
return StringSave ("?");
429
if (sfp->currDb >= 0 && sfp->currDb < MAX_DBS) {
430
dbname = GetEnumName ((UIEnum) sfp->currDb, sfp->dbalist);
433
if (dbname == NULL) {
438
sprintf (tmp, "%sItem < 1 for database %s", prefix, dbname);
439
} else if (sfp->uids != NULL && sfp->simple == NULL) {
440
uid = sfp->uids [item - 1];
442
sprintf (tmp, "%sID < 1 for database %s", prefix, dbname);
444
sprintf (tmp, "%sFailure for ID %ld in %s database", prefix, (long) uid, dbname);
446
} else if (sfp->simple != NULL && sfp->uids == NULL) {
447
ssp = sfp->simple [item - 1];
449
sprintf ("%sIncorrect seq-entry for database %s", prefix, dbname);
451
StringCpy (buf, "?");
452
if (ssp->numid > 0 && ssp->bestid < ssp->numid) {
453
StringNCpy_0 (buf, ssp->id [ssp->bestid], sizeof (buf));
455
sprintf ("%sProblem with sequence %s in %s database", prefix, buf, dbname);
458
sprintf ("%sInternal confusion for database %s", prefix, dbname);
461
return StringSave (tmp);
464
/*==================================================================*/
466
/* DoDrawCheck () - */
468
/*==================================================================*/
470
static void DoDrawCheck (SummFormPtr sfp, RectPtr r, Int2 item, Int2 frst, Boolean docsum)
476
if (sfp == NULL || sfp->state == NULL) return;
477
if (item < 1 || item > sfp->numUids) return;
478
checked = sfp->state [item - 1].checked;
481
rct.right = rct.left + sfp->lineHeight;
482
rct.bottom = rct.top + sfp->lineHeight;
483
if (RectInRgn (&rct, updateRgn)) {
486
MoveTo (rct.left, rct.top);
487
LineTo (rct.right - 1, rct.bottom - 1);
488
MoveTo (rct.left, rct.bottom - 1);
489
LineTo (rct.right - 1, rct.top);
492
if (item <= sfp->numParents) {
495
rct.left += docsumColFmt [0].pixInset - 6;
496
rct.top += (sfp->lineHeight - 4) / 2;
497
rct.right = rct.left + 4;
498
rct.bottom = rct.top + 4;
500
rct.left += textColFmt [0].pixInset - 6;
501
rct.top += (sfp->lineHeight - 4) / 2;
502
rct.right = rct.left + 4;
503
rct.bottom = rct.top + 4;
505
if (RectInRgn (&rct, updateRgn)) {
512
/*==================================================================*/
514
/* DrawLocalCheck () - */
516
/*==================================================================*/
518
static void DrawLocalCheck (SummFormPtr sfp, RectPtr r, Int2 item, Int2 frst, Boolean docsum)
523
if (sfp == NULL || sfp->simple == NULL || sfp->state == NULL) return;
524
if (item < 1 || item > sfp->numUids) return;
525
ssp = sfp->simple [item - 1];
526
if (ssp == NULL) return;
527
DoDrawCheck (sfp, r, item, frst, docsum);
530
/*==================================================================*/
532
/* DrawUidCheck () - */
534
/*==================================================================*/
536
static void DrawUidCheck (SummFormPtr sfp, RectPtr r, Int2 item, Int2 frst, Boolean docsum)
541
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return;
542
if (item < 1 || item > sfp->numUids) return;
543
uid = sfp->uids [item - 1];
545
DoDrawCheck (sfp, r, item, frst, docsum);
548
/*==================================================================*/
550
/* DrawIcon () - Figures out which icon to draw (based on the */
551
/* current db) and then draws it in the proper spot. */
553
/*==================================================================*/
555
static void DrawIcon (SummFormPtr sfp, RectPtr r, Int2 item, Int2 frst)
565
/*------------------------------------*/
566
/* Perform sanity check on parameters */
567
/*------------------------------------*/
569
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return;
570
if (item < 1 || item > sfp->numUids) return;
571
if (frst >= sfp->linesPerIcon) return;
573
/*---------------------------------*/
574
/* Get the current state of things */
575
/*---------------------------------*/
578
uid = sfp->uids [item - 1];
579
hasAbstract = sfp->state [item - 1].hasAbstract;
582
/*-----------------------------*/
583
/* Calculate which icon to use */
584
/*-----------------------------*/
586
dbName = DBGetNameFromID (db);
588
if (StringICmp (dbName, "PubMed") == 0) {
593
} else if (StringICmp (dbName, "Protein") == 0)
595
else if (StringICmp (dbName, "Nucleotide") == 0)
597
else if (StringICmp (dbName, "Structure") == 0)
599
else if (StringICmp (dbName, "Genome") == 0)
601
else if (StringICmp (dbName, "Popset") == 0)
603
else if (StringICmp (dbName, "OMIM") == 0)
605
else if (StringICmp (dbName, "Taxonomy") == 0)
607
else if (StringICmp (dbName, "Books") == 0)
609
else if (StringICmp (dbName, "geo") == 0)
611
else if (StringICmp (dbName, "domains") == 0)
616
/*------------------*/
617
/* Display the icon */
618
/*------------------*/
621
rct.left += 3 * stdCharWidth - 8;
622
rct.right = rct.left + 32;
623
rct.bottom = MIN (rct.bottom, rct.top + 22 - frst * sfp->lineHeight);
624
if (RectInRgn (&rct, updateRgn)) {
626
CopyBits (&rct, icon + 4 * frst * sfp->lineHeight);
631
/*==================================================================*/
633
/* DrawTextSum () - */
635
/*==================================================================*/
637
static void DrawTextSum (DoC d, RectPtr r, Int2 item, Int2 frst)
642
sfp = (SummFormPtr) GetObjectExtra (d);
643
DrawUidCheck (sfp, r, item, frst, FALSE);
646
/*==================================================================*/
648
/* DrawLocalSum () - */
650
/*==================================================================*/
652
static void DrawLocalSum (DoC d, RectPtr r, Int2 item, Int2 frst)
657
sfp = (SummFormPtr) GetObjectExtra (d);
658
DrawLocalCheck (sfp, r, item, frst, FALSE);
661
/*==================================================================*/
663
/* DrawDocSum () - */
665
/*==================================================================*/
667
static void DrawDocSum (DoC d, RectPtr r, Int2 item, Int2 frst)
672
sfp = (SummFormPtr) GetObjectExtra (d);
673
DrawUidCheck (sfp, r, item, frst, TRUE);
674
DrawIcon (sfp, r, item, frst);
677
/*==================================================================*/
679
/* Query_FetchDocSum () - */
680
/* Query_FetchFields () - */
682
/*==================================================================*/
684
static CharPtr FormatDocsum (Entrez2DocsumPtr e2DocsumPtr)
687
Entrez2DocsumDataPtr e2DocsumDataPtr;
710
if (e2DocsumPtr == NULL) return NULL;
728
for (e2DocsumDataPtr = e2DocsumPtr->docsum_data; e2DocsumDataPtr != NULL; e2DocsumDataPtr = e2DocsumDataPtr->next) {
729
if (StringHasNoText (e2DocsumDataPtr->field_value)) continue;
730
if (StringICmp (e2DocsumDataPtr->field_name, "Caption") == 0) {
731
caption = e2DocsumDataPtr->field_value;
732
} else if (StringICmp (e2DocsumDataPtr->field_name, "Title") == 0) {
733
title = e2DocsumDataPtr->field_value;
734
} else if (StringICmp (e2DocsumDataPtr->field_name, "Authors") == 0 ||
735
StringICmp (e2DocsumDataPtr->field_name, "Author") == 0) {
736
authors = e2DocsumDataPtr->field_value;
737
} else if (StringICmp (e2DocsumDataPtr->field_name, "Accession") == 0) {
738
accession = e2DocsumDataPtr->field_value;
739
} else if (StringICmp (e2DocsumDataPtr->field_name, "Extra") == 0) {
740
extra = e2DocsumDataPtr->field_value;
741
} else if (StringICmp (e2DocsumDataPtr->field_name, "TaxID") == 0) {
742
taxid = e2DocsumDataPtr->field_value;
743
} else if (StringICmp (e2DocsumDataPtr->field_name, "ScientificName") == 0) {
744
sciname = e2DocsumDataPtr->field_value;
745
} else if (StringICmp (e2DocsumDataPtr->field_name, "Oid") == 0) {
746
oid = e2DocsumDataPtr->field_value;
747
} else if (StringICmp (e2DocsumDataPtr->field_name, "Accession1") == 0) {
748
accession1 = e2DocsumDataPtr->field_value;
749
} else if (StringICmp (e2DocsumDataPtr->field_name, "Title1") == 0) {
750
title1 = e2DocsumDataPtr->field_value;
751
} else if (StringICmp (e2DocsumDataPtr->field_name, "mRNASource1") == 0) {
752
mrnasrc1 = e2DocsumDataPtr->field_value;
753
} else if (StringICmp (e2DocsumDataPtr->field_name, "mRNASource2") == 0) {
754
mrnasrc2 = e2DocsumDataPtr->field_value;
755
} else if (StringICmp (e2DocsumDataPtr->field_name, "Book") == 0) {
756
book = e2DocsumDataPtr->field_value;
762
if (StringHasNoText (cpt)) {
765
if (StringHasNoText (cpt)) {
768
if (StringHasNoText (cpt)) {
771
if (StringHasNoText (cpt)) {
774
if (StringHasNoText (cpt)) {
777
if (StringHasNoText (cpt)) {
780
if (StringHasNoText (cpt)) {
786
if (StringHasNoText (ttl)) {
789
if (StringHasNoText (ttl)) {
792
if (StringHasNoText (ttl)) {
795
if (StringHasNoText (ttl)) {
799
len = StringLen (cpt) + StringLen (ttl) + StringLen (extra) +
800
StringLen (mrnasrc2) + StringLen (", et al.") + StringLen ("vs. ");
801
str = MemNew (len + 10);
803
StringCpy (str, cpt);
804
if (cpt == authors) {
805
if (StringLen (str) > 64) {
808
for (tmp = str, ch = *tmp; ch != '\0'; tmp++, ch = *tmp) {
816
if (commas > 2 && etal != NULL) {
818
StringCat (str, ", et al.");
822
StringCat (str, "\t");
823
StringCat (str, ttl);
824
if (ttl == mrnasrc1) {
825
if (! StringHasNoText (mrnasrc2)) {
826
StringCat (str, "vs. ");
827
StringCat (str, mrnasrc2);
829
} else if (ttl == title) {
830
if (! StringHasNoText (extra)) {
831
StringCat (str, "\r");
832
StringCat (str, extra);
840
static CharPtr FormatFields (Entrez2DocsumPtr e2DocsumPtr)
843
Entrez2DocsumDataPtr e2DocsumDataPtr;
847
if (e2DocsumPtr == NULL) return NULL;
850
for (e2DocsumDataPtr = e2DocsumPtr->docsum_data; e2DocsumDataPtr != NULL; e2DocsumDataPtr = e2DocsumDataPtr->next) {
851
if (StringHasNoText (e2DocsumDataPtr->field_name)) continue;
852
if (StringHasNoText (e2DocsumDataPtr->field_value)) continue;
853
len += StringLen (e2DocsumDataPtr->field_name) + StringLen (e2DocsumDataPtr->field_value) + 3;
855
str = MemNew (len + 5);
857
for (e2DocsumDataPtr = e2DocsumPtr->docsum_data; e2DocsumDataPtr != NULL; e2DocsumDataPtr = e2DocsumDataPtr->next) {
858
if (StringHasNoText (e2DocsumDataPtr->field_name)) continue;
859
if (StringHasNoText (e2DocsumDataPtr->field_value)) continue;
860
StringCat (str, e2DocsumDataPtr->field_name);
861
StringCat (str, "\t");
862
StringCat (str, e2DocsumDataPtr->field_value);
863
StringCat (str, "\n");
870
typedef CharPtr (*FormatE2DSPProc) (Entrez2DocsumPtr e2DocsumPtr);
872
static CharPtr Query_FetchDocSumCommon (DoC d, Int2 item, FormatE2DSPProc proc)
875
Entrez2RequestPtr e2RequestPtr = NULL;
876
Entrez2ReplyPtr e2ReplyPtr;
877
Entrez2DocsumDataPtr e2DocsumDataPtr;
878
Entrez2DocsumListPtr e2DocsumListPtr;
879
Entrez2DocsumPtr e2DocsumPtr;
890
/*------------------------------------------*/
891
/* Make sure that initial conditions are ok */
892
/*------------------------------------------*/
894
sfp = (SummFormPtr) GetObjectExtra (d);
895
failed = SetDefaultFailureMessage (sfp, item, "\r\t");
896
if (proc == NULL) return failed;
897
if (sfp == NULL || sfp->uids == NULL ||
898
sfp->state == NULL || sfp->formatted == NULL) return failed;
899
if (item < 1) return failed;
901
/*----------------------------*/
902
/* Fetch the document summary */
903
/* for the request UID. */
904
/*----------------------------*/
906
uid = sfp->uids [item - 1];
907
dbName = DBGetNameFromID (sfp->currDb);
909
/* check existing cache */
911
if (sfp->tempE2DLP != NULL) {
912
e2DocsumListPtr = sfp->tempE2DLP;
913
for (e2DocsumPtr = e2DocsumListPtr->list; e2DocsumPtr != NULL; e2DocsumPtr = e2DocsumPtr->next) {
914
if (uid == e2DocsumPtr->uid) {
915
str = proc (e2DocsumPtr);
916
/* sfp->state [item - 1].hasAbstract = (Boolean) (! e2DocsumPtr->no_abstract); */
917
sfp->state [item - 1].hasAbstract = FALSE;
918
for (e2DocsumDataPtr = e2DocsumPtr->docsum_data; e2DocsumDataPtr != NULL; e2DocsumDataPtr = e2DocsumDataPtr->next) {
919
if (StringHasNoText (e2DocsumDataPtr->field_value)) continue;
920
if (StringICmp (e2DocsumDataPtr->field_name, "HasAbstract") == 0) {
921
if (StringICmp (e2DocsumDataPtr->field_value, "1") == 0) {
922
sfp->state [item - 1].hasAbstract = TRUE;
926
sfp->formatted [item - 1] = TRUE;
933
sfp->tempE2DLP = Entrez2DocsumListFree (sfp->tempE2DLP);
935
/* create new request */
939
for (i = item, j = 0; i < sfp->numUids && j < 20 && numToFetch < 20; i++, j++) {
940
if (! sfp->formatted [i]) {
941
uids [numToFetch] = sfp->uids [i];
945
for (i = item - 1, j = 0; i >= 0 && j < 20 && numToFetch < 30; i--, j++) {
946
if (! sfp->formatted [i]) {
947
uids [numToFetch] = sfp->uids [i];
952
/* accelerate docsum page even with slow server by requesting several at once */
955
e2RequestPtr = EntrezCreateDocSumRequest (dbName, 0, (Int4) numToFetch, uids, NULL);
958
if ((getenv ("NCBI_ENTREZ_FAST_DOCSUMS")) != NULL) {
959
e2RequestPtr = EntrezCreateDocSumRequest (dbName, 0, (Int4) numToFetch, uids, NULL);
963
/* leave one at a time request in public version until server is made faster */
965
if (e2RequestPtr == NULL) {
966
e2RequestPtr = EntrezCreateDocSumRequest (dbName, uid, 0, NULL, NULL);
969
if (e2RequestPtr == NULL) return failed;
971
if (ShowASN () == TRUE)
972
DisplayEntrezRequest (e2RequestPtr);
974
e2ReplyPtr = EntrezSynchronousQuery (e2RequestPtr);
975
if (e2ReplyPtr == NULL) return failed;
977
if (ShowASN () == TRUE)
978
DisplayEntrezReply (e2ReplyPtr);
980
sfp->tempE2DLP = EntrezExtractDocsumReply (e2ReplyPtr);
981
Entrez2RequestFree (e2RequestPtr);
982
if (sfp->tempE2DLP == NULL) return failed;
984
/* check new cache */
986
if (sfp->tempE2DLP != NULL) {
987
e2DocsumListPtr = sfp->tempE2DLP;
988
for (e2DocsumPtr = e2DocsumListPtr->list; e2DocsumPtr != NULL; e2DocsumPtr = e2DocsumPtr->next) {
989
if (uid == e2DocsumPtr->uid) {
990
str = proc (e2DocsumPtr);
991
/* sfp->state [item - 1].hasAbstract = (Boolean) (! e2DocsumPtr->no_abstract); */
992
sfp->state [item - 1].hasAbstract = FALSE;
993
for (e2DocsumDataPtr = e2DocsumPtr->docsum_data; e2DocsumDataPtr != NULL; e2DocsumDataPtr = e2DocsumDataPtr->next) {
994
if (StringHasNoText (e2DocsumDataPtr->field_value)) continue;
995
if (StringICmp (e2DocsumDataPtr->field_name, "HasAbstract") == 0) {
996
if (StringICmp (e2DocsumDataPtr->field_value, "1") == 0) {
997
sfp->state [item - 1].hasAbstract = TRUE;
1001
sfp->formatted [item - 1] = TRUE;
1011
static CharPtr Query_FetchDocSum (DoC d, Int2 item, Pointer ptr)
1014
return Query_FetchDocSumCommon (d, item, FormatDocsum);
1017
static CharPtr Query_FetchFields (DoC d, Int2 item, Pointer ptr)
1020
return Query_FetchDocSumCommon (d, item, FormatFields);
1023
/*==================================================================*/
1025
/* FileToString () - */
1027
/*==================================================================*/
1029
static CharPtr FileToString (CharPtr path)
1037
if (path == NULL) return NULL;
1039
len = FileLength (path);
1040
if (len > 0 && len < MAXALLOC) {
1041
fp = FileOpen (path, "r");
1043
ptr = MemNew (sizeof (Char) * (size_t) (len + 4));
1045
actual = FileRead (ptr, 1, (size_t) len, fp);
1046
if (actual > 0 && actual <= len) {
1047
ptr [actual] = '\0';
1056
/*==================================================================*/
1060
/*==================================================================*/
1062
static CharPtr FetchUid (DoC d, Int2 item, Pointer ptr)
1070
/*--------------------------*/
1071
/* Check initial conditions */
1072
/*--------------------------*/
1074
sfp = (SummFormPtr) GetObjectExtra (d);
1075
failed = SetDefaultFailureMessage (sfp, item, NULL);
1076
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return failed;
1077
if (item < 1) return failed;
1079
/*------------------------------------*/
1080
/* Get the UID for the requested item */
1081
/*------------------------------------*/
1083
uid = sfp->uids [item - 1];
1084
if (uid < 1) return failed;
1085
sprintf (str, "%ld\n", (long) uid);
1087
/*----------------------------------*/
1088
/* Clean up and return successfully */
1089
/*----------------------------------*/
1092
return StringSave (str);
1095
/*==================================================================*/
1097
/* FetchPubMed () - */
1099
/*==================================================================*/
1101
typedef Boolean (*FormatMedlineProc) (MedlineEntryPtr, FILE*);
1103
static CharPtr FetchPubMed (DoC d, Int2 item, Pointer ptr, FormatMedlineProc func)
1108
Char path [PATH_MAX];
1114
/*--------------------------*/
1115
/* Check initial conditions */
1116
/*--------------------------*/
1118
sfp = (SummFormPtr) GetObjectExtra (d);
1119
failed = SetDefaultFailureMessage (sfp, item, NULL);
1121
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return failed;
1122
if (item < 1) return failed;
1124
uid = sfp->uids [item - 1];
1126
if ((pep = PubMedSynchronousQuery (uid)) == NULL) return failed;
1128
/*------------------------*/
1129
/* Store to temp file and */
1130
/* then read back in. */
1131
/*------------------------*/
1135
fp = FileOpen (path, "w");
1137
if (func ((MedlineEntryPtr) pep->medent, fp)) {
1139
str = FileToString (path);
1145
PubmedEntryFree (pep);
1147
if (str == NULL) return failed;
1153
static CharPtr FetchAbstract (DoC d, Int2 item, Pointer ptr)
1156
return FetchPubMed (d, item, ptr, MedlineEntryToAbsFile);
1159
static CharPtr FetchCitation (DoC d, Int2 item, Pointer ptr)
1162
return FetchPubMed (d, item, ptr, MedlineEntryToDocFile);
1165
static CharPtr FetchMedline (DoC d, Int2 item, Pointer ptr)
1168
return FetchPubMed (d, item, ptr, MedlineEntryToDataFile);
1171
/*==================================================================*/
1173
/* GetBioseqForUid () - */
1175
/*==================================================================*/
1177
static BioseqPtr GetBioseqForUid (SeqEntryPtr topsep, Int4 uid)
1184
if (topsep == NULL || uid == 0)
1186
vn.choice = SEQID_GI;
1188
vn.data.intvalue = uid;
1190
oldsep = SeqEntrySetScope (topsep);
1191
bsp = BioseqFind (&vn);
1192
SeqEntrySetScope (oldsep);
1196
/*==================================================================*/
1198
/* FetchSequence () - */
1200
/*==================================================================*/
1202
static CharPtr FetchSequence (DoC d, Int2 item, Pointer ptr, FmtType format, Boolean do_fasta, Boolean is_na)
1208
Uint1 group_segs = 0;
1210
Boolean okay = FALSE;
1211
Char path [PATH_MAX];
1212
SeqEntryPtr seqEntryPtr;
1219
sfp = (SummFormPtr) GetObjectExtra (d);
1220
failed = SetDefaultFailureMessage (sfp, item, NULL);
1221
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return failed;
1222
if (item < 1) return failed;
1223
uid = sfp->uids [item - 1];
1225
currDbName = DBGetNameFromID (sfp->currDb);
1228
if ((seqEntryPtr = PubSeqSynchronousQuery (currDbName, uid)) == NULL) return failed;
1230
bsp = GetBioseqForUid (seqEntryPtr, uid);
1231
sep = SeqMgrGetSeqEntryForData (bsp);
1233
SeqEntryFree (seqEntryPtr);
1237
/*------------------------*/
1238
/* Store to temp file and */
1239
/* then read back in. */
1240
/*------------------------*/
1244
fp = FileOpen (path, "w");
1246
level = ErrSetMessageLevel (SEV_MAX);
1248
if (bsp->repr == Seq_repr_seg) {
1250
} else if (bsp->repr == Seq_repr_delta) {
1253
okay = SeqEntrysToFasta (seqEntryPtr, fp, is_na, group_segs);
1255
okay = SeqEntryToGnbk (sep, NULL, format, RELEASE_MODE, NORMAL_STYLE, 0, fp);
1259
str = FileToString (path);
1263
ErrSetMessageLevel (level);
1266
SeqEntryFree (seqEntryPtr);
1268
if (str == NULL) return failed;
1274
static CharPtr FetchGenBank (DoC d, Int2 item, Pointer ptr)
1277
return FetchSequence (d, item, ptr, GENBANK_FMT, FALSE, FALSE);
1280
static CharPtr FetchEmbl (DoC d, Int2 item, Pointer ptr)
1283
return FetchSequence (d, item, ptr, EMBL_FMT, FALSE, FALSE);
1286
static CharPtr FetchGenPept (DoC d, Int2 item, Pointer ptr)
1289
return FetchSequence (d, item, ptr, GENPEPT_FMT, FALSE, FALSE);
1292
static CharPtr FetchFastaNuc (DoC d, Int2 item, Pointer ptr)
1295
return FetchSequence (d, item, ptr, GENPEPT_FMT, TRUE, TRUE);
1298
static CharPtr FetchFastaProt (DoC d, Int2 item, Pointer ptr)
1301
return FetchSequence (d, item, ptr, GENPEPT_FMT, TRUE, FALSE);
1304
/*==================================================================*/
1308
/*==================================================================*/
1310
static CharPtr FetchPDB (DoC d, Int2 item, Pointer ptr)
1313
BiostrucPtr bsp = NULL;
1318
Char path [PATH_MAX];
1325
sfp = (SummFormPtr) GetObjectExtra (d);
1326
failed = SetDefaultFailureMessage (sfp, item, NULL);
1327
if (sfp == NULL || sfp->uids == NULL || sfp->state == NULL) return failed;
1328
if (item < 1) return failed;
1329
uid = sfp->uids [item - 1];
1330
complexity = VECMODEL;
1332
bsp = StrucSynchronousQuery (uid, complexity, maxModels);
1333
if (bsp == NULL) return failed;
1336
pdnms = MakeAModelstruc (bsp);
1337
if (pdnms == NULL) return failed;
1340
fp = FileOpen (path, "w");
1342
WriteStructSummary (pdnms, fp);
1343
fprintf (fp, "\n\n\n");
1344
WritePDBRemarks (pdnms, fp);
1346
str = FileToString (path);
1349
FreeAModelstruc (pdnms);
1351
if (str == NULL) return failed;
1357
/*==================================================================*/
1359
/* FetchLocalBioseq () - */
1361
/*==================================================================*/
1363
static CharPtr FetchLocalBioseq (DoC d, Int2 item, Pointer ptr)
1368
Char path [PATH_MAX];
1373
/*--------------------------*/
1374
/* Check initial conditions */
1375
/*--------------------------*/
1377
sfp = (SummFormPtr) GetObjectExtra (d);
1378
failed = SetDefaultFailureMessage (sfp, item, NULL);
1379
if (sfp == NULL || sfp->simple == NULL || sfp->state == NULL) return failed;
1380
if (item < 1) return failed;
1381
ssp = sfp->simple [item - 1];
1382
if (ssp == NULL) return failed;
1385
fp = FileOpen (path, "w");
1387
if (SimpleSeqPrint (ssp, fp, TRUE)) {
1389
str = FileToString (path);
1395
if (str == NULL) return failed;
1401
/*==================================================================*/
1403
/* SetDocSumImportExportItems () - */
1405
/*==================================================================*/
1407
static void SetDocSumImportExportItems (SummFormPtr sfp)
1413
CharPtr PNTR labels = defaultRadios;
1414
Boolean lastChoiceIsUidList = FALSE;
1421
importItm = FindFormMenuItem ((BaseFormPtr) sfp, VIB_MSG_IMPORT);
1422
if (importItm != NULL)
1423
SafeSetTitle (importItm, "Import FASTA or Uid List...");
1425
exportItm = FindFormMenuItem ((BaseFormPtr) sfp, VIB_MSG_EXPORT);
1426
if (exportItm == NULL) return;
1428
sfp->label = medRadios [0];
1429
if (sfp->simple != NULL)
1430
sfp->label = localBioseqRadios [0];
1431
else if (sfp->currDb >= 0 && sfp->currDb < MAX_DBS) {
1432
dbName = DBGetNameFromID (sfp->currDb);
1433
if (StringICmp (dbName, "PubMed") == 0)
1435
else if (StringICmp (dbName, "Protein") == 0)
1437
else if (StringICmp (dbName, "Nucleotide") == 0)
1439
else if (StringICmp (dbName, "Structure") == 0)
1440
labels = strucRadios;
1441
else if (StringICmp (dbName, "Genome") == 0)
1443
else if (StringICmp (dbName, "Popset") == 0)
1444
labels = popsetRadios;
1445
else if (StringICmp (dbName, "OMIM") == 0)
1446
labels = omimRadios;
1447
else if (StringICmp (dbName, "Taxonomy") == 0)
1448
labels = taxonomyRadios;
1449
else if (StringICmp (dbName, "Books") == 0)
1450
labels = bookRadios;
1451
else if (StringICmp (dbName, "geo") == 0)
1452
labels = probeRadios;
1453
else if (StringICmp (dbName, "domains") == 0)
1454
labels = domainRadios;
1456
val = GetValue (sfp->formatPopups [sfp->currDb]);
1458
sfp->label = labels [val - 1];
1459
if (labels [val] == NULL)
1460
lastChoiceIsUidList = TRUE;
1463
StringCpy (tmp, "Export ");
1464
StringCat (tmp, sfp->label);
1465
if (lastChoiceIsUidList)
1466
StringCat (tmp, " List");
1467
StringCat (tmp, "...");
1468
SafeSetTitle (exportItm, tmp);
1471
/*==================================================================*/
1473
/* Query_FetchNeighbors() - Gets UIDs for the neighbors of all the */
1474
/* currently selected documents. */
1477
/* sfp->currDb -- The database to link FROM */
1478
/* sfp->neighborDb -- The database to link TO */
1479
/* sfp->uids -- The list of ALL the current */
1481
/* sfp->numUids -- Count of documents in sfp->uids */
1482
/* sfp->state [n].checked -- Flag to indicate which of the */
1483
/* documents in sfp->uids are */
1487
/* sfp->numNeighbors -- The number of neighbors found. */
1488
/* sfp->neighbors -- The uids of the neighbors. */
1490
/*==================================================================*/
1492
static Boolean Query_FetchNeighbors (SummFormPtr sfp, Int2 num)
1498
Entrez2RequestPtr e2RequestPtr;
1499
Entrez2ReplyPtr e2ReplyPtr;
1500
Entrez2LinkSetPtr e2LinksPtr;
1502
CharPtr targetDbName;
1503
Entrez2InfoPtr e2ip;
1504
Entrez2DbInfoPtr e2db;
1505
Entrez2LinkInfoPtr dbLinks;
1507
/*------------------*/
1508
/* Check conditions */
1509
/*------------------*/
1511
if (sfp == NULL) return FALSE;
1513
e2ip = Query_GetInfo ();
1514
if (e2ip == NULL) return FALSE;
1516
/*---------------------------------------*/
1517
/* Allocate memory for the selected UIDs */
1518
/*---------------------------------------*/
1520
uids = MemNew ((size_t) (num + 1) * sizeof (DocUid));
1521
if (uids == NULL) return FALSE;
1523
/*----------------------------------*/
1524
/* Determine the link type based on */
1525
/* the current (source) and the */
1527
/*----------------------------------*/
1529
currDbName = DBGetNameFromID (sfp->currDb);
1530
targetDbName = DBGetNameFromID (sfp->neighborDb);
1533
for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
1534
if (StringICmp (e2db->db_name, currDbName) == 0) {
1540
if (! found) return FALSE;
1543
for (dbLinks = e2db->links; dbLinks != NULL; dbLinks = dbLinks->next) {
1544
if (StringICmp (dbLinks->db_to, targetDbName) == 0) {
1550
if (! found) return FALSE;
1552
/*----------------------*/
1553
/* Get the uids for the */
1554
/* selected items. */
1555
/*----------------------*/
1558
for (i = 0; i < sfp->numUids; i++) {
1559
if (sfp->state [i].checked) {
1560
uids [num] = sfp->uids [i];
1565
/*----------------------------------------*/
1566
/* Create a link list request, send it to */
1567
/* the server, and parse the result. */
1568
/*----------------------------------------*/
1570
e2RequestPtr = EntrezCreateGetLinksRequest (currDbName, 0, num, uids, NULL, dbLinks->link_name, MAX_UIDS, FALSE, TRUE);
1571
if (e2RequestPtr == NULL) return FALSE;
1573
if (ShowASN () == TRUE)
1574
DisplayEntrezRequest (e2RequestPtr);
1576
if ((e2ReplyPtr = EntrezSynchronousQuery (e2RequestPtr)) == NULL)
1579
if (ShowASN () == TRUE)
1580
DisplayEntrezReply (e2ReplyPtr);
1582
if ((e2LinksPtr = EntrezExtractLinksReply (e2ReplyPtr)) == NULL) return FALSE;
1584
sfp->numNeighbors = (Int2) e2LinksPtr->ids->num;
1585
sfp->neighbors = (Int4Ptr) BSMerge (e2LinksPtr->ids->uids, NULL);
1587
/*----------------------------------*/
1588
/* Clean up and return successfully */
1589
/*----------------------------------*/
1595
/*==================================================================*/
1597
/* RecalculateDocSum () - */
1599
/*==================================================================*/
1601
static void RecalculateDocSum (SummFormPtr sfp)
1610
/*------------------*/
1611
/* Check conditions */
1612
/*------------------*/
1614
if (sfp == NULL) return;
1616
/*-------------------*/
1617
/* Get the target DB */
1618
/*-------------------*/
1620
if (GetEnumPopup (sfp->target, sfp->dbalist, &val)) {
1621
targetDb = (Int2) val;
1623
targetDb = sfp->currDb;
1626
/*-------------------------------------------*/
1627
/* If there's nothing to lookup, just return */
1628
/*-------------------------------------------*/
1630
if (sfp->uids == NULL || sfp->state == NULL) {
1631
if (targetDb == sfp->currDb)
1632
SafeSetTitle (sfp->retrieve, "Neighbor 0");
1634
SafeSetTitle (sfp->retrieve, "Lookup 0");
1635
SafeDisable (sfp->retrieve);
1639
sfp->neighbors = MemFree (sfp->neighbors);
1640
sfp->numNeighbors = 0;
1641
sfp->neighborDb = targetDb;
1643
/*----------------------------------*/
1644
/* FInd out how many, if any, items */
1646
/*----------------------------------*/
1649
for (i = 0; i < sfp->numUids; i++) {
1650
if (sfp->state [i].checked) {
1655
/*----------------------------------------*/
1656
/* Update the refine and retrieve buttons */
1657
/*----------------------------------------*/
1659
if (sfp->retrieveMode == EVAL_MODE && sfp->usingDelay) {
1661
if (targetDb == sfp->currDb)
1662
SafeSetTitle (sfp->retrieve, "Neighbor 0");
1664
SafeSetTitle (sfp->retrieve, "Lookup 0");
1665
SafeDisable (sfp->retrieve);
1667
SafeSetTitle (sfp->retrieve, "Evaluate");
1668
SafeEnable (sfp->retrieve);
1672
sprintf (title, "Refine %d", (int) num);
1673
SafeSetTitle (sfp->refine, title);
1675
SafeEnable (sfp->refine);
1677
SafeDisable (sfp->refine);
1681
/*------------------------------------------*/
1682
/* If there's any items to be queried, then */
1683
/* get a count and a list of UIDs for them. */
1684
/*------------------------------------------*/
1687
Query_FetchNeighbors (sfp, num);
1689
/*--------------------------*/
1690
/* Update the button labels */
1691
/*--------------------------*/
1693
if (targetDb == sfp->currDb)
1694
sprintf (title, "Neighbor %d", (int) sfp->numNeighbors);
1696
sprintf (title, "Lookup %d", (int) sfp->numNeighbors);
1698
SafeSetTitle (sfp->retrieve, title);
1699
if (sfp->numNeighbors > 0)
1700
SafeEnable (sfp->retrieve);
1702
SafeDisable (sfp->retrieve);
1706
sprintf (title, "Refine %d", (int) num);
1707
SafeSetTitle (sfp->refine, title);
1709
SafeEnable (sfp->refine);
1711
SafeDisable (sfp->refine);
1714
/*==================================================================*/
1716
/* RepopulateDocSum () - */
1718
/*==================================================================*/
1720
static DocPrntProc mlDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchAbstract, FetchCitation, FetchMedline, FetchUid, NULL };
1721
static DocPrntProc aaDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchGenPept, FetchFastaProt, FetchUid, NULL };
1722
static DocPrntProc ntDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchGenBank, FetchEmbl, FetchFastaNuc, FetchUid, NULL };
1723
static DocPrntProc stDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchPDB, FetchUid, NULL };
1724
static DocPrntProc chDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1725
static DocPrntProc popsetDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1726
static DocPrntProc omimDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1727
static DocPrntProc taxonomyDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1728
static DocPrntProc bookDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1729
static DocPrntProc probeDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1730
static DocPrntProc domainDocProcs [] = { Query_FetchDocSum, Query_FetchFields, FetchUid, NULL };
1732
static void RepopulateDocSum (SummFormPtr sfp, Boolean needToReset)
1742
MedlineViewProcsPtr mvpp;
1743
DocPrntProc retrieveProc;
1746
SeqViewProcsPtr svpp;
1749
/*------------------------*/
1750
/* Make sure that initial */
1751
/* conditions are valid */
1752
/*------------------------*/
1754
if (sfp == NULL) return;
1760
SafeHide (sfp->docsum);
1763
/*----------------*/
1764
/*----------------*/
1766
if (! GetScrlParams4 (sfp->docsum, NULL, &firstShown, &firstLine)) {
1770
sb = GetSlateVScrollBar ((SlatE) sfp->docsum);
1772
Reset (sfp->docsum);
1773
SetDocShade (sfp->docsum, NULL, NULL, NULL, NULL);
1774
SetDocCache (sfp->docsum, NULL, NULL, NULL);
1777
/*----------------*/
1778
/*----------------*/
1780
dbName = DBGetNameFromID (sfp->currDb);
1782
retrieveProc = Query_FetchDocSum;
1784
colFmt = docsumColFmt;
1786
font = sfp->docsumFont;
1788
if (sfp->simple != NULL) {
1789
retrieveProc = FetchLocalBioseq;
1791
colFmt = textColFmt;
1792
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
1793
if (svpp != NULL && svpp->displayFont != NULL)
1794
font = svpp->displayFont;
1797
else if (sfp->currDb >= 0 && sfp->currDb < MAX_DBS) {
1798
val = GetValue (sfp->formatPopups [sfp->currDb]);
1802
colFmt = textColFmt;
1804
if ((StringICmp (dbName, "PubMed") == 0) && (val == 5)) {
1805
mvpp = (MedlineViewProcsPtr)
1806
GetAppProperty ("MedlineDisplayForm");
1807
if (mvpp != NULL && mvpp->displayFont != NULL)
1808
font = mvpp->displayFont;
1809
} else if ((StringICmp (dbName, "Protein") == 0) || (StringICmp (dbName, "Nucleotide") == 0)) {
1810
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
1811
if (svpp != NULL && svpp->displayFont != NULL)
1812
font = svpp->displayFont;
1816
if (StringICmp (dbName, "PubMed") == 0)
1817
retrieveProc = mlDocProcs [val - 1];
1818
else if (StringICmp (dbName, "Protein") == 0)
1819
retrieveProc = aaDocProcs [val - 1];
1820
else if (StringICmp (dbName, "Nucleotide") == 0)
1821
retrieveProc = ntDocProcs [val - 1];
1822
else if (StringICmp (dbName, "Structure") == 0)
1823
retrieveProc = stDocProcs [val - 1];
1824
else if (StringICmp (dbName, "Genome") == 0)
1825
retrieveProc = chDocProcs [val - 1];
1826
else if (StringICmp (dbName, "Popset") == 0)
1827
retrieveProc = popsetDocProcs [val - 1];
1828
else if (StringICmp (dbName, "OMIM") == 0)
1829
retrieveProc = omimDocProcs [val - 1];
1830
else if (StringICmp (dbName, "Taxonomy") == 0)
1831
retrieveProc = taxonomyDocProcs [val - 1];
1832
else if (StringICmp (dbName, "Books") == 0)
1833
retrieveProc = bookDocProcs [val - 1];
1834
else if (StringICmp (dbName, "geo") == 0)
1835
retrieveProc = probeDocProcs [val - 1];
1836
else if (StringICmp (dbName, "domains") == 0)
1837
retrieveProc = domainDocProcs [val - 1];
1842
/*--------------------------------*/
1843
/* Retrieve the docs and put them */
1844
/* into the docsum window. */
1845
/*--------------------------------*/
1847
MemSet ((Pointer) sfp->formatted, 0, sizeof (Boolean) * (size_t) sfp->numUids);
1849
BulkAppendItem (sfp->docsum, sfp->numUids, retrieveProc, estLines, &docsumParFmt, colFmt, font);
1851
/*-------------------------------------*/
1852
/* Draw and display the document panel */
1853
/*-------------------------------------*/
1855
SetDocShade (sfp->docsum, ddp, NULL, NULL, NULL);
1856
SetDocCache (sfp->docsum, StdPutDocCache, StdGetDocCache, StdResetDocCache);
1858
AdjustDocScroll (sfp->docsum);
1859
GetItemParams4 (sfp->docsum, firstShown, &startsAt, NULL, NULL, NULL, NULL);
1860
CorrectBarValue (sb, startsAt + firstLine);
1862
SafeShow (sfp->docsum);
1867
/*==================================================================*/
1869
/* ChangeTarget () - */
1871
/*==================================================================*/
1873
static void ChangeTarget (PopuP p)
1878
sfp = (SummFormPtr) GetObjectExtra (p);
1879
if (sfp == NULL) return;
1880
sfp->retrieveMode = EVAL_MODE;
1881
RecalculateDocSum (sfp);
1884
/*==================================================================*/
1886
/* ChangeFormat () - */
1888
/*==================================================================*/
1890
static void ChangeFormat (PopuP p)
1895
sfp = (SummFormPtr) GetObjectExtra (p);
1896
if (sfp == NULL) return;
1897
RepopulateDocSum (sfp, TRUE);
1898
SetDocSumImportExportItems (sfp);
1901
/*==================================================================*/
1903
/* ResizeDocSumForm () - */
1905
/*==================================================================*/
1907
static void ResizeDocSumForm (WindoW w)
1921
sfp = (SummFormPtr) GetObjectExtra (w);
1922
if (sfp == NULL) return;
1925
width = r.right - r.left;
1926
height = r.bottom - r.top;
1927
GetPosition (sfp->docsum, &s);
1928
GetPosition (sfp->controls, &t);
1929
diff = t.bottom - t.top;
1930
gap = t.top - s.bottom;
1931
t.bottom = height - s.left;
1932
t.top = t.bottom - diff;
1933
s.right = width - s.left;
1934
s.bottom = t.top - gap;
1935
SafeHide (sfp->controls);
1936
SetPosition (sfp->controls, &t);
1937
AdjustPrnt (sfp->controls, &t, FALSE);
1938
SetPosition (sfp->docsum, &s);
1939
AdjustPrnt (sfp->docsum, &s, FALSE);
1940
ObjectRect (sfp->docsum, &s);
1941
InsetRect (&s, 4, 4);
1942
docsumColFmt [0].pixInset = 6 * stdCharWidth;
1943
remaining = s.right - s.left - 6 * stdCharWidth;
1944
quarter = remaining / 4;
1945
docsumColFmt [0].pixWidth = quarter + 6 * stdCharWidth;
1946
docsumColFmt [1].pixWidth = remaining - quarter;
1947
SafeShow (sfp->controls);
1948
RepopulateDocSum (sfp, TRUE);
1953
/*==================================================================*/
1955
/* CleanupEntrezDocSumForm () - */
1957
/*==================================================================*/
1959
static void CleanupEntrezDocSumForm (GraphiC g, VoidPtr data)
1965
sfp = (SummFormPtr) data;
1967
MemFree (sfp->uids);
1968
MemFree (sfp->formatted);
1969
if (sfp->simple != NULL) {
1970
for (j = 0; j < sfp->numUids; j++) {
1971
SimpleSeqFree (sfp->simple [j]);
1973
sfp->simple = MemFree (sfp->simple);
1975
MemFree (sfp->state);
1976
MemFree (sfp->neighbors);
1977
FileRemove (sfp->historyFile);
1978
MemFree (sfp->historyFile);
1979
MemFree (sfp->historyOffsets);
1980
if (sfp->dbalist != NULL) {
1981
for (j = 0; sfp->dbalist [j].name != NULL; j++) {
1982
MemFree (sfp->dbalist [j].name);
1985
MemFree (sfp->dbalist);
1986
Entrez2DocsumListFree (sfp->tempE2DLP);
1988
StdCleanupFormProc (g, data);
1991
/*==================================================================*/
1993
/* ClickDocSum () - */
1995
/*==================================================================*/
1997
static void ClickDocSum (DoC d, PoinT pt)
2005
sfp = (SummFormPtr) GetObjectExtra (d);
2006
if (sfp == NULL) return;
2007
MapDocPoint (d, pt, &item, &row, &col, NULL);
2008
sfp->dsClickItem = item;
2009
sfp->dsClickRow = row;
2010
sfp->dsClickCol = col;
2011
sfp->wasDoubleClick = dblClick;
2014
/*==================================================================*/
2016
/* GetCheckedUids () - */
2018
/*==================================================================*/
2020
static Int4Ptr GetCheckedUids (SummFormPtr sfp, Int2Ptr nump)
2027
if (sfp == NULL || nump == NULL) return NULL;
2030
for (i = 0; i < sfp->numUids; i++) {
2031
if (sfp->state [i].checked) {
2036
uids = MemNew ((size_t) (num + 1) * sizeof (DocUid));
2039
for (i = 0; i < sfp->numUids; i++) {
2040
if (sfp->state [i].checked) {
2041
uids [num] = sfp->uids [i];
2053
/*==================================================================*/
2055
/* LaunchMedlineViewer () - */
2057
/*==================================================================*/
2059
static void LaunchMedlineViewer (Int4 uid)
2070
pep = PubMedSynchronousQuery (uid);
2074
Message (MSG_OK, "Unable to find this record in the database.");
2077
datatype = OBJ_MEDLINE_ENTRY;
2078
dataptr = (Pointer) (MedlineEntryPtr) pep->medent;
2079
entityID = ObjMgrRegister (datatype, dataptr);
2080
if (dataptr == NULL || entityID == 0) {
2083
Message (MSG_OK, "Unable to find this record in the database.");
2086
handled = GatherProcLaunch (OMPROC_VIEW, FALSE, entityID, 1, OBJ_MEDLINE_ENTRY, 0, 0, OBJ_MEDLINE_ENTRY, 0);
2088
if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) {
2089
Message (MSG_ERROR, "Unable to launch viewer.");
2090
PubmedEntryFree (pep);
2092
ObjMgrSetOptions (OM_OPT_FREE_IF_NO_VIEW, entityID);
2096
/*==================================================================*/
2098
/* BioseqLockByGi () - */
2100
/*==================================================================*/
2102
static BioseqPtr BioseqLockByGi (Int4 uid)
2107
if (uid <= 0) return NULL;
2108
vn.choice = SEQID_GI;
2109
vn.data.intvalue = uid;
2110
return BioseqLockById (&vn);
2113
/*==================================================================*/
2115
/* AddBlastAlignment () - */
2117
/*==================================================================*/
2119
static void AddBlastAlignment (Int4 uid, Int2 numAlign, Int4Ptr alignuids, Uint2 entityID, SeqEntryPtr sep, BioseqPtr subject)
2122
Uint1 align_type = 0;
2127
BLAST_OptionsBlkPtr options = NULL;
2132
SeqAnnotPtr PNTR sapp;
2133
BlastSearchBlkPtr search;
2135
if (sep == NULL || numAlign == 0 || alignuids == NULL) return;
2138
if (subject == NULL)
2140
if (ISA_na (subject->mol)) {
2142
options = BLASTOptionNew ("blastn", TRUE);
2143
if (options != NULL) {
2144
options->gapped_calculation = TRUE;
2145
options->db_length = 100000000;
2147
options->wordsize = 10;
2149
options->wordsize = 12;
2152
} else if (ISA_aa (subject->mol)) {
2154
options = BLASTOptionNew ("blastp", TRUE);
2155
if (options != NULL) {
2156
options->gapped_calculation = TRUE;
2157
options->db_length = 20000000;
2158
options->threshold_second = 12;
2162
search = BLASTSetUpSearch (subject, options->program_name, 0, 0, NULL, options, NULL);
2164
for (i = 0; i < numAlign; i++) {
2165
if (alignuids [i] != uid) {
2166
query = BioseqLockByGi (alignuids [i]);
2167
if (query != NULL) {
2168
salp = BlastSequencesOnTheFly (search, query);
2169
BioseqUnlock (query);
2172
sap = SeqAnnotNew ();
2178
if (sap->data != NULL) {
2180
while (prev->next != NULL) {
2185
sap->data = (Pointer) salp;
2192
BLASTOptionDelete (options);
2193
BlastSearchBlkDestruct (search);
2195
if (sap == NULL) return;
2197
AddAlignInfoToSeqAnnot (sap, align_type);
2199
ObjMgrRegister (OBJ_SEQANNOT, (Pointer) sap);
2202
if (IS_Bioseq (sep)) {
2203
bsp = (BioseqPtr) sep->data.ptrvalue;
2204
sapp = &(bsp->annot);
2205
} else if (IS_Bioseq_set (sep)) {
2206
bssp = (BioseqSetPtr) sep->data.ptrvalue;
2207
sapp = &(bssp->annot);
2210
if (*sapp != NULL) {
2212
while (curr->next != NULL) {
2222
/*==================================================================*/
2224
/* LaunchSequenceViewer () - */
2226
/*==================================================================*/
2228
static void LaunchSequenceViewer (Int4 uid, Int2 numAlign, Int4Ptr alignuids, CharPtr dbName)
2232
Entrez2GlobalsPtr egp;
2236
SeqEntryPtr seqEntryPtr;
2241
seqEntryPtr = PubSeqSynchronousQuery (dbName, uid);
2242
if (seqEntryPtr == NULL) {
2245
Message (MSG_OK, "Unable to find this record in the database.");
2248
entityID = BioseqFindEntityByGi (uid, &itemID);
2249
if (entityID == 0 || itemID == 0) {
2250
SeqEntryFree (seqEntryPtr);
2256
MemSet ((Pointer) &vn, 0, sizeof (ValNode));
2257
vn.choice = SEQID_GI;
2258
vn.data.intvalue = uid;
2259
bsp = BioseqFind (&vn);
2263
Message (MSG_OK, "Unable to find this record in memory.");
2267
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
2271
if (GetStatus (egp->alignWithChecked)) {
2272
sep = GetTopSeqEntryForEntityID (entityID);
2273
AddBlastAlignment (uid, numAlign, alignuids, entityID, sep, bsp);
2277
handled = GatherProcLaunch (OMPROC_VIEW, FALSE, entityID, itemID, OBJ_BIOSEQ, 0, 0, OBJ_BIOSEQ, 0);
2279
if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) {
2280
Message (MSG_ERROR, "Unable to launch viewer.");
2281
SeqEntryFree (seqEntryPtr);
2283
ObjMgrSetOptions (OM_OPT_FREE_IF_NO_VIEW, entityID);
2287
/*==================================================================*/
2289
/* LaunchSequin () - */
2291
/*==================================================================*/
2293
static void LaunchSequin (Int4 uid, Int2 numAlign, Int4Ptr alignuids, CharPtr dbName)
2298
Entrez2GlobalsPtr egp;
2301
Char path [PATH_MAX];
2302
SeqEntryPtr seqEntryPtr;
2305
Char cmmd [PATH_MAX];
2310
seqEntryPtr = PubSeqSynchronousQuery (dbName, uid);
2311
if (seqEntryPtr == NULL) {
2314
Message (MSG_OK, "Unable to find this record in the database.");
2317
entityID = BioseqFindEntityByGi (uid, &itemID);
2318
if (entityID == 0 || itemID == 0) {
2319
SeqEntryFree (seqEntryPtr);
2325
MemSet ((Pointer) &vn, 0, sizeof (ValNode));
2326
vn.choice = SEQID_GI;
2327
vn.data.intvalue = uid;
2328
bsp = BioseqFind (&vn);
2332
Message (MSG_OK, "Unable to find this record in memory.");
2336
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
2340
if (GetStatus (egp->alignWithChecked)) {
2341
sep = GetTopSeqEntryForEntityID (entityID);
2342
AddBlastAlignment (uid, numAlign, alignuids, entityID, sep, bsp);
2347
aip = AsnIoOpen (path, "w");
2354
SeqEntryAsnWrite (seqEntryPtr, aip, NULL);
2358
Nlm_SendOpenDocAppleEvent (path, "SEQN");
2361
Nlm_MSWin_OpenApplication ("sequin.exe", path);
2364
sprintf (cmmd, "sequin -x < %s &", path);
2371
static Int4 GetBiostrucComplexity (void)
2374
Int4 complexity = ALLMDL;
2375
Entrez2GlobalsPtr egp;
2378
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
2379
if (egp == NULL) return complexity;
2380
val = GetValue (egp->strucComplex);
2383
complexity = ONECOORDATOM;
2386
complexity = ONECOORDRES;
2389
complexity = ALLMDL;
2392
complexity = VECMODEL;
2395
complexity = BSEVERYTHING;
2398
complexity = ONECOORDATOM;
2404
static Int4 GetBiostrucMaxModels (void)
2407
Entrez2GlobalsPtr egp;
2408
Int4 maxModels = INT4_MAX;
2411
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
2412
if (egp == NULL) return maxModels;
2413
val = GetValue (egp->strucModels);
2434
maxModels = MAX_MDLNO;
2443
static void LaunchStructureViewer (Int4 uid)
2447
Message (MSG_OK, "Structure views not supported on this platform.");
2450
BiostrucPtr biostrucPtr;
2455
Char path [PATH_MAX];
2459
Char cmmd [PATH_MAX];
2462
Char prog [PATH_MAX];
2467
complexity = GetBiostrucComplexity ();
2468
maxModels = GetBiostrucMaxModels ();
2469
biostrucPtr = StrucSynchronousQuery (uid, complexity, maxModels);
2470
if (biostrucPtr == NULL) {
2473
Message (MSG_OK, "Unable to find this record in the database.");
2478
aip = AsnIoOpen (path, "w");
2480
MemSet ((Pointer) &vn, 0, sizeof (ValNode));
2481
vn.choice = Data_data_structure;
2482
vn.data.ptrvalue = (Pointer) biostrucPtr;
2485
MemSet ((Pointer) &eg, 0, sizeof (EntrezGeneral));
2486
eg.style = Entrez_style_asn1;
2489
MemSet ((Pointer) &mime, 0, sizeof (NcbiMimeAsn1));
2490
mime.choice = NcbiMimeAsn1_entrez;
2491
mime.data.ptrvalue = ⪚
2494
NcbiMimeAsn1AsnWrite (&mime, aip, NULL);
2497
BiostrucFree (biostrucPtr);
2499
/* Cn3D expects Ncbi-mime-asn1, not Biostruc */
2502
Nlm_SendOpenDocAppleEvent (path, "Cn3D");
2505
Nlm_GetExecPath ("valfile", prog, sizeof (prog));
2506
Nlm_MSWin_OpenApplication (prog, path);
2512
if (! Execv ("Cn3D", argv)) {
2513
Message (MSG_POST, "Unable to launch Cn3D");
2516
sprintf (cmmd, "Cn3D %s &", path);
2524
/*==================================================================*/
2526
/* LaunchRecViewer () - */
2528
/*==================================================================*/
2530
NLM_EXTERN void LaunchRecViewer (ForM f, Int4 uid, Int2 numAlign, Int4Ptr alignuids, Int2 db, Int2 launchType)
2535
if (uid == 0) return;
2537
if (db >= 0 && db < MAX_DBS) {
2538
SeqEntrySetScope (NULL);
2539
dbName = DBGetNameFromID (db);
2540
if (StringICmp (dbName, "PubMed") == 0) {
2541
if (launchType == 1) {
2542
LaunchMedlineViewer (uid);
2543
} else if (launchType == 2) {
2544
LaunchEntrezURL ("PubMed", uid, "Abstract");
2546
} else if (StringICmp (dbName, "Protein") == 0) {
2547
if (launchType == 1) {
2548
LaunchSequenceViewer (uid, numAlign, alignuids, dbName);
2549
} else if (launchType == 2) {
2550
LaunchSequin (uid, numAlign, alignuids, dbName);
2551
} else if (launchType == 3) {
2552
LaunchEntrezURL ("Protein", uid, "GenPept");
2554
} else if (StringICmp (dbName, "Nucleotide") == 0) {
2555
if (launchType == 1) {
2556
LaunchSequenceViewer (uid, numAlign, alignuids, dbName);
2557
} else if (launchType == 2) {
2558
LaunchSequin (uid, numAlign, alignuids, dbName);
2559
} else if (launchType == 3) {
2560
LaunchEntrezURL ("Nucleotide", uid, "GenBank");
2562
} else if (StringICmp (dbName, "Structure") == 0) {
2563
if (launchType == 1) {
2564
LaunchStructureViewer (uid);
2565
} else if (launchType == 2) {
2566
LaunchEntrezURL ("Structure", uid, "DocSum");
2568
} else if (StringICmp (dbName, "Genome") == 0) {
2569
if (launchType == 1) {
2570
LaunchSequenceViewer (uid, numAlign, alignuids, "Nucleotide");
2571
} else if (launchType == 2) {
2572
LaunchSequin (uid, numAlign, alignuids, dbName);
2573
} else if (launchType == 3) {
2574
LaunchEntrezURL ("Genome", uid, "DocSum");
2576
} else if (StringICmp (dbName, "Popset") == 0) {
2577
if (launchType == 1) {
2578
LaunchSequenceViewer (uid, numAlign, alignuids, dbName);
2579
} else if (launchType == 2) {
2580
LaunchSequin (uid, numAlign, alignuids, dbName);
2581
} else if (launchType == 3) {
2582
LaunchEntrezURL ("Popset", uid, "DocSum");
2584
} else if (StringICmp (dbName, "OMIM") == 0) {
2585
if (launchType == 1) {
2586
LaunchEntrezURL ("OMIM", uid, "DocSum");
2588
} else if (StringICmp (dbName, "Taxonomy") == 0) {
2589
if (launchType == 1) {
2590
LaunchEntrezURL ("Taxonomy", uid, "DocSum");
2592
} else if (StringICmp (dbName, "Books") == 0) {
2593
if (launchType == 1) {
2594
LaunchEntrezURL ("Books", uid, "DocSum");
2596
} else if (StringICmp (dbName, "geo") == 0) {
2597
if (launchType == 1) {
2598
LaunchEntrezURL ("geo", uid, "DocSum");
2600
} else if (StringICmp (dbName, "domains") == 0) {
2601
if (launchType == 1) {
2602
LaunchEntrezURL ("domains", uid, "DocSum");
2608
/*==================================================================*/
2610
/* ReleaseDocSum () - */
2612
/*==================================================================*/
2614
static void ReleaseDocSum (DoC d, PoinT pt)
2629
sfp = (SummFormPtr) GetObjectExtra (d);
2630
if (sfp == NULL) return;
2631
MapDocPoint (d, pt, &item, &row, &col, &r);
2632
if (item < 1 || item > sfp->numUids || row == 0 || col == 0) return;
2633
if (sfp->dsClickItem != item) return;
2634
if (row == 1 && col == 1 && sfp->dsClickRow == 1 && sfp->dsClickCol == 1) {
2635
r.right = r.left + sfp->lineHeight;
2636
r.bottom = r.top + sfp->lineHeight;
2637
if (PtInRect (pt, &r)) {
2638
checked = sfp->state [item - 1].checked;
2639
sfp->state [item - 1].checked = (Boolean) (!checked);
2641
InsetRect (&r, 4, 4);
2642
r.right = r.left + sfp->lineHeight;
2643
InsetRect (&r, -1, -1);
2648
sfp->retrieveMode = EVAL_MODE;
2649
RecalculateDocSum (sfp);
2656
if (sfp->wasDoubleClick && sfp->uids != NULL && sfp->simple == NULL) {
2658
uid = sfp->uids [item - 1];
2659
uids = GetCheckedUids (sfp, &num);
2660
if (sfp->launchPopups != NULL) {
2661
val = GetValue (sfp->launchPopups [db]);
2662
LaunchRecViewer (sfp->form, uid, num, uids, db, val);
2666
LaunchRecViewer (sfp->form, uid, num, uids, db, 1);
2672
/*==================================================================*/
2674
/* RefineProc () - */
2676
/*==================================================================*/
2678
static int refinement = 0; /* Guarantees that each refinement has a unique name. */
2680
static void RefineProc (ButtoN b)
2689
/*--------------------------*/
2690
/* Check initial conditions */
2691
/*--------------------------*/
2693
sfp = (SummFormPtr) GetObjectExtra (b);
2694
if (sfp == NULL || sfp->refineUidProc == NULL) return;
2696
/*------------------------------*/
2697
/* Get a count of checked items */
2698
/*------------------------------*/
2701
for (i = 0; i < sfp->numUids; i++) {
2702
if (sfp->state [i].checked) {
2707
/*------------------------------------------*/
2708
/* If any items are checked, then use them, */
2709
/* otherwise use all the current UIDs. */
2710
/*------------------------------------------*/
2713
sprintf (str, "*generation_%d_refinement_%d", (int) sfp->present, (int) refinement);
2715
uids = MemNew ((size_t) (num + 1) * sizeof (DocUid));
2718
for (i = 0; i < sfp->numUids; i++) {
2719
if (sfp->state [i].checked) {
2720
uids [num] = sfp->uids [i];
2724
sfp->refineUidProc (sfp->form, str, num, uids, sfp->currDb);
2728
sfp->refineUidProc (sfp->form, str, sfp->numUids, sfp->uids, sfp->currDb);
2732
/*==================================================================*/
2734
/* UidInList () - */
2736
/*==================================================================*/
2738
static Boolean UidInList (Int4 uid, Int4Ptr sorted, Int2 num)
2747
if (sorted != NULL && num > 0) {
2751
while (left <= right) {
2752
mid = (left + right) / 2;
2753
if (uid <= sorted [mid]) {
2756
if (uid >= sorted [mid]) {
2760
if (left > right + 1) {
2767
/*==================================================================*/
2769
/* RetrieveNeighbors () - */
2771
/*==================================================================*/
2773
static void RetrieveNeighbors (ButtoN b)
2776
Entrez2GlobalsPtr egp;
2787
sfp = (SummFormPtr) GetObjectExtra (b);
2788
if (sfp == NULL) return;
2790
if (sfp->retrieveMode == EVAL_MODE && sfp->usingDelay) {
2793
sfp->retrieveMode = FETCH_MODE;
2794
RecalculateDocSum (sfp);
2800
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
2801
if (egp == NULL) return;
2804
if (sfp->currDb == sfp->neighborDb)
2805
persist = GetStatus (egp->parentsPersist);
2809
for (i = 0; i < sfp->numUids; i++) {
2810
if (sfp->state [i].checked) {
2818
num = parents + sfp->numNeighbors;
2821
uids = MemNew ((size_t) (num + 1) * sizeof (DocUid));
2822
sorted = MemNew ((size_t) (parents + 1) * sizeof (DocUid));
2823
if (uids != NULL && sorted != NULL) {
2825
if (persist && sfp->uids != NULL) {
2826
for (i = 0; i < sfp->numUids; i++) {
2827
if (sfp->state [i].checked) {
2828
uids [num] = sfp->uids [i];
2829
sorted [num] = sfp->uids [i];
2833
for (i = 1; i < parents; i++) {
2834
for (j = 0; j < i; j++) {
2835
if (sorted [j] > sorted [i]) {
2837
sorted [i] = sorted [j];
2843
if (sfp->neighbors != NULL) {
2844
for (i = 0; i < sfp->numNeighbors; i++) {
2845
if (!UidInList (sfp->neighbors [i], sorted, parents)) {
2846
uids [num] = sfp->neighbors [i];
2853
sfp->neighbors = NULL;
2854
sfp->numNeighbors = 0;
2855
dbName = DBGetNameFromID (sfp->neighborDb);
2856
RetrieveDocs (sfp->form, num, parents, uids, dbName);
2861
/*==================================================================*/
2863
/* EntrezDocSumFormActivate_Callback () = Called when the Document */
2864
/* summary window is made active. Mostly just calls the */
2865
/* function provided by the controlling program. */
2867
/*==================================================================*/
2869
static void EntrezDocSumFormActivate_Callback (WindoW w)
2874
sfp = (SummFormPtr) GetObjectExtra (w);
2876
if (sfp->activate != NULL)
2878
SetDocSumImportExportItems (sfp);
2882
/*==================================================================*/
2884
/* CopyDocsumToClipboard () - */
2886
/*==================================================================*/
2888
static void CopyDocsumToClipboard (BaseFormPtr bfp)
2895
Char path [PATH_MAX];
2898
sfp = (SummFormPtr) bfp;
2899
if (sfp == NULL) return;
2901
fp = FileOpen (path, "w");
2904
for (i = 0; i < sfp->numUids; i++) {
2905
if (sfp->state [i].checked) {
2910
SaveDocument (sfp->docsum, fp);
2913
for (i = 0; i < sfp->numUids; i++) {
2914
if (sfp->state [i].checked) {
2918
SaveDocumentItem (sfp->docsum, fp, i + 1);
2924
FileToClipboard (path);
2929
/*==================================================================*/
2931
/* PrintDocsumProc () - */
2933
/*==================================================================*/
2935
static void PrintDocsumProc (BaseFormPtr bfp)
2940
if (bfp == NULL) return;
2941
sfp = (SummFormPtr) bfp;
2944
PrintDocument (sfp->docsum);
2949
/*==================================================================*/
2951
/* SaveDocsumProject () - */
2953
/*==================================================================*/
2955
static Boolean SaveDocsumProject (BaseFormPtr bfp, Boolean saveAs)
2959
Char path [PATH_MAX];
2968
sfp = (SummFormPtr) bfp;
2970
StringNCpy_0 (path, bfp->filepath, sizeof (path));
2971
if (StringHasNoText (path) || saveAs) {
2972
if (!(GetOutputFileName (path, sizeof (path), "")))
2976
fp = FileOpen (path, "r");
2980
FileCreate (path, "TEXT", "ttxt");
2985
proj = (ProjectPtr) FormToPointer (bfp->form);
2989
Message (MSG_ERROR, "Unable to create project data.");
2992
aop = AsnIoOpen (path, "w");
2994
ProjectAsnWrite (proj, aop, NULL);
2997
bfp->filepath = MemFree (bfp->filepath);
2998
bfp->filepath = StringSave (path);
3005
Message (MSG_ERROR, "Unable to write file.");
3012
/*==================================================================*/
3014
/* ImportDocSumForm () - */
3016
/*==================================================================*/
3018
static Boolean ImportDocSumForm (ForM f, CharPtr filename)
3023
Entrez2GlobalsPtr egp;
3025
ValNodePtr head = NULL;
3026
Char path [PATH_MAX];
3032
StringNCpy_0 (path, filename, sizeof (path));
3033
sfp = (SummFormPtr) GetObjectExtra (f);
3035
if (path [0] != '\0' || GetInputFileName (path, sizeof (path), "", "TEXT")) {
3036
fp = FileOpen (path, "r");
3038
while ((dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE, TRUE, TRUE)) != NULL)
3039
ValNodeAddPointer (&head, datatype, dataptr);
3041
simples = ValNodeExtractList (&head, OBJ_FASTA);
3042
if (simples != NULL) {
3043
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
3044
if (egp != NULL && egp->retrieveSimpleProc != NULL)
3045
egp->retrieveSimpleProc (NULL, simples);
3047
ValNodeFree (simples);
3049
for (vnp = head; vnp != NULL; vnp = vnp->next) {
3050
datatype = vnp->choice;
3051
dataptr = vnp->data.ptrvalue;
3063
/*==================================================================*/
3065
/* ExportDocSumForm () - */
3067
/*==================================================================*/
3069
static Boolean ExportDocSumForm (ForM f, CharPtr filename)
3075
CharPtr PNTR labels = defaultRadios;
3076
Boolean lastChoiceIsUidList = FALSE;
3080
Char path [PATH_MAX];
3085
/*----------------------*/
3086
/* Get SummFormPtr info */
3087
/*----------------------*/
3089
sfp = (SummFormPtr) GetObjectExtra (f);
3091
if (sfp == NULL) return FALSE;
3093
/*--------------------------------*/
3094
/* If no filename was passed, get */
3095
/* one from the user. */
3096
/*--------------------------------*/
3099
StringNCpy_0 (path, filename, sizeof (path));
3101
if (path [0] == '\0' && !GetOutputFileName (path, sizeof (path), NULL)) return FALSE;
3103
/*------------------------------------------*/
3104
/* On the Mac force the file to get created */
3105
/* with the desired attributes. */
3106
/*------------------------------------------*/
3109
fp = FileOpen (path, "r");
3113
FileCreate (path, "TEXT", "ttxt");
3116
/*---------------------------*/
3117
/* Open the file for writing */
3118
/*---------------------------*/
3120
fp = FileOpen (path, "w");
3122
Message (MSG_ERROR, "Unable to write file.");
3126
/*---------------------------------------------*/
3127
/* Indicate 'working' state by changing cursor */
3128
/*---------------------------------------------*/
3133
/*---------------------------------*/
3134
/* Determine whether or not we are */
3135
/* currently in UID display mode. */
3136
/*---------------------------------*/
3138
if (sfp->simple != NULL) {
3139
} else if (sfp->currDb >= 0 && sfp->currDb < MAX_DBS) {
3140
dbName = DBGetNameFromID (sfp->currDb);
3141
if (StringICmp (dbName, "PubMed") == 0)
3143
else if (StringICmp (dbName, "Protein") == 0)
3145
else if (StringICmp (dbName, "Nucleotide") == 0)
3147
else if (StringICmp (dbName, "Structure") == 0)
3148
labels = strucRadios;
3149
else if (StringICmp (dbName, "Genome") == 0)
3151
else if (StringICmp (dbName, "PopSet") == 0)
3152
labels = popsetRadios;
3153
else if (StringICmp (dbName, "OMIM") == 0)
3154
labels = omimRadios;
3155
else if (StringICmp (dbName, "Taxonomy") == 0)
3156
labels = taxonomyRadios;
3157
else if (StringICmp (dbName, "Books") == 0)
3158
labels = bookRadios;
3159
else if (StringICmp (dbName, "geo") == 0)
3160
labels = probeRadios;
3161
else if (StringICmp (dbName, "domains") == 0)
3162
labels = domainRadios;
3164
val = GetValue (sfp->formatPopups [sfp->currDb]);
3166
if (labels [val] == NULL)
3167
lastChoiceIsUidList = TRUE;
3170
/*-----------------------------*/
3171
/* If we're writing a UID list */
3172
/* then get a header for it. */
3173
/*-----------------------------*/
3175
if (lastChoiceIsUidList) {
3176
switch (sfp->currDb) {
3178
fprintf (fp, ">PubMed\n");
3181
fprintf (fp, ">Protein\n");
3184
fprintf (fp, ">Nucleotide\n");
3187
fprintf (fp, ">Structure\n");
3190
fprintf (fp, ">Genome\n");
3193
fprintf (fp, ">Popset\n");
3196
fprintf (fp, ">OMIM\n");
3199
fprintf (fp, ">Taxonomy\n");
3202
fprintf (fp, ">Books\n");
3205
fprintf (fp, ">Probes\n");
3208
fprintf (fp, ">Domains\n");
3211
fprintf (fp, ">?\n");
3216
/*-----------------------------*/
3217
/* Determine how many (if any) */
3218
/* items have been checked. */
3219
/*-----------------------------*/
3222
for (i = 0; i < sfp->numUids; i++) {
3223
if (sfp->state [i].checked) {
3228
/*------------------------------*/
3229
/* Write to the file either the */
3230
/* or the document summaries. */
3231
/*------------------------------*/
3233
if (lastChoiceIsUidList) {
3235
for (i = 0; i < sfp->numUids; i++) {
3236
sprintf (str, "%ld\n", (long) (sfp->uids [i]));
3240
for (i = 0; i < sfp->numUids; i++) {
3241
if (sfp->state [i].checked) {
3242
sprintf (str, "%ld\n", (long) (sfp->uids [i]));
3248
mon = MonitorIntNewEx ("Saving Documents", 0, sfp->numUids, FALSE);
3250
for (i = 0; i < sfp->numUids; i++) {
3251
if (num == 0 || sfp->state [i].checked) {
3254
SaveDocumentItem (sfp->docsum, fp, i + 1);
3255
MonitorIntValue (mon, i);
3262
/*----------------------------------*/
3263
/* Clean up and return successfully */
3264
/*----------------------------------*/
3267
sfp->filepath = MemFree (sfp->filepath);
3268
sfp->filepath = StringSave (path);
3275
/*================================================================*/
3277
/* EntrezDocSumFormMessage_Callback () = This function is set up */
3278
/* to receive the messages generated by menu items that are */
3279
/* created with FormCommandItem(). */
3281
/*================================================================*/
3283
static void EntrezDocSumFormMessage_Callback (ForM f, Int2 mssg)
3287
Entrez2GlobalsPtr egp;
3290
bfp = (BaseFormPtr) GetObjectExtra (f);
3293
case VIB_MSG_REDRAW:
3294
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
3296
sfp = (SummFormPtr) bfp;
3297
sfp->docsumFont = egp->docsumFont;
3298
RepopulateDocSum (sfp, TRUE);
3302
CopyDocsumToClipboard (bfp);
3304
case VIB_MSG_IMPORT:
3305
ImportDocSumForm (f, NULL);
3307
case VIB_MSG_EXPORT:
3308
ExportDocSumForm (f, NULL);
3311
PrintDocsumProc (bfp);
3313
case VIB_MSG_SAVE_AS:
3314
SaveDocsumProject (bfp, TRUE);
3317
if (bfp->appmessage != NULL) {
3318
bfp->appmessage (f, mssg);
3325
/*==================================================================*/
3327
/* RefreshAndRecalculateDocSum () - */
3329
/*==================================================================*/
3331
static void RefreshAndRecalculateDocSum (SummFormPtr sfp)
3336
if (sfp == NULL) return;
3337
Select (sfp->docsum);
3338
ObjectRect (sfp->docsum, &r);
3339
InsetRect (&r, 4, 4);
3340
r.right = r.left + sfp->lineHeight;
3341
InsetRect (&r, -1, -1);
3346
sfp->retrieveMode = EVAL_MODE;
3347
RecalculateDocSum (sfp);
3352
/*==================================================================*/
3354
/* SelectAllProc () - */
3356
/*==================================================================*/
3358
static void SelectAllProc (ButtoN b)
3364
sfp = (SummFormPtr) GetObjectExtra (b);
3365
if (sfp == NULL) return;
3366
for (i = 0; i < sfp->numUids; i++) {
3367
sfp->state [i].checked = TRUE;
3369
RefreshAndRecalculateDocSum (sfp);
3372
/*==================================================================*/
3374
/* SelectParentsProc () - */
3376
/*==================================================================*/
3378
static void SelectParentsProc (ButtoN b)
3384
sfp = (SummFormPtr) GetObjectExtra (b);
3385
if (sfp == NULL) return;
3386
for (i = 0; i < sfp->numUids; i++) {
3387
sfp->state [i].checked = (Boolean) (i < sfp->numParents);
3389
RefreshAndRecalculateDocSum (sfp);
3392
/*==================================================================*/
3394
/* ClearAllProcs () - */
3396
/*==================================================================*/
3398
static void ClearAllProc (ButtoN b)
3404
sfp = (SummFormPtr) GetObjectExtra (b);
3405
if (sfp == NULL) return;
3406
for (i = 0; i < sfp->numUids; i++) {
3407
sfp->state [i].checked = FALSE;
3409
RefreshAndRecalculateDocSum (sfp);
3412
/*==================================================================*/
3414
/* SetPrevAndNextButtons () - */
3416
/*==================================================================*/
3418
static void SetPrevAndNextButtons (SummFormPtr sfp)
3421
if (sfp->present > 1)
3422
SafeEnable (sfp->prevBtn);
3424
SafeDisable (sfp->prevBtn);
3426
if (sfp->present < sfp->generations)
3427
SafeEnable (sfp->nextBtn);
3429
SafeDisable (sfp->nextBtn);
3432
/*==================================================================*/
3434
/* RetrieveGeneration () - */
3436
/*==================================================================*/
3438
static void RetrieveGeneration (SummFormPtr sfp, Int2 num, Int2 parents, Int4Ptr uids, Int2 db)
3441
Entrez2InfoPtr e2ip;
3445
if (sfp == NULL || uids == NULL) return;
3447
/*----------------------------------*/
3448
/* Get information on the databases */
3449
/*----------------------------------*/
3451
e2ip = Query_GetInfo ();
3453
/*------------------------------*/
3454
/* Initialize the DocSum window */
3455
/*------------------------------*/
3457
Reset (sfp->docsum);
3458
SetDocShade (sfp->docsum, NULL, NULL, NULL, NULL);
3459
SetDocCache (sfp->docsum, NULL, NULL, NULL);
3460
sfp->uids = MemFree (sfp->uids);
3461
sfp->formatted = MemFree (sfp->formatted);
3462
if (sfp->simple != NULL) {
3463
for (i = 0; i < sfp->numUids; i++) {
3464
SimpleSeqFree (sfp->simple [i]);
3466
sfp->simple = MemFree (sfp->simple);
3468
sfp->state = MemFree (sfp->state);
3470
sfp->numParents = 0;
3471
sfp->neighbors = MemFree (sfp->neighbors);
3472
sfp->numNeighbors = 0;
3473
SafeSetTitle (sfp->retrieve, "Neighbor 0");
3474
SafeDisable (sfp->retrieve);
3475
sprintf (title, "Refine %d", (int) num);
3476
SafeSetTitle (sfp->refine, title);
3478
SafeEnable (sfp->refine);
3480
SafeDisable (sfp->refine);
3481
SetEnumPopup (sfp->target, sfp->dbalist, (UIEnum) db);
3482
SafeShow (sfp->target);
3483
SetPrevAndNextButtons (sfp);
3486
/*-----------------------------------*/
3487
/* Select the proper DB radio button */
3488
/*-----------------------------------*/
3490
Hide (sfp->formatPopups [MAX_DBS]);
3491
Hide (sfp->launchPopups [MAX_DBS]);
3492
for (i = 0; i < MAX_DBS; i++) {
3493
if (i != db && sfp->formatPopups [i] != NULL)
3494
SafeHide (sfp->formatPopups [i]);
3495
if (i != db && sfp->launchPopups [i] != NULL)
3496
SafeHide (sfp->launchPopups [i]);
3500
Show (sfp->formatPopups [db]);
3501
Show (sfp->launchPopups [db]);
3504
/*------------------------------------*/
3505
/* Load the documents into the window */
3506
/*------------------------------------*/
3509
sfp->uids = MemDup ((Pointer) uids, (size_t) ((num + 1) * sizeof (DocUid)));
3510
if (sfp->uids == NULL) return;
3511
sfp->state = MemNew (sizeof (DocSumStateData) * (size_t) (num + 1));
3512
if (sfp->state == NULL) return;
3513
sfp->formatted = MemNew (sizeof (Boolean) * (size_t) (num + 1));
3514
if (sfp->formatted == NULL) return;
3516
sfp->numParents = parents;
3520
RepopulateDocSum (sfp, FALSE);
3521
SetDocSumImportExportItems (sfp);
3522
SendMessageToForm (sfp->form, VIB_MSG_CHANGE);
3524
if (sfp->activate != NULL)
3525
sfp->activate ((WindoW) sfp->form);
3531
if (sfp->activate != NULL)
3532
sfp->activate ((WindoW) sfp->form);
3538
/*==================================================================*/
3540
/* LoadPresentGeneration () */
3542
/*==================================================================*/
3544
static void LoadPresentGeneration (SummFormPtr sfp)
3553
if (sfp == NULL) return;
3556
if (sfp->historyFile != NULL && sfp->historyOffsets != NULL) {
3557
fp = FileOpen (sfp->historyFile, "rb");
3559
fseek (fp, sfp->historyOffsets [(sfp->present) % 100], SEEK_SET);
3560
FileRead (&db, sizeof (db), 1, fp);
3561
FileRead (&num, sizeof (num), 1, fp);
3562
FileRead (&parents, sizeof (parents), 1, fp);
3563
uids = (Int4Ptr) MemNew ((size_t) num * sizeof (Int4) + 4);
3565
FileRead (uids, sizeof (Int4), (size_t) num, fp);
3568
RetrieveGeneration (sfp, num, parents, uids, db);
3576
/*==================================================================*/
3578
/* RetrieveDocs () */
3580
/*==================================================================*/
3582
NLM_EXTERN void RetrieveDocs (ForM f, Int2 num, Int2 parents, Int4Ptr uids, CharPtr dbName)
3587
Char path [PATH_MAX];
3591
/*--------------------------*/
3592
/* Check initial conditions */
3593
/*--------------------------*/
3595
if ((sfp = (SummFormPtr) GetObjectExtra (f)) == NULL) return;
3597
if (uids == NULL) return;
3599
db = DBGetIDFromName (dbName);
3601
/*--------------------------*/
3602
/* Increment the generation */
3603
/*--------------------------*/
3605
(sfp->generations)++;
3606
sfp->present = sfp->generations;
3608
/*---------------------------------*/
3609
/* Open the history file, creating */
3611
/*---------------------------------*/
3613
if (sfp->historyFile == NULL) {
3615
sfp->historyFile = StringSave (path);
3617
if (sfp->historyFile != NULL)
3618
FileCreate (sfp->historyFile, "????", "ENTZ");
3622
/*------------------------------*/
3623
/* Write the current generation */
3624
/* to the history file. */
3625
/*------------------------------*/
3627
if (sfp->historyOffsets == NULL)
3628
sfp->historyOffsets = MemNew (100 * sizeof (Int4));
3630
if (sfp->historyFile != NULL && sfp->historyOffsets != NULL) {
3631
fp = FileOpen (sfp->historyFile, "ab");
3633
fseek (fp, 0, SEEK_END);
3634
sfp->historyOffsets [(sfp->present) % 100] = ftell (fp);
3636
FileWrite (&val, sizeof (val), 1, fp);
3638
FileWrite (&val, sizeof (val), 1, fp);
3640
FileWrite (&val, sizeof (val), 1, fp);
3641
FileWrite (uids, sizeof (Int4), (size_t) num, fp);
3644
sfp->historyOffsets [sfp->present % 100] = 0;
3647
/*--------------------------------*/
3648
/* Get the new document summaries */
3649
/*--------------------------------*/
3651
RetrieveGeneration (sfp, num, parents, uids, db);
3654
/*==================================================================*/
3656
/* PrevButton_Callback () - */
3658
/*==================================================================*/
3660
static void PrevButton_Callback (ButtoN b)
3665
sfp = (SummFormPtr) GetObjectExtra (b);
3666
if (sfp == NULL) return;
3669
if (sfp->present < 1)
3672
SetPrevAndNextButtons (sfp);
3673
LoadPresentGeneration (sfp);
3674
SetDocSumImportExportItems (sfp);
3677
/*==================================================================*/
3679
/* NextButton_Callback () - */
3681
/*==================================================================*/
3683
static void NextButton_Callback (ButtoN b)
3688
sfp = (SummFormPtr) GetObjectExtra (b);
3689
if (sfp == NULL) return;
3692
if (sfp->present > sfp->generations)
3693
sfp->present = sfp->generations;
3695
SetPrevAndNextButtons (sfp);
3696
LoadPresentGeneration (sfp);
3697
SetDocSumImportExportItems (sfp);
3700
/*==================================================================*/
3702
/* NeighborDelayProc () - */
3704
/*==================================================================*/
3706
static void NeighborDelayProc (ChoicE c)
3711
sfp = (SummFormPtr) GetObjectExtra (c);
3714
sfp = (SummFormPtr) currentFormDataPtr;
3717
if (sfp == NULL) return;
3718
if (GetValue (c) == 1) {
3719
sfp->usingDelay = FALSE;
3721
sfp->usingDelay = TRUE;
3725
/*==================================================================*/
3727
/* CreateNeighborDelayChoice () - */
3729
/*==================================================================*/
3731
static ChoicE CreateNeighborDelayChoice (MenU m, BaseFormPtr bfp)
3737
sfp = (SummFormPtr) bfp;
3739
c = ChoiceGroup (m, NeighborDelayProc);
3740
SetObjectExtra (c, bfp, NULL);
3741
ChoiceItem (c, "Immediate");
3742
ChoiceItem (c, "Delayed");
3743
if (sfp->usingDelay == TRUE)
3751
/*==================================================================*/
3753
/* LoadDocsumOptionsMenu () - */
3755
/*==================================================================*/
3757
static void LoadDocsumOptionsMenu (MenU m)
3760
Entrez2GlobalsPtr egp;
3763
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
3764
if (egp == NULL) return;
3765
egp->parentsPersist = StatusItem (m, "Parents Persist", NULL);
3766
SetStatus (egp->parentsPersist, egp->persistDefault);
3767
egp->alignWithChecked = StatusItem (m, "Align Checked Items", NULL);
3768
SetStatus (egp->alignWithChecked, egp->alignDefault);
3770
sub = SubMenu (m, "Structure Complexity");
3771
egp->strucComplex = ChoiceGroup (sub, NULL);
3772
ChoiceItem (egp->strucComplex, "NCBI one XYZ per atom model");
3773
ChoiceItem (egp->strucComplex, "NCBI backbone model");
3774
ChoiceItem (egp->strucComplex, "Original PDB models 1-n");
3775
ChoiceItem (egp->strucComplex, "NCBI vector model");
3776
ChoiceItem (egp->strucComplex, "Everything");
3777
SetValue (egp->strucComplex, 1);
3778
sub = SubMenu (m, "Number of Models");
3779
egp->strucModels = ChoiceGroup (sub, NULL);
3780
ChoiceItem (egp->strucModels, "1");
3781
ChoiceItem (egp->strucModels, "2");
3782
ChoiceItem (egp->strucModels, "5");
3783
ChoiceItem (egp->strucModels, "10");
3784
ChoiceItem (egp->strucModels, "15");
3785
ChoiceItem (egp->strucModels, "20");
3786
ChoiceItem (egp->strucModels, "maximum");
3787
SetValue (egp->strucModels, 7);
3790
/*==================================================================*/
3792
/* DocSumFontChangeProc () - */
3794
/*==================================================================*/
3796
static void DocSumFontChangeProc (IteM i)
3800
Entrez2GlobalsPtr egp;
3804
Char str [FONT_NAME_SIZE + 10];
3806
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
3808
bfp = GetObjectExtra (i);
3811
bfp = currentFormDataPtr;
3815
MemSet ((Pointer) (&fs), 0, sizeof (FontSpec));
3817
if (egp != NULL && egp->docsumFont != NULL)
3818
fnt = egp->docsumFont;
3827
if (GetFontSpec (fnt, &fs)) {
3828
flags = CFF_READ_FSP;
3830
if (ChooseFont (&fs, flags, NULL)) {
3831
sprintf (str, "%s,%d", fs.name, (int) fs.size);
3832
if ((fs.style & STYLE_BOLD) != 0 || (fs.style & STYLE_ITALIC) != 0 || (fs.style & STYLE_UNDERLINE) != 0) {
3833
StringCat (str, ",");
3834
if ((fs.style & STYLE_BOLD) != 0) {
3835
StringCat (str, "b");
3837
if ((fs.style & STYLE_ITALIC) != 0) {
3838
StringCat (str, "i");
3840
if ((fs.style & STYLE_UNDERLINE) != 0) {
3841
StringCat (str, "u");
3845
egp->docsumFont = CreateFont (&fs);
3846
SendMessageToForm (bfp->form, VIB_MSG_REDRAW);
3851
/*==================================================================*/
3853
/* DisplayFontChangeProc () - */
3855
/*==================================================================*/
3857
static void DisplayFontChangeProc (IteM i)
3864
MedlineViewProcsPtr mvpp;
3865
Char str [FONT_NAME_SIZE + 10];
3866
SeqViewProcsPtr svpp;
3868
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
3869
mvpp = (MedlineViewProcsPtr) GetAppProperty ("MedlineDisplayForm");
3871
bfp = GetObjectExtra (i);
3874
bfp = currentFormDataPtr;
3878
MemSet ((Pointer) (&fs), 0, sizeof (FontSpec));
3880
if (svpp != NULL && svpp->displayFont != NULL) {
3881
fnt = svpp->displayFont;
3882
} else if (mvpp != NULL && mvpp->displayFont != NULL) {
3883
fnt = mvpp->displayFont;
3892
if (GetFontSpec (fnt, &fs)) {
3893
flags = CFF_READ_FSP | CFF_MONOSPACE;
3895
if (ChooseFont (&fs, flags, NULL)) {
3896
sprintf (str, "%s,%d", fs.name, (int) fs.size);
3897
if ((fs.style & STYLE_BOLD) != 0 || (fs.style & STYLE_ITALIC) != 0 || (fs.style & STYLE_UNDERLINE) != 0) {
3898
StringCat (str, ",");
3899
if ((fs.style & STYLE_BOLD) != 0) {
3900
StringCat (str, "b");
3902
if ((fs.style & STYLE_ITALIC) != 0) {
3903
StringCat (str, "i");
3905
if ((fs.style & STYLE_UNDERLINE) != 0) {
3906
StringCat (str, "u");
3911
svpp->displayFont = CreateFont (&fs);
3914
mvpp->displayFont = CreateFont (&fs);
3916
SendMessageToForm (bfp->form, VIB_MSG_REDRAW);
3921
/*==================================================================*/
3923
/* DuplicateViewProc () - */
3925
/*==================================================================*/
3927
static void DuplicateViewProc (IteM i)
3934
bfp = GetObjectExtra (i);
3937
bfp = currentFormDataPtr;
3940
if (bfp == NULL) return;
3941
if (bfp->input_itemtype == OBJ_BIOSEQ) {
3943
itemID = bfp->input_itemID;
3947
handled = GatherProcLaunch (OMPROC_VIEW, FALSE, bfp->input_entityID, itemID, OBJ_BIOSEQ, 0, 0, OBJ_BIOSEQ, 0);
3949
if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) {
3950
Message (MSG_ERROR, "Unable to launch additional viewer.");
3952
} else if (bfp->input_itemtype == OBJ_MEDLINE_ENTRY) {
3954
itemID = bfp->input_itemID;
3958
handled = GatherProcLaunch (OMPROC_VIEW, FALSE, bfp->input_entityID, itemID, OBJ_MEDLINE_ENTRY, 0, 0, OBJ_MEDLINE_ENTRY, 0);
3960
if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) {
3961
Message (MSG_ERROR, "Unable to launch additional viewer.");
3966
/*==================================================================*/
3968
/* CloseProc () - */
3970
/*==================================================================*/
3972
static void CloseProc (BaseFormPtr bfp)
3979
ObjMgrDataPtr PNTR omdpp;
3980
OMUserDataPtr omudp;
3986
for (j = 0, omdpp = omp->datalist; j < num && omdpp != NULL; j++, omdpp++) {
3988
if (tmp->parentptr == NULL && tmp->dirty && tmp->EntityID == bfp->input_entityID) {
3990
for (omudp = tmp->userdata; omudp != NULL; omudp = omudp->next) {
3991
if (omudp->proctype == OMPROC_VIEW)
3995
if (Message (MSG_OKC, "Closing the window will lose unsaved data.")
4001
for (j = 0, omdpp = omp->datalist; j < num && omdpp != NULL; j++, omdpp++) {
4003
if (tmp->parentptr == NULL)
4004
for (omudp = tmp->userdata; omudp != NULL; omudp = omudp->next)
4005
if (omudp->proctype == OMPROC_VIEW)
4013
Message (MSG_OK, "No more viewers present.");
4021
/*==================================================================*/
4023
/* MedlineViewFormMessage_Callback () - */
4025
/*==================================================================*/
4027
static void MedlineViewFormMessage_Callback (ForM f, Int2 mssg)
4032
bfp = (BaseFormPtr) GetObjectExtra (f);
4044
/*==================================================================*/
4046
/* BioseqViewFormMessage_Callback () - */
4048
/*==================================================================*/
4050
static void BioseqViewFormMessage_Callback (ForM f, Int2 mssg)
4055
bfp = (BaseFormPtr) GetObjectExtra (f);
4067
/*==================================================================*/
4069
/* MedlineViewFormMenus_Callback () - */
4071
/*==================================================================*/
4073
static void MedlineViewFormMenus_Callback (WindoW w)
4080
bfp = (BaseFormPtr) GetObjectExtra (w);
4082
m = PulldownMenu (w, "File");
4083
FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
4085
i = CommandItem (m, "Duplicate View", DuplicateViewProc);
4086
SetObjectExtra (i, bfp, NULL);
4088
FormCommandItem (m, "Export...", bfp, VIB_MSG_EXPORT);
4090
FormCommandItem (m, "Print...", bfp, VIB_MSG_PRINT);
4092
m = PulldownMenu (w, "Edit");
4093
FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
4097
/*==================================================================*/
4099
/* BioseqViewFormMenus_Callback () - */
4101
/*==================================================================*/
4103
static void BioseqViewFormMenus_Callback (WindoW w)
4111
bfp = (BaseFormPtr) GetObjectExtra (w);
4113
m = PulldownMenu (w, "File");
4114
FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
4116
i = CommandItem (m, "Duplicate View", DuplicateViewProc);
4117
SetObjectExtra (i, bfp, NULL);
4119
FormCommandItem (m, "Export...", bfp, VIB_MSG_EXPORT);
4121
FormCommandItem (m, "Print...", bfp, VIB_MSG_PRINT);
4123
m = PulldownMenu (w, "Edit");
4124
FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
4126
m = PulldownMenu (w, "Misc");
4127
sub = SubMenu (m, "Font Selection");
4128
i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
4129
SetObjectExtra (i, bfp, NULL);
4131
CreateLegendItem (m, bfp);
4135
/*==================================================================*/
4137
/* SetupMenus () - Create and initialize the pulldown menus. */
4139
/*==================================================================*/
4141
static void SetupMenus (WindoW w)
4150
bfp = (BaseFormPtr) GetObjectExtra (w);
4152
m = PulldownMenu (w, "File");
4153
FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
4155
FormCommandItem (m, "Import...", bfp, VIB_MSG_IMPORT);
4156
FormCommandItem (m, "Export...", bfp, VIB_MSG_EXPORT);
4158
FormCommandItem (m, "Print...", bfp, VIB_MSG_PRINT);
4160
m = PulldownMenu (w, "Edit");
4161
FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
4163
m = PulldownMenu (w, "Options");
4164
CommandItem (m, "Preferences...", Entrez2PrefsProc);
4166
sub = SubMenu (m, "Neighbor Policy");
4168
c = CreateNeighborDelayChoice (sub, bfp);
4170
LoadDocsumOptionsMenu (m);
4172
m = PulldownMenu (w, "Misc");
4173
sub = SubMenu (m, "Font Selection");
4174
i = CommandItem (sub, "DocSum Font...", DocSumFontChangeProc);
4175
SetObjectExtra (i, bfp, NULL);
4176
i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
4177
SetObjectExtra (i, bfp, NULL);
4181
/*==================================================================*/
4183
/* CreateDocsumForm () - */
4185
/*==================================================================*/
4187
NLM_EXTERN ForM CreateDocsumForm (
4191
WndActnProc activate,
4192
FormMessageFunc messages,
4193
E2NamedUidListProc refineUidCallback,
4194
Boolean delayedNeighbor
4199
Entrez2GlobalsPtr egp;
4200
Entrez2InfoPtr e2ip;
4201
Entrez2DbInfoPtr e2db;
4206
CharPtr PNTR labels = defaultRadios;
4208
PrompT queryPrompt, launchPrompt, ppt1, ppt2;
4219
SeqViewProcsPtr svpp;
4220
MedlineViewProcsPtr mvpp;
4222
/*---------------------------------------*/
4223
/* Make connection to the Entrez2 server */
4224
/*---------------------------------------*/
4226
e2ip = Query_GetInfo ();
4227
if (e2ip == NULL) return NULL;
4229
/*----------------------------*/
4230
/* Get global config settings */
4231
/*----------------------------*/
4233
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
4234
if (egp == NULL) return NULL;
4235
macLike = egp->popdownBehavior;
4237
/*----------------------------------*/
4238
/* Set up callbacks for SeqView and */
4239
/* MedlineView menus. */
4240
/*----------------------------------*/
4242
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
4243
/* create menus in window now also on Mac */
4244
svpp->createMenus = BioseqViewFormMenus_Callback;
4245
svpp->handleMessages = BioseqViewFormMessage_Callback;
4247
mvpp = (MedlineViewProcsPtr) GetAppProperty ("MedlineDisplayForm");
4248
/* create menus in window now also on Mac */
4249
mvpp->createMenus = MedlineViewFormMenus_Callback;
4250
mvpp->handleMessages = MedlineViewFormMessage_Callback;
4252
/*----------------------------------*/
4253
/* Create a data structure to store */
4254
/* data that we want to associate */
4255
/* with the Document Summary window */
4256
/*----------------------------------*/
4258
sfp = (SummFormPtr) MemNew (sizeof (SummFormData));
4259
if (sfp == NULL) return (ForM) w;
4261
/*------------------------------------*/
4262
/* Create the document summary window */
4263
/*------------------------------------*/
4265
w = DocumentWindow (-50, -33, -10, -10, title, StdSendCloseWindowMessageProc, ResizeDocSumForm);
4267
/*-------------------------------*/
4268
/* Set window callback functions */
4269
/* and misc attributes. */
4270
/*-------------------------------*/
4272
SetObjectExtra (w, sfp, CleanupEntrezDocSumForm);
4273
sfp->form = (ForM) w;
4274
sfp->formmessage = EntrezDocSumFormMessage_Callback;
4275
sfp->appmessage = messages;
4277
sfp->activate = activate;
4278
SetActivate (w, EntrezDocSumFormActivate_Callback);
4280
sfp->docsumFont = egp->docsumFont;
4282
if (sfp->docsumFont == NULL)
4283
sfp->docsumFont = programFont;
4285
sfp->refineUidProc = refineUidCallback;
4286
sfp->usingDelay = delayedNeighbor;
4288
/*-----------------------------------*/
4289
/* Set up the document summary menus */
4290
/*-----------------------------------*/
4294
/*---------------------------------*/
4295
/* Set up the Format radio buttons */
4296
/*---------------------------------*/
4298
for (j = 0; j < MAX_DBS; j++) {
4299
sfp->formatPopups [j] = NULL;
4300
sfp->launchPopups [j] = NULL;
4303
h = HiddenGroup (w, -1, 0, NULL);
4304
k = HiddenGroup (h, 4, 0, NULL);
4305
queryPrompt = StaticPrompt (k, "Format:", 0, 0, programFont, 'l');
4306
q = HiddenGroup (k, 0, 0, NULL);
4308
for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
4309
if (StringICmp (e2db->db_name, "PubMed") == 0)
4311
else if (StringICmp (e2db->db_name, "Protein") == 0)
4313
else if (StringICmp (e2db->db_name, "Nucleotide") == 0)
4315
else if (StringICmp (e2db->db_name, "Structure") == 0)
4316
labels = strucRadios;
4317
else if (StringICmp (e2db->db_name, "Genome") == 0)
4319
else if (StringICmp (e2db->db_name, "Popset") == 0)
4320
labels = popsetRadios;
4321
else if (StringICmp (e2db->db_name, "OMIM") == 0)
4322
labels = omimRadios;
4323
else if (StringICmp (e2db->db_name, "Taxonomy") == 0)
4324
labels = taxonomyRadios;
4325
else if (StringICmp (e2db->db_name, "Books") == 0)
4326
labels = bookRadios;
4327
else if (StringICmp (e2db->db_name, "geo") == 0)
4328
labels = probeRadios;
4329
else if (StringICmp (e2db->db_name, "domains") == 0)
4330
labels = domainRadios;
4332
dbKey = DBGetIDFromName (e2db->db_name);
4334
sfp->formatPopups [dbKey] = PopupList (q, TRUE, ChangeFormat);
4335
SetObjectExtra (sfp->formatPopups [dbKey], sfp, NULL);
4336
for (j = 0; labels [j] != NULL; j++)
4337
PopupItem (sfp->formatPopups [dbKey], labels [j]);
4338
SetValue (sfp->formatPopups [dbKey], 1);
4339
Hide (sfp->formatPopups [dbKey]);
4342
launchPrompt = StaticPrompt (k, "Double Click:", 0, 0, programFont, 'l');
4343
q = HiddenGroup (k, 0, 0, NULL);
4346
for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
4347
if (StringICmp (e2db->db_name, "PubMed") == 0)
4349
else if (StringICmp (e2db->db_name, "Protein") == 0)
4351
else if (StringICmp (e2db->db_name, "Nucleotide") == 0)
4353
else if (StringICmp (e2db->db_name, "Structure") == 0)
4354
labels = strucLaunch;
4355
else if (StringICmp (e2db->db_name, "Genome") == 0)
4357
else if (StringICmp (e2db->db_name, "Popset") == 0)
4358
labels = popsetLaunch;
4359
else if (StringICmp (e2db->db_name, "OMIM") == 0)
4360
labels = omimLaunch;
4361
else if (StringICmp (e2db->db_name, "Taxonomy") == 0)
4362
labels = taxonomyLaunch;
4363
else if (StringICmp (e2db->db_name, "Books") == 0)
4364
labels = bookLaunch;
4365
else if (StringICmp (e2db->db_name, "geo") == 0)
4366
labels = probeLaunch;
4367
else if (StringICmp (e2db->db_name, "domains") == 0)
4368
labels = domainLaunch;
4370
dbKey = DBGetIDFromName (e2db->db_name);
4372
sfp->launchPopups [dbKey] = PopupList (q, TRUE, NULL);
4373
SetObjectExtra (sfp->launchPopups [dbKey], sfp, NULL);
4374
for (j = 0; labels [j] != NULL; j++) {
4375
PopupItem (sfp->launchPopups [dbKey], labels [j]);
4377
SetValue (sfp->launchPopups [dbKey], 1);
4378
Hide (sfp->launchPopups [dbKey]);
4381
sfp->label = medRadios [0];
4382
AlignObjects (ALIGN_MIDDLE, (HANDLE) queryPrompt, (HANDLE) launchPrompt, (HANDLE) q, NULL);
4383
g = HiddenGroup (h, -1, 0, NULL);
4384
SetGroupSpacing (g, 5, 5);
4386
/*---------------------------*/
4387
/* Set up the document panel */
4388
/*---------------------------*/
4390
sfp->docsum = DocumentPanel (g, 32 * stdCharWidth, 20 * stdLineHeight);
4391
SetObjectExtra (sfp->docsum, sfp, NULL);
4392
SetDocProcs (sfp->docsum, ClickDocSum, NULL, ReleaseDocSum, NULL);
4393
SetDocCache (sfp->docsum, NULL, NULL, NULL);
4396
sfp->controls = HiddenGroup (g, 5, 0, NULL);
4397
SetGroupSpacing (sfp->controls, 10, 10);
4399
/*----------------------------------------*/
4400
/* Create the Neighbor and Refine buttons */
4401
/*----------------------------------------*/
4403
x = HiddenGroup (sfp->controls, 0, 2, NULL);
4404
sfp->retrieve = PushButton (x, "Neighbor 00000", RetrieveNeighbors);
4405
SetObjectExtra (sfp->retrieve, sfp, NULL);
4406
SetTitle (sfp->retrieve, "Neighbor 0");
4407
Disable (sfp->retrieve);
4408
sfp->refine = PushButton (x, "Refine 0000", RefineProc);
4409
SetObjectExtra (sfp->refine, sfp, NULL);
4410
SetTitle (sfp->refine, "Refine");
4411
Disable (sfp->refine);
4412
sfp->retrieveMode = FETCH_MODE;
4414
sfp->neighbors = NULL;
4415
sfp->numNeighbors = 0;
4417
sfp->historyFile = NULL;
4418
sfp->historyOffsets = NULL;
4419
sfp->generations = 0;
4422
x = HiddenGroup (sfp->controls, 0, -3, NULL);
4423
SetGroupMargins (x, 3, 0);
4424
SetGroupSpacing (x, 3, 5);
4426
/*-------------------------------------*/
4427
/* Create a pulldown list of databases */
4428
/*-------------------------------------*/
4430
sfp->dbalist = CreateDatabaseAlist (e2ip);
4432
y = HiddenGroup (x, 5, 0, NULL);
4433
ppt1 = StaticPrompt (y, "Target:", 0, popupMenuHeight, programFont, 'l');
4434
sfp->target = PopupList (y, macLike, ChangeTarget);
4435
SetObjectExtra (sfp->target, sfp, NULL);
4436
InitEnumPopup (sfp->target, sfp->dbalist, NULL);
4438
typ_ml = DBGetIDFromName ("PubMed");
4439
SetEnumPopup (sfp->target, sfp->dbalist, (UIEnum) typ_ml);
4441
/*--------------------------*/
4442
/* Create selection buttons */
4443
/*--------------------------*/
4445
y = HiddenGroup (x, 4, 0, NULL);
4446
SetGroupSpacing (y, 8, 0);
4447
ppt2 = StaticPrompt (y, "Select:", 0, 0, programFont, 'l');
4449
b1 = PushButton (y, "All", SelectAllProc);
4450
SetObjectExtra (b1, sfp, NULL);
4451
b2 = PushButton (y, "None", ClearAllProc);
4452
SetObjectExtra (b2, sfp, NULL);
4453
b3 = PushButton (y, "Parents", SelectParentsProc);
4454
SetObjectExtra (b3, sfp, NULL);
4456
/*----------------------------------*/
4457
/* Set up Previous and Next buttons */
4458
/*----------------------------------*/
4460
x = HiddenGroup (sfp->controls, 0, 2, NULL);
4462
sfp->prevBtn = PushButton (x, "Prev", PrevButton_Callback);
4463
SetObjectExtra (sfp->prevBtn, sfp, NULL);
4464
Disable (sfp->prevBtn);
4465
sfp->nextBtn = PushButton (x, "Next", NextButton_Callback);
4466
SetObjectExtra (sfp->nextBtn, sfp, NULL);
4467
Disable (sfp->nextBtn);
4469
/*------------------------------------------*/
4470
/* Align the objects properly in the window */
4471
/*------------------------------------------*/
4473
AlignObjects (ALIGN_MIDDLE, (HANDLE) sfp->retrieve, (HANDLE) ppt1, (HANDLE) sfp->target, (HANDLE) sfp->prevBtn, NULL);
4474
AlignObjects (ALIGN_MIDDLE, (HANDLE) sfp->refine, (HANDLE) ppt2, (HANDLE) b1, (HANDLE) b2, (HANDLE) b3, (HANDLE) sfp->nextBtn, NULL);
4476
/*---------------------------------*/
4477
/* Calculate the size of the icons */
4478
/*---------------------------------*/
4482
SelectFont (programFont);
4483
sfp->lineHeight = LineHeight ();
4484
SelectFont (systemFont);
4485
sfp->linesPerIcon = (22 + sfp->lineHeight - 1) / sfp->lineHeight;
4486
docsumParFmt.minLines = sfp->linesPerIcon;
4491
ObjectRect (sfp->docsum, &r);
4492
InsetRect (&r, 4, 4);
4493
docsumColFmt [0].pixInset = 6 * stdCharWidth;
4494
remaining = r.right - r.left - 6 * stdCharWidth;
4495
quarter = remaining / 4;
4496
docsumColFmt [0].pixWidth = quarter + 6 * stdCharWidth;
4497
docsumColFmt [1].pixWidth = remaining - quarter;
4498
textColFmt [0].pixInset = 3 * stdCharWidth;
4499
textColFmt [0].pixWidth = screenRect.right - screenRect.left;
4501
SetDocAutoAdjust (sfp->docsum, FALSE);
4503
/*---------------------*/
4504
/* Return successfully */
4505
/*---------------------*/
4511
static ENUM_ALIST(all_mode_alist)
4521
static ENUM_ALIST(med_views_alist)
4529
typedef struct entrezprefs {
4530
Boolean persistDefault;
4531
Boolean alignDefault;
4532
Boolean lookupDirect;
4534
CharPtr initDatabase;
4537
CharPtr initMedLabel;
4538
CharPtr initNucLabel;
4539
CharPtr initProtLabel;
4540
CharPtr initGenomeLabel;
4542
Int2 minPixelHeight;
4543
} EntrezPrefs, PNTR EntrezPrefsPtr;
4545
typedef struct prefspage {
4546
DIALOG_MESSAGE_BLOCK ButtoN persist;
4559
EnumFieldAssocPtr dbalist;
4560
EnumFieldAssocPtr fldalist;
4561
EnumFieldAssocPtr nucalist;
4562
EnumFieldAssocPtr protalist;
4563
EnumFieldAssocPtr gnomalist;
4564
} PrefsPage, PNTR PrefsPagePtr;
4566
typedef struct prefsform {
4567
FORM_MESSAGE_BLOCK DialoG prefs;
4568
} PrefsForm, PNTR PrefsFormPtr;
4571
/*==================================================================*/
4573
/* ReplaceString () - */
4575
/*==================================================================*/
4577
static void ReplaceString (CharPtr PNTR target, CharPtr newstr)
4580
if (target == NULL) return;
4582
*target = StringSaveNoNull (newstr);
4585
/*==================================================================*/
4587
/* EntrezPrefsNew () - */
4589
/*==================================================================*/
4591
static EntrezPrefsPtr EntrezPrefsNew (void)
4596
epp = (EntrezPrefsPtr) MemNew (sizeof (EntrezPrefs));
4600
/*==================================================================*/
4602
/* EntrezPrefsFree () - */
4604
/*==================================================================*/
4606
static EntrezPrefsPtr EntrezPrefsFree (EntrezPrefsPtr epp)
4609
if (epp == NULL) return NULL;
4610
epp->initDatabase = MemFree (epp->initDatabase);
4611
epp->initField = MemFree (epp->initField);
4612
epp->initMode = MemFree (epp->initMode);
4613
epp->initMedLabel = MemFree (epp->initMedLabel);
4614
epp->initNucLabel = MemFree (epp->initNucLabel);
4615
epp->initProtLabel = MemFree (epp->initProtLabel);
4616
epp->initGenomeLabel = MemFree (epp->initGenomeLabel);
4620
/*==================================================================*/
4622
/* DefaultMessageProc () - */
4624
/*==================================================================*/
4626
static void DefaultMessageProc (ForM f, Int2 mssg)
4629
StdEditorProcsPtr sepp;
4631
sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
4633
if (sepp->handleMessages != NULL)
4634
sepp->handleMessages (f, mssg);
4637
/*==================================================================*/
4639
/* AcceptPrefsProc () - */
4641
/*==================================================================*/
4643
static void AcceptPrefsProc (ButtoN b)
4648
Entrez2GlobalsPtr egp;
4649
MedlineViewProcsPtr mvpp;
4650
SeqViewProcsPtr svpp;
4652
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
4653
if (svpp == NULL) return;
4655
mvpp = (MedlineViewProcsPtr) GetAppProperty ("MedlineDisplayForm");
4656
if (mvpp == NULL) return;
4658
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
4659
if (egp == NULL) return;
4661
pfp = (PrefsFormPtr) GetObjectExtra (b);
4662
if (pfp == NULL) return;
4665
epp = (EntrezPrefsPtr) DialogToPointer (pfp->prefs);
4667
egp->persistDefault = epp->persistDefault;
4668
egp->alignDefault = epp->alignDefault;
4669
egp->lookupDirect = epp->lookupDirect;
4670
egp->showAsn = epp->showAsn;
4671
ReplaceString (&(egp->initDatabase), epp->initDatabase);
4672
ReplaceString (&(egp->initField), epp->initField);
4673
ReplaceString (&(egp->initMode), epp->initMode);
4674
ReplaceString (&(mvpp->initMedLabel), epp->initMedLabel);
4675
ReplaceString (&(svpp->initNucLabel), epp->initNucLabel);
4676
ReplaceString (&(svpp->initProtLabel), epp->initProtLabel);
4677
ReplaceString (&(svpp->initGenomeLabel), epp->initGenomeLabel);
4678
SetAppParam ("ENTREZ", "PREFERENCES", "PARENTSPERSIST", egp->persistDefault ? "TRUE" : "FALSE");
4679
SetAppParam ("ENTREZ", "PREFERENCES", "ALIGNCHECKED", egp->alignDefault ? "TRUE" : "FALSE");
4680
SetAppParam ("ENTREZ", "PREFERENCES", "LOOKUPDIRECT", egp->lookupDirect ? "TRUE" : "FALSE");
4681
SetAppParam ("ENTREZ", "PREFERENCES", "SHOWASNPAGE", egp->showAsn ? "TRUE" : "FALSE");
4682
SetAppParam ("ENTREZ", "SETTINGS", "DATABASE", egp->initDatabase);
4683
SetAppParam ("ENTREZ", "SETTINGS", "FIELD", egp->initField);
4684
SetAppParam ("ENTREZ", "SETTINGS", "MODE", egp->initMode);
4685
SetAppParam ("ENTREZ", "SETTINGS", "MEDPAGE", mvpp->initMedLabel);
4686
SetAppParam ("ENTREZ", "SETTINGS", "NUCPAGE", svpp->initNucLabel);
4687
SetAppParam ("ENTREZ", "SETTINGS", "PRTPAGE", svpp->initProtLabel);
4688
SetAppParam ("ENTREZ", "SETTINGS", "GENMPAGE", svpp->initGenomeLabel);
4690
EntrezPrefsFree (epp);
4694
/*==================================================================*/
4696
/* PrefsPtrToPrefsPage () - */
4698
/*==================================================================*/
4700
static void PrefsPtrToPrefsPage (DialoG d, Pointer data)
4706
ppp = (PrefsPagePtr) GetObjectExtra (d);
4707
if (ppp == NULL) return;
4708
epp = (EntrezPrefsPtr) data;
4710
SetStatus (ppp->persist, epp->persistDefault);
4711
SetStatus (ppp->align, epp->alignDefault);
4712
if (epp->lookupDirect) {
4713
SetValue (ppp->lookup, 2);
4715
SetValue (ppp->lookup, 1);
4717
SetStatus (ppp->showAsn, epp->showAsn);
4718
SetEnumPopupByName (ppp->initDb, ppp->dbalist, epp->initDatabase);
4719
SetEnumPopupByName (ppp->initFld, ppp->fldalist, epp->initField);
4720
SetEnumPopupByName (ppp->initMode, all_mode_alist, epp->initMode);
4721
SetEnumPopupByName (ppp->initMed, med_views_alist, epp->initMedLabel);
4722
SetEnumPopupByName (ppp->initNuc, ppp->nucalist, epp->initNucLabel);
4723
SetEnumPopupByName (ppp->initProt, ppp->protalist, epp->initProtLabel);
4724
SetEnumPopupByName (ppp->initGenome, ppp->gnomalist, epp->initGenomeLabel);
4726
SetStatus (ppp->persist, TRUE);
4727
SetStatus (ppp->align, TRUE);
4728
SetValue (ppp->lookup, 1);
4729
SetStatus (ppp->showAsn, FALSE);
4730
SetEnumPopupByName (ppp->initDb, ppp->dbalist, "PubMed");
4731
SetEnumPopupByName (ppp->initFld, ppp->fldalist, "All Fields");
4732
SetEnumPopupByName (ppp->initMode, all_mode_alist, "Automatic");
4733
SetEnumPopupByName (ppp->initMed, med_views_alist, "Abstract");
4734
SetEnumPopupByName (ppp->initNuc, ppp->nucalist, "GenBank");
4735
SetEnumPopupByName (ppp->initProt, ppp->protalist, "GenPept");
4736
SetEnumPopupByName (ppp->initGenome, ppp->gnomalist, "Map");
4740
/*==================================================================*/
4742
/* PrefsPageToPrefsPtr () - */
4744
/*==================================================================*/
4746
static Pointer PrefsPageToPrefsPtr (DialoG d)
4752
ppp = (PrefsPagePtr) GetObjectExtra (d);
4753
if (ppp == NULL) return NULL;
4754
epp = (EntrezPrefsPtr) MemNew (sizeof (EntrezPrefs));
4755
if (epp == NULL) return NULL;
4756
epp->persistDefault = GetStatus (ppp->persist);
4757
epp->alignDefault = GetStatus (ppp->align);
4758
epp->lookupDirect = (GetValue (ppp->lookup) == 2);
4759
epp->showAsn = GetStatus (ppp->showAsn);
4760
epp->initDatabase = GetEnumPopupByName (ppp->initDb, ppp->dbalist);
4761
epp->initField = GetEnumPopupByName (ppp->initFld, ppp->fldalist);
4762
epp->initMode = GetEnumPopupByName (ppp->initMode, all_mode_alist);
4763
epp->initMedLabel = GetEnumPopupByName (ppp->initMed, med_views_alist);
4764
epp->initNucLabel = GetEnumPopupByName (ppp->initNuc, ppp->nucalist);
4765
epp->initProtLabel = GetEnumPopupByName (ppp->initProt, ppp->protalist);
4766
epp->initGenomeLabel = GetEnumPopupByName (ppp->initGenome, ppp->gnomalist);
4767
return (Pointer) epp;
4770
/*==================================================================*/
4772
/* MakePageSpecAlist () - */
4774
/*==================================================================*/
4776
static EnumFieldAssocPtr MakePageSpecAlist (SeqViewProcsPtr svpp, Boolean nucOK, Boolean protOK, Boolean genomeOK)
4779
EnumFieldAssocPtr alist;
4780
EnumFieldAssocPtr ap;
4784
if (svpp == NULL) return NULL;
4785
bpp = svpp->pageSpecs;
4787
while (bpp != NULL) {
4791
alist = MemNew (sizeof (EnumFieldAssoc) * (i + 2));
4792
if (alist == NULL) return NULL;
4794
bpp = svpp->pageSpecs;
4796
while (bpp != NULL) {
4797
if ((nucOK && bpp->nucOK) || (protOK && bpp->protOK) || (genomeOK && bpp->genomeOK)) {
4798
ap->name = StringSave (bpp->label);
4809
/*==================================================================*/
4811
/* CleanupEntrezPrefsProc () - */
4813
/*==================================================================*/
4815
static void CleanupEntrezPrefsProc (GraphiC g, VoidPtr data)
4820
ppp = (PrefsPagePtr) data;
4822
ppp->dbalist = FreeEnumFieldAlist (ppp->dbalist);
4823
ppp->fldalist = FreeEnumFieldAlist (ppp->fldalist);
4824
ppp->nucalist = FreeEnumFieldAlist (ppp->nucalist);
4825
ppp->protalist = FreeEnumFieldAlist (ppp->protalist);
4826
ppp->gnomalist = FreeEnumFieldAlist (ppp->gnomalist);
4828
StdCleanupExtraProc (g, data);
4831
/*==================================================================*/
4833
/* CreateEntrezPrefsDialog () - */
4835
/*==================================================================*/
4837
static DialoG CreateEntrezPrefsDialog (GrouP prnt, CharPtr title)
4840
Entrez2GlobalsPtr egp;
4841
Entrez2InfoPtr e2ip;
4842
GrouP g1, g2, g3, g4, g5;
4847
SeqViewProcsPtr svpp;
4849
p = HiddenGroup (prnt, 1, 0, NULL);
4850
SetGroupSpacing (p, 10, 10);
4852
e2ip = Query_GetInfo ();
4853
if (e2ip == NULL) return NULL;
4855
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
4856
if (egp == NULL) return (DialoG) p;
4857
macLike = egp->popdownBehavior;
4859
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
4860
if (svpp == NULL) return (DialoG) p;
4862
ppp = (PrefsPagePtr) MemNew (sizeof (PrefsPage));
4864
SetObjectExtra (p, ppp, CleanupEntrezPrefsProc);
4865
ppp->dialog = (DialoG) p;
4866
ppp->todialog = PrefsPtrToPrefsPage;
4867
ppp->fromdialog = PrefsPageToPrefsPtr;
4869
ppp->dbalist = CreateDatabaseAlist (e2ip);
4870
ppp->fldalist = CreateFieldAlist (e2ip->db_info);
4872
ppp->nucalist = MakePageSpecAlist (svpp, TRUE, FALSE, FALSE);
4873
ppp->protalist = MakePageSpecAlist (svpp, FALSE, TRUE, FALSE);
4874
ppp->gnomalist = MakePageSpecAlist (svpp, FALSE, FALSE, TRUE);
4876
if (title != NULL && title [0] != '\0')
4877
s = NormalGroup (p, -1, 0, title, systemFont, NULL);
4879
s = HiddenGroup (p, -1, 0, NULL);
4880
SetGroupSpacing (s, 10, 10);
4882
g1 = HiddenGroup (s, -1, 0, NULL);
4883
g5 = HiddenGroup (g1, 3, 0, NULL);
4884
SetGroupSpacing (g5, 10, 3);
4885
ppp->persist = CheckBox (g5, "Parents Persist", NULL);
4886
ppp->align = CheckBox (g5, "Align Checked", NULL);
4887
ppp->showAsn = CheckBox (g5, "Show ASN.1 Report", NULL);
4888
g2 = HiddenGroup (g1, 2, 0, NULL);
4889
StaticPrompt (g2, "Lookup Mode Launches", 0, stdLineHeight, programFont, 'l');
4890
ppp->lookup = HiddenGroup (g2, 2, 0, NULL);
4891
RadioButton (ppp->lookup, "DocSum");
4892
RadioButton (ppp->lookup, "Record");
4893
AlignObjects (ALIGN_CENTER, (HANDLE) g2, (HANDLE) g5, NULL);
4895
g3 = HiddenGroup (s, 0, 2, NULL);
4897
StaticPrompt (g3, "Database", 0, 0, programFont, 'l');
4898
ppp->initDb = PopupList (g3, macLike, NULL);
4899
InitEnumPopup (ppp->initDb, ppp->dbalist, NULL);
4900
SetEnumPopupByName (ppp->initDb, ppp->dbalist, "PubMed");
4902
StaticPrompt (g3, "Field", 0, 0, programFont, 'l');
4903
ppp->initFld = PopupList (g3, macLike, NULL);
4904
InitEnumPopup (ppp->initFld, ppp->fldalist, NULL);
4905
SetEnumPopupByName (ppp->initFld, ppp->fldalist, "All Fields");
4907
StaticPrompt (g3, "Mode", 0, 0, programFont, 'l');
4908
ppp->initMode = PopupList (g3, macLike, NULL);
4909
InitEnumPopup (ppp->initMode, all_mode_alist, NULL);
4910
SetEnumPopupByName (ppp->initMode, all_mode_alist, "Automatic");
4912
g4 = HiddenGroup (s, 0, 2, NULL);
4914
StaticPrompt (g4, "PubMed", 0, 0, programFont, 'l');
4915
ppp->initMed = PopupList (g4, macLike, NULL);
4916
InitEnumPopup (ppp->initMed, med_views_alist, NULL);
4917
SetEnumPopupByName (ppp->initMed, med_views_alist, "Abstract");
4919
StaticPrompt (g4, "Nucleotide", 0, 0, programFont, 'l');
4920
ppp->initNuc = PopupList (g4, macLike, NULL);
4921
InitEnumPopup (ppp->initNuc, ppp->nucalist, NULL);
4922
SetEnumPopupByName (ppp->initNuc, ppp->nucalist, "GenBank");
4924
StaticPrompt (g4, "Protein", 0, 0, programFont, 'l');
4925
ppp->initProt = PopupList (g4, macLike, NULL);
4926
InitEnumPopup (ppp->initProt, ppp->protalist, NULL);
4927
SetEnumPopupByName (ppp->initProt, ppp->protalist, "GenPept");
4929
StaticPrompt (g4, "Genome", 0, 0, programFont, 'l');
4930
ppp->initGenome = PopupList (g4, macLike, NULL);
4931
InitEnumPopup (ppp->initGenome, ppp->gnomalist, NULL);
4932
SetEnumPopupByName (ppp->initGenome, ppp->gnomalist, "Map");
4934
AlignObjects (ALIGN_CENTER, (HANDLE) g1, (HANDLE) g3, (HANDLE) g4, NULL);
4940
/*==================================================================*/
4942
/* Entrez2PrefsProc () - */
4944
/*==================================================================*/
4946
void Entrez2PrefsProc (IteM i)
4953
MedlineViewProcsPtr mvpp;
4956
Entrez2GlobalsPtr egp;
4957
SeqViewProcsPtr svpp;
4959
svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
4960
mvpp = (MedlineViewProcsPtr) GetAppProperty ("MedlineDisplayForm");
4961
egp = (Entrez2GlobalsPtr) GetAppProperty ("Entrez2Globals");
4962
pfp = (PrefsFormPtr) MemNew (sizeof (PrefsForm));
4963
if (pfp == NULL) return;
4964
w = FixedWindow (-50, -33, -10, -10, "Preferences", StdCloseWindowProc);
4965
SetObjectExtra (w, pfp, StdCleanupFormProc);
4966
pfp->form = (ForM) w;
4967
pfp->formmessage = DefaultMessageProc;
4968
g = HiddenGroup (w, -1, 0, NULL);
4969
SetGroupSpacing (g, 10, 10);
4970
pfp->prefs = CreateEntrezPrefsDialog (g, NULL);
4971
c = HiddenGroup (g, 2, 0, NULL);
4972
b = PushButton (c, "Accept", AcceptPrefsProc);
4973
SetObjectExtra (b, pfp, NULL);
4974
PushButton (c, "Cancel", StdCancelButtonProc);
4975
AlignObjects (ALIGN_CENTER, (HANDLE) pfp->prefs, (HANDLE) c, NULL);
4977
epp = EntrezPrefsNew ();
4979
epp->persistDefault = egp->persistDefault;
4980
epp->alignDefault = egp->alignDefault;
4981
epp->lookupDirect = egp->lookupDirect;
4982
epp->showAsn = egp->showAsn;
4983
epp->initDatabase = StringSaveNoNull (egp->initDatabase);
4984
epp->initField = StringSaveNoNull (egp->initField);
4985
epp->initMode = StringSaveNoNull (egp->initMode);
4986
epp->initMedLabel = StringSaveNoNull (mvpp->initMedLabel);
4987
epp->initNucLabel = StringSaveNoNull (svpp->initNucLabel);
4988
epp->initProtLabel = StringSaveNoNull (svpp->initProtLabel);
4989
epp->initGenomeLabel = StringSaveNoNull (svpp->initGenomeLabel);
4991
PointerToDialog (pfp->prefs, (Pointer) epp);
4992
EntrezPrefsFree (epp);