|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/object/objfdef.c |
source navigation diff markup identifier search freetext search file search |
1 /* objfdef.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: objfdef.c
27 *
28 * Author: James Ostell
29 *
30 * Version Creation Date: 9/94
31 *
32 * $Revision: 6.39 $
33 *
34 * File Description: Object manager for feature definitions
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date Name Description of modification
39 * ------- ---------- -----------------------------------------------------
40 *
41 * ==========================================================================
42 */
43 #include <objfdef.h> /* the features interface */
44 #include <asnfdef.h> /* the AsnTool header */
45 #include <sequtil.h>
46 #include <explore.h> /* new public location of SeqMgrGetBestProteinFeature */
47
48 static Boolean loaded = FALSE;
49
50 /*****************************************************************************
51 *
52 * FeatDefAsnLoad()
53 * requires SeqAsnLoad() to be called first
54 *
55 *****************************************************************************/
56 NLM_EXTERN Boolean LIBCALL FeatDefAsnLoad (void)
57 {
58 if (loaded)
59 return TRUE;
60 loaded = TRUE;
61
62 if ( ! AsnLoad())
63 {
64 loaded = FALSE;
65 return FALSE;
66 }
67 return TRUE;
68 }
69
70 /*****************************************************************************
71 *
72 * FeatDef Routines
73 *
74 *****************************************************************************/
75 /*****************************************************************************
76 *
77 * FeatDefNew()
78 *
79 *****************************************************************************/
80 NLM_EXTERN FeatDefPtr LIBCALL FeatDefNew (void)
81 {
82 return (FeatDefPtr)MemNew(sizeof(FeatDef));
83 }
84
85 /*****************************************************************************
86 *
87 * FeatDefFree(fdp)
88 * Frees one FeatDef and associated data
89 *
90 *****************************************************************************/
91 NLM_EXTERN FeatDefPtr LIBCALL FeatDefFree (FeatDefPtr fdp)
92 {
93 if (fdp == NULL)
94 return (FeatDefPtr)NULL;
95
96 MemFree(fdp->typelabel);
97 MemFree(fdp->menulabel);
98 return (FeatDefPtr)MemFree(fdp);
99 }
100
101 /*****************************************************************************
102 *
103 * FeatDefAsnWrite(fdp, aip, atp)
104 * atp is the current type (if identifier of a parent struct)
105 * if atp == NULL, then assumes it stands alone (FeatDef ::=)
106 *
107 *****************************************************************************/
108 NLM_EXTERN Boolean LIBCALL FeatDefAsnWrite (FeatDefPtr fdp, AsnIoPtr aip, AsnTypePtr orig)
109 {
110 DataVal av;
111 AsnTypePtr atp;
112 Boolean retval = FALSE;
113
114 if (! loaded)
115 {
116 if (! FeatDefAsnLoad())
117 return FALSE;
118 }
119
120 if (aip == NULL)
121 return FALSE;
122
123 atp = AsnLinkType(orig, FEATDEF); /* link local tree */
124 if (atp == NULL)
125 return FALSE;
126
127 if (fdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
128
129 if (! AsnOpenStruct(aip, atp, (Pointer)fdp))
130 goto erret;
131
132 av.ptrvalue = fdp->typelabel;
133 if (! AsnWrite(aip, FEATDEF_typelabel, &av)) goto erret;
134
135 av.ptrvalue = fdp->menulabel;
136 if (! AsnWrite(aip, FEATDEF_menulabel, &av)) goto erret;
137
138 av.intvalue = (Int4)(fdp->featdef_key);
139 if (! AsnWrite(aip, FEATDEF_featdef_key, &av)) goto erret;
140
141 av.intvalue = (Int4)(fdp->seqfeat_key);
142 if (! AsnWrite(aip, FEATDEF_seqfeat_key, &av)) goto erret;
143
144 av.intvalue = (Int4)(fdp->entrygroup);
145 if (! AsnWrite(aip, FEATDEF_entrygroup, &av)) goto erret;
146
147 av.intvalue = (Int4)(fdp->displaygroup);
148 if (! AsnWrite(aip, FEATDEF_displaygroup, &av)) goto erret;
149
150 av.intvalue = (Int4)(fdp->molgroup);
151 if (! AsnWrite(aip, FEATDEF_molgroup, &av)) goto erret;
152
153 if (! AsnCloseStruct(aip, atp, (Pointer)fdp))
154 goto erret;
155 retval = TRUE;
156 erret:
157 AsnUnlinkType(orig); /* unlink local tree */
158 return retval;
159 }
160
161 /*****************************************************************************
162 *
163 * FeatDefAsnRead(aip, atp)
164 * atp is the current type (if identifier of a parent struct)
165 * assumption is readIdent has occurred
166 * if atp == NULL, then assumes it stands alone and read ident
167 * has not occurred.
168 *
169 *****************************************************************************/
170 NLM_EXTERN FeatDefPtr LIBCALL FeatDefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
171 {
172 DataVal av;
173 AsnTypePtr atp, oldtype;
174 FeatDefPtr fdp;
175
176 if (! loaded)
177 {
178 if (! FeatDefAsnLoad())
179 return (FeatDefPtr)NULL;
180 }
181
182 if (aip == NULL)
183 return (FeatDefPtr)NULL;
184
185 if (orig == NULL) /* FeatDef ::= (self contained) */
186 atp = AsnReadId(aip, amp, FEATDEF);
187 else
188 atp = AsnLinkType(orig, FEATDEF); /* link in local tree */
189 oldtype = atp;
190 if (atp == NULL)
191 return (FeatDefPtr)NULL;
192
193 fdp = FeatDefNew();
194 if (fdp == NULL)
195 goto erret;
196
197 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the start struct */
198 while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
199 {
200 if (atp == NULL) goto erret;
201 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
202 if (atp == FEATDEF_typelabel)
203 fdp->typelabel = (CharPtr)av.ptrvalue;
204 else if (atp == FEATDEF_menulabel)
205 fdp->menulabel = (CharPtr)av.ptrvalue;
206 else if (atp == FEATDEF_featdef_key)
207 fdp->featdef_key = (Uint1)(av.intvalue);
208 else if (atp == FEATDEF_seqfeat_key)
209 fdp->seqfeat_key = (Uint1)(av.intvalue);
210 else if (atp == FEATDEF_entrygroup)
211 fdp->entrygroup = (Uint1)(av.intvalue);
212 else if (atp == FEATDEF_displaygroup)
213 fdp->displaygroup = (Uint1)(av.intvalue);
214 else if (atp == FEATDEF_molgroup)
215 fdp->molgroup = (Uint1)(av.intvalue);
216 }
217 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
218 ret:
219 AsnUnlinkType(orig); /* unlink local tree */
220 return fdp;
221 erret:
222 fdp = FeatDefFree(fdp);
223 goto ret;
224 }
225
226 /*****************************************************************************
227 *
228 * FeatDefSetFree(fdp)
229 * Frees set of FeatDef
230 *
231 *****************************************************************************/
232 NLM_EXTERN FeatDefPtr LIBCALL FeatDefSetFree (FeatDefPtr fdp)
233 {
234 FeatDefPtr next;
235
236 while (fdp != NULL)
237 {
238 next = fdp->next;
239 FeatDefFree(fdp);
240 fdp = next;
241 }
242 return (FeatDefPtr)NULL;
243 }
244
245 /*****************************************************************************
246 *
247 * FeatDefSetAsnWrite(fdp, aip, atp)
248 * atp is the current type (if identifier of a parent struct)
249 * if atp == NULL, then assumes it stands alone (FeatDef ::=)
250 *
251 *****************************************************************************/
252 NLM_EXTERN Boolean LIBCALL FeatDefSetAsnWrite (FeatDefPtr fdp, AsnIoPtr aip, AsnTypePtr orig)
253 {
254 AsnTypePtr atp;
255 Boolean retval = FALSE;
256
257 if (! loaded)
258 {
259 if (! FeatDefAsnLoad())
260 return FALSE;
261 }
262
263 if (aip == NULL)
264 return FALSE;
265
266 atp = AsnLinkType(orig, FEATDEFSET); /* link local tree */
267 if (atp == NULL)
268 return FALSE;
269
270 if (fdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
271
272 if (! AsnOpenStruct(aip, atp, (Pointer)fdp))
273 goto erret;
274
275 while (fdp != NULL)
276 {
277 if (! FeatDefAsnWrite(fdp, aip, FEATDEFSET_E))
278 goto erret;
279 fdp = fdp->next;
280 }
281
282 if (! AsnCloseStruct(aip, atp, (Pointer)fdp))
283 goto erret;
284 retval = TRUE;
285 erret:
286 AsnUnlinkType(orig); /* unlink local tree */
287 return retval;
288 }
289
290 /*****************************************************************************
291 *
292 * FeatDefSetAsnRead(aip, atp)
293 * atp is the current type (if identifier of a parent struct)
294 * assumption is readIdent has occurred
295 * if atp == NULL, then assumes it stands alone and read ident
296 * has not occurred.
297 *
298 *****************************************************************************/
299 NLM_EXTERN FeatDefPtr LIBCALL FeatDefSetAsnRead (AsnIoPtr aip, AsnTypePtr orig)
300 {
301 DataVal av;
302 AsnTypePtr atp, oldtype;
303 FeatDefPtr fdp, first=NULL, last=NULL;
304
305 if (! loaded)
306 {
307 if (! FeatDefAsnLoad())
308 return (FeatDefPtr)NULL;
309 }
310
311 if (aip == NULL)
312 return (FeatDefPtr)NULL;
313
314 if (orig == NULL) /* FeatDef ::= (self contained) */
315 atp = AsnReadId(aip, amp, FEATDEFSET);
316 else
317 atp = AsnLinkType(orig, FEATDEFSET); /* link in local tree */
318 oldtype = atp;
319 if (atp == NULL)
320 return (FeatDefPtr)NULL;
321
322 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the start struct */
323 while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
324 {
325 if (atp == NULL) goto erret;
326 fdp = FeatDefAsnRead(aip, atp);
327 if (fdp == NULL) goto erret;
328 if (first == NULL) first = fdp;
329 if (last != NULL) last->next = fdp;
330 last = fdp;
331 }
332 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
333 ret:
334 AsnUnlinkType(orig); /* unlink local tree */
335 return first;
336 erret:
337 first = FeatDefSetFree(first);
338 goto ret;
339 }
340
341 /*****************************************************************************
342 *
343 * FeatDispGroup Routines
344 *
345 *****************************************************************************/
346 /*****************************************************************************
347 *
348 * FeatDispGroupNew()
349 *
350 *****************************************************************************/
351 NLM_EXTERN FeatDispGroupPtr LIBCALL FeatDispGroupNew (void)
352 {
353 return (FeatDispGroupPtr)MemNew(sizeof(FeatDispGroup));
354 }
355
356 /*****************************************************************************
357 *
358 * FeatDispGroupFree(fdp)
359 * Frees one FeatDispGroup and associated data
360 *
361 *****************************************************************************/
362 NLM_EXTERN FeatDispGroupPtr LIBCALL FeatDispGroupFree (FeatDispGroupPtr fdp)
363 {
364 if (fdp == NULL)
365 return (FeatDispGroupPtr)NULL;
366
367 MemFree(fdp->groupname);
368 return (FeatDispGroupPtr)MemFree(fdp);
369 }
370
371 /*****************************************************************************
372 *
373 * FeatDispGroupAsnWrite(fdp, aip, atp)
374 * atp is the current type (if identifier of a parent struct)
375 * if atp == NULL, then assumes it stands alone (FeatDispGroup ::=)
376 *
377 *****************************************************************************/
378 NLM_EXTERN Boolean LIBCALL FeatDispGroupAsnWrite (FeatDispGroupPtr fdp, AsnIoPtr aip, AsnTypePtr orig)
379 {
380 DataVal av;
381 AsnTypePtr atp;
382 Boolean retval = FALSE;
383
384 if (! loaded)
385 {
386 if (! FeatDefAsnLoad())
387 return FALSE;
388 }
389
390 if (aip == NULL)
391 return FALSE;
392
393 atp = AsnLinkType(orig, FEATDISPGROUP); /* link local tree */
394 if (atp == NULL)
395 return FALSE;
396
397 if (fdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
398
399 if (! AsnOpenStruct(aip, atp, (Pointer)fdp))
400 goto erret;
401
402 av.intvalue = (Int4)(fdp->groupkey);
403 if (! AsnWrite(aip, FEATDISPGROUP_groupkey, &av)) goto erret;
404
405 av.ptrvalue = fdp->groupname;
406 if (! AsnWrite(aip, FEATDISPGROUP_groupname, &av)) goto erret;
407
408 if (! AsnCloseStruct(aip, atp, (Pointer)fdp))
409 goto erret;
410 retval = TRUE;
411 erret:
412 AsnUnlinkType(orig); /* unlink local tree */
413 return retval;
414 }
415
416 /*****************************************************************************
417 *
418 * FeatDispGroupAsnRead(aip, atp)
419 * atp is the current type (if identifier of a parent struct)
420 * assumption is readIdent has occurred
421 * if atp == NULL, then assumes it stands alone and read ident
422 * has not occurred.
423 *
424 *****************************************************************************/
425 NLM_EXTERN FeatDispGroupPtr LIBCALL FeatDispGroupAsnRead (AsnIoPtr aip, AsnTypePtr orig)
426 {
427 DataVal av;
428 AsnTypePtr atp, oldtype;
429 FeatDispGroupPtr fdp;
430
431 if (! loaded)
432 {
433 if (! FeatDefAsnLoad())
434 return (FeatDispGroupPtr)NULL;
435 }
436
437 if (aip == NULL)
438 return (FeatDispGroupPtr)NULL;
439
440 if (orig == NULL) /* FeatDispGroup ::= (self contained) */
441 atp = AsnReadId(aip, amp, FEATDISPGROUP);
442 else
443 atp = AsnLinkType(orig, FEATDISPGROUP); /* link in local tree */
444 oldtype = atp;
445 if (atp == NULL)
446 return (FeatDispGroupPtr)NULL;
447
448 fdp = FeatDispGroupNew();
449 if (fdp == NULL)
450 goto erret;
451
452 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the start struct */
453 while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
454 {
455 if (atp == NULL) goto erret;
456 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
457 if (atp == FEATDISPGROUP_groupname)
458 fdp->groupname = (CharPtr)av.ptrvalue;
459 else if (atp == FEATDISPGROUP_groupkey)
460 fdp->groupkey = (Uint1)(av.intvalue);
461 }
462 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
463 ret:
464 AsnUnlinkType(orig); /* unlink local tree */
465 return fdp;
466 erret:
467 fdp = FeatDispGroupFree(fdp);
468 goto ret;
469 }
470
471 /*****************************************************************************
472 *
473 * FeatDispGroupSetFree(fdp)
474 * Frees set of FeatDispGroup
475 *
476 *****************************************************************************/
477 NLM_EXTERN FeatDispGroupPtr LIBCALL FeatDispGroupSetFree (FeatDispGroupPtr fdp)
478 {
479 FeatDispGroupPtr next;
480
481 while (fdp != NULL)
482 {
483 next = fdp->next;
484 FeatDispGroupFree(fdp);
485 fdp = next;
486 }
487 return (FeatDispGroupPtr)NULL;
488 }
489
490 /*****************************************************************************
491 *
492 * FeatDispGroupSetAsnWrite(fdp, aip, atp)
493 * atp is the current type (if identifier of a parent struct)
494 * if atp == NULL, then assumes it stands alone (FeatDispGroup ::=)
495 *
496 *****************************************************************************/
497 NLM_EXTERN Boolean LIBCALL FeatDispGroupSetAsnWrite (FeatDispGroupPtr fdp, AsnIoPtr aip, AsnTypePtr orig)
498 {
499 AsnTypePtr atp;
500 Boolean retval = FALSE;
501
502 if (! loaded)
503 {
504 if (! FeatDefAsnLoad())
505 return FALSE;
506 }
507
508 if (aip == NULL)
509 return FALSE;
510
511 atp = AsnLinkType(orig, FEATDISPGROUPSET); /* link local tree */
512 if (atp == NULL)
513 return FALSE;
514
515 if (fdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
516
517 if (! AsnOpenStruct(aip, atp, (Pointer)fdp))
518 goto erret;
519
520 while (fdp != NULL)
521 {
522 if (! FeatDispGroupAsnWrite(fdp, aip, FEATDISPGROUPSET_E))
523 goto erret;
524 fdp = fdp->next;
525 }
526
527 if (! AsnCloseStruct(aip, atp, (Pointer)fdp))
528 goto erret;
529 retval = TRUE;
530 erret:
531 AsnUnlinkType(orig); /* unlink local tree */
532 return retval;
533 }
534
535 /*****************************************************************************
536 *
537 * FeatDispGroupSetAsnRead(aip, atp)
538 * atp is the current type (if identifier of a parent struct)
539 * assumption is readIdent has occurred
540 * if atp == NULL, then assumes it stands alone and read ident
541 * has not occurred.
542 *
543 *****************************************************************************/
544 NLM_EXTERN FeatDispGroupPtr LIBCALL FeatDispGroupSetAsnRead (AsnIoPtr aip, AsnTypePtr orig)
545 {
546 DataVal av;
547 AsnTypePtr atp, oldtype;
548 FeatDispGroupPtr fdp, first=NULL, last=NULL;
549
550 if (! loaded)
551 {
552 if (! FeatDefAsnLoad())
553 return (FeatDispGroupPtr)NULL;
554 }
555
556 if (aip == NULL)
557 return (FeatDispGroupPtr)NULL;
558
559 if (orig == NULL) /* FeatDispGroup ::= (self contained) */
560 atp = AsnReadId(aip, amp, FEATDISPGROUPSET);
561 else
562 atp = AsnLinkType(orig, FEATDISPGROUPSET); /* link in local tree */
563 oldtype = atp;
564 if (atp == NULL)
565 return (FeatDispGroupPtr)NULL;
566
567 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the start struct */
568 while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
569 {
570 if (atp == NULL) goto erret;
571 fdp = FeatDispGroupAsnRead(aip, atp);
572 if (fdp == NULL) goto erret;
573 if (first == NULL) first = fdp;
574 if (last != NULL) last->next = fdp;
575 last = fdp;
576 }
577 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
578 ret:
579 AsnUnlinkType(orig); /* unlink local tree */
580 return first;
581 erret:
582 first = FeatDispGroupSetFree(first);
583 goto ret;
584 }
585
586 static FeatDefPtr featdefp = NULL;
587 static FeatDefPtr PNTR featdeflookup = NULL; /* kludge which assumes featdef_key in order */
588 static Int2 numfdef, numfdispg;
589 static FeatDispGroupPtr featdgp;
590
591 /*****************************************************************************
592 *
593 * featDefSetMemStr as last resort embedded version of featdef.prt
594 *
595 *****************************************************************************/
596
597 #ifndef WIN16
598 static CharPtr featDefSetMemStr = "FeatDefGroupSet ::= {\n" \
599 "groups {\n" \
600 "{ groupkey 0 , groupname \"Unrecognized Features\" } ,\n" \
601 "{ groupkey 1 , groupname \"Genes and Named Regions\" } ,\n" \
602 "{ groupkey 2 , groupname \"Coding Regions and Transcripts\" } ,\n" \
603 "{ groupkey 3 , groupname \"Structural RNAs\" } ,\n" \
604 "{ groupkey 4 , groupname \"Bibliographic and Comments\" } ,\n" \
605 "{ groupkey 5 , groupname \"Sites and Bonds\" } } ,\n" \
606 "defs {\n" \
607 "{ typelabel \"???\" , menulabel \"Unsupported feature\" , featdef-key 0 , seqfeat-key 0 , entrygroup 0 , displaygroup 0 , molgroup both } ,\n" \
608 "{ typelabel \"Gene\" , menulabel \"Gene\" , featdef-key 1 , seqfeat-key 1 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
609 "{ typelabel \"Org\" , menulabel \"Organism\" , featdef-key 2 , seqfeat-key 2 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
610 "{ typelabel \"CDS\" , menulabel \"Coding Region\" , featdef-key 3 , seqfeat-key 3 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
611 "{ typelabel \"Prot\" , menulabel \"Protein Names\" , featdef-key 4 , seqfeat-key 4 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
612 "{ typelabel \"preRNA\" , menulabel \"Precursor RNA\" , featdef-key 5 , seqfeat-key 5 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
613 "{ typelabel \"mRNA\" , menulabel \"Mature Messenger RNA\" , featdef-key 6 , seqfeat-key 5 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
614 "{ typelabel \"tRNA\" , menulabel \"Transfer RNA\" , featdef-key 7 , seqfeat-key 5 , entrygroup 3 , displaygroup 3 , molgroup na } ,\n" \
615 "{ typelabel \"rRNA\" , menulabel \"Ribosomal RNA\" , featdef-key 8 , seqfeat-key 5 , entrygroup 3 , displaygroup 3 , molgroup na } ,\n" \
616 "{ typelabel \"snRNA\" , menulabel \"Small Nuclear RNA\" , featdef-key 9 , seqfeat-key 5 , entrygroup 0 , displaygroup 3 , molgroup na } ,\n" \
617 "{ typelabel \"scRNA\" , menulabel \"Small Cytoplasmic RNA\" , featdef-key 10 , seqfeat-key 5 , entrygroup 0 , displaygroup 3 , molgroup na } ,\n" \
618 "{ typelabel \"RNA\" , menulabel \"Other Types of RNA\" , featdef-key 11 , seqfeat-key 5 , entrygroup 3 , displaygroup 3 , molgroup na } ,\n" \
619 "{ typelabel \"Cit\" , menulabel \"Bibliographic Citations\" , featdef-key 12 , seqfeat-key 6 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
620 "{ typelabel \"Xref\" , menulabel \"Reference to Another Sequence\" , featdef-key 13 , seqfeat-key 7 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
621 "{ typelabel \"Import\" , menulabel \"Unclassified ImpFeat\" , featdef-key 14 , seqfeat-key 8 , entrygroup 0 , displaygroup 0 , molgroup na } ,\n" \
622 "{ typelabel \"allele\" , menulabel \"Allelic Varient\" , featdef-key 15 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
623 "{ typelabel \"attenuator\" , menulabel \"Attenuator\" , featdef-key 16 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
624 "{ typelabel \"C_region\" , menulabel \"Immunoglobin/T-cell receptor constant region\" , featdef-key 17 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
625 "{ typelabel \"CAAT_signal\" , menulabel \"CAAT box\" , featdef-key 18 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
626 "{ typelabel \"CDS\" , menulabel \"Untranslatable coding region\" , featdef-key 19 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
627 "{ typelabel \"conflict\" , menulabel \"Sequence determinations differ\" , featdef-key 20 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
628 "{ typelabel \"D-loop\" , menulabel \"Displacement Loop\" , featdef-key 21 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
629 "{ typelabel \"D_segment\" , menulabel \"Diversity Segment of Immunoglobin\" , featdef-key 22 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
630 "{ typelabel \"enhancer\" , menulabel \"Enhancer\" , featdef-key 23 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
631 "{ typelabel \"exon\" , menulabel \"Exon\" , featdef-key 24 , seqfeat-key 8 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
632 "{ typelabel \"GC_signal\" , menulabel \"GC box\" , featdef-key 25 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
633 "{ typelabel \"iDNA\" , menulabel \"intervening DNA\" , featdef-key 26 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
634 "{ typelabel \"intron\" , menulabel \"Intron\" , featdef-key 27 , seqfeat-key 8 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
635 "{ typelabel \"J_segment\" , menulabel \"IG joining segment\" , featdef-key 28 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
636 "{ typelabel \"LTR\" , menulabel \"Long Terminal Repeat\" , featdef-key 29 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
637 "{ typelabel \"mat_peptide\" , menulabel \"Mature Peptide labeled on Nuc Acid\" , featdef-key 30 , seqfeat-key 8 , entrygroup 0 , displaygroup 2 , molgroup na } ,\n" \
638 "{ typelabel \"misc_binding\" , menulabel \"Miscellaneaous binding site\" , featdef-key 31 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
639 "{ typelabel \"misc_difference\" , menulabel \"Miscellaneous sequence difference\" , featdef-key 32 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
640 "{ typelabel \"misc_feature\" , menulabel \"Miscellaneaous feature\" , featdef-key 33 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
641 "{ typelabel \"misc_recomb\" , menulabel \"Miscellaneous recombination\" , featdef-key 34 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
642 "{ typelabel \"misc_RNA\" , menulabel \"Miscellaneous RNA\" , featdef-key 35 , seqfeat-key 8 , entrygroup 0 , displaygroup 3 , molgroup na } ,\n" \
643 "{ typelabel \"misc_signal\" , menulabel \"Miscellaneous signal sequence\" , featdef-key 36 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
644 "{ typelabel \"misc_structure\" , menulabel \"Miscellaneous secondary structure\" , featdef-key 37 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
645 "{ typelabel \"modified_base\" , menulabel \"Modified base\" , featdef-key 38 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
646 "{ typelabel \"mutation\" , menulabel \"site of mutation in related strain\" , featdef-key 39 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
647 "{ typelabel \"N_region\" , menulabel \"Extra na in rearranged IG\" , featdef-key 40 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
648 "{ typelabel \"old_sequence\" , menulabel \"Location of sequence revision\" , featdef-key 41 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
649 "{ typelabel \"polyA_signal\" , menulabel \"PolyA addition recognition signal\" , featdef-key 42 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
650 "{ typelabel \"polyA_site\" , menulabel \"Point where polyA tail begins\" , featdef-key 43 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
651 "{ typelabel \"precursor_RNA\" , menulabel \"RNA which is a post-transcriptional intermediate\" , featdef-key 44 , seqfeat-key 8 , entrygroup 0 , displaygroup 2 , molgroup na } ,\n" \
652 "{ typelabel \"prim_transcript\" , menulabel \"Primary transcript\" , featdef-key 45 , seqfeat-key 8 , entrygroup 0 , displaygroup 2 , molgroup na } ,\n" \
653 "{ typelabel \"primer_bind\" , menulabel \"Primer binding site\" , featdef-key 46 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
654 "{ typelabel \"promoter\" , menulabel \"Promoter\" , featdef-key 47 , seqfeat-key 8 , entrygroup 0 , displaygroup 5 , molgroup na } ,\n" \
655 "{ typelabel \"protein_bind\" , menulabel \"Protein binding site\" , featdef-key 48 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
656 "{ typelabel \"RBS\" , menulabel \"Ribosome binding site\" , featdef-key 49 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
657 "{ typelabel \"repeat_region\" , menulabel \"Region containing repeats\" , featdef-key 50 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
658 "{ typelabel \"repeat_unit\" , menulabel \"Single repeat unit\" , featdef-key 51 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
659 "{ typelabel \"rep_origin\" , menulabel \"Origin of replication\" , featdef-key 52 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
660 "{ typelabel \"S_region\" , menulabel \"IG switch region\" , featdef-key 53 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
661 "{ typelabel \"satellite\" , menulabel \"satellite repeat region\" , featdef-key 54 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
662 "{ typelabel \"sig_peptide\" , menulabel \"Signal Peptide annotated on Nuc Acid\" , featdef-key 55 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
663 "{ typelabel \"source\" , menulabel \"Source of Nuc Acid\" , featdef-key 56 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
664 "{ typelabel \"stem_loop\" , menulabel \"Stem loop structure\" , featdef-key 57 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
665 "{ typelabel \"STS\" , menulabel \"Sequence tagged site\" , featdef-key 58 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
666 "{ typelabel \"TATA_signal\" , menulabel \"TATA box\" , featdef-key 59 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
667 "{ typelabel \"terminator\" , menulabel \"Transcription terminator\" , featdef-key 60 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
668 "{ typelabel \"transit_peptide\" , menulabel \"Transit peptide annotated on Nuc Acid\" , featdef-key 61 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
669 "{ typelabel \"unsure\" , menulabel \"Unsure of exact sequence\" , featdef-key 62 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
670 "{ typelabel \"V_region\" , menulabel \"IG variable region\" , featdef-key 63 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
671 "{ typelabel \"V_segment\" , menulabel \"IG variable segment\" , featdef-key 64 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
672 "{ typelabel \"variation\" , menulabel \"Strain differences\" , featdef-key 65 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
673 "{ typelabel \"virion\" , menulabel \"Viral genome\" , featdef-key 66 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
674 "{ typelabel \"3'clip\" , menulabel \"3' region of transcript clipped off in processing\" , featdef-key 67 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
675 "{ typelabel \"3'UTR\" , menulabel \"3' untranslated region\" , featdef-key 68 , seqfeat-key 8 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
676 "{ typelabel \"5'clip\" , menulabel \"5' region of transcript clipped off in processing\" , featdef-key 69 , seqfeat-key 8 , entrygroup 0 , displaygroup 1 , molgroup na } ,\n" \
677 "{ typelabel \"5'UTR\" , menulabel \"5' untranslated region\" , featdef-key 70 , seqfeat-key 8 , entrygroup 2 , displaygroup 2 , molgroup na } ,\n" \
678 "{ typelabel \"-10_signal\" , menulabel \"Pribnow box\" , featdef-key 71 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
679 "{ typelabel \"-35_signal\" , menulabel \"-35 region of transcription start\" , featdef-key 72 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
680 "{ typelabel \"Site-ref\" , menulabel \"SITES type reference\" , featdef-key 73 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
681 "{ typelabel \"Region\" , menulabel \"Named region of sequence\" , featdef-key 74 , seqfeat-key 9 , entrygroup 1 , displaygroup 1 , molgroup both } ,\n" \
682 "{ typelabel \"Comment\" , menulabel \"Comment associated with sequence\" , featdef-key 75 , seqfeat-key 10 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
683 "{ typelabel \"Bond\" , menulabel \"Chemical bonds\" , featdef-key 76 , seqfeat-key 11 , entrygroup 5 , displaygroup 5 , molgroup aa } ,\n" \
684 "{ typelabel \"Site\" , menulabel \"Binding/Active Sites\" , featdef-key 77 , seqfeat-key 12 , entrygroup 5 , displaygroup 5 , molgroup both } ,\n" \
685 "{ typelabel \"Rsite\" , menulabel \"Restriction Sites\" , featdef-key 78 , seqfeat-key 13 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
686 "{ typelabel \"User\" , menulabel \"User Defined feature\" , featdef-key 79 , seqfeat-key 14 , entrygroup 0 , displaygroup 4 , molgroup both } ,\n" \
687 "{ typelabel \"TxInit\" , menulabel \"Transcription Initiation Site\" , featdef-key 80 , seqfeat-key 15 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
688 "{ typelabel \"Num\" , menulabel \"Numbering System for Sequence\" , featdef-key 81 , seqfeat-key 16 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
689 "{ typelabel \"SecStr\" , menulabel \"Protein Secondary Structure\" , featdef-key 82 , seqfeat-key 17 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
690 "{ typelabel \"NonStdRes\" , menulabel \"Non-standard Residue\" , featdef-key 83 , seqfeat-key 18 , entrygroup 5 , displaygroup 5 , molgroup aa } ,\n" \
691 "{ typelabel \"Het\" , menulabel \"Heterogen\" , featdef-key 84 , seqfeat-key 19 , entrygroup 5 , displaygroup 5 , molgroup aa } ,\n" \
692 "{ typelabel \"Src\" , menulabel \"Biological Source\" , featdef-key 85 , seqfeat-key 20 , entrygroup 4 , displaygroup 4 , molgroup both } ,\n" \
693 "{ typelabel \"proprotein\" , menulabel \"Proprotein\" , featdef-key 86 , seqfeat-key 4 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
694 "{ typelabel \"mat_peptide\" , menulabel \"Mature Peptide\" , featdef-key 87 , seqfeat-key 4 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
695 "{ typelabel \"sig_peptide\" , menulabel \"Signal Peptide\" , featdef-key 88 , seqfeat-key 4 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
696 "{ typelabel \"transit_peptide\" , menulabel \"Transit Peptide\" , featdef-key 89 , seqfeat-key 4 , entrygroup 1 , displaygroup 1 , molgroup aa } ,\n" \
697 "{ typelabel \"snoRNA\" , menulabel \"Small Nucleolar RNA\" , featdef-key 90 , seqfeat-key 5 , entrygroup 0 , displaygroup 3 , molgroup na } ,\n" \
698 "{ typelabel \"gap\" , menulabel \"Gap\" , featdef-key 91 , seqfeat-key 8 , entrygroup 0 , displaygroup 4 , molgroup na } ,\n" \
699 "{ typelabel \"operon\" , menulabel \"Operon\" , featdef-key 92 , seqfeat-key 8 , entrygroup 1 , displaygroup 1 , molgroup na } ,\n" \
700 "{ typelabel \"oriT\" , menulabel \"Origin of Transcription\" , featdef-key 93 , seqfeat-key 8 , entrygroup 5 , displaygroup 5 , molgroup na } ,\n" \
701 "{ typelabel \"ncRNA\" , menulabel \"Non-coding RNA\" , featdef-key 94 , seqfeat-key 5 , entrygroup 3 , displaygroup 3 , molgroup na } ,\n" \
702 "{ typelabel \"tmRNA\" , menulabel \"Transfer-messenger RNA\" , featdef-key 95 , seqfeat-key 5 , entrygroup 3 , displaygroup 3 , molgroup na } ,\n" \
703 "{ typelabel \"CloneRef\" , menulabel \"Clone Reference\" , featdef-key 96 , seqfeat-key 21 , entrygroup 0 , displaygroup 0 , molgroup na } } };\n";
704 #endif
705
706 /*****************************************************************************
707 *
708 * FeatDefPtr FeatDefSetLoad()
709 * loads all current feature defintions
710 * looks for "featdef.val" in the "data" directory
711 *
712 *****************************************************************************/
713 static FeatDefPtr LIBCALL FeatDefGroupSetAsnRead (AsnIoPtr aip, AsnTypePtr orig)
714 {
715 FeatDefPtr fdp;
716 FeatDispGroupPtr fdgp;
717 Int2 i, num;
718 DataVal av;
719 AsnTypePtr atp, oldtype;
720
721 if (! loaded)
722 {
723 if (! FeatDefAsnLoad())
724 return (FeatDefPtr)NULL;
725 }
726
727 if (aip == NULL)
728 return (FeatDefPtr)NULL;
729
730 if (orig == NULL) /* FeatDefGroupSet ::= (self contained) */
731 atp = AsnReadId(aip, amp, FEATDEFGROUPSET);
732 else
733 atp = AsnLinkType(orig, FEATDEFGROUPSET); /* link in local tree */
734 oldtype = atp;
735 if (atp == NULL)
736 return (FeatDefPtr)NULL;
737
738 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the start struct */
739 while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
740 {
741 if (atp == NULL) goto erret;
742 if (atp == FEATDEFGROUPSET_groups)
743 {
744 featdgp = FeatDispGroupSetAsnRead(aip, atp);
745 if (featdgp == NULL) goto erret;
746 }
747 else if (atp == FEATDEFGROUPSET_defs)
748 {
749 featdefp = FeatDefSetAsnRead(aip, atp);
750 if (featdefp == NULL) goto erret;
751 }
752 }
753 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
754
755 for (numfdef = 0, fdp = featdefp; fdp != NULL; fdp = fdp->next)
756 numfdef++;
757
758 num = numfdef;
759 if (num < FEATDEF_MAX) {
760 num = FEATDEF_MAX;
761 }
762 featdeflookup = MemNew((size_t)(sizeof(FeatDefPtr) * num));
763
764 for (i = 0, fdp = featdefp; fdp != NULL && i < numfdef; fdp = fdp->next, i++)
765 featdeflookup[i] = fdp;
766
767 for (numfdispg = 0, fdgp = featdgp; fdgp != NULL; fdgp = fdgp->next)
768 numfdispg++;
769
770 ret:
771 AsnUnlinkType(orig); /* unlink local tree */
772 return featdefp;
773 erret:
774 featdgp = FeatDispGroupSetFree(featdgp);
775 featdefp = FeatDefSetFree(featdefp);
776 goto ret;
777 }
778
779 static Boolean LoadFeatDefFromLocalString (void)
780
781 {
782 #ifndef WIN16
783 AsnIoMemPtr aimp;
784
785 aimp = AsnIoMemOpen ("r", (BytePtr) featDefSetMemStr, (Int4) StringLen (featDefSetMemStr));
786 if (aimp == NULL || aimp->aip == NULL) return FALSE;
787 FeatDefGroupSetAsnRead (aimp->aip, NULL);
788 AsnIoMemClose (aimp);
789 #endif
790 return (Boolean) (featdefp != NULL);
791 }
792
793 NLM_EXTERN FeatDefPtr LIBCALL FeatDefSetLoad (void)
794 {
795 Char buf[256];
796 AsnIoPtr aip;
797
798 if (featdefp != NULL)
799 return featdefp;
800
801 if (! loaded)
802 {
803 if (! FeatDefAsnLoad())
804 return (FeatDefPtr)NULL;
805 }
806
807 #ifdef OS_UNIX
808 if (getenv ("USE_FEATDEF_FILE") == NULL) {
809 if (LoadFeatDefFromLocalString ()) {
810 return featdefp;
811 }
812 }
813 #endif
814
815 if (! FindPath("ncbi", "ncbi", "data", buf, sizeof (buf)))
816 {
817
818 if (LoadFeatDefFromLocalString ()) {
819 return featdefp;
820 }
821
822 ErrPost(CTX_NCBIOBJ, 1, "FindPath failed in FeatDefSetTableLoad - ncbi configuration file missing or incorrect");
823 return featdefp;
824 }
825
826 StringCat(buf, "featdef.val");
827 if ((aip = AsnIoOpen(buf, "rb")) == NULL)
828 {
829
830 if (LoadFeatDefFromLocalString ()) {
831 return featdefp;
832 }
833
834 ErrPost(CTX_NCBIOBJ, 1, "Couldn't open [%s]", buf);
835 return featdefp;
836 }
837
838 FeatDefGroupSetAsnRead (aip, NULL);
839
840 AsnIoClose(aip);
841 return featdefp;
842 }
843
844 /*****************************************************************************
845 *
846 * FindImpFeatType(sfp)
847 * returns the featdef_key by matching the key of an Imp-feat
848 * returns FEATDEF_BAD if can't match it
849 *
850 *****************************************************************************/
851 static Uint1 FindImpFeatType (SeqFeatPtr sfp)
852 {
853 FeatDefPtr PNTR fdpp;
854 FeatDefPtr fdp;
855 ImpFeatPtr ifp;
856 CharPtr tmp;
857 Int2 i;
858
859 if (sfp == NULL) return FEATDEF_BAD;
860 if (sfp->data.choice != SEQFEAT_IMP) return FEATDEF_BAD;
861
862 ifp = (ImpFeatPtr)(sfp->data.value.ptrvalue);
863 tmp = ifp->key;
864
865 if (FeatDefSetLoad() == NULL) return FEATDEF_BAD;
866 fdpp = featdeflookup;
867
868 for (i = 0; i < numfdef; i++, fdpp++)
869 {
870 fdp = *fdpp;
871 if (fdp != NULL && fdp->seqfeat_key == SEQFEAT_IMP)
872 {
873 if (! StringCmp(fdp->typelabel, tmp))
874 return fdp->featdef_key;
875 }
876 }
877
878 return FEATDEF_BAD;
879 }
880
881
882 /*****************************************************************************
883 *
884 * FindFeatDefType(sfp)
885 * Finds the featdef_type for a SeqFeat
886 * returns FEATDEF_BAD if can't find it
887 *
888 *****************************************************************************/
889 NLM_EXTERN Uint1 LIBCALL FindFeatDefType(SeqFeatPtr sfp)
890 {
891 CharPtr name;
892 ProtRefPtr prp;
893 RnaRefPtr rrp;
894
895 if (sfp == NULL) return FEATDEF_BAD;
896 switch (sfp->data.choice)
897 {
898 case SEQFEAT_GENE:
899 return FEATDEF_GENE;
900 case SEQFEAT_ORG:
901 return FEATDEF_ORG;
902 case SEQFEAT_CDREGION:
903 return FEATDEF_CDS;
904 case SEQFEAT_PROT:
905 prp = (ProtRefPtr)(sfp->data.value.ptrvalue);
906 switch (prp->processed)
907 {
908 case 0:
909 return FEATDEF_PROT;
910 case 1:
911 return FEATDEF_preprotein;
912 case 2:
913 return FEATDEF_mat_peptide_aa;
914 case 3:
915 return FEATDEF_sig_peptide_aa;
916 case 4:
917 return FEATDEF_transit_peptide_aa;
918 }
919 return FEATDEF_BAD;
920 case SEQFEAT_RNA:
921 rrp = (RnaRefPtr)(sfp->data.value.ptrvalue);
922 switch (rrp->type)
923 {
924 case 0:
925 return FEATDEF_otherRNA; /* unknownRNA mapped to otherRNA */
926 case 1:
927 return FEATDEF_preRNA;
928 case 2:
929 return FEATDEF_mRNA;
930 case 3:
931 return FEATDEF_tRNA;
932 case 4:
933 return FEATDEF_rRNA;
934 case 5:
935 return FEATDEF_snRNA;
936 case 6:
937 return FEATDEF_scRNA;
938 case 7:
939 return FEATDEF_snoRNA;
940 case 8:
941 return FEATDEF_ncRNA;
942 case 9:
943 return FEATDEF_tmRNA;
944 case 10:
945 return FEATDEF_otherRNA;
946 case 255:
947 if (rrp->ext.choice == 1) {
948 name = (CharPtr) rrp->ext.value.ptrvalue;
949 if (StringICmp (name, "misc_RNA") == 0) return FEATDEF_otherRNA;
950 if (StringICmp (name, "ncRNA") == 0) return FEATDEF_ncRNA;
951 if (StringICmp (name, "tmRNA") == 0) return FEATDEF_tmRNA;
952 }
953 return FEATDEF_otherRNA;
954 }
955 return FEATDEF_BAD;
956 case SEQFEAT_PUB:
957 return FEATDEF_PUB;
958 case SEQFEAT_SEQ:
959 return FEATDEF_SEQ;
960 case SEQFEAT_IMP:
961 return FindImpFeatType(sfp);
962 case SEQFEAT_REGION:
963 return FEATDEF_REGION;
964 case SEQFEAT_COMMENT:
965 return FEATDEF_COMMENT;
966 case SEQFEAT_BOND:
967 return FEATDEF_BOND;
968 case SEQFEAT_SITE:
969 return FEATDEF_SITE;
970 case SEQFEAT_RSITE:
971 return FEATDEF_RSITE;
972 case SEQFEAT_USER:
973 return FEATDEF_USER;
974 case SEQFEAT_TXINIT:
975 return FEATDEF_TXINIT;
976 case SEQFEAT_NUM:
977 return FEATDEF_NUM;
978 case SEQFEAT_PSEC_STR:
979 return FEATDEF_PSEC_STR;
980 case SEQFEAT_NON_STD_RESIDUE:
981 return FEATDEF_NON_STD_RESIDUE;
982 case SEQFEAT_HET:
983 return FEATDEF_HET;
984 case SEQFEAT_BIOSRC:
985 return FEATDEF_BIOSRC;
986 case SEQFEAT_CLONEREF:
987 return FEATDEF_CLONEREF;
988 }
989
990 return FEATDEF_BAD;
991 }
992
993 /*****************************************************************************
994 *
995 * FeatDefTypeLabel(sfp)
996 * returns the type label for the feature
997 * returns NULL if can't find one
998 *
999 *****************************************************************************/
1000 NLM_EXTERN const char * LIBCALL FeatDefTypeLabel(SeqFeatPtr sfp)
1001 {
1002 Int2 i;
1003 FeatDefPtr fdp;
1004
1005 if (sfp == NULL) return (const char *)NULL;
1006 if (FeatDefSetLoad() == NULL) return (const char *)NULL;
1007
1008 i = (Int2) FindFeatDefType(sfp);
1009 if (i == FEATDEF_BAD) return NULL;
1010
1011 fdp = featdeflookup[i];
1012 if (fdp == NULL) return NULL;
1013 return (const char *)(fdp->typelabel);
1014 }
1015
1016 static Int2 NEAR FeatDefLabelContent (SeqFeatPtr sfp, CharPtr buf, Int2 buflen, Uint1 labeltype, CharPtr typelabel)
1017 {
1018 GeneRefPtr grp=NULL;
1019 OrgRefPtr orp=NULL;
1020 ProtRefPtr prp=NULL;
1021 SeqFeatXrefPtr sfxrp;
1022 SeqIdPtr sip;
1023 BioseqPtr bsp;
1024 BioseqContextPtr bcp;
1025 SeqFeatPtr sfp2;
1026 RsiteRefPtr rrp;
1027 UserObjectPtr uop;
1028 BioSourcePtr bsrcp;
1029 CharPtr label = NULL;
1030 RnaRefPtr trrp;
1031 tRNAPtr trp;
1032 RNAGenPtr rgp;
1033 Char tbuf[40], snpbuf [64];
1034 Int2 len = buflen, diff;
1035 GBQualPtr gbp;
1036 CharPtr prefix=NULL, suffix=NULL, ptr;
1037 PubdescPtr pdp;
1038 ValNodePtr vnp;
1039 ImpFeatPtr ifp;
1040 Boolean first;
1041 ValNode vn;
1042 static CharPtr slash = " /";
1043 SeqMapTablePtr smtp;
1044 SeqCodeTablePtr sctp;
1045 Uint1 aacode;
1046 DbtagPtr dbt;
1047 ObjectIdPtr oip;
1048
1049 if (sfp == NULL) return 0;
1050
1051 switch (sfp->data.choice)
1052 {
1053 case SEQFEAT_GENE:
1054 grp = (GeneRefPtr)(sfp->data.value.ptrvalue);
1055 generef: if (grp->locus != NULL)
1056 label = (grp->locus);
1057 else if (grp->desc != NULL)
1058 label = (grp->desc);
1059 else if (grp->locus_tag != NULL)
1060 label = (grp->locus_tag);
1061 else if (grp->syn != NULL)
1062 label = (CharPtr)(grp->syn->data.ptrvalue);
1063 else if (grp->db != NULL)
1064 return DbtagLabel((DbtagPtr)(grp->db->data.ptrvalue), buf, buflen);
1065 else if (grp->maploc != NULL)
1066 label = (grp->maploc);
1067 break;
1068 case SEQFEAT_ORG:
1069 orp = (OrgRefPtr)(sfp->data.value.ptrvalue);
1070 orgref: if (orp->taxname != NULL)
1071 label = (orp->taxname);
1072 else if (orp->common != NULL)
1073 label = (orp->common);
1074 else if (orp->db != NULL)
1075 return DbtagLabel((DbtagPtr)(orp->db->data.ptrvalue), buf, buflen);
1076 break;
1077 case SEQFEAT_CDREGION:
1078 for (sfxrp = sfp->xref; sfxrp != NULL; sfxrp = sfxrp->next)
1079 {
1080 switch (sfxrp->data.choice)
1081 {
1082 case SEQFEAT_PROT:
1083 prp = (ProtRefPtr)(sfxrp->data.value.ptrvalue);
1084 break;
1085 case SEQFEAT_GENE:
1086 grp = (GeneRefPtr)(sfxrp->data.value.ptrvalue);
1087 break;
1088 }
1089 }
1090 if (prp != NULL) goto protref;
1091 if (sfp->product != NULL)
1092 {
1093 sip = SeqLocId(sfp->product);
1094 bsp = BioseqFind(sip);
1095 if (bsp != NULL)
1096 {
1097 /* first see if preindexed in object manager */
1098 sfp2 = SeqMgrGetBestProteinFeature (bsp, NULL);
1099 if (sfp2 != NULL) {
1100 prp = (ProtRefPtr)(sfp2->data.value.ptrvalue);
1101 if (prp != NULL) {
1102 goto protref;
1103 }
1104 }
1105 /* if not preindexed, find with bioseq context */
1106 bcp = BioseqContextNew(bsp);
1107 sfp2 = BioseqContextGetSeqFeat(bcp, SEQFEAT_PROT, NULL, NULL, 0);
1108 BioseqContextFree(bcp);
1109 if (sfp2 != NULL)
1110 {
1111 prp = (ProtRefPtr)(sfp2->data.value.ptrvalue);
1112 goto protref;
1113 }
1114 }
1115 }
1116 if (grp != NULL &&
1117 ((grp->locus != NULL && grp->locus [0] != '\0') ||
1118 grp->allele != NULL || grp->desc != NULL ||
1119 grp->maploc != NULL || grp->locus_tag != NULL || grp->pseudo ||
1120 grp->db != NULL || grp->syn != NULL)) goto generef;
1121 break;
1122 case SEQFEAT_PROT:
1123 prp = (ProtRefPtr)(sfp->data.value.ptrvalue);
1124 protref: if (prp->name != NULL)
1125 label = (prp->name->data.ptrvalue);
1126 else if (prp->desc != NULL)
1127 label = (prp->desc);
1128 else if (prp->db != NULL)
1129 return DbtagLabel((DbtagPtr)(prp->db->data.ptrvalue), buf, buflen);
1130 break;
1131 case SEQFEAT_RNA:
1132 trrp = (RnaRefPtr)(sfp->data.value.ptrvalue);
1133 if (labeltype == OM_LABEL_CONTENT)
1134 {
1135 prefix = StringMove(tbuf, typelabel);
1136 StringMove(prefix, "-");
1137 prefix = tbuf;
1138 }
1139
1140 switch (trrp->ext.choice)
1141 {
1142 case 0:
1143 label = sfp->comment;
1144 if (label != NULL) { /* if RNA already in comment, skip it */
1145 if (StringStr(label, typelabel) != NULL)
1146 prefix = NULL;
1147 }
1148 else
1149 {
1150 prefix = NULL;
1151 label = typelabel;
1152 }
1153 break;
1154 case 1:
1155 label = (CharPtr)(trrp->ext.value.ptrvalue);
1156 if (StringCmp (label, "ncRNA") == 0 ||
1157 StringCmp (label, "tmRNA") == 0 ||
1158 StringCmp (label, "misc_RNA") == 0) {
1159 for (gbp = sfp->qual; gbp != NULL; gbp = gbp->next) {
1160 if (StringICmp ("product", gbp->qual) == 0) {
1161 label = gbp->val;
1162 break;
1163 }
1164 }
1165 }
1166 if (label != NULL) {
1167 if (StringStr(label, typelabel) != NULL)
1168 prefix = NULL;
1169 }
1170 else
1171 {
1172 prefix = NULL;
1173 label = typelabel;
1174 }
1175 break;
1176 case 2:
1177 trp = (tRNAPtr)(trrp->ext.value.ptrvalue);
1178 switch (trp->aatype)
1179 {
1180 case 1:
1181 aacode = Seq_code_iupacaa;
1182 break;
1183 case 2:
1184 aacode = Seq_code_ncbieaa;
1185 break;
1186 case 3:
1187 aacode = Seq_code_ncbi8aa;
1188 break;
1189 case 4:
1190 aacode = Seq_code_ncbistdaa;
1191 break;
1192 default:
1193 aacode = 0;
1194 break;
1195 }
1196 if (! aacode)
1197 break;
1198 sctp = SeqCodeTableFind(Seq_code_iupacaa3);
1199 if (sctp == NULL)
1200 {
1201 label = prefix;
1202 prefix = NULL;
1203 break;
1204 }
1205 if (aacode != Seq_code_ncbistdaa)
1206 {
1207 smtp = SeqMapTableFind(Seq_code_ncbistdaa, aacode);
1208 if (smtp == NULL)
1209 {
1210 label = prefix;
1211 prefix = NULL;
1212 break;
1213 }
1214 aacode = SeqMapTableConvert(smtp, trp->aa);
1215 } else {
1216 aacode = trp->aa;
1217 }
1218 if (aacode == 255) {
1219 if (trp->aatype == Seq_code_iupacaa || trp->aatype == Seq_code_ncbieaa) {
1220 if (trp->aa == 74) {
1221 aacode = 27; /* Xle */
1222 } else if (trp->aa == 79) {
1223 aacode = 26; /* Pyl */
1224 }
1225 }
1226 }
1227 if (aacode == 255) {
1228 label = prefix;
1229 prefix = NULL;
1230 break;
1231 }
1232 label = sctp->symbols[aacode - sctp->start_at];
1233 break;
1234 case 3:
1235 rgp = (RNAGenPtr) trrp->ext.value.ptrvalue;
1236 if (rgp != NULL) {
1237 if (StringDoesHaveText (rgp->product)) {
1238 label = rgp->product;
1239 } else if (StringDoesHaveText (rgp->_class)) {
1240 label = rgp->_class;
1241 }
1242 }
1243 break;
1244 default:
1245 break;
1246 }
1247 break; /* just return the type label for now */
1248 case SEQFEAT_PUB:
1249 pdp = (PubdescPtr)(sfp->data.value.ptrvalue);
1250 vn.choice = PUB_Equiv;
1251 vn.data.ptrvalue = pdp->pub;
1252 vn.next = NULL;
1253 return PubLabel(&vn, buf, buflen, OM_LABEL_CONTENT);
1254 case SEQFEAT_SEQ:
1255 break;
1256 case SEQFEAT_IMP:
1257 ifp = (ImpFeatPtr)(sfp->data.value.ptrvalue);
1258 if (! StringICmp("Site-ref", ifp->key))
1259 {
1260 if (sfp->cit != NULL)
1261 {
1262 first = TRUE;
1263 for (vnp = (ValNodePtr)(sfp->cit->data.ptrvalue);
1264 vnp != NULL; vnp = vnp->next)
1265 {
1266 if (! first)
1267 {
1268 diff = LabelCopy(buf, ",", buflen);
1269 buflen -= diff; buf += diff;
1270 }
1271 else
1272 first = FALSE;
1273 diff = PubLabel(vnp, buf, buflen, OM_LABEL_CONTENT);
1274 buflen -= diff; buf += diff;
1275 first = FALSE;
1276 }
1277 return (len - buflen);
1278 }
1279 }
1280 else if (labeltype == OM_LABEL_CONTENT) /* show key */
1281 {
1282 if (! StringICmp("CDS", ifp->key))
1283 label = "[CDS]";
1284 else if ((! StringICmp("repeat_unit", ifp->key)) ||
1285 (! StringICmp("repeat_region", ifp->key)))
1286 {
1287 for (gbp = sfp->qual; ((label == NULL) && (gbp != NULL)); gbp = gbp->next)
1288 {
1289 if (! StringICmp("rpt_family", gbp->qual))
1290 label = gbp->val;
1291 }
1292 if (label == NULL)
1293 label = typelabel;
1294 }
1295 else if (! StringICmp("STS", ifp->key))
1296 {
1297 for (gbp = sfp->qual; ((label == NULL) && (gbp != NULL)); gbp = gbp->next)
1298 {
1299 if (! StringICmp("standard_name", gbp->qual))
1300 label = gbp->val;
1301 }
1302 if (label == NULL && (! StringHasNoText (sfp->comment))) {
1303 StringNCpy_0 (snpbuf, sfp->comment, sizeof (snpbuf));
1304 ptr = StringChr (snpbuf, ';');
1305 if (ptr != NULL) {
1306 *ptr = '\0';
1307 }
1308 label = snpbuf;
1309 }
1310 if (label == NULL)
1311 label = typelabel;
1312 }
1313 else if (StringICmp("misc_feature", ifp->key)) {
1314 for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) {
1315 if (StringICmp ("standard_name", gbp->qual) == 0) {
1316 label = gbp->val;
1317 }
1318 }
1319 for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) {
1320 if (StringICmp ("function", gbp->qual) == 0) {
1321 label = gbp->val;
1322 }
1323 }
1324 for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) {
1325 if (StringICmp ("number", gbp->qual) == 0) {
1326 label = gbp->val;
1327 }
1328 }
1329 for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) {
1330 label = gbp->val;
1331 }
1332 if (label == NULL)
1333 label = typelabel;
1334 }
1335 }
1336 break;
1337 case SEQFEAT_REGION:
1338 label = (sfp->data.value.ptrvalue);
1339 if (StringICmp (label, "Domain") == 0 && sfp->comment != NULL) {
1340 label = sfp->comment;
1341 }
1342 break;
1343 case SEQFEAT_COMMENT:
1344 label = sfp->comment;
1345 break;
1346 case SEQFEAT_BOND:
1347 label = AsnEnumStr("SeqFeatData.bond",
1348 (Int2)(sfp->data.value.intvalue));
1349 break;
1350 case SEQFEAT_SITE:
1351 label = AsnEnumStr("SeqFeatData.site",
1352 (Int2)(sfp->data.value.intvalue));
1353 break;
1354 case SEQFEAT_RSITE:
1355 rrp = (RsiteRefPtr)(sfp->data.value.ptrvalue);
1356 if (rrp->choice == 1)
1357 label = (rrp->data.ptrvalue);
1358 else if (rrp->choice == 2) {
1359 /* return DbtagLabel((DbtagPtr)(rrp->data.ptrvalue), buf, buflen); */
1360 label = "?";
1361 dbt = (DbtagPtr) rrp->data.ptrvalue;
1362 if (dbt != NULL) {
1363 oip = dbt->tag;
1364 if (oip != NULL) {
1365 label = oip->str;
1366 }
1367 }
1368 }
1369 break;
1370 case SEQFEAT_USER:
1371 uop = (UserObjectPtr)(sfp->data.value.ptrvalue);
1372 label = (uop->_class);
1373 if (label == NULL) {
1374 oip = uop->type;
1375 if (oip != NULL) {
1376 label = oip->str;
1377 }
1378 }
1379 break;
1380 case SEQFEAT_TXINIT:
1381 break;
1382 case SEQFEAT_NUM:
1383 break;
1384 case SEQFEAT_PSEC_STR:
1385 label = AsnEnumStr("SeqFeatData.psec-str",
1386 (Int2)(sfp->data.value.intvalue));
1387 break;
1388 case SEQFEAT_NON_STD_RESIDUE:
1389 label = (sfp->data.value.ptrvalue);
1390 break;
1391 case SEQFEAT_HET:
1392 label = (sfp->data.value.ptrvalue);
1393 break;
1394 case SEQFEAT_BIOSRC:
1395 bsrcp = (BioSourcePtr)(sfp->data.value.ptrvalue);
1396 orp = bsrcp->org;
1397 goto orgref;
1398 case SEQFEAT_CLONEREF:
1399 break;
1400 default:
1401 break;
1402 }
1403
1404 if (label != NULL)
1405 return LabelCopyExtra (buf, label, buflen, prefix, suffix);
1406
1407 first = TRUE;
1408 diff = 1; /* just to make the first pass through loop work */
1409 for (gbp=sfp->qual; ((gbp != NULL) && (diff)); gbp = gbp->next)
1410 {
1411 if (first)
1412 prefix = (slash + 1);
1413 else
1414 prefix = slash;
1415 first = FALSE;
1416 diff = LabelCopyExtra (buf, gbp->qual, buflen, prefix, NULL);
1417 buflen -= diff;
1418 buf += diff;
1419 if (gbp->val != NULL)
1420 {
1421 prefix = "=";
1422 diff = LabelCopyExtra(buf, gbp->val, buflen, prefix, NULL);
1423 buflen -= diff;
1424 buf += diff;
1425 }
1426 }
1427
1428 if (sfp->comment != NULL)
1429 {
1430 if (! first)
1431 prefix = "; ";
1432 else
1433 prefix = NULL;
1434 diff = LabelCopyExtra(buf, sfp->comment, buflen, prefix, NULL);
1435 buflen -= diff;
1436 }
1437
1438 return (len - buflen);
1439 }
1440
1441 /*****************************************************************************
1442 *
1443 * FeatDefLabel(sfp, buf, buflen, type)
1444 * fills in buf with a content based label
1445 * if longer than buflen, makes the last visible char >
1446 * guarantees a '\0' at the end of the string
1447 *
1448 * NOTE: buf MUST be (buflen+1) long
1449 *
1450 * This function makes nicer labels since it can combine elements
1451 * returns length of string or 0 on failure
1452 *
1453 * type is OM_LABEL_TYPE_ defined in objmgr.h
1454 *
1455 *****************************************************************************/
1456 NLM_EXTERN Int2 LIBCALL FeatDefLabel (SeqFeatPtr sfp, CharPtr buf, Int2 buflen, Uint1 labeltype)
1457 {
1458 Int2 len, i, diff;
1459 CharPtr curr, typelabel, tmp;
1460 Char tbuf[40];
1461 ImpFeatPtr ifp;
1462 FeatDefPtr fdp;
1463 CharPtr suffix = NULL;
1464
1465 if ((sfp == NULL) || (buf == NULL) || (! buflen))
1466 return 0;
1467
1468 buf[0] = '\0';
1469 curr = buf;
1470 len = buflen;
1471
1472 if (FeatDefSetLoad() == NULL) return 0;
1473
1474 i = (Int2) FindFeatDefType(sfp);
1475 if (i != FEATDEF_BAD)
1476 {
1477 fdp = featdeflookup[i];
1478 if (fdp == NULL) return 0;
1479 typelabel = fdp->typelabel;
1480 if ((sfp->data.choice == SEQFEAT_IMP) &&
1481 (! StringCmp("CDS", typelabel)))
1482 {
1483 tmp = StringMove(tbuf, "[");
1484 tmp = StringMove(tmp, typelabel);
1485 tmp = StringMove(tmp, "]");
1486 typelabel = tbuf;
1487 } else if (sfp->data.choice == SEQFEAT_REGION &&
1488 StringICmp ((CharPtr) sfp->data.value.ptrvalue, "Domain") == 0 &&
1489 sfp->comment != NULL) {
1490 StringCpy (tbuf, "Domain");
1491 typelabel = tbuf;
1492 }
1493 }
1494 else
1495 {
1496 typelabel = tbuf;
1497 switch (sfp->data.choice)
1498 {
1499 case SEQFEAT_IMP:
1500 ifp = (ImpFeatPtr)(sfp->data.value.ptrvalue);
1501 tmp = StringMove(tbuf, "[");
1502 tmp = StringMove(tmp, ifp->key);
1503 tmp = StringMove(tmp, "]");
1504 break;
1505 default:
1506 sprintf(tbuf, "[Unknown=%d]", (int)(sfp->data.choice));
1507 break;
1508 }
1509 }
1510
1511 if ((labeltype == OM_LABEL_TYPE) || (labeltype == OM_LABEL_BOTH))
1512 {
1513 if (labeltype == OM_LABEL_BOTH)
1514 suffix = ": ";
1515 else
1516 suffix = NULL;
1517
1518 diff = LabelCopyExtra(curr, typelabel, buflen, NULL, suffix);
1519 curr += diff;
1520 buflen -= diff;
1521 }
1522
1523 if ((labeltype == OM_LABEL_TYPE) || (! buflen))
1524 return (len - buflen);
1525
1526 diff = FeatDefLabelContent (sfp, curr, buflen, labeltype, typelabel);
1527 buflen -= diff;
1528
1529 if ((! diff) && (labeltype == OM_LABEL_CONTENT))
1530 {
1531 buflen -= LabelCopy(curr, typelabel, buflen);
1532 }
1533
1534 return (len - buflen);
1535 }
1536
1537 /*****************************************************************************
1538 *
1539 * DispGroupNum()
1540 * returns number of display groups
1541 * returns 0 on failure
1542 * loads featdef.val if not already loaded
1543 *
1544 *****************************************************************************/
1545 NLM_EXTERN Int2 LIBCALL DispGroupNum(void)
1546 {
1547 FeatDefSetLoad();
1548 return numfdispg;
1549 }
1550
1551 /*****************************************************************************
1552 *
1553 * DispGroupFindNext(curr, groupptr, groupname)
1554 * returns display groups in order
1555 * start with curr=NULL, then return current in curr until function
1556 * returns NULL
1557 * loads featdef.val if necessary
1558 * groupptr is filled in with the key for the group, used
1559 * in FeatDefFindNext() below.
1560 * groupname points to the string naming the group
1561 *
1562 *****************************************************************************/
1563 NLM_EXTERN FeatDispGroupPtr LIBCALL DispGroupFindNext(FeatDispGroupPtr curr, Uint1Ptr groupptr, CharPtr PNTR groupname)
1564 {
1565 FeatDefSetLoad();
1566 if (curr == NULL)
1567 curr = featdgp;
1568 else
1569 curr = curr->next;
1570
1571 if (curr != NULL)
1572 {
1573 *groupptr = curr->groupkey;
1574 *groupname = curr->groupname;
1575 }
1576 return curr;
1577 }
1578
1579 /*****************************************************************************
1580 *
1581 * FeatDefNum()
1582 * returns total number of FeatDef
1583 * loads featdef.val if necessary
1584 *
1585 *****************************************************************************/
1586 NLM_EXTERN Int2 LIBCALL FeatDefNum(void)
1587 {
1588 FeatDefSetLoad();
1589 return numfdef;
1590 }
1591
1592 /*****************************************************************************
1593 *
1594 * FeatDefFindNext(curr, keyptr, menulabel, group, for_display)
1595 * returns next FeatDef within display group
1596 * if group == FEATDEF_ANY returns all
1597 * start with curr = NULL and return current in curr until function
1598 * returns NULL
1599 * keyptr is filled in with featdef-key
1600 * menulabel is filled in with menulabel
1601 * if for_display == TRUE then group must match display group
1602 * else group must match entrygroup
1603 * loads featdef.val if necessary
1604 *
1605 *****************************************************************************/
1606 NLM_EXTERN FeatDefPtr LIBCALL FeatDefFindNext (FeatDefPtr curr, Uint1Ptr keyptr,
1607 CharPtr PNTR menulabel, Uint1 group, Boolean for_display)
1608 {
1609 FeatDefSetLoad();
1610 if (curr == NULL)
1611 curr = featdefp;
1612 else
1613 curr = curr->next;
1614
1615 if ((group == FEATDEF_ANY) && (curr != NULL))
1616 {
1617 *keyptr = curr->featdef_key;
1618 *menulabel = curr->menulabel;
1619 return curr;
1620 }
1621
1622 while (curr != NULL)
1623 {
1624 if (for_display)
1625 {
1626 if (group == curr->displaygroup)
1627 {
1628 *keyptr = curr->featdef_key;
1629 *menulabel = curr->menulabel;
1630 return curr;
1631 }
1632 }
1633 else
1634 {
1635 if (group == curr->entrygroup)
1636 {
1637 *keyptr = curr->featdef_key;
1638 *menulabel = curr->menulabel;
1639 return curr;
1640 }
1641 }
1642 curr = curr->next;
1643 }
1644 return curr;
1645 }
1646
1647 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |