1 /*  objfeat.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:  objfeat.c
27 *
28 * Author:  James Ostell
29 *
30 * Version Creation Date: 4/1/91
31 *
32 * $Revision: 6.82 $
33 *
34 * File Description:  Object manager for module NCBI-SeqFeat
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date       Name        Description of modification
39 * -------  ----------  -----------------------------------------------------
40 *
41 * ==========================================================================
42 */
43 
44 /** for ErrPostEx() ****/
45 
46 static char *this_module = "ncbiobj";
47 #define THIS_MODULE this_module
48 static char *this_file = __FILE__;
49 #define THIS_FILE this_file
50 
51 /**********************/
52 
53 #include <objfeat.h>           /* the features interface */
54 #include <asnfeat.h>        /* the AsnTool header */
55 #include <objmgr.h>
56 #include <objfdef.h>
57 #include <objseq.h>
58 
59 static Boolean loaded = FALSE;
60 
61 /*****************************************************************************
62 *
63 *   SeqFeat ObjMgr Routines
64 *
65 *****************************************************************************/
SeqFeatNewFunc(void)66 static Pointer LIBCALLBACK SeqFeatNewFunc (void)
67 {
68     return (Pointer) SeqFeatNew();
69 }
70 
SeqFeatFreeFunc(Pointer data)71 static Pointer LIBCALLBACK SeqFeatFreeFunc (Pointer data)
72 {
73     return (Pointer) SeqFeatFree ((SeqFeatPtr) data);
74 }
75 
SeqFeatAsnWriteFunc(Pointer data,AsnIoPtr aip,AsnTypePtr atp)76 static Boolean LIBCALLBACK SeqFeatAsnWriteFunc (Pointer data, AsnIoPtr aip, AsnTypePtr atp)
77 {
78     return SeqFeatAsnWrite((SeqFeatPtr)data, aip, atp);
79 }
80 
SeqFeatAsnReadFunc(AsnIoPtr aip,AsnTypePtr atp)81 static Pointer LIBCALLBACK SeqFeatAsnReadFunc (AsnIoPtr aip, AsnTypePtr atp)
82 {
83     return (Pointer) SeqFeatAsnRead (aip, atp);
84 }
85 
SeqFeatLabelFunc(Pointer data,CharPtr buffer,Int2 buflen,Uint1 content)86 static Int2 LIBCALLBACK SeqFeatLabelFunc ( Pointer data, CharPtr buffer, Int2 buflen, Uint1 content)
87 {
88     Int2 rsult = 0;
89 
90     switch (content)
91     {
92         case OM_LABEL_TYPE:
93         case OM_LABEL_CONTENT:
94         case OM_LABEL_BOTH:
95             rsult = FeatDefLabel((SeqFeatPtr)data, buffer, buflen, content);
96             break;
97         case OM_LABEL_SUMMARY:
98         default:
99             rsult = FeatDefLabel((SeqFeatPtr)data, buffer, buflen, OM_LABEL_BOTH);
100             break;
101     }
102     return rsult;
103 }
104 
SeqFeatSubTypeFunc(Pointer ptr)105 static Uint2 LIBCALLBACK SeqFeatSubTypeFunc (Pointer ptr)
106 {
107     if (ptr == NULL)
108         return 0;
109     return (Uint2)FindFeatDefType((SeqFeatPtr)ptr);
110 }
111 
112 /*****************************************************************************
113 *
114 *   SeqFeatAsnLoad()
115 *      requires SeqAsnLoad() to be called first
116 *
117 *****************************************************************************/
SeqFeatAsnLoad(void)118 NLM_EXTERN Boolean LIBCALL SeqFeatAsnLoad (void)
119 {
120     if (loaded)
121         return TRUE;
122     loaded = TRUE;
123 
124     if (! GeneralAsnLoad())
125     {
126         loaded = FALSE;
127         return FALSE;
128     }
129     if (! SeqLocAsnLoad())      /* SeqLoc refers to Seqfeat and vice versa */
130     {
131         loaded = FALSE;
132         return FALSE;
133     }
134     if (! PubAsnLoad())
135     {
136         loaded = FALSE;
137         return FALSE;
138     }
139     if ( ! AsnLoad())
140     {
141         loaded = FALSE;
142         return FALSE;
143     }
144 
145     ObjMgrTypeLoad(OBJ_SEQFEAT, "Seq-feat", "SeqFeat", "Sequence Feature",
146         SEQ_FEAT, SeqFeatNewFunc, SeqFeatAsnReadFunc, SeqFeatAsnWriteFunc,
147         SeqFeatFreeFunc, SeqFeatLabelFunc, SeqFeatSubTypeFunc);
148 
149     return TRUE;
150 }
151 
152 /*****************************************************************************
153 *
154 *   SeqFeat Routines
155 *
156 *****************************************************************************/
157 /*****************************************************************************
158 *
159 *   SeqFeatNew()
160 *
161 *****************************************************************************/
SeqFeatNew(void)162 NLM_EXTERN SeqFeatPtr LIBCALL SeqFeatNew (void)
163 {
164     return (SeqFeatPtr)MemNew(sizeof(SeqFeat));
165 }
166 
167 /*****************************************************************************
168 *
169 *   SeqFeatFree(sfp)
170 *       Frees one SeqFeat and associated data
171 *
172 *****************************************************************************/
SeqFeatFree(SeqFeatPtr sfp)173 NLM_EXTERN SeqFeatPtr LIBCALL SeqFeatFree (SeqFeatPtr sfp)
174 {
175     ValNodePtr vnp, next=NULL;
176   UserObjectPtr uop, unp = NULL;
177 
178     if (sfp == NULL)
179         return (SeqFeatPtr)NULL;
180 
181     SeqFeatIdFree(&sfp->id);
182     SeqFeatDataFree(&sfp->data);
183     MemFree(sfp->title);
184     MemFree(sfp->comment);
185     UserObjectFree(sfp->ext);
186     SeqLocFree(sfp->product);
187     SeqLocFree(sfp->location);
188     GBQualFree(sfp->qual);
189     PubSetFree(sfp->cit);
190     SeqFeatXrefFree(sfp->xref);
191     for (vnp = sfp->dbxref; vnp != NULL; vnp = next)
192     {
193         next = vnp->next;
194         DbtagFree((DbtagPtr)(vnp->data.ptrvalue));
195         MemFree(vnp);
196     }
197     MemFree(sfp->except_text);
198     for (vnp = sfp->ids; vnp != NULL; vnp = next)
199     {
200         next = vnp->next;
201         SeqFeatIdFree((ChoicePtr)(vnp->data.ptrvalue));
202         MemFree(vnp);
203     }
204     /*
205     AsnGenericChoiceSeqOfFree (sfp->ids, (AsnOptFreeFunc) SeqFeatIdFree);
206     */
207     for (uop = sfp->exts; uop != NULL; uop = unp)
208     {
209         unp = uop->next;
210         UserObjectFree(uop);
211     }
212     /*
213     AsnGenericUserSeqOfFree (sfp->exts, (AsnOptFreeFunc) UserObjectFree);
214     */
215     SeqFeatSupportFree (sfp->support);
216 
217     ObjMgrDelete(OBJ_SEQFEAT, (Pointer)sfp);
218 
219     return (SeqFeatPtr)MemFree(sfp);
220 }
221 
222 /*****************************************************************************
223 *
224 *   SeqFeatAsnWrite(sfp, aip, atp)
225 *       atp is the current type (if identifier of a parent struct)
226 *       if atp == NULL, then assumes it stands alone (SeqFeat ::=)
227 *
228 *****************************************************************************/
SeqFeatAsnWrite(SeqFeatPtr sfp,AsnIoPtr aip,AsnTypePtr orig)229 NLM_EXTERN Boolean LIBCALL SeqFeatAsnWrite (SeqFeatPtr sfp, AsnIoPtr aip, AsnTypePtr orig)
230 {
231     DataVal av;
232     AsnTypePtr atp;
233     GBQualPtr gbp;
234     Boolean retval = FALSE;
235     SeqFeatXrefPtr sfxp;
236     ValNodePtr vnp;
237   UserObjectPtr uop;
238 
239     if (! loaded)
240     {
241         if (! SeqFeatAsnLoad())
242             return FALSE;
243     }
244 
245     if (aip == NULL)
246         return FALSE;
247 
248     atp = AsnLinkType(orig, SEQ_FEAT);   /* link local tree */
249     if (atp == NULL)
250         return FALSE;
251 
252     if (sfp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
253 
254     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
255 
256     if (! AsnOpenStruct(aip, atp, (Pointer)sfp))
257         goto erret;
258 
259     if (sfp->id.choice)              /* feat-id present */
260     {
261         if (! SeqFeatIdAsnWrite(&sfp->id, aip, SEQ_FEAT_id))
262             goto erret;
263     }
264 
265     if (! SeqFeatDataAsnWrite(&sfp->data, aip, SEQ_FEAT_data)) goto erret;
266 
267 
268     av.boolvalue = TRUE;
269     if (sfp->partial)
270     {
271         if (! AsnWrite(aip, SEQ_FEAT_partial, &av)) goto erret;
272     }
273     if (sfp->excpt)
274     {
275         if (! AsnWrite(aip, SEQ_FEAT_except, &av)) goto erret;
276     }
277     if (sfp->comment != NULL)
278     {
279         av.ptrvalue = sfp->comment;
280         if (! AsnWrite(aip, SEQ_FEAT_comment, &av)) goto erret;
281     }
282     if (sfp->product != NULL)
283     {
284         if (! SeqLocAsnWrite(sfp->product, aip, SEQ_FEAT_product))
285             goto erret;
286     }
287     if (sfp->location != NULL)
288     {
289         if (! SeqLocAsnWrite(sfp->location, aip, SEQ_FEAT_location))
290             goto erret;
291     }
292     if (sfp->qual != NULL)
293     {                                  /* SEQUENCE OF */
294         if (! AsnOpenStruct(aip, SEQ_FEAT_qual, (Pointer)sfp->qual))
295             goto erret;
296         gbp = sfp->qual;
297         while (gbp != NULL)
298         {
299             if (! GBQualAsnWrite(gbp, aip, SEQ_FEAT_qual_E))
300                 goto erret;
301             gbp = gbp->next;
302         }
303         if (! AsnCloseStruct(aip, SEQ_FEAT_qual, (Pointer)sfp->qual))
304             goto erret;
305     }
306     if (sfp->title != NULL)
307     {
308         av.ptrvalue = (Pointer) sfp->title;
309         if (! AsnWrite(aip, SEQ_FEAT_title, &av)) goto erret;
310     }
311     if (sfp->ext != NULL)
312     {
313         if (! UserObjectAsnWrite(sfp->ext, aip, SEQ_FEAT_ext))
314             goto erret;
315     }
316 
317     if (sfp->cit != NULL)
318     {
319         if (! PubSetAsnWrite(sfp->cit, aip, SEQ_FEAT_cit))
320             goto erret;
321     }
322 
323     if (sfp->exp_ev)
324     {
325         av.intvalue = (Int4)sfp->exp_ev;
326         if (! AsnWrite(aip, SEQ_FEAT_exp_ev, &av)) goto erret;
327     }
328 
329     if (sfp->xref != NULL)
330     {
331         if (! AsnOpenStruct(aip, SEQ_FEAT_xref, (Pointer)sfp->xref))
332             goto erret;
333         sfxp = sfp->xref;
334         while (sfxp != NULL)
335         {
336             if (! SeqFeatXrefAsnWrite(sfxp, aip, SEQ_FEAT_xref_E))
337                 goto erret;
338             sfxp = sfxp->next;
339         }
340         if (! AsnCloseStruct(aip, SEQ_FEAT_xref, (Pointer)sfp->xref))
341             goto erret;
342     }
343 
344     if (sfp->dbxref != NULL)
345     {
346         if (! AsnOpenStruct(aip, SEQ_FEAT_dbxref, (Pointer)sfp->dbxref))
347             goto erret;
348         vnp = sfp->dbxref;
349         while (vnp != NULL)
350         {
351             if (! DbtagAsnWrite((DbtagPtr)(vnp->data.ptrvalue), aip, SEQ_FEAT_dbxref_E))
352                 goto erret;
353             vnp = vnp->next;
354         }
355         if (! AsnCloseStruct(aip, SEQ_FEAT_dbxref, (Pointer)sfp->dbxref))
356             goto erret;
357     }
358     if (sfp->pseudo)
359     {
360         av.boolvalue = TRUE;
361         if ((aip->spec_version == 0) || (aip->spec_version >= 6))
362         {
363         if (! AsnWrite(aip, SEQ_FEAT_pseudo, &av)) goto erret;
364         }
365     }
366     if (sfp->except_text != NULL)
367     {
368         av.ptrvalue = sfp->except_text;
369         if ((aip->spec_version == 0) || (aip->spec_version >= 6))
370         {
371         if (! AsnWrite(aip, SEQ_FEAT_except_text, &av)) goto erret;
372         }
373     }
374     if (sfp->ids != NULL)
375     {
376         if (! AsnOpenStruct(aip, SEQ_FEAT_ids, (Pointer)sfp->ids))
377             goto erret;
378         vnp = sfp->ids;
379         while (vnp != NULL)
380         {
381             if (! SeqFeatIdAsnWrite((ChoicePtr)(vnp->data.ptrvalue), aip, SEQ_FEAT_ids_E))
382                 goto erret;
383             vnp = vnp->next;
384         }
385         if (! AsnCloseStruct(aip, SEQ_FEAT_ids, (Pointer)sfp->ids))
386             goto erret;
387         /*
388         AsnGenericChoiceSeqOfAsnWrite (sfp->ids, (AsnWriteFunc) SeqFeatIdAsnWrite, aip, SEQ_FEAT_ids, SEQ_FEAT_ids_E);
389         */
390     }
391     if (sfp->exts != NULL)
392     {
393         if (! AsnOpenStruct(aip, SEQ_FEAT_exts, (Pointer)sfp->exts))
394             goto erret;
395         uop = sfp->exts;
396         while (uop != NULL)
397         {
398             if (! UserObjectAsnWrite(uop, aip, SEQ_FEAT_exts_E))
399                 goto erret;
400             uop = uop->next;
401         }
402         if (! AsnCloseStruct(aip, SEQ_FEAT_exts, (Pointer)sfp->exts))
403             goto erret;
404         /*
405         AsnGenericUserSeqOfAsnWrite (sfp->exts, (AsnWriteFunc) UserObjectAsnWrite, aip, SEQ_FEAT_exts, SEQ_FEAT_exts_E);
406         */
407     }
408     if (sfp->support != NULL)
409     {
410         if (! SeqFeatSupportAsnWrite(sfp->support, aip, SEQ_FEAT_support))
411             goto erret;
412     }
413     if (! AsnCloseStruct(aip, atp, (Pointer)sfp))
414         goto erret;
415     retval = TRUE;
416 erret:
417     AsnUnlinkType(orig);       /* unlink local tree */
418     return retval;
419 }
420 
421 /*****************************************************************************
422 *
423 *   SeqFeatAsnRead(aip, atp)
424 *       atp is the current type (if identifier of a parent struct)
425 *            assumption is readIdent has occurred
426 *       if atp == NULL, then assumes it stands alone and read ident
427 *            has not occurred.
428 *
429 *****************************************************************************/
SeqFeatAsnRead(AsnIoPtr aip,AsnTypePtr orig)430 NLM_EXTERN SeqFeatPtr LIBCALL SeqFeatAsnRead (AsnIoPtr aip, AsnTypePtr orig)
431 {
432     DataVal av;
433     AsnTypePtr atp, oldtype;
434     SeqFeatPtr sfp;
435     GBQualPtr gbq, gbqlast = NULL;
436     SeqFeatXrefPtr sfxp, sfxplast = NULL;
437     ValNodePtr vnp, vnplast = NULL;
438     DbtagPtr dbtp;
439   Choice id;
440   ChoicePtr cp;
441     UserObjectPtr  uop, last = NULL;
442 
443     if (! loaded)
444     {
445         if (! SeqFeatAsnLoad())
446             return (SeqFeatPtr)NULL;
447     }
448 
449     if (aip == NULL)
450         return (SeqFeatPtr)NULL;
451 
452     if (orig == NULL)           /* SeqFeat ::= (self contained) */
453         atp = AsnReadId(aip, amp, SEQ_FEAT);
454     else
455         atp = AsnLinkType(orig, SEQ_FEAT);    /* link in local tree */
456     oldtype = atp;
457     if (atp == NULL)
458         return (SeqFeatPtr)NULL;
459 
460     sfp = SeqFeatNew();
461     if (sfp == NULL)
462         goto erret;
463 
464     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
465     while ((atp = AsnReadId(aip, amp, atp)) != oldtype)
466     {
467         if (atp == NULL)
468             goto erret;
469         if (atp == SEQ_FEAT_id)
470         {
471             if (! SeqFeatIdAsnRead(aip, atp, &sfp->id))
472                 goto erret;
473         }
474         else if (atp == SEQ_FEAT_data)
475         {
476             if (! SeqFeatDataAsnRead(aip, atp, &sfp->data))
477                 goto erret;
478         }
479         else if (atp == SEQ_FEAT_product)
480         {
481             sfp->product = SeqLocAsnRead(aip, atp);
482             if (sfp->product == NULL) goto erret;
483         }
484         else if (atp == SEQ_FEAT_location)
485         {
486             sfp->location = SeqLocAsnRead(aip, atp);
487             if (sfp->location == NULL) goto erret;
488         }
489         else if (atp == SEQ_FEAT_qual_E)
490         {
491             gbq = GBQualAsnRead(aip, atp);
492             if (gbq == NULL) goto erret;
493             if (gbqlast == NULL)
494                 sfp->qual = gbq;
495             else
496                 gbqlast->next = gbq;
497             gbqlast = gbq;
498         }
499         else if (atp == SEQ_FEAT_ext)
500         {
501             sfp->ext = UserObjectAsnRead(aip, atp);
502             if (sfp->ext == NULL)
503                 goto erret;
504         }
505         else if (atp == SEQ_FEAT_cit)
506         {
507             sfp->cit = PubSetAsnRead(aip, atp);
508             if (sfp->cit == NULL)
509                 goto erret;
510         }
511         else if (atp == SEQ_FEAT_xref_E)
512         {
513             sfxp = SeqFeatXrefAsnRead(aip, atp);
514             if (sfxp == NULL) goto erret;
515             if (sfxplast == NULL)
516                 sfp->xref = sfxp;
517             else
518                 sfxplast->next = sfxp;
519             sfxplast = sfxp;
520         }
521         else if (atp == SEQ_FEAT_dbxref_E)
522         {
523             dbtp = DbtagAsnRead(aip, atp);
524             if (dbtp == NULL) goto erret;
525             vnp = ValNodeNew(vnplast);
526             if (vnplast == NULL)
527                 sfp->dbxref = vnp;
528             vnplast = vnp;
529             vnp->data.ptrvalue = (Pointer)dbtp;
530         }
531         else if (atp == SEQ_FEAT_ids)
532         {
533         atp = AsnLinkType (SEQ_FEAT_ids, FEAT_ID);
534         if (atp == NULL) goto erret;
535         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the SEQUENCE */
536             while ((atp = AsnReadId(aip, amp, atp)) == SEQ_FEAT_ids_E) {
537                 if (! SeqFeatIdAsnRead(aip, atp, &id))
538                     goto erret;
539                 cp = (ChoicePtr) MemNew (sizeof (Choice));
540                 if (cp == NULL) goto erret;
541                 cp->choice = id.choice;
542                 if (id.choice == 1) {
543                     cp->value.intvalue = id.value.intvalue;
544                 } else {
545                     cp->value.ptrvalue = id.value.ptrvalue;
546                 }
547                 ValNodeAddPointer (&(sfp->ids), 0, (Pointer) cp);
548             }
549         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the END STRUCT */
550         AsnUnlinkType (SEQ_FEAT_ids);
551             /*
552             sfp->ids = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqFeatIdAsnRead, (AsnOptFreeFunc) SeqFeatIdFree);
553             if (isError && sfp->ids == NULL) {
554                 goto erret;
555             }
556             */
557         }
558         else if (atp == SEQ_FEAT_exts)
559         {
560             atp = AsnLinkType (SEQ_FEAT_exts, FEAT_ID);
561             if (atp == NULL) goto erret;
562             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the SEQUENCE */
563                 while ((atp = AsnReadId(aip, amp, atp)) == SEQ_FEAT_exts_E) {
564                 uop = UserObjectAsnRead (aip, atp);
565                 if (uop == NULL) goto erret;
566                 if (last != NULL) {
567                   last->next = uop;
568                 }
569                 if (sfp->exts == NULL) {
570                   sfp->exts = uop;
571                 }
572                 last = uop;
573             }
574             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the END STRUCT */
575             AsnUnlinkType (SEQ_FEAT_exts);
576             /*
577             sfp->exts = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) UserObjectAsnRead, (AsnOptFreeFunc) UserObjectFree);
578             if (isError && sfp->exts == NULL) {
579                 goto erret;
580             }
581             */
582         }
583         else if (atp == SEQ_FEAT_support)
584         {
585             sfp->support = SeqFeatSupportAsnRead(aip, atp);
586             if (sfp->support == NULL)
587                 goto erret;
588         }
589         else
590         {
591             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
592             if (atp == SEQ_FEAT_partial)
593                 sfp->partial = av.boolvalue;
594             else if (atp == SEQ_FEAT_except)
595                 sfp->excpt = av.boolvalue;
596             else if (atp == SEQ_FEAT_comment)
597                 sfp->comment = (CharPtr) av.ptrvalue;
598             else if (atp == SEQ_FEAT_title)
599                 sfp->title = (CharPtr) av.ptrvalue;
600             else if (atp == SEQ_FEAT_exp_ev)
601                 sfp->exp_ev = (Uint1) av.intvalue;
602             else if (atp == SEQ_FEAT_pseudo)
603                 sfp->pseudo = av.boolvalue;
604             else if (atp == SEQ_FEAT_except_text)
605                 sfp->except_text = (CharPtr)(av.ptrvalue);
606         }
607     }
608     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
609 ret:
610     AsnUnlinkType(orig);       /* unlink local tree */
611     return sfp;
612 erret:
613     aip->io_failure = TRUE;
614     sfp = SeqFeatFree(sfp);
615     goto ret;
616 }
617 
618 /*****************************************************************************
619 *
620 *   SeqFeatSetAsnWrite(sfp, aip, set, element)
621 *
622 *****************************************************************************/
SeqFeatSetAsnWrite(SeqFeatPtr sfp,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)623 NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWrite (SeqFeatPtr sfp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
624 {
625     return SeqFeatSetAsnWriteExtra(sfp, aip, set, element, (ValNodePtr) NULL);
626 }
627 
628 /*****************************************************************************
629 *
630 *   SeqFeatSetAsnWriteExtra(sfp, aip, set, element, extras)
631 *      this is to accomodate extra features from SeqEntryAsnOut()
632 *
633 *****************************************************************************/
SeqFeatSetAsnWriteExtra(SeqFeatPtr sfp,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element,ValNodePtr extras)634 NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWriteExtra (SeqFeatPtr sfp, AsnIoPtr aip,
635                     AsnTypePtr set, AsnTypePtr element, ValNodePtr extras)
636 {
637     AsnTypePtr atp;
638     SeqFeatPtr oldsfp, tsfp;
639     Boolean retval = FALSE;
640     Int2 ctr = 0;
641 
642     if (! loaded)
643     {
644         if (! SeqFeatAsnLoad())
645             return FALSE;
646     }
647 
648     if (aip == NULL)
649         return FALSE;
650 
651     atp = AsnLinkType(element, SEQ_FEAT);   /* link local tree */
652     if (atp == NULL)
653         return FALSE;
654 
655     oldsfp = sfp;
656     if (extras != NULL)   /* this is an extra set of feats */
657         oldsfp = (SeqFeatPtr)(extras->data.ptrvalue);
658 
659     if (! AsnOpenStruct(aip, set, (Pointer)oldsfp))
660         goto erret;
661 
662     while (sfp != NULL)
663     {
664         if (! SeqFeatAsnWrite(sfp, aip, atp))
665             goto erret;
666         sfp = sfp->next;
667         ctr++;
668         if (ctr == 20)
669         {
670             if (! ProgMon("Write SeqFeat"))
671                 goto erret;
672             ctr = 0;
673         }
674 
675     }
676 
677     while (extras != NULL)
678     {
679     tsfp = (SeqFeatPtr)(extras->data.ptrvalue);
680     if (! SeqFeatAsnWrite(tsfp, aip, atp))
681         goto erret;
682     extras = extras->next;
683     }
684 
685     if (! AsnCloseStruct(aip, set, (Pointer)oldsfp))
686         goto erret;
687     retval = TRUE;
688 erret:
689     AsnUnlinkType(element);       /* unlink local tree */
690     return retval;
691 }
692 
693 /*****************************************************************************
694 *
695 *   SeqFeatSetAsnRead(aip, set, element)
696 *
697 *****************************************************************************/
SeqFeatSetAsnRead(AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)698 NLM_EXTERN SeqFeatPtr LIBCALL SeqFeatSetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
699 {
700     DataVal av;
701     AsnTypePtr atp;
702     SeqFeatPtr sfp, curr = NULL, first = NULL;
703     Int2 ctr = 0;
704 
705     if (aip == NULL)
706         return (SeqFeatPtr)NULL;
707 
708     AsnLinkType(element, SEQ_FEAT);    /* link in local tree */
709     atp = set;
710 
711     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
712     while ((atp = AsnReadId(aip, amp, atp)) == element)
713     {
714         sfp = SeqFeatAsnRead(aip, atp);
715         if (sfp == NULL)
716             goto erret;
717         if (first == NULL)
718             first = sfp;
719         else
720             curr->next = sfp;
721         curr = sfp;
722         ctr++;
723         if (ctr == 20)
724         {
725             if (! ProgMon("Read SeqFeat"))
726                 goto erret;
727             ctr = 0;
728         }
729 
730     }
731     if (atp == NULL)
732         goto erret;
733     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
734     if (first == NULL)
735         ErrPostEx(SEV_WARNING, 0, 0, "Empty SET OF Seq-feat. line %ld", (long) aip->linenumber);
736 ret:
737     AsnUnlinkType(element);       /* unlink local tree */
738     return first;
739 erret:
740     while (first != NULL)
741     {
742         curr = first;
743         first = curr->next;
744         SeqFeatFree(curr);
745     }
746     goto ret;
747 }
748 
749 /*****************************************************************************
750 *
751 *   SeqFeatDataFree(cp)
752 *
753 *****************************************************************************/
SeqFeatDataFree(ChoicePtr cp)754 NLM_EXTERN void LIBCALL SeqFeatDataFree(ChoicePtr cp)
755 {
756     Pointer pnt;
757 
758     pnt = cp->value.ptrvalue;
759     switch (cp->choice)
760     {
761         case SEQFEAT_GENE :
762             GeneRefFree((GeneRefPtr)pnt);
763             break;
764         case SEQFEAT_ORG :
765             OrgRefFree((OrgRefPtr)pnt);
766             break;
767         case SEQFEAT_CDREGION :
768             CdRegionFree((CdRegionPtr)pnt);
769             break;
770         case SEQFEAT_PROT :
771             ProtRefFree((ProtRefPtr)pnt);
772             break;
773         case SEQFEAT_RNA :
774             RnaRefFree((RnaRefPtr)pnt);
775             break;
776         case SEQFEAT_PUB :
777             PubdescFree((PubdescPtr)pnt);
778             break;
779         case SEQFEAT_SEQ :         /* seq */
780             SeqLocFree((ValNodePtr)pnt);
781             break;
782         case SEQFEAT_IMP :
783             ImpFeatFree((ImpFeatPtr)pnt);
784             break;
785         case SEQFEAT_REGION:        /* region */
786         case SEQFEAT_NON_STD_RESIDUE :       /* non-std residue */
787         case SEQFEAT_HET:       /* heterogen */
788             MemFree(pnt);
789             break;
790         case SEQFEAT_COMMENT:       /* comment - nothing */
791         case SEQFEAT_BOND:       /* bond - int */
792         case SEQFEAT_SITE:       /* site - int */
793         case SEQFEAT_PSEC_STR:       /* psec_struct - int */
794             break;
795         case SEQFEAT_RSITE:
796             RsiteRefFree((RsiteRefPtr)pnt);
797             break;
798         case SEQFEAT_USER:
799             UserObjectFree((UserObjectPtr)pnt);
800             break;
801         case SEQFEAT_TXINIT:
802             TxinitFree((TxinitPtr)pnt);
803             break;
804         case SEQFEAT_NUM:
805             NumberingFree((NumberingPtr)pnt);
806             break;
807         case SEQFEAT_BIOSRC:
808             BioSourceFree((BioSourcePtr)pnt);
809             break;
810         case SEQFEAT_CLONEREF:
811             CloneRefFree((CloneRefPtr)pnt);
812             break;
813         case SEQFEAT_VARIATIONREF:
814             VariationRefFree((VariationRefPtr)pnt);
815             break;
816     }
817     return;
818 }
819 
820 /*****************************************************************************
821 *
822 *   SeqFeatDataAsnWrite(cp, aip, atp)
823 *       atp is the current type (if identifier of a parent struct)
824 *       if atp == NULL, then assumes it stands alone (SeqFeatData ::=)
825 *
826 *****************************************************************************/
SeqFeatDataAsnWrite(ChoicePtr cp,AsnIoPtr aip,AsnTypePtr orig)827 NLM_EXTERN Boolean LIBCALL SeqFeatDataAsnWrite (ChoicePtr cp, AsnIoPtr aip, AsnTypePtr orig)
828 {
829     DataVal av;
830     Pointer pnt;
831     AsnTypePtr atp;
832     Boolean retval = FALSE;
833 
834     if (! loaded)
835     {
836         if (! SeqFeatAsnLoad())
837             return FALSE;
838     }
839 
840     if (aip == NULL)
841         return FALSE;
842 
843     atp = AsnLinkType(orig, SEQFEATDATA);   /* link local tree */
844     if (atp == NULL)
845         return FALSE;
846 
847     if (cp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
848 
849     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
850 
851     pnt = cp->value.ptrvalue;
852     av.ptrvalue = pnt;
853     if (! AsnWriteChoice(aip, atp, (Int2)cp->choice, &av)) goto erret;
854 
855     switch (cp->choice)
856     {
857         case SEQFEAT_GENE :
858             if (! GeneRefAsnWrite((GeneRefPtr)pnt, aip, SEQFEATDATA_gene))
859                 goto erret;
860             break;
861         case SEQFEAT_ORG :
862             if (! OrgRefAsnWrite((OrgRefPtr)pnt, aip, SEQFEATDATA_org))
863                 goto erret;
864             break;
865         case SEQFEAT_CDREGION :
866             if (! CdRegionAsnWrite((CdRegionPtr)pnt, aip, SEQFEATDATA_cdregion))
867                 goto erret;
868             break;
869         case SEQFEAT_PROT :
870             if (! ProtRefAsnWrite((ProtRefPtr)pnt, aip, SEQFEATDATA_prot))
871                 goto erret;
872             break;
873         case SEQFEAT_RNA :
874             if (! RnaRefAsnWrite((RnaRefPtr)pnt, aip, SEQFEATDATA_rna))
875                 goto erret;
876             break;
877         case SEQFEAT_PUB:
878             if (! PubdescAsnWrite((PubdescPtr)pnt, aip, SEQFEATDATA_pub))
879                 goto erret;
880             break;
881         case SEQFEAT_SEQ:         /* seq reference */
882             if (! SeqLocAsnWrite((ValNodePtr)pnt, aip, SEQFEATDATA_seq))
883                 goto erret;
884             break;
885         case SEQFEAT_IMP:
886             if (! ImpFeatAsnWrite((ImpFeatPtr)pnt, aip, SEQFEATDATA_imp))
887                 goto erret;
888             break;
889         case SEQFEAT_REGION:        /* region */
890             av.ptrvalue = pnt;
891             if (! AsnWrite(aip, SEQFEATDATA_region, &av)) goto erret;
892             break;
893         case SEQFEAT_COMMENT:       /* comment - nothing */
894             if (! AsnWrite(aip, SEQFEATDATA_comment, &av)) goto erret;
895             break;
896         case SEQFEAT_BOND:       /* bond - int */
897             av.intvalue = cp->value.intvalue;
898             if (! AsnWrite(aip, SEQFEATDATA_bond, &av)) goto erret;
899             break;
900         case SEQFEAT_SITE:       /* site - int */
901             av.intvalue = cp->value.intvalue;
902             if (! AsnWrite(aip, SEQFEATDATA_site, &av)) goto erret;
903             break;
904         case SEQFEAT_RSITE:       /* rsite-ref */
905             if (! RsiteRefAsnWrite((RsiteRefPtr)pnt, aip, SEQFEATDATA_rsite))
906                 goto erret;
907             break;
908         case SEQFEAT_USER:       /* user object */
909             if (! UserObjectAsnWrite((UserObjectPtr)pnt, aip, SEQFEATDATA_user))
910                 goto erret;
911             break;
912         case SEQFEAT_TXINIT:
913             if (! TxinitAsnWrite((TxinitPtr)pnt, aip, SEQFEATDATA_txinit))
914                 goto erret;
915             break;
916         case SEQFEAT_NUM:
917             if (! NumberingAsnWrite((NumberingPtr)pnt, aip, SEQFEATDATA_num))
918                 goto erret;
919             break;
920         case SEQFEAT_PSEC_STR:       /* psec-struct - int */
921             av.intvalue = cp->value.intvalue;
922             if (! AsnWrite(aip, SEQFEATDATA_psec_str, &av)) goto erret;
923             break;
924         case SEQFEAT_NON_STD_RESIDUE:        /* non-std residue */
925             av.ptrvalue = pnt;
926             if (! AsnWrite(aip, SEQFEATDATA_non_std_residue, &av)) goto erret;
927             break;
928         case SEQFEAT_HET:        /* heterogen */
929             av.ptrvalue = pnt;
930             if (! AsnWrite(aip, SEQFEATDATA_het, &av)) goto erret;
931             break;
932         case SEQFEAT_BIOSRC:
933             if (! BioSourceAsnWrite((BioSourcePtr)pnt, aip, SEQFEATDATA_biosrc))
934                 goto erret;
935             break;
936         case SEQFEAT_CLONEREF:
937             if (! CloneRefAsnWrite((CloneRefPtr)pnt, aip, SEQFEATDATA_clone))
938                 goto erret;
939             break;
940         case SEQFEAT_VARIATIONREF:
941             if (! VariationRefAsnWrite((VariationRefPtr)pnt, aip, SEQFEATDATA_variation))
942                 goto erret;
943             break;
944     }
945 
946     retval = TRUE;
947 erret:
948     AsnUnlinkType(orig);       /* unlink local tree */
949     return retval;
950 }
951 
952 /*****************************************************************************
953 *
954 *   SeqFeatDataAsnRead(aip, atp, cp)
955 *       atp is the current type (if identifier of a parent struct)
956 *            assumption is readIdent has occurred
957 *       if atp == NULL, then assumes it stands alone and read ident
958 *            has not occurred.
959 *
960 *****************************************************************************/
SeqFeatDataAsnRead(AsnIoPtr aip,AsnTypePtr orig,ChoicePtr cp)961 NLM_EXTERN Boolean LIBCALL SeqFeatDataAsnRead (AsnIoPtr aip, AsnTypePtr orig, ChoicePtr cp)
962 {
963     DataVal av;
964     AsnTypePtr atp;
965     Boolean retval = FALSE;
966 
967     if (! loaded)
968     {
969         if (! SeqFeatAsnLoad())
970             return retval;
971     }
972 
973     if (aip == NULL)
974         return retval;
975 
976     if (orig == NULL)           /* SeqFeatData ::= (self contained) */
977         atp = AsnReadId(aip, amp, SEQFEATDATA);
978     else
979         atp = AsnLinkType(orig, SEQFEATDATA);    /* link in local tree */
980     if (atp == NULL)
981         return retval;
982 
983     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read CHOICE */
984     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
985     if (atp == SEQFEATDATA_gene)
986     {
987         cp->choice = SEQFEAT_GENE ;
988         cp->value.ptrvalue = (Pointer)GeneRefAsnRead(aip, atp);
989         if (cp->value.ptrvalue == NULL)
990             goto erret;
991     }
992     else if (atp == SEQFEATDATA_org)
993     {
994         cp->choice = SEQFEAT_ORG ;
995         cp->value.ptrvalue = (Pointer)OrgRefAsnRead(aip, atp);
996         if (cp->value.ptrvalue == NULL)
997             goto erret;
998     }
999     else if (atp == SEQFEATDATA_cdregion)
1000     {
1001         cp->choice = SEQFEAT_CDREGION ;
1002         cp->value.ptrvalue = (Pointer)CdRegionAsnRead(aip, atp);
1003         if (cp->value.ptrvalue == NULL)
1004             goto erret;
1005     }
1006     else if (atp == SEQFEATDATA_prot)
1007     {
1008         cp->choice = SEQFEAT_PROT ;
1009         cp->value.ptrvalue = (Pointer)ProtRefAsnRead(aip, atp);
1010         if (cp->value.ptrvalue == NULL)
1011             goto erret;
1012     }
1013     else if (atp == SEQFEATDATA_rna)
1014     {
1015         cp->choice = SEQFEAT_RNA ;
1016         cp->value.ptrvalue = (Pointer)RnaRefAsnRead(aip, atp);
1017         if (cp->value.ptrvalue == NULL)
1018             goto erret;
1019     }
1020     else if (atp == SEQFEATDATA_pub)
1021     {
1022         cp->choice = SEQFEAT_PUB ;
1023         cp->value.ptrvalue = (Pointer)PubdescAsnRead(aip, atp);
1024         if (cp->value.ptrvalue == NULL)
1025             goto erret;
1026     }
1027     else if (atp == SEQFEATDATA_seq)
1028     {
1029         cp->choice = SEQFEAT_SEQ ;
1030         cp->value.ptrvalue = (Pointer)SeqLocAsnRead(aip, atp);
1031         if (cp->value.ptrvalue == NULL)
1032             goto erret;
1033     }
1034     else if (atp == SEQFEATDATA_imp)
1035     {
1036         cp->choice = SEQFEAT_IMP ;
1037         cp->value.ptrvalue = (Pointer)ImpFeatAsnRead(aip, atp);
1038         if (cp->value.ptrvalue == NULL)
1039             goto erret;
1040     }
1041     else if (atp == SEQFEATDATA_region)
1042     {
1043         cp->choice = SEQFEAT_REGION ;
1044         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1045         cp->value.ptrvalue = av.ptrvalue;
1046     }
1047     else if (atp == SEQFEATDATA_comment)
1048     {
1049         cp->choice = SEQFEAT_COMMENT ;
1050         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1051     }
1052     else if (atp == SEQFEATDATA_bond)
1053     {
1054         cp->choice = SEQFEAT_BOND ;
1055         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1056         cp->value.intvalue = av.intvalue;
1057     }
1058     else if (atp == SEQFEATDATA_site)
1059     {
1060         cp->choice = SEQFEAT_SITE ;
1061         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1062         cp->value.intvalue = av.intvalue;
1063     }
1064     else if (atp == SEQFEATDATA_rsite)
1065     {
1066         cp->choice = SEQFEAT_RSITE ;
1067         cp->value.ptrvalue = (Pointer)RsiteRefAsnRead(aip, atp);
1068         if (cp->value.ptrvalue == NULL)
1069             goto erret;
1070     }
1071     else if (atp == SEQFEATDATA_user)
1072     {
1073         cp->choice = SEQFEAT_USER ;
1074         cp->value.ptrvalue = (Pointer)UserObjectAsnRead(aip, atp);
1075         if (cp->value.ptrvalue == NULL)
1076             goto erret;
1077     }
1078     else if (atp == SEQFEATDATA_txinit)
1079     {
1080         cp->choice = SEQFEAT_TXINIT ;
1081         cp->value.ptrvalue = (Pointer)TxinitAsnRead(aip, atp);
1082         if (cp->value.ptrvalue == NULL)
1083             goto erret;
1084     }
1085     else if (atp == SEQFEATDATA_num)
1086     {
1087         cp->choice = SEQFEAT_NUM ;
1088         cp->value.ptrvalue = (Pointer)NumberingAsnRead(aip, atp);
1089         if (cp->value.ptrvalue == NULL)
1090             goto erret;
1091     }
1092     else if (atp == SEQFEATDATA_psec_str)
1093     {
1094         cp->choice = SEQFEAT_PSEC_STR ;
1095         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1096         cp->value.intvalue = av.intvalue;
1097     }
1098     else if (atp == SEQFEATDATA_non_std_residue)
1099     {
1100         cp->choice = SEQFEAT_NON_STD_RESIDUE ;
1101         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1102         cp->value.ptrvalue = av.ptrvalue;
1103     }
1104     else if (atp == SEQFEATDATA_het)
1105     {
1106         cp->choice = SEQFEAT_HET ;
1107         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1108         cp->value.ptrvalue = av.ptrvalue;
1109     }
1110     else if (atp == SEQFEATDATA_biosrc)
1111     {
1112         cp->choice = SEQFEAT_BIOSRC ;
1113         cp->value.ptrvalue = (Pointer)BioSourceAsnRead(aip, atp);
1114         if (cp->value.ptrvalue == NULL)
1115             goto erret;
1116     }
1117     else if (atp == SEQFEATDATA_clone)
1118     {
1119         cp->choice = SEQFEAT_CLONEREF ;
1120         cp->value.ptrvalue = (Pointer)CloneRefAsnRead(aip, atp);
1121         if (cp->value.ptrvalue == NULL)
1122             goto erret;
1123     }
1124     else if (atp == SEQFEATDATA_variation)
1125     {
1126         cp->choice = SEQFEAT_VARIATIONREF ;
1127         cp->value.ptrvalue = (Pointer)VariationRefAsnRead(aip, atp);
1128         if (cp->value.ptrvalue == NULL)
1129             goto erret;
1130     }
1131 
1132     retval = TRUE;
1133 erret:
1134     AsnUnlinkType(orig);       /* unlink local tree */
1135     return retval;
1136 }
1137 
1138 /*****************************************************************************
1139 *
1140 *   GBQualNew()
1141 *
1142 *****************************************************************************/
GBQualNew(void)1143 NLM_EXTERN GBQualPtr LIBCALL GBQualNew (void)
1144 {
1145     return (GBQualPtr)MemNew(sizeof(GBQual));
1146 }
1147 
1148 /*****************************************************************************
1149 *
1150 *   GBQualFree(gbp)
1151 *       Frees a chain of GBQual and associated data
1152 *
1153 *****************************************************************************/
GBQualFree(GBQualPtr gbp)1154 NLM_EXTERN GBQualPtr LIBCALL GBQualFree (GBQualPtr gbp)
1155 {
1156     GBQualPtr next;
1157 
1158     while (gbp != NULL)
1159     {
1160         next = gbp->next;
1161         MemFree(gbp->qual);
1162         MemFree(gbp->val);
1163         MemFree(gbp);
1164         gbp = next;
1165     }
1166     return (GBQualPtr)NULL;
1167 }
1168 
1169 /*****************************************************************************
1170 *
1171 *   GBQualAsnWrite(gbp, aip, atp)
1172 *       atp is the current type (if identifier of a parent struct)
1173 *       if atp == NULL, then assumes it stands alone (GBQual ::=)
1174 *
1175 *****************************************************************************/
GBQualAsnWrite(GBQualPtr gbp,AsnIoPtr aip,AsnTypePtr orig)1176 NLM_EXTERN Boolean LIBCALL GBQualAsnWrite (GBQualPtr gbp, AsnIoPtr aip, AsnTypePtr orig)
1177 {
1178     DataVal av;
1179     AsnTypePtr atp;
1180     Boolean retval = FALSE;
1181 
1182     if (! loaded)
1183     {
1184         if (! SeqFeatAsnLoad())
1185             return FALSE;
1186     }
1187 
1188     if (aip == NULL)
1189         return FALSE;
1190 
1191     atp = AsnLinkType(orig, GB_QUAL);   /* link local tree */
1192     if (atp == NULL)
1193         return FALSE;
1194 
1195     if (gbp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1196 
1197     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1198 
1199     if (! AsnOpenStruct(aip, atp, (Pointer)gbp))
1200         goto erret;
1201 
1202     av.ptrvalue = (Pointer)gbp->qual;
1203     if (! AsnWrite(aip, GB_QUAL_qual, &av)) goto erret;
1204     av.ptrvalue = (Pointer)gbp->val;
1205     if (! AsnWrite(aip, GB_QUAL_val, &av)) goto erret;
1206 
1207     if (! AsnCloseStruct(aip, atp, (Pointer)gbp))
1208         goto erret;
1209     retval = TRUE;
1210 erret:
1211     AsnUnlinkType(orig);       /* unlink local tree */
1212     return retval;
1213 }
1214 
1215 /*****************************************************************************
1216 *
1217 *   GBQualAsnRead(aip, atp)
1218 *       atp is the current type (if identifier of a parent struct)
1219 *            assumption is readIdent has occurred
1220 *       if atp == NULL, then assumes it stands alone and read ident
1221 *            has not occurred.
1222 *
1223 *****************************************************************************/
GBQualAsnRead(AsnIoPtr aip,AsnTypePtr orig)1224 NLM_EXTERN GBQualPtr LIBCALL GBQualAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1225 {
1226     DataVal av;
1227     AsnTypePtr atp;
1228     GBQualPtr gbp=NULL;
1229 
1230     if (! loaded)
1231     {
1232         if (! SeqFeatAsnLoad())
1233             return gbp;
1234     }
1235 
1236     if (aip == NULL)
1237         return gbp;
1238 
1239     if (orig == NULL)           /* GBQual ::= (self contained) */
1240         atp = AsnReadId(aip, amp, GB_QUAL);
1241     else
1242         atp = AsnLinkType(orig, GB_QUAL);    /* link in local tree */
1243     if (atp == NULL)
1244         return gbp;
1245 
1246     gbp = GBQualNew();
1247     if (gbp == NULL)
1248         goto erret;
1249 
1250     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
1251 
1252     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1253     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1254     gbp->qual = (CharPtr)av.ptrvalue;
1255     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1256     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1257     gbp->val = (CharPtr)av.ptrvalue;
1258     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1259     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
1260 ret:
1261     AsnUnlinkType(orig);       /* unlink local tree */
1262     return gbp;
1263 erret:
1264     gbp = GBQualFree(gbp);
1265     goto ret;
1266 }
1267 
1268 /*****************************************************************************
1269 *
1270 *   SeqFeatXrefNew()
1271 *
1272 *****************************************************************************/
SeqFeatXrefNew(void)1273 NLM_EXTERN SeqFeatXrefPtr LIBCALL SeqFeatXrefNew (void)
1274 {
1275     return (SeqFeatXrefPtr)MemNew(sizeof(SeqFeatXref));
1276 }
1277 
1278 /*****************************************************************************
1279 *
1280 *   SeqFeatToXref(sfp)
1281 *       Copy a SeqFeat to an Xref
1282 *       Currently only works on Gene-ref and Prot-ref
1283 *
1284 *****************************************************************************/
SeqFeatToXref(SeqFeatPtr sfp)1285 NLM_EXTERN SeqFeatXrefPtr LIBCALL SeqFeatToXref (SeqFeatPtr sfp)
1286 {
1287     SeqFeatXrefPtr sfxp;
1288 
1289     if (sfp == NULL)
1290         return (SeqFeatXrefPtr)NULL;
1291 
1292     sfxp = SeqFeatXrefNew();
1293     if (sfxp == NULL) return NULL;
1294     SeqFeatIdDup(&sfxp->id, &sfp->id);
1295     switch (sfp->data.choice)
1296     {
1297         case SEQFEAT_GENE :
1298             sfxp->data.value.ptrvalue = (Pointer) GeneRefDup((GeneRefPtr)sfp->data.value.ptrvalue);
1299             sfxp->data.choice = sfp->data.choice;
1300             break;
1301         case SEQFEAT_PROT :
1302             sfxp->data.value.ptrvalue = (Pointer) ProtRefDup((ProtRefPtr)sfp->data.value.ptrvalue);
1303             sfxp->data.choice = sfp->data.choice;
1304             break;
1305         default:
1306             ErrPostEx(SEV_WARNING, 0, 0, "Unsupported SeqFeatToXref");
1307             break;
1308     }
1309 
1310     return sfxp;
1311 }
1312 
1313 /*****************************************************************************
1314 *
1315 *   SeqFeatXrefFree(sfxp)
1316 *       Frees a chain of SeqFeatXref and associated data
1317 *
1318 *****************************************************************************/
SeqFeatXrefFree(SeqFeatXrefPtr sfxp)1319 NLM_EXTERN SeqFeatXrefPtr LIBCALL SeqFeatXrefFree (SeqFeatXrefPtr sfxp)
1320 {
1321     SeqFeatXrefPtr next;
1322 
1323     while (sfxp != NULL)
1324     {
1325         next = sfxp->next;
1326         SeqFeatIdFree(&sfxp->id);
1327         SeqFeatDataFree(&sfxp->data);
1328         MemFree(sfxp);
1329         sfxp = next;
1330     }
1331     return (SeqFeatXrefPtr)NULL;
1332 }
1333 
1334 /*****************************************************************************
1335 *
1336 *   SeqFeatXrefAsnWrite(sfxp, aip, atp)
1337 *       atp is the current type (if identifier of a parent struct)
1338 *       if atp == NULL, then assumes it stands alone (SeqFeatXref ::=)
1339 *
1340 *****************************************************************************/
SeqFeatXrefAsnWrite(SeqFeatXrefPtr sfxp,AsnIoPtr aip,AsnTypePtr orig)1341 NLM_EXTERN Boolean LIBCALL SeqFeatXrefAsnWrite (SeqFeatXrefPtr sfxp, AsnIoPtr aip, AsnTypePtr orig)
1342 {
1343     AsnTypePtr atp;
1344     Boolean retval = FALSE;
1345 
1346     if (! loaded)
1347     {
1348         if (! SeqFeatAsnLoad())
1349             return FALSE;
1350     }
1351 
1352     if (aip == NULL)
1353         return FALSE;
1354 
1355     atp = AsnLinkType(orig, SEQFEATXREF);   /* link local tree */
1356     if (atp == NULL)
1357         return FALSE;
1358 
1359     if (sfxp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1360 
1361     if (! AsnOpenStruct(aip, atp, (Pointer)sfxp))
1362         goto erret;
1363 
1364     if (sfxp->id.choice)              /* feat-id present */
1365     {
1366         if (! SeqFeatIdAsnWrite(&sfxp->id, aip, SEQFEATXREF_id))
1367             goto erret;
1368     }
1369 
1370     if (sfxp->data.choice)            /* data present */
1371     {
1372         if (! SeqFeatDataAsnWrite(&sfxp->data, aip, SEQFEATXREF_data))
1373             goto erret;
1374     }
1375 
1376     if (! AsnCloseStruct(aip, atp, (Pointer)sfxp))
1377         goto erret;
1378     retval = TRUE;
1379 erret:
1380     AsnUnlinkType(orig);       /* unlink local tree */
1381     return retval;
1382 }
1383 
1384 /*****************************************************************************
1385 *
1386 *   SeqFeatXrefAsnRead(aip, atp)
1387 *       atp is the current type (if identifier of a parent struct)
1388 *            assumption is readIdent has occurred
1389 *       if atp == NULL, then assumes it stands alone and read ident
1390 *            has not occurred.
1391 *
1392 *****************************************************************************/
SeqFeatXrefAsnRead(AsnIoPtr aip,AsnTypePtr orig)1393 NLM_EXTERN SeqFeatXrefPtr LIBCALL SeqFeatXrefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1394 {
1395     DataVal av;
1396     AsnTypePtr atp;
1397     SeqFeatXrefPtr sfxp;
1398 
1399     if (! loaded)
1400     {
1401         if (! SeqFeatAsnLoad())
1402             return (SeqFeatXrefPtr)NULL;
1403     }
1404 
1405     if (aip == NULL)
1406         return (SeqFeatXrefPtr)NULL;
1407 
1408     if (orig == NULL)           /* SeqFeatXref ::= (self contained) */
1409         atp = AsnReadId(aip, amp, SEQFEATXREF);
1410     else
1411         atp = AsnLinkType(orig, SEQFEATXREF);    /* link in local tree */
1412     if (atp == NULL)
1413         return (SeqFeatXrefPtr)NULL;
1414 
1415     sfxp = SeqFeatXrefNew();
1416     if (sfxp == NULL)
1417         goto erret;
1418 
1419     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
1420     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1421 
1422     if (atp == SEQFEATXREF_id)
1423     {
1424         if (! SeqFeatIdAsnRead(aip, atp, &sfxp->id))
1425             goto erret;
1426         atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1427     }
1428 
1429     if (atp == SEQFEATXREF_data)
1430     {
1431         if (! SeqFeatDataAsnRead(aip, atp, &sfxp->data))
1432             goto erret;
1433         atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1434     }
1435 
1436     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
1437 ret:
1438     AsnUnlinkType(orig);       /* unlink local tree */
1439     return sfxp;
1440 erret:
1441     sfxp = SeqFeatXrefFree(sfxp);
1442     goto ret;
1443 }
1444 
1445 
1446 
1447 /**************************************************
1448 *
1449 *    ModelEvidenceSupportNew()
1450 *
1451 **************************************************/
1452 NLM_EXTERN
1453 ModelEvidenceSupportPtr LIBCALL
ModelEvidenceSupportNew(void)1454 ModelEvidenceSupportNew(void)
1455 {
1456    ModelEvidenceSupportPtr ptr = MemNew((size_t) sizeof(ModelEvidenceSupport));
1457 
1458    ptr -> full_length = 0;
1459    ptr -> supports_all_exon_combo = 0;
1460    return ptr;
1461 
1462 }
1463 
1464 
1465 /**************************************************
1466 *
1467 *    ModelEvidenceSupportFree()
1468 *
1469 **************************************************/
1470 NLM_EXTERN
1471 ModelEvidenceSupportPtr LIBCALL
ModelEvidenceSupportFree(ModelEvidenceSupportPtr ptr)1472 ModelEvidenceSupportFree(ModelEvidenceSupportPtr ptr)
1473 {
1474 
1475    if(ptr == NULL) {
1476       return NULL;
1477    }
1478    MemFree(ptr -> method);
1479    AsnGenericValNodeSetFree(ptr -> mrna, (AsnOptFreeFunc) ModelEvidenceItemFree);
1480    AsnGenericValNodeSetFree(ptr -> est, (AsnOptFreeFunc) ModelEvidenceItemFree);
1481    AsnGenericValNodeSetFree(ptr -> protein, (AsnOptFreeFunc) ModelEvidenceItemFree);
1482    SeqIdFree(ptr -> identification);
1483    AsnGenericValNodeSetFree(ptr -> dbxref, (AsnOptFreeFunc) DbtagFree);
1484    return MemFree(ptr);
1485 }
1486 
1487 
1488 /**************************************************
1489 *
1490 *    ModelEvidenceSupportAsnRead()
1491 *
1492 **************************************************/
1493 NLM_EXTERN
1494 ModelEvidenceSupportPtr LIBCALL
ModelEvidenceSupportAsnRead(AsnIoPtr aip,AsnTypePtr orig)1495 ModelEvidenceSupportAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1496 {
1497    DataVal av;
1498    AsnTypePtr atp;
1499    Boolean isError = FALSE;
1500    AsnReadFunc func;
1501    ModelEvidenceSupportPtr ptr;
1502 
1503    if (! loaded)
1504    {
1505       if (! SeqFeatAsnLoad()) {
1506          return NULL;
1507       }
1508    }
1509 
1510    if (aip == NULL) {
1511       return NULL;
1512    }
1513 
1514    if (orig == NULL) {         /* ModelEvidenceSupport ::= (self contained) */
1515       atp = AsnReadId(aip, amp, MODELEVIDENCESUPPORT);
1516    } else {
1517       atp = AsnLinkType(orig, MODELEVIDENCESUPPORT);
1518    }
1519    /* link in local tree */
1520    if (atp == NULL) {
1521       return NULL;
1522    }
1523 
1524    ptr = ModelEvidenceSupportNew();
1525    if (ptr == NULL) {
1526       goto erret;
1527    }
1528    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1529       goto erret;
1530    }
1531 
1532    atp = AsnReadId(aip,amp, atp);
1533    func = NULL;
1534 
1535    if (atp == MODELEVIDENCESUPPORT_method) {
1536       if ( AsnReadVal(aip, atp, &av) <= 0) {
1537          goto erret;
1538       }
1539       ptr -> method = av.ptrvalue;
1540       atp = AsnReadId(aip,amp, atp);
1541    }
1542    if (atp == MODELEVIDENCESUPPORT_mrna) {
1543       ptr -> mrna = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ModelEvidenceItemAsnRead, (AsnOptFreeFunc) ModelEvidenceItemFree);
1544       if (isError && ptr -> mrna == NULL) {
1545          goto erret;
1546       }
1547       atp = AsnReadId(aip,amp, atp);
1548    }
1549    if (atp == MODELEVIDENCESUPPORT_est) {
1550       ptr -> est = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ModelEvidenceItemAsnRead, (AsnOptFreeFunc) ModelEvidenceItemFree);
1551       if (isError && ptr -> est == NULL) {
1552          goto erret;
1553       }
1554       atp = AsnReadId(aip,amp, atp);
1555    }
1556    if (atp == MODELEVIDENCESUPPORT_protein) {
1557       ptr -> protein = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ModelEvidenceItemAsnRead, (AsnOptFreeFunc) ModelEvidenceItemFree);
1558       if (isError && ptr -> protein == NULL) {
1559          goto erret;
1560       }
1561       atp = AsnReadId(aip,amp, atp);
1562    }
1563    if (atp == MODELEVIDENCESUPPORT_identification) {
1564       ptr -> identification = SeqIdAsnRead(aip, atp);
1565       if (aip -> io_failure) {
1566          goto erret;
1567       }
1568       atp = AsnReadId(aip,amp, atp);
1569    }
1570    if (atp == MODELEVIDENCESUPPORT_dbxref) {
1571       ptr -> dbxref = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
1572       if (isError && ptr -> dbxref == NULL) {
1573          goto erret;
1574       }
1575       atp = AsnReadId(aip,amp, atp);
1576    }
1577    if (atp == MODELEVIDENCESUPPORT_exon_count) {
1578       if ( AsnReadVal(aip, atp, &av) <= 0) {
1579          goto erret;
1580       }
1581       ptr -> exon_count = av.intvalue;
1582       ptr -> OBbits__ |= 1<<0;
1583       atp = AsnReadId(aip,amp, atp);
1584    }
1585    if (atp == MODELEVIDENCESUPPORT_exon_length) {
1586       if ( AsnReadVal(aip, atp, &av) <= 0) {
1587          goto erret;
1588       }
1589       ptr -> exon_length = av.intvalue;
1590       ptr -> OBbits__ |= 1<<1;
1591       atp = AsnReadId(aip,amp, atp);
1592    }
1593    if (atp == MODELEVIDENCESUPPORT_full_length) {
1594       if ( AsnReadVal(aip, atp, &av) <= 0) {
1595          goto erret;
1596       }
1597       ptr -> full_length = av.boolvalue;
1598       atp = AsnReadId(aip,amp, atp);
1599    }
1600    if (atp == MODELEVIDENCESUPPORT_supports_all_exon_combo) {
1601       if ( AsnReadVal(aip, atp, &av) <= 0) {
1602          goto erret;
1603       }
1604       ptr -> supports_all_exon_combo = av.boolvalue;
1605       atp = AsnReadId(aip,amp, atp);
1606    }
1607 
1608    if (AsnReadVal(aip, atp, &av) <= 0) {
1609       goto erret;
1610    }
1611    /* end struct */
1612 
1613 ret:
1614    AsnUnlinkType(orig);       /* unlink local tree */
1615    return ptr;
1616 
1617 erret:
1618    aip -> io_failure = TRUE;
1619    ptr = ModelEvidenceSupportFree(ptr);
1620    goto ret;
1621 }
1622 
1623 
1624 
1625 /**************************************************
1626 *
1627 *    ModelEvidenceSupportAsnWrite()
1628 *
1629 **************************************************/
1630 NLM_EXTERN Boolean LIBCALL
ModelEvidenceSupportAsnWrite(ModelEvidenceSupportPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1631 ModelEvidenceSupportAsnWrite(ModelEvidenceSupportPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1632 {
1633    DataVal av;
1634    AsnTypePtr atp;
1635    Boolean retval = FALSE;
1636 
1637    if (! loaded)
1638    {
1639       if (! SeqFeatAsnLoad()) {
1640          return FALSE;
1641       }
1642    }
1643 
1644    if (aip == NULL) {
1645       return FALSE;
1646    }
1647 
1648    atp = AsnLinkType(orig, MODELEVIDENCESUPPORT);   /* link local tree */
1649    if (atp == NULL) {
1650       return FALSE;
1651    }
1652 
1653    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1654 
1655     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1656 
1657    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1658       goto erret;
1659    }
1660 
1661    if (ptr -> method != NULL) {
1662       av.ptrvalue = ptr -> method;
1663       retval = AsnWrite(aip, MODELEVIDENCESUPPORT_method,  &av);
1664    }
1665    AsnGenericValNodeSetAsnWrite(ptr -> mrna, (AsnWriteFunc) ModelEvidenceItemAsnWrite, aip, MODELEVIDENCESUPPORT_mrna, MODELEVIDENCESUPPORT_mrna_E);
1666    AsnGenericValNodeSetAsnWrite(ptr -> est, (AsnWriteFunc) ModelEvidenceItemAsnWrite, aip, MODELEVIDENCESUPPORT_est, MODELEVIDENCESUPPORT_est_E);
1667    AsnGenericValNodeSetAsnWrite(ptr -> protein, (AsnWriteFunc) ModelEvidenceItemAsnWrite, aip, MODELEVIDENCESUPPORT_protein, MODELEVIDENCESUPPORT_protein_E);
1668    if (ptr -> identification != NULL) {
1669       if ( ! SeqIdAsnWrite(ptr -> identification, aip, MODELEVIDENCESUPPORT_identification)) {
1670          goto erret;
1671       }
1672    }
1673    AsnGenericValNodeSetAsnWrite(ptr -> dbxref, (AsnWriteFunc) DbtagAsnWrite, aip, MODELEVIDENCESUPPORT_dbxref, MODELEVIDENCESUPPORT_dbxref_E);
1674    if (ptr -> exon_count || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> exon_count;
1675       retval = AsnWrite(aip, MODELEVIDENCESUPPORT_exon_count,  &av);
1676    }
1677    if (ptr -> exon_length || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> exon_length;
1678       retval = AsnWrite(aip, MODELEVIDENCESUPPORT_exon_length,  &av);
1679    }
1680    if (ptr -> full_length) {
1681       av.boolvalue = ptr -> full_length;
1682       retval = AsnWrite(aip, MODELEVIDENCESUPPORT_full_length,  &av);
1683    }
1684    if (ptr -> supports_all_exon_combo) {
1685       av.boolvalue = ptr -> supports_all_exon_combo;
1686       retval = AsnWrite(aip, MODELEVIDENCESUPPORT_supports_all_exon_combo,  &av);
1687    }
1688    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1689       goto erret;
1690    }
1691    retval = TRUE;
1692 
1693 erret:
1694    AsnUnlinkType(orig);       /* unlink local tree */
1695    return retval;
1696 }
1697 
1698 
1699 
1700 /**************************************************
1701 *
1702 *    ExperimentSupportNew()
1703 *
1704 **************************************************/
1705 NLM_EXTERN
1706 ExperimentSupportPtr LIBCALL
ExperimentSupportNew(void)1707 ExperimentSupportNew(void)
1708 {
1709    ExperimentSupportPtr ptr = MemNew((size_t) sizeof(ExperimentSupport));
1710 
1711    return ptr;
1712 
1713 }
1714 
1715 
1716 /**************************************************
1717 *
1718 *    ExperimentSupportFree()
1719 *
1720 **************************************************/
1721 NLM_EXTERN
1722 ExperimentSupportPtr LIBCALL
ExperimentSupportFree(ExperimentSupportPtr ptr)1723 ExperimentSupportFree(ExperimentSupportPtr ptr)
1724 {
1725 
1726    if(ptr == NULL) {
1727       return NULL;
1728    }
1729    MemFree(ptr -> explanation);
1730    AsnGenericBaseSeqOfFree(ptr -> pmids ,ASNCODE_INTVAL_SLOT);
1731    AsnGenericBaseSeqOfFree(ptr -> dois ,ASNCODE_PTRVAL_SLOT);
1732    return MemFree(ptr);
1733 }
1734 
1735 
1736 /**************************************************
1737 *
1738 *    ExperimentSupportAsnRead()
1739 *
1740 **************************************************/
1741 NLM_EXTERN
1742 ExperimentSupportPtr LIBCALL
ExperimentSupportAsnRead(AsnIoPtr aip,AsnTypePtr orig)1743 ExperimentSupportAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1744 {
1745    DataVal av;
1746    AsnTypePtr atp;
1747    Boolean isError = FALSE;
1748    AsnReadFunc func;
1749    ExperimentSupportPtr ptr;
1750 
1751    if (! loaded)
1752    {
1753       if (! SeqFeatAsnLoad()) {
1754          return NULL;
1755       }
1756    }
1757 
1758    if (aip == NULL) {
1759       return NULL;
1760    }
1761 
1762    if (orig == NULL) {         /* ExperimentSupport ::= (self contained) */
1763       atp = AsnReadId(aip, amp, EXPERIMENTSUPPORT);
1764    } else {
1765       atp = AsnLinkType(orig, EXPERIMENTSUPPORT);
1766    }
1767    /* link in local tree */
1768    if (atp == NULL) {
1769       return NULL;
1770    }
1771 
1772    ptr = ExperimentSupportNew();
1773    if (ptr == NULL) {
1774       goto erret;
1775    }
1776    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1777       goto erret;
1778    }
1779 
1780    atp = AsnReadId(aip,amp, atp);
1781    func = NULL;
1782 
1783    if (atp == EXPERIMENTSUPPORT_category) {
1784       if ( AsnReadVal(aip, atp, &av) <= 0) {
1785          goto erret;
1786       }
1787       ptr -> category = av.intvalue;
1788       ptr -> OBbits__ |= 1<<0;
1789       atp = AsnReadId(aip,amp, atp);
1790    }
1791    if (atp == EXPERIMENTSUPPORT_explanation) {
1792       if ( AsnReadVal(aip, atp, &av) <= 0) {
1793          goto erret;
1794       }
1795       ptr -> explanation = av.ptrvalue;
1796       atp = AsnReadId(aip,amp, atp);
1797    }
1798    if (atp == EXPERIMENTSUPPORT_pmids) {
1799       ptr -> pmids = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
1800       if (isError && ptr -> pmids == NULL) {
1801          goto erret;
1802       }
1803       atp = AsnReadId(aip,amp, atp);
1804    }
1805    if (atp == EXPERIMENTSUPPORT_dois) {
1806       ptr -> dois = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
1807       if (isError && ptr -> dois == NULL) {
1808          goto erret;
1809       }
1810       atp = AsnReadId(aip,amp, atp);
1811    }
1812 
1813    if (AsnReadVal(aip, atp, &av) <= 0) {
1814       goto erret;
1815    }
1816    /* end struct */
1817 
1818 ret:
1819    AsnUnlinkType(orig);       /* unlink local tree */
1820    return ptr;
1821 
1822 erret:
1823    aip -> io_failure = TRUE;
1824    ptr = ExperimentSupportFree(ptr);
1825    goto ret;
1826 }
1827 
1828 
1829 
1830 /**************************************************
1831 *
1832 *    ExperimentSupportAsnWrite()
1833 *
1834 **************************************************/
1835 NLM_EXTERN Boolean LIBCALL
ExperimentSupportAsnWrite(ExperimentSupportPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1836 ExperimentSupportAsnWrite(ExperimentSupportPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1837 {
1838    DataVal av;
1839    AsnTypePtr atp;
1840    Boolean retval = FALSE;
1841 
1842    if (! loaded)
1843    {
1844       if (! SeqFeatAsnLoad()) {
1845          return FALSE;
1846       }
1847    }
1848 
1849    if (aip == NULL) {
1850       return FALSE;
1851    }
1852 
1853    atp = AsnLinkType(orig, EXPERIMENTSUPPORT);   /* link local tree */
1854    if (atp == NULL) {
1855       return FALSE;
1856    }
1857 
1858    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1859 
1860     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1861 
1862    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1863       goto erret;
1864    }
1865 
1866    if (ptr -> category || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> category;
1867       retval = AsnWrite(aip, EXPERIMENTSUPPORT_category,  &av);
1868    }
1869    if (ptr -> explanation != NULL) {
1870       av.ptrvalue = ptr -> explanation;
1871       retval = AsnWrite(aip, EXPERIMENTSUPPORT_explanation,  &av);
1872    }
1873    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> pmids ,ASNCODE_INTVAL_SLOT, aip, EXPERIMENTSUPPORT_pmids, EXPERIMENTSUPPORT_pmids_E);
1874    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> dois ,ASNCODE_PTRVAL_SLOT, aip, EXPERIMENTSUPPORT_dois, EXPERIMENTSUPPORT_dois_E);
1875    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1876       goto erret;
1877    }
1878    retval = TRUE;
1879 
1880 erret:
1881    AsnUnlinkType(orig);       /* unlink local tree */
1882    return retval;
1883 }
1884 
1885 
1886 
1887 /**************************************************
1888 *
1889 *    ProgramIdNew()
1890 *
1891 **************************************************/
1892 NLM_EXTERN
1893 ProgramIdPtr LIBCALL
ProgramIdNew(void)1894 ProgramIdNew(void)
1895 {
1896    ProgramIdPtr ptr = MemNew((size_t) sizeof(ProgramId));
1897 
1898    return ptr;
1899 
1900 }
1901 
1902 
1903 /**************************************************
1904 *
1905 *    ProgramIdFree()
1906 *
1907 **************************************************/
1908 NLM_EXTERN
1909 ProgramIdPtr LIBCALL
ProgramIdFree(ProgramIdPtr ptr)1910 ProgramIdFree(ProgramIdPtr ptr)
1911 {
1912 
1913    if(ptr == NULL) {
1914       return NULL;
1915    }
1916    MemFree(ptr -> name);
1917    MemFree(ptr -> version);
1918    return MemFree(ptr);
1919 }
1920 
1921 
1922 /**************************************************
1923 *
1924 *    ProgramIdAsnRead()
1925 *
1926 **************************************************/
1927 NLM_EXTERN
1928 ProgramIdPtr LIBCALL
ProgramIdAsnRead(AsnIoPtr aip,AsnTypePtr orig)1929 ProgramIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1930 {
1931    DataVal av;
1932    AsnTypePtr atp;
1933    AsnReadFunc func;
1934    ProgramIdPtr ptr;
1935 
1936    if (! loaded)
1937    {
1938       if (! SeqFeatAsnLoad()) {
1939          return NULL;
1940       }
1941    }
1942 
1943    if (aip == NULL) {
1944       return NULL;
1945    }
1946 
1947    if (orig == NULL) {         /* ProgramId ::= (self contained) */
1948       atp = AsnReadId(aip, amp, PROGRAM_ID);
1949    } else {
1950       atp = AsnLinkType(orig, PROGRAM_ID);
1951    }
1952    /* link in local tree */
1953    if (atp == NULL) {
1954       return NULL;
1955    }
1956 
1957    ptr = ProgramIdNew();
1958    if (ptr == NULL) {
1959       goto erret;
1960    }
1961    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1962       goto erret;
1963    }
1964 
1965    atp = AsnReadId(aip,amp, atp);
1966    func = NULL;
1967 
1968    if (atp == PROGRAM_ID_name) {
1969       if ( AsnReadVal(aip, atp, &av) <= 0) {
1970          goto erret;
1971       }
1972       ptr -> name = av.ptrvalue;
1973       atp = AsnReadId(aip,amp, atp);
1974    }
1975    if (atp == PROGRAM_ID_version) {
1976       if ( AsnReadVal(aip, atp, &av) <= 0) {
1977          goto erret;
1978       }
1979       ptr -> version = av.ptrvalue;
1980       atp = AsnReadId(aip,amp, atp);
1981    }
1982 
1983    if (AsnReadVal(aip, atp, &av) <= 0) {
1984       goto erret;
1985    }
1986    /* end struct */
1987 
1988 ret:
1989    AsnUnlinkType(orig);       /* unlink local tree */
1990    return ptr;
1991 
1992 erret:
1993    aip -> io_failure = TRUE;
1994    ptr = ProgramIdFree(ptr);
1995    goto ret;
1996 }
1997 
1998 
1999 
2000 /**************************************************
2001 *
2002 *    ProgramIdAsnWrite()
2003 *
2004 **************************************************/
2005 NLM_EXTERN Boolean LIBCALL
ProgramIdAsnWrite(ProgramIdPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2006 ProgramIdAsnWrite(ProgramIdPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2007 {
2008    DataVal av;
2009    AsnTypePtr atp;
2010    Boolean retval = FALSE;
2011 
2012    if (! loaded)
2013    {
2014       if (! SeqFeatAsnLoad()) {
2015          return FALSE;
2016       }
2017    }
2018 
2019    if (aip == NULL) {
2020       return FALSE;
2021    }
2022 
2023    atp = AsnLinkType(orig, PROGRAM_ID);   /* link local tree */
2024    if (atp == NULL) {
2025       return FALSE;
2026    }
2027 
2028    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2029 
2030     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2031 
2032    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2033       goto erret;
2034    }
2035 
2036    if (ptr -> name != NULL) {
2037       av.ptrvalue = ptr -> name;
2038       retval = AsnWrite(aip, PROGRAM_ID_name,  &av);
2039    }
2040    if (ptr -> version != NULL) {
2041       av.ptrvalue = ptr -> version;
2042       retval = AsnWrite(aip, PROGRAM_ID_version,  &av);
2043    }
2044    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2045       goto erret;
2046    }
2047    retval = TRUE;
2048 
2049 erret:
2050    AsnUnlinkType(orig);       /* unlink local tree */
2051    return retval;
2052 }
2053 
2054 
2055 
2056 /**************************************************
2057 *
2058 *    EvidenceBasisNew()
2059 *
2060 **************************************************/
2061 NLM_EXTERN
2062 EvidenceBasisPtr LIBCALL
EvidenceBasisNew(void)2063 EvidenceBasisNew(void)
2064 {
2065    EvidenceBasisPtr ptr = MemNew((size_t) sizeof(EvidenceBasis));
2066 
2067    return ptr;
2068 
2069 }
2070 
2071 
2072 /**************************************************
2073 *
2074 *    EvidenceBasisFree()
2075 *
2076 **************************************************/
2077 NLM_EXTERN
2078 EvidenceBasisPtr LIBCALL
EvidenceBasisFree(EvidenceBasisPtr ptr)2079 EvidenceBasisFree(EvidenceBasisPtr ptr)
2080 {
2081 
2082    if(ptr == NULL) {
2083       return NULL;
2084    }
2085    AsnGenericValNodeSetFree(ptr -> programs, (AsnOptFreeFunc) ProgramIdFree);
2086    AsnGenericChoiceSeqOfFree(ptr -> accessions, (AsnOptFreeFunc) SeqIdFree);
2087    return MemFree(ptr);
2088 }
2089 
2090 
2091 /**************************************************
2092 *
2093 *    EvidenceBasisAsnRead()
2094 *
2095 **************************************************/
2096 NLM_EXTERN
2097 EvidenceBasisPtr LIBCALL
EvidenceBasisAsnRead(AsnIoPtr aip,AsnTypePtr orig)2098 EvidenceBasisAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2099 {
2100    DataVal av;
2101    AsnTypePtr atp;
2102    Boolean isError = FALSE;
2103    AsnReadFunc func;
2104    EvidenceBasisPtr ptr;
2105 
2106    if (! loaded)
2107    {
2108       if (! SeqFeatAsnLoad()) {
2109          return NULL;
2110       }
2111    }
2112 
2113    if (aip == NULL) {
2114       return NULL;
2115    }
2116 
2117    if (orig == NULL) {         /* EvidenceBasis ::= (self contained) */
2118       atp = AsnReadId(aip, amp, EVIDENCEBASIS);
2119    } else {
2120       atp = AsnLinkType(orig, EVIDENCEBASIS);
2121    }
2122    /* link in local tree */
2123    if (atp == NULL) {
2124       return NULL;
2125    }
2126 
2127    ptr = EvidenceBasisNew();
2128    if (ptr == NULL) {
2129       goto erret;
2130    }
2131    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2132       goto erret;
2133    }
2134 
2135    atp = AsnReadId(aip,amp, atp);
2136    func = NULL;
2137 
2138    if (atp == EVIDENCEBASIS_programs) {
2139       ptr -> programs = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ProgramIdAsnRead, (AsnOptFreeFunc) ProgramIdFree);
2140       if (isError && ptr -> programs == NULL) {
2141          goto erret;
2142       }
2143       atp = AsnReadId(aip,amp, atp);
2144    }
2145    if (atp == EVIDENCEBASIS_accessions) {
2146       ptr -> accessions = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqIdAsnRead, (AsnOptFreeFunc) SeqIdFree);
2147       if (isError && ptr -> accessions == NULL) {
2148          goto erret;
2149       }
2150       atp = AsnReadId(aip,amp, atp);
2151    }
2152 
2153    if (AsnReadVal(aip, atp, &av) <= 0) {
2154       goto erret;
2155    }
2156    /* end struct */
2157 
2158 ret:
2159    AsnUnlinkType(orig);       /* unlink local tree */
2160    return ptr;
2161 
2162 erret:
2163    aip -> io_failure = TRUE;
2164    ptr = EvidenceBasisFree(ptr);
2165    goto ret;
2166 }
2167 
2168 
2169 
2170 /**************************************************
2171 *
2172 *    EvidenceBasisAsnWrite()
2173 *
2174 **************************************************/
2175 NLM_EXTERN Boolean LIBCALL
EvidenceBasisAsnWrite(EvidenceBasisPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2176 EvidenceBasisAsnWrite(EvidenceBasisPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2177 {
2178    AsnTypePtr atp;
2179    Boolean retval = FALSE;
2180 
2181    if (! loaded)
2182    {
2183       if (! SeqFeatAsnLoad()) {
2184          return FALSE;
2185       }
2186    }
2187 
2188    if (aip == NULL) {
2189       return FALSE;
2190    }
2191 
2192    atp = AsnLinkType(orig, EVIDENCEBASIS);   /* link local tree */
2193    if (atp == NULL) {
2194       return FALSE;
2195    }
2196 
2197    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2198    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2199       goto erret;
2200    }
2201 
2202    AsnGenericValNodeSetAsnWrite(ptr -> programs, (AsnWriteFunc) ProgramIdAsnWrite, aip, EVIDENCEBASIS_programs, EVIDENCEBASIS_programs_E);
2203    AsnGenericChoiceSeqOfAsnWrite(ptr -> accessions, (AsnWriteFunc) SeqIdAsnWrite, aip, EVIDENCEBASIS_accessions, EVIDENCEBASIS_accessions_E);
2204    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2205       goto erret;
2206    }
2207    retval = TRUE;
2208 
2209 erret:
2210    AsnUnlinkType(orig);       /* unlink local tree */
2211    return retval;
2212 }
2213 
2214 
2215 
2216 /**************************************************
2217 *
2218 *    InferenceSupportNew()
2219 *
2220 **************************************************/
2221 NLM_EXTERN
2222 InferenceSupportPtr LIBCALL
InferenceSupportNew(void)2223 InferenceSupportNew(void)
2224 {
2225    InferenceSupportPtr ptr = MemNew((size_t) sizeof(InferenceSupport));
2226 
2227    ptr -> type = 0;
2228    ptr -> same_species = 0;
2229    return ptr;
2230 
2231 }
2232 
2233 
2234 /**************************************************
2235 *
2236 *    InferenceSupportFree()
2237 *
2238 **************************************************/
2239 NLM_EXTERN
2240 InferenceSupportPtr LIBCALL
InferenceSupportFree(InferenceSupportPtr ptr)2241 InferenceSupportFree(InferenceSupportPtr ptr)
2242 {
2243 
2244    if(ptr == NULL) {
2245       return NULL;
2246    }
2247    MemFree(ptr -> other_type);
2248    EvidenceBasisFree(ptr -> basis);
2249    AsnGenericBaseSeqOfFree(ptr -> pmids ,ASNCODE_INTVAL_SLOT);
2250    AsnGenericBaseSeqOfFree(ptr -> dois ,ASNCODE_PTRVAL_SLOT);
2251    return MemFree(ptr);
2252 }
2253 
2254 
2255 /**************************************************
2256 *
2257 *    InferenceSupportAsnRead()
2258 *
2259 **************************************************/
2260 NLM_EXTERN
2261 InferenceSupportPtr LIBCALL
InferenceSupportAsnRead(AsnIoPtr aip,AsnTypePtr orig)2262 InferenceSupportAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2263 {
2264    DataVal av;
2265    AsnTypePtr atp;
2266    Boolean isError = FALSE;
2267    AsnReadFunc func;
2268    InferenceSupportPtr ptr;
2269 
2270    if (! loaded)
2271    {
2272       if (! SeqFeatAsnLoad()) {
2273          return NULL;
2274       }
2275    }
2276 
2277    if (aip == NULL) {
2278       return NULL;
2279    }
2280 
2281    if (orig == NULL) {         /* InferenceSupport ::= (self contained) */
2282       atp = AsnReadId(aip, amp, INFERENCESUPPORT);
2283    } else {
2284       atp = AsnLinkType(orig, INFERENCESUPPORT);
2285    }
2286    /* link in local tree */
2287    if (atp == NULL) {
2288       return NULL;
2289    }
2290 
2291    ptr = InferenceSupportNew();
2292    if (ptr == NULL) {
2293       goto erret;
2294    }
2295    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2296       goto erret;
2297    }
2298 
2299    atp = AsnReadId(aip,amp, atp);
2300    func = NULL;
2301 
2302    if (atp == INFERENCESUPPORT_category) {
2303       if ( AsnReadVal(aip, atp, &av) <= 0) {
2304          goto erret;
2305       }
2306       ptr -> category = av.intvalue;
2307       ptr -> OBbits__ |= 1<<0;
2308       atp = AsnReadId(aip,amp, atp);
2309    }
2310    if (atp == INFERENCESUPPORT_type) {
2311       if ( AsnReadVal(aip, atp, &av) <= 0) {
2312          goto erret;
2313       }
2314       ptr -> type = av.intvalue;
2315       atp = AsnReadId(aip,amp, atp);
2316    }
2317    if (atp == INFERENCESUPPORT_other_type) {
2318       if ( AsnReadVal(aip, atp, &av) <= 0) {
2319          goto erret;
2320       }
2321       ptr -> other_type = av.ptrvalue;
2322       atp = AsnReadId(aip,amp, atp);
2323    }
2324    if (atp == INFERENCESUPPORT_same_species) {
2325       if ( AsnReadVal(aip, atp, &av) <= 0) {
2326          goto erret;
2327       }
2328       ptr -> same_species = av.boolvalue;
2329       atp = AsnReadId(aip,amp, atp);
2330    }
2331    if (atp == INFERENCESUPPORT_basis) {
2332       ptr -> basis = EvidenceBasisAsnRead(aip, atp);
2333       if (aip -> io_failure) {
2334          goto erret;
2335       }
2336       atp = AsnReadId(aip,amp, atp);
2337    }
2338    if (atp == INFERENCESUPPORT_pmids) {
2339       ptr -> pmids = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
2340       if (isError && ptr -> pmids == NULL) {
2341          goto erret;
2342       }
2343       atp = AsnReadId(aip,amp, atp);
2344    }
2345    if (atp == INFERENCESUPPORT_dois) {
2346       ptr -> dois = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
2347       if (isError && ptr -> dois == NULL) {
2348          goto erret;
2349       }
2350       atp = AsnReadId(aip,amp, atp);
2351    }
2352 
2353    if (AsnReadVal(aip, atp, &av) <= 0) {
2354       goto erret;
2355    }
2356    /* end struct */
2357 
2358 ret:
2359    AsnUnlinkType(orig);       /* unlink local tree */
2360    return ptr;
2361 
2362 erret:
2363    aip -> io_failure = TRUE;
2364    ptr = InferenceSupportFree(ptr);
2365    goto ret;
2366 }
2367 
2368 
2369 
2370 /**************************************************
2371 *
2372 *    InferenceSupportAsnWrite()
2373 *
2374 **************************************************/
2375 NLM_EXTERN Boolean LIBCALL
InferenceSupportAsnWrite(InferenceSupportPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2376 InferenceSupportAsnWrite(InferenceSupportPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2377 {
2378    DataVal av;
2379    AsnTypePtr atp;
2380    Boolean retval = FALSE;
2381 
2382    if (! loaded)
2383    {
2384       if (! SeqFeatAsnLoad()) {
2385          return FALSE;
2386       }
2387    }
2388 
2389    if (aip == NULL) {
2390       return FALSE;
2391    }
2392 
2393    atp = AsnLinkType(orig, INFERENCESUPPORT);   /* link local tree */
2394    if (atp == NULL) {
2395       return FALSE;
2396    }
2397 
2398    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2399 
2400     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2401 
2402    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2403       goto erret;
2404    }
2405 
2406    if (ptr -> category || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> category;
2407       retval = AsnWrite(aip, INFERENCESUPPORT_category,  &av);
2408    }
2409    av.intvalue = ptr -> type;
2410    retval = AsnWrite(aip, INFERENCESUPPORT_type,  &av);
2411    if (ptr -> other_type != NULL) {
2412       av.ptrvalue = ptr -> other_type;
2413       retval = AsnWrite(aip, INFERENCESUPPORT_other_type,  &av);
2414    }
2415    av.boolvalue = ptr -> same_species;
2416    retval = AsnWrite(aip, INFERENCESUPPORT_same_species,  &av);
2417    if (ptr -> basis != NULL) {
2418       if ( ! EvidenceBasisAsnWrite(ptr -> basis, aip, INFERENCESUPPORT_basis)) {
2419          goto erret;
2420       }
2421    }
2422    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> pmids ,ASNCODE_INTVAL_SLOT, aip, INFERENCESUPPORT_pmids, INFERENCESUPPORT_pmids_E);
2423    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> dois ,ASNCODE_PTRVAL_SLOT, aip, INFERENCESUPPORT_dois, INFERENCESUPPORT_dois_E);
2424    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2425       goto erret;
2426    }
2427    retval = TRUE;
2428 
2429 erret:
2430    AsnUnlinkType(orig);       /* unlink local tree */
2431    return retval;
2432 }
2433 
2434 
2435 
2436 /**************************************************
2437 *
2438 *    ModelEvidenceItemNew()
2439 *
2440 **************************************************/
2441 NLM_EXTERN
2442 ModelEvidenceItemPtr LIBCALL
ModelEvidenceItemNew(void)2443 ModelEvidenceItemNew(void)
2444 {
2445    ModelEvidenceItemPtr ptr = MemNew((size_t) sizeof(ModelEvidenceItem));
2446 
2447    ptr -> full_length = 0;
2448    ptr -> supports_all_exon_combo = 0;
2449    return ptr;
2450 
2451 }
2452 
2453 
2454 /**************************************************
2455 *
2456 *    ModelEvidenceItemFree()
2457 *
2458 **************************************************/
2459 NLM_EXTERN
2460 ModelEvidenceItemPtr LIBCALL
ModelEvidenceItemFree(ModelEvidenceItemPtr ptr)2461 ModelEvidenceItemFree(ModelEvidenceItemPtr ptr)
2462 {
2463 
2464    if(ptr == NULL) {
2465       return NULL;
2466    }
2467    SeqIdFree(ptr -> id);
2468    return MemFree(ptr);
2469 }
2470 
2471 
2472 /**************************************************
2473 *
2474 *    ModelEvidenceItemAsnRead()
2475 *
2476 **************************************************/
2477 NLM_EXTERN
2478 ModelEvidenceItemPtr LIBCALL
ModelEvidenceItemAsnRead(AsnIoPtr aip,AsnTypePtr orig)2479 ModelEvidenceItemAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2480 {
2481    DataVal av;
2482    AsnTypePtr atp;
2483    AsnReadFunc func;
2484    ModelEvidenceItemPtr ptr;
2485 
2486    if (! loaded)
2487    {
2488       if (! SeqFeatAsnLoad()) {
2489          return NULL;
2490       }
2491    }
2492 
2493    if (aip == NULL) {
2494       return NULL;
2495    }
2496 
2497    if (orig == NULL) {         /* ModelEvidenceItem ::= (self contained) */
2498       atp = AsnReadId(aip, amp, MODELEVIDENCEITEM);
2499    } else {
2500       atp = AsnLinkType(orig, MODELEVIDENCEITEM);
2501    }
2502    /* link in local tree */
2503    if (atp == NULL) {
2504       return NULL;
2505    }
2506 
2507    ptr = ModelEvidenceItemNew();
2508    if (ptr == NULL) {
2509       goto erret;
2510    }
2511    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2512       goto erret;
2513    }
2514 
2515    atp = AsnReadId(aip,amp, atp);
2516    func = NULL;
2517 
2518    if (atp == MODELEVIDENCEITEM_id) {
2519       ptr -> id = SeqIdAsnRead(aip, atp);
2520       if (aip -> io_failure) {
2521          goto erret;
2522       }
2523       atp = AsnReadId(aip,amp, atp);
2524    }
2525    if (atp == MODELEVIDENCEITEM_exon_count) {
2526       if ( AsnReadVal(aip, atp, &av) <= 0) {
2527          goto erret;
2528       }
2529       ptr -> exon_count = av.intvalue;
2530       ptr -> OBbits__ |= 1<<0;
2531       atp = AsnReadId(aip,amp, atp);
2532    }
2533    if (atp == MODELEVIDENCEITEM_exon_length) {
2534       if ( AsnReadVal(aip, atp, &av) <= 0) {
2535          goto erret;
2536       }
2537       ptr -> exon_length = av.intvalue;
2538       ptr -> OBbits__ |= 1<<1;
2539       atp = AsnReadId(aip,amp, atp);
2540    }
2541    if (atp == MODELEVIDENCEITEM_full_length) {
2542       if ( AsnReadVal(aip, atp, &av) <= 0) {
2543          goto erret;
2544       }
2545       ptr -> full_length = av.boolvalue;
2546       atp = AsnReadId(aip,amp, atp);
2547    }
2548    if (atp == MODELEVIDENCEITEM_supports_all_exon_combo) {
2549       if ( AsnReadVal(aip, atp, &av) <= 0) {
2550          goto erret;
2551       }
2552       ptr -> supports_all_exon_combo = av.boolvalue;
2553       atp = AsnReadId(aip,amp, atp);
2554    }
2555 
2556    if (AsnReadVal(aip, atp, &av) <= 0) {
2557       goto erret;
2558    }
2559    /* end struct */
2560 
2561 ret:
2562    AsnUnlinkType(orig);       /* unlink local tree */
2563    return ptr;
2564 
2565 erret:
2566    aip -> io_failure = TRUE;
2567    ptr = ModelEvidenceItemFree(ptr);
2568    goto ret;
2569 }
2570 
2571 
2572 
2573 /**************************************************
2574 *
2575 *    ModelEvidenceItemAsnWrite()
2576 *
2577 **************************************************/
2578 NLM_EXTERN Boolean LIBCALL
ModelEvidenceItemAsnWrite(ModelEvidenceItemPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2579 ModelEvidenceItemAsnWrite(ModelEvidenceItemPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2580 {
2581    DataVal av;
2582    AsnTypePtr atp;
2583    Boolean retval = FALSE;
2584 
2585    if (! loaded)
2586    {
2587       if (! SeqFeatAsnLoad()) {
2588          return FALSE;
2589       }
2590    }
2591 
2592    if (aip == NULL) {
2593       return FALSE;
2594    }
2595 
2596    atp = AsnLinkType(orig, MODELEVIDENCEITEM);   /* link local tree */
2597    if (atp == NULL) {
2598       return FALSE;
2599    }
2600 
2601    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2602 
2603     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2604 
2605    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2606       goto erret;
2607    }
2608 
2609    if (ptr -> id != NULL) {
2610       if ( ! SeqIdAsnWrite(ptr -> id, aip, MODELEVIDENCEITEM_id)) {
2611          goto erret;
2612       }
2613    }
2614    if (ptr -> exon_count || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> exon_count;
2615       retval = AsnWrite(aip, MODELEVIDENCEITEM_exon_count,  &av);
2616    }
2617    if (ptr -> exon_length || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> exon_length;
2618       retval = AsnWrite(aip, MODELEVIDENCEITEM_exon_length,  &av);
2619    }
2620    if (ptr -> full_length) {
2621       av.boolvalue = ptr -> full_length;
2622       retval = AsnWrite(aip, MODELEVIDENCEITEM_full_length,  &av);
2623    }
2624    if (ptr -> supports_all_exon_combo) {
2625       av.boolvalue = ptr -> supports_all_exon_combo;
2626       retval = AsnWrite(aip, MODELEVIDENCEITEM_supports_all_exon_combo,  &av);
2627    }
2628    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2629       goto erret;
2630    }
2631    retval = TRUE;
2632 
2633 erret:
2634    AsnUnlinkType(orig);       /* unlink local tree */
2635    return retval;
2636 }
2637 
2638 
2639 
2640 /**************************************************
2641 *
2642 *    SeqFeatSupportNew()
2643 *
2644 **************************************************/
2645 NLM_EXTERN
2646 SeqFeatSupportPtr LIBCALL
SeqFeatSupportNew(void)2647 SeqFeatSupportNew(void)
2648 {
2649    SeqFeatSupportPtr ptr = MemNew((size_t) sizeof(SeqFeatSupport));
2650 
2651    return ptr;
2652 
2653 }
2654 
2655 
2656 /**************************************************
2657 *
2658 *    SeqFeatSupportFree()
2659 *
2660 **************************************************/
2661 NLM_EXTERN
2662 SeqFeatSupportPtr LIBCALL
SeqFeatSupportFree(SeqFeatSupportPtr ptr)2663 SeqFeatSupportFree(SeqFeatSupportPtr ptr)
2664 {
2665 
2666    if(ptr == NULL) {
2667       return NULL;
2668    }
2669    AsnGenericValNodeSetFree(ptr -> experiment, (AsnOptFreeFunc) ExperimentSupportFree);
2670    AsnGenericValNodeSetFree(ptr -> inference, (AsnOptFreeFunc) InferenceSupportFree);
2671    AsnGenericValNodeSetFree(ptr -> model_evidence, (AsnOptFreeFunc) ModelEvidenceSupportFree);
2672    return MemFree(ptr);
2673 }
2674 
2675 
2676 /**************************************************
2677 *
2678 *    SeqFeatSupportAsnRead()
2679 *
2680 **************************************************/
2681 NLM_EXTERN
2682 SeqFeatSupportPtr LIBCALL
SeqFeatSupportAsnRead(AsnIoPtr aip,AsnTypePtr orig)2683 SeqFeatSupportAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2684 {
2685    DataVal av;
2686    AsnTypePtr atp;
2687    Boolean isError = FALSE;
2688    AsnReadFunc func;
2689    SeqFeatSupportPtr ptr;
2690 
2691    if (! loaded)
2692    {
2693       if (! SeqFeatAsnLoad()) {
2694          return NULL;
2695       }
2696    }
2697 
2698    if (aip == NULL) {
2699       return NULL;
2700    }
2701 
2702    if (orig == NULL) {         /* SeqFeatSupport ::= (self contained) */
2703       atp = AsnReadId(aip, amp, SEQFEATSUPPORT);
2704    } else {
2705       atp = AsnLinkType(orig, SEQFEATSUPPORT);
2706    }
2707    /* link in local tree */
2708    if (atp == NULL) {
2709       return NULL;
2710    }
2711 
2712    ptr = SeqFeatSupportNew();
2713    if (ptr == NULL) {
2714       goto erret;
2715    }
2716    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2717       goto erret;
2718    }
2719 
2720    atp = AsnReadId(aip,amp, atp);
2721    func = NULL;
2722 
2723    if (atp == SEQFEATSUPPORT_experiment) {
2724       ptr -> experiment = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ExperimentSupportAsnRead, (AsnOptFreeFunc) ExperimentSupportFree);
2725       if (isError && ptr -> experiment == NULL) {
2726          goto erret;
2727       }
2728       atp = AsnReadId(aip,amp, atp);
2729    }
2730    if (atp == SEQFEATSUPPORT_inference) {
2731       ptr -> inference = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) InferenceSupportAsnRead, (AsnOptFreeFunc) InferenceSupportFree);
2732       if (isError && ptr -> inference == NULL) {
2733          goto erret;
2734       }
2735       atp = AsnReadId(aip,amp, atp);
2736    }
2737    if (atp == SEQFEATSUPPORT_model_evidence) {
2738       ptr -> model_evidence = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ModelEvidenceSupportAsnRead, (AsnOptFreeFunc) ModelEvidenceSupportFree);
2739       if (isError && ptr -> model_evidence == NULL) {
2740          goto erret;
2741       }
2742       atp = AsnReadId(aip,amp, atp);
2743    }
2744 
2745    if (AsnReadVal(aip, atp, &av) <= 0) {
2746       goto erret;
2747    }
2748    /* end struct */
2749 
2750 ret:
2751    AsnUnlinkType(orig);       /* unlink local tree */
2752    return ptr;
2753 
2754 erret:
2755    aip -> io_failure = TRUE;
2756    ptr = SeqFeatSupportFree(ptr);
2757    goto ret;
2758 }
2759 
2760 
2761 
2762 /**************************************************
2763 *
2764 *    SeqFeatSupportAsnWrite()
2765 *
2766 **************************************************/
2767 NLM_EXTERN Boolean LIBCALL
SeqFeatSupportAsnWrite(SeqFeatSupportPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2768 SeqFeatSupportAsnWrite(SeqFeatSupportPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2769 {
2770    AsnTypePtr atp;
2771    Boolean retval = FALSE;
2772 
2773    if (! loaded)
2774    {
2775       if (! SeqFeatAsnLoad()) {
2776          return FALSE;
2777       }
2778    }
2779 
2780    if (aip == NULL) {
2781       return FALSE;
2782    }
2783 
2784    atp = AsnLinkType(orig, SEQFEATSUPPORT);   /* link local tree */
2785    if (atp == NULL) {
2786       return FALSE;
2787    }
2788 
2789    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2790    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2791       goto erret;
2792    }
2793 
2794    AsnGenericValNodeSetAsnWrite(ptr -> experiment, (AsnWriteFunc) ExperimentSupportAsnWrite, aip, SEQFEATSUPPORT_experiment, SEQFEATSUPPORT_experiment_E);
2795    AsnGenericValNodeSetAsnWrite(ptr -> inference, (AsnWriteFunc) InferenceSupportAsnWrite, aip, SEQFEATSUPPORT_inference, SEQFEATSUPPORT_inference_E);
2796    AsnGenericValNodeSetAsnWrite(ptr -> model_evidence, (AsnWriteFunc) ModelEvidenceSupportAsnWrite, aip, SEQFEATSUPPORT_model_evidence, SEQFEATSUPPORT_model_evidence_E);
2797    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2798       goto erret;
2799    }
2800    retval = TRUE;
2801 
2802 erret:
2803    AsnUnlinkType(orig);       /* unlink local tree */
2804    return retval;
2805 }
2806 
2807 
2808 
2809 
2810 /*****************************************************************************
2811 *
2812 *   CdRegionNew()
2813 *
2814 *****************************************************************************/
CdRegionNew(void)2815 NLM_EXTERN CdRegionPtr LIBCALL CdRegionNew (void)
2816 {
2817     return (CdRegionPtr)MemNew(sizeof(CdRegion));
2818 }
2819 
2820 /*****************************************************************************
2821 *
2822 *   CdRegionFree(cdp)
2823 *       Frees a CdRegion and associated data
2824 *
2825 *****************************************************************************/
CdRegionFree(CdRegionPtr cdp)2826 NLM_EXTERN CdRegionPtr LIBCALL CdRegionFree (CdRegionPtr cdp)
2827 {
2828     if (cdp == NULL)
2829         return cdp;
2830 
2831     GeneticCodeFree(cdp->genetic_code);
2832     CodeBreakFree(cdp->code_break);
2833     return (CdRegionPtr)MemFree(cdp);
2834 }
2835 
2836 /*****************************************************************************
2837 *
2838 *   CdRegionAsnWrite(cdp, aip, atp)
2839 *       atp is the current type (if identifier of a parent struct)
2840 *       if atp == NULL, then assumes it stands alone (CdRegion ::=)
2841 *
2842 *****************************************************************************/
CdRegionAsnWrite(CdRegionPtr cdp,AsnIoPtr aip,AsnTypePtr orig)2843 NLM_EXTERN Boolean LIBCALL CdRegionAsnWrite (CdRegionPtr cdp, AsnIoPtr aip, AsnTypePtr orig)
2844 {
2845     DataVal av;
2846     AsnTypePtr atp;
2847     CodeBreakPtr cbp;
2848     Boolean retval = FALSE;
2849 
2850     if (! loaded)
2851     {
2852         if (! SeqFeatAsnLoad())
2853             return FALSE;
2854     }
2855 
2856     if (aip == NULL)
2857         return FALSE;
2858 
2859     atp = AsnLinkType(orig, CDREGION);   /* link local tree */
2860     if (atp == NULL)
2861         return FALSE;
2862 
2863     if (cdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2864 
2865     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2866 
2867     if (! AsnOpenStruct(aip, atp, (Pointer)cdp))
2868         goto erret;
2869 
2870     if (cdp->orf)
2871     {
2872         av.boolvalue = cdp->orf;
2873         if (! AsnWrite(aip, CDREGION_orf, &av)) goto erret;
2874     }
2875     if (cdp->frame)
2876     {
2877         av.intvalue = cdp->frame;
2878         if (! AsnWrite(aip, CDREGION_frame, &av)) goto erret;
2879     }
2880     if (cdp->conflict)
2881     {
2882         av.boolvalue = cdp->conflict;
2883         if (! AsnWrite(aip, CDREGION_conflict, &av)) goto erret;
2884     }
2885     if (cdp->gaps)
2886     {
2887         av.intvalue = cdp->gaps;
2888         if (! AsnWrite(aip, CDREGION_gaps, &av)) goto erret;
2889     }
2890     if (cdp->mismatch)
2891     {
2892         av.intvalue = cdp->mismatch;
2893         if (! AsnWrite(aip, CDREGION_mismatch, &av)) goto erret;
2894     }
2895     if (cdp->genetic_code != NULL)
2896     {
2897         if (! GeneticCodeAsnWrite(cdp->genetic_code, aip, CDREGION_code))
2898             goto erret;
2899     }
2900     if (cdp->code_break != NULL)
2901     {
2902         if (! AsnOpenStruct(aip, CDREGION_code_break, (Pointer)cdp->code_break))
2903             goto erret;
2904         cbp = cdp->code_break;
2905         while (cbp != NULL)
2906         {
2907             if (! CodeBreakAsnWrite(cbp, aip, CDREGION_code_break_E))
2908                 goto erret;
2909             cbp = cbp->next;
2910         }
2911         if (! AsnCloseStruct(aip, CDREGION_code_break, (Pointer)cdp->code_break))
2912             goto erret;
2913     }
2914     if (cdp->stops)
2915     {
2916         av.intvalue = cdp->stops;
2917         if (! AsnWrite(aip, CDREGION_stops, &av)) goto erret;
2918     }
2919 
2920     if (! AsnCloseStruct(aip, atp, (Pointer)cdp))
2921         goto erret;
2922     retval = TRUE;
2923 erret:
2924     AsnUnlinkType(orig);       /* unlink local tree */
2925     return retval;
2926 }
2927 
2928 /*****************************************************************************
2929 *
2930 *   CdRegionAsnRead(aip, atp)
2931 *       atp is the current type (if identifier of a parent struct)
2932 *            assumption is readIdent has occurred
2933 *       if atp == NULL, then assumes it stands alone and read ident
2934 *            has not occurred.
2935 *
2936 *****************************************************************************/
CdRegionAsnRead(AsnIoPtr aip,AsnTypePtr orig)2937 NLM_EXTERN CdRegionPtr LIBCALL CdRegionAsnRead (AsnIoPtr aip, AsnTypePtr orig)
2938 {
2939     DataVal av;
2940     AsnTypePtr atp, oldatp;
2941     CdRegionPtr cdp;
2942     CodeBreakPtr curr, next;
2943 
2944     if (! loaded)
2945     {
2946         if (! SeqFeatAsnLoad())
2947             return (CdRegionPtr)NULL;
2948     }
2949 
2950     if (aip == NULL)
2951         return (CdRegionPtr)NULL;
2952 
2953     if (orig == NULL)           /* CdRegion ::= (self contained) */
2954         atp = AsnReadId(aip, amp, CDREGION);
2955     else
2956         atp = AsnLinkType(orig, CDREGION);    /* link in local tree */
2957     oldatp = atp;
2958     if (atp == NULL)
2959         return (CdRegionPtr)NULL;
2960 
2961     cdp = CdRegionNew();
2962     if (cdp == NULL)
2963         goto erret;
2964 
2965     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
2966     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
2967     {
2968         if (atp == NULL)
2969             goto erret;
2970         if (atp == CDREGION_code)
2971         {
2972             cdp->genetic_code = GeneticCodeAsnRead(aip, atp);
2973             if (cdp->genetic_code == NULL)
2974                 goto erret;
2975         }
2976         else
2977         {
2978             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2979             if (atp == CDREGION_orf)
2980                 cdp->orf = av.boolvalue;
2981             else if (atp == CDREGION_conflict)
2982                 cdp->conflict = av.boolvalue;
2983             else if (atp == CDREGION_gaps)
2984             {
2985                 if (av.intvalue > 255)
2986                     av.intvalue = 255;
2987                 cdp->gaps = (Uint1)av.intvalue;
2988             }
2989             else if (atp == CDREGION_frame)
2990             {
2991                 if (av.intvalue > 255)
2992                     av.intvalue = 255;
2993                 cdp->frame = (Uint1)av.intvalue;
2994             }
2995             else if (atp == CDREGION_mismatch)
2996             {
2997                 if (av.intvalue > 255)
2998                     av.intvalue = 255;
2999                 cdp->mismatch = (Uint1)av.intvalue;
3000             }
3001             else if (atp == CDREGION_stops)
3002             {
3003                 if (av.intvalue > 255)
3004                     av.intvalue = 255;
3005                 cdp->stops = (Uint1)av.intvalue;
3006             }
3007             else if (atp == CDREGION_code_break)
3008             {
3009                 curr = NULL;
3010                 while ((atp = AsnReadId(aip, amp, atp)) == CDREGION_code_break_E)
3011                 {
3012                     next = CodeBreakAsnRead(aip, atp);
3013                     if (next == NULL)
3014                         goto erret;
3015                     if (cdp->code_break == NULL)
3016                         cdp->code_break = next;
3017                     else
3018                         curr->next = next;
3019                     curr = next;
3020                 }
3021                 if (atp == NULL)
3022                     goto erret;
3023                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3024             }
3025 
3026         }
3027     }
3028 
3029     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
3030 ret:
3031     AsnUnlinkType(orig);       /* unlink local tree */
3032     return cdp;
3033 erret:
3034     cdp = CdRegionFree(cdp);
3035     goto ret;
3036 }
3037 
3038 static GeneticCodePtr genetic_codes = NULL;    /* array of ValNodes */
3039 static Boolean GeneticCodeAdd PROTO((GeneticCodePtr gc));
3040 
3041 /*****************************************************************************
3042 *
3043 *   GeneticCodeNew()
3044 *       returns a ValNodePtr for the head of the chain
3045 *       first ValNode has the choice 254,
3046 *       The chain of GeneticCode elements is attached to data.ptrvalue of
3047 *         this first node.
3048 *
3049 *****************************************************************************/
GeneticCodeNew(void)3050 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeNew (void)
3051 {
3052     GeneticCodePtr gc;
3053 
3054     gc = ValNodeNew(NULL);
3055     if (gc == NULL) return gc;
3056     gc->choice = 254;
3057 
3058     return gc;
3059 }
3060 
3061 /*****************************************************************************
3062 *
3063 *   GeneticCodeAdd()
3064 *       Adds to genetic_codes global list
3065 *       This should only be used by GeneticCodeTableRead()
3066 *
3067 *****************************************************************************/
GeneticCodeAdd(GeneticCodePtr gc)3068 static Boolean GeneticCodeAdd (GeneticCodePtr gc)
3069 {
3070     GeneticCodePtr tmp;
3071 
3072     if (gc == NULL)
3073         return FALSE;
3074 
3075     if (genetic_codes == NULL)
3076         genetic_codes = gc;
3077     else
3078     {
3079         tmp = genetic_codes;
3080         while (tmp->next != NULL)
3081             tmp = tmp->next;
3082         tmp->next = gc;
3083     }
3084 
3085     return TRUE;
3086 }
3087 
3088 /*****************************************************************************
3089 *
3090 *   GeneticCodeFree(gcp)
3091 *       Frees a GeneticCode and associated data
3092 *
3093 *****************************************************************************/
GeneticCodeFree(GeneticCodePtr gcp)3094 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeFree (GeneticCodePtr gcp)
3095 {
3096     ValNodePtr prev, next;
3097 
3098     if (gcp == NULL)
3099         return (GeneticCodePtr)NULL;
3100 
3101     if (gcp->choice == 254)   /* head of chain */
3102     {
3103         next = genetic_codes;
3104         prev = NULL;
3105         while ((next != NULL) && (gcp != next))
3106         {
3107             prev = next;
3108             next = prev->next;
3109         }
3110 
3111         if (next != NULL)      /* found it */
3112         {
3113             if (prev != NULL)   /* not the first one */
3114                 prev->next = next->next;
3115             else
3116                 genetic_codes = next->next;
3117             gcp->next = NULL;
3118         }
3119 
3120         prev = gcp;
3121         gcp = (GeneticCodePtr) prev->data.ptrvalue;
3122         MemFree(prev);
3123     }
3124 
3125     while (gcp != NULL)
3126     {
3127         next = gcp->next;
3128         switch (gcp->choice)
3129         {
3130             case 1:   /* name */
3131             case 3:   /* ncbieaa */
3132             case 6:   /* sncbieaa */
3133                 MemFree(gcp->data.ptrvalue);
3134                 break;
3135             case 4:   /* ncbi8aa */
3136             case 5:      /* ncbistdaa */
3137             case 7:   /* sncbi8aa */
3138             case 8:   /* sncbistdaa */
3139                 BSFree((ByteStorePtr)gcp->data.ptrvalue);
3140                 break;
3141             default:
3142                 break;
3143         }
3144         MemFree(gcp);
3145         gcp = next;
3146     }
3147     return (GeneticCodePtr)NULL;
3148 }
3149 
3150 /*****************************************************************************
3151 *
3152 *   GeneticCodeAsnWrite(gcp, aip, atp)
3153 *       atp is the current type (if identifier of a parent struct)
3154 *       if atp == NULL, then assumes it stands alone (GeneticCode ::=)
3155 *
3156 *****************************************************************************/
GeneticCodeAsnWrite(GeneticCodePtr gcp,AsnIoPtr aip,AsnTypePtr orig)3157 NLM_EXTERN Boolean LIBCALL GeneticCodeAsnWrite (GeneticCodePtr gcp, AsnIoPtr aip, AsnTypePtr orig)
3158 {
3159     GeneticCodePtr tmp;
3160     DataVal av;
3161     AsnTypePtr atp, gtp;
3162     Boolean retval = FALSE;
3163 
3164     if (! loaded)
3165     {
3166         if (! SeqFeatAsnLoad())
3167             return FALSE;
3168     }
3169 
3170     if (aip == NULL)
3171         return FALSE;
3172 
3173     atp = AsnLinkType(orig, GENETIC_CODE);   /* link local tree */
3174     if (atp == NULL)
3175         return FALSE;
3176 
3177     if (gcp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3178 
3179     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3180 
3181     if (! AsnOpenStruct(aip, atp, (Pointer)gcp))
3182         goto erret;
3183 
3184     tmp = (ValNodePtr) gcp->data.ptrvalue;
3185     while (tmp != NULL)
3186     {
3187         switch (tmp->choice)
3188         {
3189             case 1:   /* name */
3190                 gtp = GENETIC_CODE_E_name;
3191                 break;
3192             case 2:
3193                 gtp = GENETIC_CODE_E_id;
3194                 break;
3195             case 3:   /* ncbieaa */
3196                 gtp = GENETIC_CODE_E_ncbieaa;
3197                 break;
3198             case 4:      /* ncbi8aa */
3199                 gtp = GENETIC_CODE_E_ncbi8aa;
3200                 break;
3201             case 5:   /* ncbistdaa */
3202                 gtp = GENETIC_CODE_E_ncbistdaa;
3203                 break;
3204             case 6:   /* sncbieaa */
3205                 gtp = GENETIC_CODE_E_sncbieaa;
3206                 break;
3207             case 7:      /* sncbi8aa */
3208                 gtp = GENETIC_CODE_E_sncbi8aa;
3209                 break;
3210             case 8:   /* sncbistdaa */
3211                 gtp = GENETIC_CODE_E_sncbistdaa;
3212                 break;
3213             default:
3214                 ErrPostEx(SEV_WARNING, 0, 0, "Unsupported GeneticCode Type = %d", (int)gcp->choice);
3215                 goto erret;
3216         }
3217 
3218         av.ptrvalue = tmp;
3219         if (! AsnWriteChoice(aip, GENETIC_CODE_E, (Int2)tmp->choice, &av)) goto erret;
3220         if (! AsnWrite(aip, gtp, &tmp->data)) goto erret;
3221         tmp = tmp->next;
3222     }
3223 
3224     if (! AsnCloseStruct(aip, atp, (Pointer)gcp))
3225         goto erret;
3226     retval = TRUE;
3227 erret:
3228     AsnUnlinkType(orig);       /* unlink local tree */
3229     return retval;
3230 }
3231 /*****************************************************************************
3232 *
3233 *   GeneticCodePtr GeneticCodeAsnRead(aip, atp)
3234 *       atp is the current type (if identifier of a parent struct)
3235 *            assumption is readIdent has occurred
3236 *       if atp == NULL, then assumes it stands alone and read ident
3237 *            has not occurred.
3238 *
3239 *****************************************************************************/
GeneticCodeAsnRead(AsnIoPtr aip,AsnTypePtr orig)3240 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3241 {
3242     DataVal av;
3243     AsnTypePtr atp;
3244     GeneticCodePtr gcp = NULL, tmp = NULL;
3245 
3246     if (! loaded)
3247     {
3248         if (! SeqFeatAsnLoad())
3249             return 0;
3250     }
3251 
3252     if (aip == NULL)
3253         return 0;
3254 
3255     if (orig == NULL)           /* GeneticCode ::= (self contained) */
3256         atp = AsnReadId(aip, amp, GENETIC_CODE);
3257     else
3258         atp = AsnLinkType(orig, GENETIC_CODE);    /* link in local tree */
3259     if (atp == NULL)
3260         return 0;
3261 
3262     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
3263 
3264     gcp = GeneticCodeNew();
3265     if (gcp == NULL) goto erret;
3266 
3267     while((atp = AsnReadId(aip, amp, atp)) == GENETIC_CODE_E)
3268     {
3269         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3270         atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;    /* what kind? */
3271 
3272         tmp = ValNodeNew(tmp);
3273         if (tmp == NULL) goto erret;
3274         if (gcp->data.ptrvalue == NULL)
3275             gcp->data.ptrvalue = tmp;
3276 
3277         if (AsnReadVal(aip, atp, &tmp->data) <= 0) goto erret;
3278 
3279         if (atp == GENETIC_CODE_E_name)
3280             tmp->choice = 1;
3281         else if (atp == GENETIC_CODE_E_id)
3282             tmp->choice = 2;
3283         else if (atp == GENETIC_CODE_E_ncbieaa)
3284             tmp->choice = 3;
3285         else if (atp == GENETIC_CODE_E_ncbi8aa)
3286             tmp->choice = 4;
3287         else if (atp == GENETIC_CODE_E_ncbistdaa)
3288             tmp->choice = 5;
3289         else if (atp == GENETIC_CODE_E_sncbieaa)
3290             tmp->choice = 6;
3291         else if (atp == GENETIC_CODE_E_sncbi8aa)
3292             tmp->choice = 7;
3293         else if (atp == GENETIC_CODE_E_sncbistdaa)
3294             tmp->choice = 8;
3295         else
3296             tmp->choice = 255;   /* unrecognized */
3297     }
3298     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
3299     goto ret;
3300 
3301 erret:
3302     gcp = GeneticCodeFree(gcp);
3303 ret:
3304     AsnUnlinkType(orig);       /* unlink local tree */
3305     return gcp;
3306 }
3307 
3308 /*****************************************************************************
3309 *
3310 *   genCodeTblMemStr as last resort embedded version of gc.prt
3311 *
3312 *****************************************************************************/
3313 
3314 #ifndef WIN16
3315 static CharPtr genCodeTblMemStr = "Genetic-code-table ::= {\n" \
3316 "{ name \"Standard\" , name \"SGC0\" , id 1 ,\n" \
3317 "ncbieaa  \"FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3318 "sncbieaa \"---M------**--*----M---------------M----------------------------\" } ,\n" \
3319 "{ name \"Vertebrate Mitochondrial\" , name \"SGC1\" , id 2 ,\n" \
3320 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSS**VVVVAAAADDEEGGGG\",\n" \
3321 "sncbieaa \"----------**--------------------MMMM----------**---M------------\" } ,\n" \
3322 "{ name \"Yeast Mitochondrial\" , name \"SGC2\" , id 3 ,\n" \
3323 "ncbieaa  \"FFLLSSSSYY**CCWWTTTTPPPPHHQQRRRRIIMMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3324 "sncbieaa \"----------**----------------------MM----------------------------\" } ,\n" \
3325 "{ name \"Mold Mitochondrial; Protozoan Mitochondrial; Coelenterate\n" \
3326 "Mitochondrial; Mycoplasma; Spiroplasma\" ,\n" \
3327 "name \"SGC3\" , id 4 ,\n" \
3328 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3329 "sncbieaa \"--MM------**-------M------------MMMM---------------M------------\" } ,\n" \
3330 "{ name \"Invertebrate Mitochondrial\" , name \"SGC4\" , id 5 ,\n" \
3331 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSSSVVVVAAAADDEEGGGG\",\n" \
3332 "sncbieaa \"---M------**--------------------MMMM---------------M------------\" } ,\n" \
3333 "{ name \"Ciliate Nuclear; Dasycladacean Nuclear; Hexamita Nuclear\" ,\n" \
3334 "name \"SGC5\" , id 6 ,\n" \
3335 "ncbieaa  \"FFLLSSSSYYQQCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3336 "sncbieaa \"--------------*--------------------M----------------------------\" } ,\n" \
3337 "{ name \"Echinoderm Mitochondrial; Flatworm Mitochondrial\" , name \"SGC8\" , id 9 ,\n" \
3338 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG\",\n" \
3339 "sncbieaa \"----------**-----------------------M---------------M------------\" } ,\n" \
3340 "{ name \"Euplotid Nuclear\" , name \"SGC9\" , id 10 ,\n" \
3341 "ncbieaa  \"FFLLSSSSYY**CCCWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3342 "sncbieaa \"----------**-----------------------M----------------------------\" } ,\n" \
3343 "{ name \"Bacterial, Archaeal and Plant Plastid\" , id 11 ,\n" \
3344 "ncbieaa  \"FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3345 "sncbieaa \"---M------**--*----M------------MMMM---------------M------------\" } ,\n" \
3346 "{ name \"Alternative Yeast Nuclear\" , id 12 ,\n" \
3347 "ncbieaa  \"FFLLSSSSYY**CC*WLLLSPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3348 "sncbieaa \"----------**--*----M---------------M----------------------------\" } ,\n" \
3349 "{ name \"Ascidian Mitochondrial\" , id 13 ,\n" \
3350 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSGGVVVVAAAADDEEGGGG\",\n" \
3351 "sncbieaa \"---M------**----------------------MM---------------M------------\" } ,\n" \
3352 "{ name \"Alternative Flatworm Mitochondrial\" , id 14 ,\n" \
3353 "ncbieaa  \"FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG\",\n" \
3354 "sncbieaa \"-----------*-----------------------M----------------------------\" } ,\n" \
3355 "{ name \"Blepharisma Macronuclear\" , id 15 ,\n" \
3356 "ncbieaa  \"FFLLSSSSYY*QCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3357 "sncbieaa \"----------*---*--------------------M----------------------------\" } ,\n" \
3358 "{ name \"Chlorophycean Mitochondrial\" , id 16 ,\n" \
3359 "ncbieaa  \"FFLLSSSSYY*LCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3360 "sncbieaa \"----------*---*--------------------M----------------------------\" } ,\n" \
3361 "{ name \"Trematode Mitochondrial\" , id 21 ,\n" \
3362 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNNKSSSSVVVVAAAADDEEGGGG\",\n" \
3363 "sncbieaa \"----------**-----------------------M---------------M------------\" } ,\n" \
3364 "{ name \"Scenedesmus obliquus Mitochondrial\" , id 22 ,\n" \
3365 "ncbieaa  \"FFLLSS*SYY*LCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3366 "sncbieaa \"------*---*---*--------------------M----------------------------\" } ,\n" \
3367 "{ name \"Thraustochytrium Mitochondrial\" , id 23 ,\n" \
3368 "ncbieaa  \"FF*LSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3369 "sncbieaa \"--*-------**--*-----------------M--M---------------M------------\" } ,\n" \
3370 "{ name \"Pterobranchia Mitochondrial\" , id 24 ,\n" \
3371 "ncbieaa  \"FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSSKVVVVAAAADDEEGGGG\",\n" \
3372 "sncbieaa \"---M------**-------M---------------M---------------M------------\" } ,\n" \
3373 "{ name \"Candidate Division SR1 and Gracilibacteria\" , id 25 ,\n" \
3374 "ncbieaa  \"FFLLSSSSYY**CCGWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3375 "sncbieaa \"---M------**-----------------------M---------------M------------\" } ,\n" \
3376 "{ name \"Pachysolen tannophilus Nuclear\" , id 26 ,\n" \
3377 "ncbieaa  \"FFLLSSSSYY**CC*WLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3378 "sncbieaa \"----------**--*----M---------------M----------------------------\" } ,\n" \
3379 "{ name \"Karyorelict Nuclear\" , id 27 ,\n" \
3380 "ncbieaa  \"FFLLSSSSYYQQCCWWLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3381 "sncbieaa \"--------------*--------------------M----------------------------\" } ,\n" \
3382 "{ name \"Condylostoma Nuclear\" , id 28 ,\n" \
3383 "ncbieaa  \"FFLLSSSSYYQQCCWWLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3384 "sncbieaa \"----------**--*--------------------M----------------------------\" } ,\n" \
3385 "{ name \"Mesodinium Nuclear\" , id 29 ,\n" \
3386 "ncbieaa  \"FFLLSSSSYYYYCC*WLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3387 "sncbieaa \"--------------*--------------------M----------------------------\" } ,\n" \
3388 "{ name \"Peritrich Nuclear\" , id 30 ,\n" \
3389 "ncbieaa  \"FFLLSSSSYYEECC*WLLLAPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3390 "sncbieaa \"--------------*--------------------M----------------------------\" } ,\n" \
3391 "{ name \"Blastocrithidia Nuclear\" , id 31 ,\n" \
3392 "ncbieaa  \"FFLLSSSSYYEECCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG\",\n" \
3393 "sncbieaa \"----------**-----------------------M----------------------------\" } };\n";
3394 #endif
3395 
3396 /*****************************************************************************
3397 *
3398 *   GeneticCodePtr GeneticCodeTableLoad()
3399 *       loads all current genetic codes
3400 *       looks for "gc.val" in the "data" directory
3401 *       now uses genCodeTblMemStr if unable to find "data" directory
3402 *
3403 *****************************************************************************/
LoadGenCodeFromLocalString(void)3404 static Boolean LoadGenCodeFromLocalString (void)
3405 
3406 {
3407 #ifndef WIN16
3408   AsnIoMemPtr aimp;
3409 
3410   aimp = AsnIoMemOpen ("r", (BytePtr) genCodeTblMemStr, (Int4) StringLen (genCodeTblMemStr));
3411   if (aimp == NULL || aimp->aip == NULL) return FALSE;
3412   GeneticCodeTableAsnRead (aimp->aip, NULL);
3413   AsnIoMemClose (aimp);
3414 #endif
3415   return (Boolean) (genetic_codes != NULL);
3416 }
3417 
GeneticCodeTableLoad(void)3418 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeTableLoad (void)
3419 {
3420     Char buf[PATH_MAX];
3421     AsnIoPtr aip;
3422 
3423     if (genetic_codes != NULL)
3424         return genetic_codes;
3425 
3426     if (! loaded)
3427     {
3428         if (! SeqFeatAsnLoad())
3429             return (GeneticCodePtr)NULL;
3430     }
3431 
3432 #ifdef OS_UNIX
3433     if (getenv ("USE_GENCODE_FILE") == NULL) {
3434           if (LoadGenCodeFromLocalString ()) {
3435               return genetic_codes;
3436           }
3437     }
3438 #endif
3439 
3440     if (! FindPath("ncbi", "ncbi", "data", buf, sizeof (buf)))
3441     {
3442 
3443         if (LoadGenCodeFromLocalString ()) {
3444             return genetic_codes;
3445         }
3446 
3447         ErrPostEx(SEV_WARNING, 0, 0, "FindPath failed in GeneticCodeTableLoad - ncbi configuration file missing or incorrect");
3448         return genetic_codes;
3449     }
3450 
3451     StringCat(buf, "gc.val");
3452     if ((aip = AsnIoOpen(buf, "rb")) == NULL)
3453     {
3454 
3455         if (LoadGenCodeFromLocalString ()) {
3456             return genetic_codes;
3457         }
3458 
3459         ErrPostEx(SEV_WARNING, 0, 0, "Couldn't open [%s]", buf);
3460         return genetic_codes;
3461     }
3462 
3463     GeneticCodeTableAsnRead(aip, NULL);
3464 
3465     AsnIoClose(aip);
3466     return genetic_codes;
3467 }
3468 
3469 /*****************************************************************************
3470 *
3471 *   GeneticCodeFind (id, name)
3472 *       if (name == NULL)  finds by id
3473 *       returns NULL, if can't find anything
3474 *
3475 *****************************************************************************/
GeneticCodeFind(Int4 id,CharPtr name)3476 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeFind (Int4 id, CharPtr name)
3477 {
3478     GeneticCodePtr gcp;
3479     ValNodePtr tmp;
3480 
3481     if (GeneticCodeTableLoad() == NULL)
3482         return (GeneticCodePtr)NULL;
3483 
3484     for (gcp = genetic_codes; gcp != NULL; gcp = gcp->next)
3485     {
3486         for (tmp = (ValNodePtr) gcp->data.ptrvalue; tmp != NULL; tmp = tmp->next)
3487         {
3488             switch (tmp->choice)
3489             {
3490                 case 1:   /* name */
3491                     if (name != NULL)
3492                     {
3493                         if (! StringICmp(name, (CharPtr)tmp->data.ptrvalue))
3494                             return gcp;
3495                     }
3496                     break;
3497                 case 2:   /* id */
3498                     if (name == NULL)
3499                     {
3500                         if (id == tmp->data.intvalue)
3501                             return gcp;
3502                     }
3503                     break;
3504                 default:
3505                     break;
3506             }
3507         }
3508     }
3509 
3510     return (GeneticCodePtr)NULL;
3511 }
3512 
3513 
3514 /*****************************************************************************
3515 *
3516 *   GeneticCodeTableAsnWrite(gcp, aip, atp)
3517 *       atp is the current type (if identifier of a parent struct)
3518 *       if atp == NULL, then assumes it stands alone (Genetic-code-table ::=)
3519 *
3520 *****************************************************************************/
GeneticCodeTableAsnWrite(GeneticCodePtr gcp,AsnIoPtr aip,AsnTypePtr orig)3521 NLM_EXTERN Boolean LIBCALL GeneticCodeTableAsnWrite (GeneticCodePtr gcp, AsnIoPtr aip, AsnTypePtr orig)
3522 {
3523     GeneticCodePtr tmp;
3524     AsnTypePtr atp;
3525     Boolean retval = FALSE;
3526 
3527     if (! loaded)
3528     {
3529         if (! SeqFeatAsnLoad())
3530             return FALSE;
3531     }
3532 
3533     if (aip == NULL)
3534         return FALSE;
3535 
3536     atp = AsnLinkType(orig, GENETIC_CODE_TABLE);   /* link local tree */
3537     if (atp == NULL)
3538         return FALSE;
3539 
3540     if (gcp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3541 
3542     if (! AsnOpenStruct(aip, atp, (Pointer)gcp))
3543         goto erret;
3544 
3545     tmp = gcp;
3546     while (tmp != NULL)
3547     {
3548         if (! GeneticCodeAsnWrite(tmp, aip, GENETIC_CODE_TABLE_E))
3549             goto erret;
3550         tmp = tmp->next;
3551     }
3552 
3553     if (! AsnCloseStruct(aip, atp, (Pointer)gcp))
3554         goto erret;
3555     retval = TRUE;
3556 erret:
3557     AsnUnlinkType(orig);       /* unlink local tree */
3558     return retval;
3559 }
3560 
3561 /*****************************************************************************
3562 *
3563 *   GeneticCodePtr GeneticCodeTableAsnRead(aip, atp)
3564 *       atp is the current type (if identifier of a parent struct)
3565 *            assumption is readIdent has occurred
3566 *       if atp == NULL, then assumes it stands alone and read ident
3567 *            has not occurred.
3568 *
3569 *****************************************************************************/
GeneticCodeTableAsnRead(AsnIoPtr aip,AsnTypePtr orig)3570 NLM_EXTERN GeneticCodePtr LIBCALL GeneticCodeTableAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3571 {
3572     DataVal av;
3573     AsnTypePtr atp;
3574     GeneticCodePtr gcp = NULL, tmp = NULL;
3575 
3576     if (! loaded)
3577     {
3578         if (! SeqFeatAsnLoad())
3579             return 0;
3580     }
3581 
3582     if (aip == NULL)
3583         return 0;
3584 
3585     if (orig == NULL)           /* Genetic-code-table ::= (self contained) */
3586         atp = AsnReadId(aip, amp, GENETIC_CODE_TABLE);
3587     else
3588         atp = AsnLinkType(orig, GENETIC_CODE_TABLE);    /* link in local tree */
3589     if (atp == NULL)
3590         return 0;
3591 
3592     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
3593 
3594     while((atp = AsnReadId(aip, amp, atp)) == GENETIC_CODE_TABLE_E)
3595     {
3596         if ((tmp = GeneticCodeAsnRead(aip, atp)) == NULL) goto erret;
3597         if (gcp == NULL)     /* keep first one */
3598             gcp = tmp;
3599         GeneticCodeAdd(tmp);   /* add to global genetic_codes */
3600     }
3601     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
3602     goto ret;
3603 
3604 erret:
3605     while (gcp != NULL)
3606     {
3607         tmp = gcp->next;
3608         gcp = GeneticCodeFree(gcp);
3609         gcp = tmp;
3610     }
3611 ret:
3612     AsnUnlinkType(orig);       /* unlink local tree */
3613     return gcp;
3614 }
3615 
3616 /*****************************************************************************
3617 *
3618 *   CodeBreakNew()
3619 *
3620 *****************************************************************************/
CodeBreakNew(void)3621 NLM_EXTERN CodeBreakPtr LIBCALL CodeBreakNew (void)
3622 {
3623     return (CodeBreakPtr)MemNew(sizeof(CodeBreak));
3624 }
3625 
3626 /*****************************************************************************
3627 *
3628 *   CodeBreakFree(cbp)
3629 *       Frees a chain of CodeBreak and associated data
3630 *
3631 *****************************************************************************/
CodeBreakFree(CodeBreakPtr cbp)3632 NLM_EXTERN CodeBreakPtr LIBCALL CodeBreakFree (CodeBreakPtr cbp)
3633 {
3634     CodeBreakPtr next;
3635 
3636     while (cbp != NULL)
3637     {
3638         next = cbp->next;
3639         SeqLocFree(cbp->loc);
3640         MemFree(cbp);
3641         cbp = next;
3642     }
3643     return (CodeBreakPtr)NULL;
3644 }
3645 
3646 /*****************************************************************************
3647 *
3648 *   CodeBreakAsnWrite(cbp, aip, atp)
3649 *       atp is the current type (if identifier of a parent struct)
3650 *       if atp == NULL, then assumes it stands alone (CodeBreak ::=)
3651 *
3652 *****************************************************************************/
CodeBreakAsnWrite(CodeBreakPtr cbp,AsnIoPtr aip,AsnTypePtr orig)3653 NLM_EXTERN Boolean LIBCALL CodeBreakAsnWrite (CodeBreakPtr cbp, AsnIoPtr aip, AsnTypePtr orig)
3654 {
3655     DataVal av;
3656     AsnTypePtr atp, tmp = NULL;
3657     Boolean retval = FALSE;
3658 
3659     if (! loaded)
3660     {
3661         if (! SeqFeatAsnLoad())
3662             return FALSE;
3663     }
3664 
3665     if (aip == NULL)
3666         return FALSE;
3667 
3668     atp = AsnLinkType(orig, CODE_BREAK);   /* link local tree */
3669     if (atp == NULL)
3670         return FALSE;
3671 
3672     if (cbp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3673 
3674     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3675 
3676     if (! AsnOpenStruct(aip, atp, (Pointer)cbp))
3677         goto erret;
3678 
3679     if (! SeqLocAsnWrite(cbp->loc, aip, CODE_BREAK_loc))
3680         goto erret;
3681     av.intvalue = cbp->aa.value.intvalue;
3682     if (! AsnWriteChoice(aip, CODE_BREAK_aa, (Int2)cbp->aa.choice, &av)) goto erret;
3683     switch(cbp->aa.choice)
3684     {
3685         case 1:
3686             tmp = CODE_BREAK_aa_ncbieaa;
3687             break;
3688         case 2:
3689             tmp = CODE_BREAK_aa_ncbi8aa;
3690             break;
3691         case 3:
3692             tmp = CODE_BREAK_aa_ncbistdaa;
3693             break;
3694     }
3695     if (! AsnWrite(aip, tmp, &av)) goto erret;
3696     if (! AsnCloseStruct(aip, atp, (Pointer)cbp))
3697         goto erret;
3698     retval = TRUE;
3699 erret:
3700     AsnUnlinkType(orig);       /* unlink local tree */
3701     return retval;
3702 }
3703 
3704 /*****************************************************************************
3705 *
3706 *   CodeBreakAsnRead(aip, atp)
3707 *       atp is the current type (if identifier of a parent struct)
3708 *            assumption is readIdent has occurred
3709 *       if atp == NULL, then assumes it stands alone and read ident
3710 *            has not occurred.
3711 *
3712 *****************************************************************************/
CodeBreakAsnRead(AsnIoPtr aip,AsnTypePtr orig)3713 NLM_EXTERN CodeBreakPtr LIBCALL CodeBreakAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3714 {
3715     DataVal av;
3716     AsnTypePtr atp;
3717     CodeBreakPtr cbp;
3718     Uint1 choice = 0;
3719 
3720     if (! loaded)
3721     {
3722         if (! SeqFeatAsnLoad())
3723             return (CodeBreakPtr)NULL;
3724     }
3725 
3726     if (aip == NULL)
3727         return (CodeBreakPtr)NULL;
3728 
3729     if (orig == NULL)           /* CodeBreak ::= (self contained) */
3730         atp = AsnReadId(aip, amp, CODE_BREAK);
3731     else
3732         atp = AsnLinkType(orig, CODE_BREAK);    /* link in local tree */
3733     if (atp == NULL)
3734         return (CodeBreakPtr)NULL;
3735 
3736     cbp = CodeBreakNew();
3737     if (cbp == NULL)
3738         goto erret;
3739 
3740     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
3741     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;   /* location */
3742     cbp->loc = SeqLocAsnRead(aip, atp);
3743     if (cbp->loc == NULL)
3744         goto erret;
3745     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;    /* read the CHOICE */
3746     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3747     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;    /* the aa */
3748     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3749     cbp->aa.value.intvalue = av.intvalue;
3750     if (atp == CODE_BREAK_aa_ncbieaa)
3751         choice = 1;
3752     else if (atp == CODE_BREAK_aa_ncbi8aa)
3753         choice = 2;
3754     else if (atp == CODE_BREAK_aa_ncbistdaa)
3755         choice = 3;
3756     cbp->aa.choice = choice;
3757 
3758     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
3759     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
3760 ret:
3761     AsnUnlinkType(orig);       /* unlink local tree */
3762     return cbp;
3763 erret:
3764     cbp = CodeBreakFree(cbp);
3765     goto ret;
3766 }
3767 
3768 /*****************************************************************************
3769 *
3770 *   ImpFeatNew()
3771 *
3772 *****************************************************************************/
ImpFeatNew(void)3773 NLM_EXTERN ImpFeatPtr LIBCALL ImpFeatNew (void)
3774 {
3775     return (ImpFeatPtr)MemNew(sizeof(ImpFeat));
3776 }
3777 
3778 /*****************************************************************************
3779 *
3780 *   ImpFeatFree(ifp)
3781 *       Frees an ImpFeat and associated data
3782 *
3783 *****************************************************************************/
ImpFeatFree(ImpFeatPtr ifp)3784 NLM_EXTERN ImpFeatPtr LIBCALL ImpFeatFree (ImpFeatPtr ifp)
3785 {
3786     if (ifp == NULL)
3787         return (ImpFeatPtr)NULL;
3788 
3789     MemFree(ifp->key);
3790     MemFree(ifp->loc);
3791     MemFree(ifp->descr);
3792     return (ImpFeatPtr)MemFree(ifp);
3793 }
3794 
3795 /*****************************************************************************
3796 *
3797 *   ImpFeatAsnWrite(ifp, aip, atp)
3798 *       atp is the current type (if identifier of a parent struct)
3799 *       if atp == NULL, then assumes it stands alone (ImpFeat ::=)
3800 *
3801 *****************************************************************************/
ImpFeatAsnWrite(ImpFeatPtr ifp,AsnIoPtr aip,AsnTypePtr orig)3802 NLM_EXTERN Boolean LIBCALL ImpFeatAsnWrite (ImpFeatPtr ifp, AsnIoPtr aip, AsnTypePtr orig)
3803 {
3804     DataVal av;
3805     AsnTypePtr atp;
3806     Boolean retval = FALSE;
3807 
3808     if (! loaded)
3809     {
3810         if (! SeqFeatAsnLoad())
3811             return FALSE;
3812     }
3813 
3814     if (aip == NULL)
3815         return FALSE;
3816 
3817     atp = AsnLinkType(orig, IMP_FEAT);   /* link local tree */
3818     if (atp == NULL)
3819         return FALSE;
3820 
3821     if (ifp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3822 
3823     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3824 
3825     if (! AsnOpenStruct(aip, atp, (Pointer)ifp))
3826         goto erret;
3827 
3828     av.ptrvalue = ifp->key;
3829     if (! AsnWrite(aip, IMP_FEAT_key, &av)) goto erret;
3830     if (ifp->loc != NULL)
3831     {
3832         av.ptrvalue = ifp->loc;
3833         if (! AsnWrite(aip, IMP_FEAT_loc, &av)) goto erret;
3834     }
3835     if (ifp->descr != NULL)
3836     {
3837         av.ptrvalue = ifp->descr;
3838         if (! AsnWrite(aip, IMP_FEAT_descr, &av)) goto erret;
3839     }
3840     if (! AsnCloseStruct(aip, atp, (Pointer)ifp))
3841         goto erret;
3842     retval = TRUE;
3843 erret:
3844     AsnUnlinkType(orig);       /* unlink local tree */
3845     return retval;
3846 }
3847 
3848 /*****************************************************************************
3849 *
3850 *   ImpFeatAsnRead(aip, atp)
3851 *       atp is the current type (if identifier of a parent struct)
3852 *            assumption is readIdent has occurred
3853 *       if atp == NULL, then assumes it stands alone and read ident
3854 *            has not occurred.
3855 *
3856 *****************************************************************************/
ImpFeatAsnRead(AsnIoPtr aip,AsnTypePtr orig)3857 NLM_EXTERN ImpFeatPtr LIBCALL ImpFeatAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3858 {
3859     DataVal av;
3860     AsnTypePtr atp, oldatp;
3861     ImpFeatPtr ifp;
3862 
3863     if (! loaded)
3864     {
3865         if (! SeqFeatAsnLoad())
3866             return (ImpFeatPtr)NULL;
3867     }
3868 
3869     if (aip == NULL)
3870         return (ImpFeatPtr)NULL;
3871 
3872     if (orig == NULL)           /* ImpFeat ::= (self contained) */
3873         atp = AsnReadId(aip, amp, IMP_FEAT);
3874     else
3875         atp = AsnLinkType(orig, IMP_FEAT);    /* link in local tree */
3876     oldatp = atp;
3877 
3878     if (atp == NULL)
3879         return (ImpFeatPtr)NULL;
3880 
3881     ifp = ImpFeatNew();
3882     if (ifp == NULL)
3883         goto erret;
3884 
3885     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
3886 
3887     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
3888     {
3889         if (atp == NULL)
3890             goto erret;
3891         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3892         if (atp == IMP_FEAT_key)
3893             ifp->key = (CharPtr)av.ptrvalue;
3894         else if (atp == IMP_FEAT_loc)
3895             ifp->loc = (CharPtr)av.ptrvalue;
3896         else if (atp == IMP_FEAT_descr)
3897             ifp->descr = (CharPtr)av.ptrvalue;
3898     }
3899     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
3900 ret:
3901     AsnUnlinkType(orig);       /* unlink local tree */
3902     return ifp;
3903 erret:
3904     ifp = ImpFeatFree(ifp);
3905     goto ret;
3906 }
3907 
3908 /*****************************************************************************
3909 *
3910 *   RnaRefNew()
3911 *
3912 *****************************************************************************/
RnaRefNew(void)3913 NLM_EXTERN RnaRefPtr LIBCALL RnaRefNew (void)
3914 {
3915     return (RnaRefPtr)MemNew(sizeof(RnaRef));
3916 }
3917 
3918 /*****************************************************************************
3919 *
3920 *   RnaRefFree(rrp)
3921 *       Frees an RnaRef and associated data
3922 *
3923 *****************************************************************************/
RnaRefFree(RnaRefPtr rrp)3924 NLM_EXTERN RnaRefPtr LIBCALL RnaRefFree (RnaRefPtr rrp)
3925 {
3926     tRNAPtr trna;
3927     RNAGenPtr rgp;
3928 
3929     if (rrp == NULL)
3930         return (RnaRefPtr)NULL;
3931 
3932     if (rrp->ext.choice == 1)  /* name */
3933         MemFree(rrp->ext.value.ptrvalue);
3934     else if (rrp->ext.choice == 2)   /* tRNA */
3935     {
3936         trna = (tRNAPtr)(rrp->ext.value.ptrvalue);
3937         SeqLocFree(trna->anticodon);
3938         MemFree(trna);
3939     }
3940     else if (rrp->ext.choice == 3)   /* gen */
3941     {
3942         rgp = (RNAGenPtr)(rrp->ext.value.ptrvalue);
3943         RNAGenFree(rgp);
3944     }
3945     return (RnaRefPtr)MemFree(rrp);
3946 }
3947 
3948 /*****************************************************************************
3949 *
3950 *   RnaRefAsnWrite(rrp, aip, atp)
3951 *       atp is the current type (if identifier of a parent struct)
3952 *       if atp == NULL, then assumes it stands alone (RnaRef ::=)
3953 *
3954 *****************************************************************************/
RnaRefAsnWrite(RnaRefPtr rrp,AsnIoPtr aip,AsnTypePtr orig)3955 NLM_EXTERN Boolean LIBCALL RnaRefAsnWrite (RnaRefPtr rrp, AsnIoPtr aip, AsnTypePtr orig)
3956 {
3957     DataVal av;
3958     AsnTypePtr atp, tmp = NULL;
3959     tRNAPtr trna;
3960     RNAGenPtr rgp;
3961     Int2 i;
3962     Boolean first = TRUE, retval = FALSE;
3963 
3964     if (! loaded)
3965     {
3966         if (! SeqFeatAsnLoad())
3967             return FALSE;
3968     }
3969 
3970     if (aip == NULL)
3971         return FALSE;
3972 
3973     atp = AsnLinkType(orig, RNA_REF);   /* link local tree */
3974     if (atp == NULL)
3975         return FALSE;
3976 
3977     if (rrp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3978 
3979     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3980 
3981     if (! AsnOpenStruct(aip, atp, (Pointer)rrp))
3982         goto erret;
3983 
3984     av.intvalue = rrp->type;
3985     if (! AsnWrite(aip, RNA_REF_type, &av)) goto erret;
3986     if (rrp->pseudo)
3987     {
3988         av.boolvalue = rrp->pseudo;
3989         if (! AsnWrite(aip, RNA_REF_pseudo, &av)) goto erret;
3990     }
3991     if (rrp->ext.choice)
3992     {
3993         av.ptrvalue = rrp->ext.value.ptrvalue;
3994         if (! AsnWriteChoice(aip, RNA_REF_ext, (Int2)rrp->ext.choice, &av)) goto erret;
3995         if (rrp->ext.choice == 1)   /* name */
3996         {
3997             if (! AsnWrite(aip, RNA_REF_ext_name, &av)) goto erret;
3998         }
3999         else if (rrp->ext.choice == 2)   /* trna */
4000         {
4001             trna = (tRNAPtr)rrp->ext.value.ptrvalue;
4002             if (! AsnOpenStruct(aip, RNA_REF_ext_tRNA, (Pointer)trna))
4003                 goto erret;
4004             if (trna->aatype)
4005             {
4006                 av.intvalue = trna->aa;
4007                 if (! AsnWriteChoice(aip, TRNA_EXT_aa, (Int2)trna->aatype, &av)) goto erret;
4008                 switch (trna->aatype)
4009                 {
4010                     case 1:
4011                         tmp = TRNA_EXT_aa_iupacaa;
4012                         break;
4013                     case 2:
4014                         tmp = TRNA_EXT_aa_ncbieaa;
4015                         break;
4016                     case 3:
4017                         tmp = TRNA_EXT_aa_ncbi8aa;
4018                         break;
4019                     case 4:
4020                         tmp = TRNA_EXT_aa_ncbistdaa;
4021                         break;
4022                 }
4023                 if (! AsnWrite(aip, tmp, &av)) goto erret;
4024             }
4025             for (i = 0; i < 6; i++)
4026             {
4027                 if (trna->codon[i] != 255)
4028                 {
4029                     if (first)
4030                     {
4031                         if (! AsnOpenStruct(aip, TRNA_EXT_codon, (Pointer)trna->codon))
4032                             goto erret;
4033                         first = FALSE;
4034                     }
4035                     av.intvalue = trna->codon[i];
4036                     if (! AsnWrite(aip, TRNA_EXT_codon_E, &av)) goto erret;
4037                 }
4038             }
4039             if (! first)    /* wrote one */
4040                 if (! AsnCloseStruct(aip, TRNA_EXT_codon, (Pointer)trna->codon))
4041                     goto erret;
4042             if (trna->anticodon != NULL)
4043                 if (! SeqLocAsnWrite(trna->anticodon, aip, TRNA_EXT_anticodon))
4044                     goto erret;
4045 
4046             if (! AsnCloseStruct(aip, RNA_REF_ext_tRNA, (Pointer)trna))
4047                 goto erret;
4048         }
4049         else if (rrp->ext.choice == 3)   /* gen */
4050         {
4051             rgp = (RNAGenPtr)(rrp->ext.value.ptrvalue);
4052             if (! RNAGenAsnWrite (rgp, aip, RNA_REF_ext_gen))
4053                 goto erret;
4054         }
4055     }
4056     if (! AsnCloseStruct(aip, atp, (Pointer)rrp))
4057         goto erret;
4058     retval = TRUE;
4059 erret:
4060     AsnUnlinkType(orig);       /* unlink local tree */
4061     return retval;
4062 }
4063 
4064 /*****************************************************************************
4065 *
4066 *   RnaRefAsnRead(aip, atp)
4067 *       atp is the current type (if identifier of a parent struct)
4068 *            assumption is readIdent has occurred
4069 *       if atp == NULL, then assumes it stands alone and read ident
4070 *            has not occurred.
4071 *
4072 *****************************************************************************/
RnaRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)4073 NLM_EXTERN RnaRefPtr LIBCALL RnaRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
4074 {
4075     DataVal av;
4076     AsnTypePtr atp, oldatp;
4077     RnaRefPtr rrp;
4078     tRNAPtr trna = NULL;
4079     Int2 i = 0;
4080 
4081     if (! loaded)
4082     {
4083         if (! SeqFeatAsnLoad())
4084             return (RnaRefPtr)NULL;
4085     }
4086 
4087     if (aip == NULL)
4088         return (RnaRefPtr)NULL;
4089 
4090     if (orig == NULL)           /* RnaRef ::= (self contained) */
4091         atp = AsnReadId(aip, amp, RNA_REF);
4092     else
4093         atp = AsnLinkType(orig, RNA_REF);    /* link in local tree */
4094     oldatp = atp;
4095     if (atp == NULL)
4096         return (RnaRefPtr)NULL;
4097 
4098     rrp = RnaRefNew();
4099     if (rrp == NULL)
4100         goto erret;
4101 
4102     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
4103 
4104     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
4105     {
4106         if (atp == NULL)
4107             goto erret;
4108         if (atp == TRNA_EXT_anticodon)
4109         {
4110             trna->anticodon = SeqLocAsnRead(aip, atp);
4111             if (trna->anticodon == NULL) goto erret;
4112         }
4113         else
4114         {
4115             if (atp == RNA_REF_type)
4116             {
4117                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4118                 rrp->type = (Uint1)av.intvalue;
4119             }
4120             else if (atp == RNA_REF_pseudo)
4121             {
4122                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4123                 rrp->pseudo = av.boolvalue;
4124             }
4125             else if (atp == RNA_REF_ext_name)
4126             {
4127                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4128                 rrp->ext.choice = 1;
4129                 rrp->ext.value.ptrvalue = av.ptrvalue;
4130             }
4131             else if (atp == RNA_REF_ext_tRNA)   /* its a trna */
4132             {
4133                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4134                 if (trna == NULL)   /* first time */
4135                 {
4136                     rrp->ext.choice = 2;
4137                     trna = (tRNAPtr)MemNew(sizeof(tRNA));
4138                     if (trna == NULL)
4139                         goto erret;
4140                     rrp->ext.value.ptrvalue = trna;
4141                     for (i = 0; i < 6; i++)
4142                         trna->codon[i] = 255;   /* not used */
4143                     i = 0;
4144                 }
4145             }
4146             else if (atp == TRNA_EXT_aa_iupacaa)
4147             {
4148                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4149                 trna->aatype = 1;
4150                 trna->aa = (Uint1)av.intvalue;
4151             }
4152             else if (atp == TRNA_EXT_aa_ncbieaa)
4153             {
4154                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4155                 trna->aatype = 2;
4156                 trna->aa = (Uint1)av.intvalue;
4157             }
4158             else if (atp == TRNA_EXT_aa_ncbi8aa)
4159             {
4160                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4161                 trna->aatype = 3;
4162                 trna->aa = (Uint1)av.intvalue;
4163             }
4164             else if (atp == TRNA_EXT_aa_ncbistdaa)
4165             {
4166                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4167                 trna->aatype = 4;
4168                 trna->aa = (Uint1)av.intvalue;
4169             }
4170             else if (atp == TRNA_EXT_codon_E)
4171             {
4172                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4173                 if (i < 6) {
4174                     trna->codon[i] = (Uint1)av.intvalue;
4175                 }
4176                 i++;
4177             }
4178             else if (atp == RNA_REF_ext_gen)
4179             {
4180                 rrp->ext.choice = 3;
4181                 rrp->ext.value.ptrvalue = RNAGenAsnRead (aip, atp);
4182             } else {
4183                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
4184             }
4185         }
4186     }
4187     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
4188 ret:
4189     AsnUnlinkType(orig);       /* unlink local tree */
4190     return rrp;
4191 erret:
4192     rrp = RnaRefFree(rrp);
4193     goto ret;
4194 }
4195 
4196 
4197 
4198 /**************************************************
4199 *
4200 *    RNAQualNew()
4201 *
4202 **************************************************/
4203 NLM_EXTERN
4204 RNAQualPtr LIBCALL
RNAQualNew(void)4205 RNAQualNew(void)
4206 {
4207    RNAQualPtr rqp = MemNew((size_t) sizeof(RNAQual));
4208 
4209    return rqp;
4210 
4211 }
4212 
4213 
4214 /**************************************************
4215 *
4216 *    RNAQualFree()
4217 *
4218 **************************************************/
4219 NLM_EXTERN
4220 RNAQualPtr LIBCALL
RNAQualFree(RNAQualPtr rqp)4221 RNAQualFree(RNAQualPtr rqp)
4222 {
4223 
4224    if(rqp == NULL) {
4225       return NULL;
4226    }
4227    MemFree(rqp -> qual);
4228    MemFree(rqp -> val);
4229    return MemFree(rqp);
4230 }
4231 
4232 
4233 /**************************************************
4234 *
4235 *    RNAQualAsnRead()
4236 *
4237 **************************************************/
4238 NLM_EXTERN
4239 RNAQualPtr LIBCALL
RNAQualAsnRead(AsnIoPtr aip,AsnTypePtr orig)4240 RNAQualAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4241 {
4242    DataVal av;
4243    AsnTypePtr atp;
4244    AsnReadFunc func;
4245    RNAQualPtr rqp;
4246 
4247    if (! loaded)
4248    {
4249       if (! SeqFeatAsnLoad()) {
4250          return NULL;
4251       }
4252    }
4253 
4254    if (aip == NULL) {
4255       return NULL;
4256    }
4257 
4258    if (orig == NULL) {         /* RNAQual ::= (self contained) */
4259       atp = AsnReadId(aip, amp, RNA_QUAL);
4260    } else {
4261       atp = AsnLinkType(orig, RNA_QUAL);
4262    }
4263    /* link in local tree */
4264    if (atp == NULL) {
4265       return NULL;
4266    }
4267 
4268    rqp = RNAQualNew();
4269    if (rqp == NULL) {
4270       goto erret;
4271    }
4272    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
4273       goto erret;
4274    }
4275 
4276    atp = AsnReadId(aip,amp, atp);
4277    func = NULL;
4278 
4279    if (atp == RNA_QUAL_qual) {
4280       if ( AsnReadVal(aip, atp, &av) <= 0) {
4281          goto erret;
4282       }
4283       rqp -> qual = av.ptrvalue;
4284       atp = AsnReadId(aip,amp, atp);
4285    }
4286    if (atp == RNA_QUAL_val) {
4287       if ( AsnReadVal(aip, atp, &av) <= 0) {
4288          goto erret;
4289       }
4290       rqp -> val = av.ptrvalue;
4291       atp = AsnReadId(aip,amp, atp);
4292    }
4293 
4294    if (AsnReadVal(aip, atp, &av) <= 0) {
4295       goto erret;
4296    }
4297    /* end struct */
4298 
4299 ret:
4300    AsnUnlinkType(orig);       /* unlink local tree */
4301    return rqp;
4302 
4303 erret:
4304    aip -> io_failure = TRUE;
4305    rqp = RNAQualFree(rqp);
4306    goto ret;
4307 }
4308 
4309 
4310 
4311 /**************************************************
4312 *
4313 *    RNAQualAsnWrite()
4314 *
4315 **************************************************/
4316 NLM_EXTERN Boolean LIBCALL
RNAQualAsnWrite(RNAQualPtr rqp,AsnIoPtr aip,AsnTypePtr orig)4317 RNAQualAsnWrite(RNAQualPtr rqp, AsnIoPtr aip, AsnTypePtr orig)
4318 {
4319    DataVal av;
4320    AsnTypePtr atp;
4321    Boolean retval = FALSE;
4322 
4323    if (! loaded)
4324    {
4325       if (! SeqFeatAsnLoad()) {
4326          return FALSE;
4327       }
4328    }
4329 
4330    if (aip == NULL) {
4331       return FALSE;
4332    }
4333 
4334    atp = AsnLinkType(orig, RNA_QUAL);   /* link local tree */
4335    if (atp == NULL) {
4336       return FALSE;
4337    }
4338 
4339    if (rqp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4340 
4341     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4342 
4343    if (! AsnOpenStruct(aip, atp, (Pointer) rqp)) {
4344       goto erret;
4345    }
4346 
4347    if (rqp -> qual != NULL) {
4348       av.ptrvalue = rqp -> qual;
4349       retval = AsnWrite(aip, RNA_QUAL_qual,  &av);
4350    }
4351    if (rqp -> val != NULL) {
4352       av.ptrvalue = rqp -> val;
4353       retval = AsnWrite(aip, RNA_QUAL_val,  &av);
4354    }
4355    if (! AsnCloseStruct(aip, atp, (Pointer)rqp)) {
4356       goto erret;
4357    }
4358    retval = TRUE;
4359 
4360 erret:
4361    AsnUnlinkType(orig);       /* unlink local tree */
4362    return retval;
4363 }
4364 
4365 
4366 
4367 /**************************************************
4368 *
4369 *    RNAQualSetFree()
4370 *
4371 **************************************************/
4372 NLM_EXTERN
4373 RNAQualSetPtr LIBCALL
RNAQualSetFree(RNAQualSetPtr rqp)4374 RNAQualSetFree(RNAQualSetPtr rqp)
4375 {
4376 
4377    if(rqp == NULL) {
4378       return NULL;
4379    }
4380    AsnGenericUserSeqOfFree(rqp,  (AsnOptFreeFunc) RNAQualFree);
4381    return NULL;
4382 }
4383 
4384 
4385 /**************************************************
4386 *
4387 *    RNAQualSetAsnRead()
4388 *
4389 **************************************************/
4390 NLM_EXTERN
4391 RNAQualSetPtr LIBCALL
RNAQualSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)4392 RNAQualSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4393 {
4394    AsnTypePtr atp;
4395    Boolean isError = FALSE;
4396    AsnReadFunc func;
4397    RNAQualSetPtr rqp;
4398 
4399    if (! loaded)
4400    {
4401       if (! SeqFeatAsnLoad()) {
4402          return NULL;
4403       }
4404    }
4405 
4406    if (aip == NULL) {
4407       return NULL;
4408    }
4409 
4410    if (orig == NULL) {         /* RNAQualSet ::= (self contained) */
4411       atp = AsnReadId(aip, amp, RNA_QUAL_SET);
4412    } else {
4413       atp = AsnLinkType(orig, RNA_QUAL_SET);
4414    }
4415    /* link in local tree */
4416    if (atp == NULL) {
4417       return NULL;
4418    }
4419 
4420    func = NULL;
4421 
4422    rqp  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) RNAQualAsnRead, (AsnOptFreeFunc) RNAQualFree);
4423    if (isError && rqp  == NULL) {
4424       goto erret;
4425    }
4426 
4427 
4428 
4429 ret:
4430    AsnUnlinkType(orig);       /* unlink local tree */
4431    return rqp;
4432 
4433 erret:
4434    aip -> io_failure = TRUE;
4435    rqp = RNAQualSetFree(rqp);
4436    goto ret;
4437 }
4438 
4439 
4440 
4441 /**************************************************
4442 *
4443 *    RNAQualSetAsnWrite()
4444 *
4445 **************************************************/
4446 NLM_EXTERN Boolean LIBCALL
RNAQualSetAsnWrite(RNAQualSetPtr rqp,AsnIoPtr aip,AsnTypePtr orig)4447 RNAQualSetAsnWrite(RNAQualSetPtr rqp, AsnIoPtr aip, AsnTypePtr orig)
4448 {
4449    AsnTypePtr atp;
4450    Boolean retval = FALSE;
4451 
4452    if (! loaded)
4453    {
4454       if (! SeqFeatAsnLoad()) {
4455          return FALSE;
4456       }
4457    }
4458 
4459    if (aip == NULL) {
4460       return FALSE;
4461    }
4462 
4463    atp = AsnLinkType(orig, RNA_QUAL_SET);   /* link local tree */
4464    if (atp == NULL) {
4465       return FALSE;
4466    }
4467 
4468    if (rqp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4469    retval = AsnGenericUserSeqOfAsnWrite(rqp , (AsnWriteFunc) RNAQualAsnWrite, aip, atp, RNA_QUAL_SET_E);
4470    retval = TRUE;
4471 
4472 erret:
4473    AsnUnlinkType(orig);       /* unlink local tree */
4474    return retval;
4475 }
4476 
4477 
4478 /**************************************************
4479 *
4480 *    RNAGenNew()
4481 *
4482 **************************************************/
4483 NLM_EXTERN
4484 RNAGenPtr LIBCALL
RNAGenNew(void)4485 RNAGenNew(void)
4486 {
4487    RNAGenPtr rgp = MemNew((size_t) sizeof(RNAGen));
4488    return rgp;
4489 
4490 }
4491 
4492 
4493 /**************************************************
4494 *
4495 *    RNAGenFree()
4496 *
4497 **************************************************/
4498 NLM_EXTERN
4499 RNAGenPtr LIBCALL
RNAGenFree(RNAGenPtr rgp)4500 RNAGenFree(RNAGenPtr rgp)
4501 {
4502 
4503    if(rgp == NULL) {
4504       return NULL;
4505    }
4506    MemFree(rgp -> _class);
4507    MemFree(rgp -> product);
4508    RNAQualSetFree(rgp -> quals);
4509    return MemFree(rgp);
4510 }
4511 
4512 
4513 /**************************************************
4514 *
4515 *    RNAGenAsnRead()
4516 *
4517 **************************************************/
4518 NLM_EXTERN
4519 RNAGenPtr LIBCALL
RNAGenAsnRead(AsnIoPtr aip,AsnTypePtr orig)4520 RNAGenAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4521 {
4522    DataVal av;
4523    AsnTypePtr atp;
4524    AsnReadFunc func;
4525    RNAGenPtr rgp;
4526 
4527    if (! loaded)
4528    {
4529       if (! SeqFeatAsnLoad()) {
4530          return NULL;
4531       }
4532    }
4533 
4534    if (aip == NULL) {
4535       return NULL;
4536    }
4537 
4538    if (orig == NULL) {         /* RNAGen ::= (self contained) */
4539       atp = AsnReadId(aip, amp, RNA_GEN);
4540    } else {
4541       atp = AsnLinkType(orig, RNA_GEN);
4542    }
4543    /* link in local tree */
4544    if (atp == NULL) {
4545       return NULL;
4546    }
4547 
4548    rgp = RNAGenNew();
4549    if (rgp == NULL) {
4550       goto erret;
4551    }
4552    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
4553       goto erret;
4554    }
4555 
4556    atp = AsnReadId(aip,amp, atp);
4557    func = NULL;
4558 
4559    if (atp == RNA_GEN_class) {
4560       if ( AsnReadVal(aip, atp, &av) <= 0) {
4561          goto erret;
4562       }
4563       rgp -> _class = av.ptrvalue;
4564       atp = AsnReadId(aip,amp, atp);
4565    }
4566    if (atp == RNA_GEN_product) {
4567       if ( AsnReadVal(aip, atp, &av) <= 0) {
4568          goto erret;
4569       }
4570       rgp -> product = av.ptrvalue;
4571       atp = AsnReadId(aip,amp, atp);
4572    }
4573    if (atp == RNA_GEN_quals) {
4574       rgp -> quals = RNAQualSetAsnRead(aip, atp);
4575       if (aip -> io_failure) {
4576          goto erret;
4577       }
4578       atp = AsnReadId(aip,amp, atp);
4579    }
4580 
4581    if (AsnReadVal(aip, atp, &av) <= 0) {
4582       goto erret;
4583    }
4584    /* end struct */
4585 
4586 ret:
4587    AsnUnlinkType(orig);       /* unlink local tree */
4588    return rgp;
4589 
4590 erret:
4591    aip -> io_failure = TRUE;
4592    rgp = RNAGenFree(rgp);
4593    goto ret;
4594 }
4595 
4596 
4597 
4598 /**************************************************
4599 *
4600 *    RNAGenAsnWrite()
4601 *
4602 **************************************************/
4603 NLM_EXTERN Boolean LIBCALL
RNAGenAsnWrite(RNAGenPtr rgp,AsnIoPtr aip,AsnTypePtr orig)4604 RNAGenAsnWrite(RNAGenPtr rgp, AsnIoPtr aip, AsnTypePtr orig)
4605 {
4606    DataVal av;
4607    AsnTypePtr atp;
4608    Boolean retval = FALSE;
4609 
4610    if (! loaded)
4611    {
4612       if (! SeqFeatAsnLoad()) {
4613          return FALSE;
4614       }
4615    }
4616 
4617    if (aip == NULL) {
4618       return FALSE;
4619    }
4620 
4621    atp = AsnLinkType(orig, RNA_GEN);   /* link local tree */
4622    if (atp == NULL) {
4623       return FALSE;
4624    }
4625 
4626    if (rgp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4627 
4628     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4629 
4630    if (! AsnOpenStruct(aip, atp, (Pointer) rgp)) {
4631       goto erret;
4632    }
4633 
4634    if (rgp -> _class != NULL) {
4635       av.ptrvalue = rgp -> _class;
4636       retval = AsnWrite(aip, RNA_GEN_class,  &av);
4637    }
4638    if (rgp -> product != NULL) {
4639       av.ptrvalue = rgp -> product;
4640       retval = AsnWrite(aip, RNA_GEN_product,  &av);
4641    }
4642    if (rgp -> quals != NULL) {
4643       if ( ! RNAQualSetAsnWrite(rgp -> quals, aip, RNA_GEN_quals)) {
4644          goto erret;
4645       }
4646    }
4647    if (! AsnCloseStruct(aip, atp, (Pointer)rgp)) {
4648       goto erret;
4649    }
4650    retval = TRUE;
4651 
4652 erret:
4653    AsnUnlinkType(orig);       /* unlink local tree */
4654    return retval;
4655 }
4656 
4657 
4658 
4659 
4660 /**************************************************
4661 *
4662 *    GeneNomenclatureNew()
4663 *
4664 **************************************************/
4665 NLM_EXTERN
4666 GeneNomenclaturePtr LIBCALL
GeneNomenclatureNew(void)4667 GeneNomenclatureNew (void)
4668 {
4669    GeneNomenclaturePtr gnp = MemNew((size_t) sizeof(GeneNomenclature));
4670 
4671    return gnp;
4672 
4673 }
4674 
4675 
4676 /**************************************************
4677 *
4678 *    GeneNomenclatureFree()
4679 *
4680 **************************************************/
4681 NLM_EXTERN
4682 GeneNomenclaturePtr LIBCALL
GeneNomenclatureFree(GeneNomenclaturePtr gnp)4683 GeneNomenclatureFree (GeneNomenclaturePtr gnp)
4684 {
4685 
4686    if (gnp == NULL) {
4687       return NULL;
4688    }
4689    MemFree(gnp -> symbol);
4690    MemFree(gnp -> name);
4691    DbtagFree(gnp -> source);
4692    return MemFree(gnp);
4693 }
4694 
4695 
4696 /**************************************************
4697 *
4698 *    GeneNomenclatureAsnRead()
4699 *
4700 **************************************************/
4701 NLM_EXTERN
4702 GeneNomenclaturePtr LIBCALL
GeneNomenclatureAsnRead(AsnIoPtr aip,AsnTypePtr orig)4703 GeneNomenclatureAsnRead (AsnIoPtr aip, AsnTypePtr orig)
4704 {
4705    DataVal av;
4706    AsnTypePtr atp;
4707    AsnReadFunc func;
4708    GeneNomenclaturePtr gnp;
4709 
4710    if (! loaded)
4711    {
4712       if (! SeqFeatAsnLoad()) {
4713          return NULL;
4714       }
4715    }
4716 
4717    if (aip == NULL) {
4718       return NULL;
4719    }
4720 
4721    if (orig == NULL) {         /* GeneNomenclature ::= (self contained) */
4722       atp = AsnReadId(aip, amp, GENE_NOMENCLATURE);
4723    } else {
4724       atp = AsnLinkType(orig, GENE_NOMENCLATURE);
4725    }
4726    /* link in local tree */
4727    if (atp == NULL) {
4728       return NULL;
4729    }
4730 
4731    gnp = GeneNomenclatureNew();
4732    if (gnp == NULL) {
4733       goto erret;
4734    }
4735    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
4736       goto erret;
4737    }
4738 
4739    atp = AsnReadId(aip,amp, atp);
4740    func = NULL;
4741 
4742    if (atp == GENE_NOMENCLATURE_status) {
4743       if ( AsnReadVal(aip, atp, &av) <= 0) {
4744          goto erret;
4745       }
4746       gnp -> status = av.intvalue;
4747       atp = AsnReadId(aip,amp, atp);
4748    }
4749    if (atp == GENE_NOMENCLATURE_symbol) {
4750       if ( AsnReadVal(aip, atp, &av) <= 0) {
4751          goto erret;
4752       }
4753       gnp -> symbol = av.ptrvalue;
4754       atp = AsnReadId(aip,amp, atp);
4755    }
4756    if (atp == GENE_NOMENCLATURE_name) {
4757       if ( AsnReadVal(aip, atp, &av) <= 0) {
4758          goto erret;
4759       }
4760       gnp -> name = av.ptrvalue;
4761       atp = AsnReadId(aip,amp, atp);
4762    }
4763    if (atp == GENE_NOMENCLATURE_source) {
4764       gnp -> source = DbtagAsnRead(aip, atp);
4765       if (aip -> io_failure) {
4766          goto erret;
4767       }
4768       atp = AsnReadId(aip,amp, atp);
4769    }
4770 
4771    if (AsnReadVal(aip, atp, &av) <= 0) {
4772       goto erret;
4773    }
4774    /* end struct */
4775 
4776 ret:
4777    AsnUnlinkType(orig);       /* unlink local tree */
4778    return gnp;
4779 
4780 erret:
4781    aip -> io_failure = TRUE;
4782    gnp = GeneNomenclatureFree(gnp);
4783    goto ret;
4784 }
4785 
4786 
4787 /**************************************************
4788 *
4789 *    GeneNomenclatureAsnWrite()
4790 *
4791 **************************************************/
4792 NLM_EXTERN Boolean LIBCALL
GeneNomenclatureAsnWrite(GeneNomenclaturePtr gnp,AsnIoPtr aip,AsnTypePtr orig)4793 GeneNomenclatureAsnWrite (GeneNomenclaturePtr gnp, AsnIoPtr aip, AsnTypePtr orig)
4794 {
4795    DataVal av;
4796    AsnTypePtr atp;
4797    Boolean retval = FALSE;
4798 
4799    if (! loaded)
4800    {
4801       if (! SeqFeatAsnLoad()) {
4802          return FALSE;
4803       }
4804    }
4805 
4806    if (aip == NULL) {
4807       return FALSE;
4808    }
4809 
4810    atp = AsnLinkType(orig, GENE_NOMENCLATURE);   /* link local tree */
4811    if (atp == NULL) {
4812       return FALSE;
4813    }
4814 
4815    if (gnp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4816 
4817     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4818 
4819    if (! AsnOpenStruct(aip, atp, (Pointer) gnp)) {
4820       goto erret;
4821    }
4822 
4823    av.intvalue = gnp -> status;
4824    retval = AsnWrite(aip, GENE_NOMENCLATURE_status,  &av);
4825    if (gnp -> symbol != NULL) {
4826       av.ptrvalue = gnp -> symbol;
4827       retval = AsnWrite(aip, GENE_NOMENCLATURE_symbol,  &av);
4828    }
4829    if (gnp -> name != NULL) {
4830       av.ptrvalue = gnp -> name;
4831       retval = AsnWrite(aip, GENE_NOMENCLATURE_name,  &av);
4832    }
4833    if (gnp -> source != NULL) {
4834       if ( ! DbtagAsnWrite(gnp -> source, aip, GENE_NOMENCLATURE_source)) {
4835          goto erret;
4836       }
4837    }
4838    if (! AsnCloseStruct(aip, atp, (Pointer)gnp)) {
4839       goto erret;
4840    }
4841    retval = TRUE;
4842 
4843 erret:
4844    AsnUnlinkType(orig);       /* unlink local tree */
4845    return retval;
4846 }
4847 
4848 
4849 
4850 /*****************************************************************************
4851 *
4852 *   GeneRefNew()
4853 *
4854 *****************************************************************************/
GeneRefNew(void)4855 NLM_EXTERN GeneRefPtr LIBCALL GeneRefNew (void)
4856 {
4857     return (GeneRefPtr)MemNew(sizeof(GeneRef));
4858 }
4859 
4860 /*****************************************************************************
4861 *
4862 *   GeneRefFree(grp)
4863 *       Frees an GeneRef and associated data
4864 *
4865 *****************************************************************************/
GeneRefFree(GeneRefPtr grp)4866 NLM_EXTERN GeneRefPtr LIBCALL GeneRefFree (GeneRefPtr grp)
4867 {
4868     ValNodePtr anp, next;
4869 
4870     if (grp == NULL)
4871         return (GeneRefPtr)NULL;
4872 
4873     MemFree(grp->locus);
4874     MemFree(grp->allele);
4875     MemFree(grp->desc);
4876     MemFree(grp->maploc);
4877     anp = grp->db;
4878     while (anp != NULL)
4879     {
4880         next = anp->next;
4881         DbtagFree((DbtagPtr)anp->data.ptrvalue);
4882         MemFree(anp);
4883         anp = next;
4884     }
4885     anp = grp->syn;
4886     while (anp != NULL)
4887     {
4888         next = anp->next;
4889         MemFree(anp->data.ptrvalue);
4890         MemFree(anp);
4891         anp = next;
4892     }
4893     MemFree (grp->locus_tag);
4894     GeneNomenclatureFree (grp->formal_name);
4895     return (GeneRefPtr)MemFree(grp);
4896 }
4897 
4898 /*****************************************************************************
4899 *
4900 *   GeneRefDup(grp)
4901 *       Duplicates an GeneRef and associated data
4902 *
4903 *****************************************************************************/
GeneRefDup(GeneRefPtr grp)4904 NLM_EXTERN GeneRefPtr LIBCALL GeneRefDup (GeneRefPtr grp)
4905 {
4906     ValNodePtr anp, vnp;
4907     GeneRefPtr ngp;
4908 
4909     if (grp == NULL)
4910         return (GeneRefPtr)NULL;
4911 
4912     ngp = GeneRefNew();
4913     if (ngp == NULL) return ngp;
4914 
4915     if (grp->locus != NULL)
4916         ngp->locus = StringSave(grp->locus);
4917     if (grp->allele != NULL)
4918         ngp->allele = StringSave(grp->allele);
4919     if (grp->desc != NULL)
4920         ngp->desc = StringSave(grp->desc);
4921     if (grp->maploc != NULL)
4922         ngp->maploc = StringSave(grp->maploc);
4923     anp = grp->db;
4924     while (anp != NULL)
4925     {
4926         vnp = ValNodeNew(ngp->db);
4927         if (vnp == NULL) return GeneRefFree(ngp);
4928         if (ngp->db == NULL)
4929             ngp->db = vnp;
4930         vnp->data.ptrvalue = (Pointer)DbtagDup((DbtagPtr)anp->data.ptrvalue);
4931         anp = anp->next;
4932     }
4933     anp = grp->syn;
4934     while (anp != NULL)
4935     {
4936         vnp = ValNodeNew(ngp->syn);
4937         if (vnp == NULL) return GeneRefFree(ngp);
4938         if (ngp->syn == NULL)
4939             ngp->syn = vnp;
4940         vnp->data.ptrvalue = (Pointer)StringSave((CharPtr)anp->data.ptrvalue);
4941         anp = anp->next;
4942     }
4943     if (grp->locus_tag != NULL)
4944         ngp->locus_tag = StringSave(grp->locus_tag);
4945     if (grp->formal_name != NULL) {
4946       ngp = AsnIoMemCopy ((Pointer) grp->formal_name,
4947                           (AsnReadFunc) GeneNomenclatureAsnRead,
4948                           (AsnWriteFunc) GeneNomenclatureAsnWrite);
4949     }
4950     return ngp;
4951 }
4952 
4953 /*****************************************************************************
4954 *
4955 *   GeneRefAsnWrite(grp, aip, atp)
4956 *       atp is the current type (if identifier of a parent struct)
4957 *       if atp == NULL, then assumes it stands alone (GeneRef ::=)
4958 *
4959 *****************************************************************************/
GeneRefAsnWrite(GeneRefPtr grp,AsnIoPtr aip,AsnTypePtr orig)4960 NLM_EXTERN Boolean LIBCALL GeneRefAsnWrite (GeneRefPtr grp, AsnIoPtr aip, AsnTypePtr orig)
4961 {
4962     DataVal av;
4963     AsnTypePtr atp;
4964     ValNodePtr anp;
4965     Boolean retval = FALSE;
4966 
4967     if (! loaded)
4968     {
4969         if (! SeqFeatAsnLoad())
4970             return FALSE;
4971     }
4972 
4973     if (aip == NULL)
4974         return FALSE;
4975 
4976     atp = AsnLinkType(orig, GENE_REF);   /* link local tree */
4977     if (atp == NULL)
4978         return FALSE;
4979 
4980     if (grp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4981 
4982     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4983 
4984     if (! AsnOpenStruct(aip, atp, (Pointer)grp))
4985         goto erret;
4986 
4987     if (grp->locus != NULL)
4988     {
4989         av.ptrvalue = grp->locus;
4990         if (! AsnWrite(aip, GENE_REF_locus, &av)) goto erret;
4991     }
4992     if (grp->allele != NULL)
4993     {
4994         av.ptrvalue = grp->allele;
4995         if (! AsnWrite(aip, GENE_REF_allele, &av)) goto erret;
4996     }
4997     if (grp->desc != NULL)
4998     {
4999         av.ptrvalue = grp->desc;
5000         if (! AsnWrite(aip, GENE_REF_desc, &av)) goto erret;
5001     }
5002     if (grp->maploc != NULL)
5003     {
5004         av.ptrvalue = grp->maploc;
5005         if (! AsnWrite(aip, GENE_REF_maploc, &av)) goto erret;
5006     }
5007     if (grp->pseudo)
5008     {
5009         av.boolvalue = grp->pseudo;
5010         if (! AsnWrite(aip, GENE_REF_pseudo, &av)) goto erret;
5011     }
5012     if (grp->db != NULL)
5013     {
5014         anp = grp->db;
5015         if (! AsnOpenStruct(aip, GENE_REF_db, (Pointer)grp->db))
5016             goto erret;
5017         while (anp != NULL)
5018         {
5019             if (! DbtagAsnWrite((DbtagPtr)anp->data.ptrvalue, aip, GENE_REF_db_E))
5020                 goto erret;
5021             anp = anp->next;
5022         }
5023         if (! AsnCloseStruct(aip, GENE_REF_db, (Pointer)grp->db))
5024             goto erret;
5025     }
5026     if (grp->syn != NULL)
5027     {
5028         anp = grp->syn;
5029         if (! AsnOpenStruct(aip, GENE_REF_syn, (Pointer)grp->syn))
5030             goto erret;
5031         while (anp != NULL)
5032         {
5033             if (! AsnWrite(aip, GENE_REF_syn_E, &anp->data)) goto erret;
5034             anp = anp->next;
5035         }
5036         if (! AsnCloseStruct(aip, GENE_REF_syn, (Pointer)grp->syn))
5037             goto erret;
5038     }
5039     if (grp->locus_tag != NULL)
5040     {
5041         av.ptrvalue = grp->locus_tag;
5042         if (! AsnWrite(aip, GENE_REF_locus_tag, &av)) goto erret;
5043     }
5044    if (grp->formal_name != NULL) {
5045       if ( ! GeneNomenclatureAsnWrite(grp->formal_name, aip, GENE_REF_formal_name)) {
5046          goto erret;
5047       }
5048    }
5049     if (! AsnCloseStruct(aip, atp, (Pointer)grp))
5050         goto erret;
5051     retval = TRUE;
5052 erret:
5053     AsnUnlinkType(orig);       /* unlink local tree */
5054     return retval;
5055 }
5056 
5057 /*****************************************************************************
5058 *
5059 *   GeneRefAsnRead(aip, atp)
5060 *       atp is the current type (if identifier of a parent struct)
5061 *            assumption is readIdent has occurred
5062 *       if atp == NULL, then assumes it stands alone and read ident
5063 *            has not occurred.
5064 *
5065 *****************************************************************************/
GeneRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)5066 NLM_EXTERN GeneRefPtr LIBCALL GeneRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
5067 {
5068     DataVal av;
5069     AsnTypePtr atp, oldatp;
5070     GeneRefPtr grp;
5071     ValNodePtr anp;
5072 
5073     if (! loaded)
5074     {
5075         if (! SeqFeatAsnLoad())
5076             return (GeneRefPtr)NULL;
5077     }
5078 
5079     if (aip == NULL)
5080         return (GeneRefPtr)NULL;
5081 
5082     if (orig == NULL)           /* GeneRef ::= (self contained) */
5083         atp = AsnReadId(aip, amp, GENE_REF);
5084     else
5085         atp = AsnLinkType(orig, GENE_REF);    /* link in local tree */
5086     oldatp = atp;
5087     if (atp == NULL)
5088         return (GeneRefPtr)NULL;
5089 
5090     grp = GeneRefNew();
5091     if (grp == NULL)
5092         goto erret;
5093 
5094     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
5095 
5096     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
5097     {
5098         if (atp == NULL)
5099             goto erret;
5100         if (atp == GENE_REF_locus) {
5101            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5102             grp->locus = (CharPtr)av.ptrvalue;
5103         } else if (atp == GENE_REF_allele) {
5104            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5105             grp->allele = (CharPtr)av.ptrvalue;
5106         } else if (atp == GENE_REF_desc) {
5107            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5108             grp->desc = (CharPtr)av.ptrvalue;
5109         } else if (atp == GENE_REF_maploc) {
5110            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5111             grp->maploc = (CharPtr)av.ptrvalue;
5112         } else if (atp == GENE_REF_pseudo) {
5113            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5114             grp->pseudo = av.boolvalue;
5115         } else if (atp == GENE_REF_db)
5116         {
5117            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5118             while ((atp = AsnReadId(aip, amp, atp)) == GENE_REF_db_E)
5119             {
5120                 anp = ValNodeNew(grp->db);
5121                 if (anp == NULL)
5122                     goto erret;
5123                 if (grp->db == NULL)
5124                     grp->db = anp;
5125                 anp->data.ptrvalue = (Pointer)DbtagAsnRead(aip, atp);
5126                 if (anp->data.ptrvalue == NULL)
5127                     goto erret;
5128             }
5129             if (atp == NULL)
5130                 goto erret;
5131             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
5132         }
5133         else if (atp == GENE_REF_syn)
5134         {
5135            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5136             while ((atp = AsnReadId(aip, amp, atp)) == GENE_REF_syn_E)
5137             {
5138                 anp = ValNodeNew(grp->syn);
5139                 if (anp == NULL)
5140                     goto erret;
5141                 if (grp->syn == NULL)
5142                     grp->syn = anp;
5143                 if (AsnReadVal(aip, atp, &anp->data) <= 0) goto erret;
5144             }
5145             if (atp == NULL)
5146                 goto erret;
5147             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
5148         }
5149         else if (atp == GENE_REF_locus_tag) {
5150            if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5151            grp->locus_tag = (CharPtr)av.ptrvalue;
5152         } else if (atp == GENE_REF_formal_name) {
5153             grp->formal_name = GeneNomenclatureAsnRead(aip, atp);
5154             if (aip -> io_failure) goto erret;
5155         }
5156     }
5157     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
5158 ret:
5159     AsnUnlinkType(orig);       /* unlink local tree */
5160     return grp;
5161 erret:
5162     grp = GeneRefFree(grp);
5163     goto ret;
5164 }
5165 
5166 /*****************************************************************************
5167 *
5168 *   OrgRefNew()
5169 *
5170 *****************************************************************************/
OrgRefNew(void)5171 NLM_EXTERN OrgRefPtr LIBCALL OrgRefNew (void)
5172 {
5173     return (OrgRefPtr)MemNew(sizeof(OrgRef));
5174 }
5175 
5176 /*****************************************************************************
5177 *
5178 *   OrgRefFree(orp)
5179 *       Frees an OrgRef and associated data
5180 *
5181 *****************************************************************************/
OrgRefFree(OrgRefPtr orp)5182 NLM_EXTERN OrgRefPtr LIBCALL OrgRefFree (OrgRefPtr orp)
5183 {
5184     ValNodePtr anp, next;
5185 
5186     if (orp == NULL)
5187         return (OrgRefPtr)NULL;
5188 
5189     orp->taxname = MemFree(orp->taxname);
5190     orp->common = MemFree(orp->common);
5191     ValNodeFreeData(orp->mod);
5192     orp->mod = NULL;
5193     anp = orp->db;
5194     while (anp != NULL)
5195     {
5196         next = anp->next;
5197         DbtagFree((DbtagPtr)anp->data.ptrvalue);
5198         MemFree(anp);
5199         anp = next;
5200     }
5201     orp->db = NULL;
5202     ValNodeFreeData(orp->syn);
5203     orp->syn = NULL;
5204     OrgNameFree(orp->orgname);
5205     orp->orgname = NULL;
5206     return (OrgRefPtr)MemFree(orp);
5207 }
5208 
5209 /*****************************************************************************
5210 *
5211 *   OrgRefAsnWrite(orp, aip, atp)
5212 *       atp is the current type (if identifier of a parent struct)
5213 *       if atp == NULL, then assumes it stands alone (OrgRef ::=)
5214 *
5215 *****************************************************************************/
OrgRefAsnWrite(OrgRefPtr orp,AsnIoPtr aip,AsnTypePtr orig)5216 NLM_EXTERN Boolean LIBCALL OrgRefAsnWrite (OrgRefPtr orp, AsnIoPtr aip, AsnTypePtr orig)
5217 {
5218     DataVal av;
5219     AsnTypePtr atp;
5220     ValNodePtr anp;
5221     Boolean retval = FALSE;
5222 
5223     if (! loaded)
5224     {
5225         if (! SeqFeatAsnLoad())
5226             return FALSE;
5227     }
5228 
5229     if (aip == NULL)
5230         return FALSE;
5231 
5232     atp = AsnLinkType(orig, ORG_REF);   /* link local tree */
5233     if (atp == NULL)
5234         return FALSE;
5235 
5236     if (orp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
5237 
5238     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
5239 
5240     if (! AsnOpenStruct(aip, atp, (Pointer)orp))
5241         goto erret;
5242 
5243     if (orp->taxname != NULL)
5244     {
5245         av.ptrvalue = orp->taxname;
5246         if (! AsnWrite(aip, ORG_REF_taxname, &av)) goto erret;
5247     }
5248     if (orp->common != NULL)
5249     {
5250         av.ptrvalue = orp->common;
5251         if (! AsnWrite(aip, ORG_REF_common, &av)) goto erret;
5252     }
5253     if (orp->mod != NULL)
5254     {
5255         anp = orp->mod;
5256         if (! AsnOpenStruct(aip, ORG_REF_mod, (Pointer)orp->mod))
5257             goto erret;
5258         while (anp != NULL)
5259         {
5260             av.ptrvalue = anp->data.ptrvalue;
5261             if (! AsnWrite(aip, ORG_REF_mod_E, &av)) goto erret;
5262             anp = anp->next;
5263         }
5264         if (! AsnCloseStruct(aip, ORG_REF_mod, (Pointer)orp->mod))
5265             goto erret;
5266     }
5267     if (orp->db != NULL)
5268     {
5269         anp = orp->db;
5270         if (! AsnOpenStruct(aip, ORG_REF_db, (Pointer)orp->db))
5271             goto erret;
5272         while (anp != NULL)
5273         {
5274             if (! DbtagAsnWrite((DbtagPtr)anp->data.ptrvalue, aip, ORG_REF_db_E))
5275                 goto erret;
5276             anp = anp->next;
5277         }
5278         if (! AsnCloseStruct(aip, ORG_REF_db, (Pointer)orp->db))
5279             goto erret;
5280     }
5281     if (orp->syn != NULL)
5282     {
5283         anp = orp->syn;
5284         if (! AsnOpenStruct(aip, ORG_REF_syn, (Pointer)orp->syn))
5285             goto erret;
5286         while (anp != NULL)
5287         {
5288             av.ptrvalue = anp->data.ptrvalue;
5289             if (! AsnWrite(aip, ORG_REF_syn_E, &av)) goto erret;
5290             anp = anp->next;
5291         }
5292         if (! AsnCloseStruct(aip, ORG_REF_syn, (Pointer)orp->syn))
5293             goto erret;
5294     }
5295     if (orp->orgname != NULL)
5296     {
5297         if (! OrgNameAsnWrite(orp->orgname, aip, ORG_REF_orgname))
5298             goto erret;
5299     }
5300     if (! AsnCloseStruct(aip, atp, (Pointer)orp))
5301         goto erret;
5302     retval = TRUE;
5303 erret:
5304     AsnUnlinkType(orig);       /* unlink local tree */
5305     return retval;
5306 }
5307 
5308 /*****************************************************************************
5309 *
5310 *   OrgRefAsnRead(aip, atp)
5311 *       atp is the current type (if identifier of a parent struct)
5312 *            assumption is readIdent has occurred
5313 *       if atp == NULL, then assumes it stands alone and read ident
5314 *            has not occurred.
5315 *
5316 *****************************************************************************/
OrgRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)5317 NLM_EXTERN OrgRefPtr LIBCALL OrgRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
5318 {
5319     DataVal av;
5320     AsnTypePtr atp, oldatp;
5321     OrgRefPtr orp;
5322     ValNodePtr anp;
5323 
5324     if (! loaded)
5325     {
5326         if (! SeqFeatAsnLoad())
5327             return (OrgRefPtr)NULL;
5328     }
5329 
5330     if (aip == NULL)
5331         return (OrgRefPtr)NULL;
5332 
5333     if (orig == NULL)           /* OrgRef ::= (self contained) */
5334         atp = AsnReadId(aip, amp, ORG_REF);
5335     else
5336         atp = AsnLinkType(orig, ORG_REF);    /* link in local tree */
5337     oldatp = atp;
5338     if (atp == NULL)
5339         return (OrgRefPtr)NULL;
5340 
5341     orp = OrgRefNew();
5342     if (orp == NULL)
5343         goto erret;
5344 
5345     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
5346 
5347     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
5348     {
5349         if (atp == NULL)
5350             goto erret;
5351         if (atp == ORG_REF_orgname)
5352         {
5353             orp->orgname = OrgNameAsnRead(aip, atp);
5354             if (orp->orgname == NULL) goto erret;
5355         } else {
5356             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5357             if (atp == ORG_REF_taxname)
5358                 orp->taxname = (CharPtr)av.ptrvalue;
5359             else if (atp == ORG_REF_common)
5360                 orp->common = (CharPtr)av.ptrvalue;
5361             else if (atp == ORG_REF_mod_E)
5362             {
5363                 anp = ValNodeNew(orp->mod);
5364                 if (anp == NULL)
5365                     goto erret;
5366                 anp->data.ptrvalue = av.ptrvalue;
5367                 if (orp->mod == NULL)
5368                     orp->mod = anp;
5369             }
5370             else if (atp == ORG_REF_db)
5371             {
5372                 while ((atp = AsnReadId(aip, amp, atp)) == ORG_REF_db_E)
5373                 {
5374                     anp = ValNodeNew(orp->db);
5375                     if (anp == NULL)
5376                         goto erret;
5377                     if (orp->db == NULL)
5378                         orp->db = anp;
5379                     anp->data.ptrvalue = (Pointer)DbtagAsnRead(aip, atp);
5380                     if (anp->data.ptrvalue == NULL)
5381                         goto erret;
5382                 }
5383                 if (atp == NULL)
5384                     goto erret;
5385                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
5386             }
5387             else if (atp == ORG_REF_syn_E)
5388             {
5389                 anp = ValNodeNew(orp->syn);
5390                 if (anp == NULL)
5391                     goto erret;
5392                 anp->data.ptrvalue = av.ptrvalue;
5393                 if (orp->syn == NULL)
5394                     orp->syn = anp;
5395             }
5396         }
5397     }
5398     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
5399 ret:
5400     AsnUnlinkType(orig);       /* unlink local tree */
5401     return orp;
5402 erret:
5403     orp = OrgRefFree(orp);
5404     goto ret;
5405 }
5406 
5407 /*****************************************************************************
5408 *
5409 *   ValNodeStringListMatch(vnp1, vnp2)
5410 *
5411 *   This function is used by OrgRefMatch.
5412 *****************************************************************************/
ValNodeStringListMatch(ValNodePtr vnp1,ValNodePtr vnp2)5413 NLM_EXTERN Boolean ValNodeStringListMatch (ValNodePtr vnp1, ValNodePtr vnp2)
5414 {
5415   if (vnp1 == NULL && vnp2 == NULL)
5416   {
5417     return TRUE;
5418   }
5419   else if (vnp1 == NULL || vnp2 == NULL)
5420   {
5421     return FALSE;
5422   }
5423   else if (vnp1->choice != vnp2->choice)
5424   {
5425     return FALSE;
5426   }
5427   else if (StringCmp (vnp1->data.ptrvalue, vnp2->data.ptrvalue) != 0)
5428   {
5429     return FALSE;
5430   }
5431   else
5432   {
5433     return ValNodeStringListMatch (vnp1->next, vnp2->next);
5434   }
5435 }
5436 
5437 
5438 /*****************************************************************************
5439 *
5440 *   ValNodeDbtagMatch(vnp1, vnp2)
5441 *
5442 *   This function is used by OrgRefMatch.
5443 *****************************************************************************/
ValNodeDbtagMatch(ValNodePtr vnp1,ValNodePtr vnp2)5444 NLM_EXTERN Boolean ValNodeDbtagMatch (ValNodePtr vnp1, ValNodePtr vnp2)
5445 {
5446   if (vnp1 == NULL && vnp2 == NULL)
5447   {
5448     return TRUE;
5449   }
5450   else if (vnp1 == NULL || vnp2 == NULL)
5451   {
5452     return FALSE;
5453   }
5454   else if (vnp1->choice != vnp2->choice)
5455   {
5456     return FALSE;
5457   }
5458   else if (!DbtagMatch (vnp1->data.ptrvalue, vnp2->data.ptrvalue))
5459   {
5460     return FALSE;
5461   }
5462   else
5463   {
5464     return ValNodeDbtagMatch (vnp1->next, vnp2->next);
5465   }
5466 }
5467 
5468 /*****************************************************************************
5469 *
5470 *   OrgRefMatch(orp1, orp2)
5471 *
5472 *****************************************************************************/
OrgRefMatch(OrgRefPtr orp1,OrgRefPtr orp2)5473 NLM_EXTERN Boolean LIBCALL OrgRefMatch (OrgRefPtr orp1, OrgRefPtr orp2)
5474 {
5475   if (orp1 == NULL && orp2 == NULL)
5476   {
5477     return TRUE;
5478   }
5479   else if (orp1 == NULL || orp2 == NULL)
5480   {
5481     return FALSE;
5482   }
5483   else if (StringCmp (orp1->taxname, orp2->taxname) != 0
5484            || StringCmp (orp1->common, orp2->common) != 0)
5485   {
5486     return FALSE;
5487   }
5488   else if (!ValNodeStringListMatch (orp1->syn, orp2->syn)
5489           || ! ValNodeDbtagMatch (orp1->db, orp2->db))
5490   {
5491     return FALSE;
5492   }
5493   else if (! OrgNameMatch (orp1->orgname, orp2->orgname))
5494   {
5495     return FALSE;
5496   }
5497   else
5498   {
5499     return TRUE;
5500   }
5501 }
5502 
5503 
5504 /*****************************************************************************
5505 *
5506 *   OrgNameNew()
5507 *
5508 *****************************************************************************/
OrgNameNew(void)5509 NLM_EXTERN OrgNamePtr LIBCALL OrgNameNew (void)
5510 {
5511     return (OrgNamePtr)MemNew(sizeof(OrgName));
5512 }
5513 
5514 /*****************************************************************************
5515 *
5516 *   OrgNameFree(onp)
5517 *       Frees an OrgName and associated data
5518 *
5519 *****************************************************************************/
OrgNameFree(OrgNamePtr onp)5520 NLM_EXTERN OrgNamePtr LIBCALL OrgNameFree (OrgNamePtr onp)
5521 {
5522     if (onp == NULL)
5523         return (OrgNamePtr)NULL;
5524 
5525     switch (onp->choice)
5526     {
5527         case 1:      /* binomial name */
5528         case 4:      /* named hydrid */
5529             BinomialOrgNameFree((BinomialOrgNamePtr)(onp->data));
5530             break;
5531         case 2:      /* virus name */
5532             MemFree(onp->data);
5533             break;
5534         case 3:   /* hybrid */
5535             OrgNameSetFree((OrgNamePtr)(onp->data));
5536             break;
5537         case 5:   /* partially characterized name */
5538             TaxElementSetFree((TaxElementPtr)(onp->data));
5539             break;
5540 
5541     }
5542     MemFree(onp->attrib);
5543     OrgModSetFree(onp->mod);
5544      MemFree(onp->lineage);
5545      MemFree(onp->div);
5546     return (OrgNamePtr)MemFree(onp);
5547 }
5548 
5549 /*****************************************************************************
5550 *
5551 *   OrgNameAsnWrite(onp, aip, atp)
5552 *       atp is the current type (if identifier of a parent struct)
5553 *       if atp == NULL, then assumes it stands alone (OrgName ::=)
5554 *
5555 *****************************************************************************/
OrgNameAsnWrite(OrgNamePtr onp,AsnIoPtr aip,AsnTypePtr orig)5556 NLM_EXTERN Boolean LIBCALL OrgNameAsnWrite (OrgNamePtr onp, AsnIoPtr aip, AsnTypePtr orig)
5557 {
5558     DataVal av;
5559     AsnTypePtr atp;
5560     Boolean retval = FALSE;
5561 
5562     if (! loaded)
5563     {
5564         if (! SeqFeatAsnLoad())
5565             return FALSE;
5566     }
5567 
5568     if (aip == NULL)
5569         return FALSE;
5570 
5571     atp = AsnLinkType(orig, ORGNAME);   /* link local tree */
5572     if (atp == NULL)
5573         return FALSE;
5574 
5575     if (onp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
5576 
5577     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
5578 
5579     if (! AsnOpenStruct(aip, atp, (Pointer)onp))
5580         goto erret;
5581 
5582     if (onp->choice != 0)
5583     {
5584     if (! AsnWriteChoice(aip, ORGNAME_name, (Int2)onp->choice, &av)) goto erret;
5585 
5586 
5587     switch (onp->choice)
5588     {
5589         case 1:      /* binomial name */
5590             if (! BinomialOrgNameAsnWrite((BinomialOrgNamePtr)(onp->data), aip, ORGNAME_name_binomial))
5591                 goto erret;
5592             break;
5593         case 2:      /* virus name */
5594             av.ptrvalue = onp->data;
5595             if (AsnWrite(aip, ORGNAME_name_virus, &av) <= 0)
5596                 goto erret;
5597             break;
5598         case 3:   /* hybrid */
5599             if (! OrgNameSetAsnWrite((OrgNamePtr)(onp->data), aip, ORGNAME_name_hybrid, MULTIORGNAME_E))
5600                 goto erret;
5601             break;
5602         case 4:      /* named hybrid */
5603             if (! BinomialOrgNameAsnWrite((BinomialOrgNamePtr)(onp->data), aip, ORGNAME_name_namedhybrid))
5604                 goto erret;
5605             break;
5606         case 5:   /* partially characterized name */
5607             if (! TaxElementSetAsnWrite((TaxElementPtr)(onp->data), aip, ORGNAME_name_partial, PARTIALORGNAME_E))
5608                 goto erret;
5609             break;
5610 
5611     }
5612     }
5613 
5614     if (onp->attrib != NULL)
5615     {
5616         av.ptrvalue = onp->attrib;
5617         if (! AsnWrite(aip, ORGNAME_attrib, &av)) goto erret;
5618     }
5619     if (onp->mod != NULL)
5620     {
5621         if (! OrgModSetAsnWrite(onp->mod, aip, ORGNAME_mod, ORGNAME_mod_E))
5622             goto erret;
5623     }
5624 
5625     if (onp->lineage != NULL)
5626     {
5627           if (aip->spec_version == 3)    /* ASN3 strip new value */
5628           {
5629               ErrPostEx(SEV_ERROR,0,0,"ASN3: OrgName.lineage stripped");
5630           }
5631           else
5632           {
5633         av.ptrvalue = onp->lineage;
5634         if (! AsnWrite(aip, ORGNAME_lineage, &av)) goto erret;
5635          }
5636     }
5637 
5638     if (onp->gcode)
5639     {
5640           if (aip->spec_version == 3)    /* ASN3 strip new value */
5641           {
5642               ErrPostEx(SEV_ERROR,0,0,"ASN3: OrgName.gcode stripped");
5643           }
5644           else
5645           {
5646         av.intvalue = (Int4)(onp->gcode);
5647         if (! AsnWrite(aip, ORGNAME_gcode, &av)) goto erret;
5648          }
5649     }
5650 
5651     if (onp->mgcode)
5652     {
5653           if (aip->spec_version == 3)    /* ASN3 strip new value */
5654           {
5655               ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.mgcode stripped");
5656           }
5657           else
5658           {
5659         av.intvalue = (Int4)(onp->mgcode);
5660         if (! AsnWrite(aip, ORGNAME_mgcode, &av)) goto erret;
5661          }
5662     }
5663 
5664     if (onp->div != NULL)
5665     {
5666           if (aip->spec_version > 0 && aip->spec_version < 5)    /* ASN4 strip new value */
5667           {
5668               ErrPostEx(SEV_ERROR,0,0,"ASN3: OrgName.lineage stripped");
5669           }
5670           else
5671           {
5672         av.ptrvalue = onp->div;
5673         if (! AsnWrite(aip, ORGNAME_div, &av)) goto erret;
5674          }
5675     }
5676 
5677     if (onp->pgcode)
5678     {
5679           if (aip->spec_version == 3)    /* ASN3 strip new value */
5680           {
5681               ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.pgcode stripped");
5682           }
5683           else
5684           {
5685         av.intvalue = (Int4)(onp->pgcode);
5686         if (! AsnWrite(aip, ORGNAME_pgcode, &av)) goto erret;
5687          }
5688     }
5689 
5690 
5691     if (! AsnCloseStruct(aip, atp, (Pointer)onp))
5692         goto erret;
5693     retval = TRUE;
5694 erret:
5695     AsnUnlinkType(orig);       /* unlink local tree */
5696     return retval;
5697 }
5698 
5699 /*****************************************************************************
5700 *
5701 *   OrgNameAsnRead(aip, atp)
5702 *       atp is the current type (if identifier of a parent struct)
5703 *            assumption is readIdent has occurred
5704 *       if atp == NULL, then assumes it stands alone and read ident
5705 *            has not occurred.
5706 *
5707 *****************************************************************************/
OrgNameAsnRead(AsnIoPtr aip,AsnTypePtr orig)5708 NLM_EXTERN OrgNamePtr LIBCALL OrgNameAsnRead (AsnIoPtr aip, AsnTypePtr orig)
5709 {
5710     DataVal av;
5711     AsnTypePtr atp, oldatp;
5712     OrgNamePtr onp;
5713 
5714     if (! loaded)
5715     {
5716         if (! SeqFeatAsnLoad())
5717             return (OrgNamePtr)NULL;
5718     }
5719 
5720     if (aip == NULL)
5721         return (OrgNamePtr)NULL;
5722 
5723     if (orig == NULL)           /* OrgName ::= (self contained) */
5724         atp = AsnReadId(aip, amp, ORGNAME);
5725     else
5726         atp = AsnLinkType(orig, ORGNAME);    /* link in local tree */
5727     oldatp = atp;
5728     if (atp == NULL)
5729         return (OrgNamePtr)NULL;
5730 
5731     onp = OrgNameNew();
5732     if (onp == NULL)
5733         goto erret;
5734 
5735     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
5736 
5737     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
5738     {
5739         if (atp == NULL)
5740             goto erret;
5741         if (atp == ORGNAME_name_binomial)
5742         {
5743             onp->choice = 1;
5744             onp->data = (Pointer)BinomialOrgNameAsnRead(aip, atp);
5745             if (onp->data == NULL) goto erret;
5746         }
5747         else if (atp == ORGNAME_name_hybrid)
5748         {
5749             onp->choice = 3;
5750             onp->data = (Pointer)OrgNameSetAsnRead(aip, atp, MULTIORGNAME_E);
5751             if (onp->data == NULL) goto erret;
5752         }
5753         else if (atp == ORGNAME_name_namedhybrid)
5754         {
5755             onp->choice = 4;
5756             onp->data = (Pointer)BinomialOrgNameAsnRead(aip, atp);
5757             if (onp->data == NULL) goto erret;
5758         }
5759         else if (atp == ORGNAME_name_partial)
5760         {
5761             onp->choice = 5;
5762             onp->data = (Pointer)TaxElementSetAsnRead(aip, atp, PARTIALORGNAME_E);
5763             if (onp->data == NULL) goto erret;
5764         }
5765         else if (atp == ORGNAME_mod)
5766         {
5767             onp->mod = OrgModSetAsnRead(aip, atp, ORGNAME_mod_E);
5768             if (onp->mod == NULL) goto erret;
5769         }
5770         else
5771         {
5772          if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
5773          if (atp == ORGNAME_name_virus)
5774             {
5775                 onp->choice = 2;
5776                 onp->data = av.ptrvalue;
5777             }
5778             else if (atp == ORGNAME_attrib)
5779                 onp->attrib = (CharPtr)av.ptrvalue;
5780             else if (atp == ORGNAME_lineage)
5781             {
5782                if (aip->spec_version == 3)    /* ASN3 strip new value */
5783               {
5784                   ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.lineage stripped");
5785                 MemFree((CharPtr)(av.ptrvalue));
5786               }
5787               else
5788                 onp->lineage = (CharPtr)av.ptrvalue;
5789            }
5790             else if (atp == ORGNAME_gcode)
5791             {
5792                if (aip->spec_version == 3)    /* ASN3 strip new value */
5793               {
5794                   ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.gcode stripped");
5795               }
5796               else
5797                 onp->gcode = (Uint1)av.intvalue;
5798            }
5799             else if (atp == ORGNAME_mgcode)
5800             {
5801                if (aip->spec_version == 3)    /* ASN3 strip new value */
5802               {
5803                   ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.mgcode stripped");
5804               }
5805               else
5806                 onp->mgcode = (Uint1)av.intvalue;
5807            }
5808             else if (atp == ORGNAME_div)
5809             {
5810                if (aip->spec_version > 0 && aip->spec_version < 5)    /* ASN4 strip new value */
5811               {
5812                   ErrPostEx(SEV_ERROR,0,0,"ASN4:  OrgName.div stripped");
5813               }
5814               else
5815                 onp->div = (CharPtr)(av.ptrvalue);
5816            }
5817             else if (atp == ORGNAME_pgcode)
5818             {
5819                if (aip->spec_version == 3)    /* ASN3 strip new value */
5820               {
5821                   ErrPostEx(SEV_ERROR,0,0,"ASN3:  OrgName.pgcode stripped");
5822               }
5823               else
5824                 onp->pgcode = (Uint1)av.intvalue;
5825            }
5826         }
5827     }
5828     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
5829 ret:
5830     AsnUnlinkType(orig);       /* unlink local tree */
5831     return onp;
5832 erret:
5833     onp = OrgNameFree(onp);
5834     goto ret;
5835 }
5836 
5837 /*****************************************************************************
5838 *
5839 *   OrgNameSetFree (onp)
5840 *
5841 *****************************************************************************/
OrgNameSetFree(OrgNamePtr onp)5842 NLM_EXTERN OrgNamePtr LIBCALL OrgNameSetFree (OrgNamePtr onp)
5843 {
5844     OrgNamePtr next;
5845 
5846     while (onp != NULL)
5847     {
5848         next = onp->next;
5849         OrgNameFree(onp);
5850         onp = next;
5851     }
5852     return onp;
5853 }
5854 
5855 /*****************************************************************************
5856 *
5857 *   OrgNameSetAsnWrite(onp, aip, set, element)
5858 *
5859 *****************************************************************************/
OrgNameSetAsnWrite(OrgNamePtr onp,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)5860 NLM_EXTERN Boolean LIBCALL OrgNameSetAsnWrite (OrgNamePtr onp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
5861 {
5862     AsnTypePtr atp;
5863     OrgNamePtr oldonp;
5864     Boolean retval = FALSE;
5865 
5866     if (! loaded)
5867     {
5868         if (! SeqFeatAsnLoad())
5869             return FALSE;
5870     }
5871 
5872     if (aip == NULL)
5873         return FALSE;
5874 
5875     atp = AsnLinkType(element, ORGNAME);   /* link local tree */
5876     if (atp == NULL)
5877         return FALSE;
5878     oldonp = onp;
5879 
5880     if (! AsnOpenStruct(aip, set, (Pointer)oldonp))
5881         goto erret;
5882 
5883     while (onp != NULL)
5884     {
5885         if (! OrgNameAsnWrite(onp, aip, atp))
5886             goto erret;
5887         onp = onp->next;
5888     }
5889 
5890     if (! AsnCloseStruct(aip, set, (Pointer)oldonp))
5891         goto erret;
5892     retval = TRUE;
5893 erret:
5894     AsnUnlinkType(element);       /* unlink local tree */
5895     return retval;
5896 }
5897 
5898 /*****************************************************************************
5899 *
5900 *   OrgNameSetAsnRead(aip, set, element)
5901 *
5902 *****************************************************************************/
OrgNameSetAsnRead(AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)5903 NLM_EXTERN OrgNamePtr LIBCALL OrgNameSetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
5904 {
5905     DataVal av;
5906     AsnTypePtr atp;
5907     OrgNamePtr onp, curr = NULL, first = NULL;
5908 
5909     if (aip == NULL)
5910         return (OrgNamePtr)NULL;
5911 
5912     AsnLinkType(element, ORGNAME);    /* link in local tree */
5913     atp = set;
5914 
5915     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
5916     while ((atp = AsnReadId(aip, amp, atp)) == element)
5917     {
5918         onp = OrgNameAsnRead(aip, atp);
5919         if (onp == NULL)
5920             goto erret;
5921         if (first == NULL)
5922             first = onp;
5923         else
5924             curr->next = onp;
5925         curr = onp;
5926     }
5927     if (atp == NULL)
5928         goto erret;
5929     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
5930     if (first == NULL)
5931         ErrPostEx(SEV_WARNING, 0, 0, "Empty SET OF OrgName. line %ld", (long) aip->linenumber);
5932 ret:
5933     AsnUnlinkType(element);       /* unlink local tree */
5934     return first;
5935 erret:
5936     first = OrgNameSetFree(first);
5937     goto ret;
5938 }
5939 
5940 /*****************************************************************************
5941 *
5942 *   OrgNameMatch (onp1, onp2)
5943 *
5944 *****************************************************************************/
OrgNameMatch(OrgNamePtr onp1,OrgNamePtr onp2)5945 NLM_EXTERN Boolean LIBCALL OrgNameMatch (OrgNamePtr onp1, OrgNamePtr onp2)
5946 {
5947     if (onp1 == NULL && onp2 == NULL)
5948   {
5949     return TRUE;
5950   }
5951   else if (onp1 == NULL || onp2 == NULL)
5952   {
5953     return FALSE;
5954   }
5955   else if (onp1->choice != onp2->choice
5956            || onp1->gcode != onp2->gcode
5957            || onp2->mgcode != onp2->mgcode
5958            || StringCmp (onp1->attrib, onp2->attrib) != 0
5959            || StringCmp (onp1->lineage, onp2->lineage) != 0
5960            || StringCmp (onp1->div, onp2->div) != 0
5961            || ! OrgModSetMatch (onp1->mod, onp2->mod)
5962            || ! OrgNameMatch (onp1->next, onp2->next))
5963   {
5964     return FALSE;
5965   }
5966   else
5967   {
5968     return TRUE;
5969   }
5970 }
5971 
5972 /*****************************************************************************
5973 *
5974 *   ProtRefNew()
5975 *
5976 *****************************************************************************/
ProtRefNew(void)5977 NLM_EXTERN ProtRefPtr LIBCALL ProtRefNew (void)
5978 {
5979     return (ProtRefPtr)MemNew(sizeof(ProtRef));
5980 }
5981 
5982 /*****************************************************************************
5983 *
5984 *   ProtRefFree(prp)
5985 *       Frees an ProtRef and associated data
5986 *
5987 *****************************************************************************/
ProtRefFree(ProtRefPtr prp)5988 NLM_EXTERN ProtRefPtr LIBCALL ProtRefFree (ProtRefPtr prp)
5989 {
5990     ValNodePtr anp, next;
5991 
5992     if (prp == NULL)
5993         return (ProtRefPtr)NULL;
5994 
5995     MemFree(prp->desc);
5996     anp = prp->name;
5997     while (anp != NULL)
5998     {
5999         next = anp->next;
6000         MemFree(anp->data.ptrvalue);
6001         MemFree(anp);
6002         anp = next;
6003     }
6004     anp = prp->ec;
6005     while (anp != NULL)
6006     {
6007         next = anp->next;
6008         MemFree(anp->data.ptrvalue);
6009         MemFree(anp);
6010         anp = next;
6011     }
6012     anp = prp->activity;
6013     while (anp != NULL)
6014     {
6015         next = anp->next;
6016         MemFree(anp->data.ptrvalue);
6017         MemFree(anp);
6018         anp = next;
6019     }
6020     anp = prp->db;
6021     while (anp != NULL)
6022     {
6023         next = anp->next;
6024         DbtagFree((DbtagPtr)anp->data.ptrvalue);
6025         MemFree(anp);
6026         anp = next;
6027     }
6028     return (ProtRefPtr)MemFree(prp);
6029 }
6030 
6031 /*****************************************************************************
6032 *
6033 *   ProtRefDup(prp)
6034 *       Duplicates an ProtRef and associated data
6035 *
6036 *****************************************************************************/
ProtRefDup(ProtRefPtr prp)6037 NLM_EXTERN ProtRefPtr LIBCALL ProtRefDup (ProtRefPtr prp)
6038 {
6039     ValNodePtr anp, vnp;
6040     ProtRefPtr npp;
6041 
6042     if (prp == NULL)
6043         return (ProtRefPtr)NULL;
6044 
6045     npp = ProtRefNew();
6046     if (npp == NULL) return npp;
6047 
6048     if (prp->desc != NULL)
6049         npp->desc = StringSave(prp->desc);
6050     anp = prp->name;
6051     while (anp != NULL)
6052     {
6053         vnp = ValNodeNew(npp->name);
6054         if (vnp == NULL) return ProtRefFree(prp);
6055         if (npp->name == NULL)
6056             npp->name = vnp;
6057         vnp->data.ptrvalue = StringSave((CharPtr)anp->data.ptrvalue);
6058         anp = anp->next;
6059     }
6060     anp = prp->ec;
6061     while (anp != NULL)
6062     {
6063         vnp = ValNodeNew(npp->ec);
6064         if (vnp == NULL) return ProtRefFree(prp);
6065         if (npp->ec == NULL)
6066             npp->ec = vnp;
6067         vnp->data.ptrvalue = StringSave((CharPtr)anp->data.ptrvalue);
6068         anp = anp->next;
6069     }
6070     anp = prp->activity;
6071     while (anp != NULL)
6072     {
6073         vnp = ValNodeNew(npp->activity);
6074         if (vnp == NULL) return ProtRefFree(prp);
6075         if (npp->activity == NULL)
6076             npp->activity = vnp;
6077         vnp->data.ptrvalue = StringSave((CharPtr)anp->data.ptrvalue);
6078         anp = anp->next;
6079     }
6080     anp = prp->db;
6081     while (anp != NULL)
6082     {
6083         vnp = ValNodeNew(npp->db);
6084         if (vnp == NULL) return ProtRefFree(prp);
6085         if (npp->db == NULL)
6086             npp->db = vnp;
6087         vnp->data.ptrvalue = DbtagDup((DbtagPtr)anp->data.ptrvalue);
6088         anp = anp->next;
6089     }
6090     npp->processed = prp->processed;
6091     return npp;
6092 }
6093 
6094 /*****************************************************************************
6095 *
6096 *   ProtRefAsnWrite(prp, aip, atp)
6097 *       atp is the current type (if identifier of a parent struct)
6098 *       if atp == NULL, then assumes it stands alone (ProtRef ::=)
6099 *
6100 *****************************************************************************/
ProtRefAsnWrite(ProtRefPtr prp,AsnIoPtr aip,AsnTypePtr orig)6101 NLM_EXTERN Boolean LIBCALL ProtRefAsnWrite (ProtRefPtr prp, AsnIoPtr aip, AsnTypePtr orig)
6102 {
6103     DataVal av;
6104     AsnTypePtr atp;
6105     ValNodePtr anp;
6106     Boolean retval = FALSE;
6107 
6108     if (! loaded)
6109     {
6110         if (! SeqFeatAsnLoad())
6111             return FALSE;
6112     }
6113 
6114     if (aip == NULL)
6115         return FALSE;
6116 
6117     atp = AsnLinkType(orig, PROT_REF);   /* link local tree */
6118     if (atp == NULL)
6119         return FALSE;
6120 
6121     if (prp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
6122 
6123     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
6124 
6125     if (! AsnOpenStruct(aip, atp, (Pointer)prp))
6126         goto erret;
6127 
6128     if (prp->name != NULL)
6129     {
6130         if (! AsnOpenStruct(aip, PROT_REF_name, (Pointer)prp->name))
6131             goto erret;
6132         anp = prp->name;
6133         while (anp != NULL)
6134         {
6135             if (! AsnWrite(aip, PROT_REF_name_E, &anp->data))
6136                 goto erret;
6137             anp = anp->next;
6138         }
6139         if (! AsnCloseStruct(aip, PROT_REF_name, (Pointer)prp->name))
6140             goto erret;
6141     }
6142     if (prp->desc != NULL)
6143     {
6144         av.ptrvalue = prp->desc;
6145         if (! AsnWrite(aip, PROT_REF_desc, &av)) goto erret;
6146     }
6147     if (prp->ec != NULL)
6148     {
6149         if (! AsnOpenStruct(aip, PROT_REF_ec, (Pointer)prp->ec))
6150             goto erret;
6151         anp = prp->ec;
6152         while (anp != NULL)
6153         {
6154             if (! AsnWrite(aip, PROT_REF_ec_E, &anp->data))
6155                 goto erret;
6156             anp = anp->next;
6157         }
6158         if (! AsnCloseStruct(aip, PROT_REF_ec, (Pointer)prp->ec))
6159             goto erret;
6160     }
6161     if (prp->activity != NULL)
6162     {
6163         if (! AsnOpenStruct(aip, PROT_REF_activity, (Pointer)prp->activity))
6164             goto erret;
6165         anp = prp->activity;
6166         while (anp != NULL)
6167         {
6168             if (! AsnWrite(aip, PROT_REF_activity_E, &anp->data))
6169                 goto erret;
6170             anp = anp->next;
6171         }
6172         if (! AsnCloseStruct(aip, PROT_REF_activity, (Pointer)prp->activity))
6173             goto erret;
6174     }
6175     if (prp->db != NULL)
6176     {
6177         anp = prp->db;
6178         if (! AsnOpenStruct(aip, PROT_REF_db, (Pointer)prp->db))
6179             goto erret;
6180         while (anp != NULL)
6181         {
6182             if (! DbtagAsnWrite((DbtagPtr)anp->data.ptrvalue, aip, PROT_REF_db_E))
6183                 goto erret;
6184             anp = anp->next;
6185         }
6186         if (! AsnCloseStruct(aip, PROT_REF_db, (Pointer)prp->db))
6187             goto erret;
6188     }
6189     if (prp->processed)
6190     {
6191         if ((prp->processed < 3) || (aip->spec_version == 0 || aip->spec_version > 4))
6192         {
6193             av.intvalue = (Int4)(prp->processed);
6194             if (AsnWrite(aip, PROT_REF_processed, &av) <= 0) goto erret;
6195         }
6196     }
6197 
6198     if (! AsnCloseStruct(aip, atp, (Pointer)prp))
6199         goto erret;
6200     retval = TRUE;
6201 erret:
6202     AsnUnlinkType(orig);       /* unlink local tree */
6203     return retval;
6204 }
6205 
6206 /*****************************************************************************
6207 *
6208 *   ProtRefAsnRead(aip, atp)
6209 *       atp is the current type (if identifier of a parent struct)
6210 *            assumption is readIdent has occurred
6211 *       if atp == NULL, then assumes it stands alone and read ident
6212 *            has not occurred.
6213 *
6214 *****************************************************************************/
ProtRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)6215 NLM_EXTERN ProtRefPtr LIBCALL ProtRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
6216 {
6217     DataVal av;
6218     AsnTypePtr atp, oldatp;
6219     ProtRefPtr prp;
6220     ValNodePtr anp;
6221 
6222     if (! loaded)
6223     {
6224         if (! SeqFeatAsnLoad())
6225             return (ProtRefPtr)NULL;
6226     }
6227 
6228     if (aip == NULL)
6229         return (ProtRefPtr)NULL;
6230 
6231     if (orig == NULL)           /* ProtRef ::= (self contained) */
6232         atp = AsnReadId(aip, amp, PROT_REF);
6233     else
6234         atp = AsnLinkType(orig, PROT_REF);    /* link in local tree */
6235     oldatp = atp;
6236     if (atp == NULL)
6237         return (ProtRefPtr)NULL;
6238 
6239     prp = ProtRefNew();
6240     if (prp == NULL)
6241         goto erret;
6242 
6243     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
6244 
6245     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
6246     {
6247         if (atp == NULL)
6248             goto erret;
6249         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
6250         if (atp == PROT_REF_desc)
6251             prp->desc = (CharPtr)av.ptrvalue;
6252         else if (atp == PROT_REF_name)
6253         {
6254             while ((atp = AsnReadId(aip, amp, atp)) == PROT_REF_name_E)
6255             {
6256                 anp = ValNodeNew(prp->name);
6257                 if (anp == NULL)
6258                     goto erret;
6259                 if (prp->name == NULL)
6260                     prp->name = anp;
6261                 if (AsnReadVal(aip, atp, &anp->data) <= 0) goto erret;
6262             }
6263             if (atp == NULL)
6264                 goto erret;
6265             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
6266         }
6267         else if (atp == PROT_REF_ec)
6268         {
6269             while ((atp = AsnReadId(aip, amp, atp)) == PROT_REF_ec_E)
6270             {
6271                 anp = ValNodeNew(prp->ec);
6272                 if (anp == NULL)
6273                     goto erret;
6274                 if (prp->ec == NULL)
6275                     prp->ec = anp;
6276                 if (AsnReadVal(aip, atp, &anp->data) <= 0) goto erret;
6277             }
6278             if (atp == NULL)
6279                 goto erret;
6280             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
6281         }
6282         else if (atp == PROT_REF_activity)
6283         {
6284             while ((atp = AsnReadId(aip, amp, atp)) == PROT_REF_activity_E)
6285             {
6286                 anp = ValNodeNew(prp->activity);
6287                 if (anp == NULL)
6288                     goto erret;
6289                 if (prp->activity == NULL)
6290                     prp->activity = anp;
6291                 if (AsnReadVal(aip, atp, &anp->data) <= 0) goto erret;
6292             }
6293             if (atp == NULL)
6294                 goto erret;
6295             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
6296         }
6297         else if (atp == PROT_REF_db)
6298         {
6299             while ((atp = AsnReadId(aip, amp, atp)) == PROT_REF_db_E)
6300             {
6301                 anp = ValNodeNew(prp->db);
6302                 if (anp == NULL)
6303                     goto erret;
6304                 if (prp->db == NULL)
6305                     prp->db = anp;
6306                 anp->data.ptrvalue = (Pointer)DbtagAsnRead(aip, atp);
6307                 if (anp->data.ptrvalue == NULL)
6308                     goto erret;
6309             }
6310             if (atp == NULL)
6311                 goto erret;
6312             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;  /* end SET OF */
6313         }
6314         else if (atp == PROT_REF_processed)
6315             prp->processed = (Uint1)(av.intvalue);
6316     }
6317     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
6318 ret:
6319     AsnUnlinkType(orig);       /* unlink local tree */
6320     return prp;
6321 erret:
6322     prp = ProtRefFree(prp);
6323     goto ret;
6324 }
6325 
6326 /*****************************************************************************
6327 *
6328 *   RsiteRefFree(rrp)
6329 *       Frees an RsiteRef and associated data
6330 *
6331 *****************************************************************************/
RsiteRefFree(RsiteRefPtr rrp)6332 NLM_EXTERN RsiteRefPtr LIBCALL RsiteRefFree (RsiteRefPtr rrp)
6333 {
6334     if (rrp == NULL)
6335         return (RsiteRefPtr)NULL;
6336 
6337     if (rrp->choice == 1)   /* str */
6338         MemFree(rrp->data.ptrvalue);
6339     else
6340         DbtagFree((DbtagPtr)rrp->data.ptrvalue);
6341     return (RsiteRefPtr)MemFree(rrp);
6342 }
6343 
6344 /*****************************************************************************
6345 *
6346 *   RsiteRefAsnWrite(rrp, aip, atp)
6347 *       atp is the current type (if identifier of a parent struct)
6348 *       if atp == NULL, then assumes it stands alone (RsiteRef ::=)
6349 *
6350 *****************************************************************************/
RsiteRefAsnWrite(RsiteRefPtr rrp,AsnIoPtr aip,AsnTypePtr orig)6351 NLM_EXTERN Boolean LIBCALL RsiteRefAsnWrite (RsiteRefPtr rrp, AsnIoPtr aip, AsnTypePtr orig)
6352 {
6353     DataVal av;
6354     AsnTypePtr atp;
6355     Boolean retval = FALSE;
6356 
6357     if (! loaded)
6358     {
6359         if (! SeqFeatAsnLoad())
6360             return FALSE;
6361     }
6362 
6363     if (aip == NULL)
6364         return FALSE;
6365 
6366     atp = AsnLinkType(orig, RSITE_REF);   /* link local tree */
6367     if (atp == NULL)
6368         return FALSE;
6369 
6370     if (rrp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
6371 
6372     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
6373 
6374     if (! AsnWrite(aip, atp, &av)) goto erret;     /* CHOICE */
6375     switch (rrp->choice)
6376     {
6377         case 1:
6378             if (! AsnWrite(aip, RSITE_REF_str, &rrp->data))
6379                 goto erret;
6380             break;
6381         case 2:
6382             if (! DbtagAsnWrite((DbtagPtr)rrp->data.ptrvalue, aip, RSITE_REF_db))
6383                 goto erret;
6384             break;
6385     }
6386     retval = TRUE;
6387 erret:
6388     AsnUnlinkType(orig);       /* unlink local tree */
6389     return retval;
6390 }
6391 
6392 /*****************************************************************************
6393 *
6394 *   RsiteRefAsnRead(aip, atp)
6395 *       atp is the current type (if identifier of a parent struct)
6396 *            assumption is readIdent has occurred
6397 *       if atp == NULL, then assumes it stands alone and read ident
6398 *            has not occurred.
6399 *
6400 *****************************************************************************/
RsiteRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)6401 NLM_EXTERN RsiteRefPtr LIBCALL RsiteRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
6402 {
6403     DataVal av;
6404     AsnTypePtr atp;
6405     RsiteRefPtr rrp;
6406 
6407     if (! loaded)
6408     {
6409         if (! SeqFeatAsnLoad())
6410             return (RsiteRefPtr)NULL;
6411     }
6412 
6413     if (aip == NULL)
6414         return (RsiteRefPtr)NULL;
6415 
6416     if (orig == NULL)           /* RsiteRef ::= (self contained) */
6417         atp = AsnReadId(aip, amp, RSITE_REF);
6418     else
6419         atp = AsnLinkType(orig, RSITE_REF);    /* link in local tree */
6420     if (atp == NULL)
6421         return (RsiteRefPtr)NULL;
6422 
6423     rrp = ValNodeNew(NULL);
6424     if (rrp == NULL)
6425         goto erret;
6426 
6427     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the CHOICE */
6428     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;   /* which CHOICE */
6429     if (atp == NULL)
6430         goto erret;
6431     if (atp == RSITE_REF_str)
6432     {
6433         rrp->choice = 1;
6434         if (AsnReadVal(aip, atp, &rrp->data) <= 0)
6435             goto erret;
6436     }
6437     else if (atp == RSITE_REF_db)
6438     {
6439         rrp->choice = 2;
6440         rrp->data.ptrvalue = (Pointer) DbtagAsnRead(aip, atp);
6441         if (rrp->data.ptrvalue == NULL)
6442             goto erret;
6443     }
6444 ret:
6445     AsnUnlinkType(orig);       /* unlink local tree */
6446     return rrp;
6447 erret:
6448     rrp = RsiteRefFree(rrp);
6449     goto ret;
6450 }
6451 
6452 /*****************************************************************************
6453 *
6454 *   SeqFeatIdFree(cp)
6455 *       Frees one SeqFeatId's associated data
6456 *       Does NOT free the Choice itself
6457 *
6458 *****************************************************************************/
SeqFeatIdFree(ChoicePtr cp)6459 NLM_EXTERN void LIBCALL SeqFeatIdFree (ChoicePtr cp)
6460 {
6461     Pointer pnt;
6462 
6463     if (cp == NULL)
6464         return;
6465 
6466     pnt = cp->value.ptrvalue;
6467     switch (cp->choice)
6468     {
6469         case 1:     /* gibb id */
6470             cp->value.intvalue = 0;
6471             break;
6472         case 2:     /* giim id */
6473             cp->value.ptrvalue = GiimFree((GiimPtr)pnt);
6474             break;
6475         case 3:
6476             cp->value.ptrvalue = ObjectIdFree((ObjectIdPtr)pnt);
6477             break;
6478         case 4:
6479             cp->value.ptrvalue = DbtagFree((DbtagPtr)pnt);
6480             break;
6481     }
6482     cp->choice = 0;
6483     return;
6484 }
6485 
6486 /*****************************************************************************
6487 *
6488 *   SeqFeatIdDup(dest, src)
6489 *       Duplicates one SeqFeatId's associated data
6490 *
6491 *****************************************************************************/
SeqFeatIdDup(ChoicePtr dest,ChoicePtr src)6492 NLM_EXTERN Boolean LIBCALL SeqFeatIdDup (ChoicePtr dest, ChoicePtr src)
6493 {
6494     GiimPtr ga, gb;
6495 
6496     if (src == NULL)
6497         return FALSE;
6498 
6499     dest->choice = src->choice;
6500     switch (src->choice)
6501     {
6502         case 1:     /* gibb */
6503             dest->value.intvalue = src->value.intvalue;
6504             break;
6505         case 2:     /* giim id */
6506             ga = (GiimPtr) src->value.ptrvalue;
6507             gb = GiimNew();
6508             if (gb == NULL) return FALSE;
6509             gb->id = ga->id;
6510             gb->db = StringSave(ga->db);
6511             gb->release = StringSave(ga->release);
6512             dest->value.ptrvalue = gb;
6513             break;
6514         case 3:
6515             dest->value.ptrvalue = ObjectIdDup((ObjectIdPtr)src->value.ptrvalue);
6516             break;
6517         case 4:
6518             dest->value.ptrvalue = DbtagDup((DbtagPtr)src->value.ptrvalue);
6519             break;
6520     }
6521     return TRUE;
6522 }
6523 
6524 /*****************************************************************************
6525 *
6526 *   SeqFeatIdAsnWrite(cp, aip, atp)
6527 *       atp is the current type (if identifier of a parent struct)
6528 *       if atp == NULL, then assumes it stands alone (SeqFeatId ::=)
6529 *
6530 *****************************************************************************/
SeqFeatIdAsnWrite(ChoicePtr cp,AsnIoPtr aip,AsnTypePtr orig)6531 NLM_EXTERN Boolean LIBCALL SeqFeatIdAsnWrite (ChoicePtr cp, AsnIoPtr aip, AsnTypePtr orig)
6532 {
6533     DataVal av;
6534     AsnTypePtr atp;
6535     Boolean retval = FALSE;
6536 
6537     if (! loaded)
6538     {
6539         if (! SeqFeatAsnLoad())
6540             return FALSE;
6541     }
6542 
6543     if (aip == NULL)
6544         return FALSE;
6545 
6546     atp = AsnLinkType(orig, FEAT_ID);   /* link local tree */
6547     if (atp == NULL)
6548         return FALSE;
6549 
6550     if (cp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
6551 
6552     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
6553 
6554     if (cp->choice)              /* feat-id present */
6555     {
6556         if (! AsnWrite(aip, atp, &av)) goto erret;   /* CHOICE */
6557         if (cp->choice == 1)           /* gibb */
6558         {
6559             av.intvalue = cp->value.intvalue;
6560             if (! AsnWrite(aip, FEAT_ID_gibb, &av)) goto erret;
6561         }
6562         else if (cp->choice == 2)      /* giim */
6563         {
6564             if (! GiimAsnWrite((GiimPtr)cp->value.ptrvalue, aip, FEAT_ID_giim))
6565                 goto erret;
6566         }
6567         else if (cp->choice == 3)      /* local */
6568         {
6569             if (! ObjectIdAsnWrite((ObjectIdPtr)cp->value.ptrvalue, aip, FEAT_ID_local))
6570                 goto erret;
6571         }
6572         else if (cp->choice == 4)      /* general */
6573         {
6574             if (! DbtagAsnWrite((DbtagPtr)cp->value.ptrvalue, aip, FEAT_ID_general))
6575                 goto erret;
6576         }
6577     }
6578     retval = TRUE;
6579 erret:
6580     AsnUnlinkType(orig);       /* unlink local tree */
6581     return retval;
6582 }
6583 
6584 /*****************************************************************************
6585 *
6586 *   SeqFeatIdAsnRead(aip, atp, cp)
6587 *       atp is the current type (if identifier of a parent struct)
6588 *            assumption is readIdent has occurred
6589 *       if atp == NULL, then assumes it stands alone and read ident
6590 *            has not occurred.
6591 *
6592 *****************************************************************************/
SeqFeatIdAsnRead(AsnIoPtr aip,AsnTypePtr orig,ChoicePtr cp)6593 NLM_EXTERN Boolean LIBCALL SeqFeatIdAsnRead (AsnIoPtr aip, AsnTypePtr orig, ChoicePtr cp)
6594 {
6595     DataVal av;
6596     AsnTypePtr atp;
6597     Boolean retval = FALSE;
6598 
6599     if (! loaded)
6600     {
6601         if (! SeqFeatAsnLoad())
6602             return retval;
6603     }
6604 
6605     if (aip == NULL)
6606         return retval;
6607 
6608     if (orig == NULL)           /* SeqFeatId ::= (self contained) */
6609         atp = AsnReadId(aip, amp, FEAT_ID);
6610     else
6611         atp = AsnLinkType(orig, FEAT_ID);    /* link in local tree */
6612     if (atp == NULL)
6613         return retval;
6614 
6615     if (AsnReadVal(aip, atp, &av) <= 0)    /* read CHOICE */
6616         goto erret;
6617     atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
6618     if (atp == FEAT_ID_gibb)
6619     {
6620         cp->choice = 1;
6621         if (AsnReadVal(aip, atp, &av) <= 0)
6622             goto erret;
6623         cp->value.intvalue = av.intvalue;
6624     }
6625     else if (atp == FEAT_ID_giim)
6626     {
6627         cp->choice = 2;
6628         cp->value.ptrvalue = (Pointer)GiimAsnRead(aip, atp);
6629         if (cp->value.ptrvalue == NULL)
6630             goto erret;
6631     }
6632     else if (atp == FEAT_ID_local)
6633     {
6634         cp->choice = 3;
6635         cp->value.ptrvalue = (Pointer)ObjectIdAsnRead(aip, atp);
6636         if (cp->value.ptrvalue == NULL)
6637             goto erret;
6638     }
6639     else if (atp == FEAT_ID_general)
6640     {
6641         cp->choice = 4;
6642         cp->value.ptrvalue = (Pointer)DbtagAsnRead(aip, atp);
6643         if (cp->value.ptrvalue == NULL)
6644             goto erret;
6645     }
6646     retval = TRUE;
6647 erret:
6648     AsnUnlinkType(orig);       /* unlink local tree */
6649     return retval;
6650 }
6651 
6652 /*****************************************************************************
6653 *
6654 *   TxinitNew()
6655 *
6656 *****************************************************************************/
TxinitNew(void)6657 NLM_EXTERN TxinitPtr LIBCALL TxinitNew (void)
6658 {
6659     TxinitPtr txp;
6660 
6661     txp = (TxinitPtr)MemNew(sizeof(Txinit));
6662     if (txp == NULL) return txp;
6663     txp->inittype = 255;
6664     return txp;
6665 }
6666 
6667 /*****************************************************************************
6668 *
6669 *   TxinitFree(txp)
6670 *       Frees a Txinit and associated data
6671 *
6672 *****************************************************************************/
TxinitFree(TxinitPtr txp)6673 NLM_EXTERN TxinitPtr LIBCALL TxinitFree (TxinitPtr txp)
6674 {
6675     ValNodePtr anp, next;
6676     TxEvidencePtr txep, txnext;
6677 
6678     if (txp == NULL)
6679         return (TxinitPtr)NULL;
6680 
6681     MemFree(txp->name);
6682     ValNodeFreeData(txp->syn);
6683     anp = txp->gene;
6684     while (anp != NULL)
6685     {
6686         next = anp->next;
6687         GeneRefFree((GeneRefPtr)anp->data.ptrvalue);
6688         MemFree(anp);
6689         anp = next;
6690     }
6691     anp = txp->protein;
6692     while (anp != NULL)
6693     {
6694         next = anp->next;
6695         ProtRefFree((ProtRefPtr)anp->data.ptrvalue);
6696         MemFree(anp);
6697         anp = next;
6698     }
6699     ValNodeFreeData(txp->rna);
6700     MemFree(txp->expression);
6701     MemFree(txp->txdescr);
6702     OrgRefFree(txp->txorg);
6703     txep = txp->evidence;
6704     while (txep != NULL)
6705     {
6706         txnext = txep->next;
6707         MemFree(txep);
6708         txep = txnext;
6709     }
6710 
6711     return (TxinitPtr)MemFree(txp);
6712 }
6713 
6714 /*****************************************************************************
6715 *
6716 *   TxinitAsnWrite(txp, aip, atp)
6717 *       atp is the current type (if identifier of a parent struct)
6718 *       if atp == NULL, then assumes it stands alone (Txinit ::=)
6719 *
6720 *****************************************************************************/
TxinitAsnWrite(TxinitPtr txp,AsnIoPtr aip,AsnTypePtr orig)6721 NLM_EXTERN Boolean LIBCALL TxinitAsnWrite (TxinitPtr txp, AsnIoPtr aip, AsnTypePtr orig)
6722 {
6723     DataVal av;
6724     AsnTypePtr atp;
6725     ValNodePtr anp;
6726     TxEvidencePtr txep;
6727     Boolean retval = FALSE;
6728 
6729     if (! loaded)
6730     {
6731         if (! SeqFeatAsnLoad())
6732             return FALSE;
6733     }
6734 
6735     if (aip == NULL)
6736         return FALSE;
6737 
6738     atp = AsnLinkType(orig, TXINIT);   /* link local tree */
6739     if (atp == NULL)
6740         return FALSE;
6741 
6742     if (txp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
6743 
6744     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
6745 
6746     if (! AsnOpenStruct(aip, atp, (Pointer)txp))
6747         goto erret;
6748 
6749     av.ptrvalue = (Pointer)txp->name;
6750     if (! AsnWrite(aip, TXINIT_name, &av)) goto erret;
6751     if (txp->syn != NULL)
6752     {
6753         anp = txp->syn;
6754         if (! AsnOpenStruct(aip, TXINIT_syn, (Pointer)txp->syn))
6755             goto erret;
6756         while (anp != NULL)
6757         {
6758             av.ptrvalue = anp->data.ptrvalue;
6759             if (! AsnWrite(aip, TXINIT_syn_E, &av)) goto erret;
6760             anp = anp->next;
6761         }
6762         if (! AsnCloseStruct(aip, TXINIT_syn, (Pointer)txp->syn))
6763             goto erret;
6764     }
6765     if (txp->gene != NULL)
6766     {
6767         anp = txp->gene;
6768         if (! AsnOpenStruct(aip, TXINIT_gene, (Pointer)txp->gene))
6769             goto erret;
6770         while (anp != NULL)
6771         {
6772             if (! GeneRefAsnWrite((GeneRefPtr)anp->data.ptrvalue, aip, TXINIT_gene_E))
6773                 goto erret;
6774             anp = anp->next;
6775         }
6776         if (! AsnCloseStruct(aip, TXINIT_gene, (Pointer)txp->gene))
6777             goto erret;
6778     }
6779     if (txp->protein != NULL)
6780     {
6781         anp = txp->protein;
6782         if (! AsnOpenStruct(aip, TXINIT_protein, (Pointer)txp->protein))
6783             goto erret;
6784         while (anp != NULL)
6785         {
6786             if (! ProtRefAsnWrite((ProtRefPtr)anp->data.ptrvalue, aip, TXINIT_protein_E))
6787                 goto erret;
6788             anp = anp->next;
6789         }
6790         if (! AsnCloseStruct(aip, TXINIT_protein, (Pointer)txp->protein))
6791             goto erret;
6792     }
6793     if (txp->rna != NULL)
6794     {
6795         anp = txp->rna;
6796         if (! AsnOpenStruct(aip, TXINIT_rna, (Pointer)txp->rna))
6797             goto erret;
6798         while (anp != NULL)
6799         {
6800             av.ptrvalue = anp->data.ptrvalue;
6801             if (! AsnWrite(aip, TXINIT_rna_E, &av)) goto erret;
6802             anp = anp->next;
6803         }
6804         if (! AsnCloseStruct(aip, TXINIT_rna, (Pointer)txp->rna))
6805             goto erret;
6806     }
6807     if (txp->expression != NULL)
6808     {
6809         av.ptrvalue = (Pointer)txp->expression;
6810         if (! AsnWrite(aip, TXINIT_expression, &av)) goto erret;
6811     }
6812 
6813     av.intvalue = (Int4)txp->txsystem;
6814     if (! AsnWrite(aip, TXINIT_txsystem, &av)) goto erret;
6815 
6816     if (txp->txdescr != NULL)
6817     {
6818         av.ptrvalue = (Pointer)txp->txdescr;
6819         if (! AsnWrite(aip, TXINIT_txdescr, &av)) goto erret;
6820     }
6821 
6822     if (txp->txorg != NULL)
6823     {
6824         if (! OrgRefAsnWrite(txp->txorg, aip, TXINIT_txorg))
6825             goto erret;
6826     }
6827 
6828     if (txp->mapping_precise)
6829     {
6830         av.boolvalue = TRUE;
6831         if (! AsnWrite(aip, TXINIT_mapping_precise, &av)) goto erret;
6832     }
6833 
6834     if (txp->location_accurate)
6835     {
6836         av.boolvalue = TRUE;
6837         if (! AsnWrite(aip, TXINIT_location_accurate, &av)) goto erret;
6838     }
6839 
6840     if (txp->inittype != 255)
6841     {
6842         av.intvalue = (Int4) txp->inittype;
6843         if (! AsnWrite(aip, TXINIT_inittype, &av)) goto erret;
6844     }
6845 
6846     if (txp->evidence != NULL)
6847     {
6848         txep = txp->evidence;
6849         if (! AsnOpenStruct(aip, TXINIT_evidence, (Pointer)txp->evidence))
6850             goto erret;
6851         while (txep != NULL)
6852         {
6853             if (! AsnOpenStruct(aip, TXINIT_evidence_E, (Pointer)txep))
6854                 goto erret;
6855             av.intvalue = (Int4) txep->exp_code;
6856             if (! AsnWrite(aip, TX_EVIDENCE_exp_code, &av)) goto erret;
6857             if (txep->exp_sys != 1)
6858             {
6859                 av.intvalue = (Int4) txep->exp_sys;
6860                 if (! AsnWrite(aip, TX_EVIDENCE_expression_system, &av)) goto erret;
6861             }
6862             if (txep->low_prec_data)
6863             {
6864                 av.boolvalue = TRUE;
6865                 if (! AsnWrite(aip, TX_EVIDENCE_low_prec_data, &av)) goto erret;
6866             }
6867             if (txep->from_homolog)
6868             {
6869                 av.boolvalue = TRUE;
6870                 if (! AsnWrite(aip, TX_EVIDENCE_from_homolog, &av)) goto erret;
6871             }
6872             if (! AsnCloseStruct(aip, TXINIT_evidence_E, (Pointer)txep))
6873                 goto erret;
6874             txep = txep->next;
6875         }
6876         if (! AsnCloseStruct(aip, TXINIT_evidence, (Pointer)txp->evidence))
6877             goto erret;
6878     }
6879 
6880     if (! AsnCloseStruct(aip, atp, (Pointer)txp))
6881         goto erret;
6882     retval = TRUE;
6883 erret:
6884     AsnUnlinkType(orig);       /* unlink local tree */
6885     return retval;
6886 }
6887 
6888 /*****************************************************************************
6889 *
6890 *   TxinitAsnRead(aip, atp)
6891 *       atp is the current type (if identifier of a parent struct)
6892 *            assumption is readIdent has occurred
6893 *       if atp == NULL, then assumes it stands alone and read ident
6894 *            has not occurred.
6895 *
6896 *****************************************************************************/
TxinitAsnRead(AsnIoPtr aip,AsnTypePtr orig)6897 NLM_EXTERN TxinitPtr LIBCALL TxinitAsnRead (AsnIoPtr aip, AsnTypePtr orig)
6898 {
6899     DataVal av;
6900     AsnTypePtr atp, oldatp;
6901     TxinitPtr txp;
6902     ValNodePtr curr, last;
6903     TxEvidencePtr txep, txlast;
6904 
6905     if (! loaded)
6906     {
6907         if (! SeqFeatAsnLoad())
6908             return (TxinitPtr)NULL;
6909     }
6910 
6911     if (aip == NULL)
6912         return (TxinitPtr)NULL;
6913 
6914     if (orig == NULL)           /* Txinit ::= (self contained) */
6915         atp = AsnReadId(aip, amp, TXINIT);
6916     else
6917         atp = AsnLinkType(orig, TXINIT);    /* link in local tree */
6918     oldatp = atp;
6919     if (atp == NULL)
6920         return (TxinitPtr)NULL;
6921 
6922     txp = TxinitNew();
6923     if (txp == NULL)
6924         return txp;
6925 
6926     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
6927 
6928     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
6929     {
6930         if (atp == NULL)
6931             goto erret;
6932         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
6933         if (atp == TXINIT_name)
6934             txp->name = (CharPtr)av.ptrvalue;
6935         else if (atp == TXINIT_syn)
6936         {
6937             last = NULL;
6938             while ((atp = AsnReadId(aip, amp, atp)) == TXINIT_syn_E)
6939             {
6940                 curr = ValNodeNew(last);
6941                 if (curr == NULL)
6942                     goto erret;
6943                 if (AsnReadVal(aip, atp, &curr->data) <= 0) goto erret;
6944                 if (last == NULL)
6945                     txp->syn = curr;
6946                 last = curr;
6947             }
6948             if (atp == NULL)
6949                 goto erret;
6950             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
6951         }
6952         else if (atp == TXINIT_gene)
6953         {
6954             last = NULL;
6955             while ((atp = AsnReadId(aip, amp, atp)) == TXINIT_gene_E)
6956             {
6957                 curr = ValNodeNew(last);
6958                 if (curr == NULL)
6959                     goto erret;
6960                 curr->data.ptrvalue = (Pointer)GeneRefAsnRead(aip, atp);
6961                 if (curr->data.ptrvalue == NULL)
6962                     goto erret;
6963                 if (last == NULL)
6964                     txp->gene = curr;
6965                 last = curr;
6966             }
6967             if (atp == NULL)
6968                 goto erret;
6969             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
6970         }
6971         else if (atp == TXINIT_protein)
6972         {
6973             last = NULL;
6974             while ((atp = AsnReadId(aip, amp, atp)) == TXINIT_protein_E)
6975             {
6976                 curr = ValNodeNew(last);
6977                 if (curr == NULL)
6978                     goto erret;
6979                 curr->data.ptrvalue = (Pointer)ProtRefAsnRead(aip, atp);
6980                 if (curr->data.ptrvalue == NULL)
6981                     goto erret;
6982                 if (last == NULL)
6983                     txp->protein = curr;
6984                 last = curr;
6985             }
6986             if (atp == NULL)
6987                 goto erret;
6988             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
6989         }
6990         else if (atp == TXINIT_rna)
6991         {
6992             last = NULL;
6993             while ((atp = AsnReadId(aip, amp, atp)) == TXINIT_rna_E)
6994             {
6995                 curr = ValNodeNew(last);
6996                 if (curr == NULL)
6997                     goto erret;
6998                 if (AsnReadVal(aip, atp, &curr->data) <= 0) goto erret;
6999                 if (last == NULL)
7000                     txp->rna = curr;
7001                 last = curr;
7002             }
7003             if (atp == NULL)
7004                 goto erret;
7005             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7006         }
7007         else if (atp == TXINIT_expression)
7008             txp->expression = (CharPtr)av.ptrvalue;
7009         else if (atp == TXINIT_txsystem)
7010             txp->txsystem = (Uint1)av.intvalue;
7011         else if (atp == TXINIT_txdescr)
7012             txp->txdescr = (CharPtr)av.ptrvalue;
7013         else if (atp == TXINIT_txorg)
7014         {
7015             txp->txorg = OrgRefAsnRead(aip, atp);
7016             if (txp->txorg == NULL)
7017                 goto erret;
7018         }
7019         else if (atp == TXINIT_mapping_precise)
7020             txp->mapping_precise = av.boolvalue;
7021         else if (atp == TXINIT_location_accurate)
7022             txp->location_accurate = av.boolvalue;
7023         else if (atp == TXINIT_inittype)
7024             txp->inittype = (Uint1)av.intvalue;
7025         else if (atp == TXINIT_evidence)
7026         {
7027             txlast = NULL;
7028             txep = NULL;
7029             while ((atp = AsnReadId(aip, amp, atp)) != TXINIT_evidence)
7030             {
7031                 if (atp == NULL)
7032                     goto erret;
7033                 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7034                 if ((atp == TXINIT_evidence_E) && (av.intvalue == START_STRUCT))
7035                 {
7036                     txep = (TxEvidencePtr)MemNew(sizeof(TxEvidence));
7037                     if (txep == NULL)
7038                         goto erret;
7039                     txep->exp_sys = 1;    /* default */
7040                     if (txlast != NULL)
7041                         txlast->next = txep;
7042                     else
7043                         txp->evidence = txep;
7044                     txlast = txep;
7045                 }
7046                 else if (atp == TX_EVIDENCE_exp_code)
7047                     txep->exp_code = (Uint1) av.intvalue;
7048                 else if (atp == TX_EVIDENCE_expression_system)
7049                     txep->exp_sys = (Uint1) av.intvalue;
7050                 else if (atp == TX_EVIDENCE_low_prec_data)
7051                     txep->low_prec_data = av.boolvalue;
7052                 else if (atp == TX_EVIDENCE_from_homolog)
7053                     txep->from_homolog = av.boolvalue;
7054             }
7055             if (atp == NULL)
7056                 goto erret;
7057             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7058         }
7059     }
7060     if (atp == NULL)
7061         goto erret;
7062     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7063 ret:
7064     AsnUnlinkType(orig);       /* unlink local tree */
7065     return txp;
7066 erret:
7067     txp = TxinitFree(txp);
7068     goto ret;
7069 }
7070 
7071 
7072 /*****************************************************************************
7073 *
7074 *   OrgModNew()
7075 *
7076 *****************************************************************************/
OrgModNew(void)7077 NLM_EXTERN OrgModPtr LIBCALL OrgModNew (void)
7078 {
7079     return (OrgModPtr)MemNew(sizeof(OrgMod));
7080 }
7081 
7082 /*****************************************************************************
7083 *
7084 *   OrgModFree(omp)
7085 *       Frees an OrgMod and associated data
7086 *
7087 *****************************************************************************/
OrgModFree(OrgModPtr omp)7088 NLM_EXTERN OrgModPtr LIBCALL OrgModFree (OrgModPtr omp)
7089 {
7090     if (omp == NULL)
7091         return (OrgModPtr)NULL;
7092 
7093     MemFree(omp->subname);
7094     MemFree(omp->attrib);
7095     return (OrgModPtr)MemFree(omp);
7096 }
7097 
7098 /*****************************************************************************
7099 *
7100 *   OrgModAsnWrite(omp, aip, atp)
7101 *       atp is the current type (if identifier of a parent struct)
7102 *       if atp == NULL, then assumes it stands alone (OrgMod ::=)
7103 *
7104 *****************************************************************************/
OrgModAsnWrite(OrgModPtr omp,AsnIoPtr aip,AsnTypePtr orig)7105 NLM_EXTERN Boolean LIBCALL OrgModAsnWrite (OrgModPtr omp, AsnIoPtr aip, AsnTypePtr orig)
7106 {
7107     DataVal av;
7108     AsnTypePtr atp;
7109     Boolean retval = FALSE;
7110 
7111     if (! loaded)
7112     {
7113         if (! SeqFeatAsnLoad())
7114             return FALSE;
7115     }
7116 
7117     if (aip == NULL)
7118         return FALSE;
7119 
7120     atp = AsnLinkType(orig, ORGMOD);   /* link local tree */
7121     if (atp == NULL)
7122         return FALSE;
7123 
7124     if (omp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
7125 
7126     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
7127 
7128     if (! AsnOpenStruct(aip, atp, (Pointer)omp))
7129         goto erret;
7130 
7131     av.intvalue = (Int4)(omp->subtype);
7132     if (AsnWrite(aip, ORGMOD_subtype, &av) <= 0) goto erret;
7133 
7134     if (omp->subname != NULL)
7135     {
7136         av.ptrvalue = omp->subname;
7137         if (! AsnWrite(aip, ORGMOD_subname, &av)) goto erret;
7138     }
7139 
7140     if (omp->attrib != NULL)
7141     {
7142         av.ptrvalue = omp->attrib;
7143         if (! AsnWrite(aip, ORGMOD_attrib, &av)) goto erret;
7144     }
7145 
7146     if (! AsnCloseStruct(aip, atp, (Pointer)omp))
7147         goto erret;
7148     retval = TRUE;
7149 erret:
7150     AsnUnlinkType(orig);       /* unlink local tree */
7151     return retval;
7152 }
7153 
7154 /*****************************************************************************
7155 *
7156 *   OrgModAsnRead(aip, atp)
7157 *       atp is the current type (if identifier of a parent struct)
7158 *            assumption is readIdent has occurred
7159 *       if atp == NULL, then assumes it stands alone and read ident
7160 *            has not occurred.
7161 *
7162 *****************************************************************************/
OrgModAsnRead(AsnIoPtr aip,AsnTypePtr orig)7163 NLM_EXTERN OrgModPtr LIBCALL OrgModAsnRead (AsnIoPtr aip, AsnTypePtr orig)
7164 {
7165     DataVal av;
7166     AsnTypePtr atp, oldatp;
7167     OrgModPtr omp;
7168 
7169     if (! loaded)
7170     {
7171         if (! SeqFeatAsnLoad())
7172             return (OrgModPtr)NULL;
7173     }
7174 
7175     if (aip == NULL)
7176         return (OrgModPtr)NULL;
7177 
7178     if (orig == NULL)           /* OrgMod ::= (self contained) */
7179         atp = AsnReadId(aip, amp, ORGMOD);
7180     else
7181         atp = AsnLinkType(orig, ORGMOD);    /* link in local tree */
7182     oldatp = atp;
7183     if (atp == NULL)
7184         return (OrgModPtr)NULL;
7185 
7186     omp = OrgModNew();
7187     if (omp == NULL)
7188         goto erret;
7189 
7190     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7191 
7192     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
7193     {
7194         if (atp == NULL)
7195             goto erret;
7196         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7197         if (atp == ORGMOD_subtype)
7198             omp->subtype = (Uint1)(av.intvalue);
7199         else if (atp == ORGMOD_subname)
7200             omp->subname = (CharPtr)(av.ptrvalue);
7201         else if (atp == ORGMOD_attrib)
7202             omp->attrib = (CharPtr)(av.ptrvalue);
7203     }
7204     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7205 ret:
7206     AsnUnlinkType(orig);       /* unlink local tree */
7207     return omp;
7208 erret:
7209     omp = OrgModFree(omp);
7210     goto ret;
7211 }
7212 
7213 /*****************************************************************************
7214 *
7215 *   OrgModSetFree (omp)
7216 *
7217 *****************************************************************************/
OrgModSetFree(OrgModPtr omp)7218 NLM_EXTERN OrgModPtr LIBCALL OrgModSetFree (OrgModPtr omp)
7219 {
7220     OrgModPtr next;
7221 
7222     while (omp != NULL)
7223     {
7224         next = omp->next;
7225         OrgModFree(omp);
7226         omp = next;
7227     }
7228     return omp;
7229 }
7230 
7231 /*****************************************************************************
7232 *
7233 *   OrgModSetAsnWrite(omp, aip, set, element)
7234 *
7235 *****************************************************************************/
OrgModSetAsnWrite(OrgModPtr omp,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)7236 NLM_EXTERN Boolean LIBCALL OrgModSetAsnWrite (OrgModPtr omp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
7237 {
7238     AsnTypePtr atp;
7239     OrgModPtr oldomp;
7240     Boolean retval = FALSE;
7241 
7242     if (! loaded)
7243     {
7244         if (! SeqFeatAsnLoad())
7245             return FALSE;
7246     }
7247 
7248     if (aip == NULL)
7249         return FALSE;
7250 
7251     atp = AsnLinkType(element, ORGMOD);   /* link local tree */
7252     if (atp == NULL)
7253         return FALSE;
7254     oldomp = omp;
7255 
7256     if (! AsnOpenStruct(aip, set, (Pointer)oldomp))
7257         goto erret;
7258 
7259     while (omp != NULL)
7260     {
7261         if (! OrgModAsnWrite(omp, aip, atp))
7262             goto erret;
7263         omp = omp->next;
7264     }
7265 
7266     if (! AsnCloseStruct(aip, set, (Pointer)oldomp))
7267         goto erret;
7268     retval = TRUE;
7269 erret:
7270     AsnUnlinkType(element);       /* unlink local tree */
7271     return retval;
7272 }
7273 
7274 /*****************************************************************************
7275 *
7276 *   OrgModSetAsnRead(aip, set, element)
7277 *
7278 *****************************************************************************/
OrgModSetAsnRead(AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)7279 NLM_EXTERN OrgModPtr LIBCALL OrgModSetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
7280 {
7281     DataVal av;
7282     AsnTypePtr atp;
7283     OrgModPtr omp, curr = NULL, first = NULL;
7284 
7285     if (aip == NULL)
7286         return (OrgModPtr)NULL;
7287 
7288     AsnLinkType(element, ORGMOD);    /* link in local tree */
7289     atp = set;
7290 
7291     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7292     while ((atp = AsnReadId(aip, amp, atp)) == element)
7293     {
7294         omp = OrgModAsnRead(aip, atp);
7295         if (omp == NULL)
7296             goto erret;
7297         if (first == NULL)
7298             first = omp;
7299         else
7300             curr->next = omp;
7301         curr = omp;
7302     }
7303     if (atp == NULL)
7304         goto erret;
7305     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7306     if (first == NULL)
7307         ErrPostEx(SEV_WARNING, 0, 0, "Empty SET OF OrgMod. line %ld", (long) aip->linenumber);
7308 ret:
7309     AsnUnlinkType(element);       /* unlink local tree */
7310     return first;
7311 erret:
7312     first = OrgModSetFree(first);
7313     goto ret;
7314 }
7315 
7316 /*****************************************************************************
7317 *
7318 *   OrgModSetMatch (mod1, mod2)
7319 *
7320 *****************************************************************************/
OrgModSetMatch(OrgModPtr mod1,OrgModPtr mod2)7321 NLM_EXTERN Boolean LIBCALL OrgModSetMatch (OrgModPtr mod1, OrgModPtr mod2)
7322 {
7323   if (mod1 == NULL && mod2 == NULL)
7324   {
7325     return TRUE;
7326   }
7327   else if (mod1 == NULL || mod2 == NULL)
7328   {
7329     return FALSE;
7330   }
7331   else if (mod1->subtype != mod2->subtype
7332            || StringCmp (mod1->attrib, mod2->attrib) != 0
7333            || StringCmp (mod1->subname, mod2->subname) != 0)
7334   {
7335     return FALSE;
7336   }
7337   else
7338   {
7339     return OrgModSetMatch (mod1->next, mod2->next);
7340   }
7341 }
7342 
7343 /*****************************************************************************
7344 *
7345 *   TaxElementNew()
7346 *
7347 *****************************************************************************/
TaxElementNew(void)7348 NLM_EXTERN TaxElementPtr LIBCALL TaxElementNew (void)
7349 {
7350     return (TaxElementPtr)MemNew(sizeof(TaxElement));
7351 }
7352 
7353 /*****************************************************************************
7354 *
7355 *   TaxElementFree(tep)
7356 *       Frees an TaxElement and associated data
7357 *
7358 *****************************************************************************/
TaxElementFree(TaxElementPtr tep)7359 NLM_EXTERN TaxElementPtr LIBCALL TaxElementFree (TaxElementPtr tep)
7360 {
7361     if (tep == NULL)
7362         return (TaxElementPtr)NULL;
7363 
7364     MemFree(tep->level);
7365     MemFree(tep->name);
7366     return (TaxElementPtr)MemFree(tep);
7367 }
7368 
7369 /*****************************************************************************
7370 *
7371 *   TaxElementAsnWrite(tep, aip, atp)
7372 *       atp is the current type (if identifier of a parent struct)
7373 *       if atp == NULL, then assumes it stands alone (TaxElement ::=)
7374 *
7375 *****************************************************************************/
TaxElementAsnWrite(TaxElementPtr tep,AsnIoPtr aip,AsnTypePtr orig)7376 NLM_EXTERN Boolean LIBCALL TaxElementAsnWrite (TaxElementPtr tep, AsnIoPtr aip, AsnTypePtr orig)
7377 {
7378     DataVal av;
7379     AsnTypePtr atp;
7380     Boolean retval = FALSE;
7381 
7382     if (! loaded)
7383     {
7384         if (! SeqFeatAsnLoad())
7385             return FALSE;
7386     }
7387 
7388     if (aip == NULL)
7389         return FALSE;
7390 
7391     atp = AsnLinkType(orig, TAXELEMENT);   /* link local tree */
7392     if (atp == NULL)
7393         return FALSE;
7394 
7395     if (tep == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
7396 
7397     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
7398 
7399     if (! AsnOpenStruct(aip, atp, (Pointer)tep))
7400         goto erret;
7401 
7402         av.intvalue = (Int4)(tep->fixed_level);
7403         if (AsnWrite(aip, TAXELEMENT_fixed_level, &av) <= 0) goto erret;
7404 
7405     if (tep->level != NULL)
7406     {
7407         av.ptrvalue = tep->level;
7408         if (! AsnWrite(aip, TAXELEMENT_level, &av)) goto erret;
7409     }
7410 
7411     if (tep->name != NULL)
7412     {
7413         av.ptrvalue = tep->name;
7414         if (! AsnWrite(aip, TAXELEMENT_name, &av)) goto erret;
7415     }
7416 
7417     if (! AsnCloseStruct(aip, atp, (Pointer)tep))
7418         goto erret;
7419     retval = TRUE;
7420 erret:
7421     AsnUnlinkType(orig);       /* unlink local tree */
7422     return retval;
7423 }
7424 
7425 /*****************************************************************************
7426 *
7427 *   TaxElementAsnRead(aip, atp)
7428 *       atp is the current type (if identifier of a parent struct)
7429 *            assumption is readIdent has occurred
7430 *       if atp == NULL, then assumes it stands alone and read ident
7431 *            has not occurred.
7432 *
7433 *****************************************************************************/
TaxElementAsnRead(AsnIoPtr aip,AsnTypePtr orig)7434 NLM_EXTERN TaxElementPtr LIBCALL TaxElementAsnRead (AsnIoPtr aip, AsnTypePtr orig)
7435 {
7436     DataVal av;
7437     AsnTypePtr atp, oldatp;
7438     TaxElementPtr tep;
7439 
7440     if (! loaded)
7441     {
7442         if (! SeqFeatAsnLoad())
7443             return (TaxElementPtr)NULL;
7444     }
7445 
7446     if (aip == NULL)
7447         return (TaxElementPtr)NULL;
7448 
7449     if (orig == NULL)           /* TaxElement ::= (self contained) */
7450         atp = AsnReadId(aip, amp, TAXELEMENT);
7451     else
7452         atp = AsnLinkType(orig, TAXELEMENT);    /* link in local tree */
7453     oldatp = atp;
7454     if (atp == NULL)
7455         return (TaxElementPtr)NULL;
7456 
7457     tep = TaxElementNew();
7458     if (tep == NULL)
7459         goto erret;
7460 
7461     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7462 
7463     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
7464     {
7465         if (atp == NULL)
7466             goto erret;
7467         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7468         if (atp == TAXELEMENT_fixed_level)
7469             tep->fixed_level = (Uint1)(av.intvalue);
7470         else if (atp == TAXELEMENT_level)
7471             tep->level = (CharPtr)(av.ptrvalue);
7472         else if (atp == TAXELEMENT_name)
7473             tep->name = (CharPtr)(av.ptrvalue);
7474     }
7475     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7476 ret:
7477     AsnUnlinkType(orig);       /* unlink local tree */
7478     return tep;
7479 erret:
7480     tep = TaxElementFree(tep);
7481     goto ret;
7482 }
7483 
7484 /*****************************************************************************
7485 *
7486 *   TaxElementSetFree (tep)
7487 *
7488 *****************************************************************************/
TaxElementSetFree(TaxElementPtr tep)7489 NLM_EXTERN TaxElementPtr LIBCALL TaxElementSetFree (TaxElementPtr tep)
7490 {
7491     TaxElementPtr next;
7492 
7493     while (tep != NULL)
7494     {
7495         next = tep->next;
7496         TaxElementFree(tep);
7497         tep = next;
7498     }
7499     return tep;
7500 }
7501 
7502 /*****************************************************************************
7503 *
7504 *   TaxElementSetAsnWrite(tep, aip, set, element)
7505 *
7506 *****************************************************************************/
TaxElementSetAsnWrite(TaxElementPtr tep,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)7507 NLM_EXTERN Boolean LIBCALL TaxElementSetAsnWrite (TaxElementPtr tep, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
7508 {
7509     AsnTypePtr atp;
7510     TaxElementPtr oldtep;
7511     Boolean retval = FALSE;
7512 
7513     if (! loaded)
7514     {
7515         if (! SeqFeatAsnLoad())
7516             return FALSE;
7517     }
7518 
7519     if (aip == NULL)
7520         return FALSE;
7521 
7522     atp = AsnLinkType(element, TAXELEMENT);   /* link local tree */
7523     if (atp == NULL)
7524         return FALSE;
7525     oldtep = tep;
7526 
7527     if (! AsnOpenStruct(aip, set, (Pointer)oldtep))
7528         goto erret;
7529 
7530     while (tep != NULL)
7531     {
7532         if (! TaxElementAsnWrite(tep, aip, atp))
7533             goto erret;
7534         tep = tep->next;
7535     }
7536 
7537     if (! AsnCloseStruct(aip, set, (Pointer)oldtep))
7538         goto erret;
7539     retval = TRUE;
7540 erret:
7541     AsnUnlinkType(element);       /* unlink local tree */
7542     return retval;
7543 }
7544 
7545 /*****************************************************************************
7546 *
7547 *   TaxElementSetAsnRead(aip, set, element)
7548 *
7549 *****************************************************************************/
TaxElementSetAsnRead(AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)7550 NLM_EXTERN TaxElementPtr LIBCALL TaxElementSetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
7551 {
7552     DataVal av;
7553     AsnTypePtr atp;
7554     TaxElementPtr tep, curr = NULL, first = NULL;
7555 
7556     if (aip == NULL)
7557         return (TaxElementPtr)NULL;
7558 
7559     AsnLinkType(element, TAXELEMENT);    /* link in local tree */
7560     atp = set;
7561 
7562     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7563     while ((atp = AsnReadId(aip, amp, atp)) == element)
7564     {
7565         tep = TaxElementAsnRead(aip, atp);
7566         if (tep == NULL)
7567             goto erret;
7568         if (first == NULL)
7569             first = tep;
7570         else
7571             curr->next = tep;
7572         curr = tep;
7573     }
7574     if (atp == NULL)
7575         goto erret;
7576     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7577     if (first == NULL)
7578         ErrPostEx(SEV_WARNING, 0, 0, "Empty SET OF TaxElement. line %ld", (long) aip->linenumber);
7579 ret:
7580     AsnUnlinkType(element);       /* unlink local tree */
7581     return first;
7582 erret:
7583     first = TaxElementSetFree(first);
7584     goto ret;
7585 }
7586 
7587 /*****************************************************************************
7588 *
7589 *   BinomialOrgNameNew()
7590 *
7591 *****************************************************************************/
BinomialOrgNameNew(void)7592 NLM_EXTERN BinomialOrgNamePtr LIBCALL BinomialOrgNameNew (void)
7593 {
7594     return (BinomialOrgNamePtr)MemNew(sizeof(BinomialOrgName));
7595 }
7596 
7597 /*****************************************************************************
7598 *
7599 *   BinomialOrgNameFree(bop)
7600 *       Frees an BinomialOrgName and associated data
7601 *
7602 *****************************************************************************/
BinomialOrgNameFree(BinomialOrgNamePtr bop)7603 NLM_EXTERN BinomialOrgNamePtr LIBCALL BinomialOrgNameFree (BinomialOrgNamePtr bop)
7604 {
7605     if (bop == NULL)
7606         return (BinomialOrgNamePtr)NULL;
7607 
7608     MemFree(bop->genus);
7609     MemFree(bop->species);
7610     MemFree(bop->subspecies);
7611     return (BinomialOrgNamePtr)MemFree(bop);
7612 }
7613 
7614 /*****************************************************************************
7615 *
7616 *   BinomialOrgNameAsnWrite(bop, aip, atp)
7617 *       atp is the current type (if identifier of a parent struct)
7618 *       if atp == NULL, then assumes it stands alone (BinomialOrgName ::=)
7619 *
7620 *****************************************************************************/
BinomialOrgNameAsnWrite(BinomialOrgNamePtr bop,AsnIoPtr aip,AsnTypePtr orig)7621 NLM_EXTERN Boolean LIBCALL BinomialOrgNameAsnWrite (BinomialOrgNamePtr bop, AsnIoPtr aip, AsnTypePtr orig)
7622 {
7623     DataVal av;
7624     AsnTypePtr atp;
7625     Boolean retval = FALSE;
7626 
7627     if (! loaded)
7628     {
7629         if (! SeqFeatAsnLoad())
7630             return FALSE;
7631     }
7632 
7633     if (aip == NULL)
7634         return FALSE;
7635 
7636     atp = AsnLinkType(orig, BINOMIALORGNAME);   /* link local tree */
7637     if (atp == NULL)
7638         return FALSE;
7639 
7640     if (bop == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
7641 
7642     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
7643 
7644     if (! AsnOpenStruct(aip, atp, (Pointer)bop))
7645         goto erret;
7646 
7647     if (bop->genus != NULL)
7648     {
7649         av.ptrvalue = bop->genus;
7650         if (! AsnWrite(aip, BINOMIALORGNAME_genus, &av)) goto erret;
7651     }
7652 
7653     if (bop->species != NULL)
7654     {
7655         av.ptrvalue = bop->species;
7656         if (! AsnWrite(aip, BINOMIALORGNAME_species, &av)) goto erret;
7657     }
7658 
7659     if (bop->subspecies != NULL)
7660     {
7661         av.ptrvalue = bop->subspecies;
7662         if (! AsnWrite(aip, BINOMIALORGNAME_subspecies, &av)) goto erret;
7663     }
7664 
7665     if (! AsnCloseStruct(aip, atp, (Pointer)bop))
7666         goto erret;
7667     retval = TRUE;
7668 erret:
7669     AsnUnlinkType(orig);       /* unlink local tree */
7670     return retval;
7671 }
7672 
7673 /*****************************************************************************
7674 *
7675 *   BinomialOrgNameAsnRead(aip, atp)
7676 *       atp is the current type (if identifier of a parent struct)
7677 *            assumption is readIdent has occurred
7678 *       if atp == NULL, then assumes it stands alone and read ident
7679 *            has not occurred.
7680 *
7681 *****************************************************************************/
BinomialOrgNameAsnRead(AsnIoPtr aip,AsnTypePtr orig)7682 NLM_EXTERN BinomialOrgNamePtr LIBCALL BinomialOrgNameAsnRead (AsnIoPtr aip, AsnTypePtr orig)
7683 {
7684     DataVal av;
7685     AsnTypePtr atp, oldatp;
7686     BinomialOrgNamePtr bop;
7687 
7688     if (! loaded)
7689     {
7690         if (! SeqFeatAsnLoad())
7691             return (BinomialOrgNamePtr)NULL;
7692     }
7693 
7694     if (aip == NULL)
7695         return (BinomialOrgNamePtr)NULL;
7696 
7697     if (orig == NULL)           /* BinomialOrgName ::= (self contained) */
7698         atp = AsnReadId(aip, amp, BINOMIALORGNAME);
7699     else
7700         atp = AsnLinkType(orig, BINOMIALORGNAME);    /* link in local tree */
7701     oldatp = atp;
7702     if (atp == NULL)
7703         return (BinomialOrgNamePtr)NULL;
7704 
7705     bop = BinomialOrgNameNew();
7706     if (bop == NULL)
7707         goto erret;
7708 
7709     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7710 
7711     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
7712     {
7713         if (atp == NULL)
7714             goto erret;
7715         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7716         if (atp == BINOMIALORGNAME_genus)
7717             bop->genus = (CharPtr)(av.ptrvalue);
7718         else if (atp == BINOMIALORGNAME_species)
7719             bop->species = (CharPtr)(av.ptrvalue);
7720         else if (atp == BINOMIALORGNAME_subspecies)
7721             bop->subspecies = (CharPtr)(av.ptrvalue);
7722     }
7723     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7724 ret:
7725     AsnUnlinkType(orig);       /* unlink local tree */
7726     return bop;
7727 erret:
7728     bop = BinomialOrgNameFree(bop);
7729     goto ret;
7730 }
7731 
7732 
7733 /*****************************************************************************
7734 *
7735 *   BioSourceNew()
7736 *
7737 *****************************************************************************/
BioSourceNew(void)7738 NLM_EXTERN BioSourcePtr LIBCALL BioSourceNew (void)
7739 {
7740     return (BioSourcePtr)MemNew(sizeof(BioSource));
7741 }
7742 
7743 /*****************************************************************************
7744 *
7745 *   BioSourceFree(bsp)
7746 *       Frees an BioSource and associated data
7747 *
7748 *****************************************************************************/
BioSourceFree(BioSourcePtr bsp)7749 NLM_EXTERN BioSourcePtr LIBCALL BioSourceFree (BioSourcePtr bsp)
7750 {
7751     if (bsp == NULL)
7752         return (BioSourcePtr)NULL;
7753 
7754     OrgRefFree(bsp->org);
7755     SubSourceSetFree(bsp->subtype);
7756     PCRReactionSetFree(bsp->pcr_primers);
7757     return (BioSourcePtr)MemFree(bsp);
7758 }
7759 
7760 /*****************************************************************************
7761 *
7762 *   BioSourceAsnWrite(bsp, aip, atp)
7763 *       atp is the current type (if identifier of a parent struct)
7764 *       if atp == NULL, then assumes it stands alone (BioSource ::=)
7765 *
7766 *****************************************************************************/
BioSourceAsnWrite(BioSourcePtr bsp,AsnIoPtr aip,AsnTypePtr orig)7767 NLM_EXTERN Boolean LIBCALL BioSourceAsnWrite (BioSourcePtr bsp, AsnIoPtr aip, AsnTypePtr orig)
7768 {
7769     DataVal av;
7770     AsnTypePtr atp;
7771     Boolean retval = FALSE;
7772 
7773     if (! loaded)
7774     {
7775         if (! SeqFeatAsnLoad())
7776             return FALSE;
7777     }
7778 
7779     if (aip == NULL)
7780         return FALSE;
7781 
7782     atp = AsnLinkType(orig, BIOSOURCE);   /* link local tree */
7783     if (atp == NULL)
7784         return FALSE;
7785 
7786     if (bsp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
7787 
7788     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
7789 
7790     if (! AsnOpenStruct(aip, atp, (Pointer)bsp))
7791         goto erret;
7792 
7793     if (bsp->genome)
7794     {
7795         if ((bsp->genome < 14) || (aip->spec_version == 0 || aip->spec_version > 4))
7796         {
7797             av.intvalue = (Int4)bsp->genome;
7798             if (! AsnWrite(aip, BIOSOURCE_genome, &av)) goto erret;
7799         }
7800     }
7801 
7802     if (bsp->origin)
7803     {
7804         av.intvalue = (Int4)bsp->origin;
7805         if (! AsnWrite(aip, BIOSOURCE_origin, &av)) goto erret;
7806     }
7807 
7808     if (bsp->org != NULL)
7809     {
7810         if (! OrgRefAsnWrite(bsp->org, aip, BIOSOURCE_org))
7811             goto erret;
7812     }
7813 
7814     if (bsp->subtype != NULL)
7815     {
7816         if (! SubSourceSetAsnWrite(bsp->subtype, aip, BIOSOURCE_subtype, BIOSOURCE_subtype_E))
7817             goto erret;
7818     }
7819 
7820     if ((bsp->is_focus) && ((aip->spec_version == 0) || (aip->spec_version >= 6)))
7821     {
7822         av.ptrvalue = NULL;
7823         if (! AsnWrite(aip, BIOSOURCE_is_focus, &av))
7824             goto erret;
7825     }
7826 
7827     if (bsp->pcr_primers != NULL) {
7828         if (! PCRReactionSetAsnWrite(bsp->pcr_primers, aip, BIOSOURCE_pcr_primers)) {
7829             goto erret;
7830         }
7831     }
7832 
7833     if (! AsnCloseStruct(aip, atp, (Pointer)bsp))
7834         goto erret;
7835     retval = TRUE;
7836 erret:
7837     AsnUnlinkType(orig);       /* unlink local tree */
7838     return retval;
7839 }
7840 
7841 /*****************************************************************************
7842 *
7843 *   BioSourceAsnRead(aip, atp)
7844 *       atp is the current type (if identifier of a parent struct)
7845 *            assumption is readIdent has occurred
7846 *       if atp == NULL, then assumes it stands alone and read ident
7847 *            has not occurred.
7848 *
7849 *****************************************************************************/
BioSourceAsnRead(AsnIoPtr aip,AsnTypePtr orig)7850 NLM_EXTERN BioSourcePtr LIBCALL BioSourceAsnRead (AsnIoPtr aip, AsnTypePtr orig)
7851 {
7852     DataVal av;
7853     AsnTypePtr atp, oldatp;
7854     BioSourcePtr bsp;
7855 
7856     if (! loaded)
7857     {
7858         if (! SeqFeatAsnLoad())
7859             return (BioSourcePtr)NULL;
7860     }
7861 
7862     if (aip == NULL)
7863         return (BioSourcePtr)NULL;
7864 
7865     if (orig == NULL)           /* BioSource ::= (self contained) */
7866         atp = AsnReadId(aip, amp, BIOSOURCE);
7867     else
7868         atp = AsnLinkType(orig, BIOSOURCE);    /* link in local tree */
7869     oldatp = atp;
7870     if (atp == NULL)
7871         return (BioSourcePtr)NULL;
7872 
7873     bsp = BioSourceNew();
7874     if (bsp == NULL)
7875         goto erret;
7876 
7877     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
7878 
7879     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
7880     {
7881         if (atp == NULL)
7882             goto erret;
7883         if (atp == BIOSOURCE_org)
7884         {
7885             bsp->org = OrgRefAsnRead(aip, atp);
7886             if (bsp->org == NULL) goto erret;
7887         }
7888         else if (atp == BIOSOURCE_subtype)
7889         {
7890             bsp->subtype = SubSourceSetAsnRead(aip, atp, BIOSOURCE_subtype_E);
7891             if (bsp->subtype == NULL) goto erret;
7892         }
7893         else if (atp == BIOSOURCE_pcr_primers)
7894         {
7895             bsp->pcr_primers = PCRReactionSetAsnRead(aip, atp);
7896             if (bsp->pcr_primers == NULL) goto erret;
7897         }
7898         else
7899         {
7900             if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
7901             if (atp == BIOSOURCE_genome)
7902                 bsp->genome = (Uint1)(av.intvalue);
7903             else if (atp == BIOSOURCE_origin)
7904                 bsp->origin = (Uint1)(av.intvalue);
7905             else if (atp == BIOSOURCE_is_focus)
7906                 bsp->is_focus = TRUE;
7907         }
7908     }
7909     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
7910 ret:
7911     AsnUnlinkType(orig);       /* unlink local tree */
7912     return bsp;
7913 erret:
7914     bsp = BioSourceFree(bsp);
7915     goto ret;
7916 }
7917 
7918 /*****************************************************************************
7919 *
7920 *   BioSourceMatch(biop1, biop2)
7921 *
7922 *****************************************************************************/
BioSourceMatch(BioSourcePtr biop1,BioSourcePtr biop2)7923 NLM_EXTERN Boolean LIBCALL BioSourceMatch (BioSourcePtr biop1, BioSourcePtr biop2)
7924 {
7925   if (biop1 == NULL && biop2 == NULL)
7926   {
7927     return TRUE;
7928   }
7929   else if (biop1 == NULL || biop2 == NULL)
7930   {
7931     return FALSE;
7932   }
7933   else if (biop1->origin != biop2->origin
7934            || biop1->is_focus != biop2->is_focus
7935            || ! OrgRefMatch (biop1->org, biop2->org)
7936            || ! SubSourceSetMatch (biop1->subtype, biop2->subtype))
7937   {
7938     return FALSE;
7939   }
7940   else if (biop1->genome == biop2->genome
7941            || (biop1->genome == 0 && biop2->genome == 1)
7942            || (biop1->genome == 1 && biop2->genome == 0))
7943   {
7944     return TRUE;
7945   }
7946   else
7947   {
7948     return FALSE;
7949   }
7950 }
7951 
7952 /*****************************************************************************
7953 *
7954 *   SubSourceNew()
7955 *
7956 *****************************************************************************/
SubSourceNew(void)7957 NLM_EXTERN SubSourcePtr LIBCALL SubSourceNew (void)
7958 {
7959     return (SubSourcePtr)MemNew(sizeof(SubSource));
7960 }
7961 
7962 /*****************************************************************************
7963 *
7964 *   SubSourceFree(ssp)
7965 *       Frees an SubSource and associated data
7966 *
7967 *****************************************************************************/
SubSourceFree(SubSourcePtr ssp)7968 NLM_EXTERN SubSourcePtr LIBCALL SubSourceFree (SubSourcePtr ssp)
7969 {
7970     if (ssp == NULL)
7971         return (SubSourcePtr)NULL;
7972 
7973     MemFree(ssp->name);
7974     MemFree(ssp->attrib);
7975     return (SubSourcePtr)MemFree(ssp);
7976 }
7977 
7978 /*****************************************************************************
7979 *
7980 *   SubSourceAsnWrite(ssp, aip, atp)
7981 *       atp is the current type (if identifier of a parent struct)
7982 *       if atp == NULL, then assumes it stands alone (SubSource ::=)
7983 *
7984 *****************************************************************************/
SubSourceAsnWrite(SubSourcePtr ssp,AsnIoPtr aip,AsnTypePtr orig)7985 NLM_EXTERN Boolean LIBCALL SubSourceAsnWrite (SubSourcePtr ssp, AsnIoPtr aip, AsnTypePtr orig)
7986 {
7987     DataVal av;
7988     AsnTypePtr atp;
7989     Boolean retval = FALSE;
7990 
7991     if (! loaded)
7992     {
7993         if (! SeqFeatAsnLoad())
7994             return FALSE;
7995     }
7996 
7997     if (aip == NULL)
7998         return FALSE;
7999 
8000     atp = AsnLinkType(orig, SUBSOURCE);   /* link local tree */
8001     if (atp == NULL)
8002         return FALSE;
8003 
8004     if (ssp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8005 
8006     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
8007 
8008     if (! AsnOpenStruct(aip, atp, (Pointer)ssp))
8009         goto erret;
8010 
8011     av.intvalue = (Int4)(ssp->subtype);
8012     if (AsnWrite(aip, SUBSOURCE_subtype, &av) <= 0) goto erret;
8013 
8014     if (ssp->name != NULL)
8015     {
8016         av.ptrvalue = ssp->name;
8017         if (! AsnWrite(aip, SUBSOURCE_name, &av)) goto erret;
8018     }
8019 
8020     if (ssp->attrib != NULL)
8021     {
8022         av.ptrvalue = ssp->attrib;
8023         if (! AsnWrite(aip, SUBSOURCE_attrib, &av)) goto erret;
8024     }
8025 
8026     if (! AsnCloseStruct(aip, atp, (Pointer)ssp))
8027         goto erret;
8028     retval = TRUE;
8029 erret:
8030     AsnUnlinkType(orig);       /* unlink local tree */
8031     return retval;
8032 }
8033 
8034 /*****************************************************************************
8035 *
8036 *   SubSourceAsnRead(aip, atp)
8037 *       atp is the current type (if identifier of a parent struct)
8038 *            assumption is readIdent has occurred
8039 *       if atp == NULL, then assumes it stands alone and read ident
8040 *            has not occurred.
8041 *
8042 *****************************************************************************/
SubSourceAsnRead(AsnIoPtr aip,AsnTypePtr orig)8043 NLM_EXTERN SubSourcePtr LIBCALL SubSourceAsnRead (AsnIoPtr aip, AsnTypePtr orig)
8044 {
8045     DataVal av;
8046     AsnTypePtr atp, oldatp;
8047     SubSourcePtr ssp;
8048 
8049     if (! loaded)
8050     {
8051         if (! SeqFeatAsnLoad())
8052             return (SubSourcePtr)NULL;
8053     }
8054 
8055     if (aip == NULL)
8056         return (SubSourcePtr)NULL;
8057 
8058     if (orig == NULL)           /* SubSource ::= (self contained) */
8059         atp = AsnReadId(aip, amp, SUBSOURCE);
8060     else
8061         atp = AsnLinkType(orig, SUBSOURCE);    /* link in local tree */
8062     oldatp = atp;
8063     if (atp == NULL)
8064         return (SubSourcePtr)NULL;
8065 
8066     ssp = SubSourceNew();
8067     if (ssp == NULL)
8068         goto erret;
8069 
8070     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
8071 
8072     while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
8073     {
8074         if (atp == NULL)
8075             goto erret;
8076         if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
8077         if (atp == SUBSOURCE_subtype)
8078             ssp->subtype = (Uint1)(av.intvalue);
8079         else if (atp == SUBSOURCE_name)
8080             ssp->name = (CharPtr)(av.ptrvalue);
8081         else if (atp == SUBSOURCE_attrib)
8082             ssp->attrib = (CharPtr)(av.ptrvalue);
8083     }
8084     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
8085 ret:
8086     AsnUnlinkType(orig);       /* unlink local tree */
8087     return ssp;
8088 erret:
8089     ssp = SubSourceFree(ssp);
8090     goto ret;
8091 }
8092 
8093 /*****************************************************************************
8094 *
8095 *   SubSourceSetFree (ssp)
8096 *
8097 *****************************************************************************/
SubSourceSetFree(SubSourcePtr ssp)8098 NLM_EXTERN SubSourcePtr LIBCALL SubSourceSetFree (SubSourcePtr ssp)
8099 {
8100     SubSourcePtr next;
8101 
8102     while (ssp != NULL)
8103     {
8104         next = ssp->next;
8105         SubSourceFree(ssp);
8106         ssp = next;
8107     }
8108     return ssp;
8109 }
8110 
8111 /*****************************************************************************
8112 *
8113 *   SubSourceSetAsnWrite(ssp, aip, set, element)
8114 *
8115 *****************************************************************************/
SubSourceSetAsnWrite(SubSourcePtr ssp,AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)8116 NLM_EXTERN Boolean LIBCALL SubSourceSetAsnWrite (SubSourcePtr ssp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
8117 {
8118     AsnTypePtr atp;
8119     SubSourcePtr oldssp;
8120     Boolean retval = FALSE;
8121 
8122     if (! loaded)
8123     {
8124         if (! SeqFeatAsnLoad())
8125             return FALSE;
8126     }
8127 
8128     if (aip == NULL)
8129         return FALSE;
8130 
8131     atp = AsnLinkType(element, SUBSOURCE);   /* link local tree */
8132     if (atp == NULL)
8133         return FALSE;
8134     oldssp = ssp;
8135 
8136     if (! AsnOpenStruct(aip, set, (Pointer)oldssp))
8137         goto erret;
8138 
8139     while (ssp != NULL)
8140     {
8141         if (! SubSourceAsnWrite(ssp, aip, atp))
8142             goto erret;
8143         ssp = ssp->next;
8144     }
8145 
8146     if (! AsnCloseStruct(aip, set, (Pointer)oldssp))
8147         goto erret;
8148     retval = TRUE;
8149 erret:
8150     AsnUnlinkType(element);       /* unlink local tree */
8151     return retval;
8152 }
8153 
8154 /*****************************************************************************
8155 *
8156 *   SubSourceSetAsnRead(aip, set, element)
8157 *
8158 *****************************************************************************/
SubSourceSetAsnRead(AsnIoPtr aip,AsnTypePtr set,AsnTypePtr element)8159 NLM_EXTERN SubSourcePtr LIBCALL SubSourceSetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
8160 {
8161     DataVal av;
8162     AsnTypePtr atp;
8163     SubSourcePtr ssp, curr = NULL, first = NULL;
8164 
8165     if (aip == NULL)
8166         return (SubSourcePtr)NULL;
8167 
8168     AsnLinkType(element, SUBSOURCE);    /* link in local tree */
8169     atp = set;
8170 
8171     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;    /* read the start struct */
8172     while ((atp = AsnReadId(aip, amp, atp)) == element)
8173     {
8174         ssp = SubSourceAsnRead(aip, atp);
8175         if (ssp == NULL)
8176             goto erret;
8177         if (first == NULL)
8178             first = ssp;
8179         else
8180             curr->next = ssp;
8181         curr = ssp;
8182     }
8183     if (atp == NULL)
8184         goto erret;
8185     if (AsnReadVal(aip, atp, &av) <= 0) goto erret;   /* end struct */
8186     if (first == NULL)
8187         ErrPostEx(SEV_WARNING, 0, 0, "Empty SET OF SubSource. line %ld", (long) aip->linenumber);
8188 ret:
8189     AsnUnlinkType(element);       /* unlink local tree */
8190     return first;
8191 erret:
8192     first = SubSourceSetFree(first);
8193     goto ret;
8194 }
8195 
8196 /*****************************************************************************
8197 *
8198 *   SubSourceSetMatch(ssp1, ssp2)
8199 *
8200 *****************************************************************************/
SubSourceSetMatch(SubSourcePtr ssp1,SubSourcePtr ssp2)8201 NLM_EXTERN Boolean LIBCALL SubSourceSetMatch (SubSourcePtr ssp1, SubSourcePtr ssp2)
8202 {
8203   while (ssp1 != NULL && ssp2 != NULL)
8204   {
8205     if (ssp1->subtype != ssp2->subtype)
8206     {
8207       return FALSE;
8208     }
8209     else if (StringCmp (ssp1->name, ssp2->name) != 0)
8210     {
8211       return FALSE;
8212     }
8213     else if (StringCmp (ssp1->attrib, ssp2->attrib) != 0)
8214     {
8215       return FALSE;
8216     }
8217 
8218     ssp1 = ssp1->next;
8219     ssp2 = ssp2->next;
8220   }
8221 
8222   if (ssp1 == NULL && ssp2 == NULL)
8223   {
8224     return TRUE;
8225   }
8226   else
8227   {
8228     return FALSE;
8229   }
8230 }
8231 
8232 /**************************************************
8233 *
8234 *    PCRPrimerNew()
8235 *
8236 **************************************************/
8237 NLM_EXTERN
8238 PCRPrimerPtr LIBCALL
PCRPrimerNew(void)8239 PCRPrimerNew(void)
8240 {
8241    PCRPrimerPtr ptr = MemNew((size_t) sizeof(PCRPrimer));
8242 
8243    return ptr;
8244 
8245 }
8246 
8247 /**************************************************
8248 *
8249 *    PCRPrimerFree()
8250 *
8251 **************************************************/
8252 NLM_EXTERN
8253 PCRPrimerPtr LIBCALL
PCRPrimerFree(PCRPrimerPtr ptr)8254 PCRPrimerFree(PCRPrimerPtr ptr)
8255 {
8256 
8257    if(ptr == NULL) {
8258       return NULL;
8259    }
8260    MemFree(ptr -> seq);
8261    MemFree(ptr -> name);
8262    return MemFree(ptr);
8263 }
8264 
8265 /**************************************************
8266 *
8267 *    PCRPrimerAsnRead()
8268 *
8269 **************************************************/
8270 NLM_EXTERN
8271 PCRPrimerPtr LIBCALL
PCRPrimerAsnRead(AsnIoPtr aip,AsnTypePtr orig)8272 PCRPrimerAsnRead(AsnIoPtr aip, AsnTypePtr orig)
8273 {
8274    DataVal av;
8275    AsnTypePtr atp;
8276    AsnReadFunc func;
8277    PCRPrimerPtr ptr;
8278 
8279     if (! loaded)
8280     {
8281         if (! SeqFeatAsnLoad())
8282             return (PCRPrimerPtr)NULL;
8283     }
8284 
8285    if (aip == NULL) {
8286       return NULL;
8287    }
8288 
8289    if (orig == NULL) {         /* PCRPrimer ::= (self contained) */
8290       atp = AsnReadId(aip, amp, PCRPRIMER);
8291    } else {
8292       atp = AsnLinkType(orig, PCRPRIMER);
8293    }
8294    /* link in local tree */
8295    if (atp == NULL) {
8296       return NULL;
8297    }
8298 
8299    ptr = PCRPrimerNew();
8300    if (ptr == NULL) {
8301       goto erret;
8302    }
8303    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
8304       goto erret;
8305    }
8306 
8307    atp = AsnReadId(aip,amp, atp);
8308    func = NULL;
8309 
8310    if (atp == PCRPRIMER_seq) {
8311       if ( AsnReadVal(aip, atp, &av) <= 0) {
8312          goto erret;
8313       }
8314       ptr -> seq = av.ptrvalue;
8315       atp = AsnReadId(aip,amp, atp);
8316    }
8317    if (atp == PCRPRIMER_name) {
8318       if ( AsnReadVal(aip, atp, &av) <= 0) {
8319          goto erret;
8320       }
8321       ptr -> name = av.ptrvalue;
8322       atp = AsnReadId(aip,amp, atp);
8323    }
8324 
8325    if (AsnReadVal(aip, atp, &av) <= 0) {
8326       goto erret;
8327    }
8328    /* end struct */
8329 
8330 ret:
8331    AsnUnlinkType(orig);       /* unlink local tree */
8332    return ptr;
8333 
8334 erret:
8335    aip -> io_failure = TRUE;
8336    ptr = PCRPrimerFree(ptr);
8337    goto ret;
8338 }
8339 
8340 /**************************************************
8341 *
8342 *    PCRPrimerAsnWrite()
8343 *
8344 **************************************************/
8345 NLM_EXTERN Boolean LIBCALL
PCRPrimerAsnWrite(PCRPrimerPtr ptr,AsnIoPtr aip,AsnTypePtr orig)8346 PCRPrimerAsnWrite(PCRPrimerPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
8347 {
8348    DataVal av;
8349    AsnTypePtr atp;
8350    Boolean retval = FALSE;
8351 
8352     if (! loaded)
8353     {
8354         if (! SeqFeatAsnLoad())
8355             return FALSE;
8356     }
8357 
8358    if (aip == NULL) {
8359       return FALSE;
8360    }
8361 
8362    atp = AsnLinkType(orig, PCRPRIMER);   /* link local tree */
8363    if (atp == NULL) {
8364       return FALSE;
8365    }
8366 
8367    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8368 
8369     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
8370 
8371    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
8372       goto erret;
8373    }
8374 
8375    if (ptr -> seq != NULL) {
8376       av.ptrvalue = ptr -> seq;
8377       retval = AsnWrite(aip, PCRPRIMER_seq,  &av);
8378    }
8379    if (ptr -> name != NULL) {
8380       av.ptrvalue = ptr -> name;
8381       retval = AsnWrite(aip, PCRPRIMER_name,  &av);
8382    }
8383    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
8384       goto erret;
8385    }
8386    retval = TRUE;
8387 
8388 erret:
8389    AsnUnlinkType(orig);       /* unlink local tree */
8390    return retval;
8391 }
8392 
8393 /**************************************************
8394 *
8395 *    PCRPrimerSetFree()
8396 *
8397 **************************************************/
8398 NLM_EXTERN
8399 PCRPrimerSetPtr LIBCALL
PCRPrimerSetFree(PCRPrimerSetPtr ptr)8400 PCRPrimerSetFree(PCRPrimerSetPtr ptr)
8401 {
8402 
8403    if(ptr == NULL) {
8404       return NULL;
8405    }
8406    AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) PCRPrimerFree);
8407    return NULL;
8408 }
8409 
8410 /**************************************************
8411 *
8412 *    PCRPrimerSetAsnRead()
8413 *
8414 **************************************************/
8415 NLM_EXTERN
8416 PCRPrimerSetPtr LIBCALL
PCRPrimerSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)8417 PCRPrimerSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
8418 {
8419    AsnTypePtr atp;
8420    Boolean isError = FALSE;
8421    AsnReadFunc func;
8422    PCRPrimerSetPtr ptr;
8423 
8424     if (! loaded)
8425     {
8426         if (! SeqFeatAsnLoad())
8427             return (PCRPrimerSetPtr)NULL;
8428     }
8429 
8430    if (aip == NULL) {
8431       return NULL;
8432    }
8433 
8434    if (orig == NULL) {         /* PCRPrimerSet ::= (self contained) */
8435       atp = AsnReadId(aip, amp, PCRPRIMERSET);
8436    } else {
8437       atp = AsnLinkType(orig, PCRPRIMERSET);
8438    }
8439    /* link in local tree */
8440    if (atp == NULL) {
8441       return NULL;
8442    }
8443 
8444    func = NULL;
8445 
8446    ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) PCRPrimerAsnRead, (AsnOptFreeFunc) PCRPrimerFree);
8447    if (isError && ptr  == NULL) {
8448       goto erret;
8449    }
8450 
8451 
8452 
8453 ret:
8454    AsnUnlinkType(orig);       /* unlink local tree */
8455    return ptr;
8456 
8457 erret:
8458    aip -> io_failure = TRUE;
8459    ptr = PCRPrimerSetFree(ptr);
8460    goto ret;
8461 }
8462 
8463 /**************************************************
8464 *
8465 *    PCRPrimerSetAsnWrite()
8466 *
8467 **************************************************/
8468 NLM_EXTERN Boolean LIBCALL
PCRPrimerSetAsnWrite(PCRPrimerSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)8469 PCRPrimerSetAsnWrite(PCRPrimerSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
8470 {
8471    AsnTypePtr atp;
8472    Boolean retval = FALSE;
8473 
8474     if (! loaded)
8475     {
8476         if (! SeqFeatAsnLoad())
8477             return FALSE;
8478     }
8479 
8480    if (aip == NULL) {
8481       return FALSE;
8482    }
8483 
8484    atp = AsnLinkType(orig, PCRPRIMERSET);   /* link local tree */
8485    if (atp == NULL) {
8486       return FALSE;
8487    }
8488 
8489    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8490    retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) PCRPrimerAsnWrite, aip, atp, PCRPRIMERSET_E);
8491    retval = TRUE;
8492 
8493 erret:
8494    AsnUnlinkType(orig);       /* unlink local tree */
8495    return retval;
8496 }
8497 
8498 /**************************************************
8499 *
8500 *    PCRReactionNew()
8501 *
8502 **************************************************/
8503 NLM_EXTERN
8504 PCRReactionPtr LIBCALL
PCRReactionNew(void)8505 PCRReactionNew(void)
8506 {
8507    PCRReactionPtr ptr = MemNew((size_t) sizeof(PCRReaction));
8508 
8509    return ptr;
8510 
8511 }
8512 
8513 /**************************************************
8514 *
8515 *    PCRReactionFree()
8516 *
8517 **************************************************/
8518 NLM_EXTERN
8519 PCRReactionPtr LIBCALL
PCRReactionFree(PCRReactionPtr ptr)8520 PCRReactionFree(PCRReactionPtr ptr)
8521 {
8522 
8523    if(ptr == NULL) {
8524       return NULL;
8525    }
8526    PCRPrimerSetFree(ptr -> forward);
8527    PCRPrimerSetFree(ptr -> reverse);
8528    return MemFree(ptr);
8529 }
8530 
8531 /**************************************************
8532 *
8533 *    PCRReactionAsnRead()
8534 *
8535 **************************************************/
8536 NLM_EXTERN
8537 PCRReactionPtr LIBCALL
PCRReactionAsnRead(AsnIoPtr aip,AsnTypePtr orig)8538 PCRReactionAsnRead(AsnIoPtr aip, AsnTypePtr orig)
8539 {
8540    DataVal av;
8541    AsnTypePtr atp;
8542    AsnReadFunc func;
8543    PCRReactionPtr ptr;
8544 
8545     if (! loaded)
8546     {
8547         if (! SeqFeatAsnLoad())
8548             return (PCRReactionPtr)NULL;
8549     }
8550 
8551    if (aip == NULL) {
8552       return NULL;
8553    }
8554 
8555    if (orig == NULL) {         /* PCRReaction ::= (self contained) */
8556       atp = AsnReadId(aip, amp, PCRREACTION);
8557    } else {
8558       atp = AsnLinkType(orig, PCRREACTION);
8559    }
8560    /* link in local tree */
8561    if (atp == NULL) {
8562       return NULL;
8563    }
8564 
8565    ptr = PCRReactionNew();
8566    if (ptr == NULL) {
8567       goto erret;
8568    }
8569    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
8570       goto erret;
8571    }
8572 
8573    atp = AsnReadId(aip,amp, atp);
8574    func = NULL;
8575 
8576    if (atp == PCRREACTION_forward) {
8577       ptr -> forward = PCRPrimerSetAsnRead(aip, atp);
8578       if (aip -> io_failure) {
8579          goto erret;
8580       }
8581       atp = AsnReadId(aip,amp, atp);
8582    }
8583    if (atp == PCRREACTION_reverse) {
8584       ptr -> reverse = PCRPrimerSetAsnRead(aip, atp);
8585       if (aip -> io_failure) {
8586          goto erret;
8587       }
8588       atp = AsnReadId(aip,amp, atp);
8589    }
8590 
8591    if (AsnReadVal(aip, atp, &av) <= 0) {
8592       goto erret;
8593    }
8594    /* end struct */
8595 
8596 ret:
8597    AsnUnlinkType(orig);       /* unlink local tree */
8598    return ptr;
8599 
8600 erret:
8601    aip -> io_failure = TRUE;
8602    ptr = PCRReactionFree(ptr);
8603    goto ret;
8604 }
8605 
8606 /**************************************************
8607 *
8608 *    PCRReactionAsnWrite()
8609 *
8610 **************************************************/
8611 NLM_EXTERN Boolean LIBCALL
PCRReactionAsnWrite(PCRReactionPtr ptr,AsnIoPtr aip,AsnTypePtr orig)8612 PCRReactionAsnWrite(PCRReactionPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
8613 {
8614    AsnTypePtr atp;
8615    Boolean retval = FALSE;
8616 
8617     if (! loaded)
8618     {
8619         if (! SeqFeatAsnLoad())
8620             return FALSE;
8621     }
8622 
8623    if (aip == NULL) {
8624       return FALSE;
8625    }
8626 
8627    atp = AsnLinkType(orig, PCRREACTION);   /* link local tree */
8628    if (atp == NULL) {
8629       return FALSE;
8630    }
8631 
8632    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8633    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
8634       goto erret;
8635    }
8636 
8637    if (ptr -> forward != NULL) {
8638       if ( ! PCRPrimerSetAsnWrite(ptr -> forward, aip, PCRREACTION_forward)) {
8639          goto erret;
8640       }
8641    }
8642    if (ptr -> reverse != NULL) {
8643       if ( ! PCRPrimerSetAsnWrite(ptr -> reverse, aip, PCRREACTION_reverse)) {
8644          goto erret;
8645       }
8646    }
8647    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
8648       goto erret;
8649    }
8650    retval = TRUE;
8651 
8652 erret:
8653    AsnUnlinkType(orig);       /* unlink local tree */
8654    return retval;
8655 }
8656 
8657 /**************************************************
8658 *
8659 *    PCRReactionSetFree()
8660 *
8661 **************************************************/
8662 NLM_EXTERN
8663 PCRReactionSetPtr LIBCALL
PCRReactionSetFree(PCRReactionSetPtr ptr)8664 PCRReactionSetFree(PCRReactionSetPtr ptr)
8665 {
8666 
8667    if(ptr == NULL) {
8668       return NULL;
8669    }
8670    AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) PCRReactionFree);
8671    return NULL;
8672 }
8673 
8674 /**************************************************
8675 *
8676 *    PCRReactionSetAsnRead()
8677 *
8678 **************************************************/
8679 NLM_EXTERN
8680 PCRReactionSetPtr LIBCALL
PCRReactionSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)8681 PCRReactionSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
8682 {
8683    AsnTypePtr atp;
8684    Boolean isError = FALSE;
8685    AsnReadFunc func;
8686    PCRReactionSetPtr ptr;
8687 
8688     if (! loaded)
8689     {
8690         if (! SeqFeatAsnLoad())
8691             return (PCRReactionSetPtr)NULL;
8692     }
8693 
8694    if (aip == NULL) {
8695       return NULL;
8696    }
8697 
8698    if (orig == NULL) {         /* PCRReactionSet ::= (self contained) */
8699       atp = AsnReadId(aip, amp, PCRREACTIONSET);
8700    } else {
8701       atp = AsnLinkType(orig, PCRREACTIONSET);
8702    }
8703    /* link in local tree */
8704    if (atp == NULL) {
8705       return NULL;
8706    }
8707 
8708    func = NULL;
8709 
8710    ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) PCRReactionAsnRead, (AsnOptFreeFunc) PCRReactionFree);
8711    if (isError && ptr  == NULL) {
8712       goto erret;
8713    }
8714 
8715 
8716 
8717 ret:
8718    AsnUnlinkType(orig);       /* unlink local tree */
8719    return ptr;
8720 
8721 erret:
8722    aip -> io_failure = TRUE;
8723    ptr = PCRReactionSetFree(ptr);
8724    goto ret;
8725 }
8726 
8727 /**************************************************
8728 *
8729 *    PCRReactionSetAsnWrite()
8730 *
8731 **************************************************/
8732 NLM_EXTERN Boolean LIBCALL
PCRReactionSetAsnWrite(PCRReactionSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)8733 PCRReactionSetAsnWrite(PCRReactionSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
8734 {
8735    AsnTypePtr atp;
8736    Boolean retval = FALSE;
8737 
8738     if (! loaded)
8739     {
8740         if (! SeqFeatAsnLoad())
8741             return FALSE;
8742     }
8743 
8744    if (aip == NULL) {
8745       return FALSE;
8746    }
8747 
8748    atp = AsnLinkType(orig, PCRREACTIONSET);   /* link local tree */
8749    if (atp == NULL) {
8750       return FALSE;
8751    }
8752 
8753    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8754    retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) PCRReactionAsnWrite, aip, atp, PCRREACTIONSET_E);
8755    retval = TRUE;
8756 
8757 erret:
8758    AsnUnlinkType(orig);       /* unlink local tree */
8759    return retval;
8760 }
8761 
8762 
8763 /**************************************************
8764 *
8765 *    CloneRefNew()
8766 *
8767 **************************************************/
8768 NLM_EXTERN
8769 CloneRefPtr LIBCALL
CloneRefNew(void)8770 CloneRefNew(void)
8771 {
8772    CloneRefPtr ptr = MemNew((size_t) sizeof(CloneRef));
8773 
8774    ptr -> concordant = 0;
8775    ptr -> unique = 0;
8776    return ptr;
8777 
8778 }
8779 
8780 
8781 /**************************************************
8782 *
8783 *    CloneRefFree()
8784 *
8785 **************************************************/
8786 NLM_EXTERN
8787 CloneRefPtr LIBCALL
CloneRefFree(CloneRefPtr ptr)8788 CloneRefFree(CloneRefPtr ptr)
8789 {
8790 
8791    if(ptr == NULL) {
8792       return NULL;
8793    }
8794    MemFree(ptr -> name);
8795    MemFree(ptr -> library);
8796    CloneSeqSetFree(ptr -> clone_seq);
8797    return MemFree(ptr);
8798 }
8799 
8800 
8801 /**************************************************
8802 *
8803 *    CloneRefAsnRead()
8804 *
8805 **************************************************/
8806 NLM_EXTERN
8807 CloneRefPtr LIBCALL
CloneRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)8808 CloneRefAsnRead(AsnIoPtr aip, AsnTypePtr orig)
8809 {
8810    DataVal av;
8811    AsnTypePtr atp;
8812    AsnReadFunc func;
8813    CloneRefPtr ptr;
8814 
8815    if (! loaded)
8816    {
8817       if (! SeqFeatAsnLoad()) {
8818          return NULL;
8819       }
8820    }
8821 
8822    if (aip == NULL) {
8823       return NULL;
8824    }
8825 
8826    if (orig == NULL) {         /* CloneRef ::= (self contained) */
8827       atp = AsnReadId(aip, amp, CLONE_REF);
8828    } else {
8829       atp = AsnLinkType(orig, CLONE_REF);
8830    }
8831    /* link in local tree */
8832    if (atp == NULL) {
8833       return NULL;
8834    }
8835 
8836    ptr = CloneRefNew();
8837    if (ptr == NULL) {
8838       goto erret;
8839    }
8840    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
8841       goto erret;
8842    }
8843 
8844    atp = AsnReadId(aip,amp, atp);
8845    func = NULL;
8846 
8847    if (atp == CLONE_REF_name) {
8848       if ( AsnReadVal(aip, atp, &av) <= 0) {
8849          goto erret;
8850       }
8851       ptr -> name = av.ptrvalue;
8852       atp = AsnReadId(aip,amp, atp);
8853    }
8854    if (atp == CLONE_REF_library) {
8855       if ( AsnReadVal(aip, atp, &av) <= 0) {
8856          goto erret;
8857       }
8858       ptr -> library = av.ptrvalue;
8859       atp = AsnReadId(aip,amp, atp);
8860    }
8861    if (atp == CLONE_REF_concordant) {
8862       if ( AsnReadVal(aip, atp, &av) <= 0) {
8863          goto erret;
8864       }
8865       ptr -> concordant = av.boolvalue;
8866       atp = AsnReadId(aip,amp, atp);
8867    }
8868    if (atp == CLONE_REF_unique) {
8869       if ( AsnReadVal(aip, atp, &av) <= 0) {
8870          goto erret;
8871       }
8872       ptr -> unique = av.boolvalue;
8873       atp = AsnReadId(aip,amp, atp);
8874    }
8875    if (atp == CLONE_REF_placement_method) {
8876       if ( AsnReadVal(aip, atp, &av) <= 0) {
8877          goto erret;
8878       }
8879       ptr -> placement_method = av.intvalue;
8880       ptr -> OBbits__ |= 1<<0;
8881       atp = AsnReadId(aip,amp, atp);
8882    }
8883    if (atp == CLONE_REF_clone_seq) {
8884       ptr -> clone_seq = CloneSeqSetAsnRead(aip, atp);
8885       if (aip -> io_failure) {
8886          goto erret;
8887       }
8888       atp = AsnReadId(aip,amp, atp);
8889    }
8890 
8891    if (AsnReadVal(aip, atp, &av) <= 0) {
8892       goto erret;
8893    }
8894    /* end struct */
8895 
8896 ret:
8897    AsnUnlinkType(orig);       /* unlink local tree */
8898    return ptr;
8899 
8900 erret:
8901    aip -> io_failure = TRUE;
8902    ptr = CloneRefFree(ptr);
8903    goto ret;
8904 }
8905 
8906 
8907 
8908 /**************************************************
8909 *
8910 *    CloneRefAsnWrite()
8911 *
8912 **************************************************/
8913 NLM_EXTERN Boolean LIBCALL
CloneRefAsnWrite(CloneRefPtr ptr,AsnIoPtr aip,AsnTypePtr orig)8914 CloneRefAsnWrite(CloneRefPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
8915 {
8916    DataVal av;
8917    AsnTypePtr atp;
8918    Boolean retval = FALSE;
8919 
8920    if (! loaded)
8921    {
8922       if (! SeqFeatAsnLoad()) {
8923          return FALSE;
8924       }
8925    }
8926 
8927    if (aip == NULL) {
8928       return FALSE;
8929    }
8930 
8931    atp = AsnLinkType(orig, CLONE_REF);   /* link local tree */
8932    if (atp == NULL) {
8933       return FALSE;
8934    }
8935 
8936    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
8937 
8938     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
8939 
8940    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
8941       goto erret;
8942    }
8943 
8944    if (ptr -> name != NULL) {
8945       av.ptrvalue = ptr -> name;
8946       retval = AsnWrite(aip, CLONE_REF_name,  &av);
8947    }
8948    if (ptr -> library != NULL) {
8949       av.ptrvalue = ptr -> library;
8950       retval = AsnWrite(aip, CLONE_REF_library,  &av);
8951    }
8952    av.boolvalue = ptr -> concordant;
8953    retval = AsnWrite(aip, CLONE_REF_concordant,  &av);
8954    av.boolvalue = ptr -> unique;
8955    retval = AsnWrite(aip, CLONE_REF_unique,  &av);
8956    if (ptr -> placement_method || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> placement_method;
8957       retval = AsnWrite(aip, CLONE_REF_placement_method,  &av);
8958    }
8959    if (ptr -> clone_seq != NULL) {
8960       if ( ! CloneSeqSetAsnWrite(ptr -> clone_seq, aip, CLONE_REF_clone_seq)) {
8961          goto erret;
8962       }
8963    }
8964    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
8965       goto erret;
8966    }
8967    retval = TRUE;
8968 
8969 erret:
8970    AsnUnlinkType(orig);       /* unlink local tree */
8971    return retval;
8972 }
8973 
8974 
8975 
8976 /**************************************************
8977 *
8978 *    CloneSeqSetFree()
8979 *
8980 **************************************************/
8981 NLM_EXTERN
8982 CloneSeqSetPtr LIBCALL
CloneSeqSetFree(CloneSeqSetPtr ptr)8983 CloneSeqSetFree(CloneSeqSetPtr ptr)
8984 {
8985 
8986    if(ptr == NULL) {
8987       return NULL;
8988    }
8989    AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) CloneSeqFree);
8990    return NULL;
8991 }
8992 
8993 
8994 /**************************************************
8995 *
8996 *    CloneSeqSetAsnRead()
8997 *
8998 **************************************************/
8999 NLM_EXTERN
9000 CloneSeqSetPtr LIBCALL
CloneSeqSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)9001 CloneSeqSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9002 {
9003    AsnTypePtr atp;
9004    Boolean isError = FALSE;
9005    AsnReadFunc func;
9006    CloneSeqSetPtr ptr;
9007 
9008    if (! loaded)
9009    {
9010       if (! SeqFeatAsnLoad()) {
9011          return NULL;
9012       }
9013    }
9014 
9015    if (aip == NULL) {
9016       return NULL;
9017    }
9018 
9019    if (orig == NULL) {         /* CloneSeqSet ::= (self contained) */
9020       atp = AsnReadId(aip, amp, CLONE_SEQ_SET);
9021    } else {
9022       atp = AsnLinkType(orig, CLONE_SEQ_SET);
9023    }
9024    /* link in local tree */
9025    if (atp == NULL) {
9026       return NULL;
9027    }
9028 
9029    func = NULL;
9030 
9031    ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) CloneSeqAsnRead, (AsnOptFreeFunc) CloneSeqFree);
9032    if (isError && ptr  == NULL) {
9033       goto erret;
9034    }
9035 
9036 
9037 
9038 ret:
9039    AsnUnlinkType(orig);       /* unlink local tree */
9040    return ptr;
9041 
9042 erret:
9043    aip -> io_failure = TRUE;
9044    ptr = CloneSeqSetFree(ptr);
9045    goto ret;
9046 }
9047 
9048 
9049 
9050 /**************************************************
9051 *
9052 *    CloneSeqSetAsnWrite()
9053 *
9054 **************************************************/
9055 NLM_EXTERN Boolean LIBCALL
CloneSeqSetAsnWrite(CloneSeqSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)9056 CloneSeqSetAsnWrite(CloneSeqSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
9057 {
9058    AsnTypePtr atp;
9059    Boolean retval = FALSE;
9060 
9061    if (! loaded)
9062    {
9063       if (! SeqFeatAsnLoad()) {
9064          return FALSE;
9065       }
9066    }
9067 
9068    if (aip == NULL) {
9069       return FALSE;
9070    }
9071 
9072    atp = AsnLinkType(orig, CLONE_SEQ_SET);   /* link local tree */
9073    if (atp == NULL) {
9074       return FALSE;
9075    }
9076 
9077    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
9078    retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) CloneSeqAsnWrite, aip, atp, CLONE_SEQ_SET_E);
9079    retval = TRUE;
9080 
9081 erret:
9082    AsnUnlinkType(orig);       /* unlink local tree */
9083    return retval;
9084 }
9085 
9086 
9087 
9088 /**************************************************
9089 *
9090 *    CloneSeqNew()
9091 *
9092 **************************************************/
9093 NLM_EXTERN
9094 CloneSeqPtr LIBCALL
CloneSeqNew(void)9095 CloneSeqNew(void)
9096 {
9097    CloneSeqPtr ptr = MemNew((size_t) sizeof(CloneSeq));
9098 
9099    return ptr;
9100 
9101 }
9102 
9103 
9104 /**************************************************
9105 *
9106 *    CloneSeqFree()
9107 *
9108 **************************************************/
9109 NLM_EXTERN
9110 CloneSeqPtr LIBCALL
CloneSeqFree(CloneSeqPtr ptr)9111 CloneSeqFree(CloneSeqPtr ptr)
9112 {
9113 
9114    if(ptr == NULL) {
9115       return NULL;
9116    }
9117    SeqLocFree(ptr -> location);
9118    SeqLocFree(ptr -> seq);
9119    DbtagFree(ptr -> align_id);
9120    return MemFree(ptr);
9121 }
9122 
9123 
9124 /**************************************************
9125 *
9126 *    CloneSeqAsnRead()
9127 *
9128 **************************************************/
9129 NLM_EXTERN
9130 CloneSeqPtr LIBCALL
CloneSeqAsnRead(AsnIoPtr aip,AsnTypePtr orig)9131 CloneSeqAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9132 {
9133    DataVal av;
9134    AsnTypePtr atp;
9135    AsnReadFunc func;
9136    CloneSeqPtr ptr;
9137 
9138    if (! loaded)
9139    {
9140       if (! SeqFeatAsnLoad()) {
9141          return NULL;
9142       }
9143    }
9144 
9145    if (aip == NULL) {
9146       return NULL;
9147    }
9148 
9149    if (orig == NULL) {         /* CloneSeq ::= (self contained) */
9150       atp = AsnReadId(aip, amp, CLONE_SEQ);
9151    } else {
9152       atp = AsnLinkType(orig, CLONE_SEQ);
9153    }
9154    /* link in local tree */
9155    if (atp == NULL) {
9156       return NULL;
9157    }
9158 
9159    ptr = CloneSeqNew();
9160    if (ptr == NULL) {
9161       goto erret;
9162    }
9163    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
9164       goto erret;
9165    }
9166 
9167    atp = AsnReadId(aip,amp, atp);
9168    func = NULL;
9169 
9170    if (atp == CLONE_SEQ_type) {
9171       if ( AsnReadVal(aip, atp, &av) <= 0) {
9172          goto erret;
9173       }
9174       ptr -> type = av.intvalue;
9175       atp = AsnReadId(aip,amp, atp);
9176    }
9177    if (atp == CLONE_SEQ_confidence) {
9178       if ( AsnReadVal(aip, atp, &av) <= 0) {
9179          goto erret;
9180       }
9181       ptr -> confidence = av.intvalue;
9182       ptr -> OBbits__ |= 1<<0;
9183       atp = AsnReadId(aip,amp, atp);
9184    }
9185    if (atp == CLONE_SEQ_location) {
9186       ptr -> location = SeqLocAsnRead(aip, atp);
9187       if (aip -> io_failure) {
9188          goto erret;
9189       }
9190       atp = AsnReadId(aip,amp, atp);
9191    }
9192    if (atp == CLONE_SEQ_seq) {
9193       ptr -> seq = SeqLocAsnRead(aip, atp);
9194       if (aip -> io_failure) {
9195          goto erret;
9196       }
9197       atp = AsnReadId(aip,amp, atp);
9198    }
9199    if (atp == CLONE_SEQ_align_id) {
9200       ptr -> align_id = DbtagAsnRead(aip, atp);
9201       if (aip -> io_failure) {
9202          goto erret;
9203       }
9204       atp = AsnReadId(aip,amp, atp);
9205    }
9206    if (atp == CLONE_SEQ_support) {
9207       if ( AsnReadVal(aip, atp, &av) <= 0) {
9208          goto erret;
9209       }
9210       ptr -> support = av.intvalue;
9211       ptr -> OBbits__ |= 1<<1;
9212       atp = AsnReadId(aip,amp, atp);
9213    }
9214 
9215    if (AsnReadVal(aip, atp, &av) <= 0) {
9216       goto erret;
9217    }
9218    /* end struct */
9219 
9220 ret:
9221    AsnUnlinkType(orig);       /* unlink local tree */
9222    return ptr;
9223 
9224 erret:
9225    aip -> io_failure = TRUE;
9226    ptr = CloneSeqFree(ptr);
9227    goto ret;
9228 }
9229 
9230 
9231 
9232 /**************************************************
9233 *
9234 *    CloneSeqAsnWrite()
9235 *
9236 **************************************************/
9237 NLM_EXTERN Boolean LIBCALL
CloneSeqAsnWrite(CloneSeqPtr ptr,AsnIoPtr aip,AsnTypePtr orig)9238 CloneSeqAsnWrite(CloneSeqPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
9239 {
9240    DataVal av;
9241    AsnTypePtr atp;
9242    Boolean retval = FALSE;
9243 
9244    if (! loaded)
9245    {
9246       if (! SeqFeatAsnLoad()) {
9247          return FALSE;
9248       }
9249    }
9250 
9251    if (aip == NULL) {
9252       return FALSE;
9253    }
9254 
9255    atp = AsnLinkType(orig, CLONE_SEQ);   /* link local tree */
9256    if (atp == NULL) {
9257       return FALSE;
9258    }
9259 
9260    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
9261 
9262     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
9263 
9264    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
9265       goto erret;
9266    }
9267 
9268    av.intvalue = ptr -> type;
9269    retval = AsnWrite(aip, CLONE_SEQ_type,  &av);
9270    if (ptr -> confidence || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> confidence;
9271       retval = AsnWrite(aip, CLONE_SEQ_confidence,  &av);
9272    }
9273    if (ptr -> location != NULL) {
9274       if ( ! SeqLocAsnWrite(ptr -> location, aip, CLONE_SEQ_location)) {
9275          goto erret;
9276       }
9277    }
9278    if (ptr -> seq != NULL) {
9279       if ( ! SeqLocAsnWrite(ptr -> seq, aip, CLONE_SEQ_seq)) {
9280          goto erret;
9281       }
9282    }
9283    if (ptr -> align_id != NULL) {
9284       if ( ! DbtagAsnWrite(ptr -> align_id, aip, CLONE_SEQ_align_id)) {
9285          goto erret;
9286       }
9287    }
9288    if (ptr -> support || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> support;
9289       retval = AsnWrite(aip, CLONE_SEQ_support,  &av);
9290    }
9291    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
9292       goto erret;
9293    }
9294    retval = TRUE;
9295 
9296 erret:
9297    AsnUnlinkType(orig);       /* unlink local tree */
9298    return retval;
9299 }
9300 
9301 
9302 /**************************************************
9303 *
9304 *    SomaticOriginNew()
9305 *
9306 **************************************************/
9307 NLM_EXTERN
9308 SomaticOriginPtr LIBCALL
SomaticOriginNew(void)9309 SomaticOriginNew(void)
9310 {
9311    SomaticOriginPtr ptr = MemNew((size_t) sizeof(SomaticOrigin));
9312 
9313    return ptr;
9314 
9315 }
9316 
9317 
9318 /**************************************************
9319 *
9320 *    SomaticOriginConditionNew()
9321 *
9322 **************************************************/
9323 NLM_EXTERN
9324 SomaticOriginConditionPtr LIBCALL
SomaticOriginConditionNew(void)9325 SomaticOriginConditionNew(void)
9326 {
9327    SomaticOriginConditionPtr ptr = MemNew((size_t) sizeof(SomaticOriginCondition));
9328 
9329    return ptr;
9330 
9331 }
9332 
9333 
9334 /**************************************************
9335 *
9336 *    VariationRefNew()
9337 *
9338 **************************************************/
9339 NLM_EXTERN
9340 VariationRefPtr LIBCALL
VariationRefNew(void)9341 VariationRefNew(void)
9342 {
9343    VariationRefPtr ptr = MemNew((size_t) sizeof(VariationRef));
9344 
9345    return ptr;
9346 
9347 }
9348 
9349 
9350 /**************************************************
9351 *
9352 *    Consequence_loss_of_heterozygosityNew()
9353 *
9354 **************************************************/
9355 NLM_EXTERN
9356 Consequence_loss_of_heterozygosityPtr LIBCALL
Consequence_loss_of_heterozygosityNew(void)9357 Consequence_loss_of_heterozygosityNew(void)
9358 {
9359    Consequence_loss_of_heterozygosityPtr ptr = MemNew((size_t) sizeof(Consequence_loss_of_heterozygosity));
9360 
9361    return ptr;
9362 
9363 }
9364 
9365 
9366 /**************************************************
9367 *
9368 *    SomaticOriginFree()
9369 *
9370 **************************************************/
9371 NLM_EXTERN
9372 SomaticOriginPtr LIBCALL
SomaticOriginFree(SomaticOriginPtr ptr)9373 SomaticOriginFree(SomaticOriginPtr ptr)
9374 {
9375 
9376    if(ptr == NULL) {
9377       return NULL;
9378    }
9379    SubSourceFree(ptr -> source);
9380    SomaticOriginConditionFree(ptr -> condition);
9381    return MemFree(ptr);
9382 }
9383 
9384 
9385 /**************************************************
9386 *
9387 *    SomaticOriginConditionFree()
9388 *
9389 **************************************************/
9390 NLM_EXTERN
9391 SomaticOriginConditionPtr LIBCALL
SomaticOriginConditionFree(SomaticOriginConditionPtr ptr)9392 SomaticOriginConditionFree(SomaticOriginConditionPtr ptr)
9393 {
9394 
9395    if(ptr == NULL) {
9396       return NULL;
9397    }
9398    MemFree(ptr -> description);
9399    AsnGenericValNodeSetFree(ptr -> object_id, (AsnOptFreeFunc) DbtagFree);
9400    return MemFree(ptr);
9401 }
9402 
9403 
9404 /**************************************************
9405 *
9406 *    VariationRefFree()
9407 *
9408 **************************************************/
9409 NLM_EXTERN
9410 VariationRefPtr LIBCALL
VariationRefFree(VariationRefPtr ptr)9411 VariationRefFree(VariationRefPtr ptr)
9412 {
9413    if(ptr == NULL) {
9414       return NULL;
9415    }
9416    DbtagFree(ptr -> id);
9417    DbtagFree(ptr -> parent_id);
9418    ObjectIdFree(ptr -> sample_id);
9419    AsnGenericValNodeSetFree(ptr -> other_ids, (AsnOptFreeFunc) DbtagFree);
9420    /*
9421    AsnGenericUserSeqOfFree(ptr -> other_ids, (AsnOptFreeFunc) DbtagFree);
9422    */
9423    MemFree(ptr -> name);
9424    /*
9425    AsnGenericValNodeSetFree(ptr -> synonyms, (AsnOptFreeFunc) MemFree);
9426    */
9427    AsnGenericBaseSeqOfFree(ptr -> synonyms ,ASNCODE_PTRVAL_SLOT);
9428    MemFree(ptr -> description);
9429    AsnGenericValNodeSetFree(ptr -> phenotype, (AsnOptFreeFunc) PhenotypeFree);
9430    /*
9431    AsnGenericUserSeqOfFree(ptr -> phenotype, (AsnOptFreeFunc) PhenotypeFree);
9432    */
9433    AsnGenericBaseSeqOfFree(ptr -> method ,ASNCODE_INTVAL_SLOT);
9434    AsnGenericValNodeSetFree(ptr -> population_data, (AsnOptFreeFunc) PopulationDataFree);
9435    /*
9436    AsnGenericUserSeqOfFree(ptr -> population_data, (AsnOptFreeFunc) PopulationDataFree);
9437    */
9438    VariantPropertiesFree(ptr -> variant_prop);
9439    AsnGenericValNodeSetFree(ptr -> clinical_test, (AsnOptFreeFunc) DbtagFree);
9440    /*
9441    AsnGenericUserSeqOfFree(ptr -> clinical_test, (AsnOptFreeFunc) DbtagFree);
9442    */
9443    PubFree(ptr -> pub);
9444    VarRefDataFree(ptr -> data);
9445    ConsequenceFree(ptr -> consequence);
9446    SeqLocFree(ptr -> location);
9447    AsnGenericValNodeSetFree(ptr -> ext_locs, (AsnOptFreeFunc) ExtLocFree);
9448    /*
9449    AsnGenericUserSeqOfFree(ptr -> ext_locs, (AsnOptFreeFunc) ExtLocFree);
9450    */
9451    UserObjectFree(ptr -> ext);
9452    AsnGenericValNodeSetFree(ptr -> somatic_origin, (AsnOptFreeFunc) SomaticOriginFree);
9453    return MemFree(ptr);
9454 }
9455 
9456 
9457 /**************************************************
9458 *
9459 *    ConsequenceFree()
9460 *
9461 **************************************************/
9462 NLM_EXTERN
9463 ConsequencePtr LIBCALL
ConsequenceFree(ValNodePtr anp)9464 ConsequenceFree(ValNodePtr anp)
9465 {
9466 
9467    if (anp == NULL) {
9468       return NULL;
9469    }
9470 
9471    AsnGenericChoiceSeqOfFree(anp, (AsnOptFreeFunc) Consequence_elementFree);
9472    return NULL;
9473 }
9474 
9475 
9476 /**************************************************
9477 *
9478 *    SomaticOriginAsnRead()
9479 *
9480 **************************************************/
9481 NLM_EXTERN
9482 SomaticOriginPtr LIBCALL
SomaticOriginAsnRead(AsnIoPtr aip,AsnTypePtr orig)9483 SomaticOriginAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9484 {
9485    DataVal av;
9486    AsnTypePtr atp;
9487    AsnReadFunc func;
9488    SomaticOriginPtr ptr;
9489 
9490    if (! loaded)
9491    {
9492       if (! SeqFeatAsnLoad()) {
9493          return NULL;
9494       }
9495    }
9496 
9497    if (aip == NULL) {
9498       return NULL;
9499    }
9500 
9501    if (orig == NULL) {         /* SomaticOrigin ::= (self contained) */
9502       atp = AsnReadId(aip, amp, VARIATION_REF_somatic_origin);
9503    } else {
9504       atp = AsnLinkType(orig, VARIATION_REF_somatic_origin);
9505    }
9506    /* link in local tree */
9507    if (atp == NULL) {
9508       return NULL;
9509    }
9510 
9511    ptr = SomaticOriginNew();
9512    if (ptr == NULL) {
9513       goto erret;
9514    }
9515    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
9516       goto erret;
9517    }
9518 
9519    atp = AsnReadId(aip,amp, atp);
9520    func = NULL;
9521 
9522    if (atp == VARIATION_REF_somatic_origin_E_source) {
9523       ptr -> source = SubSourceAsnRead(aip, atp);
9524       if (aip -> io_failure) {
9525          goto erret;
9526       }
9527       atp = AsnReadId(aip,amp, atp);
9528    }
9529    if (atp == VARIATION_REF_somatic_origin_E_condition) {
9530       ptr -> condition = SomaticOriginConditionAsnRead(aip, atp);
9531       if (aip -> io_failure) {
9532          goto erret;
9533       }
9534       atp = AsnReadId(aip,amp, atp);
9535    }
9536 
9537    if (AsnReadVal(aip, atp, &av) <= 0) {
9538       goto erret;
9539    }
9540    /* end struct */
9541 
9542 ret:
9543    AsnUnlinkType(orig);       /* unlink local tree */
9544    return ptr;
9545 
9546 erret:
9547    aip -> io_failure = TRUE;
9548    ptr = SomaticOriginFree(ptr);
9549    goto ret;
9550 }
9551 
9552 
9553 
9554 /**************************************************
9555 *
9556 *    SomaticOriginConditionAsnRead()
9557 *
9558 **************************************************/
9559 NLM_EXTERN
9560 SomaticOriginConditionPtr LIBCALL
SomaticOriginConditionAsnRead(AsnIoPtr aip,AsnTypePtr orig)9561 SomaticOriginConditionAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9562 {
9563    DataVal av;
9564    AsnTypePtr atp;
9565    Boolean isError = FALSE;
9566    AsnReadFunc func;
9567    SomaticOriginConditionPtr ptr;
9568 
9569    if (! loaded)
9570    {
9571       if (! SeqFeatAsnLoad()) {
9572          return NULL;
9573       }
9574    }
9575 
9576    if (aip == NULL) {
9577       return NULL;
9578    }
9579 
9580    if (orig == NULL) {         /* SomaticOriginCondition ::= (self contained) */
9581       atp = AsnReadId(aip, amp, VARIATION_REF_somatic_origin_E_condition);
9582    } else {
9583       atp = AsnLinkType(orig, VARIATION_REF_somatic_origin_E_condition);
9584    }
9585    /* link in local tree */
9586    if (atp == NULL) {
9587       return NULL;
9588    }
9589 
9590    ptr = SomaticOriginConditionNew();
9591    if (ptr == NULL) {
9592       goto erret;
9593    }
9594    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
9595       goto erret;
9596    }
9597 
9598    atp = AsnReadId(aip,amp, atp);
9599    func = NULL;
9600 
9601    if (atp == VARIATION_REF_somatic_origin_E_condition_description) {
9602       if ( AsnReadVal(aip, atp, &av) <= 0) {
9603          goto erret;
9604       }
9605       ptr -> description = av.ptrvalue;
9606       atp = AsnReadId(aip,amp, atp);
9607    }
9608    if (atp == VARIATION_REF_somatic_origin_E_condition_object_id) {
9609       ptr -> object_id = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
9610       if (isError && ptr -> object_id == NULL) {
9611          goto erret;
9612       }
9613       atp = AsnReadId(aip,amp, atp);
9614    }
9615 
9616    if (AsnReadVal(aip, atp, &av) <= 0) {
9617       goto erret;
9618    }
9619    /* end struct */
9620 
9621 ret:
9622    AsnUnlinkType(orig);       /* unlink local tree */
9623    return ptr;
9624 
9625 erret:
9626    aip -> io_failure = TRUE;
9627    ptr = SomaticOriginConditionFree(ptr);
9628    goto ret;
9629 }
9630 
9631 
9632 
9633 /**************************************************
9634 *
9635 *    VariationRefAsnRead()
9636 *
9637 **************************************************/
9638 NLM_EXTERN
9639 VariationRefPtr LIBCALL
VariationRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)9640 VariationRefAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9641 {
9642    DataVal av;
9643    AsnTypePtr atp;
9644    Boolean isError = FALSE;
9645    AsnReadFunc func;
9646    VariationRefPtr ptr;
9647 
9648    if (! loaded)
9649    {
9650       if (! SeqFeatAsnLoad()) {
9651          return NULL;
9652       }
9653    }
9654 
9655    if (aip == NULL) {
9656       return NULL;
9657    }
9658 
9659    if (orig == NULL) {         /* VariationRef ::= (self contained) */
9660       atp = AsnReadId(aip, amp, VARIATION_REF);
9661    } else {
9662       atp = AsnLinkType(orig, VARIATION_REF);
9663    }
9664    /* link in local tree */
9665    if (atp == NULL) {
9666       return NULL;
9667    }
9668 
9669    ptr = VariationRefNew();
9670    if (ptr == NULL) {
9671       goto erret;
9672    }
9673    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
9674       goto erret;
9675    }
9676 
9677    atp = AsnReadId(aip,amp, atp);
9678    func = NULL;
9679 
9680    if (atp == VARIATION_REF_id) {
9681       ptr -> id = DbtagAsnRead(aip, atp);
9682       if (aip -> io_failure) {
9683          goto erret;
9684       }
9685       atp = AsnReadId(aip,amp, atp);
9686    }
9687    if (atp == VARIATION_REF_parent_id) {
9688       ptr -> parent_id = DbtagAsnRead(aip, atp);
9689       if (aip -> io_failure) {
9690          goto erret;
9691       }
9692       atp = AsnReadId(aip,amp, atp);
9693    }
9694    if (atp == VARIATION_REF_sample_id) {
9695       ptr -> sample_id = ObjectIdAsnRead(aip, atp);
9696       if (aip -> io_failure) {
9697          goto erret;
9698       }
9699       atp = AsnReadId(aip,amp, atp);
9700    }
9701    if (atp == VARIATION_REF_other_ids) {
9702       ptr -> other_ids = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
9703       /*
9704       ptr -> other_ids = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
9705       */
9706       if (isError && ptr -> other_ids == NULL) {
9707          goto erret;
9708       }
9709       atp = AsnReadId(aip,amp, atp);
9710    }
9711    if (atp == VARIATION_REF_name) {
9712       if ( AsnReadVal(aip, atp, &av) <= 0) {
9713          goto erret;
9714       }
9715       ptr -> name = av.ptrvalue;
9716       atp = AsnReadId(aip,amp, atp);
9717    }
9718    if (atp == VARIATION_REF_synonyms) {
9719       /*
9720       ptr -> synonyms = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) NULL, (AsnOptFreeFunc) MemFree);
9721       */
9722       ptr -> synonyms = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
9723       if (isError && ptr -> synonyms == NULL) {
9724          goto erret;
9725       }
9726       atp = AsnReadId(aip,amp, atp);
9727    }
9728    if (atp == VARIATION_REF_description) {
9729       if ( AsnReadVal(aip, atp, &av) <= 0) {
9730          goto erret;
9731       }
9732       ptr -> description = av.ptrvalue;
9733       atp = AsnReadId(aip,amp, atp);
9734    }
9735    if (atp == VARIATION_REF_phenotype) {
9736       ptr -> phenotype = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) PhenotypeAsnRead, (AsnOptFreeFunc) PhenotypeFree);
9737       /*
9738       ptr -> phenotype = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) PhenotypeAsnRead, (AsnOptFreeFunc) PhenotypeFree);
9739       */
9740       if (isError && ptr -> phenotype == NULL) {
9741          goto erret;
9742       }
9743       atp = AsnReadId(aip,amp, atp);
9744    }
9745    if (atp == VARIATION_REF_method) {
9746       ptr -> method = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
9747       if (isError && ptr -> method == NULL) {
9748          goto erret;
9749       }
9750       atp = AsnReadId(aip,amp, atp);
9751    }
9752    if (atp == VARIATION_REF_population_data) {
9753       ptr -> population_data = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) PopulationDataAsnRead, (AsnOptFreeFunc) PopulationDataFree);
9754       /*
9755       ptr -> population_data = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) PopulationDataAsnRead, (AsnOptFreeFunc) PopulationDataFree);
9756       */
9757       if (isError && ptr -> population_data == NULL) {
9758          goto erret;
9759       }
9760       atp = AsnReadId(aip,amp, atp);
9761    }
9762    if (atp == VARIATION_REF_variant_prop) {
9763       ptr -> variant_prop = VariantPropertiesAsnRead(aip, atp);
9764       if (aip -> io_failure) {
9765          goto erret;
9766       }
9767       atp = AsnReadId(aip,amp, atp);
9768    }
9769    if (atp == VARIATION_REF_validated) {
9770       if ( AsnReadVal(aip, atp, &av) <= 0) {
9771          goto erret;
9772       }
9773       ptr -> validated = av.boolvalue;
9774       ptr -> OBbits__ |= 1<<0;
9775       atp = AsnReadId(aip,amp, atp);
9776    }
9777    if (atp == VARIATION_REF_clinical_test) {
9778       ptr -> clinical_test = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
9779       /*
9780       ptr -> clinical_test = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
9781       */
9782       if (isError && ptr -> clinical_test == NULL) {
9783          goto erret;
9784       }
9785       atp = AsnReadId(aip,amp, atp);
9786    }
9787    if (atp == VARIATION_REF_allele_origin) {
9788       if ( AsnReadVal(aip, atp, &av) <= 0) {
9789          goto erret;
9790       }
9791       ptr -> allele_origin = av.intvalue;
9792       ptr -> OBbits__ |= 1<<1;
9793       atp = AsnReadId(aip,amp, atp);
9794    }
9795    if (atp == VARIATION_REF_allele_state) {
9796       if ( AsnReadVal(aip, atp, &av) <= 0) {
9797          goto erret;
9798       }
9799       ptr -> allele_state = av.intvalue;
9800       ptr -> OBbits__ |= 1<<2;
9801       atp = AsnReadId(aip,amp, atp);
9802    }
9803    if (atp == VARIATION_REF_allele_frequency) {
9804       if ( AsnReadVal(aip, atp, &av) <= 0) {
9805          goto erret;
9806       }
9807       ptr -> allele_frequency = av.realvalue;
9808       ptr -> OBbits__ |= 1<<3;
9809       atp = AsnReadId(aip,amp, atp);
9810    }
9811    if (atp == VARIATION_REF_is_ancestral_allele) {
9812       if ( AsnReadVal(aip, atp, &av) <= 0) {
9813          goto erret;
9814       }
9815       ptr -> is_ancestral_allele = av.boolvalue;
9816       ptr -> OBbits__ |= 1<<4;
9817       atp = AsnReadId(aip,amp, atp);
9818    }
9819    if (atp == VARIATION_REF_pub) {
9820       ptr -> pub = PubAsnRead(aip, atp);
9821       if (aip -> io_failure) {
9822          goto erret;
9823       }
9824       atp = AsnReadId(aip,amp, atp);
9825    }
9826    if (atp == VARIATION_REF_data) {
9827       ptr -> data = VarRefDataAsnRead(aip, atp);
9828       if (aip -> io_failure) {
9829          goto erret;
9830       }
9831       atp = AsnReadId(aip,amp, atp);
9832    }
9833    if (atp == VARIATION_REF_consequence) {
9834       ptr -> consequence =  ConsequenceAsnRead(aip, atp);
9835       if (isError && ptr -> consequence == NULL) {
9836          goto erret;
9837       }
9838       atp = AsnReadId(aip,amp, atp);
9839    }
9840    if (atp == VARIATION_REF_location) {
9841       ptr -> location = SeqLocAsnRead(aip, atp);
9842       if (aip -> io_failure) {
9843          goto erret;
9844       }
9845       atp = AsnReadId(aip,amp, atp);
9846    }
9847    if (atp == VARIATION_REF_ext_locs) {
9848       ptr -> ext_locs = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) ExtLocAsnRead, (AsnOptFreeFunc) ExtLocFree);
9849       /*
9850       ptr -> ext_locs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ExtLocAsnRead, (AsnOptFreeFunc) ExtLocFree);
9851       */
9852       if (isError && ptr -> ext_locs == NULL) {
9853          goto erret;
9854       }
9855       atp = AsnReadId(aip,amp, atp);
9856    }
9857    if (atp == VARIATION_REF_ext) {
9858       ptr -> ext = UserObjectAsnRead(aip, atp);
9859       if (aip -> io_failure) {
9860          goto erret;
9861       }
9862       atp = AsnReadId(aip,amp, atp);
9863    }
9864    if (atp == VARIATION_REF_somatic_origin) {
9865       ptr -> somatic_origin = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) SomaticOriginAsnRead, (AsnOptFreeFunc) SomaticOriginFree);
9866       if (isError && ptr -> somatic_origin == NULL) {
9867          goto erret;
9868       }
9869       atp = AsnReadId(aip,amp, atp);
9870    }
9871 
9872    if (AsnReadVal(aip, atp, &av) <= 0) {
9873       goto erret;
9874    }
9875    /* end struct */
9876 
9877 ret:
9878    AsnUnlinkType(orig);       /* unlink local tree */
9879    return ptr;
9880 
9881 erret:
9882    aip -> io_failure = TRUE;
9883    ptr = VariationRefFree(ptr);
9884    goto ret;
9885 }
9886 
9887 
9888 
9889 /**************************************************
9890 *
9891 *    ConsequenceAsnRead()
9892 *
9893 **************************************************/
9894 NLM_EXTERN
9895 ConsequencePtr LIBCALL
ConsequenceAsnRead(AsnIoPtr aip,AsnTypePtr orig)9896 ConsequenceAsnRead(AsnIoPtr aip, AsnTypePtr orig)
9897 {
9898 
9899 
9900    AsnTypePtr atp;
9901    ValNodePtr anp;
9902    Boolean isError = FALSE;
9903 
9904    if (! loaded)
9905    {
9906       if (! SeqFeatAsnLoad()) {
9907          return NULL;
9908       }
9909    }
9910 
9911    if (aip == NULL) {
9912       return NULL;
9913    }
9914 
9915    if (orig == NULL) {         /* Consequence_element ::= (self contained) */
9916       atp = AsnReadId(aip, amp, VARIATION_REF_consequence);
9917    } else {
9918       atp = AsnLinkType(orig, VARIATION_REF_consequence);    /* link in local tree */
9919    }
9920    if (atp == NULL) {
9921       return NULL;
9922    }
9923 
9924    anp =
9925    AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError,
9926    (AsnReadFunc) Consequence_elementAsnRead, (AsnOptFreeFunc) Consequence_elementFree);
9927    if (isError)
9928    goto erret;
9929 
9930 
9931 ret:
9932    AsnUnlinkType(orig);       /* unlink local tree */
9933    return anp;
9934 
9935 erret:
9936    aip -> io_failure = TRUE;
9937    goto ret;
9938 }
9939 
9940 
9941 /**************************************************
9942 *
9943 *    SomaticOriginAsnWrite()
9944 *
9945 **************************************************/
9946 NLM_EXTERN Boolean LIBCALL
SomaticOriginAsnWrite(SomaticOriginPtr ptr,AsnIoPtr aip,AsnTypePtr orig)9947 SomaticOriginAsnWrite(SomaticOriginPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
9948 {
9949    AsnTypePtr atp;
9950    Boolean retval = FALSE;
9951 
9952    if (! loaded)
9953    {
9954       if (! SeqFeatAsnLoad()) {
9955          return FALSE;
9956       }
9957    }
9958 
9959    if (aip == NULL) {
9960       return FALSE;
9961    }
9962 
9963    atp = AsnLinkType(orig, VARIATION_REF_somatic_origin);   /* link local tree */
9964    if (atp == NULL) {
9965       return FALSE;
9966    }
9967 
9968    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
9969    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
9970       goto erret;
9971    }
9972 
9973    if (ptr -> source != NULL) {
9974       if ( ! SubSourceAsnWrite(ptr -> source, aip, VARIATION_REF_somatic_origin_E_source)) {
9975          goto erret;
9976       }
9977    }
9978    if (ptr -> condition != NULL) {
9979       if ( ! SomaticOriginConditionAsnWrite(ptr -> condition, aip, VARIATION_REF_somatic_origin_E_condition)) {
9980          goto erret;
9981       }
9982    }
9983    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
9984       goto erret;
9985    }
9986    retval = TRUE;
9987 
9988 erret:
9989    AsnUnlinkType(orig);       /* unlink local tree */
9990    return retval;
9991 }
9992 
9993 
9994 
9995 /**************************************************
9996 *
9997 *    SomaticOriginConditionAsnWrite()
9998 *
9999 **************************************************/
10000 NLM_EXTERN Boolean LIBCALL
SomaticOriginConditionAsnWrite(SomaticOriginConditionPtr ptr,AsnIoPtr aip,AsnTypePtr orig)10001 SomaticOriginConditionAsnWrite(SomaticOriginConditionPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
10002 {
10003    DataVal av;
10004    AsnTypePtr atp;
10005    Boolean retval = FALSE;
10006 
10007    if (! loaded)
10008    {
10009       if (! SeqFeatAsnLoad()) {
10010          return FALSE;
10011       }
10012    }
10013 
10014    if (aip == NULL) {
10015       return FALSE;
10016    }
10017 
10018    atp = AsnLinkType(orig, VARIATION_REF_somatic_origin_E_condition);   /* link local tree */
10019    if (atp == NULL) {
10020       return FALSE;
10021    }
10022 
10023    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10024 
10025     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10026 
10027    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
10028       goto erret;
10029    }
10030 
10031    if (ptr -> description != NULL) {
10032       av.ptrvalue = ptr -> description;
10033       retval = AsnWrite(aip, VARIATION_REF_somatic_origin_E_condition_description,  &av);
10034    }
10035    if (ptr -> object_id != NULL) {
10036      AsnGenericValNodeSetAsnWrite(ptr -> object_id, (AsnWriteFunc) DbtagAsnWrite, aip, VARIATION_REF_somatic_origin_E_condition_object_id, VARIATION_REF_somatic_origin_E_condition_object_id_E);
10037    }
10038    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
10039       goto erret;
10040    }
10041    retval = TRUE;
10042 
10043 erret:
10044    AsnUnlinkType(orig);       /* unlink local tree */
10045    return retval;
10046 }
10047 
10048 
10049 
10050 /**************************************************
10051 *
10052 *    VariationRefAsnWrite()
10053 *
10054 **************************************************/
10055 NLM_EXTERN Boolean LIBCALL
VariationRefAsnWrite(VariationRefPtr ptr,AsnIoPtr aip,AsnTypePtr orig)10056 VariationRefAsnWrite(VariationRefPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
10057 {
10058    DataVal av;
10059    AsnTypePtr atp;
10060    Boolean retval = FALSE;
10061 
10062    if (! loaded)
10063    {
10064       if (! SeqFeatAsnLoad()) {
10065          return FALSE;
10066       }
10067    }
10068 
10069    if (aip == NULL) {
10070       return FALSE;
10071    }
10072 
10073    atp = AsnLinkType(orig, VARIATION_REF);   /* link local tree */
10074    if (atp == NULL) {
10075       return FALSE;
10076    }
10077 
10078    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10079 
10080     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10081 
10082    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
10083       goto erret;
10084    }
10085 
10086    if (ptr -> id != NULL) {
10087       if ( ! DbtagAsnWrite(ptr -> id, aip, VARIATION_REF_id)) {
10088          goto erret;
10089       }
10090    }
10091    if (ptr -> parent_id != NULL) {
10092       if ( ! DbtagAsnWrite(ptr -> parent_id, aip, VARIATION_REF_parent_id)) {
10093          goto erret;
10094       }
10095    }
10096    if (ptr -> sample_id != NULL) {
10097       if ( ! ObjectIdAsnWrite(ptr -> sample_id, aip, VARIATION_REF_sample_id)) {
10098          goto erret;
10099       }
10100    }
10101    if (ptr -> other_ids != NULL) {
10102      AsnGenericValNodeSetAsnWrite (ptr -> other_ids, (AsnWriteFunc) DbtagAsnWrite, aip, VARIATION_REF_other_ids, VARIATION_REF_other_ids_E);
10103      /*
10104      AsnGenericUserSeqOfAsnWrite(ptr -> other_ids, (AsnWriteFunc) DbtagAsnWrite, aip, VARIATION_REF_other_ids, VARIATION_REF_other_ids_E);
10105      */
10106    }
10107    if (ptr -> name != NULL) {
10108       av.ptrvalue = ptr -> name;
10109       retval = AsnWrite(aip, VARIATION_REF_name,  &av);
10110    }
10111    if (ptr -> synonyms != NULL) {
10112      retval = AsnGenericBaseSeqOfAsnWrite(ptr -> synonyms ,ASNCODE_PTRVAL_SLOT, aip, VARIATION_REF_synonyms, VARIATION_REF_synonyms_E);
10113    }
10114    if (ptr -> description != NULL) {
10115       av.ptrvalue = ptr -> description;
10116       retval = AsnWrite(aip, VARIATION_REF_description,  &av);
10117    }
10118    if (ptr -> phenotype != NULL) {
10119      AsnGenericValNodeSetAsnWrite (ptr -> phenotype, (AsnWriteFunc) PhenotypeAsnWrite, aip, VARIATION_REF_phenotype, VARIATION_REF_phenotype_E);
10120      /*
10121      AsnGenericUserSeqOfAsnWrite(ptr -> phenotype, (AsnWriteFunc) PhenotypeAsnWrite, aip, VARIATION_REF_phenotype, VARIATION_REF_phenotype_E);
10122      */
10123    }
10124    if (ptr -> method != NULL) {
10125      retval = AsnGenericBaseSeqOfAsnWrite(ptr -> method ,ASNCODE_INTVAL_SLOT, aip, VARIATION_REF_method, VARIATION_REF_method_E);
10126    }
10127    if (ptr -> population_data != NULL) {
10128      AsnGenericValNodeSetAsnWrite (ptr -> population_data, (AsnWriteFunc) PopulationDataAsnWrite, aip, VARIATION_REF_population_data, VARIATION_REF_population_data_E);
10129      /*
10130      AsnGenericUserSeqOfAsnWrite(ptr -> population_data, (AsnWriteFunc) PopulationDataAsnWrite, aip, VARIATION_REF_population_data, VARIATION_REF_population_data_E);
10131      */
10132    }
10133    if (ptr -> variant_prop != NULL) {
10134       if ( ! VariantPropertiesAsnWrite(ptr -> variant_prop, aip, VARIATION_REF_variant_prop)) {
10135          goto erret;
10136       }
10137    }
10138    if (ptr -> validated || (ptr -> OBbits__ & (1<<0) )){   av.boolvalue = ptr -> validated;
10139       retval = AsnWrite(aip, VARIATION_REF_validated,  &av);
10140    }
10141    if (ptr -> clinical_test != NULL) {
10142      AsnGenericValNodeSetAsnWrite (ptr -> clinical_test, (AsnWriteFunc) DbtagAsnWrite, aip, VARIATION_REF_clinical_test, VARIATION_REF_clinical_test_E);
10143      /*
10144      AsnGenericUserSeqOfAsnWrite(ptr -> clinical_test, (AsnWriteFunc) DbtagAsnWrite, aip, VARIATION_REF_clinical_test, VARIATION_REF_clinical_test_E);
10145      */
10146    }
10147    if (ptr -> allele_origin || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> allele_origin;
10148       retval = AsnWrite(aip, VARIATION_REF_allele_origin,  &av);
10149    }
10150    if (ptr -> allele_state || (ptr -> OBbits__ & (1<<2) )){   av.intvalue = ptr -> allele_state;
10151       retval = AsnWrite(aip, VARIATION_REF_allele_state,  &av);
10152    }
10153    if (ptr -> allele_frequency || (ptr -> OBbits__ & (1<<3) )){   av.realvalue = ptr -> allele_frequency;
10154       retval = AsnWrite(aip, VARIATION_REF_allele_frequency,  &av);
10155    }
10156    if (ptr -> is_ancestral_allele || (ptr -> OBbits__ & (1<<4) )){   av.boolvalue = ptr -> is_ancestral_allele;
10157       retval = AsnWrite(aip, VARIATION_REF_is_ancestral_allele,  &av);
10158    }
10159    if (ptr -> pub != NULL) {
10160       if ( ! PubAsnWrite(ptr -> pub, aip, VARIATION_REF_pub)) {
10161          goto erret;
10162       }
10163    }
10164    if (ptr -> data != NULL) {
10165       if ( ! VarRefDataAsnWrite(ptr -> data, aip, VARIATION_REF_data)) {
10166          goto erret;
10167       }
10168    }
10169    if (ptr -> consequence != NULL) {
10170      retval = ConsequenceAsnWrite(ptr -> consequence, aip,VARIATION_REF_consequence);
10171    }
10172    if (ptr -> location != NULL) {
10173       if ( ! SeqLocAsnWrite(ptr -> location, aip, VARIATION_REF_location)) {
10174          goto erret;
10175       }
10176    }
10177    if (ptr -> ext_locs != NULL) {
10178      AsnGenericValNodeSetAsnWrite (ptr -> ext_locs, (AsnWriteFunc) ExtLocAsnWrite, aip, VARIATION_REF_ext_locs, VARIATION_REF_ext_locs_E);
10179      /*
10180      AsnGenericUserSeqOfAsnWrite(ptr -> ext_locs, (AsnWriteFunc) ExtLocAsnWrite, aip, VARIATION_REF_ext_locs, VARIATION_REF_ext_locs_E);
10181      */
10182    }
10183    if (ptr -> ext != NULL) {
10184       if ( ! UserObjectAsnWrite(ptr -> ext, aip, VARIATION_REF_ext)) {
10185          goto erret;
10186       }
10187    }
10188    if (ptr -> somatic_origin != NULL) {
10189      AsnGenericValNodeSetAsnWrite (ptr -> somatic_origin, (AsnWriteFunc) SomaticOriginAsnWrite, aip, VARIATION_REF_somatic_origin, VARIATION_REF_somatic_origin_E);
10190    }
10191    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
10192       goto erret;
10193    }
10194    retval = TRUE;
10195 
10196 erret:
10197    AsnUnlinkType(orig);       /* unlink local tree */
10198    return retval;
10199 }
10200 
10201 
10202 
10203 /**************************************************
10204 *
10205 *    ConsequenceAsnWrite()
10206 *
10207 **************************************************/
10208 NLM_EXTERN Boolean LIBCALL
ConsequenceAsnWrite(ValNodePtr anp,AsnIoPtr aip,AsnTypePtr orig)10209 ConsequenceAsnWrite(ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig)
10210 
10211 {
10212    DataVal av;
10213    AsnTypePtr atp;
10214    Boolean retval = FALSE;
10215 
10216    if (! loaded)
10217    {
10218       if (! SeqFeatAsnLoad())
10219       return FALSE;
10220    }
10221 
10222    if (aip == NULL)
10223    return FALSE;
10224 
10225    atp = AsnLinkType(orig, VARIATION_REF_consequence);   /* link local tree */
10226    if (atp == NULL) {
10227       return FALSE;
10228    }
10229 
10230    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10231 
10232     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10233 
10234    av.ptrvalue = (Pointer)anp;
10235    retval = AsnGenericChoiceSeqOfAsnWrite(anp,
10236    (AsnWriteFunc) Consequence_elementAsnWrite, aip, atp, VARIATION_REF_consequence_E);
10237 erret:
10238    AsnUnlinkType(orig);       /* unlink local tree */
10239    return retval;
10240 }
10241 
10242 
10243 /**************************************************
10244 *
10245 *    Consequence_elementAsnWrite()
10246 *
10247 **************************************************/
10248 NLM_EXTERN Boolean LIBCALL
Consequence_elementAsnWrite(Consequence_elementPtr anp,AsnIoPtr aip,AsnTypePtr orig)10249 Consequence_elementAsnWrite(Consequence_elementPtr anp, AsnIoPtr aip, AsnTypePtr orig)
10250 
10251 {
10252    DataVal av;
10253    AsnTypePtr atp, writetype = NULL;
10254    Pointer pnt;
10255    AsnWriteFunc func = NULL;
10256    Boolean retval = FALSE;
10257 
10258    if (! loaded)
10259    {
10260       if (! SeqFeatAsnLoad())
10261       return FALSE;
10262    }
10263 
10264    if (aip == NULL)
10265    return FALSE;
10266 
10267    atp = AsnLinkType(orig, VARIATION_REF_consequence_E);   /* link local tree */
10268    if (atp == NULL) {
10269       return FALSE;
10270    }
10271 
10272    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10273 
10274     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10275 
10276    av.ptrvalue = (Pointer)anp;
10277    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
10278       goto erret;
10279    }
10280 
10281    pnt = anp->data.ptrvalue;
10282    switch (anp->choice)
10283    {
10284    case Consequence_unknown:
10285       av.boolvalue = anp->data.boolvalue;
10286       retval = AsnWrite(aip, VARIATION_REF_consequence_E_unknown, &av);
10287       break;
10288    case Consequence_splicing:
10289       av.boolvalue = anp->data.boolvalue;
10290       retval = AsnWrite(aip, VARIATION_REF_consequence_E_splicing, &av);
10291       break;
10292    case Consequence_note:
10293       av.ptrvalue = anp->data.ptrvalue;
10294       retval = AsnWrite(aip, VARIATION_REF_consequence_E_note, &av);
10295       break;
10296    case Consequence_variation:
10297       writetype = VARIATION_REF_consequence_E_variation;
10298       func = (AsnWriteFunc) VariationRefAsnWrite;
10299       break;
10300    case Consequence_Consequence_Frameshift:
10301       writetype = VARIATION_REF_consequence_E_frameshift;
10302       func = (AsnWriteFunc) Consequence_frameshiftAsnWrite;
10303       break;
10304    case Consequence_Consequence_LossOfHeterozygosity:
10305       writetype = VARIATION_REF_consequence_E_loss_of_heterozygosity;
10306       func = (AsnWriteFunc) Consequence_loss_of_heterozygosityAsnWrite;
10307       break;
10308    }
10309    if (writetype != NULL) {
10310       retval = (* func)(pnt, aip, writetype);   /* write it out */
10311    }
10312    if (!retval) {
10313       goto erret;
10314    }
10315    retval = TRUE;
10316 
10317 erret:
10318    AsnUnlinkType(orig);       /* unlink local tree */
10319    return retval;
10320 }
10321 
10322 
10323 /**************************************************
10324 *
10325 *    Consequence_loss_of_heterozygosityAsnWrite()
10326 *
10327 **************************************************/
10328 NLM_EXTERN Boolean LIBCALL
Consequence_loss_of_heterozygosityAsnWrite(Consequence_loss_of_heterozygosityPtr ptr,AsnIoPtr aip,AsnTypePtr orig)10329 Consequence_loss_of_heterozygosityAsnWrite(Consequence_loss_of_heterozygosityPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
10330 {
10331    DataVal av;
10332    AsnTypePtr atp;
10333    Boolean retval = FALSE;
10334 
10335    if (! loaded)
10336    {
10337       if (! SeqFeatAsnLoad()) {
10338          return FALSE;
10339       }
10340    }
10341 
10342    if (aip == NULL) {
10343       return FALSE;
10344    }
10345 
10346    atp = AsnLinkType(orig, VARIATION_REF_consequence_E_loss_of_heterozygosity);   /* link local tree */
10347    if (atp == NULL) {
10348       return FALSE;
10349    }
10350 
10351    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10352 
10353     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10354 
10355    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
10356       goto erret;
10357    }
10358 
10359    if (ptr -> reference != NULL) {
10360       av.ptrvalue = ptr -> reference;
10361       retval = AsnWrite(aip, VARIATION_REF_consequence_E_loss_of_heterozygosity_reference,  &av);
10362    }
10363    if (ptr -> test != NULL) {
10364       av.ptrvalue = ptr -> test;
10365       retval = AsnWrite(aip, VARIATION_REF_consequence_E_loss_of_heterozygosity_test,  &av);
10366    }
10367    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
10368       goto erret;
10369    }
10370    retval = TRUE;
10371 
10372 erret:
10373    AsnUnlinkType(orig);       /* unlink local tree */
10374    return retval;
10375 }
10376 
10377 
10378 
10379 /**************************************************
10380 *
10381 *    Consequence_frameshiftAsnWrite()
10382 *
10383 **************************************************/
10384 NLM_EXTERN Boolean LIBCALL
Consequence_frameshiftAsnWrite(Consequence_frameshiftPtr ptr,AsnIoPtr aip,AsnTypePtr orig)10385 Consequence_frameshiftAsnWrite(Consequence_frameshiftPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
10386 {
10387    DataVal av;
10388    AsnTypePtr atp;
10389    Boolean retval = FALSE;
10390 
10391    if (! loaded)
10392    {
10393       if (! SeqFeatAsnLoad()) {
10394          return FALSE;
10395       }
10396    }
10397 
10398    if (aip == NULL) {
10399       return FALSE;
10400    }
10401 
10402    atp = AsnLinkType(orig, VARIATION_REF_consequence_E_frameshift);   /* link local tree */
10403    if (atp == NULL) {
10404       return FALSE;
10405    }
10406 
10407    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10408 
10409     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10410 
10411    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
10412       goto erret;
10413    }
10414 
10415    if (ptr -> phase || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> phase;
10416       retval = AsnWrite(aip, VARIATION_REF_consequence_E_frameshift_phase,  &av);
10417    }
10418    if (ptr -> x_length || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> x_length;
10419       retval = AsnWrite(aip, VARIATION_REF_consequence_E_frameshift_x_length,  &av);
10420    }
10421    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
10422       goto erret;
10423    }
10424    retval = TRUE;
10425 
10426 erret:
10427    AsnUnlinkType(orig);       /* unlink local tree */
10428    return retval;
10429 }
10430 
10431 
10432 
10433 /**************************************************
10434 *
10435 *    Data_setAsnWrite()
10436 *
10437 **************************************************/
10438 NLM_EXTERN Boolean LIBCALL
VarRefDataSetAsnWrite(VarRefDataSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)10439 VarRefDataSetAsnWrite(VarRefDataSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
10440 {
10441    DataVal av;
10442    AsnTypePtr atp;
10443    Boolean retval = FALSE;
10444 
10445    if (! loaded)
10446    {
10447       if (! SeqFeatAsnLoad()) {
10448          return FALSE;
10449       }
10450    }
10451 
10452    if (aip == NULL) {
10453       return FALSE;
10454    }
10455 
10456    atp = AsnLinkType(orig, VARIATION_REF_data_set);   /* link local tree */
10457    if (atp == NULL) {
10458       return FALSE;
10459    }
10460 
10461    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10462 
10463     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10464 
10465    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
10466       goto erret;
10467    }
10468 
10469    av.intvalue = ptr -> type;
10470    retval = AsnWrite(aip, VARIATION_REF_data_set_type,  &av);
10471    AsnGenericValNodeSetAsnWrite(ptr -> variations, (AsnWriteFunc) VariationRefAsnWrite, aip, VARIATION_REF_data_set_variations, VARIATION_REF_data_set_variations_E);
10472    /*
10473    AsnGenericUserSeqOfAsnWrite(ptr -> variations, (AsnWriteFunc) VariationRefAsnWrite, aip, VARIATION_REF_data_set_variations, VARIATION_REF_data_set_variations_E);
10474    */
10475    if (ptr -> name != NULL) {
10476       av.ptrvalue = ptr -> name;
10477       retval = AsnWrite(aip, VARIATION_REF_data_set_name,  &av);
10478    }
10479    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
10480       goto erret;
10481    }
10482    retval = TRUE;
10483 
10484 erret:
10485    AsnUnlinkType(orig);       /* unlink local tree */
10486    return retval;
10487 }
10488 
10489 
10490 /**************************************************
10491 *
10492 *    VarRefDataAsnWrite()
10493 *
10494 **************************************************/
10495 NLM_EXTERN Boolean LIBCALL
VarRefDataAsnWrite(VarRefDataPtr anp,AsnIoPtr aip,AsnTypePtr orig)10496 VarRefDataAsnWrite( VarRefDataPtr anp, AsnIoPtr aip, AsnTypePtr orig)
10497 
10498 {
10499    DataVal av;
10500    AsnTypePtr atp, writetype = NULL;
10501    Pointer pnt;
10502    AsnWriteFunc func = NULL;
10503    Boolean retval = FALSE;
10504 
10505    if (! loaded)
10506    {
10507       if (! SeqFeatAsnLoad())
10508       return FALSE;
10509    }
10510 
10511    if (aip == NULL)
10512    return FALSE;
10513 
10514    atp = AsnLinkType(orig, VARIATION_REF_data);   /* link local tree */
10515    if (atp == NULL) {
10516       return FALSE;
10517    }
10518 
10519    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
10520 
10521     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
10522 
10523    av.ptrvalue = (Pointer)anp;
10524    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
10525       goto erret;
10526    }
10527 
10528    pnt = anp->data.ptrvalue;
10529    switch (anp->choice)
10530    {
10531    case VarRefData_unknown:
10532       av.boolvalue = anp->data.boolvalue;
10533       retval = AsnWrite(aip, VARIATION_REF_data_unknown, &av);
10534       break;
10535    case VarRefData_note:
10536       av.ptrvalue = anp->data.ptrvalue;
10537       retval = AsnWrite(aip, VARIATION_REF_data_note, &av);
10538       break;
10539    case VarRefData_uniparental_disomy:
10540       av.boolvalue = anp->data.boolvalue;
10541       retval = AsnWrite(aip, VARIATION_REF_data_uniparental_disomy, &av);
10542       break;
10543    case VarRefData_instance:
10544       writetype = VARIATION_REF_data_instance;
10545       func = (AsnWriteFunc) VariationInstAsnWrite;
10546       break;
10547    case VarRefData_set:
10548       writetype = VARIATION_REF_data_set;
10549       func = (AsnWriteFunc) VarRefDataSetAsnWrite;
10550       break;
10551    case VarRefData_complex:
10552       av.boolvalue = anp->data.boolvalue;
10553       retval = AsnWrite(aip, VARIATION_REF_data_complex, &av);
10554       break;
10555    }
10556    if (writetype != NULL) {
10557       retval = (* func)(pnt, aip, writetype);   /* write it out */
10558    }
10559    if (!retval) {
10560       goto erret;
10561    }
10562    retval = TRUE;
10563 
10564 erret:
10565    AsnUnlinkType(orig);       /* unlink local tree */
10566    return retval;
10567 }
10568 
10569 
10570 
10571 /**************************************************
10572 *
10573 *    Consequence_elementAsnRead()
10574 *
10575 **************************************************/
10576 NLM_EXTERN
10577 Consequence_elementPtr LIBCALL
Consequence_elementAsnRead(AsnIoPtr aip,AsnTypePtr orig)10578 Consequence_elementAsnRead(AsnIoPtr aip, AsnTypePtr orig)
10579 {
10580    DataVal av;
10581    AsnTypePtr atp;
10582    ValNodePtr anp;
10583    Uint1 choice = 0;
10584    Boolean nullIsError = FALSE;
10585    AsnReadFunc func;
10586 
10587    if (! loaded)
10588    {
10589       if (! SeqFeatAsnLoad()) {
10590          return NULL;
10591       }
10592    }
10593 
10594    if (aip == NULL) {
10595       return NULL;
10596    }
10597 
10598    if (orig == NULL) {         /* Consequence_element ::= (self contained) */
10599       atp = AsnReadId(aip, amp, VARIATION_REF_consequence_E);
10600    } else {
10601       atp = AsnLinkType(orig, VARIATION_REF_consequence_E);    /* link in local tree */
10602    }
10603    if (atp == NULL) {
10604       return NULL;
10605    }
10606 
10607    anp = ValNodeNew(NULL);
10608    if (anp == NULL) {
10609       goto erret;
10610    }
10611    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
10612       goto erret;
10613    }
10614 
10615    func = NULL;
10616 
10617    atp = AsnReadId(aip, amp, atp);  /* find the choice */
10618    if (atp == NULL) {
10619       goto erret;
10620    }
10621    if (atp == VARIATION_REF_consequence_E_unknown) {
10622       choice = Consequence_unknown;
10623       if (AsnReadVal(aip, atp, &av) <= 0) {
10624          goto erret;
10625       }
10626       anp->data.boolvalue = av.boolvalue;
10627    }
10628    else if (atp == VARIATION_REF_consequence_E_splicing) {
10629       choice = Consequence_splicing;
10630       if (AsnReadVal(aip, atp, &av) <= 0) {
10631          goto erret;
10632       }
10633       anp->data.boolvalue = av.boolvalue;
10634    }
10635    else if (atp == VARIATION_REF_consequence_E_note) {
10636       choice = Consequence_note;
10637       if (AsnReadVal(aip, atp, &av) <= 0) {
10638          goto erret;
10639       }
10640       anp->data.ptrvalue = av.ptrvalue;
10641    }
10642    else if (atp == VARIATION_REF_consequence_E_variation) {
10643       choice = Consequence_variation;
10644       func = (AsnReadFunc) VariationRefAsnRead;
10645    }
10646    else if (atp == VARIATION_REF_consequence_E_frameshift) {
10647       choice = Consequence_Consequence_Frameshift;
10648       func = (AsnReadFunc) Consequence_frameshiftAsnRead;
10649    }
10650    else if (atp == VARIATION_REF_consequence_E_loss_of_heterozygosity) {
10651       choice = Consequence_Consequence_LossOfHeterozygosity;
10652       func = (AsnReadFunc) Consequence_loss_of_heterozygosityAsnRead;
10653    }
10654    anp->choice = choice;
10655    if (func != NULL)
10656    {
10657       anp->data.ptrvalue = (* func)(aip, atp);
10658       if (aip -> io_failure) goto erret;
10659 
10660       if (nullIsError && anp->data.ptrvalue == NULL) {
10661          goto erret;
10662       }
10663    }
10664 
10665 ret:
10666    AsnUnlinkType(orig);       /* unlink local tree */
10667    return anp;
10668 
10669 erret:
10670    anp = MemFree(anp);
10671    aip -> io_failure = TRUE;
10672    goto ret;
10673 }
10674 
10675 
10676 /**************************************************
10677 *
10678 *    Consequence_loss_of_heterozygosityAsnRead()
10679 *
10680 **************************************************/
10681 NLM_EXTERN
10682 Consequence_loss_of_heterozygosityPtr LIBCALL
Consequence_loss_of_heterozygosityAsnRead(AsnIoPtr aip,AsnTypePtr orig)10683 Consequence_loss_of_heterozygosityAsnRead(AsnIoPtr aip, AsnTypePtr orig)
10684 {
10685    DataVal av;
10686    AsnTypePtr atp;
10687    AsnReadFunc func;
10688    Consequence_loss_of_heterozygosityPtr ptr;
10689 
10690    if (! loaded)
10691    {
10692       if (! SeqFeatAsnLoad()) {
10693          return NULL;
10694       }
10695    }
10696 
10697    if (aip == NULL) {
10698       return NULL;
10699    }
10700 
10701    if (orig == NULL) {         /* Consequence_loss_of_heterozygosity ::= (self contained) */
10702       atp = AsnReadId(aip, amp, VARIATION_REF_consequence_E_loss_of_heterozygosity);
10703    } else {
10704       atp = AsnLinkType(orig, VARIATION_REF_consequence_E_loss_of_heterozygosity);
10705    }
10706    /* link in local tree */
10707    if (atp == NULL) {
10708       return NULL;
10709    }
10710 
10711    ptr = Consequence_loss_of_heterozygosityNew();
10712    if (ptr == NULL) {
10713       goto erret;
10714    }
10715    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
10716       goto erret;
10717    }
10718 
10719    atp = AsnReadId(aip,amp, atp);
10720    func = NULL;
10721 
10722    if (atp == VARIATION_REF_consequence_E_loss_of_heterozygosity_reference) {
10723       if ( AsnReadVal(aip, atp, &av) <= 0) {
10724          goto erret;
10725       }
10726       ptr -> reference = av.ptrvalue;
10727       atp = AsnReadId(aip,amp, atp);
10728    }
10729    if (atp == VARIATION_REF_consequence_E_loss_of_heterozygosity_test) {
10730       if ( AsnReadVal(aip, atp, &av) <= 0) {
10731          goto erret;
10732       }
10733       ptr -> test = av.ptrvalue;
10734       atp = AsnReadId(aip,amp, atp);
10735    }
10736 
10737    if (AsnReadVal(aip, atp, &av) <= 0) {
10738       goto erret;
10739    }
10740    /* end struct */
10741 
10742 ret:
10743    AsnUnlinkType(orig);       /* unlink local tree */
10744    return ptr;
10745 
10746 erret:
10747    aip -> io_failure = TRUE;
10748    ptr = Consequence_loss_of_heterozygosityFree(ptr);
10749    goto ret;
10750 }
10751 
10752 
10753 
10754 /**************************************************
10755 *
10756 *    Consequence_frameshiftAsnRead()
10757 *
10758 **************************************************/
10759 NLM_EXTERN
10760 Consequence_frameshiftPtr LIBCALL
Consequence_frameshiftAsnRead(AsnIoPtr aip,AsnTypePtr orig)10761 Consequence_frameshiftAsnRead(AsnIoPtr aip, AsnTypePtr orig)
10762 {
10763    DataVal av;
10764    AsnTypePtr atp;
10765    AsnReadFunc func;
10766    Consequence_frameshiftPtr ptr;
10767 
10768    if (! loaded)
10769    {
10770       if (! SeqFeatAsnLoad()) {
10771          return NULL;
10772       }
10773    }
10774 
10775    if (aip == NULL) {
10776       return NULL;
10777    }
10778 
10779    if (orig == NULL) {         /* Consequence_frameshift ::= (self contained) */
10780       atp = AsnReadId(aip, amp, VARIATION_REF_consequence_E_frameshift);
10781    } else {
10782       atp = AsnLinkType(orig, VARIATION_REF_consequence_E_frameshift);
10783    }
10784    /* link in local tree */
10785    if (atp == NULL) {
10786       return NULL;
10787    }
10788 
10789    ptr = Consequence_frameshiftNew();
10790    if (ptr == NULL) {
10791       goto erret;
10792    }
10793    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
10794       goto erret;
10795    }
10796 
10797    atp = AsnReadId(aip,amp, atp);
10798    func = NULL;
10799 
10800    if (atp == VARIATION_REF_consequence_E_frameshift_phase) {
10801       if ( AsnReadVal(aip, atp, &av) <= 0) {
10802          goto erret;
10803       }
10804       ptr -> phase = av.intvalue;
10805       ptr -> OBbits__ |= 1<<0;
10806       atp = AsnReadId(aip,amp, atp);
10807    }
10808    if (atp == VARIATION_REF_consequence_E_frameshift_x_length) {
10809       if ( AsnReadVal(aip, atp, &av) <= 0) {
10810          goto erret;
10811       }
10812       ptr -> x_length = av.intvalue;
10813       ptr -> OBbits__ |= 1<<1;
10814       atp = AsnReadId(aip,amp, atp);
10815    }
10816 
10817    if (AsnReadVal(aip, atp, &av) <= 0) {
10818       goto erret;
10819    }
10820    /* end struct */
10821 
10822 ret:
10823    AsnUnlinkType(orig);       /* unlink local tree */
10824    return ptr;
10825 
10826 erret:
10827    aip -> io_failure = TRUE;
10828    ptr = Consequence_frameshiftFree(ptr);
10829    goto ret;
10830 }
10831 
10832 
10833 
10834 /**************************************************
10835 *
10836 *    Data_setFree()
10837 *
10838 **************************************************/
10839 NLM_EXTERN
10840 VarRefDataSetPtr LIBCALL
VarRefDataSetFree(VarRefDataSetPtr ptr)10841 VarRefDataSetFree(VarRefDataSetPtr ptr)
10842 {
10843 
10844    if(ptr == NULL) {
10845       return NULL;
10846    }
10847    AsnGenericValNodeSetFree (ptr -> variations, (AsnOptFreeFunc) VariationRefFree);
10848    /*
10849    AsnGenericUserSeqOfFree(ptr -> variations, (AsnOptFreeFunc) VariationRefFree);
10850    */
10851    MemFree(ptr -> name);
10852    return MemFree(ptr);
10853 }
10854 
10855 
10856 /**************************************************
10857 *
10858 *    VarRefDataFree()
10859 *
10860 **************************************************/
10861 NLM_EXTERN
10862 VarRefDataPtr LIBCALL
VarRefDataFree(ValNodePtr anp)10863 VarRefDataFree(ValNodePtr anp)
10864 {
10865    Pointer pnt;
10866 
10867    if (anp == NULL) {
10868       return NULL;
10869    }
10870 
10871    pnt = anp->data.ptrvalue;
10872    switch (anp->choice)
10873    {
10874    default:
10875       break;
10876    case VarRefData_note:
10877       MemFree(anp -> data.ptrvalue);
10878       break;
10879    case VarRefData_instance:
10880       VariationInstFree(anp -> data.ptrvalue);
10881       break;
10882    case VarRefData_set:
10883       VarRefDataSetFree(anp -> data.ptrvalue);
10884       break;
10885    }
10886    return MemFree(anp);
10887 }
10888 
10889 
10890 /**************************************************
10891 *
10892 *    Data_setNew()
10893 *
10894 **************************************************/
10895 NLM_EXTERN
10896 VarRefDataSetPtr LIBCALL
VarRefDataSetNew(void)10897 VarRefDataSetNew(void)
10898 {
10899    VarRefDataSetPtr ptr = MemNew((size_t) sizeof(VarRefData));
10900 
10901    return ptr;
10902 
10903 }
10904 
10905 
10906 /**************************************************
10907 *
10908 *    Data_setAsnRead()
10909 *
10910 **************************************************/
10911 NLM_EXTERN
10912 VarRefDataSetPtr LIBCALL
VarRefDataSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)10913 VarRefDataSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
10914 {
10915    DataVal av;
10916    AsnTypePtr atp;
10917    Boolean isError = FALSE;
10918    AsnReadFunc func;
10919    VarRefDataSetPtr ptr;
10920 
10921    if (! loaded)
10922    {
10923       if (! SeqFeatAsnLoad()) {
10924          return NULL;
10925       }
10926    }
10927 
10928    if (aip == NULL) {
10929       return NULL;
10930    }
10931 
10932    if (orig == NULL) {         /* Data_set ::= (self contained) */
10933       atp = AsnReadId(aip, amp, VARIATION_REF_data_set);
10934    } else {
10935       atp = AsnLinkType(orig, VARIATION_REF_data_set);
10936    }
10937    /* link in local tree */
10938    if (atp == NULL) {
10939       return NULL;
10940    }
10941 
10942    ptr = VarRefDataSetNew();
10943    if (ptr == NULL) {
10944       goto erret;
10945    }
10946    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
10947       goto erret;
10948    }
10949 
10950    atp = AsnReadId(aip,amp, atp);
10951    func = NULL;
10952 
10953    if (atp == VARIATION_REF_data_set_type) {
10954       if ( AsnReadVal(aip, atp, &av) <= 0) {
10955          goto erret;
10956       }
10957       ptr -> type = av.intvalue;
10958       atp = AsnReadId(aip,amp, atp);
10959    }
10960    if (atp == VARIATION_REF_data_set_variations) {
10961       ptr -> variations = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) VariationRefAsnRead, (AsnOptFreeFunc) VariationRefFree);
10962       /*
10963       ptr -> variations = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) VariationRefAsnRead, (AsnOptFreeFunc) VariationRefFree);
10964       */
10965       if (isError && ptr -> variations == NULL) {
10966          goto erret;
10967       }
10968       atp = AsnReadId(aip,amp, atp);
10969    }
10970    if (atp == VARIATION_REF_data_set_name) {
10971       if ( AsnReadVal(aip, atp, &av) <= 0) {
10972          goto erret;
10973       }
10974       ptr -> name = av.ptrvalue;
10975       atp = AsnReadId(aip,amp, atp);
10976    }
10977 
10978    if (AsnReadVal(aip, atp, &av) <= 0) {
10979       goto erret;
10980    }
10981    /* end struct */
10982 
10983 ret:
10984    AsnUnlinkType(orig);       /* unlink local tree */
10985    return ptr;
10986 
10987 erret:
10988    aip -> io_failure = TRUE;
10989    ptr = VarRefDataSetFree(ptr);
10990    goto ret;
10991 }
10992 
10993 
10994 /**************************************************
10995 *
10996 *    VarRefDataAsnRead()
10997 *
10998 **************************************************/
10999 NLM_EXTERN
11000 VarRefDataPtr LIBCALL
VarRefDataAsnRead(AsnIoPtr aip,AsnTypePtr orig)11001 VarRefDataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
11002 {
11003    DataVal av;
11004    AsnTypePtr atp;
11005    ValNodePtr anp;
11006    Uint1 choice = 0;
11007    Boolean nullIsError = FALSE;
11008    AsnReadFunc func;
11009 
11010    if (! loaded)
11011    {
11012       if (! SeqFeatAsnLoad()) {
11013          return NULL;
11014       }
11015    }
11016 
11017    if (aip == NULL) {
11018       return NULL;
11019    }
11020 
11021    if (orig == NULL) {         /* data ::= (self contained) */
11022       atp = AsnReadId(aip, amp, VARIATION_REF_data);
11023    } else {
11024       atp = AsnLinkType(orig, VARIATION_REF_data);    /* link in local tree */
11025    }
11026    if (atp == NULL) {
11027       return NULL;
11028    }
11029 
11030    anp = ValNodeNew(NULL);
11031    if (anp == NULL) {
11032       goto erret;
11033    }
11034    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
11035       goto erret;
11036    }
11037 
11038    func = NULL;
11039 
11040    atp = AsnReadId(aip, amp, atp);  /* find the choice */
11041    if (atp == NULL) {
11042       goto erret;
11043    }
11044    if (atp == VARIATION_REF_data_unknown) {
11045       choice = VarRefData_unknown;
11046       if (AsnReadVal(aip, atp, &av) <= 0) {
11047          goto erret;
11048       }
11049       anp->data.boolvalue = av.boolvalue;
11050    }
11051    else if (atp == VARIATION_REF_data_note) {
11052       choice = VarRefData_note;
11053       if (AsnReadVal(aip, atp, &av) <= 0) {
11054          goto erret;
11055       }
11056       anp->data.ptrvalue = av.ptrvalue;
11057    }
11058    else if (atp == VARIATION_REF_data_uniparental_disomy) {
11059       choice = VarRefData_uniparental_disomy;
11060       if (AsnReadVal(aip, atp, &av) <= 0) {
11061          goto erret;
11062       }
11063       anp->data.boolvalue = av.boolvalue;
11064    }
11065    else if (atp == VARIATION_REF_data_instance) {
11066       choice = VarRefData_instance;
11067       func = (AsnReadFunc) VariationInstAsnRead;
11068    }
11069    else if (atp == VARIATION_REF_data_set) {
11070       choice = VarRefData_set;
11071       func = (AsnReadFunc) VarRefDataSetAsnRead;
11072    }
11073    else if (atp == VARIATION_REF_data_complex) {
11074       choice = VarRefData_complex;
11075       if (AsnReadVal(aip, atp, &av) <= 0) {
11076          goto erret;
11077       }
11078       anp->data.boolvalue = av.boolvalue;
11079    }
11080    anp->choice = choice;
11081    if (func != NULL)
11082    {
11083       anp->data.ptrvalue = (* func)(aip, atp);
11084       if (aip -> io_failure) goto erret;
11085 
11086       if (nullIsError && anp->data.ptrvalue == NULL) {
11087          goto erret;
11088       }
11089    }
11090 
11091 ret:
11092    AsnUnlinkType(orig);       /* unlink local tree */
11093    return anp;
11094 
11095 erret:
11096    anp = MemFree(anp);
11097    aip -> io_failure = TRUE;
11098    goto ret;
11099 }
11100 
11101 
11102 
11103 /**************************************************
11104 *
11105 *    Consequence_elementFree()
11106 *
11107 **************************************************/
11108 NLM_EXTERN
11109 Consequence_elementPtr LIBCALL
Consequence_elementFree(ValNodePtr anp)11110 Consequence_elementFree(ValNodePtr anp)
11111 {
11112    Pointer pnt;
11113 
11114    if (anp == NULL) {
11115       return NULL;
11116    }
11117 
11118    pnt = anp->data.ptrvalue;
11119    switch (anp->choice)
11120    {
11121    default:
11122       break;
11123    case Consequence_note:
11124       MemFree(anp -> data.ptrvalue);
11125       break;
11126    case Consequence_variation:
11127       VariationRefFree(anp -> data.ptrvalue);
11128       break;
11129    case Consequence_Consequence_Frameshift:
11130       Consequence_frameshiftFree(anp -> data.ptrvalue);
11131       break;
11132    case Consequence_Consequence_LossOfHeterozygosity:
11133       Consequence_loss_of_heterozygosityFree(anp -> data.ptrvalue);
11134       break;
11135    }
11136    return MemFree(anp);
11137 }
11138 
11139 
11140 /**************************************************
11141 *
11142 *    Consequence_loss_of_heterozygosityFree()
11143 *
11144 **************************************************/
11145 NLM_EXTERN
11146 Consequence_loss_of_heterozygosityPtr LIBCALL
Consequence_loss_of_heterozygosityFree(Consequence_loss_of_heterozygosityPtr ptr)11147 Consequence_loss_of_heterozygosityFree(Consequence_loss_of_heterozygosityPtr ptr)
11148 {
11149 
11150    if(ptr == NULL) {
11151       return NULL;
11152    }
11153    MemFree(ptr -> reference);
11154    MemFree(ptr -> test);
11155    return MemFree(ptr);
11156 }
11157 
11158 
11159 /**************************************************
11160 *
11161 *    Consequence_frameshiftFree()
11162 *
11163 **************************************************/
11164 NLM_EXTERN
11165 Consequence_frameshiftPtr LIBCALL
Consequence_frameshiftFree(Consequence_frameshiftPtr ptr)11166 Consequence_frameshiftFree(Consequence_frameshiftPtr ptr)
11167 {
11168 
11169    if(ptr == NULL) {
11170       return NULL;
11171    }
11172    return MemFree(ptr);
11173 }
11174 
11175 
11176 /**************************************************
11177 *
11178 *    Consequence_frameshiftNew()
11179 *
11180 **************************************************/
11181 NLM_EXTERN
11182 Consequence_frameshiftPtr LIBCALL
Consequence_frameshiftNew(void)11183 Consequence_frameshiftNew(void)
11184 {
11185    Consequence_frameshiftPtr ptr = MemNew((size_t) sizeof(Consequence_frameshift));
11186 
11187    return ptr;
11188 
11189 }
11190 
11191 
11192 /**************************************************
11193 *
11194 *    VariationInstNew()
11195 *
11196 **************************************************/
11197 NLM_EXTERN
11198 VariationInstPtr LIBCALL
VariationInstNew(void)11199 VariationInstNew(void)
11200 {
11201    VariationInstPtr ptr = MemNew((size_t) sizeof(VariationInst));
11202 
11203    return ptr;
11204 
11205 }
11206 
11207 
11208 /**************************************************
11209 *
11210 *    VariationInstFree()
11211 *
11212 **************************************************/
11213 NLM_EXTERN
11214 VariationInstPtr LIBCALL
VariationInstFree(VariationInstPtr ptr)11215 VariationInstFree(VariationInstPtr ptr)
11216 {
11217 
11218    if(ptr == NULL) {
11219       return NULL;
11220    }
11221    AsnGenericValNodeSetFree (ptr -> delta, (AsnOptFreeFunc) DeltaItemFree);
11222    /*
11223    AsnGenericUserSeqOfFree(ptr -> delta, (AsnOptFreeFunc) DeltaItemFree);
11224    */
11225    return MemFree(ptr);
11226 }
11227 
11228 
11229 /**************************************************
11230 *
11231 *    VariationInstAsnRead()
11232 *
11233 **************************************************/
11234 NLM_EXTERN
11235 VariationInstPtr LIBCALL
VariationInstAsnRead(AsnIoPtr aip,AsnTypePtr orig)11236 VariationInstAsnRead(AsnIoPtr aip, AsnTypePtr orig)
11237 {
11238    DataVal av;
11239    AsnTypePtr atp;
11240    Boolean isError = FALSE;
11241    AsnReadFunc func;
11242    VariationInstPtr ptr;
11243 
11244    if (! loaded)
11245    {
11246       if (! SeqFeatAsnLoad()) {
11247          return NULL;
11248       }
11249    }
11250 
11251    if (aip == NULL) {
11252       return NULL;
11253    }
11254 
11255    if (orig == NULL) {         /* VariationInst ::= (self contained) */
11256       atp = AsnReadId(aip, amp, VARIATION_INST);
11257    } else {
11258       atp = AsnLinkType(orig, VARIATION_INST);
11259    }
11260    /* link in local tree */
11261    if (atp == NULL) {
11262       return NULL;
11263    }
11264 
11265    ptr = VariationInstNew();
11266    if (ptr == NULL) {
11267       goto erret;
11268    }
11269    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
11270       goto erret;
11271    }
11272 
11273    atp = AsnReadId(aip,amp, atp);
11274    func = NULL;
11275 
11276    if (atp == VARIATION_INST_type) {
11277       if ( AsnReadVal(aip, atp, &av) <= 0) {
11278          goto erret;
11279       }
11280       ptr -> type = av.intvalue;
11281       atp = AsnReadId(aip,amp, atp);
11282    }
11283    if (atp == VARIATION_INST_delta) {
11284       ptr -> delta = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) DeltaItemAsnRead, (AsnOptFreeFunc) DeltaItemFree);
11285       /*
11286       ptr -> delta = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DeltaItemAsnRead, (AsnOptFreeFunc) DeltaItemFree);
11287       */
11288       if (isError && ptr -> delta == NULL) {
11289          goto erret;
11290       }
11291       atp = AsnReadId(aip,amp, atp);
11292    }
11293    if (atp == VARIATION_INST_observation) {
11294       if ( AsnReadVal(aip, atp, &av) <= 0) {
11295          goto erret;
11296       }
11297       ptr -> observation = av.intvalue;
11298       ptr -> OBbits__ |= 1<<0;
11299       atp = AsnReadId(aip,amp, atp);
11300    }
11301 
11302    if (AsnReadVal(aip, atp, &av) <= 0) {
11303       goto erret;
11304    }
11305    /* end struct */
11306 
11307 ret:
11308    AsnUnlinkType(orig);       /* unlink local tree */
11309    return ptr;
11310 
11311 erret:
11312    aip -> io_failure = TRUE;
11313    ptr = VariationInstFree(ptr);
11314    goto ret;
11315 }
11316 
11317 
11318 
11319 /**************************************************
11320 *
11321 *    VariationInstAsnWrite()
11322 *
11323 **************************************************/
11324 NLM_EXTERN Boolean LIBCALL
VariationInstAsnWrite(VariationInstPtr ptr,AsnIoPtr aip,AsnTypePtr orig)11325 VariationInstAsnWrite(VariationInstPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
11326 {
11327    DataVal av;
11328    AsnTypePtr atp;
11329    Boolean retval = FALSE;
11330 
11331    if (! loaded)
11332    {
11333       if (! SeqFeatAsnLoad()) {
11334          return FALSE;
11335       }
11336    }
11337 
11338    if (aip == NULL) {
11339       return FALSE;
11340    }
11341 
11342    atp = AsnLinkType(orig, VARIATION_INST);   /* link local tree */
11343    if (atp == NULL) {
11344       return FALSE;
11345    }
11346 
11347    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
11348 
11349     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
11350 
11351    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
11352       goto erret;
11353    }
11354 
11355    av.intvalue = ptr -> type;
11356    retval = AsnWrite(aip, VARIATION_INST_type,  &av);
11357    AsnGenericValNodeSetAsnWrite (ptr -> delta, (AsnWriteFunc) DeltaItemAsnWrite, aip, VARIATION_INST_delta, VARIATION_INST_delta_E);
11358    /*
11359    AsnGenericUserSeqOfAsnWrite(ptr -> delta, (AsnWriteFunc) DeltaItemAsnWrite, aip, VARIATION_INST_delta, VARIATION_INST_delta_E);
11360    */
11361    if (ptr -> observation || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> observation;
11362       retval = AsnWrite(aip, VARIATION_INST_observation,  &av);
11363    }
11364    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
11365       goto erret;
11366    }
11367    retval = TRUE;
11368 
11369 erret:
11370    AsnUnlinkType(orig);       /* unlink local tree */
11371    return retval;
11372 }
11373 
11374 
11375 
11376 /**************************************************
11377 *
11378 *    VariantPropertiesNew()
11379 *
11380 **************************************************/
11381 NLM_EXTERN
11382 VariantPropertiesPtr LIBCALL
VariantPropertiesNew(void)11383 VariantPropertiesNew(void)
11384 {
11385    VariantPropertiesPtr ptr = MemNew((size_t) sizeof(VariantProperties));
11386 
11387    return ptr;
11388 
11389 }
11390 
11391 
11392 /**************************************************
11393 /**************************************************
11394 *
11395 *    VariantPropertiesFree()
11396 *
11397 **************************************************/
11398 NLM_EXTERN
11399 VariantPropertiesPtr LIBCALL
VariantPropertiesFree(VariantPropertiesPtr ptr)11400 VariantPropertiesFree(VariantPropertiesPtr ptr)
11401 {
11402 
11403    if(ptr == NULL) {
11404       return NULL;
11405    }
11406    AsnGenericBaseSeqOfFree(ptr -> project_data, ASNCODE_INTVAL_SLOT);
11407    return MemFree(ptr);
11408 }
11409 
11410 
11411 /**************************************************
11412 *
11413 *    VariantPropertiesAsnRead()
11414 *
11415 **************************************************/
11416 NLM_EXTERN
11417 VariantPropertiesPtr LIBCALL
VariantPropertiesAsnRead(AsnIoPtr aip,AsnTypePtr orig)11418 VariantPropertiesAsnRead(AsnIoPtr aip, AsnTypePtr orig)
11419 {
11420    DataVal av;
11421    AsnTypePtr atp;
11422    AsnReadFunc func;
11423    VariantPropertiesPtr ptr;
11424    Boolean isError = FALSE;
11425 
11426    if (! loaded)
11427    {
11428       if (! SeqFeatAsnLoad()) {
11429          return NULL;
11430       }
11431    }
11432 
11433    if (aip == NULL) {
11434       return NULL;
11435    }
11436 
11437    if (orig == NULL) {         /* VariantProperties ::= (self contained) */
11438       atp = AsnReadId(aip, amp, VARIANTPROPERTIES);
11439    } else {
11440       atp = AsnLinkType(orig, VARIANTPROPERTIES);
11441    }
11442    /* link in local tree */
11443    if (atp == NULL) {
11444       return NULL;
11445    }
11446 
11447    ptr = VariantPropertiesNew();
11448    if (ptr == NULL) {
11449       goto erret;
11450    }
11451    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
11452       goto erret;
11453    }
11454 
11455    atp = AsnReadId(aip,amp, atp);
11456    func = NULL;
11457 
11458    if (atp == VARIANTPROPERTIES_version) {
11459       if ( AsnReadVal(aip, atp, &av) <= 0) {
11460          goto erret;
11461       }
11462       ptr -> version = av.intvalue;
11463       atp = AsnReadId(aip,amp, atp);
11464    }
11465    if (atp == VARIANTPROPERTIES_resource_link) {
11466       if ( AsnReadVal(aip, atp, &av) <= 0) {
11467          goto erret;
11468       }
11469       ptr -> resource_link = av.intvalue;
11470       ptr -> OBbits__ |= 1<<0;
11471       atp = AsnReadId(aip,amp, atp);
11472    }
11473    if (atp == VARIANTPROPERTIES_gene_location) {
11474       if ( AsnReadVal(aip, atp, &av) <= 0) {
11475          goto erret;
11476       }
11477       ptr -> gene_location = av.intvalue;
11478       ptr -> OBbits__ |= 1<<1;
11479       atp = AsnReadId(aip,amp, atp);
11480    }
11481    if (atp == VARIANTPROPERTIES_effect) {
11482       if ( AsnReadVal(aip, atp, &av) <= 0) {
11483          goto erret;
11484       }
11485       ptr -> effect = av.intvalue;
11486       ptr -> OBbits__ |= 1<<2;
11487       atp = AsnReadId(aip,amp, atp);
11488    }
11489    if (atp == VARIANTPROPERTIES_mapping) {
11490       if ( AsnReadVal(aip, atp, &av) <= 0) {
11491          goto erret;
11492       }
11493       ptr -> mapping = av.intvalue;
11494       ptr -> OBbits__ |= 1<<3;
11495       atp = AsnReadId(aip,amp, atp);
11496    }
11497    if (atp == VARIANTPROPERTIES_map_weight) {
11498       if ( AsnReadVal(aip, atp, &av) <= 0) {
11499          goto erret;
11500       }
11501       ptr -> map_weight = av.intvalue;
11502       ptr -> OBbits__ |= 1<<4;
11503       atp = AsnReadId(aip,amp, atp);
11504    }
11505    if (atp == VARIANTPROPERTIES_frequency_based_validation) {
11506       if ( AsnReadVal(aip, atp, &av) <= 0) {
11507          goto erret;
11508       }
11509       ptr -> freq_based_validation = av.intvalue;
11510       ptr -> OBbits__ |= 1<<5;
11511       atp = AsnReadId(aip,amp, atp);
11512    }
11513    if (atp == VARIANTPROPERTIES_genotype) {
11514       if ( AsnReadVal(aip, atp, &av) <= 0) {
11515          goto erret;
11516       }
11517       ptr -> genotype = av.intvalue;
11518       ptr -> OBbits__ |= 1<<6;
11519       atp = AsnReadId(aip,amp, atp);
11520    }
11521    if (atp == VARIANTPROPERTIES_project_data) {
11522       ptr -> project_data = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
11523       if (isError && ptr -> project_data == NULL) {
11524          goto erret;
11525       }
11526       atp = AsnReadId(aip,amp, atp);
11527    }
11528    if (atp == VARIANTPROPERTIES_quality_check) {
11529       if ( AsnReadVal(aip, atp, &av) <= 0) {
11530          goto erret;
11531       }
11532       ptr -> quality_check = av.intvalue;
11533       ptr -> OBbits__ |= 1<<7;
11534       atp = AsnReadId(aip,amp, atp);
11535    }
11536    if (atp == VARIANTPROPERTIES_confidence) {
11537       if ( AsnReadVal(aip, atp, &av) <= 0) {
11538          goto erret;
11539       }
11540       ptr -> confidence = av.intvalue;
11541       ptr -> OBbits__ |= 1<<8;
11542       atp = AsnReadId(aip,amp, atp);
11543    }
11544    if (atp == VARIANTPROPERTIES_other_validation) {
11545       if ( AsnReadVal(aip, atp, &av) <= 0) {
11546          goto erret;
11547       }
11548       ptr -> other_validation = av.boolvalue;
11549       ptr -> OBbits__ |= 1<<9;
11550       atp = AsnReadId(aip,amp, atp);
11551    }
11552    if (atp == VARIANTPROPERTIES_allele_origin) {
11553       if ( AsnReadVal(aip, atp, &av) <= 0) {
11554          goto erret;
11555       }
11556       ptr -> allele_origin = av.intvalue;
11557       ptr -> OBbits__ |= 1<<10;
11558       atp = AsnReadId(aip,amp, atp);
11559    }
11560    if (atp == VARIANTPROPERTIES_allele_state) {
11561       if ( AsnReadVal(aip, atp, &av) <= 0) {
11562          goto erret;
11563       }
11564       ptr -> allele_state = av.intvalue;
11565       ptr -> OBbits__ |= 1<<11;
11566       atp = AsnReadId(aip,amp, atp);
11567    }
11568    if (atp == VARIANTPROPERTIES_allele_frequency) {
11569       if ( AsnReadVal(aip, atp, &av) <= 0) {
11570          goto erret;
11571       }
11572       ptr -> allele_frequency = av.realvalue;
11573       ptr -> OBbits__ |= 1<<12;
11574       atp = AsnReadId(aip,amp, atp);
11575    }
11576    if (atp == VARIANTPROPERTIES_is_ancestral_allele) {
11577       if ( AsnReadVal(aip, atp, &av) <= 0) {
11578          goto erret;
11579       }
11580       ptr -> is_ancestral_allele = av.boolvalue;
11581       ptr -> OBbits__ |= 1<<13;
11582       atp = AsnReadId(aip,amp, atp);
11583    }
11584 
11585    if (AsnReadVal(aip, atp, &av) <= 0) {
11586       goto erret;
11587    }
11588    /* end struct */
11589 
11590 ret:
11591    AsnUnlinkType(orig);       /* unlink local tree */
11592    return ptr;
11593 
11594 erret:
11595    aip -> io_failure = TRUE;
11596    ptr = VariantPropertiesFree(ptr);
11597    goto ret;
11598 }
11599 
11600 
11601 
11602 /**************************************************
11603 *
11604 *    VariantPropertiesAsnWrite()
11605 *
11606 **************************************************/
11607 NLM_EXTERN Boolean LIBCALL
VariantPropertiesAsnWrite(VariantPropertiesPtr ptr,AsnIoPtr aip,AsnTypePtr orig)11608 VariantPropertiesAsnWrite(VariantPropertiesPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
11609 {
11610    DataVal av;
11611    AsnTypePtr atp;
11612    Boolean retval = FALSE;
11613 
11614    if (! loaded)
11615    {
11616       if (! SeqFeatAsnLoad()) {
11617          return FALSE;
11618       }
11619    }
11620 
11621    if (aip == NULL) {
11622       return FALSE;
11623    }
11624 
11625    atp = AsnLinkType(orig, VARIANTPROPERTIES);   /* link local tree */
11626    if (atp == NULL) {
11627       return FALSE;
11628    }
11629 
11630    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
11631 
11632     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
11633 
11634    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
11635       goto erret;
11636    }
11637 
11638    av.intvalue = ptr -> version;
11639    retval = AsnWrite(aip, VARIANTPROPERTIES_version,  &av);
11640    if (ptr -> resource_link || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> resource_link;
11641       retval = AsnWrite(aip, VARIANTPROPERTIES_resource_link,  &av);
11642    }
11643    if (ptr -> gene_location || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> gene_location;
11644       retval = AsnWrite(aip, VARIANTPROPERTIES_gene_location,  &av);
11645    }
11646    if (ptr -> effect || (ptr -> OBbits__ & (1<<2) )){   av.intvalue = ptr -> effect;
11647       retval = AsnWrite(aip, VARIANTPROPERTIES_effect,  &av);
11648    }
11649    if (ptr -> mapping || (ptr -> OBbits__ & (1<<3) )){   av.intvalue = ptr -> mapping;
11650       retval = AsnWrite(aip, VARIANTPROPERTIES_mapping,  &av);
11651    }
11652    if (ptr -> map_weight || (ptr -> OBbits__ & (1<<4) )){   av.intvalue = ptr -> map_weight;
11653       retval = AsnWrite(aip, VARIANTPROPERTIES_map_weight,  &av);
11654    }
11655    if (ptr -> freq_based_validation || (ptr -> OBbits__ & (1<<5) )){   av.intvalue = ptr -> freq_based_validation;
11656       retval = AsnWrite(aip, VARIANTPROPERTIES_frequency_based_validation,  &av);
11657    }
11658    if (ptr -> genotype || (ptr -> OBbits__ & (1<<6) )){   av.intvalue = ptr -> genotype;
11659       retval = AsnWrite(aip, VARIANTPROPERTIES_genotype,  &av);
11660    }
11661    if (ptr -> project_data != NULL) {
11662       retval = AsnGenericBaseSeqOfAsnWrite(ptr -> project_data ,ASNCODE_INTVAL_SLOT, aip, VARIANTPROPERTIES_project_data, VARIANTPROPERTIES_project_data_E);
11663    }
11664    if (ptr -> quality_check || (ptr -> OBbits__ & (1<<7) )){   av.intvalue = ptr -> quality_check;
11665       retval = AsnWrite(aip, VARIANTPROPERTIES_quality_check,  &av);
11666    }
11667    if (ptr -> confidence || (ptr -> OBbits__ & (1<<8) )){   av.intvalue = ptr -> confidence;
11668       retval = AsnWrite(aip, VARIANTPROPERTIES_confidence,  &av);
11669    }
11670    if (ptr -> other_validation || (ptr -> OBbits__ & (1<<9) )){   av.boolvalue = ptr -> other_validation;
11671       retval = AsnWrite(aip, VARIANTPROPERTIES_other_validation,  &av);
11672    }
11673    if (ptr -> allele_origin || (ptr -> OBbits__ & (1<<10) )){   av.intvalue = ptr -> allele_origin;
11674       retval = AsnWrite(aip, VARIANTPROPERTIES_allele_origin,  &av);
11675    }
11676    if (ptr -> allele_state || (ptr -> OBbits__ & (1<<11) )){   av.intvalue = ptr -> allele_state;
11677       retval = AsnWrite(aip, VARIANTPROPERTIES_allele_state,  &av);
11678    }
11679    if (ptr -> allele_frequency || (ptr -> OBbits__ & (1<<12) )){   av.realvalue = ptr -> allele_frequency;
11680       retval = AsnWrite(aip, VARIANTPROPERTIES_allele_frequency,  &av);
11681    }
11682    if (ptr -> is_ancestral_allele || (ptr -> OBbits__ & (1<<13) )){   av.boolvalue = ptr -> is_ancestral_allele;
11683       retval = AsnWrite(aip, VARIANTPROPERTIES_is_ancestral_allele,  &av);
11684    }
11685    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
11686       goto erret;
11687    }
11688    retval = TRUE;
11689 
11690 erret:
11691    AsnUnlinkType(orig);       /* unlink local tree */
11692    return retval;
11693 }
11694 
11695 
11696 
11697 /**************************************************
11698 *
11699 *    PhenotypeNew()
11700 *
11701 **************************************************/
11702 NLM_EXTERN
11703 PhenotypePtr LIBCALL
PhenotypeNew(void)11704 PhenotypeNew(void)
11705 {
11706    PhenotypePtr ptr = MemNew((size_t) sizeof(Phenotype));
11707 
11708    return ptr;
11709 
11710 }
11711 
11712 
11713 /**************************************************
11714 *
11715 *    PhenotypeFree()
11716 *
11717 **************************************************/
11718 NLM_EXTERN
11719 PhenotypePtr LIBCALL
PhenotypeFree(PhenotypePtr ptr)11720 PhenotypeFree(PhenotypePtr ptr)
11721 {
11722    if(ptr == NULL) {
11723       return NULL;
11724    }
11725    MemFree(ptr -> source);
11726    MemFree(ptr -> term);
11727    /*
11728    AsnGenericUserSeqOfFree(ptr -> xref, (AsnOptFreeFunc) DbtagFree);
11729    */
11730    AsnGenericValNodeSetFree (ptr->xref, (AsnOptFreeFunc) DbtagFree);
11731    return MemFree(ptr);
11732 }
11733 
11734 
11735 /**************************************************
11736 *
11737 *    PhenotypeAsnRead()
11738 *
11739 **************************************************/
11740 NLM_EXTERN
11741 PhenotypePtr LIBCALL
PhenotypeAsnRead(AsnIoPtr aip,AsnTypePtr orig)11742 PhenotypeAsnRead(AsnIoPtr aip, AsnTypePtr orig)
11743 {
11744    DataVal av;
11745    AsnTypePtr atp;
11746    AsnReadFunc func;
11747    PhenotypePtr ptr;
11748    Boolean isError = FALSE;
11749 
11750    if (! loaded)
11751    {
11752       if (! SeqFeatAsnLoad()) {
11753          return NULL;
11754       }
11755    }
11756 
11757    if (aip == NULL) {
11758       return NULL;
11759    }
11760 
11761    if (orig == NULL) {         /* Phenotype ::= (self contained) */
11762       atp = AsnReadId(aip, amp, PHENOTYPE);
11763    } else {
11764       atp = AsnLinkType(orig, PHENOTYPE);
11765    }
11766    /* link in local tree */
11767    if (atp == NULL) {
11768       return NULL;
11769    }
11770 
11771    ptr = PhenotypeNew();
11772    if (ptr == NULL) {
11773       goto erret;
11774    }
11775    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
11776       goto erret;
11777    }
11778 
11779    atp = AsnReadId(aip,amp, atp);
11780    func = NULL;
11781 
11782    if (atp == PHENOTYPE_source) {
11783       if ( AsnReadVal(aip, atp, &av) <= 0) {
11784          goto erret;
11785       }
11786       ptr -> source = av.ptrvalue;
11787       atp = AsnReadId(aip,amp, atp);
11788    }
11789    if (atp == PHENOTYPE_term) {
11790       if ( AsnReadVal(aip, atp, &av) <= 0) {
11791          goto erret;
11792       }
11793       ptr -> term = av.ptrvalue;
11794       atp = AsnReadId(aip,amp, atp);
11795    }
11796    if (atp == PHENOTYPE_xref) {
11797       ptr->xref = AsnGenericValNodeSetAsnRead (aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
11798       /*
11799       ptr -> xref = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DbtagAsnRead, (AsnOptFreeFunc) DbtagFree);
11800       */
11801       if (isError && ptr -> xref == NULL) {
11802          goto erret;
11803       }
11804       atp = AsnReadId(aip,amp, atp);
11805    }
11806    if (atp == PHENOTYPE_clinical_significance) {
11807       if ( AsnReadVal(aip, atp, &av) <= 0) {
11808          goto erret;
11809       }
11810       ptr -> clinical_significance = av.intvalue;
11811       ptr -> OBbits__ |= 1<<0;
11812       atp = AsnReadId(aip,amp, atp);
11813    }
11814 
11815    if (AsnReadVal(aip, atp, &av) <= 0) {
11816       goto erret;
11817    }
11818    /* end struct */
11819 
11820 ret:
11821    AsnUnlinkType(orig);       /* unlink local tree */
11822    return ptr;
11823 
11824 erret:
11825    aip -> io_failure = TRUE;
11826    ptr = PhenotypeFree(ptr);
11827    goto ret;
11828 }
11829 
11830 
11831 
11832 /**************************************************
11833 *
11834 *    PhenotypeAsnWrite()
11835 *
11836 **************************************************/
11837 NLM_EXTERN Boolean LIBCALL
PhenotypeAsnWrite(PhenotypePtr ptr,AsnIoPtr aip,AsnTypePtr orig)11838 PhenotypeAsnWrite(PhenotypePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
11839 {
11840    DataVal av;
11841    AsnTypePtr atp;
11842    Boolean retval = FALSE;
11843 
11844    if (! loaded)
11845    {
11846       if (! SeqFeatAsnLoad()) {
11847          return FALSE;
11848       }
11849    }
11850 
11851    if (aip == NULL) {
11852       return FALSE;
11853    }
11854 
11855    atp = AsnLinkType(orig, PHENOTYPE);   /* link local tree */
11856    if (atp == NULL) {
11857       return FALSE;
11858    }
11859 
11860    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
11861 
11862     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
11863 
11864    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
11865       goto erret;
11866    }
11867 
11868    if (ptr -> source != NULL) {
11869       av.ptrvalue = ptr -> source;
11870       retval = AsnWrite(aip, PHENOTYPE_source,  &av);
11871    }
11872    if (ptr -> term != NULL) {
11873       av.ptrvalue = ptr -> term;
11874       retval = AsnWrite(aip, PHENOTYPE_term,  &av);
11875    }
11876    AsnGenericValNodeSetAsnWrite (ptr->xref, (AsnWriteFunc) DbtagAsnWrite, aip, PHENOTYPE_xref, PHENOTYPE_xref_E);
11877    /*
11878    AsnGenericUserSeqOfAsnWrite(ptr -> xref, (AsnWriteFunc) DbtagAsnWrite, aip, PHENOTYPE_xref, PHENOTYPE_xref_E);
11879    */
11880    if (ptr -> clinical_significance || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> clinical_significance;
11881       retval = AsnWrite(aip, PHENOTYPE_clinical_significance,  &av);
11882    }
11883    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
11884       goto erret;
11885    }
11886    retval = TRUE;
11887 
11888 erret:
11889    AsnUnlinkType(orig);       /* unlink local tree */
11890    return retval;
11891 }
11892 
11893 
11894 
11895 /**************************************************
11896 *
11897 *    PopulationDataNew()
11898 *
11899 **************************************************/
11900 NLM_EXTERN
11901 PopulationDataPtr LIBCALL
PopulationDataNew(void)11902 PopulationDataNew(void)
11903 {
11904    PopulationDataPtr ptr = MemNew((size_t) sizeof(PopulationData));
11905 
11906    return ptr;
11907 
11908 }
11909 
11910 
11911 /**************************************************
11912 *
11913 *    PopulationDataFree()
11914 *
11915 **************************************************/
11916 NLM_EXTERN
11917 PopulationDataPtr LIBCALL
PopulationDataFree(PopulationDataPtr ptr)11918 PopulationDataFree(PopulationDataPtr ptr)
11919 {
11920 
11921    if(ptr == NULL) {
11922       return NULL;
11923    }
11924    MemFree(ptr -> population);
11925    AsnGenericValNodeSetFree (ptr -> sample_ids, (AsnOptFreeFunc) ObjectIdFree);
11926    /*
11927    AsnGenericChoiceSeqOfFree(ptr -> sample_ids, (AsnOptFreeFunc) ObjectIdFree);
11928    */
11929    return MemFree(ptr);
11930 }
11931 
11932 
11933 /**************************************************
11934 *
11935 *    PopulationDataAsnRead()
11936 *
11937 **************************************************/
11938 NLM_EXTERN
11939 PopulationDataPtr LIBCALL
PopulationDataAsnRead(AsnIoPtr aip,AsnTypePtr orig)11940 PopulationDataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
11941 {
11942    DataVal av;
11943    AsnTypePtr atp;
11944    Boolean isError = FALSE;
11945    AsnReadFunc func;
11946    PopulationDataPtr ptr;
11947 
11948    if (! loaded)
11949    {
11950       if (! SeqFeatAsnLoad()) {
11951          return NULL;
11952       }
11953    }
11954 
11955    if (aip == NULL) {
11956       return NULL;
11957    }
11958 
11959    if (orig == NULL) {         /* PopulationData ::= (self contained) */
11960       atp = AsnReadId(aip, amp, POPULATION_DATA);
11961    } else {
11962       atp = AsnLinkType(orig, POPULATION_DATA);
11963    }
11964    /* link in local tree */
11965    if (atp == NULL) {
11966       return NULL;
11967    }
11968 
11969    ptr = PopulationDataNew();
11970    if (ptr == NULL) {
11971       goto erret;
11972    }
11973    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
11974       goto erret;
11975    }
11976 
11977    atp = AsnReadId(aip,amp, atp);
11978    func = NULL;
11979 
11980    if (atp == POPULATION_DATA_population) {
11981       if ( AsnReadVal(aip, atp, &av) <= 0) {
11982          goto erret;
11983       }
11984       ptr -> population = av.ptrvalue;
11985       atp = AsnReadId(aip,amp, atp);
11986    }
11987    if (atp == POPULATION_DATA_genotype_frequency) {
11988       if ( AsnReadVal(aip, atp, &av) <= 0) {
11989          goto erret;
11990       }
11991       ptr -> genotype_frequency = av.realvalue;
11992       ptr -> OBbits__ |= 1<<0;
11993       atp = AsnReadId(aip,amp, atp);
11994    }
11995    if (atp == POPULATION_DATA_chromosomes_tested) {
11996       if ( AsnReadVal(aip, atp, &av) <= 0) {
11997          goto erret;
11998       }
11999       ptr -> chromosomes_tested = av.intvalue;
12000       ptr -> OBbits__ |= 1<<1;
12001       atp = AsnReadId(aip,amp, atp);
12002    }
12003    if (atp == POPULATION_DATA_sample_ids) {
12004       ptr -> sample_ids = AsnGenericValNodeSetAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ObjectIdAsnRead, (AsnOptFreeFunc) ObjectIdFree);
12005       /*
12006       ptr -> sample_ids = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ObjectIdAsnRead, (AsnOptFreeFunc) ObjectIdFree);
12007       */
12008       if (isError && ptr -> sample_ids == NULL) {
12009          goto erret;
12010       }
12011       atp = AsnReadId(aip,amp, atp);
12012    }
12013    if (atp == POPULATION_DATA_allele_frequency) {
12014       if ( AsnReadVal(aip, atp, &av) <= 0) {
12015          goto erret;
12016       }
12017       ptr -> allele_frequency = av.realvalue;
12018       ptr -> OBbits__ |= 1<<2;
12019       atp = AsnReadId(aip,amp, atp);
12020    }
12021    if (atp == POPULATION_DATA_flags) {
12022       if ( AsnReadVal(aip, atp, &av) <= 0) {
12023          goto erret;
12024       }
12025       ptr -> flags = av.intvalue;
12026       ptr -> OBbits__ |= 1<<3;
12027       atp = AsnReadId(aip,amp, atp);
12028    }
12029 
12030    if (AsnReadVal(aip, atp, &av) <= 0) {
12031       goto erret;
12032    }
12033    /* end struct */
12034 
12035 ret:
12036    AsnUnlinkType(orig);       /* unlink local tree */
12037    return ptr;
12038 
12039 erret:
12040    aip -> io_failure = TRUE;
12041    ptr = PopulationDataFree(ptr);
12042    goto ret;
12043 }
12044 
12045 
12046 
12047 /**************************************************
12048 *
12049 *    PopulationDataAsnWrite()
12050 *
12051 **************************************************/
12052 NLM_EXTERN Boolean LIBCALL
PopulationDataAsnWrite(PopulationDataPtr ptr,AsnIoPtr aip,AsnTypePtr orig)12053 PopulationDataAsnWrite(PopulationDataPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
12054 {
12055    DataVal av;
12056    AsnTypePtr atp;
12057    Boolean retval = FALSE;
12058 
12059    if (! loaded)
12060    {
12061       if (! SeqFeatAsnLoad()) {
12062          return FALSE;
12063       }
12064    }
12065 
12066    if (aip == NULL) {
12067       return FALSE;
12068    }
12069 
12070    atp = AsnLinkType(orig, POPULATION_DATA);   /* link local tree */
12071    if (atp == NULL) {
12072       return FALSE;
12073    }
12074 
12075    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
12076 
12077     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
12078 
12079    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
12080       goto erret;
12081    }
12082 
12083    if (ptr -> population != NULL) {
12084       av.ptrvalue = ptr -> population;
12085       retval = AsnWrite(aip, POPULATION_DATA_population,  &av);
12086    }
12087    if (ptr -> genotype_frequency || (ptr -> OBbits__ & (1<<0) )){   av.realvalue = ptr -> genotype_frequency;
12088       retval = AsnWrite(aip, POPULATION_DATA_genotype_frequency,  &av);
12089    }
12090    if (ptr -> chromosomes_tested || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> chromosomes_tested;
12091       retval = AsnWrite(aip, POPULATION_DATA_chromosomes_tested,  &av);
12092    }
12093    AsnGenericValNodeSetAsnWrite(ptr -> sample_ids, (AsnWriteFunc) ObjectIdAsnWrite, aip, POPULATION_DATA_sample_ids, POPULATION_DATA_sample_ids_E);
12094    /*
12095    AsnGenericChoiceSeqOfAsnWrite(ptr -> sample_ids, (AsnWriteFunc) ObjectIdAsnWrite, aip, POPULATION_DATA_sample_ids, POPULATION_DATA_sample_ids_E);
12096    */
12097    if (ptr -> allele_frequency || (ptr -> OBbits__ & (1<<2) )){   av.realvalue = ptr -> allele_frequency;
12098       retval = AsnWrite(aip, POPULATION_DATA_allele_frequency,  &av);
12099    }
12100    if (ptr -> flags || (ptr -> OBbits__ & (1<<3) )){   av.intvalue = ptr -> flags;
12101       retval = AsnWrite(aip, POPULATION_DATA_flags,  &av);
12102    }
12103    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
12104       goto erret;
12105    }
12106    retval = TRUE;
12107 
12108 erret:
12109    AsnUnlinkType(orig);       /* unlink local tree */
12110    return retval;
12111 }
12112 
12113 
12114 
12115 /**************************************************
12116 *
12117 *    ExtLocNew()
12118 *
12119 **************************************************/
12120 NLM_EXTERN
12121 ExtLocPtr LIBCALL
ExtLocNew(void)12122 ExtLocNew(void)
12123 {
12124    ExtLocPtr ptr = MemNew((size_t) sizeof(ExtLoc));
12125 
12126    return ptr;
12127 
12128 }
12129 
12130 
12131 /**************************************************
12132 *
12133 *    ExtLocFree()
12134 *
12135 **************************************************/
12136 NLM_EXTERN
12137 ExtLocPtr LIBCALL
ExtLocFree(ExtLocPtr ptr)12138 ExtLocFree(ExtLocPtr ptr)
12139 {
12140 
12141    if(ptr == NULL) {
12142       return NULL;
12143    }
12144    ObjectIdFree(ptr -> id);
12145    SeqLocFree(ptr -> location);
12146    return MemFree(ptr);
12147 }
12148 
12149 
12150 /**************************************************
12151 *
12152 *    ExtLocAsnRead()
12153 *
12154 **************************************************/
12155 NLM_EXTERN
12156 ExtLocPtr LIBCALL
ExtLocAsnRead(AsnIoPtr aip,AsnTypePtr orig)12157 ExtLocAsnRead(AsnIoPtr aip, AsnTypePtr orig)
12158 {
12159    DataVal av;
12160    AsnTypePtr atp;
12161    AsnReadFunc func;
12162    ExtLocPtr ptr;
12163 
12164    if (! loaded)
12165    {
12166       if (! SeqFeatAsnLoad()) {
12167          return NULL;
12168       }
12169    }
12170 
12171    if (aip == NULL) {
12172       return NULL;
12173    }
12174 
12175    if (orig == NULL) {         /* ExtLoc ::= (self contained) */
12176       atp = AsnReadId(aip, amp, EXT_LOC);
12177    } else {
12178       atp = AsnLinkType(orig, EXT_LOC);
12179    }
12180    /* link in local tree */
12181    if (atp == NULL) {
12182       return NULL;
12183    }
12184 
12185    ptr = ExtLocNew();
12186    if (ptr == NULL) {
12187       goto erret;
12188    }
12189    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
12190       goto erret;
12191    }
12192 
12193    atp = AsnReadId(aip,amp, atp);
12194    func = NULL;
12195 
12196    if (atp == EXT_LOC_id) {
12197       ptr -> id = ObjectIdAsnRead(aip, atp);
12198       if (aip -> io_failure) {
12199          goto erret;
12200       }
12201       atp = AsnReadId(aip,amp, atp);
12202    }
12203    if (atp == EXT_LOC_location) {
12204       ptr -> location = SeqLocAsnRead(aip, atp);
12205       if (aip -> io_failure) {
12206          goto erret;
12207       }
12208       atp = AsnReadId(aip,amp, atp);
12209    }
12210 
12211    if (AsnReadVal(aip, atp, &av) <= 0) {
12212       goto erret;
12213    }
12214    /* end struct */
12215 
12216 ret:
12217    AsnUnlinkType(orig);       /* unlink local tree */
12218    return ptr;
12219 
12220 erret:
12221    aip -> io_failure = TRUE;
12222    ptr = ExtLocFree(ptr);
12223    goto ret;
12224 }
12225 
12226 
12227 
12228 /**************************************************
12229 *
12230 *    ExtLocAsnWrite()
12231 *
12232 **************************************************/
12233 NLM_EXTERN Boolean LIBCALL
ExtLocAsnWrite(ExtLocPtr ptr,AsnIoPtr aip,AsnTypePtr orig)12234 ExtLocAsnWrite(ExtLocPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
12235 {
12236    AsnTypePtr atp;
12237    Boolean retval = FALSE;
12238 
12239    if (! loaded)
12240    {
12241       if (! SeqFeatAsnLoad()) {
12242          return FALSE;
12243       }
12244    }
12245 
12246    if (aip == NULL) {
12247       return FALSE;
12248    }
12249 
12250    atp = AsnLinkType(orig, EXT_LOC);   /* link local tree */
12251    if (atp == NULL) {
12252       return FALSE;
12253    }
12254 
12255    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
12256 
12257    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
12258       goto erret;
12259    }
12260 
12261    if (ptr -> id != NULL) {
12262       if ( ! ObjectIdAsnWrite(ptr -> id, aip, EXT_LOC_id)) {
12263          goto erret;
12264       }
12265    }
12266    if (ptr -> location != NULL) {
12267       if ( ! SeqLocAsnWrite(ptr -> location, aip, EXT_LOC_location)) {
12268          goto erret;
12269       }
12270    }
12271    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
12272       goto erret;
12273    }
12274    retval = TRUE;
12275 
12276 erret:
12277    AsnUnlinkType(orig);       /* unlink local tree */
12278    return retval;
12279 }
12280 
12281 
12282 
12283 /**************************************************
12284 *
12285 *    DeltaItemNew()
12286 *
12287 **************************************************/
12288 NLM_EXTERN
12289 DeltaItemPtr LIBCALL
DeltaItemNew(void)12290 DeltaItemNew(void)
12291 {
12292    DeltaItemPtr ptr = MemNew((size_t) sizeof(DeltaItem));
12293 
12294    return ptr;
12295 
12296 }
12297 
12298 
12299 /**************************************************
12300 *
12301 *    DeltaItemFree()
12302 *
12303 **************************************************/
12304 NLM_EXTERN
12305 DeltaItemPtr LIBCALL
DeltaItemFree(DeltaItemPtr ptr)12306 DeltaItemFree(DeltaItemPtr ptr)
12307 {
12308 
12309    if(ptr == NULL) {
12310       return NULL;
12311    }
12312    Seq_seqFree(ptr -> Seq_seq);
12313    IntFuzzFree(ptr -> multiplier_fuzz);
12314    return MemFree(ptr);
12315 }
12316 
12317 
12318 /**************************************************
12319 *
12320 *    Seq_seqFree()
12321 *
12322 **************************************************/
12323 NLM_EXTERN
12324 Seq_seqPtr LIBCALL
Seq_seqFree(ValNodePtr anp)12325 Seq_seqFree(ValNodePtr anp)
12326 {
12327    Pointer pnt;
12328 
12329    if (anp == NULL) {
12330       return NULL;
12331    }
12332 
12333    pnt = anp->data.ptrvalue;
12334    switch (anp->choice)
12335    {
12336    default:
12337       break;
12338    case Seq_seq_literal:
12339       SeqLitFree(anp -> data.ptrvalue);
12340       break;
12341    case Seq_seq_loc:
12342       SeqLocFree(anp -> data.ptrvalue);
12343       break;
12344    }
12345    return MemFree(anp);
12346 }
12347 
12348 
12349 /**************************************************
12350 *
12351 *    DeltaItemAsnRead()
12352 *
12353 **************************************************/
12354 NLM_EXTERN
12355 DeltaItemPtr LIBCALL
DeltaItemAsnRead(AsnIoPtr aip,AsnTypePtr orig)12356 DeltaItemAsnRead(AsnIoPtr aip, AsnTypePtr orig)
12357 {
12358    DataVal av;
12359    AsnTypePtr atp;
12360    AsnReadFunc func;
12361    DeltaItemPtr ptr;
12362 
12363    if (! loaded)
12364    {
12365       if (! SeqFeatAsnLoad()) {
12366          return NULL;
12367       }
12368    }
12369 
12370    if (aip == NULL) {
12371       return NULL;
12372    }
12373 
12374    if (orig == NULL) {         /* DeltaItem ::= (self contained) */
12375       atp = AsnReadId(aip, amp, DELTA_ITEM);
12376    } else {
12377       atp = AsnLinkType(orig, DELTA_ITEM);
12378    }
12379    /* link in local tree */
12380    if (atp == NULL) {
12381       return NULL;
12382    }
12383 
12384    ptr = DeltaItemNew();
12385    if (ptr == NULL) {
12386       goto erret;
12387    }
12388    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
12389       goto erret;
12390    }
12391 
12392    atp = AsnReadId(aip,amp, atp);
12393    func = NULL;
12394 
12395    if (atp == DELTA_ITEM_seq) {
12396       ptr -> Seq_seq = Seq_seqAsnRead(aip, atp);
12397       if (aip -> io_failure) {
12398          goto erret;
12399       }
12400       atp = AsnReadId(aip,amp, atp);
12401    }
12402    if (atp == DELTA_ITEM_multiplier) {
12403       if ( AsnReadVal(aip, atp, &av) <= 0) {
12404          goto erret;
12405       }
12406       ptr -> multiplier = av.intvalue;
12407       ptr -> OBbits__ |= 1<<0;
12408       atp = AsnReadId(aip,amp, atp);
12409    }
12410    if (atp == DELTA_ITEM_multiplier_fuzz) {
12411       ptr -> multiplier_fuzz = IntFuzzAsnRead(aip, atp);
12412       if (aip -> io_failure) {
12413          goto erret;
12414       }
12415       atp = AsnReadId(aip,amp, atp);
12416    }
12417    if (atp == DELTA_ITEM_action) {
12418       if ( AsnReadVal(aip, atp, &av) <= 0) {
12419          goto erret;
12420       }
12421       ptr -> action = av.intvalue;
12422       atp = AsnReadId(aip,amp, atp);
12423    }
12424 
12425    if (AsnReadVal(aip, atp, &av) <= 0) {
12426       goto erret;
12427    }
12428    /* end struct */
12429 
12430 ret:
12431    AsnUnlinkType(orig);       /* unlink local tree */
12432    return ptr;
12433 
12434 erret:
12435    aip -> io_failure = TRUE;
12436    ptr = DeltaItemFree(ptr);
12437    goto ret;
12438 }
12439 
12440 
12441 
12442 /**************************************************
12443 *
12444 *    Seq_seqAsnRead()
12445 *
12446 **************************************************/
12447 NLM_EXTERN
12448 Seq_seqPtr LIBCALL
Seq_seqAsnRead(AsnIoPtr aip,AsnTypePtr orig)12449 Seq_seqAsnRead(AsnIoPtr aip, AsnTypePtr orig)
12450 {
12451    DataVal av;
12452    AsnTypePtr atp;
12453    ValNodePtr anp;
12454    Uint1 choice = 0;
12455    Boolean nullIsError = FALSE;
12456    AsnReadFunc func;
12457 
12458    if (! loaded)
12459    {
12460       if (! SeqFeatAsnLoad()) {
12461          return NULL;
12462       }
12463    }
12464 
12465    if (aip == NULL) {
12466       return NULL;
12467    }
12468 
12469    if (orig == NULL) {         /* Seq_seq ::= (self contained) */
12470       atp = AsnReadId(aip, amp, DELTA_ITEM_seq);
12471    } else {
12472       atp = AsnLinkType(orig, DELTA_ITEM_seq);    /* link in local tree */
12473    }
12474    if (atp == NULL) {
12475       return NULL;
12476    }
12477 
12478    anp = ValNodeNew(NULL);
12479    if (anp == NULL) {
12480       goto erret;
12481    }
12482    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
12483       goto erret;
12484    }
12485 
12486    func = NULL;
12487 
12488    atp = AsnReadId(aip, amp, atp);  /* find the choice */
12489    if (atp == NULL) {
12490       goto erret;
12491    }
12492    if (atp == DELTA_ITEM_seq_literal) {
12493       choice = Seq_seq_literal;
12494       func = (AsnReadFunc) SeqLitAsnRead;
12495    }
12496    else if (atp == DELTA_ITEM_seq_loc) {
12497       choice = Seq_seq_loc;
12498       func = (AsnReadFunc) SeqLocAsnRead;
12499    }
12500    else if (atp == DELTA_ITEM_seq_this) {
12501       choice = Seq_seq_this__;
12502       if (AsnReadVal(aip, atp, &av) <= 0) {
12503          goto erret;
12504       }
12505       anp->data.boolvalue = av.boolvalue;
12506    }
12507    anp->choice = choice;
12508    if (func != NULL)
12509    {
12510       anp->data.ptrvalue = (* func)(aip, atp);
12511       if (aip -> io_failure) goto erret;
12512 
12513       if (nullIsError && anp->data.ptrvalue == NULL) {
12514          goto erret;
12515       }
12516    }
12517 
12518 ret:
12519    AsnUnlinkType(orig);       /* unlink local tree */
12520    return anp;
12521 
12522 erret:
12523    anp = MemFree(anp);
12524    aip -> io_failure = TRUE;
12525    goto ret;
12526 }
12527 
12528 
12529 /**************************************************
12530 *
12531 *    DeltaItemAsnWrite()
12532 *
12533 **************************************************/
12534 NLM_EXTERN Boolean LIBCALL
DeltaItemAsnWrite(DeltaItemPtr ptr,AsnIoPtr aip,AsnTypePtr orig)12535 DeltaItemAsnWrite(DeltaItemPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
12536 {
12537    DataVal av;
12538    AsnTypePtr atp;
12539    Boolean retval = FALSE;
12540 
12541    if (! loaded)
12542    {
12543       if (! SeqFeatAsnLoad()) {
12544          return FALSE;
12545       }
12546    }
12547 
12548    if (aip == NULL) {
12549       return FALSE;
12550    }
12551 
12552    atp = AsnLinkType(orig, DELTA_ITEM);   /* link local tree */
12553    if (atp == NULL) {
12554       return FALSE;
12555    }
12556 
12557    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
12558 
12559     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
12560 
12561    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
12562       goto erret;
12563    }
12564 
12565    if (ptr -> Seq_seq != NULL) {
12566       if ( ! Seq_seqAsnWrite(ptr -> Seq_seq, aip, DELTA_ITEM_seq)) {
12567          goto erret;
12568       }
12569    }
12570    if (ptr -> multiplier || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> multiplier;
12571       retval = AsnWrite(aip, DELTA_ITEM_multiplier,  &av);
12572    }
12573    if (ptr -> multiplier_fuzz != NULL) {
12574       if ( ! IntFuzzAsnWrite(ptr -> multiplier_fuzz, aip, DELTA_ITEM_multiplier_fuzz)) {
12575          goto erret;
12576       }
12577    }
12578    if (ptr -> action != 0) {
12579       av.intvalue = ptr -> action;
12580       retval = AsnWrite(aip, DELTA_ITEM_action,  &av);
12581    }
12582    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
12583       goto erret;
12584    }
12585    retval = TRUE;
12586 
12587 erret:
12588    AsnUnlinkType(orig);       /* unlink local tree */
12589    return retval;
12590 }
12591 
12592 
12593 
12594 /**************************************************
12595 *
12596 *    Seq_seqAsnWrite()
12597 *
12598 **************************************************/
12599 NLM_EXTERN Boolean LIBCALL
Seq_seqAsnWrite(Seq_seqPtr anp,AsnIoPtr aip,AsnTypePtr orig)12600 Seq_seqAsnWrite(Seq_seqPtr anp, AsnIoPtr aip, AsnTypePtr orig)
12601 
12602 {
12603    DataVal av;
12604    AsnTypePtr atp, writetype = NULL;
12605    Pointer pnt;
12606    AsnWriteFunc func = NULL;
12607    Boolean retval = FALSE;
12608 
12609    if (! loaded)
12610    {
12611       if (! SeqFeatAsnLoad())
12612       return FALSE;
12613    }
12614 
12615    if (aip == NULL)
12616    return FALSE;
12617 
12618    atp = AsnLinkType(orig, DELTA_ITEM_seq);   /* link local tree */
12619    if (atp == NULL) {
12620       return FALSE;
12621    }
12622 
12623    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
12624 
12625     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
12626 
12627    av.ptrvalue = (Pointer)anp;
12628    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
12629       goto erret;
12630    }
12631 
12632    pnt = anp->data.ptrvalue;
12633    switch (anp->choice)
12634    {
12635    case Seq_seq_literal:
12636       writetype = DELTA_ITEM_seq_literal;
12637       func = (AsnWriteFunc) SeqLitAsnWrite;
12638       break;
12639    case Seq_seq_loc:
12640       writetype = DELTA_ITEM_seq_loc;
12641       func = (AsnWriteFunc) SeqLocAsnWrite;
12642       break;
12643    case Seq_seq_this__:
12644       av.boolvalue = anp->data.boolvalue;
12645       retval = AsnWrite(aip, DELTA_ITEM_seq_this, &av);
12646       break;
12647    }
12648    if (writetype != NULL) {
12649       retval = (* func)(pnt, aip, writetype);   /* write it out */
12650    }
12651    if (!retval) {
12652       goto erret;
12653    }
12654    retval = TRUE;
12655 
12656 erret:
12657    AsnUnlinkType(orig);       /* unlink local tree */
12658    return retval;
12659 }
12660 
12661