1 #include <asn.h>
2
3 #define NLM_GENERATED_CODE_PROTO
4
5 #include <strimprt.h>
6 #include <objmmdb1.h>
7
8 static Boolean loaded = FALSE;
9
10 #include <mmdb1.h>
11
12 #ifndef NLM_EXTERN_LOADS
13 #define NLM_EXTERN_LOADS {}
14 #endif
15
16 Boolean LIBCALL
objmmdb1AsnLoad(void)17 objmmdb1AsnLoad(void)
18 {
19
20 if ( ! loaded) {
21 NLM_EXTERN_LOADS
22
23 if ( ! AsnLoad ())
24 return FALSE;
25 loaded = TRUE;
26 }
27
28 return TRUE;
29 }
30
31
32
33 /**************************************************
34 * Generated object loaders for Module MMDB-Chemical-graph
35 * Generated using ASNCODE Revision: 4.2 at Aug 1, 1996 4:27 PM
36 *
37 **************************************************/
38
39
40 /**************************************************
41 *
42 * BiostrucNew()
43 *
44 **************************************************/
45
46 BiostrucPtr LIBCALL
BiostrucNew(void)47 BiostrucNew(void)
48 {
49 BiostrucPtr ptr = MemNew((size_t) sizeof(Biostruc));
50
51 return ptr;
52
53 }
54
55
56 /**************************************************
57 *
58 * BiostrucFree()
59 *
60 **************************************************/
61
62 BiostrucPtr LIBCALL
BiostrucFree(BiostrucPtr ptr)63 BiostrucFree(BiostrucPtr ptr)
64 {
65
66 if(ptr == NULL) {
67 return NULL;
68 }
69 AsnGenericChoiceSeqOfFree(ptr -> id, (AsnOptFreeFunc) BiostrucIdFree);
70 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiostrucDescrFree);
71 BiostrucGraphFree(ptr -> chemical_graph);
72 AsnGenericUserSeqOfFree(ptr -> features, (AsnOptFreeFunc) BiostrucFeatureSetFree);
73 AsnGenericUserSeqOfFree(ptr -> model, (AsnOptFreeFunc) BiostrucModelFree);
74 return MemFree(ptr);
75 }
76
77
78 /**************************************************
79 *
80 * BiostrucAsnRead()
81 *
82 **************************************************/
83
84 BiostrucPtr LIBCALL
BiostrucAsnRead(AsnIoPtr aip,AsnTypePtr orig)85 BiostrucAsnRead(AsnIoPtr aip, AsnTypePtr orig)
86 {
87 DataVal av;
88 AsnTypePtr atp;
89 Boolean isError = FALSE;
90 AsnReadFunc func;
91 BiostrucPtr ptr;
92
93 if (! loaded)
94 {
95 if (! objmmdb1AsnLoad()) {
96 return NULL;
97 }
98 }
99
100 if (aip == NULL) {
101 return NULL;
102 }
103
104 if (orig == NULL) { /* Biostruc ::= (self contained) */
105 atp = AsnReadId(aip, amp, BIOSTRUC);
106 } else {
107 atp = AsnLinkType(orig, BIOSTRUC);
108 }
109 /* link in local tree */
110 if (atp == NULL) {
111 return NULL;
112 }
113
114 ptr = BiostrucNew();
115 if (ptr == NULL) {
116 goto erret;
117 }
118 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
119 goto erret;
120 }
121
122 atp = AsnReadId(aip,amp, atp);
123 func = NULL;
124
125 if (atp == BIOSTRUC_id) {
126 ptr -> id = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucIdAsnRead, (AsnOptFreeFunc) BiostrucIdFree);
127 if (isError && ptr -> id == NULL) {
128 goto erret;
129 }
130 atp = AsnReadId(aip,amp, atp);
131 }
132 if (atp == BIOSTRUC_descr) {
133 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucDescrAsnRead, (AsnOptFreeFunc) BiostrucDescrFree);
134 if (isError && ptr -> descr == NULL) {
135 goto erret;
136 }
137 atp = AsnReadId(aip,amp, atp);
138 }
139 if (atp == BIOSTRUC_chemical_graph) {
140 ptr -> chemical_graph = BiostrucGraphAsnRead(aip, atp);
141 if (aip -> io_failure) {
142 goto erret;
143 }
144 atp = AsnReadId(aip,amp, atp);
145 }
146 if (atp == BIOSTRUC_features) {
147 ptr -> features = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucFeatureSetAsnRead, (AsnOptFreeFunc) BiostrucFeatureSetFree);
148 if (isError && ptr -> features == NULL) {
149 goto erret;
150 }
151 atp = AsnReadId(aip,amp, atp);
152 }
153 if (atp == BIOSTRUC_model) {
154 /* begin manual insertion */
155 AsnOptionPtr aop;
156 int option = -1;
157
158 if ((aop = AsnIoOptionGet(aip, OP_NCBIOBJSTR, BIOSTRUC_CHECK_MODEL, NULL)) != NULL)
159 {
160 AsnTypePtr start_atp;
161 BiostrucModelPtr model;
162 BiostrucModelPtr last = NULL;
163 Int4 maxModels = INT2_MAX;
164 Boolean retain;
165 Boolean quitAfterRetainingNext = FALSE;
166 Boolean quitNow = FALSE;
167
168 option = aop->data.intvalue;
169 if ((aop = AsnIoOptionGet(aip, OP_NCBIOBJSTR, BIOSTRUC_MAX_MODELS, NULL)) != NULL)
170 {
171 maxModels = aop->data.intvalue;
172 }
173
174 if (option == ONECOORDATOM || option == ONECOORDRES ||
175 option == ALLMDL || option == VECMODEL)
176 {
177 if (AsnReadVal (aip, atp, &av) <= 0) /* START_STRUCT */
178 goto erret;
179
180 start_atp = atp;
181
182 while ((atp = AsnReadId (aip, amp, atp)) != start_atp) {
183
184 if ( ! ProgMon("caller of BiostrucModelAsnRead") )
185 {
186 return NULL;
187 }
188
189 model = BiostrucModelAsnRead(aip, atp);
190 if (model == NULL)
191 break;
192
193 retain = FALSE;
194 quitAfterRetainingNext = TRUE;
195 switch(option) {
196 case VECMODEL:
197 retain = model->type == 1;
198 break;
199 case ONECOORDRES:
200 retain = model->type == 2;
201 break;
202 case ALLMDL:
203 retain = model->type == 4 && maxModels-- > 0;
204 quitAfterRetainingNext = maxModels <= 0;
205 break;
206 case ONECOORDATOM:
207 default:
208 retain = model->type == 3;
209 break;
210 }
211
212 if (quitNow)
213 break;
214
215 if (retain)
216 {
217 if (ptr->model == NULL)
218 {
219 ptr->model = model;
220 last = model;
221 } else { /* insert at the end */
222 last->next = model;
223 last = model;
224 }
225 if (quitAfterRetainingNext)
226 break;
227
228 }
229 else { /* fix - if didn't retain model, free it */
230 BiostrucModelFree(model);
231 }
232 }
233 return ptr;
234 }
235 }
236 /* end manual insertion */
237 ptr -> model = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucModelAsnRead, (AsnOptFreeFunc) BiostrucModelFree);
238 if (isError && ptr -> model == NULL) {
239 goto erret;
240 }
241 atp = AsnReadId(aip,amp, atp);
242 }
243
244 if (AsnReadVal(aip, atp, &av) <= 0) {
245 goto erret;
246 }
247 /* end struct */
248
249 ret:
250 AsnUnlinkType(orig); /* unlink local tree */
251 return ptr;
252
253 erret:
254 aip -> io_failure = TRUE;
255 ptr = BiostrucFree(ptr);
256 goto ret;
257 }
258
259
260
261 /**************************************************
262 *
263 * BiostrucAsnWrite()
264 *
265 **************************************************/
266 Boolean LIBCALL
BiostrucAsnWrite(BiostrucPtr ptr,AsnIoPtr aip,AsnTypePtr orig)267 BiostrucAsnWrite(BiostrucPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
268 {
269 AsnTypePtr atp;
270 Boolean retval = FALSE;
271
272 if (! loaded)
273 {
274 if (! objmmdb1AsnLoad()) {
275 return FALSE;
276 }
277 }
278
279 if (aip == NULL) {
280 return FALSE;
281 }
282
283 atp = AsnLinkType(orig, BIOSTRUC); /* link local tree */
284 if (atp == NULL) {
285 return FALSE;
286 }
287
288 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
289 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
290 goto erret;
291 }
292
293 AsnGenericChoiceSeqOfAsnWrite(ptr -> id, (AsnWriteFunc) BiostrucIdAsnWrite, aip, BIOSTRUC_id, BIOSTRUC_id_E);
294 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiostrucDescrAsnWrite, aip, BIOSTRUC_descr, BIOSTRUC_descr_E);
295 if (ptr -> chemical_graph != NULL) {
296 if ( ! BiostrucGraphAsnWrite(ptr -> chemical_graph, aip, BIOSTRUC_chemical_graph)) {
297 goto erret;
298 }
299 }
300 AsnGenericUserSeqOfAsnWrite(ptr -> features, (AsnWriteFunc) BiostrucFeatureSetAsnWrite, aip, BIOSTRUC_features, BIOSTRUC_features_E);
301 AsnGenericUserSeqOfAsnWrite(ptr -> model, (AsnWriteFunc) BiostrucModelAsnWrite, aip, BIOSTRUC_model, BIOSTRUC_model_E);
302 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
303 goto erret;
304 }
305 retval = TRUE;
306
307 erret:
308 AsnUnlinkType(orig); /* unlink local tree */
309 return retval;
310 }
311
312
313
314 /**************************************************
315 *
316 * BiostrucIdFree()
317 *
318 **************************************************/
319
320 BiostrucIdPtr LIBCALL
BiostrucIdFree(ValNodePtr anp)321 BiostrucIdFree(ValNodePtr anp)
322 {
323 Pointer pnt;
324
325 if (anp == NULL) {
326 return NULL;
327 }
328
329 pnt = anp->data.ptrvalue;
330 switch (anp->choice)
331 {
332 default:
333 break;
334 case BiostrucId_other_database:
335 DbtagFree(anp -> data.ptrvalue);
336 break;
337 case BiostrucId_local_id:
338 ObjectIdFree(anp -> data.ptrvalue);
339 break;
340 }
341 return MemFree(anp);
342 }
343
344
345 /**************************************************
346 *
347 * BiostrucIdAsnRead()
348 *
349 **************************************************/
350
351 BiostrucIdPtr LIBCALL
BiostrucIdAsnRead(AsnIoPtr aip,AsnTypePtr orig)352 BiostrucIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
353 {
354 DataVal av;
355 AsnTypePtr atp;
356 ValNodePtr anp;
357 Uint1 choice;
358 Boolean isError = FALSE;
359 Boolean nullIsError = FALSE;
360 AsnReadFunc func;
361
362 if (! loaded)
363 {
364 if (! objmmdb1AsnLoad()) {
365 return NULL;
366 }
367 }
368
369 if (aip == NULL) {
370 return NULL;
371 }
372
373 if (orig == NULL) { /* BiostrucId ::= (self contained) */
374 atp = AsnReadId(aip, amp, BIOSTRUC_ID);
375 } else {
376 atp = AsnLinkType(orig, BIOSTRUC_ID); /* link in local tree */
377 }
378 if (atp == NULL) {
379 return NULL;
380 }
381
382 anp = ValNodeNew(NULL);
383 if (anp == NULL) {
384 goto erret;
385 }
386 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
387 goto erret;
388 }
389
390 func = NULL;
391
392 atp = AsnReadId(aip, amp, atp); /* find the choice */
393 if (atp == NULL) {
394 goto erret;
395 }
396 if (atp == BIOSTRUC_ID_mmdb_id) {
397 choice = BiostrucId_mmdb_id;
398 if (AsnReadVal(aip, atp, &av) <= 0) {
399 goto erret;
400 }
401 anp->data.intvalue = av.intvalue;
402 }
403 else if (atp == BIOSTRUC_ID_other_database) {
404 choice = BiostrucId_other_database;
405 func = (AsnReadFunc) DbtagAsnRead;
406 }
407 else if (atp == BIOSTRUC_ID_local_id) {
408 choice = BiostrucId_local_id;
409 func = (AsnReadFunc) ObjectIdAsnRead;
410 }
411 anp->choice = choice;
412 if (func != NULL)
413 {
414 anp->data.ptrvalue = (* func)(aip, atp);
415 if (aip -> io_failure) goto erret;
416
417 if (nullIsError && anp->data.ptrvalue == NULL) {
418 goto erret;
419 }
420 }
421
422 ret:
423 AsnUnlinkType(orig); /* unlink local tree */
424 return anp;
425
426 erret:
427 anp = MemFree(anp);
428 aip -> io_failure = TRUE;
429 goto ret;
430 }
431
432
433 /**************************************************
434 *
435 * BiostrucIdAsnWrite()
436 *
437 **************************************************/
438 Boolean LIBCALL
BiostrucIdAsnWrite(BiostrucIdPtr anp,AsnIoPtr aip,AsnTypePtr orig)439 BiostrucIdAsnWrite(BiostrucIdPtr anp, AsnIoPtr aip, AsnTypePtr orig)
440
441 {
442 DataVal av;
443 AsnTypePtr atp, writetype = NULL;
444 Pointer pnt;
445 AsnWriteFunc func = NULL;
446 Boolean retval = FALSE;
447
448 if (! loaded)
449 {
450 if (! objmmdb1AsnLoad())
451 return FALSE;
452 }
453
454 if (aip == NULL)
455 return FALSE;
456
457 atp = AsnLinkType(orig, BIOSTRUC_ID); /* link local tree */
458 if (atp == NULL) {
459 return FALSE;
460 }
461
462 if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
463 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
464 av.ptrvalue = (Pointer)anp;
465 if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
466 goto erret;
467 }
468
469 pnt = anp->data.ptrvalue;
470 switch (anp->choice)
471 {
472 case BiostrucId_mmdb_id:
473 av.intvalue = anp->data.intvalue;
474 retval = AsnWrite(aip, BIOSTRUC_ID_mmdb_id, &av);
475 break;
476 case BiostrucId_other_database:
477 writetype = BIOSTRUC_ID_other_database;
478 func = (AsnWriteFunc) DbtagAsnWrite;
479 break;
480 case BiostrucId_local_id:
481 writetype = BIOSTRUC_ID_local_id;
482 func = (AsnWriteFunc) ObjectIdAsnWrite;
483 break;
484 }
485 if (writetype != NULL) {
486 retval = (* func)(pnt, aip, writetype); /* write it out */
487 }
488 if (!retval) {
489 goto erret;
490 }
491 retval = TRUE;
492
493 erret:
494 AsnUnlinkType(orig); /* unlink local tree */
495 return retval;
496 }
497
498
499 /**************************************************
500 *
501 * BiostrucSetNew()
502 *
503 **************************************************/
504
505 BiostrucSetPtr LIBCALL
BiostrucSetNew(void)506 BiostrucSetNew(void)
507 {
508 BiostrucSetPtr ptr = MemNew((size_t) sizeof(BiostrucSet));
509
510 return ptr;
511
512 }
513
514
515 /**************************************************
516 *
517 * BiostrucSetFree()
518 *
519 **************************************************/
520
521 BiostrucSetPtr LIBCALL
BiostrucSetFree(BiostrucSetPtr ptr)522 BiostrucSetFree(BiostrucSetPtr ptr)
523 {
524
525 if(ptr == NULL) {
526 return NULL;
527 }
528 AsnGenericChoiceSeqOfFree(ptr -> id, (AsnOptFreeFunc) BiostrucIdFree);
529 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiostrucDescrFree);
530 AsnGenericUserSeqOfFree(ptr -> biostrucs, (AsnOptFreeFunc) BiostrucFree);
531 return MemFree(ptr);
532 }
533
534
535 /**************************************************
536 *
537 * BiostrucSetAsnRead()
538 *
539 **************************************************/
540
541 BiostrucSetPtr LIBCALL
BiostrucSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)542 BiostrucSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
543 {
544 DataVal av;
545 AsnTypePtr atp;
546 Boolean isError = FALSE;
547 AsnReadFunc func;
548 BiostrucSetPtr ptr;
549
550 if (! loaded)
551 {
552 if (! objmmdb1AsnLoad()) {
553 return NULL;
554 }
555 }
556
557 if (aip == NULL) {
558 return NULL;
559 }
560
561 if (orig == NULL) { /* BiostrucSet ::= (self contained) */
562 atp = AsnReadId(aip, amp, BIOSTRUC_SET);
563 } else {
564 atp = AsnLinkType(orig, BIOSTRUC_SET);
565 }
566 /* link in local tree */
567 if (atp == NULL) {
568 return NULL;
569 }
570
571 ptr = BiostrucSetNew();
572 if (ptr == NULL) {
573 goto erret;
574 }
575 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
576 goto erret;
577 }
578
579 atp = AsnReadId(aip,amp, atp);
580 func = NULL;
581
582 if (atp == BIOSTRUC_SET_id) {
583 ptr -> id = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucIdAsnRead, (AsnOptFreeFunc) BiostrucIdFree);
584 if (isError && ptr -> id == NULL) {
585 goto erret;
586 }
587 atp = AsnReadId(aip,amp, atp);
588 }
589 if (atp == BIOSTRUC_SET_descr) {
590 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucDescrAsnRead, (AsnOptFreeFunc) BiostrucDescrFree);
591 if (isError && ptr -> descr == NULL) {
592 goto erret;
593 }
594 atp = AsnReadId(aip,amp, atp);
595 }
596 if (atp == BIOSTRUC_SET_biostrucs) {
597 ptr -> biostrucs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucAsnRead, (AsnOptFreeFunc) BiostrucFree);
598 if (isError && ptr -> biostrucs == NULL) {
599 goto erret;
600 }
601 atp = AsnReadId(aip,amp, atp);
602 }
603
604 if (AsnReadVal(aip, atp, &av) <= 0) {
605 goto erret;
606 }
607 /* end struct */
608
609 ret:
610 AsnUnlinkType(orig); /* unlink local tree */
611 return ptr;
612
613 erret:
614 aip -> io_failure = TRUE;
615 ptr = BiostrucSetFree(ptr);
616 goto ret;
617 }
618
619
620
621 /**************************************************
622 *
623 * BiostrucSetAsnWrite()
624 *
625 **************************************************/
626 Boolean LIBCALL
BiostrucSetAsnWrite(BiostrucSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)627 BiostrucSetAsnWrite(BiostrucSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
628 {
629 AsnTypePtr atp;
630 Boolean retval = FALSE;
631
632 if (! loaded)
633 {
634 if (! objmmdb1AsnLoad()) {
635 return FALSE;
636 }
637 }
638
639 if (aip == NULL) {
640 return FALSE;
641 }
642
643 atp = AsnLinkType(orig, BIOSTRUC_SET); /* link local tree */
644 if (atp == NULL) {
645 return FALSE;
646 }
647
648 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
649 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
650 goto erret;
651 }
652
653 AsnGenericChoiceSeqOfAsnWrite(ptr -> id, (AsnWriteFunc) BiostrucIdAsnWrite, aip, BIOSTRUC_SET_id, BIOSTRUC_SET_id_E);
654 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiostrucDescrAsnWrite, aip, BIOSTRUC_SET_descr, BIOSTRUC_SET_descr_E);
655 AsnGenericUserSeqOfAsnWrite(ptr -> biostrucs, (AsnWriteFunc) BiostrucAsnWrite, aip, BIOSTRUC_SET_biostrucs, BIOSTRUC_SET_biostrucs_E);
656 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
657 goto erret;
658 }
659 retval = TRUE;
660
661 erret:
662 AsnUnlinkType(orig); /* unlink local tree */
663 return retval;
664 }
665
666
667
668 /**************************************************
669 *
670 * BiostrucAnnotSetNew()
671 *
672 **************************************************/
673
674 BiostrucAnnotSetPtr LIBCALL
BiostrucAnnotSetNew(void)675 BiostrucAnnotSetNew(void)
676 {
677 BiostrucAnnotSetPtr ptr = MemNew((size_t) sizeof(BiostrucAnnotSet));
678
679 return ptr;
680
681 }
682
683
684 /**************************************************
685 *
686 * BiostrucAnnotSetFree()
687 *
688 **************************************************/
689
690 BiostrucAnnotSetPtr LIBCALL
BiostrucAnnotSetFree(BiostrucAnnotSetPtr ptr)691 BiostrucAnnotSetFree(BiostrucAnnotSetPtr ptr)
692 {
693
694 if(ptr == NULL) {
695 return NULL;
696 }
697 AsnGenericChoiceSeqOfFree(ptr -> id, (AsnOptFreeFunc) BiostrucIdFree);
698 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiostrucDescrFree);
699 AsnGenericUserSeqOfFree(ptr -> features, (AsnOptFreeFunc) BiostrucFeatureSetFree);
700 return MemFree(ptr);
701 }
702
703
704 /**************************************************
705 *
706 * BiostrucAnnotSetAsnRead()
707 *
708 **************************************************/
709
710 BiostrucAnnotSetPtr LIBCALL
BiostrucAnnotSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)711 BiostrucAnnotSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
712 {
713 DataVal av;
714 AsnTypePtr atp;
715 Boolean isError = FALSE;
716 AsnReadFunc func;
717 BiostrucAnnotSetPtr ptr;
718
719 if (! loaded)
720 {
721 if (! objmmdb1AsnLoad()) {
722 return NULL;
723 }
724 }
725
726 if (aip == NULL) {
727 return NULL;
728 }
729
730 if (orig == NULL) { /* BiostrucAnnotSet ::= (self contained) */
731 atp = AsnReadId(aip, amp, BIOSTRUC_ANNOT_SET);
732 } else {
733 atp = AsnLinkType(orig, BIOSTRUC_ANNOT_SET);
734 }
735 /* link in local tree */
736 if (atp == NULL) {
737 return NULL;
738 }
739
740 ptr = BiostrucAnnotSetNew();
741 if (ptr == NULL) {
742 goto erret;
743 }
744 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
745 goto erret;
746 }
747
748 atp = AsnReadId(aip,amp, atp);
749 func = NULL;
750
751 if (atp == BIOSTRUC_ANNOT_SET_id) {
752 ptr -> id = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucIdAsnRead, (AsnOptFreeFunc) BiostrucIdFree);
753 if (isError && ptr -> id == NULL) {
754 goto erret;
755 }
756 atp = AsnReadId(aip,amp, atp);
757 }
758 if (atp == BIOSTRUC_ANNOT_SET_descr) {
759 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucDescrAsnRead, (AsnOptFreeFunc) BiostrucDescrFree);
760 if (isError && ptr -> descr == NULL) {
761 goto erret;
762 }
763 atp = AsnReadId(aip,amp, atp);
764 }
765 if (atp == BIOSTRUC_ANNOT_SET_features) {
766 ptr -> features = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucFeatureSetAsnRead, (AsnOptFreeFunc) BiostrucFeatureSetFree);
767 if (isError && ptr -> features == NULL) {
768 goto erret;
769 }
770 atp = AsnReadId(aip,amp, atp);
771 }
772
773 if (AsnReadVal(aip, atp, &av) <= 0) {
774 goto erret;
775 }
776 /* end struct */
777
778 ret:
779 AsnUnlinkType(orig); /* unlink local tree */
780 return ptr;
781
782 erret:
783 aip -> io_failure = TRUE;
784 ptr = BiostrucAnnotSetFree(ptr);
785 goto ret;
786 }
787
788
789
790 /**************************************************
791 *
792 * BiostrucAnnotSetAsnWrite()
793 *
794 **************************************************/
795 Boolean LIBCALL
BiostrucAnnotSetAsnWrite(BiostrucAnnotSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)796 BiostrucAnnotSetAsnWrite(BiostrucAnnotSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
797 {
798 AsnTypePtr atp;
799 Boolean retval = FALSE;
800
801 if (! loaded)
802 {
803 if (! objmmdb1AsnLoad()) {
804 return FALSE;
805 }
806 }
807
808 if (aip == NULL) {
809 return FALSE;
810 }
811
812 atp = AsnLinkType(orig, BIOSTRUC_ANNOT_SET); /* link local tree */
813 if (atp == NULL) {
814 return FALSE;
815 }
816
817 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
818 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
819 goto erret;
820 }
821
822 AsnGenericChoiceSeqOfAsnWrite(ptr -> id, (AsnWriteFunc) BiostrucIdAsnWrite, aip, BIOSTRUC_ANNOT_SET_id, BIOSTRUC_ANNOT_SET_id_E);
823 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiostrucDescrAsnWrite, aip, BIOSTRUC_ANNOT_SET_descr, BIOSTRUC_ANNOT_SET_descr_E);
824 AsnGenericUserSeqOfAsnWrite(ptr -> features, (AsnWriteFunc) BiostrucFeatureSetAsnWrite, aip, BIOSTRUC_ANNOT_SET_features, BIOSTRUC_ANNOT_SET_features_E);
825 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
826 goto erret;
827 }
828 retval = TRUE;
829
830 erret:
831 AsnUnlinkType(orig); /* unlink local tree */
832 return retval;
833 }
834
835
836
837 /**************************************************
838 *
839 * BiostrucResidueGraphSetNew()
840 *
841 **************************************************/
842
843 BiostrucResidueGraphSetPtr LIBCALL
BiostrucResidueGraphSetNew(void)844 BiostrucResidueGraphSetNew(void)
845 {
846 BiostrucResidueGraphSetPtr ptr = MemNew((size_t) sizeof(BiostrucResidueGraphSet));
847
848 return ptr;
849
850 }
851
852
853 /**************************************************
854 *
855 * BiostrucResidueGraphSetFree()
856 *
857 **************************************************/
858
859 BiostrucResidueGraphSetPtr LIBCALL
BiostrucResidueGraphSetFree(BiostrucResidueGraphSetPtr ptr)860 BiostrucResidueGraphSetFree(BiostrucResidueGraphSetPtr ptr)
861 {
862
863 if(ptr == NULL) {
864 return NULL;
865 }
866 AsnGenericChoiceSeqOfFree(ptr -> id, (AsnOptFreeFunc) BiostrucIdFree);
867 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiomolDescrFree);
868 AsnGenericUserSeqOfFree(ptr -> residue_graphs, (AsnOptFreeFunc) ResidueGraphFree);
869 return MemFree(ptr);
870 }
871
872
873 /**************************************************
874 *
875 * BiostrucResidueGraphSetAsnRead()
876 *
877 **************************************************/
878
879 BiostrucResidueGraphSetPtr LIBCALL
BiostrucResidueGraphSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)880 BiostrucResidueGraphSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
881 {
882 DataVal av;
883 AsnTypePtr atp;
884 Boolean isError = FALSE;
885 AsnReadFunc func;
886 BiostrucResidueGraphSetPtr ptr;
887
888 if (! loaded)
889 {
890 if (! objmmdb1AsnLoad()) {
891 return NULL;
892 }
893 }
894
895 if (aip == NULL) {
896 return NULL;
897 }
898
899 if (orig == NULL) { /* BiostrucResidueGraphSet ::= (self contained) */
900 atp = AsnReadId(aip, amp, BIOSTRUC_RESIDUE_GRAPH_SET);
901 } else {
902 atp = AsnLinkType(orig, BIOSTRUC_RESIDUE_GRAPH_SET);
903 }
904 /* link in local tree */
905 if (atp == NULL) {
906 return NULL;
907 }
908
909 ptr = BiostrucResidueGraphSetNew();
910 if (ptr == NULL) {
911 goto erret;
912 }
913 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
914 goto erret;
915 }
916
917 atp = AsnReadId(aip,amp, atp);
918 func = NULL;
919
920 if (atp == BIOSTRUC_RESIDUE_GRAPH_SET_id) {
921 ptr -> id = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucIdAsnRead, (AsnOptFreeFunc) BiostrucIdFree);
922 if (isError && ptr -> id == NULL) {
923 goto erret;
924 }
925 atp = AsnReadId(aip,amp, atp);
926 }
927 if (atp == BIOSTRUC_RESIDUE_GRAPH_SET_descr) {
928 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiomolDescrAsnRead, (AsnOptFreeFunc) BiomolDescrFree);
929 if (isError && ptr -> descr == NULL) {
930 goto erret;
931 }
932 atp = AsnReadId(aip,amp, atp);
933 }
934 if (atp == BIOSTRUC_RESIDUE_GRAPH_SET_residue_graphs) {
935 ptr -> residue_graphs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ResidueGraphAsnRead, (AsnOptFreeFunc) ResidueGraphFree);
936 if (isError && ptr -> residue_graphs == NULL) {
937 goto erret;
938 }
939 atp = AsnReadId(aip,amp, atp);
940 }
941
942 if (AsnReadVal(aip, atp, &av) <= 0) {
943 goto erret;
944 }
945 /* end struct */
946
947 ret:
948 AsnUnlinkType(orig); /* unlink local tree */
949 return ptr;
950
951 erret:
952 aip -> io_failure = TRUE;
953 ptr = BiostrucResidueGraphSetFree(ptr);
954 goto ret;
955 }
956
957
958
959 /**************************************************
960 *
961 * BiostrucResidueGraphSetAsnWrite()
962 *
963 **************************************************/
964 Boolean LIBCALL
BiostrucResidueGraphSetAsnWrite(BiostrucResidueGraphSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)965 BiostrucResidueGraphSetAsnWrite(BiostrucResidueGraphSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
966 {
967 AsnTypePtr atp;
968 Boolean retval = FALSE;
969
970 if (! loaded)
971 {
972 if (! objmmdb1AsnLoad()) {
973 return FALSE;
974 }
975 }
976
977 if (aip == NULL) {
978 return FALSE;
979 }
980
981 atp = AsnLinkType(orig, BIOSTRUC_RESIDUE_GRAPH_SET); /* link local tree */
982 if (atp == NULL) {
983 return FALSE;
984 }
985
986 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
987 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
988 goto erret;
989 }
990
991 AsnGenericChoiceSeqOfAsnWrite(ptr -> id, (AsnWriteFunc) BiostrucIdAsnWrite, aip, BIOSTRUC_RESIDUE_GRAPH_SET_id, BIOSTRUC_RESIDUE_GRAPH_SET_id_E);
992 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiomolDescrAsnWrite, aip, BIOSTRUC_RESIDUE_GRAPH_SET_descr, BIOSTRUC_RESIDUE_GRAPH_SET_descr_E);
993 AsnGenericUserSeqOfAsnWrite(ptr -> residue_graphs, (AsnWriteFunc) ResidueGraphAsnWrite, aip, BIOSTRUC_RESIDUE_GRAPH_SET_residue_graphs, BIOSTRUC_RESIDUE_GRAPH_SET_residue_graphs_E);
994 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
995 goto erret;
996 }
997 retval = TRUE;
998
999 erret:
1000 AsnUnlinkType(orig); /* unlink local tree */
1001 return retval;
1002 }
1003
1004
1005
1006 /**************************************************
1007 *
1008 * BiostrucDescrFree()
1009 *
1010 **************************************************/
1011
1012 BiostrucDescrPtr LIBCALL
BiostrucDescrFree(ValNodePtr anp)1013 BiostrucDescrFree(ValNodePtr anp)
1014 {
1015 Pointer pnt;
1016
1017 if (anp == NULL) {
1018 return NULL;
1019 }
1020
1021 pnt = anp->data.ptrvalue;
1022 switch (anp->choice)
1023 {
1024 default:
1025 break;
1026 case BiostrucDescr_name:
1027 MemFree(anp -> data.ptrvalue);
1028 break;
1029 case BiostrucDescr_pdb_comment:
1030 MemFree(anp -> data.ptrvalue);
1031 break;
1032 case BiostrucDescr_other_comment:
1033 MemFree(anp -> data.ptrvalue);
1034 break;
1035 case BiostrucDescr_history:
1036 BiostrucHistoryFree(anp -> data.ptrvalue);
1037 break;
1038 case BiostrucDescr_attribution:
1039 PubFree(anp -> data.ptrvalue);
1040 break;
1041 }
1042 return MemFree(anp);
1043 }
1044
1045
1046 /**************************************************
1047 *
1048 * BiostrucDescrAsnRead()
1049 *
1050 **************************************************/
1051
1052 BiostrucDescrPtr LIBCALL
BiostrucDescrAsnRead(AsnIoPtr aip,AsnTypePtr orig)1053 BiostrucDescrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1054 {
1055 DataVal av;
1056 AsnTypePtr atp;
1057 ValNodePtr anp;
1058 Uint1 choice;
1059 Boolean isError = FALSE;
1060 Boolean nullIsError = FALSE;
1061 AsnReadFunc func;
1062
1063 if (! loaded)
1064 {
1065 if (! objmmdb1AsnLoad()) {
1066 return NULL;
1067 }
1068 }
1069
1070 if (aip == NULL) {
1071 return NULL;
1072 }
1073
1074 if (orig == NULL) { /* BiostrucDescr ::= (self contained) */
1075 atp = AsnReadId(aip, amp, BIOSTRUC_DESCR);
1076 } else {
1077 atp = AsnLinkType(orig, BIOSTRUC_DESCR); /* link in local tree */
1078 }
1079 if (atp == NULL) {
1080 return NULL;
1081 }
1082
1083 anp = ValNodeNew(NULL);
1084 if (anp == NULL) {
1085 goto erret;
1086 }
1087 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
1088 goto erret;
1089 }
1090
1091 func = NULL;
1092
1093 atp = AsnReadId(aip, amp, atp); /* find the choice */
1094 if (atp == NULL) {
1095 goto erret;
1096 }
1097 if (atp == BIOSTRUC_DESCR_name) {
1098 choice = BiostrucDescr_name;
1099 if (AsnReadVal(aip, atp, &av) <= 0) {
1100 goto erret;
1101 }
1102 anp->data.ptrvalue = av.ptrvalue;
1103 }
1104 else if (atp == BIOSTRUC_DESCR_pdb_comment) {
1105 choice = BiostrucDescr_pdb_comment;
1106 if (AsnReadVal(aip, atp, &av) <= 0) {
1107 goto erret;
1108 }
1109 anp->data.ptrvalue = av.ptrvalue;
1110 }
1111 else if (atp == BIOSTRUC_DESCR_other_comment) {
1112 choice = BiostrucDescr_other_comment;
1113 if (AsnReadVal(aip, atp, &av) <= 0) {
1114 goto erret;
1115 }
1116 anp->data.ptrvalue = av.ptrvalue;
1117 }
1118 else if (atp == BIOSTRUC_DESCR_history) {
1119 choice = BiostrucDescr_history;
1120 func = (AsnReadFunc) BiostrucHistoryAsnRead;
1121 }
1122 else if (atp == BIOSTRUC_DESCR_attribution) {
1123 choice = BiostrucDescr_attribution;
1124 func = (AsnReadFunc) PubAsnRead;
1125 }
1126 anp->choice = choice;
1127 if (func != NULL)
1128 {
1129 anp->data.ptrvalue = (* func)(aip, atp);
1130 if (aip -> io_failure) goto erret;
1131
1132 if (nullIsError && anp->data.ptrvalue == NULL) {
1133 goto erret;
1134 }
1135 }
1136
1137 ret:
1138 AsnUnlinkType(orig); /* unlink local tree */
1139 return anp;
1140
1141 erret:
1142 anp = MemFree(anp);
1143 aip -> io_failure = TRUE;
1144 goto ret;
1145 }
1146
1147
1148 /**************************************************
1149 *
1150 * BiostrucDescrAsnWrite()
1151 *
1152 **************************************************/
1153 Boolean LIBCALL
BiostrucDescrAsnWrite(BiostrucDescrPtr anp,AsnIoPtr aip,AsnTypePtr orig)1154 BiostrucDescrAsnWrite(BiostrucDescrPtr anp, AsnIoPtr aip, AsnTypePtr orig)
1155
1156 {
1157 DataVal av;
1158 AsnTypePtr atp, writetype = NULL;
1159 Pointer pnt;
1160 AsnWriteFunc func = NULL;
1161 Boolean retval = FALSE;
1162
1163 if (! loaded)
1164 {
1165 if (! objmmdb1AsnLoad())
1166 return FALSE;
1167 }
1168
1169 if (aip == NULL)
1170 return FALSE;
1171
1172 atp = AsnLinkType(orig, BIOSTRUC_DESCR); /* link local tree */
1173 if (atp == NULL) {
1174 return FALSE;
1175 }
1176
1177 if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1178 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1179 av.ptrvalue = (Pointer)anp;
1180 if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
1181 goto erret;
1182 }
1183
1184 pnt = anp->data.ptrvalue;
1185 switch (anp->choice)
1186 {
1187 case BiostrucDescr_name:
1188 av.ptrvalue = anp->data.ptrvalue;
1189 retval = AsnWrite(aip, BIOSTRUC_DESCR_name, &av);
1190 break;
1191 case BiostrucDescr_pdb_comment:
1192 av.ptrvalue = anp->data.ptrvalue;
1193 retval = AsnWrite(aip, BIOSTRUC_DESCR_pdb_comment, &av);
1194 break;
1195 case BiostrucDescr_other_comment:
1196 av.ptrvalue = anp->data.ptrvalue;
1197 retval = AsnWrite(aip, BIOSTRUC_DESCR_other_comment, &av);
1198 break;
1199 case BiostrucDescr_history:
1200 writetype = BIOSTRUC_DESCR_history;
1201 func = (AsnWriteFunc) BiostrucHistoryAsnWrite;
1202 break;
1203 case BiostrucDescr_attribution:
1204 writetype = BIOSTRUC_DESCR_attribution;
1205 func = (AsnWriteFunc) PubAsnWrite;
1206 break;
1207 }
1208 if (writetype != NULL) {
1209 retval = (* func)(pnt, aip, writetype); /* write it out */
1210 }
1211 if (!retval) {
1212 goto erret;
1213 }
1214 retval = TRUE;
1215
1216 erret:
1217 AsnUnlinkType(orig); /* unlink local tree */
1218 return retval;
1219 }
1220
1221
1222 /**************************************************
1223 *
1224 * BiostrucHistoryNew()
1225 *
1226 **************************************************/
1227
1228 BiostrucHistoryPtr LIBCALL
BiostrucHistoryNew(void)1229 BiostrucHistoryNew(void)
1230 {
1231 BiostrucHistoryPtr ptr = MemNew((size_t) sizeof(BiostrucHistory));
1232
1233 return ptr;
1234
1235 }
1236
1237
1238 /**************************************************
1239 *
1240 * BiostrucHistoryFree()
1241 *
1242 **************************************************/
1243
1244 BiostrucHistoryPtr LIBCALL
BiostrucHistoryFree(BiostrucHistoryPtr ptr)1245 BiostrucHistoryFree(BiostrucHistoryPtr ptr)
1246 {
1247
1248 if(ptr == NULL) {
1249 return NULL;
1250 }
1251 BiostrucReplaceFree(ptr -> replaces);
1252 BiostrucReplaceFree(ptr -> replaced_by);
1253 BiostrucSourceFree(ptr -> data_source);
1254 return MemFree(ptr);
1255 }
1256
1257
1258 /**************************************************
1259 *
1260 * BiostrucHistoryAsnRead()
1261 *
1262 **************************************************/
1263
1264 BiostrucHistoryPtr LIBCALL
BiostrucHistoryAsnRead(AsnIoPtr aip,AsnTypePtr orig)1265 BiostrucHistoryAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1266 {
1267 DataVal av;
1268 AsnTypePtr atp;
1269 Boolean isError = FALSE;
1270 AsnReadFunc func;
1271 BiostrucHistoryPtr ptr;
1272
1273 if (! loaded)
1274 {
1275 if (! objmmdb1AsnLoad()) {
1276 return NULL;
1277 }
1278 }
1279
1280 if (aip == NULL) {
1281 return NULL;
1282 }
1283
1284 if (orig == NULL) { /* BiostrucHistory ::= (self contained) */
1285 atp = AsnReadId(aip, amp, BIOSTRUC_HISTORY);
1286 } else {
1287 atp = AsnLinkType(orig, BIOSTRUC_HISTORY);
1288 }
1289 /* link in local tree */
1290 if (atp == NULL) {
1291 return NULL;
1292 }
1293
1294 ptr = BiostrucHistoryNew();
1295 if (ptr == NULL) {
1296 goto erret;
1297 }
1298 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1299 goto erret;
1300 }
1301
1302 atp = AsnReadId(aip,amp, atp);
1303 func = NULL;
1304
1305 if (atp == BIOSTRUC_HISTORY_replaces) {
1306 ptr -> replaces = BiostrucReplaceAsnRead(aip, atp);
1307 if (aip -> io_failure) {
1308 goto erret;
1309 }
1310 atp = AsnReadId(aip,amp, atp);
1311 }
1312 if (atp == BIOSTRUC_HISTORY_replaced_by) {
1313 ptr -> replaced_by = BiostrucReplaceAsnRead(aip, atp);
1314 if (aip -> io_failure) {
1315 goto erret;
1316 }
1317 atp = AsnReadId(aip,amp, atp);
1318 }
1319 if (atp == BIOSTRUC_HISTORY_data_source) {
1320 ptr -> data_source = BiostrucSourceAsnRead(aip, atp);
1321 if (aip -> io_failure) {
1322 goto erret;
1323 }
1324 atp = AsnReadId(aip,amp, atp);
1325 }
1326
1327 if (AsnReadVal(aip, atp, &av) <= 0) {
1328 goto erret;
1329 }
1330 /* end struct */
1331
1332 ret:
1333 AsnUnlinkType(orig); /* unlink local tree */
1334 return ptr;
1335
1336 erret:
1337 aip -> io_failure = TRUE;
1338 ptr = BiostrucHistoryFree(ptr);
1339 goto ret;
1340 }
1341
1342
1343
1344 /**************************************************
1345 *
1346 * BiostrucHistoryAsnWrite()
1347 *
1348 **************************************************/
1349 Boolean LIBCALL
BiostrucHistoryAsnWrite(BiostrucHistoryPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1350 BiostrucHistoryAsnWrite(BiostrucHistoryPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1351 {
1352 AsnTypePtr atp;
1353 Boolean retval = FALSE;
1354
1355 if (! loaded)
1356 {
1357 if (! objmmdb1AsnLoad()) {
1358 return FALSE;
1359 }
1360 }
1361
1362 if (aip == NULL) {
1363 return FALSE;
1364 }
1365
1366 atp = AsnLinkType(orig, BIOSTRUC_HISTORY); /* link local tree */
1367 if (atp == NULL) {
1368 return FALSE;
1369 }
1370
1371 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1372 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1373 goto erret;
1374 }
1375
1376 if (ptr -> replaces != NULL) {
1377 if ( ! BiostrucReplaceAsnWrite(ptr -> replaces, aip, BIOSTRUC_HISTORY_replaces)) {
1378 goto erret;
1379 }
1380 }
1381 if (ptr -> replaced_by != NULL) {
1382 if ( ! BiostrucReplaceAsnWrite(ptr -> replaced_by, aip, BIOSTRUC_HISTORY_replaced_by)) {
1383 goto erret;
1384 }
1385 }
1386 if (ptr -> data_source != NULL) {
1387 if ( ! BiostrucSourceAsnWrite(ptr -> data_source, aip, BIOSTRUC_HISTORY_data_source)) {
1388 goto erret;
1389 }
1390 }
1391 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1392 goto erret;
1393 }
1394 retval = TRUE;
1395
1396 erret:
1397 AsnUnlinkType(orig); /* unlink local tree */
1398 return retval;
1399 }
1400
1401
1402
1403 /**************************************************
1404 *
1405 * BiostrucReplaceNew()
1406 *
1407 **************************************************/
1408
1409 BiostrucReplacePtr LIBCALL
BiostrucReplaceNew(void)1410 BiostrucReplaceNew(void)
1411 {
1412 BiostrucReplacePtr ptr = MemNew((size_t) sizeof(BiostrucReplace));
1413
1414 return ptr;
1415
1416 }
1417
1418
1419 /**************************************************
1420 *
1421 * BiostrucReplaceFree()
1422 *
1423 **************************************************/
1424
1425 BiostrucReplacePtr LIBCALL
BiostrucReplaceFree(BiostrucReplacePtr ptr)1426 BiostrucReplaceFree(BiostrucReplacePtr ptr)
1427 {
1428
1429 if(ptr == NULL) {
1430 return NULL;
1431 }
1432 BiostrucIdFree(ptr -> id);
1433 DateFree(ptr -> date);
1434 return MemFree(ptr);
1435 }
1436
1437
1438 /**************************************************
1439 *
1440 * BiostrucReplaceAsnRead()
1441 *
1442 **************************************************/
1443
1444 BiostrucReplacePtr LIBCALL
BiostrucReplaceAsnRead(AsnIoPtr aip,AsnTypePtr orig)1445 BiostrucReplaceAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1446 {
1447 DataVal av;
1448 AsnTypePtr atp;
1449 Boolean isError = FALSE;
1450 AsnReadFunc func;
1451 BiostrucReplacePtr ptr;
1452
1453 if (! loaded)
1454 {
1455 if (! objmmdb1AsnLoad()) {
1456 return NULL;
1457 }
1458 }
1459
1460 if (aip == NULL) {
1461 return NULL;
1462 }
1463
1464 if (orig == NULL) { /* BiostrucReplace ::= (self contained) */
1465 atp = AsnReadId(aip, amp, BIOSTRUC_REPLACE);
1466 } else {
1467 atp = AsnLinkType(orig, BIOSTRUC_REPLACE);
1468 }
1469 /* link in local tree */
1470 if (atp == NULL) {
1471 return NULL;
1472 }
1473
1474 ptr = BiostrucReplaceNew();
1475 if (ptr == NULL) {
1476 goto erret;
1477 }
1478 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1479 goto erret;
1480 }
1481
1482 atp = AsnReadId(aip,amp, atp);
1483 func = NULL;
1484
1485 if (atp == BIOSTRUC_REPLACE_id) {
1486 ptr -> id = BiostrucIdAsnRead(aip, atp);
1487 if (aip -> io_failure) {
1488 goto erret;
1489 }
1490 atp = AsnReadId(aip,amp, atp);
1491 }
1492 if (atp == BIOSTRUC_REPLACE_date) {
1493 ptr -> date = DateAsnRead(aip, atp);
1494 if (aip -> io_failure) {
1495 goto erret;
1496 }
1497 atp = AsnReadId(aip,amp, atp);
1498 }
1499
1500 if (AsnReadVal(aip, atp, &av) <= 0) {
1501 goto erret;
1502 }
1503 /* end struct */
1504
1505 ret:
1506 AsnUnlinkType(orig); /* unlink local tree */
1507 return ptr;
1508
1509 erret:
1510 aip -> io_failure = TRUE;
1511 ptr = BiostrucReplaceFree(ptr);
1512 goto ret;
1513 }
1514
1515
1516
1517 /**************************************************
1518 *
1519 * BiostrucReplaceAsnWrite()
1520 *
1521 **************************************************/
1522 Boolean LIBCALL
BiostrucReplaceAsnWrite(BiostrucReplacePtr ptr,AsnIoPtr aip,AsnTypePtr orig)1523 BiostrucReplaceAsnWrite(BiostrucReplacePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1524 {
1525 AsnTypePtr atp;
1526 Boolean retval = FALSE;
1527
1528 if (! loaded)
1529 {
1530 if (! objmmdb1AsnLoad()) {
1531 return FALSE;
1532 }
1533 }
1534
1535 if (aip == NULL) {
1536 return FALSE;
1537 }
1538
1539 atp = AsnLinkType(orig, BIOSTRUC_REPLACE); /* link local tree */
1540 if (atp == NULL) {
1541 return FALSE;
1542 }
1543
1544 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1545 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1546 goto erret;
1547 }
1548
1549 if (ptr -> id != NULL) {
1550 if ( ! BiostrucIdAsnWrite(ptr -> id, aip, BIOSTRUC_REPLACE_id)) {
1551 goto erret;
1552 }
1553 }
1554 if (ptr -> date != NULL) {
1555 if ( ! DateAsnWrite(ptr -> date, aip, BIOSTRUC_REPLACE_date)) {
1556 goto erret;
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 /**************************************************
1572 *
1573 * BiostrucSourceNew()
1574 *
1575 **************************************************/
1576
1577 BiostrucSourcePtr LIBCALL
BiostrucSourceNew(void)1578 BiostrucSourceNew(void)
1579 {
1580 BiostrucSourcePtr ptr = MemNew((size_t) sizeof(BiostrucSource));
1581
1582 return ptr;
1583
1584 }
1585
1586
1587 /**************************************************
1588 *
1589 * BiostrucSourceFree()
1590 *
1591 **************************************************/
1592
1593 BiostrucSourcePtr LIBCALL
BiostrucSourceFree(BiostrucSourcePtr ptr)1594 BiostrucSourceFree(BiostrucSourcePtr ptr)
1595 {
1596
1597 if(ptr == NULL) {
1598 return NULL;
1599 }
1600 MemFree(ptr -> name_of_database);
1601 VersionOfDatabase_version_of_databaseFree(ptr -> VersionOfDatabase_version_of_database);
1602 BiostrucIdFree(ptr -> database_entry_id);
1603 DateFree(ptr -> database_entry_date);
1604 AsnGenericBaseSeqOfFree(ptr -> database_entry_history ,ASNCODE_PTRVAL_SLOT);
1605 return MemFree(ptr);
1606 }
1607
1608
1609 /**************************************************
1610 *
1611 * VersionOfDatabase_version_of_databaseFree()
1612 *
1613 **************************************************/
1614 static
1615 VersionOfDatabase_version_of_databasePtr LIBCALL
VersionOfDatabase_version_of_databaseFree(ValNodePtr anp)1616 VersionOfDatabase_version_of_databaseFree(ValNodePtr anp)
1617 {
1618 Pointer pnt;
1619
1620 if (anp == NULL) {
1621 return NULL;
1622 }
1623
1624 pnt = anp->data.ptrvalue;
1625 switch (anp->choice)
1626 {
1627 default:
1628 break;
1629 case VersionOfDatabase_version_of_database_release_date:
1630 DateFree(anp -> data.ptrvalue);
1631 break;
1632 case VersionOfDatabase_version_of_database_release_code:
1633 MemFree(anp -> data.ptrvalue);
1634 break;
1635 }
1636 return MemFree(anp);
1637 }
1638
1639
1640 /**************************************************
1641 *
1642 * BiostrucSourceAsnRead()
1643 *
1644 **************************************************/
1645
1646 BiostrucSourcePtr LIBCALL
BiostrucSourceAsnRead(AsnIoPtr aip,AsnTypePtr orig)1647 BiostrucSourceAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1648 {
1649 DataVal av;
1650 AsnTypePtr atp;
1651 Boolean isError = FALSE;
1652 AsnReadFunc func;
1653 BiostrucSourcePtr ptr;
1654
1655 if (! loaded)
1656 {
1657 if (! objmmdb1AsnLoad()) {
1658 return NULL;
1659 }
1660 }
1661
1662 if (aip == NULL) {
1663 return NULL;
1664 }
1665
1666 if (orig == NULL) { /* BiostrucSource ::= (self contained) */
1667 atp = AsnReadId(aip, amp, BIOSTRUC_SOURCE);
1668 } else {
1669 atp = AsnLinkType(orig, BIOSTRUC_SOURCE);
1670 }
1671 /* link in local tree */
1672 if (atp == NULL) {
1673 return NULL;
1674 }
1675
1676 ptr = BiostrucSourceNew();
1677 if (ptr == NULL) {
1678 goto erret;
1679 }
1680 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1681 goto erret;
1682 }
1683
1684 atp = AsnReadId(aip,amp, atp);
1685 func = NULL;
1686
1687 if (atp == BIOSTRUC_SOURCE_name_of_database) {
1688 if ( AsnReadVal(aip, atp, &av) <= 0) {
1689 goto erret;
1690 }
1691 ptr -> name_of_database = av.ptrvalue;
1692 atp = AsnReadId(aip,amp, atp);
1693 }
1694 if (atp == BIOSTRUC_SOURCE_version_of_database) {
1695 ptr -> VersionOfDatabase_version_of_database = VersionOfDatabase_version_of_databaseAsnRead(aip, atp);
1696 if (aip -> io_failure) {
1697 goto erret;
1698 }
1699 atp = AsnReadId(aip,amp, atp);
1700 }
1701 if (atp == BIOSTRUC_SOURCE_database_entry_id) {
1702 ptr -> database_entry_id = BiostrucIdAsnRead(aip, atp);
1703 if (aip -> io_failure) {
1704 goto erret;
1705 }
1706 atp = AsnReadId(aip,amp, atp);
1707 }
1708 if (atp == BIOSTRUC_SOURCE_database_entry_date) {
1709 ptr -> database_entry_date = DateAsnRead(aip, atp);
1710 if (aip -> io_failure) {
1711 goto erret;
1712 }
1713 atp = AsnReadId(aip,amp, atp);
1714 }
1715 if (atp == BIOSTRUC_SOURCE_database_entry_history) {
1716 ptr -> database_entry_history = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
1717 if (isError && ptr -> database_entry_history == NULL) {
1718 goto erret;
1719 }
1720 atp = AsnReadId(aip,amp, atp);
1721 }
1722
1723 if (AsnReadVal(aip, atp, &av) <= 0) {
1724 goto erret;
1725 }
1726 /* end struct */
1727
1728 ret:
1729 AsnUnlinkType(orig); /* unlink local tree */
1730 return ptr;
1731
1732 erret:
1733 aip -> io_failure = TRUE;
1734 ptr = BiostrucSourceFree(ptr);
1735 goto ret;
1736 }
1737
1738
1739
1740 /**************************************************
1741 *
1742 * VersionOfDatabase_version_of_databaseAsnRead()
1743 *
1744 **************************************************/
1745 static
1746 VersionOfDatabase_version_of_databasePtr LIBCALL
VersionOfDatabase_version_of_databaseAsnRead(AsnIoPtr aip,AsnTypePtr orig)1747 VersionOfDatabase_version_of_databaseAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1748 {
1749 DataVal av;
1750 AsnTypePtr atp;
1751 ValNodePtr anp;
1752 Uint1 choice;
1753 Boolean isError = FALSE;
1754 Boolean nullIsError = FALSE;
1755 AsnReadFunc func;
1756
1757 if (! loaded)
1758 {
1759 if (! objmmdb1AsnLoad()) {
1760 return NULL;
1761 }
1762 }
1763
1764 if (aip == NULL) {
1765 return NULL;
1766 }
1767
1768 if (orig == NULL) { /* VersionOfDatabase_version_of_database ::= (self contained) */
1769 atp = AsnReadId(aip, amp, BIOSTRUC_SOURCE_version_of_database);
1770 } else {
1771 atp = AsnLinkType(orig, BIOSTRUC_SOURCE_version_of_database); /* link in local tree */
1772 }
1773 if (atp == NULL) {
1774 return NULL;
1775 }
1776
1777 anp = ValNodeNew(NULL);
1778 if (anp == NULL) {
1779 goto erret;
1780 }
1781 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
1782 goto erret;
1783 }
1784
1785 func = NULL;
1786
1787 atp = AsnReadId(aip, amp, atp); /* find the choice */
1788 if (atp == NULL) {
1789 goto erret;
1790 }
1791 if (atp == BIOSTRUC_SOURCE_version_of_database_release_date) {
1792 choice = VersionOfDatabase_version_of_database_release_date;
1793 func = (AsnReadFunc) DateAsnRead;
1794 }
1795 else if (atp == BIOSTRUC_SOURCE_version_of_database_release_code) {
1796 choice = VersionOfDatabase_version_of_database_release_code;
1797 if (AsnReadVal(aip, atp, &av) <= 0) {
1798 goto erret;
1799 }
1800 anp->data.ptrvalue = av.ptrvalue;
1801 }
1802 anp->choice = choice;
1803 if (func != NULL)
1804 {
1805 anp->data.ptrvalue = (* func)(aip, atp);
1806 if (aip -> io_failure) goto erret;
1807
1808 if (nullIsError && anp->data.ptrvalue == NULL) {
1809 goto erret;
1810 }
1811 }
1812
1813 ret:
1814 AsnUnlinkType(orig); /* unlink local tree */
1815 return anp;
1816
1817 erret:
1818 anp = MemFree(anp);
1819 aip -> io_failure = TRUE;
1820 goto ret;
1821 }
1822
1823
1824 /**************************************************
1825 *
1826 * BiostrucSourceAsnWrite()
1827 *
1828 **************************************************/
1829 Boolean LIBCALL
BiostrucSourceAsnWrite(BiostrucSourcePtr ptr,AsnIoPtr aip,AsnTypePtr orig)1830 BiostrucSourceAsnWrite(BiostrucSourcePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1831 {
1832 DataVal av;
1833 AsnTypePtr atp;
1834 Boolean retval = FALSE;
1835
1836 if (! loaded)
1837 {
1838 if (! objmmdb1AsnLoad()) {
1839 return FALSE;
1840 }
1841 }
1842
1843 if (aip == NULL) {
1844 return FALSE;
1845 }
1846
1847 atp = AsnLinkType(orig, BIOSTRUC_SOURCE); /* link local tree */
1848 if (atp == NULL) {
1849 return FALSE;
1850 }
1851
1852 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1853 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1854 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1855 goto erret;
1856 }
1857
1858 if (ptr -> name_of_database != NULL) {
1859 av.ptrvalue = ptr -> name_of_database;
1860 retval = AsnWrite(aip, BIOSTRUC_SOURCE_name_of_database, &av);
1861 }
1862 if (ptr -> VersionOfDatabase_version_of_database != NULL) {
1863 if ( ! VersionOfDatabase_version_of_databaseAsnWrite(ptr -> VersionOfDatabase_version_of_database, aip, BIOSTRUC_SOURCE_version_of_database)) {
1864 goto erret;
1865 }
1866 }
1867 if (ptr -> database_entry_id != NULL) {
1868 if ( ! BiostrucIdAsnWrite(ptr -> database_entry_id, aip, BIOSTRUC_SOURCE_database_entry_id)) {
1869 goto erret;
1870 }
1871 }
1872 if (ptr -> database_entry_date != NULL) {
1873 if ( ! DateAsnWrite(ptr -> database_entry_date, aip, BIOSTRUC_SOURCE_database_entry_date)) {
1874 goto erret;
1875 }
1876 }
1877 retval = AsnGenericBaseSeqOfAsnWrite(ptr -> database_entry_history ,ASNCODE_PTRVAL_SLOT, aip, BIOSTRUC_SOURCE_database_entry_history, BIOSTRUC_SOURCE_database_entry_history_E);
1878 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1879 goto erret;
1880 }
1881 retval = TRUE;
1882
1883 erret:
1884 AsnUnlinkType(orig); /* unlink local tree */
1885 return retval;
1886 }
1887
1888
1889
1890 /**************************************************
1891 *
1892 * VersionOfDatabase_version_of_databaseAsnWrite()
1893 *
1894 **************************************************/
1895 static Boolean LIBCALL
VersionOfDatabase_version_of_databaseAsnWrite(VersionOfDatabase_version_of_databasePtr anp,AsnIoPtr aip,AsnTypePtr orig)1896 VersionOfDatabase_version_of_databaseAsnWrite(VersionOfDatabase_version_of_databasePtr anp, AsnIoPtr aip, AsnTypePtr orig)
1897
1898 {
1899 DataVal av;
1900 AsnTypePtr atp, writetype = NULL;
1901 Pointer pnt;
1902 AsnWriteFunc func = NULL;
1903 Boolean retval = FALSE;
1904
1905 if (! loaded)
1906 {
1907 if (! objmmdb1AsnLoad())
1908 return FALSE;
1909 }
1910
1911 if (aip == NULL)
1912 return FALSE;
1913
1914 atp = AsnLinkType(orig, BIOSTRUC_SOURCE_version_of_database); /* link local tree */
1915 if (atp == NULL) {
1916 return FALSE;
1917 }
1918
1919 if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1920 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1921 av.ptrvalue = (Pointer)anp;
1922 if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
1923 goto erret;
1924 }
1925
1926 pnt = anp->data.ptrvalue;
1927 switch (anp->choice)
1928 {
1929 case VersionOfDatabase_version_of_database_release_date:
1930 writetype = BIOSTRUC_SOURCE_version_of_database_release_date;
1931 func = (AsnWriteFunc) DateAsnWrite;
1932 break;
1933 case VersionOfDatabase_version_of_database_release_code:
1934 av.ptrvalue = anp->data.ptrvalue;
1935 retval = AsnWrite(aip, BIOSTRUC_SOURCE_version_of_database_release_code, &av);
1936 break;
1937 }
1938 if (writetype != NULL) {
1939 retval = (* func)(pnt, aip, writetype); /* write it out */
1940 }
1941 if (!retval) {
1942 goto erret;
1943 }
1944 retval = TRUE;
1945
1946 erret:
1947 AsnUnlinkType(orig); /* unlink local tree */
1948 return retval;
1949 }
1950
1951
1952 /**************************************************
1953 *
1954 * BiostrucGraphNew()
1955 *
1956 **************************************************/
1957
1958 BiostrucGraphPtr LIBCALL
BiostrucGraphNew(void)1959 BiostrucGraphNew(void)
1960 {
1961 BiostrucGraphPtr ptr = MemNew((size_t) sizeof(BiostrucGraph));
1962
1963 return ptr;
1964
1965 }
1966
1967
1968 /**************************************************
1969 *
1970 * BiostrucGraphFree()
1971 *
1972 **************************************************/
1973
1974 BiostrucGraphPtr LIBCALL
BiostrucGraphFree(BiostrucGraphPtr ptr)1975 BiostrucGraphFree(BiostrucGraphPtr ptr)
1976 {
1977
1978 if(ptr == NULL) {
1979 return NULL;
1980 }
1981 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiomolDescrFree);
1982 AsnGenericUserSeqOfFree(ptr -> molecule_graphs, (AsnOptFreeFunc) MoleculeGraphFree);
1983 AsnGenericUserSeqOfFree(ptr -> inter_molecule_bonds, (AsnOptFreeFunc) InterResidueBondFree);
1984 AsnGenericUserSeqOfFree(ptr -> residue_graphs, (AsnOptFreeFunc) ResidueGraphFree);
1985 return MemFree(ptr);
1986 }
1987
1988
1989 /**************************************************
1990 *
1991 * BiostrucGraphAsnRead()
1992 *
1993 **************************************************/
1994
1995 BiostrucGraphPtr LIBCALL
BiostrucGraphAsnRead(AsnIoPtr aip,AsnTypePtr orig)1996 BiostrucGraphAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1997 {
1998 DataVal av;
1999 AsnTypePtr atp;
2000 Boolean isError = FALSE;
2001 AsnReadFunc func;
2002 BiostrucGraphPtr ptr;
2003
2004 if (! loaded)
2005 {
2006 if (! objmmdb1AsnLoad()) {
2007 return NULL;
2008 }
2009 }
2010
2011 if (aip == NULL) {
2012 return NULL;
2013 }
2014
2015 if (orig == NULL) { /* BiostrucGraph ::= (self contained) */
2016 atp = AsnReadId(aip, amp, BIOSTRUC_GRAPH);
2017 } else {
2018 atp = AsnLinkType(orig, BIOSTRUC_GRAPH);
2019 }
2020 /* link in local tree */
2021 if (atp == NULL) {
2022 return NULL;
2023 }
2024
2025 ptr = BiostrucGraphNew();
2026 if (ptr == NULL) {
2027 goto erret;
2028 }
2029 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2030 goto erret;
2031 }
2032
2033 atp = AsnReadId(aip,amp, atp);
2034 func = NULL;
2035
2036 if (atp == BIOSTRUC_GRAPH_descr) {
2037 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiomolDescrAsnRead, (AsnOptFreeFunc) BiomolDescrFree);
2038 if (isError && ptr -> descr == NULL) {
2039 goto erret;
2040 }
2041 atp = AsnReadId(aip,amp, atp);
2042 }
2043 if (atp == BIOSTRUC_GRAPH_molecule_graphs) {
2044 ptr -> molecule_graphs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) MoleculeGraphAsnRead, (AsnOptFreeFunc) MoleculeGraphFree);
2045 if (isError && ptr -> molecule_graphs == NULL) {
2046 goto erret;
2047 }
2048 atp = AsnReadId(aip,amp, atp);
2049 }
2050 if (atp == BIOSTRUC_GRAPH_inter_molecule_bonds) {
2051 ptr -> inter_molecule_bonds = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) InterResidueBondAsnRead, (AsnOptFreeFunc) InterResidueBondFree);
2052 if (isError && ptr -> inter_molecule_bonds == NULL) {
2053 goto erret;
2054 }
2055 atp = AsnReadId(aip,amp, atp);
2056 }
2057 if (atp == BIOSTRUC_GRAPH_residue_graphs) {
2058 ptr -> residue_graphs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ResidueGraphAsnRead, (AsnOptFreeFunc) ResidueGraphFree);
2059 if (isError && ptr -> residue_graphs == NULL) {
2060 goto erret;
2061 }
2062 atp = AsnReadId(aip,amp, atp);
2063 }
2064
2065 if (AsnReadVal(aip, atp, &av) <= 0) {
2066 goto erret;
2067 }
2068 /* end struct */
2069
2070 ret:
2071 AsnUnlinkType(orig); /* unlink local tree */
2072 return ptr;
2073
2074 erret:
2075 aip -> io_failure = TRUE;
2076 ptr = BiostrucGraphFree(ptr);
2077 goto ret;
2078 }
2079
2080
2081
2082 /**************************************************
2083 *
2084 * BiostrucGraphAsnWrite()
2085 *
2086 **************************************************/
2087 Boolean LIBCALL
BiostrucGraphAsnWrite(BiostrucGraphPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2088 BiostrucGraphAsnWrite(BiostrucGraphPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2089 {
2090 AsnTypePtr atp;
2091 Boolean retval = FALSE;
2092
2093 if (! loaded)
2094 {
2095 if (! objmmdb1AsnLoad()) {
2096 return FALSE;
2097 }
2098 }
2099
2100 if (aip == NULL) {
2101 return FALSE;
2102 }
2103
2104 atp = AsnLinkType(orig, BIOSTRUC_GRAPH); /* link local tree */
2105 if (atp == NULL) {
2106 return FALSE;
2107 }
2108
2109 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2110 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2111 goto erret;
2112 }
2113
2114 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiomolDescrAsnWrite, aip, BIOSTRUC_GRAPH_descr, BIOSTRUC_GRAPH_descr_E);
2115 AsnGenericUserSeqOfAsnWrite(ptr -> molecule_graphs, (AsnWriteFunc) MoleculeGraphAsnWrite, aip, BIOSTRUC_GRAPH_molecule_graphs, BIOSTRUC_GRAPH_molecule_graphs_E);
2116 AsnGenericUserSeqOfAsnWrite(ptr -> inter_molecule_bonds, (AsnWriteFunc) InterResidueBondAsnWrite, aip, BIOSTRUC_GRAPH_inter_molecule_bonds, BIOSTRUC_GRAPH_inter_molecule_bonds_E);
2117 AsnGenericUserSeqOfAsnWrite(ptr -> residue_graphs, (AsnWriteFunc) ResidueGraphAsnWrite, aip, BIOSTRUC_GRAPH_residue_graphs, BIOSTRUC_GRAPH_residue_graphs_E);
2118 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2119 goto erret;
2120 }
2121 retval = TRUE;
2122
2123 erret:
2124 AsnUnlinkType(orig); /* unlink local tree */
2125 return retval;
2126 }
2127
2128
2129
2130 /**************************************************
2131 *
2132 * BiomolDescrFree()
2133 *
2134 **************************************************/
2135
2136 BiomolDescrPtr LIBCALL
BiomolDescrFree(ValNodePtr anp)2137 BiomolDescrFree(ValNodePtr anp)
2138 {
2139 Pointer pnt;
2140
2141 if (anp == NULL) {
2142 return NULL;
2143 }
2144
2145 pnt = anp->data.ptrvalue;
2146 switch (anp->choice)
2147 {
2148 default:
2149 break;
2150 case BiomolDescr_name:
2151 MemFree(anp -> data.ptrvalue);
2152 break;
2153 case BiomolDescr_pdb_class:
2154 MemFree(anp -> data.ptrvalue);
2155 break;
2156 case BiomolDescr_pdb_source:
2157 MemFree(anp -> data.ptrvalue);
2158 break;
2159 case BiomolDescr_pdb_comment:
2160 MemFree(anp -> data.ptrvalue);
2161 break;
2162 case BiomolDescr_other_comment:
2163 MemFree(anp -> data.ptrvalue);
2164 break;
2165 case BiomolDescr_organism:
2166 BioSourceFree(anp -> data.ptrvalue);
2167 break;
2168 case BiomolDescr_attribution:
2169 PubFree(anp -> data.ptrvalue);
2170 break;
2171 }
2172 return MemFree(anp);
2173 }
2174
2175
2176 /**************************************************
2177 *
2178 * BiomolDescrAsnRead()
2179 *
2180 **************************************************/
2181
2182 BiomolDescrPtr LIBCALL
BiomolDescrAsnRead(AsnIoPtr aip,AsnTypePtr orig)2183 BiomolDescrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2184 {
2185 DataVal av;
2186 AsnTypePtr atp;
2187 ValNodePtr anp;
2188 Uint1 choice;
2189 Boolean isError = FALSE;
2190 Boolean nullIsError = FALSE;
2191 AsnReadFunc func;
2192
2193 if (! loaded)
2194 {
2195 if (! objmmdb1AsnLoad()) {
2196 return NULL;
2197 }
2198 }
2199
2200 if (aip == NULL) {
2201 return NULL;
2202 }
2203
2204 if (orig == NULL) { /* BiomolDescr ::= (self contained) */
2205 atp = AsnReadId(aip, amp, BIOMOL_DESCR);
2206 } else {
2207 atp = AsnLinkType(orig, BIOMOL_DESCR); /* link in local tree */
2208 }
2209 if (atp == NULL) {
2210 return NULL;
2211 }
2212
2213 anp = ValNodeNew(NULL);
2214 if (anp == NULL) {
2215 goto erret;
2216 }
2217 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
2218 goto erret;
2219 }
2220
2221 func = NULL;
2222
2223 atp = AsnReadId(aip, amp, atp); /* find the choice */
2224 if (atp == NULL) {
2225 goto erret;
2226 }
2227 if (atp == BIOMOL_DESCR_name) {
2228 choice = BiomolDescr_name;
2229 if (AsnReadVal(aip, atp, &av) <= 0) {
2230 goto erret;
2231 }
2232 anp->data.ptrvalue = av.ptrvalue;
2233 }
2234 else if (atp == BIOMOL_DESCR_pdb_class) {
2235 choice = BiomolDescr_pdb_class;
2236 if (AsnReadVal(aip, atp, &av) <= 0) {
2237 goto erret;
2238 }
2239 anp->data.ptrvalue = av.ptrvalue;
2240 }
2241 else if (atp == BIOMOL_DESCR_pdb_source) {
2242 choice = BiomolDescr_pdb_source;
2243 if (AsnReadVal(aip, atp, &av) <= 0) {
2244 goto erret;
2245 }
2246 anp->data.ptrvalue = av.ptrvalue;
2247 }
2248 else if (atp == BIOMOL_DESCR_pdb_comment) {
2249 choice = BiomolDescr_pdb_comment;
2250 if (AsnReadVal(aip, atp, &av) <= 0) {
2251 goto erret;
2252 }
2253 anp->data.ptrvalue = av.ptrvalue;
2254 }
2255 else if (atp == BIOMOL_DESCR_other_comment) {
2256 choice = BiomolDescr_other_comment;
2257 if (AsnReadVal(aip, atp, &av) <= 0) {
2258 goto erret;
2259 }
2260 anp->data.ptrvalue = av.ptrvalue;
2261 }
2262 else if (atp == BIOMOL_DESCR_organism) {
2263 choice = BiomolDescr_organism;
2264 func = (AsnReadFunc) BioSourceAsnRead;
2265 }
2266 else if (atp == BIOMOL_DESCR_attribution) {
2267 choice = BiomolDescr_attribution;
2268 func = (AsnReadFunc) PubAsnRead;
2269 }
2270 else if (atp == BIOMOL_DESCR_assembly_type) {
2271 choice = BiomolDescr_assembly_type;
2272 if (AsnReadVal(aip, atp, &av) <= 0) {
2273 goto erret;
2274 }
2275 anp->data.intvalue = av.intvalue;
2276 }
2277 else if (atp == BIOMOL_DESCR_molecule_type) {
2278 choice = BiomolDescr_molecule_type;
2279 if (AsnReadVal(aip, atp, &av) <= 0) {
2280 goto erret;
2281 }
2282 anp->data.intvalue = av.intvalue;
2283 }
2284 anp->choice = choice;
2285 if (func != NULL)
2286 {
2287 anp->data.ptrvalue = (* func)(aip, atp);
2288 if (aip -> io_failure) goto erret;
2289
2290 if (nullIsError && anp->data.ptrvalue == NULL) {
2291 goto erret;
2292 }
2293 }
2294
2295 ret:
2296 AsnUnlinkType(orig); /* unlink local tree */
2297 return anp;
2298
2299 erret:
2300 anp = MemFree(anp);
2301 aip -> io_failure = TRUE;
2302 goto ret;
2303 }
2304
2305
2306 /**************************************************
2307 *
2308 * BiomolDescrAsnWrite()
2309 *
2310 **************************************************/
2311 Boolean LIBCALL
BiomolDescrAsnWrite(BiomolDescrPtr anp,AsnIoPtr aip,AsnTypePtr orig)2312 BiomolDescrAsnWrite(BiomolDescrPtr anp, AsnIoPtr aip, AsnTypePtr orig)
2313
2314 {
2315 DataVal av;
2316 AsnTypePtr atp, writetype = NULL;
2317 Pointer pnt;
2318 AsnWriteFunc func = NULL;
2319 Boolean retval = FALSE;
2320
2321 if (! loaded)
2322 {
2323 if (! objmmdb1AsnLoad())
2324 return FALSE;
2325 }
2326
2327 if (aip == NULL)
2328 return FALSE;
2329
2330 atp = AsnLinkType(orig, BIOMOL_DESCR); /* link local tree */
2331 if (atp == NULL) {
2332 return FALSE;
2333 }
2334
2335 if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2336 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2337 av.ptrvalue = (Pointer)anp;
2338 if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
2339 goto erret;
2340 }
2341
2342 pnt = anp->data.ptrvalue;
2343 switch (anp->choice)
2344 {
2345 case BiomolDescr_name:
2346 av.ptrvalue = anp->data.ptrvalue;
2347 retval = AsnWrite(aip, BIOMOL_DESCR_name, &av);
2348 break;
2349 case BiomolDescr_pdb_class:
2350 av.ptrvalue = anp->data.ptrvalue;
2351 retval = AsnWrite(aip, BIOMOL_DESCR_pdb_class, &av);
2352 break;
2353 case BiomolDescr_pdb_source:
2354 av.ptrvalue = anp->data.ptrvalue;
2355 retval = AsnWrite(aip, BIOMOL_DESCR_pdb_source, &av);
2356 break;
2357 case BiomolDescr_pdb_comment:
2358 av.ptrvalue = anp->data.ptrvalue;
2359 retval = AsnWrite(aip, BIOMOL_DESCR_pdb_comment, &av);
2360 break;
2361 case BiomolDescr_other_comment:
2362 av.ptrvalue = anp->data.ptrvalue;
2363 retval = AsnWrite(aip, BIOMOL_DESCR_other_comment, &av);
2364 break;
2365 case BiomolDescr_organism:
2366 writetype = BIOMOL_DESCR_organism;
2367 func = (AsnWriteFunc) BioSourceAsnWrite;
2368 break;
2369 case BiomolDescr_attribution:
2370 writetype = BIOMOL_DESCR_attribution;
2371 func = (AsnWriteFunc) PubAsnWrite;
2372 break;
2373 case BiomolDescr_assembly_type:
2374 av.intvalue = anp->data.intvalue;
2375 retval = AsnWrite(aip, BIOMOL_DESCR_assembly_type, &av);
2376 break;
2377 case BiomolDescr_molecule_type:
2378 av.intvalue = anp->data.intvalue;
2379 retval = AsnWrite(aip, BIOMOL_DESCR_molecule_type, &av);
2380 break;
2381 }
2382 if (writetype != NULL) {
2383 retval = (* func)(pnt, aip, writetype); /* write it out */
2384 }
2385 if (!retval) {
2386 goto erret;
2387 }
2388 retval = TRUE;
2389
2390 erret:
2391 AsnUnlinkType(orig); /* unlink local tree */
2392 return retval;
2393 }
2394
2395
2396 /**************************************************
2397 *
2398 * ResidueGraphNew()
2399 *
2400 **************************************************/
2401
2402 ResidueGraphPtr LIBCALL
ResidueGraphNew(void)2403 ResidueGraphNew(void)
2404 {
2405 ResidueGraphPtr ptr = MemNew((size_t) sizeof(ResidueGraph));
2406
2407 return ptr;
2408
2409 }
2410
2411
2412 /**************************************************
2413 *
2414 * ResidueGraphFree()
2415 *
2416 **************************************************/
2417
2418 ResidueGraphPtr LIBCALL
ResidueGraphFree(ResidueGraphPtr ptr)2419 ResidueGraphFree(ResidueGraphPtr ptr)
2420 {
2421
2422 if(ptr == NULL) {
2423 return NULL;
2424 }
2425 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiomolDescrFree);
2426 AsnGenericBaseSeqOfFree(ptr -> iupac_code ,ASNCODE_PTRVAL_SLOT);
2427 AsnGenericUserSeqOfFree(ptr -> atoms, (AsnOptFreeFunc) AtomFree);
2428 AsnGenericUserSeqOfFree(ptr -> bonds, (AsnOptFreeFunc) IntraResidueBondFree);
2429 AsnGenericUserSeqOfFree(ptr -> chiral_centers, (AsnOptFreeFunc) ChiralCenterFree);
2430 return MemFree(ptr);
2431 }
2432
2433
2434 /**************************************************
2435 *
2436 * ResidueGraphAsnRead()
2437 *
2438 **************************************************/
2439
2440 ResidueGraphPtr LIBCALL
ResidueGraphAsnRead(AsnIoPtr aip,AsnTypePtr orig)2441 ResidueGraphAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2442 {
2443 DataVal av;
2444 AsnTypePtr atp;
2445 Boolean isError = FALSE;
2446 AsnReadFunc func;
2447 ResidueGraphPtr ptr;
2448
2449 if (! loaded)
2450 {
2451 if (! objmmdb1AsnLoad()) {
2452 return NULL;
2453 }
2454 }
2455
2456 if (aip == NULL) {
2457 return NULL;
2458 }
2459
2460 if (orig == NULL) { /* ResidueGraph ::= (self contained) */
2461 atp = AsnReadId(aip, amp, RESIDUE_GRAPH);
2462 } else {
2463 atp = AsnLinkType(orig, RESIDUE_GRAPH);
2464 }
2465 /* link in local tree */
2466 if (atp == NULL) {
2467 return NULL;
2468 }
2469
2470 ptr = ResidueGraphNew();
2471 if (ptr == NULL) {
2472 goto erret;
2473 }
2474 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2475 goto erret;
2476 }
2477
2478 atp = AsnReadId(aip,amp, atp);
2479 func = NULL;
2480
2481 if (atp == RESIDUE_GRAPH_id) {
2482 if ( AsnReadVal(aip, atp, &av) <= 0) {
2483 goto erret;
2484 }
2485 ptr -> id = av.intvalue;
2486 atp = AsnReadId(aip,amp, atp);
2487 }
2488 if (atp == RESIDUE_GRAPH_descr) {
2489 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiomolDescrAsnRead, (AsnOptFreeFunc) BiomolDescrFree);
2490 if (isError && ptr -> descr == NULL) {
2491 goto erret;
2492 }
2493 atp = AsnReadId(aip,amp, atp);
2494 }
2495 if (atp == RESIDUE_GRAPH_residue_type) {
2496 if ( AsnReadVal(aip, atp, &av) <= 0) {
2497 goto erret;
2498 }
2499 ptr -> residue_type = av.intvalue;
2500 ptr -> OBbits__ |= 1<<0;
2501 atp = AsnReadId(aip,amp, atp);
2502 }
2503 if (atp == RESIDUE_GRAPH_iupac_code) {
2504 ptr -> iupac_code = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
2505 if (isError && ptr -> iupac_code == NULL) {
2506 goto erret;
2507 }
2508 atp = AsnReadId(aip,amp, atp);
2509 }
2510 if (atp == RESIDUE_GRAPH_atoms) {
2511 ptr -> atoms = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) AtomAsnRead, (AsnOptFreeFunc) AtomFree);
2512 if (isError && ptr -> atoms == NULL) {
2513 goto erret;
2514 }
2515 atp = AsnReadId(aip,amp, atp);
2516 }
2517 if (atp == RESIDUE_GRAPH_bonds) {
2518 ptr -> bonds = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) IntraResidueBondAsnRead, (AsnOptFreeFunc) IntraResidueBondFree);
2519 if (isError && ptr -> bonds == NULL) {
2520 goto erret;
2521 }
2522 atp = AsnReadId(aip,amp, atp);
2523 }
2524 if (atp == RESIDUE_GRAPH_chiral_centers) {
2525 ptr -> chiral_centers = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ChiralCenterAsnRead, (AsnOptFreeFunc) ChiralCenterFree);
2526 if (isError && ptr -> chiral_centers == NULL) {
2527 goto erret;
2528 }
2529 atp = AsnReadId(aip,amp, atp);
2530 }
2531
2532 if (AsnReadVal(aip, atp, &av) <= 0) {
2533 goto erret;
2534 }
2535 /* end struct */
2536
2537 ret:
2538 AsnUnlinkType(orig); /* unlink local tree */
2539 return ptr;
2540
2541 erret:
2542 aip -> io_failure = TRUE;
2543 ptr = ResidueGraphFree(ptr);
2544 goto ret;
2545 }
2546
2547
2548
2549 /**************************************************
2550 *
2551 * ResidueGraphAsnWrite()
2552 *
2553 **************************************************/
2554 Boolean LIBCALL
ResidueGraphAsnWrite(ResidueGraphPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2555 ResidueGraphAsnWrite(ResidueGraphPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2556 {
2557 DataVal av;
2558 AsnTypePtr atp;
2559 Boolean retval = FALSE;
2560
2561 if (! loaded)
2562 {
2563 if (! objmmdb1AsnLoad()) {
2564 return FALSE;
2565 }
2566 }
2567
2568 if (aip == NULL) {
2569 return FALSE;
2570 }
2571
2572 atp = AsnLinkType(orig, RESIDUE_GRAPH); /* link local tree */
2573 if (atp == NULL) {
2574 return FALSE;
2575 }
2576
2577 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2578 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2579 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2580 goto erret;
2581 }
2582
2583 av.intvalue = ptr -> id;
2584 retval = AsnWrite(aip, RESIDUE_GRAPH_id, &av);
2585 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiomolDescrAsnWrite, aip, RESIDUE_GRAPH_descr, RESIDUE_GRAPH_descr_E);
2586 if (ptr -> residue_type || (ptr -> OBbits__ & (1<<0) )){ av.intvalue = ptr -> residue_type;
2587 retval = AsnWrite(aip, RESIDUE_GRAPH_residue_type, &av);
2588 }
2589 retval = AsnGenericBaseSeqOfAsnWrite(ptr -> iupac_code ,ASNCODE_PTRVAL_SLOT, aip, RESIDUE_GRAPH_iupac_code, RESIDUE_GRAPH_iupac_code_E);
2590 AsnGenericUserSeqOfAsnWrite(ptr -> atoms, (AsnWriteFunc) AtomAsnWrite, aip, RESIDUE_GRAPH_atoms, RESIDUE_GRAPH_atoms_E);
2591 AsnGenericUserSeqOfAsnWrite(ptr -> bonds, (AsnWriteFunc) IntraResidueBondAsnWrite, aip, RESIDUE_GRAPH_bonds, RESIDUE_GRAPH_bonds_E);
2592 AsnGenericUserSeqOfAsnWrite(ptr -> chiral_centers, (AsnWriteFunc) ChiralCenterAsnWrite, aip, RESIDUE_GRAPH_chiral_centers, RESIDUE_GRAPH_chiral_centers_E);
2593 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2594 goto erret;
2595 }
2596 retval = TRUE;
2597
2598 erret:
2599 AsnUnlinkType(orig); /* unlink local tree */
2600 return retval;
2601 }
2602
2603
2604
2605 /**************************************************
2606 *
2607 * MoleculeGraphNew()
2608 *
2609 **************************************************/
2610
2611 MoleculeGraphPtr LIBCALL
MoleculeGraphNew(void)2612 MoleculeGraphNew(void)
2613 {
2614 MoleculeGraphPtr ptr = MemNew((size_t) sizeof(MoleculeGraph));
2615
2616 return ptr;
2617
2618 }
2619
2620
2621 /**************************************************
2622 *
2623 * MoleculeGraphFree()
2624 *
2625 **************************************************/
2626
2627 MoleculeGraphPtr LIBCALL
MoleculeGraphFree(MoleculeGraphPtr ptr)2628 MoleculeGraphFree(MoleculeGraphPtr ptr)
2629 {
2630
2631 if(ptr == NULL) {
2632 return NULL;
2633 }
2634 AsnGenericChoiceSeqOfFree(ptr -> descr, (AsnOptFreeFunc) BiomolDescrFree);
2635 SeqIdFree(ptr -> seq_id);
2636 AsnGenericUserSeqOfFree(ptr -> residue_sequence, (AsnOptFreeFunc) ResidueFree);
2637 AsnGenericUserSeqOfFree(ptr -> inter_residue_bonds, (AsnOptFreeFunc) InterResidueBondFree);
2638 return MemFree(ptr);
2639 }
2640
2641
2642 /**************************************************
2643 *
2644 * MoleculeGraphAsnRead()
2645 *
2646 **************************************************/
2647
2648 MoleculeGraphPtr LIBCALL
MoleculeGraphAsnRead(AsnIoPtr aip,AsnTypePtr orig)2649 MoleculeGraphAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2650 {
2651 DataVal av;
2652 AsnTypePtr atp;
2653 Boolean isError = FALSE;
2654 AsnReadFunc func;
2655 MoleculeGraphPtr ptr;
2656
2657 if (! loaded)
2658 {
2659 if (! objmmdb1AsnLoad()) {
2660 return NULL;
2661 }
2662 }
2663
2664 if (aip == NULL) {
2665 return NULL;
2666 }
2667
2668 if (orig == NULL) { /* MoleculeGraph ::= (self contained) */
2669 atp = AsnReadId(aip, amp, MOLECULE_GRAPH);
2670 } else {
2671 atp = AsnLinkType(orig, MOLECULE_GRAPH);
2672 }
2673 /* link in local tree */
2674 if (atp == NULL) {
2675 return NULL;
2676 }
2677
2678 ptr = MoleculeGraphNew();
2679 if (ptr == NULL) {
2680 goto erret;
2681 }
2682 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2683 goto erret;
2684 }
2685
2686 atp = AsnReadId(aip,amp, atp);
2687 func = NULL;
2688
2689 if (atp == MOLECULE_GRAPH_id) {
2690 if ( AsnReadVal(aip, atp, &av) <= 0) {
2691 goto erret;
2692 }
2693 ptr -> id = av.intvalue;
2694 atp = AsnReadId(aip,amp, atp);
2695 }
2696 if (atp == MOLECULE_GRAPH_descr) {
2697 ptr -> descr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiomolDescrAsnRead, (AsnOptFreeFunc) BiomolDescrFree);
2698 if (isError && ptr -> descr == NULL) {
2699 goto erret;
2700 }
2701 atp = AsnReadId(aip,amp, atp);
2702 }
2703 if (atp == MOLECULE_GRAPH_seq_id) {
2704 ptr -> seq_id = SeqIdAsnRead(aip, atp);
2705 if (aip -> io_failure) {
2706 goto erret;
2707 }
2708 atp = AsnReadId(aip,amp, atp);
2709 }
2710 if (atp == MOLECULE_GRAPH_residue_sequence) {
2711 ptr -> residue_sequence = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ResidueAsnRead, (AsnOptFreeFunc) ResidueFree);
2712 if (isError && ptr -> residue_sequence == NULL) {
2713 goto erret;
2714 }
2715 atp = AsnReadId(aip,amp, atp);
2716 }
2717 if (atp == MOLECULE_GRAPH_inter_residue_bonds) {
2718 ptr -> inter_residue_bonds = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) InterResidueBondAsnRead, (AsnOptFreeFunc) InterResidueBondFree);
2719 if (isError && ptr -> inter_residue_bonds == NULL) {
2720 goto erret;
2721 }
2722 atp = AsnReadId(aip,amp, atp);
2723 }
2724 if (atp == MOLECULE_GRAPH_sid) {
2725 if ( AsnReadVal(aip, atp, &av) <= 0) {
2726 goto erret;
2727 }
2728 ptr -> sid = av.intvalue;
2729 atp = AsnReadId(aip,amp, atp);
2730 }
2731
2732 if (AsnReadVal(aip, atp, &av) <= 0) {
2733 goto erret;
2734 }
2735 /* end struct */
2736
2737 ret:
2738 AsnUnlinkType(orig); /* unlink local tree */
2739 return ptr;
2740
2741 erret:
2742 aip -> io_failure = TRUE;
2743 ptr = MoleculeGraphFree(ptr);
2744 goto ret;
2745 }
2746
2747
2748
2749 /**************************************************
2750 *
2751 * MoleculeGraphAsnWrite()
2752 *
2753 **************************************************/
2754 Boolean LIBCALL
MoleculeGraphAsnWrite(MoleculeGraphPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2755 MoleculeGraphAsnWrite(MoleculeGraphPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2756 {
2757 DataVal av;
2758 AsnTypePtr atp;
2759 Boolean retval = FALSE;
2760
2761 if (! loaded)
2762 {
2763 if (! objmmdb1AsnLoad()) {
2764 return FALSE;
2765 }
2766 }
2767
2768 if (aip == NULL) {
2769 return FALSE;
2770 }
2771
2772 atp = AsnLinkType(orig, MOLECULE_GRAPH); /* link local tree */
2773 if (atp == NULL) {
2774 return FALSE;
2775 }
2776
2777 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2778 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2779 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2780 goto erret;
2781 }
2782
2783 av.intvalue = ptr -> id;
2784 retval = AsnWrite(aip, MOLECULE_GRAPH_id, &av);
2785 AsnGenericChoiceSeqOfAsnWrite(ptr -> descr, (AsnWriteFunc) BiomolDescrAsnWrite, aip, MOLECULE_GRAPH_descr, MOLECULE_GRAPH_descr_E);
2786 if (ptr -> seq_id != NULL) {
2787 if ( ! SeqIdAsnWrite(ptr -> seq_id, aip, MOLECULE_GRAPH_seq_id)) {
2788 goto erret;
2789 }
2790 }
2791 AsnGenericUserSeqOfAsnWrite(ptr -> residue_sequence, (AsnWriteFunc) ResidueAsnWrite, aip, MOLECULE_GRAPH_residue_sequence, MOLECULE_GRAPH_residue_sequence_E);
2792 AsnGenericUserSeqOfAsnWrite(ptr -> inter_residue_bonds, (AsnWriteFunc) InterResidueBondAsnWrite, aip, MOLECULE_GRAPH_inter_residue_bonds, MOLECULE_GRAPH_inter_residue_bonds_E);
2793 if (ptr -> sid > 0) {
2794 av.intvalue = ptr -> sid;
2795 retval = AsnWrite(aip, MOLECULE_GRAPH_sid, &av);
2796 }
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 * InterResidueBondNew()
2812 *
2813 **************************************************/
2814
2815 InterResidueBondPtr LIBCALL
InterResidueBondNew(void)2816 InterResidueBondNew(void)
2817 {
2818 InterResidueBondPtr ptr = MemNew((size_t) sizeof(InterResidueBond));
2819
2820 return ptr;
2821
2822 }
2823
2824
2825 /**************************************************
2826 *
2827 * InterResidueBondFree()
2828 *
2829 **************************************************/
2830
2831 InterResidueBondPtr LIBCALL
InterResidueBondFree(InterResidueBondPtr ptr)2832 InterResidueBondFree(InterResidueBondPtr ptr)
2833 {
2834
2835 if(ptr == NULL) {
2836 return NULL;
2837 }
2838 AtomPntrFree(ptr -> atom_id_1);
2839 AtomPntrFree(ptr -> atom_id_2);
2840 return MemFree(ptr);
2841 }
2842
2843
2844 /**************************************************
2845 *
2846 * InterResidueBondAsnRead()
2847 *
2848 **************************************************/
2849
2850 InterResidueBondPtr LIBCALL
InterResidueBondAsnRead(AsnIoPtr aip,AsnTypePtr orig)2851 InterResidueBondAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2852 {
2853 DataVal av;
2854 AsnTypePtr atp;
2855 Boolean isError = FALSE;
2856 AsnReadFunc func;
2857 InterResidueBondPtr ptr;
2858
2859 if (! loaded)
2860 {
2861 if (! objmmdb1AsnLoad()) {
2862 return NULL;
2863 }
2864 }
2865
2866 if (aip == NULL) {
2867 return NULL;
2868 }
2869
2870 if (orig == NULL) { /* InterResidueBond ::= (self contained) */
2871 atp = AsnReadId(aip, amp, INTER_RESIDUE_BOND);
2872 } else {
2873 atp = AsnLinkType(orig, INTER_RESIDUE_BOND);
2874 }
2875 /* link in local tree */
2876 if (atp == NULL) {
2877 return NULL;
2878 }
2879
2880 ptr = InterResidueBondNew();
2881 if (ptr == NULL) {
2882 goto erret;
2883 }
2884 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2885 goto erret;
2886 }
2887
2888 atp = AsnReadId(aip,amp, atp);
2889 func = NULL;
2890
2891 if (atp == INTER_RESIDUE_BOND_atom_id_1) {
2892 ptr -> atom_id_1 = AtomPntrAsnRead(aip, atp);
2893 if (aip -> io_failure) {
2894 goto erret;
2895 }
2896 atp = AsnReadId(aip,amp, atp);
2897 }
2898 if (atp == INTER_RESIDUE_BOND_atom_id_2) {
2899 ptr -> atom_id_2 = AtomPntrAsnRead(aip, atp);
2900 if (aip -> io_failure) {
2901 goto erret;
2902 }
2903 atp = AsnReadId(aip,amp, atp);
2904 }
2905 if (atp == INTER_RESIDUE_BOND_bond_order) {
2906 if ( AsnReadVal(aip, atp, &av) <= 0) {
2907 goto erret;
2908 }
2909 ptr -> bond_order = av.intvalue;
2910 ptr -> OBbits__ |= 1<<0;
2911 atp = AsnReadId(aip,amp, atp);
2912 }
2913
2914 if (AsnReadVal(aip, atp, &av) <= 0) {
2915 goto erret;
2916 }
2917 /* end struct */
2918
2919 ret:
2920 AsnUnlinkType(orig); /* unlink local tree */
2921 return ptr;
2922
2923 erret:
2924 aip -> io_failure = TRUE;
2925 ptr = InterResidueBondFree(ptr);
2926 goto ret;
2927 }
2928
2929
2930
2931 /**************************************************
2932 *
2933 * InterResidueBondAsnWrite()
2934 *
2935 **************************************************/
2936 Boolean LIBCALL
InterResidueBondAsnWrite(InterResidueBondPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2937 InterResidueBondAsnWrite(InterResidueBondPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2938 {
2939 DataVal av;
2940 AsnTypePtr atp;
2941 Boolean retval = FALSE;
2942
2943 if (! loaded)
2944 {
2945 if (! objmmdb1AsnLoad()) {
2946 return FALSE;
2947 }
2948 }
2949
2950 if (aip == NULL) {
2951 return FALSE;
2952 }
2953
2954 atp = AsnLinkType(orig, INTER_RESIDUE_BOND); /* link local tree */
2955 if (atp == NULL) {
2956 return FALSE;
2957 }
2958
2959 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2960 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2961 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2962 goto erret;
2963 }
2964
2965 if (ptr -> atom_id_1 != NULL) {
2966 if ( ! AtomPntrAsnWrite(ptr -> atom_id_1, aip, INTER_RESIDUE_BOND_atom_id_1)) {
2967 goto erret;
2968 }
2969 }
2970 if (ptr -> atom_id_2 != NULL) {
2971 if ( ! AtomPntrAsnWrite(ptr -> atom_id_2, aip, INTER_RESIDUE_BOND_atom_id_2)) {
2972 goto erret;
2973 }
2974 }
2975 if (ptr -> bond_order || (ptr -> OBbits__ & (1<<0) )){ av.intvalue = ptr -> bond_order;
2976 retval = AsnWrite(aip, INTER_RESIDUE_BOND_bond_order, &av);
2977 }
2978 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2979 goto erret;
2980 }
2981 retval = TRUE;
2982
2983 erret:
2984 AsnUnlinkType(orig); /* unlink local tree */
2985 return retval;
2986 }
2987
2988
2989
2990 /**************************************************
2991 *
2992 * ResidueNew()
2993 *
2994 **************************************************/
2995
2996 ResiduePtr LIBCALL
ResidueNew(void)2997 ResidueNew(void)
2998 {
2999 ResiduePtr ptr = MemNew((size_t) sizeof(Residue));
3000
3001 return ptr;
3002
3003 }
3004
3005
3006 /**************************************************
3007 *
3008 * ResidueFree()
3009 *
3010 **************************************************/
3011
3012 ResiduePtr LIBCALL
ResidueFree(ResiduePtr ptr)3013 ResidueFree(ResiduePtr ptr)
3014 {
3015
3016 if(ptr == NULL) {
3017 return NULL;
3018 }
3019 MemFree(ptr -> name);
3020 ResidueGraphPntrFree(ptr -> residue_graph);
3021 return MemFree(ptr);
3022 }
3023
3024
3025 /**************************************************
3026 *
3027 * ResidueAsnRead()
3028 *
3029 **************************************************/
3030
3031 ResiduePtr LIBCALL
ResidueAsnRead(AsnIoPtr aip,AsnTypePtr orig)3032 ResidueAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3033 {
3034 DataVal av;
3035 AsnTypePtr atp;
3036 Boolean isError = FALSE;
3037 AsnReadFunc func;
3038 ResiduePtr ptr;
3039
3040 if (! loaded)
3041 {
3042 if (! objmmdb1AsnLoad()) {
3043 return NULL;
3044 }
3045 }
3046
3047 if (aip == NULL) {
3048 return NULL;
3049 }
3050
3051 if (orig == NULL) { /* Residue ::= (self contained) */
3052 atp = AsnReadId(aip, amp, RESIDUE);
3053 } else {
3054 atp = AsnLinkType(orig, RESIDUE);
3055 }
3056 /* link in local tree */
3057 if (atp == NULL) {
3058 return NULL;
3059 }
3060
3061 ptr = ResidueNew();
3062 if (ptr == NULL) {
3063 goto erret;
3064 }
3065 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3066 goto erret;
3067 }
3068
3069 atp = AsnReadId(aip,amp, atp);
3070 func = NULL;
3071
3072 if (atp == RESIDUE_id) {
3073 if ( AsnReadVal(aip, atp, &av) <= 0) {
3074 goto erret;
3075 }
3076 ptr -> id = av.intvalue;
3077 atp = AsnReadId(aip,amp, atp);
3078 }
3079 if (atp == RESIDUE_name) {
3080 if ( AsnReadVal(aip, atp, &av) <= 0) {
3081 goto erret;
3082 }
3083 ptr -> name = av.ptrvalue;
3084 atp = AsnReadId(aip,amp, atp);
3085 }
3086 if (atp == RESIDUE_residue_graph) {
3087 ptr -> residue_graph = ResidueGraphPntrAsnRead(aip, atp);
3088 if (aip -> io_failure) {
3089 goto erret;
3090 }
3091 atp = AsnReadId(aip,amp, atp);
3092 }
3093
3094 if (AsnReadVal(aip, atp, &av) <= 0) {
3095 goto erret;
3096 }
3097 /* end struct */
3098
3099 ret:
3100 AsnUnlinkType(orig); /* unlink local tree */
3101 return ptr;
3102
3103 erret:
3104 aip -> io_failure = TRUE;
3105 ptr = ResidueFree(ptr);
3106 goto ret;
3107 }
3108
3109
3110
3111 /**************************************************
3112 *
3113 * ResidueAsnWrite()
3114 *
3115 **************************************************/
3116 Boolean LIBCALL
ResidueAsnWrite(ResiduePtr ptr,AsnIoPtr aip,AsnTypePtr orig)3117 ResidueAsnWrite(ResiduePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
3118 {
3119 DataVal av;
3120 AsnTypePtr atp;
3121 Boolean retval = FALSE;
3122
3123 if (! loaded)
3124 {
3125 if (! objmmdb1AsnLoad()) {
3126 return FALSE;
3127 }
3128 }
3129
3130 if (aip == NULL) {
3131 return FALSE;
3132 }
3133
3134 atp = AsnLinkType(orig, RESIDUE); /* link local tree */
3135 if (atp == NULL) {
3136 return FALSE;
3137 }
3138
3139 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3140 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3141 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
3142 goto erret;
3143 }
3144
3145 av.intvalue = ptr -> id;
3146 retval = AsnWrite(aip, RESIDUE_id, &av);
3147 if (ptr -> name != NULL) {
3148 av.ptrvalue = ptr -> name;
3149 retval = AsnWrite(aip, RESIDUE_name, &av);
3150 }
3151 if (ptr -> residue_graph != NULL) {
3152 if ( ! ResidueGraphPntrAsnWrite(ptr -> residue_graph, aip, RESIDUE_residue_graph)) {
3153 goto erret;
3154 }
3155 }
3156 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
3157 goto erret;
3158 }
3159 retval = TRUE;
3160
3161 erret:
3162 AsnUnlinkType(orig); /* unlink local tree */
3163 return retval;
3164 }
3165
3166
3167
3168 /**************************************************
3169 *
3170 * ResidueGraphPntrFree()
3171 *
3172 **************************************************/
3173
3174 ResidueGraphPntrPtr LIBCALL
ResidueGraphPntrFree(ValNodePtr anp)3175 ResidueGraphPntrFree(ValNodePtr anp)
3176 {
3177 Pointer pnt;
3178
3179 if (anp == NULL) {
3180 return NULL;
3181 }
3182
3183 pnt = anp->data.ptrvalue;
3184 switch (anp->choice)
3185 {
3186 default:
3187 break;
3188 case ResidueGraphPntr_biostruc:
3189 BiostrucGraphPntrFree(anp -> data.ptrvalue);
3190 break;
3191 case ResidueGraphPntr_standard:
3192 BiostrucResidueGraphSetPntrFree(anp -> data.ptrvalue);
3193 break;
3194 }
3195 return MemFree(anp);
3196 }
3197
3198
3199 /**************************************************
3200 *
3201 * ResidueGraphPntrAsnRead()
3202 *
3203 **************************************************/
3204
3205 ResidueGraphPntrPtr LIBCALL
ResidueGraphPntrAsnRead(AsnIoPtr aip,AsnTypePtr orig)3206 ResidueGraphPntrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3207 {
3208 DataVal av;
3209 AsnTypePtr atp;
3210 ValNodePtr anp;
3211 Uint1 choice;
3212 Boolean isError = FALSE;
3213 Boolean nullIsError = FALSE;
3214 AsnReadFunc func;
3215
3216 if (! loaded)
3217 {
3218 if (! objmmdb1AsnLoad()) {
3219 return NULL;
3220 }
3221 }
3222
3223 if (aip == NULL) {
3224 return NULL;
3225 }
3226
3227 if (orig == NULL) { /* ResidueGraphPntr ::= (self contained) */
3228 atp = AsnReadId(aip, amp, RESIDUE_GRAPH_PNTR);
3229 } else {
3230 atp = AsnLinkType(orig, RESIDUE_GRAPH_PNTR); /* link in local tree */
3231 }
3232 if (atp == NULL) {
3233 return NULL;
3234 }
3235
3236 anp = ValNodeNew(NULL);
3237 if (anp == NULL) {
3238 goto erret;
3239 }
3240 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
3241 goto erret;
3242 }
3243
3244 func = NULL;
3245
3246 atp = AsnReadId(aip, amp, atp); /* find the choice */
3247 if (atp == NULL) {
3248 goto erret;
3249 }
3250 if (atp == RESIDUE_GRAPH_PNTR_local) {
3251 choice = ResidueGraphPntr_local;
3252 if (AsnReadVal(aip, atp, &av) <= 0) {
3253 goto erret;
3254 }
3255 anp->data.intvalue = av.intvalue;
3256 }
3257 else if (atp == RESIDUE_GRAPH_PNTR_biostruc) {
3258 choice = ResidueGraphPntr_biostruc;
3259 func = (AsnReadFunc) BiostrucGraphPntrAsnRead;
3260 }
3261 else if (atp == RESIDUE_GRAPH_PNTR_standard) {
3262 choice = ResidueGraphPntr_standard;
3263 func = (AsnReadFunc) BiostrucResidueGraphSetPntrAsnRead;
3264 }
3265 anp->choice = choice;
3266 if (func != NULL)
3267 {
3268 anp->data.ptrvalue = (* func)(aip, atp);
3269 if (aip -> io_failure) goto erret;
3270
3271 if (nullIsError && anp->data.ptrvalue == NULL) {
3272 goto erret;
3273 }
3274 }
3275
3276 ret:
3277 AsnUnlinkType(orig); /* unlink local tree */
3278 return anp;
3279
3280 erret:
3281 anp = MemFree(anp);
3282 aip -> io_failure = TRUE;
3283 goto ret;
3284 }
3285
3286
3287 /**************************************************
3288 *
3289 * ResidueGraphPntrAsnWrite()
3290 *
3291 **************************************************/
3292 Boolean LIBCALL
ResidueGraphPntrAsnWrite(ResidueGraphPntrPtr anp,AsnIoPtr aip,AsnTypePtr orig)3293 ResidueGraphPntrAsnWrite(ResidueGraphPntrPtr anp, AsnIoPtr aip, AsnTypePtr orig)
3294
3295 {
3296 DataVal av;
3297 AsnTypePtr atp, writetype = NULL;
3298 Pointer pnt;
3299 AsnWriteFunc func = NULL;
3300 Boolean retval = FALSE;
3301
3302 if (! loaded)
3303 {
3304 if (! objmmdb1AsnLoad())
3305 return FALSE;
3306 }
3307
3308 if (aip == NULL)
3309 return FALSE;
3310
3311 atp = AsnLinkType(orig, RESIDUE_GRAPH_PNTR); /* link local tree */
3312 if (atp == NULL) {
3313 return FALSE;
3314 }
3315
3316 if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3317 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3318 av.ptrvalue = (Pointer)anp;
3319 if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
3320 goto erret;
3321 }
3322
3323 pnt = anp->data.ptrvalue;
3324 switch (anp->choice)
3325 {
3326 case ResidueGraphPntr_local:
3327 av.intvalue = anp->data.intvalue;
3328 retval = AsnWrite(aip, RESIDUE_GRAPH_PNTR_local, &av);
3329 break;
3330 case ResidueGraphPntr_biostruc:
3331 writetype = RESIDUE_GRAPH_PNTR_biostruc;
3332 func = (AsnWriteFunc) BiostrucGraphPntrAsnWrite;
3333 break;
3334 case ResidueGraphPntr_standard:
3335 writetype = RESIDUE_GRAPH_PNTR_standard;
3336 func = (AsnWriteFunc) BiostrucResidueGraphSetPntrAsnWrite;
3337 break;
3338 }
3339 if (writetype != NULL) {
3340 retval = (* func)(pnt, aip, writetype); /* write it out */
3341 }
3342 if (!retval) {
3343 goto erret;
3344 }
3345 retval = TRUE;
3346
3347 erret:
3348 AsnUnlinkType(orig); /* unlink local tree */
3349 return retval;
3350 }
3351
3352
3353 /**************************************************
3354 *
3355 * BiostrucGraphPntrNew()
3356 *
3357 **************************************************/
3358
3359 BiostrucGraphPntrPtr LIBCALL
BiostrucGraphPntrNew(void)3360 BiostrucGraphPntrNew(void)
3361 {
3362 BiostrucGraphPntrPtr ptr = MemNew((size_t) sizeof(BiostrucGraphPntr));
3363
3364 return ptr;
3365
3366 }
3367
3368
3369 /**************************************************
3370 *
3371 * BiostrucGraphPntrFree()
3372 *
3373 **************************************************/
3374
3375 BiostrucGraphPntrPtr LIBCALL
BiostrucGraphPntrFree(BiostrucGraphPntrPtr ptr)3376 BiostrucGraphPntrFree(BiostrucGraphPntrPtr ptr)
3377 {
3378
3379 if(ptr == NULL) {
3380 return NULL;
3381 }
3382 BiostrucIdFree(ptr -> biostruc_id);
3383 return MemFree(ptr);
3384 }
3385
3386
3387 /**************************************************
3388 *
3389 * BiostrucGraphPntrAsnRead()
3390 *
3391 **************************************************/
3392
3393 BiostrucGraphPntrPtr LIBCALL
BiostrucGraphPntrAsnRead(AsnIoPtr aip,AsnTypePtr orig)3394 BiostrucGraphPntrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3395 {
3396 DataVal av;
3397 AsnTypePtr atp;
3398 Boolean isError = FALSE;
3399 AsnReadFunc func;
3400 BiostrucGraphPntrPtr ptr;
3401
3402 if (! loaded)
3403 {
3404 if (! objmmdb1AsnLoad()) {
3405 return NULL;
3406 }
3407 }
3408
3409 if (aip == NULL) {
3410 return NULL;
3411 }
3412
3413 if (orig == NULL) { /* BiostrucGraphPntr ::= (self contained) */
3414 atp = AsnReadId(aip, amp, BIOSTRUC_GRAPH_PNTR);
3415 } else {
3416 atp = AsnLinkType(orig, BIOSTRUC_GRAPH_PNTR);
3417 }
3418 /* link in local tree */
3419 if (atp == NULL) {
3420 return NULL;
3421 }
3422
3423 ptr = BiostrucGraphPntrNew();
3424 if (ptr == NULL) {
3425 goto erret;
3426 }
3427 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3428 goto erret;
3429 }
3430
3431 atp = AsnReadId(aip,amp, atp);
3432 func = NULL;
3433
3434 if (atp == BIOSTRUC_GRAPH_PNTR_biostruc_id) {
3435 ptr -> biostruc_id = BiostrucIdAsnRead(aip, atp);
3436 if (aip -> io_failure) {
3437 goto erret;
3438 }
3439 atp = AsnReadId(aip,amp, atp);
3440 }
3441 if (atp == BIOSTRUC_GRAPH_PNTR_residue_graph_id) {
3442 if ( AsnReadVal(aip, atp, &av) <= 0) {
3443 goto erret;
3444 }
3445 ptr -> residue_graph_id = av.intvalue;
3446 atp = AsnReadId(aip,amp, atp);
3447 }
3448
3449 if (AsnReadVal(aip, atp, &av) <= 0) {
3450 goto erret;
3451 }
3452 /* end struct */
3453
3454 ret:
3455 AsnUnlinkType(orig); /* unlink local tree */
3456 return ptr;
3457
3458 erret:
3459 aip -> io_failure = TRUE;
3460 ptr = BiostrucGraphPntrFree(ptr);
3461 goto ret;
3462 }
3463
3464
3465
3466 /**************************************************
3467 *
3468 * BiostrucGraphPntrAsnWrite()
3469 *
3470 **************************************************/
3471 Boolean LIBCALL
BiostrucGraphPntrAsnWrite(BiostrucGraphPntrPtr ptr,AsnIoPtr aip,AsnTypePtr orig)3472 BiostrucGraphPntrAsnWrite(BiostrucGraphPntrPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
3473 {
3474 DataVal av;
3475 AsnTypePtr atp;
3476 Boolean retval = FALSE;
3477
3478 if (! loaded)
3479 {
3480 if (! objmmdb1AsnLoad()) {
3481 return FALSE;
3482 }
3483 }
3484
3485 if (aip == NULL) {
3486 return FALSE;
3487 }
3488
3489 atp = AsnLinkType(orig, BIOSTRUC_GRAPH_PNTR); /* link local tree */
3490 if (atp == NULL) {
3491 return FALSE;
3492 }
3493
3494 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3495 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3496 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
3497 goto erret;
3498 }
3499
3500 if (ptr -> biostruc_id != NULL) {
3501 if ( ! BiostrucIdAsnWrite(ptr -> biostruc_id, aip, BIOSTRUC_GRAPH_PNTR_biostruc_id)) {
3502 goto erret;
3503 }
3504 }
3505 av.intvalue = ptr -> residue_graph_id;
3506 retval = AsnWrite(aip, BIOSTRUC_GRAPH_PNTR_residue_graph_id, &av);
3507 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
3508 goto erret;
3509 }
3510 retval = TRUE;
3511
3512 erret:
3513 AsnUnlinkType(orig); /* unlink local tree */
3514 return retval;
3515 }
3516
3517
3518
3519 /**************************************************
3520 *
3521 * BiostrucResidueGraphSetPntrNew()
3522 *
3523 **************************************************/
3524
3525 BiostrucResidueGraphSetPntrPtr LIBCALL
BiostrucResidueGraphSetPntrNew(void)3526 BiostrucResidueGraphSetPntrNew(void)
3527 {
3528 BiostrucResidueGraphSetPntrPtr ptr = MemNew((size_t) sizeof(BiostrucResidueGraphSetPntr));
3529
3530 return ptr;
3531
3532 }
3533
3534
3535 /**************************************************
3536 *
3537 * BiostrucResidueGraphSetPntrFree()
3538 *
3539 **************************************************/
3540
3541 BiostrucResidueGraphSetPntrPtr LIBCALL
BiostrucResidueGraphSetPntrFree(BiostrucResidueGraphSetPntrPtr ptr)3542 BiostrucResidueGraphSetPntrFree(BiostrucResidueGraphSetPntrPtr ptr)
3543 {
3544
3545 if(ptr == NULL) {
3546 return NULL;
3547 }
3548 BiostrucIdFree(ptr -> biostruc_residue_graph_set_id);
3549 return MemFree(ptr);
3550 }
3551
3552
3553 /**************************************************
3554 *
3555 * BiostrucResidueGraphSetPntrAsnRead()
3556 *
3557 **************************************************/
3558
3559 BiostrucResidueGraphSetPntrPtr LIBCALL
BiostrucResidueGraphSetPntrAsnRead(AsnIoPtr aip,AsnTypePtr orig)3560 BiostrucResidueGraphSetPntrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3561 {
3562 DataVal av;
3563 AsnTypePtr atp;
3564 Boolean isError = FALSE;
3565 AsnReadFunc func;
3566 BiostrucResidueGraphSetPntrPtr ptr;
3567
3568 if (! loaded)
3569 {
3570 if (! objmmdb1AsnLoad()) {
3571 return NULL;
3572 }
3573 }
3574
3575 if (aip == NULL) {
3576 return NULL;
3577 }
3578
3579 if (orig == NULL) { /* BiostrucResidueGraphSetPntr ::= (self contained) */
3580 atp = AsnReadId(aip, amp, BIOSTRUC_RESIDUE_GRAPH_SET_PNTR);
3581 } else {
3582 atp = AsnLinkType(orig, BIOSTRUC_RESIDUE_GRAPH_SET_PNTR);
3583 }
3584 /* link in local tree */
3585 if (atp == NULL) {
3586 return NULL;
3587 }
3588
3589 ptr = BiostrucResidueGraphSetPntrNew();
3590 if (ptr == NULL) {
3591 goto erret;
3592 }
3593 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3594 goto erret;
3595 }
3596
3597 atp = AsnReadId(aip,amp, atp);
3598 func = NULL;
3599
3600 if (atp == BIOSTRUC_RESIDUE_GRAPH_SET_PNTR_biostruc_residue_graph_set_id) {
3601 ptr -> biostruc_residue_graph_set_id = BiostrucIdAsnRead(aip, atp);
3602 if (aip -> io_failure) {
3603 goto erret;
3604 }
3605 atp = AsnReadId(aip,amp, atp);
3606 }
3607 if (atp == BIOSTRUC_RESIDUE_GRAPH_SET_PNTR_residue_graph_id) {
3608 if ( AsnReadVal(aip, atp, &av) <= 0) {
3609 goto erret;
3610 }
3611 ptr -> residue_graph_id = av.intvalue;
3612 atp = AsnReadId(aip,amp, atp);
3613 }
3614
3615 if (AsnReadVal(aip, atp, &av) <= 0) {
3616 goto erret;
3617 }
3618 /* end struct */
3619
3620 ret:
3621 AsnUnlinkType(orig); /* unlink local tree */
3622 return ptr;
3623
3624 erret:
3625 aip -> io_failure = TRUE;
3626 ptr = BiostrucResidueGraphSetPntrFree(ptr);
3627 goto ret;
3628 }
3629
3630
3631
3632 /**************************************************
3633 *
3634 * BiostrucResidueGraphSetPntrAsnWrite()
3635 *
3636 **************************************************/
3637 Boolean LIBCALL
BiostrucResidueGraphSetPntrAsnWrite(BiostrucResidueGraphSetPntrPtr ptr,AsnIoPtr aip,AsnTypePtr orig)3638 BiostrucResidueGraphSetPntrAsnWrite(BiostrucResidueGraphSetPntrPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
3639 {
3640 DataVal av;
3641 AsnTypePtr atp;
3642 Boolean retval = FALSE;
3643
3644 if (! loaded)
3645 {
3646 if (! objmmdb1AsnLoad()) {
3647 return FALSE;
3648 }
3649 }
3650
3651 if (aip == NULL) {
3652 return FALSE;
3653 }
3654
3655 atp = AsnLinkType(orig, BIOSTRUC_RESIDUE_GRAPH_SET_PNTR); /* link local tree */
3656 if (atp == NULL) {
3657 return FALSE;
3658 }
3659
3660 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3661 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3662 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
3663 goto erret;
3664 }
3665
3666 if (ptr -> biostruc_residue_graph_set_id != NULL) {
3667 if ( ! BiostrucIdAsnWrite(ptr -> biostruc_residue_graph_set_id, aip, BIOSTRUC_RESIDUE_GRAPH_SET_PNTR_biostruc_residue_graph_set_id)) {
3668 goto erret;
3669 }
3670 }
3671 av.intvalue = ptr -> residue_graph_id;
3672 retval = AsnWrite(aip, BIOSTRUC_RESIDUE_GRAPH_SET_PNTR_residue_graph_id, &av);
3673 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
3674 goto erret;
3675 }
3676 retval = TRUE;
3677
3678 erret:
3679 AsnUnlinkType(orig); /* unlink local tree */
3680 return retval;
3681 }
3682
3683
3684
3685 /**************************************************
3686 *
3687 * AtomNew()
3688 *
3689 **************************************************/
3690
3691 AtomPtr LIBCALL
AtomNew(void)3692 AtomNew(void)
3693 {
3694 AtomPtr ptr = MemNew((size_t) sizeof(Atom));
3695
3696 return ptr;
3697
3698 }
3699
3700
3701 /**************************************************
3702 *
3703 * AtomFree()
3704 *
3705 **************************************************/
3706
3707 AtomPtr LIBCALL
AtomFree(AtomPtr ptr)3708 AtomFree(AtomPtr ptr)
3709 {
3710
3711 if(ptr == NULL) {
3712 return NULL;
3713 }
3714 MemFree(ptr -> name);
3715 AsnGenericBaseSeqOfFree(ptr -> iupac_code ,ASNCODE_PTRVAL_SLOT);
3716 return MemFree(ptr);
3717 }
3718
3719
3720 /**************************************************
3721 *
3722 * AtomAsnRead()
3723 *
3724 **************************************************/
3725
3726 AtomPtr LIBCALL
AtomAsnRead(AsnIoPtr aip,AsnTypePtr orig)3727 AtomAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3728 {
3729 DataVal av;
3730 AsnTypePtr atp;
3731 Boolean isError = FALSE;
3732 AsnReadFunc func;
3733 AtomPtr ptr;
3734
3735 if (! loaded)
3736 {
3737 if (! objmmdb1AsnLoad()) {
3738 return NULL;
3739 }
3740 }
3741
3742 if (aip == NULL) {
3743 return NULL;
3744 }
3745
3746 if (orig == NULL) { /* Atom ::= (self contained) */
3747 atp = AsnReadId(aip, amp, ATOM);
3748 } else {
3749 atp = AsnLinkType(orig, ATOM);
3750 }
3751 /* link in local tree */
3752 if (atp == NULL) {
3753 return NULL;
3754 }
3755
3756 ptr = AtomNew();
3757 if (ptr == NULL) {
3758 goto erret;
3759 }
3760 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3761 goto erret;
3762 }
3763
3764 atp = AsnReadId(aip,amp, atp);
3765 func = NULL;
3766
3767 if (atp == ATOM_id) {
3768 if ( AsnReadVal(aip, atp, &av) <= 0) {
3769 goto erret;
3770 }
3771 ptr -> id = av.intvalue;
3772 atp = AsnReadId(aip,amp, atp);
3773 }
3774 if (atp == ATOM_name) {
3775 if ( AsnReadVal(aip, atp, &av) <= 0) {
3776 goto erret;
3777 }
3778 ptr -> name = av.ptrvalue;
3779 atp = AsnReadId(aip,amp, atp);
3780 }
3781 if (atp == ATOM_iupac_code) {
3782 ptr -> iupac_code = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
3783 if (isError && ptr -> iupac_code == NULL) {
3784 goto erret;
3785 }
3786 atp = AsnReadId(aip,amp, atp);
3787 }
3788 if (atp == ATOM_element) {
3789 if ( AsnReadVal(aip, atp, &av) <= 0) {
3790 goto erret;
3791 }
3792 ptr -> element = av.intvalue;
3793 atp = AsnReadId(aip,amp, atp);
3794 }
3795 if (atp == ATOM_ionizable_proton) {
3796 if ( AsnReadVal(aip, atp, &av) <= 0) {
3797 goto erret;
3798 }
3799 ptr -> ionizable_proton = av.intvalue;
3800 ptr -> OBbits__ |= 1<<0;
3801 atp = AsnReadId(aip,amp, atp);
3802 }
3803
3804 if (AsnReadVal(aip, atp, &av) <= 0) {
3805 goto erret;
3806 }
3807 /* end struct */
3808
3809 ret:
3810 AsnUnlinkType(orig); /* unlink local tree */
3811 return ptr;
3812
3813 erret:
3814 aip -> io_failure = TRUE;
3815 ptr = AtomFree(ptr);
3816 goto ret;
3817 }
3818
3819
3820
3821 /**************************************************
3822 *
3823 * AtomAsnWrite()
3824 *
3825 **************************************************/
3826 Boolean LIBCALL
AtomAsnWrite(AtomPtr ptr,AsnIoPtr aip,AsnTypePtr orig)3827 AtomAsnWrite(AtomPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
3828 {
3829 DataVal av;
3830 AsnTypePtr atp;
3831 Boolean retval = FALSE;
3832
3833 if (! loaded)
3834 {
3835 if (! objmmdb1AsnLoad()) {
3836 return FALSE;
3837 }
3838 }
3839
3840 if (aip == NULL) {
3841 return FALSE;
3842 }
3843
3844 atp = AsnLinkType(orig, ATOM); /* link local tree */
3845 if (atp == NULL) {
3846 return FALSE;
3847 }
3848
3849 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3850 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3851 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
3852 goto erret;
3853 }
3854
3855 av.intvalue = ptr -> id;
3856 retval = AsnWrite(aip, ATOM_id, &av);
3857 if (ptr -> name != NULL) {
3858 av.ptrvalue = ptr -> name;
3859 retval = AsnWrite(aip, ATOM_name, &av);
3860 }
3861 retval = AsnGenericBaseSeqOfAsnWrite(ptr -> iupac_code ,ASNCODE_PTRVAL_SLOT, aip, ATOM_iupac_code, ATOM_iupac_code_E);
3862 av.intvalue = ptr -> element;
3863 retval = AsnWrite(aip, ATOM_element, &av);
3864 if (ptr -> ionizable_proton || (ptr -> OBbits__ & (1<<0) )){ av.intvalue = ptr -> ionizable_proton;
3865 retval = AsnWrite(aip, ATOM_ionizable_proton, &av);
3866 }
3867 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
3868 goto erret;
3869 }
3870 retval = TRUE;
3871
3872 erret:
3873 AsnUnlinkType(orig); /* unlink local tree */
3874 return retval;
3875 }
3876
3877
3878
3879 /**************************************************
3880 *
3881 * IntraResidueBondNew()
3882 *
3883 **************************************************/
3884
3885 IntraResidueBondPtr LIBCALL
IntraResidueBondNew(void)3886 IntraResidueBondNew(void)
3887 {
3888 IntraResidueBondPtr ptr = MemNew((size_t) sizeof(IntraResidueBond));
3889
3890 return ptr;
3891
3892 }
3893
3894
3895 /**************************************************
3896 *
3897 * IntraResidueBondFree()
3898 *
3899 **************************************************/
3900
3901 IntraResidueBondPtr LIBCALL
IntraResidueBondFree(IntraResidueBondPtr ptr)3902 IntraResidueBondFree(IntraResidueBondPtr ptr)
3903 {
3904
3905 if(ptr == NULL) {
3906 return NULL;
3907 }
3908 return MemFree(ptr);
3909 }
3910
3911
3912 /**************************************************
3913 *
3914 * IntraResidueBondAsnRead()
3915 *
3916 **************************************************/
3917
3918 IntraResidueBondPtr LIBCALL
IntraResidueBondAsnRead(AsnIoPtr aip,AsnTypePtr orig)3919 IntraResidueBondAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3920 {
3921 DataVal av;
3922 AsnTypePtr atp;
3923 Boolean isError = FALSE;
3924 AsnReadFunc func;
3925 IntraResidueBondPtr ptr;
3926
3927 if (! loaded)
3928 {
3929 if (! objmmdb1AsnLoad()) {
3930 return NULL;
3931 }
3932 }
3933
3934 if (aip == NULL) {
3935 return NULL;
3936 }
3937
3938 if (orig == NULL) { /* IntraResidueBond ::= (self contained) */
3939 atp = AsnReadId(aip, amp, INTRA_RESIDUE_BOND);
3940 } else {
3941 atp = AsnLinkType(orig, INTRA_RESIDUE_BOND);
3942 }
3943 /* link in local tree */
3944 if (atp == NULL) {
3945 return NULL;
3946 }
3947
3948 ptr = IntraResidueBondNew();
3949 if (ptr == NULL) {
3950 goto erret;
3951 }
3952 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3953 goto erret;
3954 }
3955
3956 atp = AsnReadId(aip,amp, atp);
3957 func = NULL;
3958
3959 if (atp == INTRA_RESIDUE_BOND_atom_id_1) {
3960 if ( AsnReadVal(aip, atp, &av) <= 0) {
3961 goto erret;
3962 }
3963 ptr -> atom_id_1 = av.intvalue;
3964 atp = AsnReadId(aip,amp, atp);
3965 }
3966 if (atp == INTRA_RESIDUE_BOND_atom_id_2) {
3967 if ( AsnReadVal(aip, atp, &av) <= 0) {
3968 goto erret;
3969 }
3970 ptr -> atom_id_2 = av.intvalue;
3971 atp = AsnReadId(aip,amp, atp);
3972 }
3973 if (atp == INTRA_RESIDUE_BOND_bond_order) {
3974 if ( AsnReadVal(aip, atp, &av) <= 0) {
3975 goto erret;
3976 }
3977 ptr -> bond_order = av.intvalue;
3978 ptr -> OBbits__ |= 1<<0;
3979 atp = AsnReadId(aip,amp, atp);
3980 }
3981
3982 if (AsnReadVal(aip, atp, &av) <= 0) {
3983 goto erret;
3984 }
3985 /* end struct */
3986
3987 ret:
3988 AsnUnlinkType(orig); /* unlink local tree */
3989 return ptr;
3990
3991 erret:
3992 aip -> io_failure = TRUE;
3993 ptr = IntraResidueBondFree(ptr);
3994 goto ret;
3995 }
3996
3997
3998
3999 /**************************************************
4000 *
4001 * IntraResidueBondAsnWrite()
4002 *
4003 **************************************************/
4004 Boolean LIBCALL
IntraResidueBondAsnWrite(IntraResidueBondPtr ptr,AsnIoPtr aip,AsnTypePtr orig)4005 IntraResidueBondAsnWrite(IntraResidueBondPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
4006 {
4007 DataVal av;
4008 AsnTypePtr atp;
4009 Boolean retval = FALSE;
4010
4011 if (! loaded)
4012 {
4013 if (! objmmdb1AsnLoad()) {
4014 return FALSE;
4015 }
4016 }
4017
4018 if (aip == NULL) {
4019 return FALSE;
4020 }
4021
4022 atp = AsnLinkType(orig, INTRA_RESIDUE_BOND); /* link local tree */
4023 if (atp == NULL) {
4024 return FALSE;
4025 }
4026
4027 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4028 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4029 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
4030 goto erret;
4031 }
4032
4033 av.intvalue = ptr -> atom_id_1;
4034 retval = AsnWrite(aip, INTRA_RESIDUE_BOND_atom_id_1, &av);
4035 av.intvalue = ptr -> atom_id_2;
4036 retval = AsnWrite(aip, INTRA_RESIDUE_BOND_atom_id_2, &av);
4037 if (ptr -> bond_order || (ptr -> OBbits__ & (1<<0) )){ av.intvalue = ptr -> bond_order;
4038 retval = AsnWrite(aip, INTRA_RESIDUE_BOND_bond_order, &av);
4039 }
4040 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
4041 goto erret;
4042 }
4043 retval = TRUE;
4044
4045 erret:
4046 AsnUnlinkType(orig); /* unlink local tree */
4047 return retval;
4048 }
4049
4050
4051
4052 /**************************************************
4053 *
4054 * ChiralCenterNew()
4055 *
4056 **************************************************/
4057
4058 ChiralCenterPtr LIBCALL
ChiralCenterNew(void)4059 ChiralCenterNew(void)
4060 {
4061 ChiralCenterPtr ptr = MemNew((size_t) sizeof(ChiralCenter));
4062
4063 return ptr;
4064
4065 }
4066
4067
4068 /**************************************************
4069 *
4070 * ChiralCenterFree()
4071 *
4072 **************************************************/
4073
4074 ChiralCenterPtr LIBCALL
ChiralCenterFree(ChiralCenterPtr ptr)4075 ChiralCenterFree(ChiralCenterPtr ptr)
4076 {
4077
4078 if(ptr == NULL) {
4079 return NULL;
4080 }
4081 return MemFree(ptr);
4082 }
4083
4084
4085 /**************************************************
4086 *
4087 * ChiralCenterAsnRead()
4088 *
4089 **************************************************/
4090
4091 ChiralCenterPtr LIBCALL
ChiralCenterAsnRead(AsnIoPtr aip,AsnTypePtr orig)4092 ChiralCenterAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4093 {
4094 DataVal av;
4095 AsnTypePtr atp;
4096 Boolean isError = FALSE;
4097 AsnReadFunc func;
4098 ChiralCenterPtr ptr;
4099
4100 if (! loaded)
4101 {
4102 if (! objmmdb1AsnLoad()) {
4103 return NULL;
4104 }
4105 }
4106
4107 if (aip == NULL) {
4108 return NULL;
4109 }
4110
4111 if (orig == NULL) { /* ChiralCenter ::= (self contained) */
4112 atp = AsnReadId(aip, amp, CHIRAL_CENTER);
4113 } else {
4114 atp = AsnLinkType(orig, CHIRAL_CENTER);
4115 }
4116 /* link in local tree */
4117 if (atp == NULL) {
4118 return NULL;
4119 }
4120
4121 ptr = ChiralCenterNew();
4122 if (ptr == NULL) {
4123 goto erret;
4124 }
4125 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
4126 goto erret;
4127 }
4128
4129 atp = AsnReadId(aip,amp, atp);
4130 func = NULL;
4131
4132 if (atp == CHIRAL_CENTER_c) {
4133 if ( AsnReadVal(aip, atp, &av) <= 0) {
4134 goto erret;
4135 }
4136 ptr -> c = av.intvalue;
4137 atp = AsnReadId(aip,amp, atp);
4138 }
4139 if (atp == CHIRAL_CENTER_n1) {
4140 if ( AsnReadVal(aip, atp, &av) <= 0) {
4141 goto erret;
4142 }
4143 ptr -> n1 = av.intvalue;
4144 atp = AsnReadId(aip,amp, atp);
4145 }
4146 if (atp == CHIRAL_CENTER_n2) {
4147 if ( AsnReadVal(aip, atp, &av) <= 0) {
4148 goto erret;
4149 }
4150 ptr -> n2 = av.intvalue;
4151 atp = AsnReadId(aip,amp, atp);
4152 }
4153 if (atp == CHIRAL_CENTER_n3) {
4154 if ( AsnReadVal(aip, atp, &av) <= 0) {
4155 goto erret;
4156 }
4157 ptr -> n3 = av.intvalue;
4158 atp = AsnReadId(aip,amp, atp);
4159 }
4160 if (atp == CHIRAL_CENTER_sign) {
4161 if ( AsnReadVal(aip, atp, &av) <= 0) {
4162 goto erret;
4163 }
4164 ptr -> sign = av.intvalue;
4165 atp = AsnReadId(aip,amp, atp);
4166 }
4167
4168 if (AsnReadVal(aip, atp, &av) <= 0) {
4169 goto erret;
4170 }
4171 /* end struct */
4172
4173 ret:
4174 AsnUnlinkType(orig); /* unlink local tree */
4175 return ptr;
4176
4177 erret:
4178 aip -> io_failure = TRUE;
4179 ptr = ChiralCenterFree(ptr);
4180 goto ret;
4181 }
4182
4183
4184
4185 /**************************************************
4186 *
4187 * ChiralCenterAsnWrite()
4188 *
4189 **************************************************/
4190 Boolean LIBCALL
ChiralCenterAsnWrite(ChiralCenterPtr ptr,AsnIoPtr aip,AsnTypePtr orig)4191 ChiralCenterAsnWrite(ChiralCenterPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
4192 {
4193 DataVal av;
4194 AsnTypePtr atp;
4195 Boolean retval = FALSE;
4196
4197 if (! loaded)
4198 {
4199 if (! objmmdb1AsnLoad()) {
4200 return FALSE;
4201 }
4202 }
4203
4204 if (aip == NULL) {
4205 return FALSE;
4206 }
4207
4208 atp = AsnLinkType(orig, CHIRAL_CENTER); /* link local tree */
4209 if (atp == NULL) {
4210 return FALSE;
4211 }
4212
4213 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4214 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4215 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
4216 goto erret;
4217 }
4218
4219 av.intvalue = ptr -> c;
4220 retval = AsnWrite(aip, CHIRAL_CENTER_c, &av);
4221 av.intvalue = ptr -> n1;
4222 retval = AsnWrite(aip, CHIRAL_CENTER_n1, &av);
4223 av.intvalue = ptr -> n2;
4224 retval = AsnWrite(aip, CHIRAL_CENTER_n2, &av);
4225 av.intvalue = ptr -> n3;
4226 retval = AsnWrite(aip, CHIRAL_CENTER_n3, &av);
4227 av.intvalue = ptr -> sign;
4228 retval = AsnWrite(aip, CHIRAL_CENTER_sign, &av);
4229 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
4230 goto erret;
4231 }
4232 retval = TRUE;
4233
4234 erret:
4235 AsnUnlinkType(orig); /* unlink local tree */
4236 return retval;
4237 }
4238
4239
4240
4241 /**************************************************
4242 *
4243 * AtomPntrNew()
4244 *
4245 **************************************************/
4246
4247 AtomPntrPtr LIBCALL
AtomPntrNew(void)4248 AtomPntrNew(void)
4249 {
4250 AtomPntrPtr ptr = MemNew((size_t) sizeof(AtomPntr));
4251
4252 return ptr;
4253
4254 }
4255
4256
4257 /**************************************************
4258 *
4259 * AtomPntrFree()
4260 *
4261 **************************************************/
4262
4263 AtomPntrPtr LIBCALL
AtomPntrFree(AtomPntrPtr ptr)4264 AtomPntrFree(AtomPntrPtr ptr)
4265 {
4266
4267 if(ptr == NULL) {
4268 return NULL;
4269 }
4270 return MemFree(ptr);
4271 }
4272
4273
4274 /**************************************************
4275 *
4276 * AtomPntrAsnRead()
4277 *
4278 **************************************************/
4279
4280 AtomPntrPtr LIBCALL
AtomPntrAsnRead(AsnIoPtr aip,AsnTypePtr orig)4281 AtomPntrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4282 {
4283 DataVal av;
4284 AsnTypePtr atp;
4285 Boolean isError = FALSE;
4286 AsnReadFunc func;
4287 AtomPntrPtr ptr;
4288
4289 if (! loaded)
4290 {
4291 if (! objmmdb1AsnLoad()) {
4292 return NULL;
4293 }
4294 }
4295
4296 if (aip == NULL) {
4297 return NULL;
4298 }
4299
4300 if (orig == NULL) { /* AtomPntr ::= (self contained) */
4301 atp = AsnReadId(aip, amp, ATOM_PNTR);
4302 } else {
4303 atp = AsnLinkType(orig, ATOM_PNTR);
4304 }
4305 /* link in local tree */
4306 if (atp == NULL) {
4307 return NULL;
4308 }
4309
4310 ptr = AtomPntrNew();
4311 if (ptr == NULL) {
4312 goto erret;
4313 }
4314 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
4315 goto erret;
4316 }
4317
4318 atp = AsnReadId(aip,amp, atp);
4319 func = NULL;
4320
4321 if (atp == ATOM_PNTR_molecule_id) {
4322 if ( AsnReadVal(aip, atp, &av) <= 0) {
4323 goto erret;
4324 }
4325 ptr -> molecule_id = av.intvalue;
4326 atp = AsnReadId(aip,amp, atp);
4327 }
4328 if (atp == ATOM_PNTR_residue_id) {
4329 if ( AsnReadVal(aip, atp, &av) <= 0) {
4330 goto erret;
4331 }
4332 ptr -> residue_id = av.intvalue;
4333 atp = AsnReadId(aip,amp, atp);
4334 }
4335 if (atp == ATOM_PNTR_atom_id) {
4336 if ( AsnReadVal(aip, atp, &av) <= 0) {
4337 goto erret;
4338 }
4339 ptr -> atom_id = av.intvalue;
4340 atp = AsnReadId(aip,amp, atp);
4341 }
4342
4343 if (AsnReadVal(aip, atp, &av) <= 0) {
4344 goto erret;
4345 }
4346 /* end struct */
4347
4348 ret:
4349 AsnUnlinkType(orig); /* unlink local tree */
4350 return ptr;
4351
4352 erret:
4353 aip -> io_failure = TRUE;
4354 ptr = AtomPntrFree(ptr);
4355 goto ret;
4356 }
4357
4358
4359
4360 /**************************************************
4361 *
4362 * AtomPntrAsnWrite()
4363 *
4364 **************************************************/
4365 Boolean LIBCALL
AtomPntrAsnWrite(AtomPntrPtr ptr,AsnIoPtr aip,AsnTypePtr orig)4366 AtomPntrAsnWrite(AtomPntrPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
4367 {
4368 DataVal av;
4369 AsnTypePtr atp;
4370 Boolean retval = FALSE;
4371
4372 if (! loaded)
4373 {
4374 if (! objmmdb1AsnLoad()) {
4375 return FALSE;
4376 }
4377 }
4378
4379 if (aip == NULL) {
4380 return FALSE;
4381 }
4382
4383 atp = AsnLinkType(orig, ATOM_PNTR); /* link local tree */
4384 if (atp == NULL) {
4385 return FALSE;
4386 }
4387
4388 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4389 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
4390 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
4391 goto erret;
4392 }
4393
4394 av.intvalue = ptr -> molecule_id;
4395 retval = AsnWrite(aip, ATOM_PNTR_molecule_id, &av);
4396 av.intvalue = ptr -> residue_id;
4397 retval = AsnWrite(aip, ATOM_PNTR_residue_id, &av);
4398 av.intvalue = ptr -> atom_id;
4399 retval = AsnWrite(aip, ATOM_PNTR_atom_id, &av);
4400 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
4401 goto erret;
4402 }
4403 retval = TRUE;
4404
4405 erret:
4406 AsnUnlinkType(orig); /* unlink local tree */
4407 return retval;
4408 }
4409
4410
4411
4412 /**************************************************
4413 *
4414 * AtomPntrSetFree()
4415 *
4416 **************************************************/
4417
4418 AtomPntrSetPtr LIBCALL
AtomPntrSetFree(AtomPntrSetPtr ptr)4419 AtomPntrSetFree(AtomPntrSetPtr ptr)
4420 {
4421
4422 if(ptr == NULL) {
4423 return NULL;
4424 }
4425 AsnGenericUserSeqOfFree(ptr, (AsnOptFreeFunc) AtomPntrFree);
4426 return NULL;
4427 }
4428
4429
4430 /**************************************************
4431 *
4432 * AtomPntrSetAsnRead()
4433 *
4434 **************************************************/
4435
4436 AtomPntrSetPtr LIBCALL
AtomPntrSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)4437 AtomPntrSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
4438 {
4439 AsnTypePtr atp;
4440 Boolean isError = FALSE;
4441 AsnReadFunc func;
4442 AtomPntrSetPtr ptr;
4443
4444 if (! loaded)
4445 {
4446 if (! objmmdb1AsnLoad()) {
4447 return NULL;
4448 }
4449 }
4450
4451 if (aip == NULL) {
4452 return NULL;
4453 }
4454
4455 if (orig == NULL) { /* AtomPntrSet ::= (self contained) */
4456 atp = AsnReadId(aip, amp, ATOM_PNTR_SET);
4457 } else {
4458 atp = AsnLinkType(orig, ATOM_PNTR_SET);
4459 }
4460 /* link in local tree */
4461 if (atp == NULL) {
4462 return NULL;
4463 }
4464
4465 func = NULL;
4466
4467 ptr = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) AtomPntrAsnRead, (AsnOptFreeFunc) AtomPntrFree);
4468 if (isError && ptr == NULL) {
4469 goto erret;
4470 }
4471
4472
4473
4474 ret:
4475 AsnUnlinkType(orig); /* unlink local tree */
4476 return ptr;
4477
4478 erret:
4479 aip -> io_failure = TRUE;
4480 ptr = AtomPntrSetFree(ptr);
4481 goto ret;
4482 }
4483
4484
4485
4486 /**************************************************
4487 *
4488 * AtomPntrSetAsnWrite()
4489 *
4490 **************************************************/
4491 Boolean LIBCALL
AtomPntrSetAsnWrite(AtomPntrSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)4492 AtomPntrSetAsnWrite(AtomPntrSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
4493 {
4494 AsnTypePtr atp;
4495 Boolean retval = FALSE;
4496
4497 if (! loaded)
4498 {
4499 if (! objmmdb1AsnLoad()) {
4500 return FALSE;
4501 }
4502 }
4503
4504 if (aip == NULL) {
4505 return FALSE;
4506 }
4507
4508 atp = AsnLinkType(orig, ATOM_PNTR_SET); /* link local tree */
4509 if (atp == NULL) {
4510 return FALSE;
4511 }
4512
4513 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
4514 retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) AtomPntrAsnWrite, aip, atp, ATOM_PNTR_SET_E);
4515 retval = TRUE;
4516
4517 erret:
4518 AsnUnlinkType(orig); /* unlink local tree */
4519 return retval;
4520 }
4521
4522