1 /*  objmime.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:  objmime.c
27 *
28 * Modifications:
29 * --------------------------------------------------------------------------
30 * Date     Name        Description of modification
31 * -------  ----------  -----------------------------------------------------
32 *
33 * $Log: objmime.c,v $
34 * Revision 6.16  2015/10/23 00:04:24  kans
35 * NOIJRA Clear av DataVal variable on AsnWrite, needed for supporting Int8 integers in ASN.1
36 *
37 * Revision 6.15  2006/07/13 17:03:19  bollin
38 * removed unused variables
39 *
40 * Revision 6.14  2002/08/23 20:35:34  thiessen
41 * fix wrong user_annotations symbols
42 *
43 * Revision 6.13  2002/02/27 15:53:37  thiessen
44 * fix typo
45 *
46 * Revision 6.12  2002/02/26 13:21:21  thiessen
47 * add structure type to new general mime
48 *
49 * Revision 6.11  2001/11/21 16:38:23  thiessen
50 * move cn3d stuff into bundle
51 *
52 * Revision 6.10  2001/11/21 14:25:41  thiessen
53 * remove BisotrucOrId
54 *
55 * Revision 6.9  2001/11/20 15:59:34  thiessen
56 * add imports to BundleSeqsAligns
57 *
58 * Revision 6.8  2001/11/16 14:54:26  thiessen
59 * add new general type
60 *
61 * Revision 6.7  2001/06/21 14:44:29  thiessen
62 * add new user annotations
63 *
64 * Revision 6.6  2001/06/14 14:21:32  thiessen
65 * add style dictionary to mime blobs
66 *
67 * Revision 6.5  1999/09/16 17:12:02  ywang
68 * use SeqAnnotSetAsnRead/Write to replace AsnGenericUserSeqOfAsnRead/Write to remove problem with seqannotset
69 *
70  * Revision 6.4  1998/12/07  16:29:28  ywang
71  * add object loaded for mime type Biostruc-seqs
72  *
73 * ==========================================================================
74 */
75 
76 #include <asn.h>
77 
78 #define NLM_GENERATED_CODE_PROTO
79 
80 /* hand change add include --- lyg */
81 #include <mapmime.h>
82 #include <objmime.h>
83 
84 static Boolean loaded = FALSE;
85 
86 /*hand change from ncbimime.h -- lyg & yanli */
87 #include <asnmime.h>
88 
89 #ifndef NLM_EXTERN_LOADS
90 #define NLM_EXTERN_LOADS {}
91 #endif
92 
93 NLM_EXTERN Boolean LIBCALL
objmimeAsnLoad(void)94 objmimeAsnLoad(void)
95 {
96 
97    if ( ! loaded) {
98       NLM_EXTERN_LOADS
99 
100       if ( ! AsnLoad ())
101       return FALSE;
102       loaded = TRUE;
103    }
104 
105    return TRUE;
106 }
107 
108 
109 
110 /**************************************************
111 *    Generated object loaders for Module NCBI-Mime
112 *    Generated using ASNCODE Revision: 6.5 at Dec 4, 1998  2:11 PM
113 *
114 **************************************************/
115 
116 
117 /**************************************************
118 *
119 *    NcbiMimeAsn1Free()
120 *
121 **************************************************/
122 NLM_EXTERN
123 NcbiMimeAsn1Ptr LIBCALL
NcbiMimeAsn1Free(ValNodePtr anp)124 NcbiMimeAsn1Free(ValNodePtr anp)
125 {
126    Pointer pnt;
127 
128    if (anp == NULL) {
129       return NULL;
130    }
131 
132    pnt = anp->data.ptrvalue;
133    switch (anp->choice)
134    {
135    default:
136       break;
137    case NcbiMimeAsn1_entrez:
138       EntrezGeneralFree(anp -> data.ptrvalue);
139       break;
140    case NcbiMimeAsn1_alignstruc:
141       BiostrucAlignFree(anp -> data.ptrvalue);
142       break;
143    case NcbiMimeAsn1_alignseq:
144       BiostrucAlignSeqFree(anp -> data.ptrvalue);
145       break;
146    case NcbiMimeAsn1_strucseq:
147       BiostrucSeqFree(anp -> data.ptrvalue);
148       break;
149    case NcbiMimeAsn1_strucseqs:
150       BiostrucSeqsFree(anp -> data.ptrvalue);
151       break;
152    case NcbiMimeAsn1_general:
153       BiostrucSeqsAlignsCddFree(anp -> data.ptrvalue);
154       break;
155    }
156    return MemFree(anp);
157 }
158 
159 
160 /**************************************************
161 *
162 *    NcbiMimeAsn1AsnRead()
163 *
164 **************************************************/
165 NLM_EXTERN
166 NcbiMimeAsn1Ptr LIBCALL
NcbiMimeAsn1AsnRead(AsnIoPtr aip,AsnTypePtr orig)167 NcbiMimeAsn1AsnRead(AsnIoPtr aip, AsnTypePtr orig)
168 {
169    DataVal av;
170    AsnTypePtr atp;
171    ValNodePtr anp;
172    Uint1 choice;
173    Boolean isError = FALSE;
174    Boolean nullIsError = FALSE;
175    AsnReadFunc func;
176 
177    if (! loaded)
178    {
179       if (! objmimeAsnLoad()) {
180          return NULL;
181       }
182    }
183 
184    if (aip == NULL) {
185       return NULL;
186    }
187 
188    if (orig == NULL) {         /* NcbiMimeAsn1 ::= (self contained) */
189       atp = AsnReadId(aip, amp, NCBI_MIME_ASN1);
190    } else {
191       atp = AsnLinkType(orig, NCBI_MIME_ASN1);    /* link in local tree */
192    }
193    if (atp == NULL) {
194       return NULL;
195    }
196 
197    anp = ValNodeNew(NULL);
198    if (anp == NULL) {
199       goto erret;
200    }
201    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
202       goto erret;
203    }
204 
205    func = NULL;
206 
207    atp = AsnReadId(aip, amp, atp);  /* find the choice */
208    if (atp == NULL) {
209       goto erret;
210    }
211    if (atp == NCBI_MIME_ASN1_entrez) {
212       choice = NcbiMimeAsn1_entrez;
213       func = (AsnReadFunc) EntrezGeneralAsnRead;
214    }
215    else if (atp == NCBI_MIME_ASN1_alignstruc) {
216       choice = NcbiMimeAsn1_alignstruc;
217       func = (AsnReadFunc) BiostrucAlignAsnRead;
218    }
219    else if (atp == NCBI_MIME_ASN1_alignseq) {
220       choice = NcbiMimeAsn1_alignseq;
221       func = (AsnReadFunc) BiostrucAlignSeqAsnRead;
222    }
223    else if (atp == NCBI_MIME_ASN1_strucseq) {
224       choice = NcbiMimeAsn1_strucseq;
225       func = (AsnReadFunc) BiostrucSeqAsnRead;
226    }
227    else if (atp == NCBI_MIME_ASN1_strucseqs) {
228       choice = NcbiMimeAsn1_strucseqs;
229       func = (AsnReadFunc) BiostrucSeqsAsnRead;
230    }
231    else if (atp == NCBI_MIME_ASN1_general) {
232       choice = NcbiMimeAsn1_general;
233       func = (AsnReadFunc) BiostrucSeqsAlignsCddAsnRead;
234    }
235    anp->choice = choice;
236    if (func != NULL)
237    {
238       anp->data.ptrvalue = (* func)(aip, atp);
239       if (aip -> io_failure) goto erret;
240 
241       if (nullIsError && anp->data.ptrvalue == NULL) {
242          goto erret;
243       }
244    }
245 
246 ret:
247    AsnUnlinkType(orig);       /* unlink local tree */
248    return anp;
249 
250 erret:
251    anp = MemFree(anp);
252    aip -> io_failure = TRUE;
253    goto ret;
254 }
255 
256 
257 /**************************************************
258 *
259 *    NcbiMimeAsn1AsnWrite()
260 *
261 **************************************************/
262 NLM_EXTERN Boolean LIBCALL
NcbiMimeAsn1AsnWrite(NcbiMimeAsn1Ptr anp,AsnIoPtr aip,AsnTypePtr orig)263 NcbiMimeAsn1AsnWrite(NcbiMimeAsn1Ptr anp, AsnIoPtr aip, AsnTypePtr orig)
264 
265 {
266    DataVal av;
267    AsnTypePtr atp, writetype = NULL;
268    Pointer pnt;
269    AsnWriteFunc func = NULL;
270    Boolean retval = FALSE;
271 
272    if (! loaded)
273    {
274       if (! objmimeAsnLoad())
275       return FALSE;
276    }
277 
278    if (aip == NULL)
279    return FALSE;
280 
281    atp = AsnLinkType(orig, NCBI_MIME_ASN1);   /* link local tree */
282    if (atp == NULL) {
283       return FALSE;
284    }
285 
286    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
287 
288     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
289 
290    av.ptrvalue = (Pointer)anp;
291    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
292       goto erret;
293    }
294 
295    pnt = anp->data.ptrvalue;
296    switch (anp->choice)
297    {
298    case NcbiMimeAsn1_entrez:
299       writetype = NCBI_MIME_ASN1_entrez;
300       func = (AsnWriteFunc) EntrezGeneralAsnWrite;
301       break;
302    case NcbiMimeAsn1_alignstruc:
303       writetype = NCBI_MIME_ASN1_alignstruc;
304       func = (AsnWriteFunc) BiostrucAlignAsnWrite;
305       break;
306    case NcbiMimeAsn1_alignseq:
307       writetype = NCBI_MIME_ASN1_alignseq;
308       func = (AsnWriteFunc) BiostrucAlignSeqAsnWrite;
309       break;
310    case NcbiMimeAsn1_strucseq:
311       writetype = NCBI_MIME_ASN1_strucseq;
312       func = (AsnWriteFunc) BiostrucSeqAsnWrite;
313       break;
314    case NcbiMimeAsn1_strucseqs:
315       writetype = NCBI_MIME_ASN1_strucseqs;
316       func = (AsnWriteFunc) BiostrucSeqsAsnWrite;
317       break;
318    case NcbiMimeAsn1_general:
319       writetype = NCBI_MIME_ASN1_general;
320       func = (AsnWriteFunc) BiostrucSeqsAlignsCddAsnWrite;
321       break;
322    }
323    if (writetype != NULL) {
324       retval = (* func)(pnt, aip, writetype);   /* write it out */
325    }
326    if (!retval) {
327       goto erret;
328    }
329    retval = TRUE;
330 
331 erret:
332    AsnUnlinkType(orig);       /* unlink local tree */
333    return retval;
334 }
335 
336 
337 /**************************************************
338 *
339 *    EntrezGeneralNew()
340 *
341 **************************************************/
342 NLM_EXTERN
343 EntrezGeneralPtr LIBCALL
EntrezGeneralNew(void)344 EntrezGeneralNew(void)
345 {
346    EntrezGeneralPtr ptr = MemNew((size_t) sizeof(EntrezGeneral));
347 
348    return ptr;
349 
350 }
351 
352 
353 /**************************************************
354 *
355 *    EntrezGeneralFree()
356 *
357 **************************************************/
358 NLM_EXTERN
359 EntrezGeneralPtr LIBCALL
EntrezGeneralFree(EntrezGeneralPtr ptr)360 EntrezGeneralFree(EntrezGeneralPtr ptr)
361 {
362 
363    if(ptr == NULL) {
364       return NULL;
365    }
366    MemFree(ptr -> title);
367    Data_dataFree(ptr -> Data_data);
368    MemFree(ptr -> location);
369    return MemFree(ptr);
370 }
371 
372 
373 /**************************************************
374 *
375 *    Data_dataFree()
376 *
377 **************************************************/
378 static
379 Data_dataPtr LIBCALL
Data_dataFree(ValNodePtr anp)380 Data_dataFree(ValNodePtr anp)
381 {
382    Pointer pnt;
383 
384    if (anp == NULL) {
385       return NULL;
386    }
387 
388    pnt = anp->data.ptrvalue;
389    switch (anp->choice)
390    {
391    default:
392       break;
393    case Data_data_ml:
394       MedlineEntryFree(anp -> data.ptrvalue);
395       break;
396    case Data_data_prot:
397       SeqEntryFree(anp -> data.ptrvalue);
398       break;
399    case Data_data_nuc:
400       SeqEntryFree(anp -> data.ptrvalue);
401       break;
402    case Data_data_genome:
403       SeqEntryFree(anp -> data.ptrvalue);
404       break;
405    case Data_data_structure:
406       BiostrucFree(anp -> data.ptrvalue);
407       break;
408    case Data_data_strucAnnot:
409       BiostrucAnnotSetFree(anp -> data.ptrvalue);
410       break;
411    }
412    return MemFree(anp);
413 }
414 
415 
416 /**************************************************
417 *
418 *    EntrezGeneralAsnRead()
419 *
420 **************************************************/
421 NLM_EXTERN
422 EntrezGeneralPtr LIBCALL
EntrezGeneralAsnRead(AsnIoPtr aip,AsnTypePtr orig)423 EntrezGeneralAsnRead(AsnIoPtr aip, AsnTypePtr orig)
424 {
425    DataVal av;
426    AsnTypePtr atp;
427    Boolean isError = FALSE;
428    AsnReadFunc func;
429    EntrezGeneralPtr ptr;
430 
431    if (! loaded)
432    {
433       if (! objmimeAsnLoad()) {
434          return NULL;
435       }
436    }
437 
438    if (aip == NULL) {
439       return NULL;
440    }
441 
442    if (orig == NULL) {         /* EntrezGeneral ::= (self contained) */
443       atp = AsnReadId(aip, amp, ENTREZ_GENERAL);
444    } else {
445       atp = AsnLinkType(orig, ENTREZ_GENERAL);
446    }
447    /* link in local tree */
448    if (atp == NULL) {
449       return NULL;
450    }
451 
452    ptr = EntrezGeneralNew();
453    if (ptr == NULL) {
454       goto erret;
455    }
456    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
457       goto erret;
458    }
459 
460    atp = AsnReadId(aip,amp, atp);
461    func = NULL;
462 
463    if (atp == ENTREZ_GENERAL_title) {
464       if ( AsnReadVal(aip, atp, &av) <= 0) {
465          goto erret;
466       }
467       ptr -> title = av.ptrvalue;
468       atp = AsnReadId(aip,amp, atp);
469    }
470    if (atp == ENTREZ_GENERAL_data) {
471       ptr -> Data_data = Data_dataAsnRead(aip, atp);
472       if (aip -> io_failure) {
473          goto erret;
474       }
475       atp = AsnReadId(aip,amp, atp);
476    }
477    if (atp == ENTREZ_GENERAL_style) {
478       if ( AsnReadVal(aip, atp, &av) <= 0) {
479          goto erret;
480       }
481       ptr -> style = av.intvalue;
482       atp = AsnReadId(aip,amp, atp);
483    }
484    if (atp == ENTREZ_GENERAL_location) {
485       if ( AsnReadVal(aip, atp, &av) <= 0) {
486          goto erret;
487       }
488       ptr -> location = av.ptrvalue;
489       atp = AsnReadId(aip,amp, atp);
490    }
491 
492    if (AsnReadVal(aip, atp, &av) <= 0) {
493       goto erret;
494    }
495    /* end struct */
496 
497 ret:
498    AsnUnlinkType(orig);       /* unlink local tree */
499    return ptr;
500 
501 erret:
502    aip -> io_failure = TRUE;
503    ptr = EntrezGeneralFree(ptr);
504    goto ret;
505 }
506 
507 
508 
509 /**************************************************
510 *
511 *    Data_dataAsnRead()
512 *
513 **************************************************/
514 static
515 Data_dataPtr LIBCALL
Data_dataAsnRead(AsnIoPtr aip,AsnTypePtr orig)516 Data_dataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
517 {
518    DataVal av;
519    AsnTypePtr atp;
520    ValNodePtr anp;
521    Uint1 choice;
522    Boolean isError = FALSE;
523    Boolean nullIsError = FALSE;
524    AsnReadFunc func;
525 
526    if (! loaded)
527    {
528       if (! objmimeAsnLoad()) {
529          return NULL;
530       }
531    }
532 
533    if (aip == NULL) {
534       return NULL;
535    }
536 
537    if (orig == NULL) {         /* Data_data ::= (self contained) */
538       atp = AsnReadId(aip, amp, ENTREZ_GENERAL_data);
539    } else {
540       atp = AsnLinkType(orig, ENTREZ_GENERAL_data);    /* link in local tree */
541    }
542    if (atp == NULL) {
543       return NULL;
544    }
545 
546    anp = ValNodeNew(NULL);
547    if (anp == NULL) {
548       goto erret;
549    }
550    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
551       goto erret;
552    }
553 
554    func = NULL;
555 
556    atp = AsnReadId(aip, amp, atp);  /* find the choice */
557    if (atp == NULL) {
558       goto erret;
559    }
560    if (atp == ENTREZ_GENERAL_data_ml) {
561       choice = Data_data_ml;
562       func = (AsnReadFunc) MedlineEntryAsnRead;
563    }
564    else if (atp == ENTREZ_GENERAL_data_prot) {
565       choice = Data_data_prot;
566       func = (AsnReadFunc) SeqEntryAsnRead;
567    }
568    else if (atp == ENTREZ_GENERAL_data_nuc) {
569       choice = Data_data_nuc;
570       func = (AsnReadFunc) SeqEntryAsnRead;
571    }
572    else if (atp == ENTREZ_GENERAL_data_genome) {
573       choice = Data_data_genome;
574       func = (AsnReadFunc) SeqEntryAsnRead;
575    }
576    else if (atp == ENTREZ_GENERAL_data_structure) {
577       choice = Data_data_structure;
578       func = (AsnReadFunc) BiostrucAsnRead;
579    }
580    else if (atp == ENTREZ_GENERAL_data_strucAnnot) {
581       choice = Data_data_strucAnnot;
582       func = (AsnReadFunc) BiostrucAnnotSetAsnRead;
583    }
584    anp->choice = choice;
585    if (func != NULL)
586    {
587       anp->data.ptrvalue = (* func)(aip, atp);
588       if (aip -> io_failure) goto erret;
589 
590       if (nullIsError && anp->data.ptrvalue == NULL) {
591          goto erret;
592       }
593    }
594 
595 ret:
596    AsnUnlinkType(orig);       /* unlink local tree */
597    return anp;
598 
599 erret:
600    anp = MemFree(anp);
601    aip -> io_failure = TRUE;
602    goto ret;
603 }
604 
605 
606 /**************************************************
607 *
608 *    EntrezGeneralAsnWrite()
609 *
610 **************************************************/
611 NLM_EXTERN Boolean LIBCALL
EntrezGeneralAsnWrite(EntrezGeneralPtr ptr,AsnIoPtr aip,AsnTypePtr orig)612 EntrezGeneralAsnWrite(EntrezGeneralPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
613 {
614    DataVal av;
615    AsnTypePtr atp;
616    Boolean retval = FALSE;
617 
618    if (! loaded)
619    {
620       if (! objmimeAsnLoad()) {
621          return FALSE;
622       }
623    }
624 
625    if (aip == NULL) {
626       return FALSE;
627    }
628 
629    atp = AsnLinkType(orig, ENTREZ_GENERAL);   /* link local tree */
630    if (atp == NULL) {
631       return FALSE;
632    }
633 
634    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
635 
636     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
637 
638    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
639       goto erret;
640    }
641 
642    if (ptr -> title != NULL) {
643       av.ptrvalue = ptr -> title;
644       retval = AsnWrite(aip, ENTREZ_GENERAL_title,  &av);
645    }
646    if (ptr -> Data_data != NULL) {
647       if ( ! Data_dataAsnWrite(ptr -> Data_data, aip, ENTREZ_GENERAL_data)) {
648          goto erret;
649       }
650    }
651    av.intvalue = ptr -> style;
652    retval = AsnWrite(aip, ENTREZ_GENERAL_style,  &av);
653    if (ptr -> location != NULL) {
654       av.ptrvalue = ptr -> location;
655       retval = AsnWrite(aip, ENTREZ_GENERAL_location,  &av);
656    }
657    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
658       goto erret;
659    }
660    retval = TRUE;
661 
662 erret:
663    AsnUnlinkType(orig);       /* unlink local tree */
664    return retval;
665 }
666 
667 
668 
669 /**************************************************
670 *
671 *    Data_dataAsnWrite()
672 *
673 **************************************************/
674 static Boolean LIBCALL
Data_dataAsnWrite(Data_dataPtr anp,AsnIoPtr aip,AsnTypePtr orig)675 Data_dataAsnWrite(Data_dataPtr anp, AsnIoPtr aip, AsnTypePtr orig)
676 
677 {
678    DataVal av;
679    AsnTypePtr atp, writetype = NULL;
680    Pointer pnt;
681    AsnWriteFunc func = NULL;
682    Boolean retval = FALSE;
683 
684    if (! loaded)
685    {
686       if (! objmimeAsnLoad())
687       return FALSE;
688    }
689 
690    if (aip == NULL)
691    return FALSE;
692 
693    atp = AsnLinkType(orig, ENTREZ_GENERAL_data);   /* link local tree */
694    if (atp == NULL) {
695       return FALSE;
696    }
697 
698    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
699 
700     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
701 
702    av.ptrvalue = (Pointer)anp;
703    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
704       goto erret;
705    }
706 
707    pnt = anp->data.ptrvalue;
708    switch (anp->choice)
709    {
710    case Data_data_ml:
711       writetype = ENTREZ_GENERAL_data_ml;
712       func = (AsnWriteFunc) MedlineEntryAsnWrite;
713       break;
714    case Data_data_prot:
715       writetype = ENTREZ_GENERAL_data_prot;
716       func = (AsnWriteFunc) SeqEntryAsnWrite;
717       break;
718    case Data_data_nuc:
719       writetype = ENTREZ_GENERAL_data_nuc;
720       func = (AsnWriteFunc) SeqEntryAsnWrite;
721       break;
722    case Data_data_genome:
723       writetype = ENTREZ_GENERAL_data_genome;
724       func = (AsnWriteFunc) SeqEntryAsnWrite;
725       break;
726    case Data_data_structure:
727       writetype = ENTREZ_GENERAL_data_structure;
728       func = (AsnWriteFunc) BiostrucAsnWrite;
729       break;
730    case Data_data_strucAnnot:
731       writetype = ENTREZ_GENERAL_data_strucAnnot;
732       func = (AsnWriteFunc) BiostrucAnnotSetAsnWrite;
733       break;
734    }
735    if (writetype != NULL) {
736       retval = (* func)(pnt, aip, writetype);   /* write it out */
737    }
738    if (!retval) {
739       goto erret;
740    }
741    retval = TRUE;
742 
743 erret:
744    AsnUnlinkType(orig);       /* unlink local tree */
745    return retval;
746 }
747 
748 
749 /**************************************************
750 *
751 *    BiostrucAlignNew()
752 *
753 **************************************************/
754 NLM_EXTERN
755 BiostrucAlignPtr LIBCALL
BiostrucAlignNew(void)756 BiostrucAlignNew(void)
757 {
758    BiostrucAlignPtr ptr = MemNew((size_t) sizeof(BiostrucAlign));
759 
760    return ptr;
761 
762 }
763 
764 
765 /**************************************************
766 *
767 *    BiostrucAlignFree()
768 *
769 **************************************************/
770 NLM_EXTERN
771 BiostrucAlignPtr LIBCALL
BiostrucAlignFree(BiostrucAlignPtr ptr)772 BiostrucAlignFree(BiostrucAlignPtr ptr)
773 {
774 
775    if(ptr == NULL) {
776       return NULL;
777    }
778    BiostrucFree(ptr -> master);
779    AsnGenericUserSeqOfFree(ptr -> slaves, (AsnOptFreeFunc) BiostrucFree);
780    BiostrucAnnotSetFree(ptr -> alignments);
781    AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree);
782    AsnGenericUserSeqOfFree(ptr -> seqalign, (AsnOptFreeFunc) SeqAnnotFree);
783    Cn3dStyleDictionaryFree(ptr -> style_dictionary); /* paul */
784    Cn3dUserAnnotationsFree(ptr -> user_annotations);
785    return MemFree(ptr);
786 }
787 
788 
789 /**************************************************
790 *
791 *    BiostrucAlignAsnRead()
792 *
793 **************************************************/
794 NLM_EXTERN
795 BiostrucAlignPtr LIBCALL
BiostrucAlignAsnRead(AsnIoPtr aip,AsnTypePtr orig)796 BiostrucAlignAsnRead(AsnIoPtr aip, AsnTypePtr orig)
797 {
798    DataVal av;
799    AsnTypePtr atp;
800    Boolean isError = FALSE;
801    AsnReadFunc func;
802    BiostrucAlignPtr ptr;
803 
804    if (! loaded)
805    {
806       if (! objmimeAsnLoad()) {
807          return NULL;
808       }
809    }
810 
811    if (aip == NULL) {
812       return NULL;
813    }
814 
815    if (orig == NULL) {         /* BiostrucAlign ::= (self contained) */
816       atp = AsnReadId(aip, amp, BIOSTRUC_ALIGN);
817    } else {
818       atp = AsnLinkType(orig, BIOSTRUC_ALIGN);
819    }
820    /* link in local tree */
821    if (atp == NULL) {
822       return NULL;
823    }
824 
825    ptr = BiostrucAlignNew();
826    if (ptr == NULL) {
827       goto erret;
828    }
829    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
830       goto erret;
831    }
832 
833    atp = AsnReadId(aip,amp, atp);
834    func = NULL;
835 
836    if (atp == BIOSTRUC_ALIGN_master) {
837       ptr -> master = BiostrucAsnRead(aip, atp);
838       if (aip -> io_failure) {
839          goto erret;
840       }
841       atp = AsnReadId(aip,amp, atp);
842    }
843    if (atp == BIOSTRUC_ALIGN_slaves) {
844       ptr -> slaves = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucAsnRead, (AsnOptFreeFunc) BiostrucFree);
845       if (isError && ptr -> slaves == NULL) {
846          goto erret;
847       }
848       atp = AsnReadId(aip,amp, atp);
849    }
850    if (atp == BIOSTRUC_ALIGN_alignments) {
851       ptr -> alignments = BiostrucAnnotSetAsnRead(aip, atp);
852       if (aip -> io_failure) {
853          goto erret;
854       }
855       atp = AsnReadId(aip,amp, atp);
856    }
857    if (atp == BIOSTRUC_ALIGN_sequences) {
858       ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree);
859       if (isError && ptr -> sequences == NULL) {
860          goto erret;
861       }
862       atp = AsnReadId(aip,amp, atp);
863    }
864    if (atp == BIOSTRUC_ALIGN_seqalign) {
865 /*    ptr -> seqalign = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
866       if (isError && ptr -> seqalign == NULL) {
867          goto erret;
868       }  */   /* yanli comment this out, add the following, Sept. 16, 1999 */
869       ptr -> seqalign = SeqAnnotSetAsnRead(aip, BIOSTRUC_ALIGN_seqalign, BIOSTRUC_ALIGN_seqalign_E);
870       atp = AsnReadId(aip,amp, atp);
871    }
872    /* paul */
873    if (atp == BIOSTRUC_ALIGN_style_dictionary) {
874       ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp);
875       if (aip -> io_failure) {
876          goto erret;
877       }
878       atp = AsnReadId(aip,amp, atp);
879    }
880    if (atp == BIOSTRUC_ALIGN_user_annotations) {
881       ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp);
882       if (aip -> io_failure) {
883          goto erret;
884       }
885       atp = AsnReadId(aip,amp, atp);
886    }
887 
888    if (AsnReadVal(aip, atp, &av) <= 0) {
889       goto erret;
890    }
891    /* end struct */
892 
893 ret:
894    AsnUnlinkType(orig);       /* unlink local tree */
895    return ptr;
896 
897 erret:
898    aip -> io_failure = TRUE;
899    ptr = BiostrucAlignFree(ptr);
900    goto ret;
901 }
902 
903 
904 
905 /**************************************************
906 *
907 *    BiostrucAlignAsnWrite()
908 *
909 **************************************************/
910 NLM_EXTERN Boolean LIBCALL
BiostrucAlignAsnWrite(BiostrucAlignPtr ptr,AsnIoPtr aip,AsnTypePtr orig)911 BiostrucAlignAsnWrite(BiostrucAlignPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
912 {
913    AsnTypePtr atp;
914    Boolean retval = FALSE;
915 
916    if (! loaded)
917    {
918       if (! objmimeAsnLoad()) {
919          return FALSE;
920       }
921    }
922 
923    if (aip == NULL) {
924       return FALSE;
925    }
926 
927    atp = AsnLinkType(orig, BIOSTRUC_ALIGN);   /* link local tree */
928    if (atp == NULL) {
929       return FALSE;
930    }
931 
932    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
933 
934    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
935       goto erret;
936    }
937 
938    if (ptr -> master != NULL) {
939       if ( ! BiostrucAsnWrite(ptr -> master, aip, BIOSTRUC_ALIGN_master)) {
940          goto erret;
941       }
942    }
943    AsnGenericUserSeqOfAsnWrite(ptr -> slaves, (AsnWriteFunc) BiostrucAsnWrite, aip, BIOSTRUC_ALIGN_slaves, BIOSTRUC_ALIGN_slaves_E);
944    if (ptr -> alignments != NULL) {
945       if ( ! BiostrucAnnotSetAsnWrite(ptr -> alignments, aip, BIOSTRUC_ALIGN_alignments)) {
946          goto erret;
947       }
948    }
949    AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BIOSTRUC_ALIGN_sequences, BIOSTRUC_ALIGN_sequences_E);
950 
951 /* AsnGenericUserSeqOfAsnWrite(ptr -> seqalign, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BIOSTRUC_ALIGN_seqalign, BIOSTRUC_ALIGN_seqalign_E); */
952        /* yanli comment it out, and add the following, Sept. 16, 1999 */
953    SeqAnnotSetAsnWrite(ptr -> seqalign, aip, BIOSTRUC_ALIGN_seqalign, BIOSTRUC_ALIGN_seqalign_E);
954    /* paul */
955    if (ptr -> style_dictionary != NULL) {
956       if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, BIOSTRUC_ALIGN_style_dictionary)) {
957          goto erret;
958       }
959    }
960    if (ptr -> user_annotations != NULL) {
961       if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, BIOSTRUC_ALIGN_user_annotations)) {
962          goto erret;
963       }
964    }
965 
966    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
967       goto erret;
968    }
969    retval = TRUE;
970 
971 erret:
972    AsnUnlinkType(orig);       /* unlink local tree */
973    return retval;
974 }
975 
976 
977 
978 /**************************************************
979 *
980 *    BiostrucAlignSeqNew()
981 *
982 **************************************************/
983 NLM_EXTERN
984 BiostrucAlignSeqPtr LIBCALL
BiostrucAlignSeqNew(void)985 BiostrucAlignSeqNew(void)
986 {
987    BiostrucAlignSeqPtr ptr = MemNew((size_t) sizeof(BiostrucAlignSeq));
988 
989    return ptr;
990 
991 }
992 
993 
994 /**************************************************
995 *
996 *    BiostrucAlignSeqFree()
997 *
998 **************************************************/
999 NLM_EXTERN
1000 BiostrucAlignSeqPtr LIBCALL
BiostrucAlignSeqFree(BiostrucAlignSeqPtr ptr)1001 BiostrucAlignSeqFree(BiostrucAlignSeqPtr ptr)
1002 {
1003 
1004    if(ptr == NULL) {
1005       return NULL;
1006    }
1007    AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree);
1008    AsnGenericUserSeqOfFree(ptr -> seqalign, (AsnOptFreeFunc) SeqAnnotFree);
1009    Cn3dStyleDictionaryFree(ptr -> style_dictionary); /* paul */
1010    Cn3dUserAnnotationsFree(ptr -> user_annotations);
1011    return MemFree(ptr);
1012 }
1013 
1014 
1015 /**************************************************
1016 *
1017 *    BiostrucAlignSeqAsnRead()
1018 *
1019 **************************************************/
1020 NLM_EXTERN
1021 BiostrucAlignSeqPtr LIBCALL
BiostrucAlignSeqAsnRead(AsnIoPtr aip,AsnTypePtr orig)1022 BiostrucAlignSeqAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1023 {
1024    DataVal av;
1025    AsnTypePtr atp;
1026    Boolean isError = FALSE;
1027    AsnReadFunc func;
1028    BiostrucAlignSeqPtr ptr;
1029 
1030    if (! loaded)
1031    {
1032       if (! objmimeAsnLoad()) {
1033          return NULL;
1034       }
1035    }
1036 
1037    if (aip == NULL) {
1038       return NULL;
1039    }
1040 
1041    if (orig == NULL) {         /* BiostrucAlignSeq ::= (self contained) */
1042       atp = AsnReadId(aip, amp, BIOSTRUC_ALIGN_SEQ);
1043    } else {
1044       atp = AsnLinkType(orig, BIOSTRUC_ALIGN_SEQ);
1045    }
1046    /* link in local tree */
1047    if (atp == NULL) {
1048       return NULL;
1049    }
1050 
1051    ptr = BiostrucAlignSeqNew();
1052    if (ptr == NULL) {
1053       goto erret;
1054    }
1055    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1056       goto erret;
1057    }
1058 
1059    atp = AsnReadId(aip,amp, atp);
1060    func = NULL;
1061 
1062    if (atp == BIOSTRUC_ALIGN_SEQ_sequences) {
1063       ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree);
1064       if (isError && ptr -> sequences == NULL) {
1065          goto erret;
1066       }
1067       atp = AsnReadId(aip,amp, atp);
1068    }
1069    if (atp == BIOSTRUC_ALIGN_SEQ_seqalign) {
1070 /*    ptr -> seqalign = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
1071       if (isError && ptr -> seqalign == NULL) {
1072          goto erret;
1073       }  */ /* yanli comment this out, and add the following, Sept. 16, 1999 */
1074       ptr -> seqalign = SeqAnnotSetAsnRead(aip, BIOSTRUC_ALIGN_SEQ_seqalign, BIOSTRUC_ALIGN_SEQ_seqalign_E);
1075       atp = AsnReadId(aip,amp, atp);
1076    }
1077    /* paul */
1078    if (atp == ALIGN_SEQ_style_dictionary) {
1079       ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp);
1080       if (aip -> io_failure) {
1081          goto erret;
1082       }
1083       atp = AsnReadId(aip,amp, atp);
1084    }
1085    if (atp == ALIGN_SEQ_user_annotations) {
1086       ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp);
1087       if (aip -> io_failure) {
1088          goto erret;
1089       }
1090       atp = AsnReadId(aip,amp, atp);
1091    }
1092 
1093    if (AsnReadVal(aip, atp, &av) <= 0) {
1094       goto erret;
1095    }
1096    /* end struct */
1097 
1098 ret:
1099    AsnUnlinkType(orig);       /* unlink local tree */
1100    return ptr;
1101 
1102 erret:
1103    aip -> io_failure = TRUE;
1104    ptr = BiostrucAlignSeqFree(ptr);
1105    goto ret;
1106 }
1107 
1108 
1109 
1110 /**************************************************
1111 *
1112 *    BiostrucAlignSeqAsnWrite()
1113 *
1114 **************************************************/
1115 NLM_EXTERN Boolean LIBCALL
BiostrucAlignSeqAsnWrite(BiostrucAlignSeqPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1116 BiostrucAlignSeqAsnWrite(BiostrucAlignSeqPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1117 {
1118    AsnTypePtr atp;
1119    Boolean retval = FALSE;
1120 
1121    if (! loaded)
1122    {
1123       if (! objmimeAsnLoad()) {
1124          return FALSE;
1125       }
1126    }
1127 
1128    if (aip == NULL) {
1129       return FALSE;
1130    }
1131 
1132    atp = AsnLinkType(orig, BIOSTRUC_ALIGN_SEQ);   /* link local tree */
1133    if (atp == NULL) {
1134       return FALSE;
1135    }
1136 
1137    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1138 
1139    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1140       goto erret;
1141    }
1142 
1143    AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BIOSTRUC_ALIGN_SEQ_sequences, BIOSTRUC_ALIGN_SEQ_sequences_E);
1144 /* AsnGenericUserSeqOfAsnWrite(ptr -> seqalign, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BIOSTRUC_ALIGN_SEQ_seqalign, BIOSTRUC_ALIGN_SEQ_seqalign_E); */
1145      /* yanli comment it out, and add the following, Sept. 16, 1999 */
1146    SeqAnnotSetAsnWrite(ptr -> seqalign, aip, BIOSTRUC_ALIGN_SEQ_seqalign, BIOSTRUC_ALIGN_SEQ_seqalign_E);
1147    /* paul */
1148    if (ptr -> style_dictionary != NULL) {
1149       if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, ALIGN_SEQ_style_dictionary)) {
1150          goto erret;
1151       }
1152    }
1153    if (ptr -> user_annotations != NULL) {
1154       if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, ALIGN_SEQ_user_annotations)) {
1155          goto erret;
1156       }
1157    }
1158 
1159    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1160       goto erret;
1161    }
1162    retval = TRUE;
1163 
1164 erret:
1165    AsnUnlinkType(orig);       /* unlink local tree */
1166    return retval;
1167 }
1168 
1169 
1170 
1171 /**************************************************
1172 *
1173 *    BiostrucSeqNew()
1174 *
1175 **************************************************/
1176 NLM_EXTERN
1177 BiostrucSeqPtr LIBCALL
BiostrucSeqNew(void)1178 BiostrucSeqNew(void)
1179 {
1180    BiostrucSeqPtr ptr = MemNew((size_t) sizeof(BiostrucSeq));
1181 
1182    return ptr;
1183 
1184 }
1185 
1186 
1187 /**************************************************
1188 *
1189 *    BiostrucSeqFree()
1190 *
1191 **************************************************/
1192 NLM_EXTERN
1193 BiostrucSeqPtr LIBCALL
BiostrucSeqFree(BiostrucSeqPtr ptr)1194 BiostrucSeqFree(BiostrucSeqPtr ptr)
1195 {
1196 
1197    if(ptr == NULL) {
1198       return NULL;
1199    }
1200    BiostrucFree(ptr -> structure);
1201    AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree);
1202    Cn3dStyleDictionaryFree(ptr -> style_dictionary); /* paul */
1203    Cn3dUserAnnotationsFree(ptr -> user_annotations);
1204    return MemFree(ptr);
1205 }
1206 
1207 
1208 /**************************************************
1209 *
1210 *    BiostrucSeqAsnRead()
1211 *
1212 **************************************************/
1213 NLM_EXTERN
1214 BiostrucSeqPtr LIBCALL
BiostrucSeqAsnRead(AsnIoPtr aip,AsnTypePtr orig)1215 BiostrucSeqAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1216 {
1217    DataVal av;
1218    AsnTypePtr atp;
1219    Boolean isError = FALSE;
1220    AsnReadFunc func;
1221    BiostrucSeqPtr ptr;
1222 
1223    if (! loaded)
1224    {
1225       if (! objmimeAsnLoad()) {
1226          return NULL;
1227       }
1228    }
1229 
1230    if (aip == NULL) {
1231       return NULL;
1232    }
1233 
1234    if (orig == NULL) {         /* BiostrucSeq ::= (self contained) */
1235       atp = AsnReadId(aip, amp, BIOSTRUC_SEQ);
1236    } else {
1237       atp = AsnLinkType(orig, BIOSTRUC_SEQ);
1238    }
1239    /* link in local tree */
1240    if (atp == NULL) {
1241       return NULL;
1242    }
1243 
1244    ptr = BiostrucSeqNew();
1245    if (ptr == NULL) {
1246       goto erret;
1247    }
1248    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1249       goto erret;
1250    }
1251 
1252    atp = AsnReadId(aip,amp, atp);
1253    func = NULL;
1254 
1255    if (atp == BIOSTRUC_SEQ_structure) {
1256       ptr -> structure = BiostrucAsnRead(aip, atp);
1257       if (aip -> io_failure) {
1258          goto erret;
1259       }
1260       atp = AsnReadId(aip,amp, atp);
1261    }
1262    if (atp == BIOSTRUC_SEQ_sequences) {
1263       ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree);
1264       if (isError && ptr -> sequences == NULL) {
1265          goto erret;
1266       }
1267       atp = AsnReadId(aip,amp, atp);
1268    }
1269    /* paul */
1270    if (atp == BIOSTRUC_SEQ_style_dictionary) {
1271       ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp);
1272       if (aip -> io_failure) {
1273          goto erret;
1274       }
1275       atp = AsnReadId(aip,amp, atp);
1276    }
1277    if (atp == BIOSTRUC_SEQ_user_annotations) {
1278       ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp);
1279       if (aip -> io_failure) {
1280          goto erret;
1281       }
1282       atp = AsnReadId(aip,amp, atp);
1283    }
1284 
1285    if (AsnReadVal(aip, atp, &av) <= 0) {
1286       goto erret;
1287    }
1288    /* end struct */
1289 
1290 ret:
1291    AsnUnlinkType(orig);       /* unlink local tree */
1292    return ptr;
1293 
1294 erret:
1295    aip -> io_failure = TRUE;
1296    ptr = BiostrucSeqFree(ptr);
1297    goto ret;
1298 }
1299 
1300 
1301 
1302 /**************************************************
1303 *
1304 *    BiostrucSeqAsnWrite()
1305 *
1306 **************************************************/
1307 NLM_EXTERN Boolean LIBCALL
BiostrucSeqAsnWrite(BiostrucSeqPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1308 BiostrucSeqAsnWrite(BiostrucSeqPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1309 {
1310    AsnTypePtr atp;
1311    Boolean retval = FALSE;
1312 
1313    if (! loaded)
1314    {
1315       if (! objmimeAsnLoad()) {
1316          return FALSE;
1317       }
1318    }
1319 
1320    if (aip == NULL) {
1321       return FALSE;
1322    }
1323 
1324    atp = AsnLinkType(orig, BIOSTRUC_SEQ);   /* link local tree */
1325    if (atp == NULL) {
1326       return FALSE;
1327    }
1328 
1329    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1330 
1331    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1332       goto erret;
1333    }
1334 
1335    if (ptr -> structure != NULL) {
1336       if ( ! BiostrucAsnWrite(ptr -> structure, aip, BIOSTRUC_SEQ_structure)) {
1337          goto erret;
1338       }
1339    }
1340    AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BIOSTRUC_SEQ_sequences, BIOSTRUC_SEQ_sequences_E);
1341    /* paul */
1342    if (ptr -> style_dictionary != NULL) {
1343       if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, BIOSTRUC_SEQ_style_dictionary)) {
1344          goto erret;
1345       }
1346    }
1347    if (ptr -> user_annotations != NULL) {
1348       if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, BIOSTRUC_SEQ_user_annotations)) {
1349          goto erret;
1350       }
1351    }
1352 
1353    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1354       goto erret;
1355    }
1356    retval = TRUE;
1357 
1358 erret:
1359    AsnUnlinkType(orig);       /* unlink local tree */
1360    return retval;
1361 }
1362 
1363 
1364 
1365 /**************************************************
1366 *
1367 *    BiostrucSeqsNew()
1368 *
1369 **************************************************/
1370 NLM_EXTERN
1371 BiostrucSeqsPtr LIBCALL
BiostrucSeqsNew(void)1372 BiostrucSeqsNew(void)
1373 {
1374    BiostrucSeqsPtr ptr = MemNew((size_t) sizeof(BiostrucSeqs));
1375 
1376    return ptr;
1377 
1378 }
1379 
1380 
1381 /**************************************************
1382 *
1383 *    BiostrucSeqsFree()
1384 *
1385 **************************************************/
1386 NLM_EXTERN
1387 BiostrucSeqsPtr LIBCALL
BiostrucSeqsFree(BiostrucSeqsPtr ptr)1388 BiostrucSeqsFree(BiostrucSeqsPtr ptr)
1389 {
1390 
1391    if(ptr == NULL) {
1392       return NULL;
1393    }
1394    BiostrucFree(ptr -> structure);
1395    AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree);
1396    AsnGenericUserSeqOfFree(ptr -> seqalign, (AsnOptFreeFunc) SeqAnnotFree);
1397    Cn3dStyleDictionaryFree(ptr -> style_dictionary); /* paul */
1398    Cn3dUserAnnotationsFree(ptr -> user_annotations);
1399    return MemFree(ptr);
1400 }
1401 
1402 
1403 /**************************************************
1404 *
1405 *    BiostrucSeqsAsnRead()
1406 *
1407 **************************************************/
1408 NLM_EXTERN
1409 BiostrucSeqsPtr LIBCALL
BiostrucSeqsAsnRead(AsnIoPtr aip,AsnTypePtr orig)1410 BiostrucSeqsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1411 {
1412    DataVal av;
1413    AsnTypePtr atp;
1414    Boolean isError = FALSE;
1415    AsnReadFunc func;
1416    BiostrucSeqsPtr ptr;
1417 
1418    if (! loaded)
1419    {
1420       if (! objmimeAsnLoad()) {
1421          return NULL;
1422       }
1423    }
1424 
1425    if (aip == NULL) {
1426       return NULL;
1427    }
1428 
1429    if (orig == NULL) {         /* BiostrucSeqs ::= (self contained) */
1430       atp = AsnReadId(aip, amp, BIOSTRUC_SEQS);
1431    } else {
1432       atp = AsnLinkType(orig, BIOSTRUC_SEQS);
1433    }
1434    /* link in local tree */
1435    if (atp == NULL) {
1436       return NULL;
1437    }
1438 
1439    ptr = BiostrucSeqsNew();
1440    if (ptr == NULL) {
1441       goto erret;
1442    }
1443    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1444       goto erret;
1445    }
1446 
1447    atp = AsnReadId(aip,amp, atp);
1448    func = NULL;
1449 
1450    if (atp == BIOSTRUC_SEQS_structure) {
1451       ptr -> structure = BiostrucAsnRead(aip, atp);
1452       if (aip -> io_failure) {
1453          goto erret;
1454       }
1455       atp = AsnReadId(aip,amp, atp);
1456    }
1457    if (atp == BIOSTRUC_SEQS_sequences) {
1458       ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree);
1459       if (isError && ptr -> sequences == NULL) {
1460          goto erret;
1461       }
1462       atp = AsnReadId(aip,amp, atp);
1463    }
1464    if (atp == BIOSTRUC_SEQS_seqalign) {
1465 /*    ptr -> seqalign = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
1466       if (isError && ptr -> seqalign == NULL) {
1467          goto erret;
1468       }  */ /* yanli comment it out, add following, Sept. 16, 1999 */
1469       ptr -> seqalign = SeqAnnotSetAsnRead(aip, BIOSTRUC_SEQS_seqalign, BIOSTRUC_SEQS_seqalign_E);
1470       atp = AsnReadId(aip,amp, atp);
1471    }
1472    /* paul */
1473    if (atp == BIOSTRUC_SEQS_style_dictionary) {
1474       ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp);
1475       if (aip -> io_failure) {
1476          goto erret;
1477       }
1478       atp = AsnReadId(aip,amp, atp);
1479    }
1480    if (atp == BIOSTRUC_SEQS_user_annotations) {
1481       ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp);
1482       if (aip -> io_failure) {
1483          goto erret;
1484       }
1485       atp = AsnReadId(aip,amp, atp);
1486    }
1487 
1488    if (AsnReadVal(aip, atp, &av) <= 0) {
1489       goto erret;
1490    }
1491    /* end struct */
1492 
1493 ret:
1494    AsnUnlinkType(orig);       /* unlink local tree */
1495    return ptr;
1496 
1497 erret:
1498    aip -> io_failure = TRUE;
1499    ptr = BiostrucSeqsFree(ptr);
1500    goto ret;
1501 }
1502 
1503 
1504 
1505 /**************************************************
1506 *
1507 *    BiostrucSeqsAsnWrite()
1508 *
1509 **************************************************/
1510 NLM_EXTERN Boolean LIBCALL
BiostrucSeqsAsnWrite(BiostrucSeqsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1511 BiostrucSeqsAsnWrite(BiostrucSeqsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1512 {
1513    AsnTypePtr atp;
1514    Boolean retval = FALSE;
1515 
1516    if (! loaded)
1517    {
1518       if (! objmimeAsnLoad()) {
1519          return FALSE;
1520       }
1521    }
1522 
1523    if (aip == NULL) {
1524       return FALSE;
1525    }
1526 
1527    atp = AsnLinkType(orig, BIOSTRUC_SEQS);   /* link local tree */
1528    if (atp == NULL) {
1529       return FALSE;
1530    }
1531 
1532    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1533 
1534    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1535       goto erret;
1536    }
1537 
1538    if (ptr -> structure != NULL) {
1539       if ( ! BiostrucAsnWrite(ptr -> structure, aip, BIOSTRUC_SEQS_structure)) {
1540          goto erret;
1541       }
1542    }
1543    AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BIOSTRUC_SEQS_sequences, BIOSTRUC_SEQS_sequences_E);
1544 /* AsnGenericUserSeqOfAsnWrite(ptr -> seqalign, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BIOSTRUC_SEQS_seqalign, BIOSTRUC_SEQS_seqalign_E); */
1545    /* yanli comment this out, and the following, Sept. 16, 1998 */
1546    SeqAnnotSetAsnWrite(ptr -> seqalign, aip, BIOSTRUC_SEQS_seqalign, BIOSTRUC_SEQS_seqalign_E);
1547    /* paul */
1548    if (ptr -> style_dictionary != NULL) {
1549       if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, BIOSTRUC_SEQS_style_dictionary)) {
1550          goto erret;
1551       }
1552    }
1553    if (ptr -> user_annotations != NULL) {
1554       if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, BIOSTRUC_SEQS_user_annotations)) {
1555          goto erret;
1556       }
1557    }
1558 
1559    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1560       goto erret;
1561    }
1562    retval = TRUE;
1563 
1564 erret:
1565    AsnUnlinkType(orig);       /* unlink local tree */
1566    return retval;
1567 }
1568 
1569 /**************************************************
1570 *
1571 *    BiostrucSeqsAlignsCddNew()
1572 *
1573 **************************************************/
1574 NLM_EXTERN
1575 BiostrucSeqsAlignsCddPtr LIBCALL
BiostrucSeqsAlignsCddNew(void)1576 BiostrucSeqsAlignsCddNew(void)
1577 {
1578    BiostrucSeqsAlignsCddPtr ptr = MemNew((size_t) sizeof(BiostrucSeqsAlignsCdd));
1579 
1580    return ptr;
1581 
1582 }
1583 
1584 
1585 /**************************************************
1586 *
1587 *    BiostrucSeqsAlignsCddFree()
1588 *
1589 **************************************************/
1590 NLM_EXTERN
1591 BiostrucSeqsAlignsCddPtr LIBCALL
BiostrucSeqsAlignsCddFree(BiostrucSeqsAlignsCddPtr ptr)1592 BiostrucSeqsAlignsCddFree(BiostrucSeqsAlignsCddPtr ptr)
1593 {
1594 
1595    if(ptr == NULL) {
1596       return NULL;
1597    }
1598    SeqAlignData_seq_align_dataFree(ptr -> SeqAlignData_seq_align_data);
1599    AsnGenericUserSeqOfFree(ptr -> structures, (AsnOptFreeFunc) BiostrucFree);
1600    return MemFree(ptr);
1601 }
1602 
1603 
1604 /**************************************************
1605 *
1606 *    SeqAlignData_seq_align_dataFree()
1607 *
1608 **************************************************/
1609 static
1610 SeqAlignData_seq_align_dataPtr LIBCALL
SeqAlignData_seq_align_dataFree(ValNodePtr anp)1611 SeqAlignData_seq_align_dataFree(ValNodePtr anp)
1612 {
1613    Pointer pnt;
1614 
1615    if (anp == NULL) {
1616       return NULL;
1617    }
1618 
1619    pnt = anp->data.ptrvalue;
1620    switch (anp->choice)
1621    {
1622    default:
1623       break;
1624    case SeqAlignData_seq_align_data_bundle:
1625       BundleSeqsAlignsFree(anp -> data.ptrvalue);
1626       break;
1627    case SeqAlignData_seq_align_data_cdd:
1628       CddFree(anp -> data.ptrvalue);
1629       break;
1630    }
1631    return MemFree(anp);
1632 }
1633 
1634 
1635 /**************************************************
1636 *
1637 *    BiostrucSeqsAlignsCddAsnRead()
1638 *
1639 **************************************************/
1640 NLM_EXTERN
1641 BiostrucSeqsAlignsCddPtr LIBCALL
BiostrucSeqsAlignsCddAsnRead(AsnIoPtr aip,AsnTypePtr orig)1642 BiostrucSeqsAlignsCddAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1643 {
1644    DataVal av;
1645    AsnTypePtr atp;
1646    Boolean isError = FALSE;
1647    AsnReadFunc func;
1648    BiostrucSeqsAlignsCddPtr ptr;
1649 
1650    if (! loaded)
1651    {
1652       if (! objmimeAsnLoad()) {
1653          return NULL;
1654       }
1655    }
1656 
1657    if (aip == NULL) {
1658       return NULL;
1659    }
1660 
1661    if (orig == NULL) {         /* BiostrucSeqsAlignsCdd ::= (self contained) */
1662       atp = AsnReadId(aip, amp, BIOSTRUC_SEQS_ALIGNS_CDD);
1663    } else {
1664       atp = AsnLinkType(orig, BIOSTRUC_SEQS_ALIGNS_CDD);
1665    }
1666    /* link in local tree */
1667    if (atp == NULL) {
1668       return NULL;
1669    }
1670 
1671    ptr = BiostrucSeqsAlignsCddNew();
1672    if (ptr == NULL) {
1673       goto erret;
1674    }
1675    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1676       goto erret;
1677    }
1678 
1679    atp = AsnReadId(aip,amp, atp);
1680    func = NULL;
1681 
1682    if (atp == SEQS_ALIGNS_CDD_seq_align_data) {
1683       ptr -> SeqAlignData_seq_align_data = SeqAlignData_seq_align_dataAsnRead(aip, atp);
1684       if (aip -> io_failure) {
1685          goto erret;
1686       }
1687       atp = AsnReadId(aip,amp, atp);
1688    }
1689    if (atp == SEQS_ALIGNS_CDD_structures) {
1690       ptr -> structures = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucAsnRead, (AsnOptFreeFunc) BiostrucFree);
1691       if (isError && ptr -> structures == NULL) {
1692          goto erret;
1693       }
1694       atp = AsnReadId(aip,amp, atp);
1695    }
1696    if (atp == SEQS_ALIGNS_CDD_structure_type) {
1697       if ( AsnReadVal(aip, atp, &av) <= 0) {
1698          goto erret;
1699       }
1700       ptr -> structure_type = av.intvalue;
1701       atp = AsnReadId(aip,amp, atp);
1702    }
1703 
1704    if (AsnReadVal(aip, atp, &av) <= 0) {
1705       goto erret;
1706    }
1707    /* end struct */
1708 
1709 ret:
1710    AsnUnlinkType(orig);       /* unlink local tree */
1711    return ptr;
1712 
1713 erret:
1714    aip -> io_failure = TRUE;
1715    ptr = BiostrucSeqsAlignsCddFree(ptr);
1716    goto ret;
1717 }
1718 
1719 
1720 
1721 /**************************************************
1722 *
1723 *    SeqAlignData_seq_align_dataAsnRead()
1724 *
1725 **************************************************/
1726 static
1727 SeqAlignData_seq_align_dataPtr LIBCALL
SeqAlignData_seq_align_dataAsnRead(AsnIoPtr aip,AsnTypePtr orig)1728 SeqAlignData_seq_align_dataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1729 {
1730    DataVal av;
1731    AsnTypePtr atp;
1732    ValNodePtr anp;
1733    Uint1 choice;
1734    Boolean isError = FALSE;
1735    Boolean nullIsError = FALSE;
1736    AsnReadFunc func;
1737 
1738    if (! loaded)
1739    {
1740       if (! objmimeAsnLoad()) {
1741          return NULL;
1742       }
1743    }
1744 
1745    if (aip == NULL) {
1746       return NULL;
1747    }
1748 
1749    if (orig == NULL) {         /* SeqAlignData_seq_align_data ::= (self contained) */
1750       atp = AsnReadId(aip, amp, SEQS_ALIGNS_CDD_seq_align_data);
1751    } else {
1752       atp = AsnLinkType(orig, SEQS_ALIGNS_CDD_seq_align_data);    /* link in local tree */
1753    }
1754    if (atp == NULL) {
1755       return NULL;
1756    }
1757 
1758    anp = ValNodeNew(NULL);
1759    if (anp == NULL) {
1760       goto erret;
1761    }
1762    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
1763       goto erret;
1764    }
1765 
1766    func = NULL;
1767 
1768    atp = AsnReadId(aip, amp, atp);  /* find the choice */
1769    if (atp == NULL) {
1770       goto erret;
1771    }
1772    if (atp == CDD_seq_align_data_bundle) {
1773       choice = SeqAlignData_seq_align_data_bundle;
1774       func = (AsnReadFunc) BundleSeqsAlignsAsnRead;
1775    }
1776    else if (atp == ALIGNS_CDD_seq_align_data_cdd) {
1777       choice = SeqAlignData_seq_align_data_cdd;
1778       func = (AsnReadFunc) CddAsnRead;
1779    }
1780    anp->choice = choice;
1781    if (func != NULL)
1782    {
1783       anp->data.ptrvalue = (* func)(aip, atp);
1784       if (aip -> io_failure) goto erret;
1785 
1786       if (nullIsError && anp->data.ptrvalue == NULL) {
1787          goto erret;
1788       }
1789    }
1790 
1791 ret:
1792    AsnUnlinkType(orig);       /* unlink local tree */
1793    return anp;
1794 
1795 erret:
1796    anp = MemFree(anp);
1797    aip -> io_failure = TRUE;
1798    goto ret;
1799 }
1800 
1801 
1802 /**************************************************
1803 *
1804 *    BiostrucSeqsAlignsCddAsnWrite()
1805 *
1806 **************************************************/
1807 NLM_EXTERN Boolean LIBCALL
BiostrucSeqsAlignsCddAsnWrite(BiostrucSeqsAlignsCddPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1808 BiostrucSeqsAlignsCddAsnWrite(BiostrucSeqsAlignsCddPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1809 {
1810    DataVal av;
1811    AsnTypePtr atp;
1812    Boolean retval = FALSE;
1813 
1814    if (! loaded)
1815    {
1816       if (! objmimeAsnLoad()) {
1817          return FALSE;
1818       }
1819    }
1820 
1821    if (aip == NULL) {
1822       return FALSE;
1823    }
1824 
1825    atp = AsnLinkType(orig, BIOSTRUC_SEQS_ALIGNS_CDD);   /* link local tree */
1826    if (atp == NULL) {
1827       return FALSE;
1828    }
1829 
1830    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1831 
1832     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1833 
1834    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1835       goto erret;
1836    }
1837 
1838    if (ptr -> SeqAlignData_seq_align_data != NULL) {
1839       if ( ! SeqAlignData_seq_align_dataAsnWrite(ptr -> SeqAlignData_seq_align_data, aip, SEQS_ALIGNS_CDD_seq_align_data)) {
1840          goto erret;
1841       }
1842    }
1843    AsnGenericUserSeqOfAsnWrite(ptr -> structures, (AsnWriteFunc) BiostrucAsnWrite, aip, SEQS_ALIGNS_CDD_structures, SEQS_ALIGNS_CDD_structures_E);
1844    av.intvalue = ptr -> structure_type;
1845    retval = AsnWrite(aip, SEQS_ALIGNS_CDD_structure_type,  &av);
1846    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1847       goto erret;
1848    }
1849    retval = TRUE;
1850 
1851 erret:
1852    AsnUnlinkType(orig);       /* unlink local tree */
1853    return retval;
1854 }
1855 
1856 
1857 
1858 /**************************************************
1859 *
1860 *    SeqAlignData_seq_align_dataAsnWrite()
1861 *
1862 **************************************************/
1863 static Boolean LIBCALL
SeqAlignData_seq_align_dataAsnWrite(SeqAlignData_seq_align_dataPtr anp,AsnIoPtr aip,AsnTypePtr orig)1864 SeqAlignData_seq_align_dataAsnWrite(SeqAlignData_seq_align_dataPtr anp, AsnIoPtr aip, AsnTypePtr orig)
1865 
1866 {
1867    DataVal av;
1868    AsnTypePtr atp, writetype = NULL;
1869    Pointer pnt;
1870    AsnWriteFunc func = NULL;
1871    Boolean retval = FALSE;
1872 
1873    if (! loaded)
1874    {
1875       if (! objmimeAsnLoad())
1876       return FALSE;
1877    }
1878 
1879    if (aip == NULL)
1880    return FALSE;
1881 
1882    atp = AsnLinkType(orig, SEQS_ALIGNS_CDD_seq_align_data);   /* link local tree */
1883    if (atp == NULL) {
1884       return FALSE;
1885    }
1886 
1887    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1888 
1889     MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1890 
1891    av.ptrvalue = (Pointer)anp;
1892    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
1893       goto erret;
1894    }
1895 
1896    pnt = anp->data.ptrvalue;
1897    switch (anp->choice)
1898    {
1899    case SeqAlignData_seq_align_data_bundle:
1900       writetype = CDD_seq_align_data_bundle;
1901       func = (AsnWriteFunc) BundleSeqsAlignsAsnWrite;
1902       break;
1903    case SeqAlignData_seq_align_data_cdd:
1904       writetype = ALIGNS_CDD_seq_align_data_cdd;
1905       func = (AsnWriteFunc) CddAsnWrite;
1906       break;
1907    }
1908    if (writetype != NULL) {
1909       retval = (* func)(pnt, aip, writetype);   /* write it out */
1910    }
1911    if (!retval) {
1912       goto erret;
1913    }
1914    retval = TRUE;
1915 
1916 erret:
1917    AsnUnlinkType(orig);       /* unlink local tree */
1918    return retval;
1919 }
1920 
1921 
1922 /**************************************************
1923 *
1924 *    BundleSeqsAlignsNew()
1925 *
1926 **************************************************/
1927 NLM_EXTERN
1928 BundleSeqsAlignsPtr LIBCALL
BundleSeqsAlignsNew(void)1929 BundleSeqsAlignsNew(void)
1930 {
1931    BundleSeqsAlignsPtr ptr = MemNew((size_t) sizeof(BundleSeqsAligns));
1932 
1933    return ptr;
1934 
1935 }
1936 
1937 
1938 /**************************************************
1939 *
1940 *    BundleSeqsAlignsFree()
1941 *
1942 **************************************************/
1943 NLM_EXTERN
1944 BundleSeqsAlignsPtr LIBCALL
BundleSeqsAlignsFree(BundleSeqsAlignsPtr ptr)1945 BundleSeqsAlignsFree(BundleSeqsAlignsPtr ptr)
1946 {
1947 
1948    if(ptr == NULL) {
1949       return NULL;
1950    }
1951    AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree);
1952    AsnGenericUserSeqOfFree(ptr -> seqaligns, (AsnOptFreeFunc) SeqAnnotFree);
1953    BiostrucAnnotSetFree(ptr -> strucaligns);
1954    AsnGenericUserSeqOfFree(ptr -> imports, (AsnOptFreeFunc) SeqAnnotFree);
1955    Cn3dStyleDictionaryFree(ptr -> style_dictionary);
1956    Cn3dUserAnnotationsFree(ptr -> user_annotations);
1957    return MemFree(ptr);
1958 }
1959 
1960 
1961 /**************************************************
1962 *
1963 *    BundleSeqsAlignsAsnRead()
1964 *
1965 **************************************************/
1966 NLM_EXTERN
1967 BundleSeqsAlignsPtr LIBCALL
BundleSeqsAlignsAsnRead(AsnIoPtr aip,AsnTypePtr orig)1968 BundleSeqsAlignsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1969 {
1970    DataVal av;
1971    AsnTypePtr atp;
1972    Boolean isError = FALSE;
1973    AsnReadFunc func;
1974    BundleSeqsAlignsPtr ptr;
1975 
1976    if (! loaded)
1977    {
1978       if (! objmimeAsnLoad()) {
1979          return NULL;
1980       }
1981    }
1982 
1983    if (aip == NULL) {
1984       return NULL;
1985    }
1986 
1987    if (orig == NULL) {         /* BundleSeqsAligns ::= (self contained) */
1988       atp = AsnReadId(aip, amp, BUNDLE_SEQS_ALIGNS);
1989    } else {
1990       atp = AsnLinkType(orig, BUNDLE_SEQS_ALIGNS);
1991    }
1992    /* link in local tree */
1993    if (atp == NULL) {
1994       return NULL;
1995    }
1996 
1997    ptr = BundleSeqsAlignsNew();
1998    if (ptr == NULL) {
1999       goto erret;
2000    }
2001    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2002       goto erret;
2003    }
2004 
2005    atp = AsnReadId(aip,amp, atp);
2006    func = NULL;
2007 
2008    if (atp == BUNDLE_SEQS_ALIGNS_sequences) {
2009       ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree);
2010       if (isError && ptr -> sequences == NULL) {
2011          goto erret;
2012       }
2013       atp = AsnReadId(aip,amp, atp);
2014    }
2015    if (atp == BUNDLE_SEQS_ALIGNS_seqaligns) {
2016       ptr -> seqaligns = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
2017       if (isError && ptr -> seqaligns == NULL) {
2018          goto erret;
2019       }
2020       atp = AsnReadId(aip,amp, atp);
2021    }
2022    if (atp == BUNDLE_SEQS_ALIGNS_strucaligns) {
2023       ptr -> strucaligns = BiostrucAnnotSetAsnRead(aip, atp);
2024       if (aip -> io_failure) {
2025          goto erret;
2026       }
2027       atp = AsnReadId(aip,amp, atp);
2028    }
2029    if (atp == BUNDLE_SEQS_ALIGNS_imports) {
2030       ptr -> imports = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
2031       if (isError && ptr -> imports == NULL) {
2032          goto erret;
2033       }
2034       atp = AsnReadId(aip,amp, atp);
2035    }
2036    if (atp == SEQS_ALIGNS_style_dictionary) {
2037       ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp);
2038       if (aip -> io_failure) {
2039          goto erret;
2040       }
2041       atp = AsnReadId(aip,amp, atp);
2042    }
2043    if (atp == SEQS_ALIGNS_user_annotations) {
2044       ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp);
2045       if (aip -> io_failure) {
2046          goto erret;
2047       }
2048       atp = AsnReadId(aip,amp, atp);
2049    }
2050 
2051    if (AsnReadVal(aip, atp, &av) <= 0) {
2052       goto erret;
2053    }
2054    /* end struct */
2055 
2056 ret:
2057    AsnUnlinkType(orig);       /* unlink local tree */
2058    return ptr;
2059 
2060 erret:
2061    aip -> io_failure = TRUE;
2062    ptr = BundleSeqsAlignsFree(ptr);
2063    goto ret;
2064 }
2065 
2066 
2067 
2068 /**************************************************
2069 *
2070 *    BundleSeqsAlignsAsnWrite()
2071 *
2072 **************************************************/
2073 NLM_EXTERN Boolean LIBCALL
BundleSeqsAlignsAsnWrite(BundleSeqsAlignsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2074 BundleSeqsAlignsAsnWrite(BundleSeqsAlignsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2075 {
2076    AsnTypePtr atp;
2077    Boolean retval = FALSE;
2078 
2079    if (! loaded)
2080    {
2081       if (! objmimeAsnLoad()) {
2082          return FALSE;
2083       }
2084    }
2085 
2086    if (aip == NULL) {
2087       return FALSE;
2088    }
2089 
2090    atp = AsnLinkType(orig, BUNDLE_SEQS_ALIGNS);   /* link local tree */
2091    if (atp == NULL) {
2092       return FALSE;
2093    }
2094 
2095    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2096 
2097    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2098       goto erret;
2099    }
2100 
2101    AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BUNDLE_SEQS_ALIGNS_sequences, BUNDLE_SEQS_ALIGNS_sequences_E);
2102    AsnGenericUserSeqOfAsnWrite(ptr -> seqaligns, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BUNDLE_SEQS_ALIGNS_seqaligns, BUNDLE_SEQS_ALIGNS_seqaligns_E);
2103    if (ptr -> strucaligns != NULL) {
2104       if ( ! BiostrucAnnotSetAsnWrite(ptr -> strucaligns, aip, BUNDLE_SEQS_ALIGNS_strucaligns)) {
2105          goto erret;
2106       }
2107    }
2108    AsnGenericUserSeqOfAsnWrite(ptr -> imports, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BUNDLE_SEQS_ALIGNS_imports, BUNDLE_SEQS_ALIGNS_imports_E);
2109    if (ptr -> style_dictionary != NULL) {
2110       if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, SEQS_ALIGNS_style_dictionary)) {
2111          goto erret;
2112       }
2113    }
2114    if (ptr -> user_annotations != NULL) {
2115       if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, SEQS_ALIGNS_user_annotations)) {
2116          goto erret;
2117       }
2118    }
2119    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2120       goto erret;
2121    }
2122    retval = TRUE;
2123 
2124 erret:
2125    AsnUnlinkType(orig);       /* unlink local tree */
2126    return retval;
2127 }
2128