1 static char const rcsid[] = "$Id: bxmlobj.c,v 6.11 2006/09/18 15:20:39 bealer Exp $";
2 
3 #include <asn.h>
4 
5 #define NLM_GENERATED_CODE_PROTO
6 
7 #include <bxmlobj.h>
8 
9 static Boolean loaded = FALSE;
10 
11 #include <blstxml.h>
12 
13 #ifndef NLM_EXTERN_LOADS
14 #define NLM_EXTERN_LOADS {}
15 #endif
16 
17 NLM_EXTERN Boolean LIBCALL
bxmlobjAsnLoad(void)18 bxmlobjAsnLoad(void)
19 {
20 
21    if ( ! loaded) {
22       NLM_EXTERN_LOADS
23 
24       if ( ! AsnLoad ())
25       return FALSE;
26       loaded = TRUE;
27    }
28 
29    return TRUE;
30 }
31 
32 
33 
34 /**************************************************
35 *    Generated object loaders for Module NCBI-BlastOutput
36 *    Generated using ASNCODE Revision: 6.16 at Sep 15, 2006  1:53 PM
37 *
38 **************************************************/
39 
40 
41 /**************************************************
42 *
43 *    BlastOutputNew()
44 *
45 **************************************************/
46 NLM_EXTERN
47 BlastOutputPtr LIBCALL
BlastOutputNew(void)48 BlastOutputNew(void)
49 {
50    BlastOutputPtr ptr = MemNew((size_t) sizeof(BlastOutput));
51 
52    return ptr;
53 
54 }
55 
56 
57 /**************************************************
58 *
59 *    BlastOutputFree()
60 *
61 **************************************************/
62 NLM_EXTERN
63 BlastOutputPtr LIBCALL
BlastOutputFree(BlastOutputPtr ptr)64 BlastOutputFree(BlastOutputPtr ptr)
65 {
66 
67    if(ptr == NULL) {
68       return NULL;
69    }
70    MemFree(ptr -> program);
71    MemFree(ptr -> version);
72    MemFree(ptr -> reference);
73    MemFree(ptr -> db);
74    MemFree(ptr -> query_ID);
75    MemFree(ptr -> query_def);
76    MemFree(ptr -> query_seq);
77    ParametersFree(ptr -> param);
78    AsnGenericUserSeqOfFree(ptr -> iterations, (AsnOptFreeFunc) IterationFree);
79    StatisticsFree(ptr -> mbstat);
80    return MemFree(ptr);
81 }
82 
83 
84 /**************************************************
85 *
86 *    BlastOutputAsnRead()
87 *
88 **************************************************/
89 NLM_EXTERN
90 BlastOutputPtr LIBCALL
BlastOutputAsnRead(AsnIoPtr aip,AsnTypePtr orig)91 BlastOutputAsnRead(AsnIoPtr aip, AsnTypePtr orig)
92 {
93    DataVal av;
94    AsnTypePtr atp;
95    Boolean isError = FALSE;
96    AsnReadFunc func;
97    BlastOutputPtr ptr;
98 
99    if (! loaded)
100    {
101       if (! bxmlobjAsnLoad()) {
102          return NULL;
103       }
104    }
105 
106    if (aip == NULL) {
107       return NULL;
108    }
109 
110    if (orig == NULL) {         /* BlastOutput ::= (self contained) */
111       atp = AsnReadId(aip, amp, BLASTOUTPUT);
112    } else {
113       atp = AsnLinkType(orig, BLASTOUTPUT);
114    }
115    /* link in local tree */
116    if (atp == NULL) {
117       return NULL;
118    }
119 
120    ptr = BlastOutputNew();
121    if (ptr == NULL) {
122       goto erret;
123    }
124    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
125       goto erret;
126    }
127 
128    atp = AsnReadId(aip,amp, atp);
129    func = NULL;
130 
131    if (atp == BLASTOUTPUT_program) {
132       if ( AsnReadVal(aip, atp, &av) <= 0) {
133          goto erret;
134       }
135       ptr -> program = av.ptrvalue;
136       atp = AsnReadId(aip,amp, atp);
137    }
138    if (atp == BLASTOUTPUT_version) {
139       if ( AsnReadVal(aip, atp, &av) <= 0) {
140          goto erret;
141       }
142       ptr -> version = av.ptrvalue;
143       atp = AsnReadId(aip,amp, atp);
144    }
145    if (atp == BLASTOUTPUT_reference) {
146       if ( AsnReadVal(aip, atp, &av) <= 0) {
147          goto erret;
148       }
149       ptr -> reference = av.ptrvalue;
150       atp = AsnReadId(aip,amp, atp);
151    }
152    if (atp == BLASTOUTPUT_db) {
153       if ( AsnReadVal(aip, atp, &av) <= 0) {
154          goto erret;
155       }
156       ptr -> db = av.ptrvalue;
157       atp = AsnReadId(aip,amp, atp);
158    }
159    if (atp == BLASTOUTPUT_query_ID) {
160       if ( AsnReadVal(aip, atp, &av) <= 0) {
161          goto erret;
162       }
163       ptr -> query_ID = av.ptrvalue;
164       atp = AsnReadId(aip,amp, atp);
165    }
166    if (atp == BLASTOUTPUT_query_def) {
167       if ( AsnReadVal(aip, atp, &av) <= 0) {
168          goto erret;
169       }
170       ptr -> query_def = av.ptrvalue;
171       atp = AsnReadId(aip,amp, atp);
172    }
173    if (atp == BLASTOUTPUT_query_len) {
174       if ( AsnReadVal(aip, atp, &av) <= 0) {
175          goto erret;
176       }
177       ptr -> query_len = av.intvalue;
178       atp = AsnReadId(aip,amp, atp);
179    }
180    if (atp == BLASTOUTPUT_query_seq) {
181       if ( AsnReadVal(aip, atp, &av) <= 0) {
182          goto erret;
183       }
184       ptr -> query_seq = av.ptrvalue;
185       atp = AsnReadId(aip,amp, atp);
186    }
187    if (atp == BLASTOUTPUT_param) {
188       ptr -> param = ParametersAsnRead(aip, atp);
189       if (aip -> io_failure) {
190          goto erret;
191       }
192       atp = AsnReadId(aip,amp, atp);
193    }
194    if (atp == BLASTOUTPUT_iterations) {
195       ptr -> iterations = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) IterationAsnRead, (AsnOptFreeFunc) IterationFree);
196       if (isError && ptr -> iterations == NULL) {
197          goto erret;
198       }
199       atp = AsnReadId(aip,amp, atp);
200    }
201    if (atp == BLASTOUTPUT_mbstat) {
202       ptr -> mbstat = StatisticsAsnRead(aip, atp);
203       if (aip -> io_failure) {
204          goto erret;
205       }
206       atp = AsnReadId(aip,amp, atp);
207    }
208 
209    if (AsnReadVal(aip, atp, &av) <= 0) {
210       goto erret;
211    }
212    /* end struct */
213 
214 ret:
215    AsnUnlinkType(orig);       /* unlink local tree */
216    return ptr;
217 
218 erret:
219    aip -> io_failure = TRUE;
220    ptr = BlastOutputFree(ptr);
221    goto ret;
222 }
223 
224 
225 
226 /**************************************************
227 *
228 *    BlastOutputAsnWrite()
229 *
230 **************************************************/
231 NLM_EXTERN Boolean LIBCALL
BlastOutputAsnWrite(BlastOutputPtr ptr,AsnIoPtr aip,AsnTypePtr orig)232 BlastOutputAsnWrite(BlastOutputPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
233 {
234    DataVal av;
235    AsnTypePtr atp;
236    Boolean retval = FALSE;
237 
238    if (! loaded)
239    {
240       if (! bxmlobjAsnLoad()) {
241          return FALSE;
242       }
243    }
244 
245    if (aip == NULL) {
246       return FALSE;
247    }
248 
249    atp = AsnLinkType(orig, BLASTOUTPUT);   /* link local tree */
250    if (atp == NULL) {
251       return FALSE;
252    }
253 
254    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
255    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
256       goto erret;
257    }
258 
259    if (ptr -> program != NULL) {
260       av.ptrvalue = ptr -> program;
261       retval = AsnWrite(aip, BLASTOUTPUT_program,  &av);
262    }
263    if (ptr -> version != NULL) {
264       av.ptrvalue = ptr -> version;
265       retval = AsnWrite(aip, BLASTOUTPUT_version,  &av);
266    }
267    if (ptr -> reference != NULL) {
268       av.ptrvalue = ptr -> reference;
269       retval = AsnWrite(aip, BLASTOUTPUT_reference,  &av);
270    }
271    if (ptr -> db != NULL) {
272       av.ptrvalue = ptr -> db;
273       retval = AsnWrite(aip, BLASTOUTPUT_db,  &av);
274    }
275    if (ptr -> query_ID != NULL) {
276       av.ptrvalue = ptr -> query_ID;
277       retval = AsnWrite(aip, BLASTOUTPUT_query_ID,  &av);
278    }
279    if (ptr -> query_def != NULL) {
280       av.ptrvalue = ptr -> query_def;
281       retval = AsnWrite(aip, BLASTOUTPUT_query_def,  &av);
282    }
283    av.intvalue = ptr -> query_len;
284    retval = AsnWrite(aip, BLASTOUTPUT_query_len,  &av);
285    if (ptr -> query_seq != NULL) {
286       av.ptrvalue = ptr -> query_seq;
287       retval = AsnWrite(aip, BLASTOUTPUT_query_seq,  &av);
288    }
289    if (ptr -> param != NULL) {
290       if ( ! ParametersAsnWrite(ptr -> param, aip, BLASTOUTPUT_param)) {
291          goto erret;
292       }
293    }
294    AsnGenericUserSeqOfAsnWrite(ptr -> iterations, (AsnWriteFunc) IterationAsnWrite, aip, BLASTOUTPUT_iterations, BLASTOUTPUT_iterations_E);
295    if (ptr -> mbstat != NULL) {
296       if ( ! StatisticsAsnWrite(ptr -> mbstat, aip, BLASTOUTPUT_mbstat)) {
297          goto erret;
298       }
299    }
300    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
301       goto erret;
302    }
303    retval = TRUE;
304 
305 erret:
306    AsnUnlinkType(orig);       /* unlink local tree */
307    return retval;
308 }
309 
310 
311 
312 /**************************************************
313 *
314 *    ParametersNew()
315 *
316 **************************************************/
317 NLM_EXTERN
318 ParametersPtr LIBCALL
ParametersNew(void)319 ParametersNew(void)
320 {
321    ParametersPtr ptr = MemNew((size_t) sizeof(Parameters));
322 
323    return ptr;
324 
325 }
326 
327 
328 /**************************************************
329 *
330 *    ParametersFree()
331 *
332 **************************************************/
333 NLM_EXTERN
334 ParametersPtr LIBCALL
ParametersFree(ParametersPtr ptr)335 ParametersFree(ParametersPtr ptr)
336 {
337 
338    if(ptr == NULL) {
339       return NULL;
340    }
341    MemFree(ptr -> matrix);
342    MemFree(ptr -> filter);
343    MemFree(ptr -> pattern);
344    MemFree(ptr -> entrez_query);
345    return MemFree(ptr);
346 }
347 
348 
349 /**************************************************
350 *
351 *    ParametersAsnRead()
352 *
353 **************************************************/
354 NLM_EXTERN
355 ParametersPtr LIBCALL
ParametersAsnRead(AsnIoPtr aip,AsnTypePtr orig)356 ParametersAsnRead(AsnIoPtr aip, AsnTypePtr orig)
357 {
358    DataVal av;
359    AsnTypePtr atp;
360    Boolean isError = FALSE;
361    AsnReadFunc func;
362    ParametersPtr ptr;
363 
364    if (! loaded)
365    {
366       if (! bxmlobjAsnLoad()) {
367          return NULL;
368       }
369    }
370 
371    if (aip == NULL) {
372       return NULL;
373    }
374 
375    if (orig == NULL) {         /* Parameters ::= (self contained) */
376       atp = AsnReadId(aip, amp, PARAMETERS);
377    } else {
378       atp = AsnLinkType(orig, PARAMETERS);
379    }
380    /* link in local tree */
381    if (atp == NULL) {
382       return NULL;
383    }
384 
385    ptr = ParametersNew();
386    if (ptr == NULL) {
387       goto erret;
388    }
389    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
390       goto erret;
391    }
392 
393    atp = AsnReadId(aip,amp, atp);
394    func = NULL;
395 
396    if (atp == PARAMETERS_matrix) {
397       if ( AsnReadVal(aip, atp, &av) <= 0) {
398          goto erret;
399       }
400       ptr -> matrix = av.ptrvalue;
401       atp = AsnReadId(aip,amp, atp);
402    }
403    if (atp == PARAMETERS_expect) {
404       if ( AsnReadVal(aip, atp, &av) <= 0) {
405          goto erret;
406       }
407       ptr -> expect = av.realvalue;
408       atp = AsnReadId(aip,amp, atp);
409    }
410    if (atp == PARAMETERS_include) {
411       if ( AsnReadVal(aip, atp, &av) <= 0) {
412          goto erret;
413       }
414       ptr -> include = av.realvalue;
415       ptr -> OBbits__ |= 1<<0;
416       atp = AsnReadId(aip,amp, atp);
417    }
418    if (atp == PARAMETERS_sc_match) {
419       if ( AsnReadVal(aip, atp, &av) <= 0) {
420          goto erret;
421       }
422       ptr -> sc_match = av.intvalue;
423       ptr -> OBbits__ |= 1<<1;
424       atp = AsnReadId(aip,amp, atp);
425    }
426    if (atp == PARAMETERS_sc_mismatch) {
427       if ( AsnReadVal(aip, atp, &av) <= 0) {
428          goto erret;
429       }
430       ptr -> sc_mismatch = av.intvalue;
431       ptr -> OBbits__ |= 1<<2;
432       atp = AsnReadId(aip,amp, atp);
433    }
434    if (atp == PARAMETERS_gap_open) {
435       if ( AsnReadVal(aip, atp, &av) <= 0) {
436          goto erret;
437       }
438       ptr -> gap_open = av.intvalue;
439       atp = AsnReadId(aip,amp, atp);
440    }
441    if (atp == PARAMETERS_gap_extend) {
442       if ( AsnReadVal(aip, atp, &av) <= 0) {
443          goto erret;
444       }
445       ptr -> gap_extend = av.intvalue;
446       atp = AsnReadId(aip,amp, atp);
447    }
448    if (atp == PARAMETERS_filter) {
449       if ( AsnReadVal(aip, atp, &av) <= 0) {
450          goto erret;
451       }
452       ptr -> filter = av.ptrvalue;
453       atp = AsnReadId(aip,amp, atp);
454    }
455    if (atp == PARAMETERS_pattern) {
456       if ( AsnReadVal(aip, atp, &av) <= 0) {
457          goto erret;
458       }
459       ptr -> pattern = av.ptrvalue;
460       atp = AsnReadId(aip,amp, atp);
461    }
462    if (atp == PARAMETERS_entrez_query) {
463       if ( AsnReadVal(aip, atp, &av) <= 0) {
464          goto erret;
465       }
466       ptr -> entrez_query = av.ptrvalue;
467       atp = AsnReadId(aip,amp, atp);
468    }
469 
470    if (AsnReadVal(aip, atp, &av) <= 0) {
471       goto erret;
472    }
473    /* end struct */
474 
475 ret:
476    AsnUnlinkType(orig);       /* unlink local tree */
477    return ptr;
478 
479 erret:
480    aip -> io_failure = TRUE;
481    ptr = ParametersFree(ptr);
482    goto ret;
483 }
484 
485 
486 
487 /**************************************************
488 *
489 *    ParametersAsnWrite()
490 *
491 **************************************************/
492 NLM_EXTERN Boolean LIBCALL
ParametersAsnWrite(ParametersPtr ptr,AsnIoPtr aip,AsnTypePtr orig)493 ParametersAsnWrite(ParametersPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
494 {
495    DataVal av;
496    AsnTypePtr atp;
497    Boolean retval = FALSE;
498 
499    if (! loaded)
500    {
501       if (! bxmlobjAsnLoad()) {
502          return FALSE;
503       }
504    }
505 
506    if (aip == NULL) {
507       return FALSE;
508    }
509 
510    atp = AsnLinkType(orig, PARAMETERS);   /* link local tree */
511    if (atp == NULL) {
512       return FALSE;
513    }
514 
515    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
516    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
517       goto erret;
518    }
519 
520    if (ptr -> matrix != NULL) {
521       av.ptrvalue = ptr -> matrix;
522       retval = AsnWrite(aip, PARAMETERS_matrix,  &av);
523    }
524    av.realvalue = ptr -> expect;
525    retval = AsnWrite(aip, PARAMETERS_expect,  &av);
526    if (ptr -> include || (ptr -> OBbits__ & (1<<0) )){   av.realvalue = ptr -> include;
527       retval = AsnWrite(aip, PARAMETERS_include,  &av);
528    }
529    if (ptr -> sc_match || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> sc_match;
530       retval = AsnWrite(aip, PARAMETERS_sc_match,  &av);
531    }
532    if (ptr -> sc_mismatch || (ptr -> OBbits__ & (1<<2) )){   av.intvalue = ptr -> sc_mismatch;
533       retval = AsnWrite(aip, PARAMETERS_sc_mismatch,  &av);
534    }
535    av.intvalue = ptr -> gap_open;
536    retval = AsnWrite(aip, PARAMETERS_gap_open,  &av);
537    av.intvalue = ptr -> gap_extend;
538    retval = AsnWrite(aip, PARAMETERS_gap_extend,  &av);
539    if (ptr -> filter != NULL) {
540       av.ptrvalue = ptr -> filter;
541       retval = AsnWrite(aip, PARAMETERS_filter,  &av);
542    }
543    if (ptr -> pattern != NULL) {
544       av.ptrvalue = ptr -> pattern;
545       retval = AsnWrite(aip, PARAMETERS_pattern,  &av);
546    }
547    if (ptr -> entrez_query != NULL) {
548       av.ptrvalue = ptr -> entrez_query;
549       retval = AsnWrite(aip, PARAMETERS_entrez_query,  &av);
550    }
551    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
552       goto erret;
553    }
554    retval = TRUE;
555 
556 erret:
557    AsnUnlinkType(orig);       /* unlink local tree */
558    return retval;
559 }
560 
561 
562 
563 /**************************************************
564 *
565 *    IterationNew()
566 *
567 **************************************************/
568 NLM_EXTERN
569 IterationPtr LIBCALL
IterationNew(void)570 IterationNew(void)
571 {
572    IterationPtr ptr = MemNew((size_t) sizeof(Iteration));
573 
574    return ptr;
575 
576 }
577 
578 
579 /**************************************************
580 *
581 *    IterationFree()
582 *
583 **************************************************/
584 NLM_EXTERN
585 IterationPtr LIBCALL
IterationFree(IterationPtr ptr)586 IterationFree(IterationPtr ptr)
587 {
588 
589    if(ptr == NULL) {
590       return NULL;
591    }
592    MemFree(ptr -> query_ID);
593    MemFree(ptr -> query_def);
594    AsnGenericUserSeqOfFree(ptr -> hits, (AsnOptFreeFunc) HitFree);
595    StatisticsFree(ptr -> stat);
596    MemFree(ptr -> message);
597    return MemFree(ptr);
598 }
599 
600 
601 /**************************************************
602 *
603 *    IterationAsnRead()
604 *
605 **************************************************/
606 NLM_EXTERN
607 IterationPtr LIBCALL
IterationAsnRead(AsnIoPtr aip,AsnTypePtr orig)608 IterationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
609 {
610    DataVal av;
611    AsnTypePtr atp;
612    Boolean isError = FALSE;
613    AsnReadFunc func;
614    IterationPtr ptr;
615 
616    if (! loaded)
617    {
618       if (! bxmlobjAsnLoad()) {
619          return NULL;
620       }
621    }
622 
623    if (aip == NULL) {
624       return NULL;
625    }
626 
627    if (orig == NULL) {         /* Iteration ::= (self contained) */
628       atp = AsnReadId(aip, amp, ITERATION);
629    } else {
630       atp = AsnLinkType(orig, ITERATION);
631    }
632    /* link in local tree */
633    if (atp == NULL) {
634       return NULL;
635    }
636 
637    ptr = IterationNew();
638    if (ptr == NULL) {
639       goto erret;
640    }
641    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
642       goto erret;
643    }
644 
645    atp = AsnReadId(aip,amp, atp);
646    func = NULL;
647 
648    if (atp == ITERATION_iter_num) {
649       if ( AsnReadVal(aip, atp, &av) <= 0) {
650          goto erret;
651       }
652       ptr -> iter_num = av.intvalue;
653       atp = AsnReadId(aip,amp, atp);
654    }
655    if (atp == ITERATION_query_ID) {
656       if ( AsnReadVal(aip, atp, &av) <= 0) {
657          goto erret;
658       }
659       ptr -> query_ID = av.ptrvalue;
660       atp = AsnReadId(aip,amp, atp);
661    }
662    if (atp == ITERATION_query_def) {
663       if ( AsnReadVal(aip, atp, &av) <= 0) {
664          goto erret;
665       }
666       ptr -> query_def = av.ptrvalue;
667       atp = AsnReadId(aip,amp, atp);
668    }
669    if (atp == ITERATION_query_len) {
670       if ( AsnReadVal(aip, atp, &av) <= 0) {
671          goto erret;
672       }
673       ptr -> query_len = av.intvalue;
674       ptr -> OBbits__ |= 1<<0;
675       atp = AsnReadId(aip,amp, atp);
676    }
677    if (atp == ITERATION_hits) {
678       ptr -> hits = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) HitAsnRead, (AsnOptFreeFunc) HitFree);
679       if (isError && ptr -> hits == NULL) {
680          goto erret;
681       }
682       atp = AsnReadId(aip,amp, atp);
683    }
684    if (atp == ITERATION_stat) {
685       ptr -> stat = StatisticsAsnRead(aip, atp);
686       if (aip -> io_failure) {
687          goto erret;
688       }
689       atp = AsnReadId(aip,amp, atp);
690    }
691    if (atp == ITERATION_message) {
692       if ( AsnReadVal(aip, atp, &av) <= 0) {
693          goto erret;
694       }
695       ptr -> message = av.ptrvalue;
696       atp = AsnReadId(aip,amp, atp);
697    }
698 
699    if (AsnReadVal(aip, atp, &av) <= 0) {
700       goto erret;
701    }
702    /* end struct */
703 
704 ret:
705    AsnUnlinkType(orig);       /* unlink local tree */
706    return ptr;
707 
708 erret:
709    aip -> io_failure = TRUE;
710    ptr = IterationFree(ptr);
711    goto ret;
712 }
713 
714 
715 
716 /**************************************************
717 *
718 *    IterationAsnWrite()
719 *
720 **************************************************/
721 NLM_EXTERN Boolean LIBCALL
IterationAsnWrite(IterationPtr ptr,AsnIoPtr aip,AsnTypePtr orig)722 IterationAsnWrite(IterationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
723 {
724    DataVal av;
725    AsnTypePtr atp;
726    Boolean retval = FALSE;
727 
728    if (! loaded)
729    {
730       if (! bxmlobjAsnLoad()) {
731          return FALSE;
732       }
733    }
734 
735    if (aip == NULL) {
736       return FALSE;
737    }
738 
739    atp = AsnLinkType(orig, ITERATION);   /* link local tree */
740    if (atp == NULL) {
741       return FALSE;
742    }
743 
744    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
745    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
746       goto erret;
747    }
748 
749    av.intvalue = ptr -> iter_num;
750    retval = AsnWrite(aip, ITERATION_iter_num,  &av);
751    if (ptr -> query_ID != NULL) {
752       av.ptrvalue = ptr -> query_ID;
753       retval = AsnWrite(aip, ITERATION_query_ID,  &av);
754    }
755    if (ptr -> query_def != NULL) {
756       av.ptrvalue = ptr -> query_def;
757       retval = AsnWrite(aip, ITERATION_query_def,  &av);
758    }
759    if (ptr -> query_len || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> query_len;
760       retval = AsnWrite(aip, ITERATION_query_len,  &av);
761    }
762    AsnGenericUserSeqOfAsnWrite(ptr -> hits, (AsnWriteFunc) HitAsnWrite, aip, ITERATION_hits, ITERATION_hits_E);
763    if (ptr -> stat != NULL) {
764       if ( ! StatisticsAsnWrite(ptr -> stat, aip, ITERATION_stat)) {
765          goto erret;
766       }
767    }
768    if (ptr -> message != NULL) {
769       av.ptrvalue = ptr -> message;
770       retval = AsnWrite(aip, ITERATION_message,  &av);
771    }
772    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
773       goto erret;
774    }
775    retval = TRUE;
776 
777 erret:
778    AsnUnlinkType(orig);       /* unlink local tree */
779    return retval;
780 }
781 
782 
783 
784 /**************************************************
785 *
786 *    StatisticsNew()
787 *
788 **************************************************/
789 NLM_EXTERN
790 StatisticsPtr LIBCALL
StatisticsNew(void)791 StatisticsNew(void)
792 {
793    StatisticsPtr ptr = MemNew((size_t) sizeof(Statistics));
794 
795    return ptr;
796 
797 }
798 
799 
800 /**************************************************
801 *
802 *    StatisticsFree()
803 *
804 **************************************************/
805 NLM_EXTERN
806 StatisticsPtr LIBCALL
StatisticsFree(StatisticsPtr ptr)807 StatisticsFree(StatisticsPtr ptr)
808 {
809 
810    if(ptr == NULL) {
811       return NULL;
812    }
813    return MemFree(ptr);
814 }
815 
816 
817 /**************************************************
818 *
819 *    StatisticsAsnRead()
820 *
821 **************************************************/
822 NLM_EXTERN
823 StatisticsPtr LIBCALL
StatisticsAsnRead(AsnIoPtr aip,AsnTypePtr orig)824 StatisticsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
825 {
826    DataVal av;
827    AsnTypePtr atp;
828    Boolean isError = FALSE;
829    AsnReadFunc func;
830    StatisticsPtr ptr;
831 
832    if (! loaded)
833    {
834       if (! bxmlobjAsnLoad()) {
835          return NULL;
836       }
837    }
838 
839    if (aip == NULL) {
840       return NULL;
841    }
842 
843    if (orig == NULL) {         /* Statistics ::= (self contained) */
844       atp = AsnReadId(aip, amp, STATISTICS);
845    } else {
846       atp = AsnLinkType(orig, STATISTICS);
847    }
848    /* link in local tree */
849    if (atp == NULL) {
850       return NULL;
851    }
852 
853    ptr = StatisticsNew();
854    if (ptr == NULL) {
855       goto erret;
856    }
857    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
858       goto erret;
859    }
860 
861    atp = AsnReadId(aip,amp, atp);
862    func = NULL;
863 
864    if (atp == STATISTICS_db_num) {
865       if ( AsnReadVal(aip, atp, &av) <= 0) {
866          goto erret;
867       }
868       ptr -> db_num = av.intvalue;
869       atp = AsnReadId(aip,amp, atp);
870    }
871    if (atp == STATISTICS_db_len) {
872       if ( AsnReadVal(aip, atp, &av) <= 0) {
873          goto erret;
874       }
875       ptr -> db_len = av.bigintvalue;
876       atp = AsnReadId(aip,amp, atp);
877    }
878    if (atp == STATISTICS_hsp_len) {
879       if ( AsnReadVal(aip, atp, &av) <= 0) {
880          goto erret;
881       }
882       ptr -> hsp_len = av.intvalue;
883       atp = AsnReadId(aip,amp, atp);
884    }
885    if (atp == STATISTICS_eff_space) {
886       if ( AsnReadVal(aip, atp, &av) <= 0) {
887          goto erret;
888       }
889       ptr -> eff_space = av.realvalue;
890       atp = AsnReadId(aip,amp, atp);
891    }
892    if (atp == STATISTICS_kappa) {
893       if ( AsnReadVal(aip, atp, &av) <= 0) {
894          goto erret;
895       }
896       ptr -> kappa = av.realvalue;
897       atp = AsnReadId(aip,amp, atp);
898    }
899    if (atp == STATISTICS_lambda) {
900       if ( AsnReadVal(aip, atp, &av) <= 0) {
901          goto erret;
902       }
903       ptr -> lambda = av.realvalue;
904       atp = AsnReadId(aip,amp, atp);
905    }
906    if (atp == STATISTICS_entropy) {
907       if ( AsnReadVal(aip, atp, &av) <= 0) {
908          goto erret;
909       }
910       ptr -> entropy = av.realvalue;
911       atp = AsnReadId(aip,amp, atp);
912    }
913 
914    if (AsnReadVal(aip, atp, &av) <= 0) {
915       goto erret;
916    }
917    /* end struct */
918 
919 ret:
920    AsnUnlinkType(orig);       /* unlink local tree */
921    return ptr;
922 
923 erret:
924    aip -> io_failure = TRUE;
925    ptr = StatisticsFree(ptr);
926    goto ret;
927 }
928 
929 
930 
931 /**************************************************
932 *
933 *    StatisticsAsnWrite()
934 *
935 **************************************************/
936 NLM_EXTERN Boolean LIBCALL
StatisticsAsnWrite(StatisticsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)937 StatisticsAsnWrite(StatisticsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
938 {
939    DataVal av;
940    AsnTypePtr atp;
941    Boolean retval = FALSE;
942 
943    if (! loaded)
944    {
945       if (! bxmlobjAsnLoad()) {
946          return FALSE;
947       }
948    }
949 
950    if (aip == NULL) {
951       return FALSE;
952    }
953 
954    atp = AsnLinkType(orig, STATISTICS);   /* link local tree */
955    if (atp == NULL) {
956       return FALSE;
957    }
958 
959    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
960    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
961       goto erret;
962    }
963 
964    av.intvalue = ptr -> db_num;
965    retval = AsnWrite(aip, STATISTICS_db_num,  &av);
966    av.bigintvalue = ptr -> db_len;
967    retval = AsnWrite(aip, STATISTICS_db_len,  &av);
968    av.intvalue = ptr -> hsp_len;
969    retval = AsnWrite(aip, STATISTICS_hsp_len,  &av);
970    av.realvalue = ptr -> eff_space;
971    retval = AsnWrite(aip, STATISTICS_eff_space,  &av);
972    av.realvalue = ptr -> kappa;
973    retval = AsnWrite(aip, STATISTICS_kappa,  &av);
974    av.realvalue = ptr -> lambda;
975    retval = AsnWrite(aip, STATISTICS_lambda,  &av);
976    av.realvalue = ptr -> entropy;
977    retval = AsnWrite(aip, STATISTICS_entropy,  &av);
978    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
979       goto erret;
980    }
981    retval = TRUE;
982 
983 erret:
984    AsnUnlinkType(orig);       /* unlink local tree */
985    return retval;
986 }
987 
988 
989 
990 /**************************************************
991 *
992 *    HitNew()
993 *
994 **************************************************/
995 NLM_EXTERN
996 HitPtr LIBCALL
HitNew(void)997 HitNew(void)
998 {
999    HitPtr ptr = MemNew((size_t) sizeof(Hit));
1000 
1001    return ptr;
1002 
1003 }
1004 
1005 
1006 /**************************************************
1007 *
1008 *    HitFree()
1009 *
1010 **************************************************/
1011 NLM_EXTERN
1012 HitPtr LIBCALL
HitFree(HitPtr ptr)1013 HitFree(HitPtr ptr)
1014 {
1015 
1016    if(ptr == NULL) {
1017       return NULL;
1018    }
1019    MemFree(ptr -> id);
1020    MemFree(ptr -> def);
1021    MemFree(ptr -> accession);
1022    AsnGenericUserSeqOfFree(ptr -> hsps, (AsnOptFreeFunc) HspFree);
1023    return MemFree(ptr);
1024 }
1025 
1026 
1027 /**************************************************
1028 *
1029 *    HitAsnRead()
1030 *
1031 **************************************************/
1032 NLM_EXTERN
1033 HitPtr LIBCALL
HitAsnRead(AsnIoPtr aip,AsnTypePtr orig)1034 HitAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1035 {
1036    DataVal av;
1037    AsnTypePtr atp;
1038    Boolean isError = FALSE;
1039    AsnReadFunc func;
1040    HitPtr ptr;
1041 
1042    if (! loaded)
1043    {
1044       if (! bxmlobjAsnLoad()) {
1045          return NULL;
1046       }
1047    }
1048 
1049    if (aip == NULL) {
1050       return NULL;
1051    }
1052 
1053    if (orig == NULL) {         /* Hit ::= (self contained) */
1054       atp = AsnReadId(aip, amp, HIT);
1055    } else {
1056       atp = AsnLinkType(orig, HIT);
1057    }
1058    /* link in local tree */
1059    if (atp == NULL) {
1060       return NULL;
1061    }
1062 
1063    ptr = HitNew();
1064    if (ptr == NULL) {
1065       goto erret;
1066    }
1067    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1068       goto erret;
1069    }
1070 
1071    atp = AsnReadId(aip,amp, atp);
1072    func = NULL;
1073 
1074    if (atp == HIT_num) {
1075       if ( AsnReadVal(aip, atp, &av) <= 0) {
1076          goto erret;
1077       }
1078       ptr -> num = av.intvalue;
1079       atp = AsnReadId(aip,amp, atp);
1080    }
1081    if (atp == HIT_id) {
1082       if ( AsnReadVal(aip, atp, &av) <= 0) {
1083          goto erret;
1084       }
1085       ptr -> id = av.ptrvalue;
1086       atp = AsnReadId(aip,amp, atp);
1087    }
1088    if (atp == HIT_def) {
1089       if ( AsnReadVal(aip, atp, &av) <= 0) {
1090          goto erret;
1091       }
1092       ptr -> def = av.ptrvalue;
1093       atp = AsnReadId(aip,amp, atp);
1094    }
1095    if (atp == HIT_accession) {
1096       if ( AsnReadVal(aip, atp, &av) <= 0) {
1097          goto erret;
1098       }
1099       ptr -> accession = av.ptrvalue;
1100       atp = AsnReadId(aip,amp, atp);
1101    }
1102    if (atp == HIT_len) {
1103       if ( AsnReadVal(aip, atp, &av) <= 0) {
1104          goto erret;
1105       }
1106       ptr -> len = av.intvalue;
1107       atp = AsnReadId(aip,amp, atp);
1108    }
1109    if (atp == HIT_hsps) {
1110       ptr -> hsps = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) HspAsnRead, (AsnOptFreeFunc) HspFree);
1111       if (isError && ptr -> hsps == NULL) {
1112          goto erret;
1113       }
1114       atp = AsnReadId(aip,amp, atp);
1115    }
1116 
1117    if (AsnReadVal(aip, atp, &av) <= 0) {
1118       goto erret;
1119    }
1120    /* end struct */
1121 
1122 ret:
1123    AsnUnlinkType(orig);       /* unlink local tree */
1124    return ptr;
1125 
1126 erret:
1127    aip -> io_failure = TRUE;
1128    ptr = HitFree(ptr);
1129    goto ret;
1130 }
1131 
1132 
1133 
1134 /**************************************************
1135 *
1136 *    HitAsnWrite()
1137 *
1138 **************************************************/
1139 NLM_EXTERN Boolean LIBCALL
HitAsnWrite(HitPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1140 HitAsnWrite(HitPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1141 {
1142    DataVal av;
1143    AsnTypePtr atp;
1144    Boolean retval = FALSE;
1145 
1146    if (! loaded)
1147    {
1148       if (! bxmlobjAsnLoad()) {
1149          return FALSE;
1150       }
1151    }
1152 
1153    if (aip == NULL) {
1154       return FALSE;
1155    }
1156 
1157    atp = AsnLinkType(orig, HIT);   /* link local tree */
1158    if (atp == NULL) {
1159       return FALSE;
1160    }
1161 
1162    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1163    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1164       goto erret;
1165    }
1166 
1167    av.intvalue = ptr -> num;
1168    retval = AsnWrite(aip, HIT_num,  &av);
1169    if (ptr -> id != NULL) {
1170       av.ptrvalue = ptr -> id;
1171       retval = AsnWrite(aip, HIT_id,  &av);
1172    }
1173    if (ptr -> def != NULL) {
1174       av.ptrvalue = ptr -> def;
1175       retval = AsnWrite(aip, HIT_def,  &av);
1176    }
1177    if (ptr -> accession != NULL) {
1178       av.ptrvalue = ptr -> accession;
1179       retval = AsnWrite(aip, HIT_accession,  &av);
1180    }
1181    av.intvalue = ptr -> len;
1182    retval = AsnWrite(aip, HIT_len,  &av);
1183    AsnGenericUserSeqOfAsnWrite(ptr -> hsps, (AsnWriteFunc) HspAsnWrite, aip, HIT_hsps, HIT_hsps_E);
1184    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1185       goto erret;
1186    }
1187    retval = TRUE;
1188 
1189 erret:
1190    AsnUnlinkType(orig);       /* unlink local tree */
1191    return retval;
1192 }
1193 
1194 
1195 
1196 /**************************************************
1197 *
1198 *    HspNew()
1199 *
1200 **************************************************/
1201 NLM_EXTERN
1202 HspPtr LIBCALL
HspNew(void)1203 HspNew(void)
1204 {
1205    HspPtr ptr = MemNew((size_t) sizeof(Hsp));
1206 
1207    return ptr;
1208 
1209 }
1210 
1211 
1212 /**************************************************
1213 *
1214 *    HspFree()
1215 *
1216 **************************************************/
1217 NLM_EXTERN
1218 HspPtr LIBCALL
HspFree(HspPtr ptr)1219 HspFree(HspPtr ptr)
1220 {
1221 
1222    if(ptr == NULL) {
1223       return NULL;
1224    }
1225    MemFree(ptr -> qseq);
1226    MemFree(ptr -> hseq);
1227    MemFree(ptr -> midline);
1228    return MemFree(ptr);
1229 }
1230 
1231 
1232 /**************************************************
1233 *
1234 *    HspAsnRead()
1235 *
1236 **************************************************/
1237 NLM_EXTERN
1238 HspPtr LIBCALL
HspAsnRead(AsnIoPtr aip,AsnTypePtr orig)1239 HspAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1240 {
1241    DataVal av;
1242    AsnTypePtr atp;
1243    Boolean isError = FALSE;
1244    AsnReadFunc func;
1245    HspPtr ptr;
1246 
1247    if (! loaded)
1248    {
1249       if (! bxmlobjAsnLoad()) {
1250          return NULL;
1251       }
1252    }
1253 
1254    if (aip == NULL) {
1255       return NULL;
1256    }
1257 
1258    if (orig == NULL) {         /* Hsp ::= (self contained) */
1259       atp = AsnReadId(aip, amp, HSP);
1260    } else {
1261       atp = AsnLinkType(orig, HSP);
1262    }
1263    /* link in local tree */
1264    if (atp == NULL) {
1265       return NULL;
1266    }
1267 
1268    ptr = HspNew();
1269    if (ptr == NULL) {
1270       goto erret;
1271    }
1272    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1273       goto erret;
1274    }
1275 
1276    atp = AsnReadId(aip,amp, atp);
1277    func = NULL;
1278 
1279    if (atp == HSP_num) {
1280       if ( AsnReadVal(aip, atp, &av) <= 0) {
1281          goto erret;
1282       }
1283       ptr -> num = av.intvalue;
1284       atp = AsnReadId(aip,amp, atp);
1285    }
1286    if (atp == HSP_bit_score) {
1287       if ( AsnReadVal(aip, atp, &av) <= 0) {
1288          goto erret;
1289       }
1290       ptr -> bit_score = av.realvalue;
1291       atp = AsnReadId(aip,amp, atp);
1292    }
1293    if (atp == HSP_score) {
1294       if ( AsnReadVal(aip, atp, &av) <= 0) {
1295          goto erret;
1296       }
1297       ptr -> score = av.realvalue;
1298       atp = AsnReadId(aip,amp, atp);
1299    }
1300    if (atp == HSP_evalue) {
1301       if ( AsnReadVal(aip, atp, &av) <= 0) {
1302          goto erret;
1303       }
1304       ptr -> evalue = av.realvalue;
1305       atp = AsnReadId(aip,amp, atp);
1306    }
1307    if (atp == HSP_query_from) {
1308       if ( AsnReadVal(aip, atp, &av) <= 0) {
1309          goto erret;
1310       }
1311       ptr -> query_from = av.intvalue;
1312       atp = AsnReadId(aip,amp, atp);
1313    }
1314    if (atp == HSP_query_to) {
1315       if ( AsnReadVal(aip, atp, &av) <= 0) {
1316          goto erret;
1317       }
1318       ptr -> query_to = av.intvalue;
1319       atp = AsnReadId(aip,amp, atp);
1320    }
1321    if (atp == HSP_hit_from) {
1322       if ( AsnReadVal(aip, atp, &av) <= 0) {
1323          goto erret;
1324       }
1325       ptr -> hit_from = av.intvalue;
1326       atp = AsnReadId(aip,amp, atp);
1327    }
1328    if (atp == HSP_hit_to) {
1329       if ( AsnReadVal(aip, atp, &av) <= 0) {
1330          goto erret;
1331       }
1332       ptr -> hit_to = av.intvalue;
1333       atp = AsnReadId(aip,amp, atp);
1334    }
1335    if (atp == HSP_pattern_from) {
1336       if ( AsnReadVal(aip, atp, &av) <= 0) {
1337          goto erret;
1338       }
1339       ptr -> pattern_from = av.intvalue;
1340       ptr -> OBbits__ |= 1<<0;
1341       atp = AsnReadId(aip,amp, atp);
1342    }
1343    if (atp == HSP_pattern_to) {
1344       if ( AsnReadVal(aip, atp, &av) <= 0) {
1345          goto erret;
1346       }
1347       ptr -> pattern_to = av.intvalue;
1348       ptr -> OBbits__ |= 1<<1;
1349       atp = AsnReadId(aip,amp, atp);
1350    }
1351    if (atp == HSP_query_frame) {
1352       if ( AsnReadVal(aip, atp, &av) <= 0) {
1353          goto erret;
1354       }
1355       ptr -> query_frame = av.intvalue;
1356       ptr -> OBbits__ |= 1<<2;
1357       atp = AsnReadId(aip,amp, atp);
1358    }
1359    if (atp == HSP_hit_frame) {
1360       if ( AsnReadVal(aip, atp, &av) <= 0) {
1361          goto erret;
1362       }
1363       ptr -> hit_frame = av.intvalue;
1364       ptr -> OBbits__ |= 1<<3;
1365       atp = AsnReadId(aip,amp, atp);
1366    }
1367    if (atp == HSP_identity) {
1368       if ( AsnReadVal(aip, atp, &av) <= 0) {
1369          goto erret;
1370       }
1371       ptr -> identity = av.intvalue;
1372       ptr -> OBbits__ |= 1<<4;
1373       atp = AsnReadId(aip,amp, atp);
1374    }
1375    if (atp == HSP_positive) {
1376       if ( AsnReadVal(aip, atp, &av) <= 0) {
1377          goto erret;
1378       }
1379       ptr -> positive = av.intvalue;
1380       ptr -> OBbits__ |= 1<<5;
1381       atp = AsnReadId(aip,amp, atp);
1382    }
1383    if (atp == HSP_gaps) {
1384       if ( AsnReadVal(aip, atp, &av) <= 0) {
1385          goto erret;
1386       }
1387       ptr -> gaps = av.intvalue;
1388       ptr -> OBbits__ |= 1<<6;
1389       atp = AsnReadId(aip,amp, atp);
1390    }
1391    if (atp == HSP_align_len) {
1392       if ( AsnReadVal(aip, atp, &av) <= 0) {
1393          goto erret;
1394       }
1395       ptr -> align_len = av.intvalue;
1396       ptr -> OBbits__ |= 1<<7;
1397       atp = AsnReadId(aip,amp, atp);
1398    }
1399    if (atp == HSP_density) {
1400       if ( AsnReadVal(aip, atp, &av) <= 0) {
1401          goto erret;
1402       }
1403       ptr -> density = av.intvalue;
1404       ptr -> OBbits__ |= 1<<8;
1405       atp = AsnReadId(aip,amp, atp);
1406    }
1407    if (atp == HSP_qseq) {
1408       if ( AsnReadVal(aip, atp, &av) <= 0) {
1409          goto erret;
1410       }
1411       ptr -> qseq = av.ptrvalue;
1412       atp = AsnReadId(aip,amp, atp);
1413    }
1414    if (atp == HSP_hseq) {
1415       if ( AsnReadVal(aip, atp, &av) <= 0) {
1416          goto erret;
1417       }
1418       ptr -> hseq = av.ptrvalue;
1419       atp = AsnReadId(aip,amp, atp);
1420    }
1421    if (atp == HSP_midline) {
1422       if ( AsnReadVal(aip, atp, &av) <= 0) {
1423          goto erret;
1424       }
1425       ptr -> midline = av.ptrvalue;
1426       atp = AsnReadId(aip,amp, atp);
1427    }
1428 
1429    if (AsnReadVal(aip, atp, &av) <= 0) {
1430       goto erret;
1431    }
1432    /* end struct */
1433 
1434 ret:
1435    AsnUnlinkType(orig);       /* unlink local tree */
1436    return ptr;
1437 
1438 erret:
1439    aip -> io_failure = TRUE;
1440    ptr = HspFree(ptr);
1441    goto ret;
1442 }
1443 
1444 
1445 
1446 /**************************************************
1447 *
1448 *    HspAsnWrite()
1449 *
1450 **************************************************/
1451 NLM_EXTERN Boolean LIBCALL
HspAsnWrite(HspPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1452 HspAsnWrite(HspPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1453 {
1454    DataVal av;
1455    AsnTypePtr atp;
1456    Boolean retval = FALSE;
1457 
1458    if (! loaded)
1459    {
1460       if (! bxmlobjAsnLoad()) {
1461          return FALSE;
1462       }
1463    }
1464 
1465    if (aip == NULL) {
1466       return FALSE;
1467    }
1468 
1469    atp = AsnLinkType(orig, HSP);   /* link local tree */
1470    if (atp == NULL) {
1471       return FALSE;
1472    }
1473 
1474    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1475    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1476       goto erret;
1477    }
1478 
1479    av.intvalue = ptr -> num;
1480    retval = AsnWrite(aip, HSP_num,  &av);
1481    av.realvalue = ptr -> bit_score;
1482    retval = AsnWrite(aip, HSP_bit_score,  &av);
1483    av.realvalue = ptr -> score;
1484    retval = AsnWrite(aip, HSP_score,  &av);
1485    av.realvalue = ptr -> evalue;
1486    retval = AsnWrite(aip, HSP_evalue,  &av);
1487    av.intvalue = ptr -> query_from;
1488    retval = AsnWrite(aip, HSP_query_from,  &av);
1489    av.intvalue = ptr -> query_to;
1490    retval = AsnWrite(aip, HSP_query_to,  &av);
1491    av.intvalue = ptr -> hit_from;
1492    retval = AsnWrite(aip, HSP_hit_from,  &av);
1493    av.intvalue = ptr -> hit_to;
1494    retval = AsnWrite(aip, HSP_hit_to,  &av);
1495    if (ptr -> pattern_from || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> pattern_from;
1496       retval = AsnWrite(aip, HSP_pattern_from,  &av);
1497    }
1498    if (ptr -> pattern_to || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> pattern_to;
1499       retval = AsnWrite(aip, HSP_pattern_to,  &av);
1500    }
1501    if (ptr -> query_frame || (ptr -> OBbits__ & (1<<2) )){   av.intvalue = ptr -> query_frame;
1502       retval = AsnWrite(aip, HSP_query_frame,  &av);
1503    }
1504    if (ptr -> hit_frame || (ptr -> OBbits__ & (1<<3) )){   av.intvalue = ptr -> hit_frame;
1505       retval = AsnWrite(aip, HSP_hit_frame,  &av);
1506    }
1507    if (ptr -> identity || (ptr -> OBbits__ & (1<<4) )){   av.intvalue = ptr -> identity;
1508       retval = AsnWrite(aip, HSP_identity,  &av);
1509    }
1510    if (ptr -> positive || (ptr -> OBbits__ & (1<<5) )){   av.intvalue = ptr -> positive;
1511       retval = AsnWrite(aip, HSP_positive,  &av);
1512    }
1513    if (ptr -> gaps || (ptr -> OBbits__ & (1<<6) )){   av.intvalue = ptr -> gaps;
1514       retval = AsnWrite(aip, HSP_gaps,  &av);
1515    }
1516    if (ptr -> align_len || (ptr -> OBbits__ & (1<<7) )){   av.intvalue = ptr -> align_len;
1517       retval = AsnWrite(aip, HSP_align_len,  &av);
1518    }
1519    if (ptr -> density || (ptr -> OBbits__ & (1<<8) )){   av.intvalue = ptr -> density;
1520       retval = AsnWrite(aip, HSP_density,  &av);
1521    }
1522    if (ptr -> qseq != NULL) {
1523       av.ptrvalue = ptr -> qseq;
1524       retval = AsnWrite(aip, HSP_qseq,  &av);
1525    }
1526    if (ptr -> hseq != NULL) {
1527       av.ptrvalue = ptr -> hseq;
1528       retval = AsnWrite(aip, HSP_hseq,  &av);
1529    }
1530    if (ptr -> midline != NULL) {
1531       av.ptrvalue = ptr -> midline;
1532       retval = AsnWrite(aip, HSP_midline,  &av);
1533    }
1534    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1535       goto erret;
1536    }
1537    retval = TRUE;
1538 
1539 erret:
1540    AsnUnlinkType(orig);       /* unlink local tree */
1541    return retval;
1542 }
1543 
1544