home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / blast2 / client / objblst2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-05  |  130.2 KB  |  5,858 lines  |  [TEXT/R*ch]

  1. #include <asn.h>
  2.  
  3. #define NLM_GENERATED_CODE_PROTO
  4.  
  5. #include "blast18p.h"
  6. #include "objblst2.h"
  7.  
  8. static Boolean loaded = FALSE;
  9.  
  10. #include "asnbl18.h"
  11.  
  12. #ifndef NLM_EXTERN_LOADS
  13. #define NLM_EXTERN_LOADS {}
  14. #endif
  15.  
  16. Boolean LIBCALL
  17. objblst2AsnLoad(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 NCBI-BLAST-1
  35. *    Generated using ASNCODE Revision: 1.17 at Jun 28, 1995  2:37 PM
  36. *
  37. **************************************************/
  38.  
  39.  
  40. /**************************************************
  41. *
  42. *    BLAST0PrefaceNew()
  43. *
  44. **************************************************/
  45.  
  46. BLAST0PrefacePtr LIBCALL
  47. BLAST0PrefaceNew(void)
  48. {
  49.    BLAST0PrefacePtr ptr = MemNew((size_t) sizeof(BLAST0Preface));
  50.  
  51.    return ptr;
  52.  
  53. }
  54.  
  55.  
  56. /**************************************************
  57. *
  58. *    BLAST0PrefaceFree()
  59. *
  60. **************************************************/
  61.  
  62. BLAST0PrefacePtr LIBCALL
  63. BLAST0PrefaceFree(BLAST0PrefacePtr ptr)
  64. {
  65.  
  66.    if(ptr == NULL) {
  67.       return NULL;
  68.    }
  69.    MemFree(ptr -> program);
  70.    MemFree(ptr -> desc);
  71.    MemFree(ptr -> version);
  72.    MemFree(ptr -> dev_date);
  73.    MemFree(ptr -> bld_date);
  74.    AsnGenericBaseSeqOfFree(ptr -> cit ,ASNCODE_PTRVAL_SLOT);
  75.    AsnGenericBaseSeqOfFree(ptr -> notice ,ASNCODE_PTRVAL_SLOT);
  76.    AsnGenericBaseSeqOfFree(ptr -> prog_usage ,ASNCODE_PTRVAL_SLOT);
  77.    BLAST0SeqUsageFree(ptr -> susage);
  78.    BLAST0SeqUsageFree(ptr -> qusage);
  79.    return MemFree(ptr);
  80. }
  81.  
  82.  
  83. /**************************************************
  84. *
  85. *    BLAST0PrefaceAsnRead()
  86. *
  87. **************************************************/
  88.  
  89. BLAST0PrefacePtr LIBCALL
  90. BLAST0PrefaceAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  91. {
  92.    DataVal av;
  93.    AsnTypePtr atp;
  94.    Boolean isError = FALSE;
  95.    AsnReadFunc func;
  96.    BLAST0PrefacePtr ptr;
  97.  
  98.    if (! loaded)
  99.    {
  100.       if (! objblst2AsnLoad()) {
  101.          return NULL;
  102.       }
  103.    }
  104.  
  105.    if (aip == NULL) {
  106.       return NULL;
  107.    }
  108.  
  109.    if (orig == NULL) {         /* BLAST0Preface ::= (self contained) */
  110.       atp = AsnReadId(aip, amp, BLAST0_PREFACE);
  111.    } else {
  112.       atp = AsnLinkType(orig, BLAST0_PREFACE);
  113.    }
  114.    /* link in local tree */
  115.    if (atp == NULL) {
  116.       return NULL;
  117.    }
  118.  
  119.    ptr = BLAST0PrefaceNew();
  120.    if (ptr == NULL) {
  121.       goto erret;
  122.    }
  123.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  124.       goto erret;
  125.    }
  126.  
  127.    atp = AsnReadId(aip,amp, atp);
  128.    func = NULL;
  129.  
  130.    if (atp == BLAST0_PREFACE_program) {
  131.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  132.          goto erret;
  133.       }
  134.       ptr -> program = av.ptrvalue;
  135.       atp = AsnReadId(aip,amp, atp);
  136.    }
  137.    if (atp == BLAST0_PREFACE_desc) {
  138.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  139.          goto erret;
  140.       }
  141.       ptr -> desc = av.ptrvalue;
  142.       atp = AsnReadId(aip,amp, atp);
  143.    }
  144.    if (atp == BLAST0_PREFACE_version) {
  145.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  146.          goto erret;
  147.       }
  148.       ptr -> version = av.ptrvalue;
  149.       atp = AsnReadId(aip,amp, atp);
  150.    }
  151.    if (atp == BLAST0_PREFACE_dev_date) {
  152.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  153.          goto erret;
  154.       }
  155.       ptr -> dev_date = av.ptrvalue;
  156.       atp = AsnReadId(aip,amp, atp);
  157.    }
  158.    if (atp == BLAST0_PREFACE_bld_date) {
  159.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  160.          goto erret;
  161.       }
  162.       ptr -> bld_date = av.ptrvalue;
  163.       atp = AsnReadId(aip,amp, atp);
  164.    }
  165.    if (atp == BLAST0_PREFACE_cit) {
  166.       ptr -> cit = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  167.       if (isError && ptr -> cit == NULL) {
  168.          goto erret;
  169.       }
  170.       atp = AsnReadId(aip,amp, atp);
  171.    }
  172.    if (atp == BLAST0_PREFACE_notice) {
  173.       ptr -> notice = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  174.       if (isError && ptr -> notice == NULL) {
  175.          goto erret;
  176.       }
  177.       atp = AsnReadId(aip,amp, atp);
  178.    }
  179.    if (atp == BLAST0_PREFACE_prog_usage) {
  180.       ptr -> prog_usage = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  181.       if (isError && ptr -> prog_usage == NULL) {
  182.          goto erret;
  183.       }
  184.       atp = AsnReadId(aip,amp, atp);
  185.    }
  186.    if (atp == BLAST0_PREFACE_susage) {
  187.       ptr -> susage = BLAST0SeqUsageAsnRead(aip, atp);
  188.       if (aip -> io_failure) {
  189.          goto erret;
  190.       }
  191.       atp = AsnReadId(aip,amp, atp);
  192.    }
  193.    if (atp == BLAST0_PREFACE_qusage) {
  194.       ptr -> qusage = BLAST0SeqUsageAsnRead(aip, atp);
  195.       if (aip -> io_failure) {
  196.          goto erret;
  197.       }
  198.       atp = AsnReadId(aip,amp, atp);
  199.    }
  200.  
  201.    if (AsnReadVal(aip, atp, &av) <= 0) {
  202.       goto erret;
  203.    }
  204.    /* end struct */
  205.  
  206. ret:
  207.    AsnUnlinkType(orig);       /* unlink local tree */
  208.    return ptr;
  209.  
  210. erret:
  211.    aip -> io_failure = TRUE;
  212.    ptr = BLAST0PrefaceFree(ptr);
  213.    goto ret;
  214. }
  215.  
  216.  
  217.  
  218. /**************************************************
  219. *
  220. *    BLAST0PrefaceAsnWrite()
  221. *
  222. **************************************************/
  223. Boolean LIBCALL 
  224. BLAST0PrefaceAsnWrite(BLAST0PrefacePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  225. {
  226.    DataVal av;
  227.    AsnTypePtr atp;
  228.    Boolean retval = FALSE;
  229.  
  230.    if (! loaded)
  231.    {
  232.       if (! objblst2AsnLoad()) {
  233.          return FALSE;
  234.       }
  235.    }
  236.  
  237.    if (aip == NULL) {
  238.       return FALSE;
  239.    }
  240.  
  241.    atp = AsnLinkType(orig, BLAST0_PREFACE);   /* link local tree */
  242.    if (atp == NULL) {
  243.       return FALSE;
  244.    }
  245.  
  246.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  247.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  248.       goto erret;
  249.    }
  250.  
  251.    if (ptr -> program != NULL) {
  252.       av.ptrvalue = ptr -> program;
  253.       retval = AsnWrite(aip, BLAST0_PREFACE_program,  &av);
  254.    }
  255.    if (ptr -> desc != NULL) {
  256.       av.ptrvalue = ptr -> desc;
  257.       retval = AsnWrite(aip, BLAST0_PREFACE_desc,  &av);
  258.    }
  259.    if (ptr -> version != NULL) {
  260.       av.ptrvalue = ptr -> version;
  261.       retval = AsnWrite(aip, BLAST0_PREFACE_version,  &av);
  262.    }
  263.    if (ptr -> dev_date != NULL) {
  264.       av.ptrvalue = ptr -> dev_date;
  265.       retval = AsnWrite(aip, BLAST0_PREFACE_dev_date,  &av);
  266.    }
  267.    if (ptr -> bld_date != NULL) {
  268.       av.ptrvalue = ptr -> bld_date;
  269.       retval = AsnWrite(aip, BLAST0_PREFACE_bld_date,  &av);
  270.    }
  271.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> cit ,ASNCODE_PTRVAL_SLOT, aip, BLAST0_PREFACE_cit, BLAST0_PREFACE_cit_E);
  272.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> notice ,ASNCODE_PTRVAL_SLOT, aip, BLAST0_PREFACE_notice, BLAST0_PREFACE_notice_E);
  273.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> prog_usage ,ASNCODE_PTRVAL_SLOT, aip, BLAST0_PREFACE_prog_usage, BLAST0_PREFACE_prog_usage_E);
  274.    if (ptr -> susage != NULL) {
  275.       if ( ! BLAST0SeqUsageAsnWrite(ptr -> susage, aip, BLAST0_PREFACE_susage)) {
  276.          goto erret;
  277.       }
  278.    }
  279.    if (ptr -> qusage != NULL) {
  280.       if ( ! BLAST0SeqUsageAsnWrite(ptr -> qusage, aip, BLAST0_PREFACE_qusage)) {
  281.          goto erret;
  282.       }
  283.    }
  284.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  285.       goto erret;
  286.    }
  287.    retval = TRUE;
  288.  
  289. erret:
  290.    AsnUnlinkType(orig);       /* unlink local tree */
  291.    return retval;
  292. }
  293.  
  294.  
  295.  
  296. /**************************************************
  297. *
  298. *    BLAST0JobDescNew()
  299. *
  300. **************************************************/
  301.  
  302. BLAST0JobDescPtr LIBCALL
  303. BLAST0JobDescNew(void)
  304. {
  305.    BLAST0JobDescPtr ptr = MemNew((size_t) sizeof(BLAST0JobDesc));
  306.  
  307.    return ptr;
  308.  
  309. }
  310.  
  311.  
  312. /**************************************************
  313. *
  314. *    BLAST0JobDescFree()
  315. *
  316. **************************************************/
  317.  
  318. BLAST0JobDescPtr LIBCALL
  319. BLAST0JobDescFree(BLAST0JobDescPtr ptr)
  320. {
  321.  
  322.    if(ptr == NULL) {
  323.       return NULL;
  324.    }
  325.    MemFree(ptr -> desc);
  326.    return MemFree(ptr);
  327. }
  328.  
  329.  
  330. /**************************************************
  331. *
  332. *    BLAST0JobDescAsnRead()
  333. *
  334. **************************************************/
  335.  
  336. BLAST0JobDescPtr LIBCALL
  337. BLAST0JobDescAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  338. {
  339.    DataVal av;
  340.    AsnTypePtr atp;
  341.    Boolean isError = FALSE;
  342.    AsnReadFunc func;
  343.    BLAST0JobDescPtr ptr;
  344.  
  345.    if (! loaded)
  346.    {
  347.       if (! objblst2AsnLoad()) {
  348.          return NULL;
  349.       }
  350.    }
  351.  
  352.    if (aip == NULL) {
  353.       return NULL;
  354.    }
  355.  
  356.    if (orig == NULL) {         /* BLAST0JobDesc ::= (self contained) */
  357.       atp = AsnReadId(aip, amp, BLAST0_JOB_DESC);
  358.    } else {
  359.       atp = AsnLinkType(orig, BLAST0_JOB_DESC);
  360.    }
  361.    /* link in local tree */
  362.    if (atp == NULL) {
  363.       return NULL;
  364.    }
  365.  
  366.    ptr = BLAST0JobDescNew();
  367.    if (ptr == NULL) {
  368.       goto erret;
  369.    }
  370.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  371.       goto erret;
  372.    }
  373.  
  374.    atp = AsnReadId(aip,amp, atp);
  375.    func = NULL;
  376.  
  377.    if (atp == BLAST0_JOB_DESC_jid) {
  378.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  379.          goto erret;
  380.       }
  381.       ptr -> jid = av.intvalue;
  382.       atp = AsnReadId(aip,amp, atp);
  383.    }
  384.    if (atp == BLAST0_JOB_DESC_desc) {
  385.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  386.          goto erret;
  387.       }
  388.       ptr -> desc = av.ptrvalue;
  389.       atp = AsnReadId(aip,amp, atp);
  390.    }
  391.    if (atp == BLAST0_JOB_DESC_size) {
  392.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  393.          goto erret;
  394.       }
  395.       ptr -> size = av.intvalue;
  396.       atp = AsnReadId(aip,amp, atp);
  397.    }
  398.  
  399.    if (AsnReadVal(aip, atp, &av) <= 0) {
  400.       goto erret;
  401.    }
  402.    /* end struct */
  403.  
  404. ret:
  405.    AsnUnlinkType(orig);       /* unlink local tree */
  406.    return ptr;
  407.  
  408. erret:
  409.    aip -> io_failure = TRUE;
  410.    ptr = BLAST0JobDescFree(ptr);
  411.    goto ret;
  412. }
  413.  
  414.  
  415.  
  416. /**************************************************
  417. *
  418. *    BLAST0JobDescAsnWrite()
  419. *
  420. **************************************************/
  421. Boolean LIBCALL 
  422. BLAST0JobDescAsnWrite(BLAST0JobDescPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  423. {
  424.    DataVal av;
  425.    AsnTypePtr atp;
  426.    Boolean retval = FALSE;
  427.  
  428.    if (! loaded)
  429.    {
  430.       if (! objblst2AsnLoad()) {
  431.          return FALSE;
  432.       }
  433.    }
  434.  
  435.    if (aip == NULL) {
  436.       return FALSE;
  437.    }
  438.  
  439.    atp = AsnLinkType(orig, BLAST0_JOB_DESC);   /* link local tree */
  440.    if (atp == NULL) {
  441.       return FALSE;
  442.    }
  443.  
  444.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  445.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  446.       goto erret;
  447.    }
  448.  
  449.    av.intvalue = ptr -> jid;
  450.    retval = AsnWrite(aip, BLAST0_JOB_DESC_jid,  &av);
  451.    if (ptr -> desc != NULL) {
  452.       av.ptrvalue = ptr -> desc;
  453.       retval = AsnWrite(aip, BLAST0_JOB_DESC_desc,  &av);
  454.    }
  455.    av.intvalue = ptr -> size;
  456.    retval = AsnWrite(aip, BLAST0_JOB_DESC_size,  &av);
  457.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  458.       goto erret;
  459.    }
  460.    retval = TRUE;
  461.  
  462. erret:
  463.    AsnUnlinkType(orig);       /* unlink local tree */
  464.    return retval;
  465. }
  466.  
  467.  
  468.  
  469. /**************************************************
  470. *
  471. *    BLAST0JobProgressNew()
  472. *
  473. **************************************************/
  474.  
  475. BLAST0JobProgressPtr LIBCALL
  476. BLAST0JobProgressNew(void)
  477. {
  478.    BLAST0JobProgressPtr ptr = MemNew((size_t) sizeof(BLAST0JobProgress));
  479.  
  480.    return ptr;
  481.  
  482. }
  483.  
  484.  
  485. /**************************************************
  486. *
  487. *    BLAST0JobProgressFree()
  488. *
  489. **************************************************/
  490.  
  491. BLAST0JobProgressPtr LIBCALL
  492. BLAST0JobProgressFree(BLAST0JobProgressPtr ptr)
  493. {
  494.  
  495.    if(ptr == NULL) {
  496.       return NULL;
  497.    }
  498.    return MemFree(ptr);
  499. }
  500.  
  501.  
  502. /**************************************************
  503. *
  504. *    BLAST0JobProgressAsnRead()
  505. *
  506. **************************************************/
  507.  
  508. BLAST0JobProgressPtr LIBCALL
  509. BLAST0JobProgressAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  510. {
  511.    DataVal av;
  512.    AsnTypePtr atp;
  513.    Boolean isError = FALSE;
  514.    AsnReadFunc func;
  515.    BLAST0JobProgressPtr ptr;
  516.  
  517.    if (! loaded)
  518.    {
  519.       if (! objblst2AsnLoad()) {
  520.          return NULL;
  521.       }
  522.    }
  523.  
  524.    if (aip == NULL) {
  525.       return NULL;
  526.    }
  527.  
  528.    if (orig == NULL) {         /* BLAST0JobProgress ::= (self contained) */
  529.       atp = AsnReadId(aip, amp, BLAST0_JOB_PROGRESS);
  530.    } else {
  531.       atp = AsnLinkType(orig, BLAST0_JOB_PROGRESS);
  532.    }
  533.    /* link in local tree */
  534.    if (atp == NULL) {
  535.       return NULL;
  536.    }
  537.  
  538.    ptr = BLAST0JobProgressNew();
  539.    if (ptr == NULL) {
  540.       goto erret;
  541.    }
  542.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  543.       goto erret;
  544.    }
  545.  
  546.    atp = AsnReadId(aip,amp, atp);
  547.    func = NULL;
  548.  
  549.    if (atp == BLAST0_JOB_PROGRESS_done) {
  550.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  551.          goto erret;
  552.       }
  553.       ptr -> done = av.intvalue;
  554.       atp = AsnReadId(aip,amp, atp);
  555.    }
  556.    if (atp == BLAST0_JOB_PROGRESS_positives) {
  557.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  558.          goto erret;
  559.       }
  560.       ptr -> positives = av.intvalue;
  561.       atp = AsnReadId(aip,amp, atp);
  562.    }
  563.  
  564.    if (AsnReadVal(aip, atp, &av) <= 0) {
  565.       goto erret;
  566.    }
  567.    /* end struct */
  568.  
  569. ret:
  570.    AsnUnlinkType(orig);       /* unlink local tree */
  571.    return ptr;
  572.  
  573. erret:
  574.    aip -> io_failure = TRUE;
  575.    ptr = BLAST0JobProgressFree(ptr);
  576.    goto ret;
  577. }
  578.  
  579.  
  580.  
  581. /**************************************************
  582. *
  583. *    BLAST0JobProgressAsnWrite()
  584. *
  585. **************************************************/
  586. Boolean LIBCALL 
  587. BLAST0JobProgressAsnWrite(BLAST0JobProgressPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  588. {
  589.    DataVal av;
  590.    AsnTypePtr atp;
  591.    Boolean retval = FALSE;
  592.  
  593.    if (! loaded)
  594.    {
  595.       if (! objblst2AsnLoad()) {
  596.          return FALSE;
  597.       }
  598.    }
  599.  
  600.    if (aip == NULL) {
  601.       return FALSE;
  602.    }
  603.  
  604.    atp = AsnLinkType(orig, BLAST0_JOB_PROGRESS);   /* link local tree */
  605.    if (atp == NULL) {
  606.       return FALSE;
  607.    }
  608.  
  609.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  610.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  611.       goto erret;
  612.    }
  613.  
  614.    av.intvalue = ptr -> done;
  615.    retval = AsnWrite(aip, BLAST0_JOB_PROGRESS_done,  &av);
  616.    av.intvalue = ptr -> positives;
  617.    retval = AsnWrite(aip, BLAST0_JOB_PROGRESS_positives,  &av);
  618.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  619.       goto erret;
  620.    }
  621.    retval = TRUE;
  622.  
  623. erret:
  624.    AsnUnlinkType(orig);       /* unlink local tree */
  625.    return retval;
  626. }
  627.  
  628.  
  629.  
  630. /**************************************************
  631. *
  632. *    BLAST0SequenceNew()
  633. *
  634. **************************************************/
  635.  
  636. BLAST0SequencePtr LIBCALL
  637. BLAST0SequenceNew(void)
  638. {
  639.    BLAST0SequencePtr ptr = MemNew((size_t) sizeof(BLAST0Sequence));
  640.  
  641.    return ptr;
  642.  
  643. }
  644.  
  645.  
  646. /**************************************************
  647. *
  648. *    BLAST0SequenceFree()
  649. *
  650. **************************************************/
  651.  
  652. BLAST0SequencePtr LIBCALL
  653. BLAST0SequenceFree(BLAST0SequencePtr ptr)
  654. {
  655.  
  656.    if(ptr == NULL) {
  657.       return NULL;
  658.    }
  659.    AsnGenericUserSeqOfFree(ptr -> desc, (AsnOptFreeFunc) BLAST0SeqDescFree);
  660.    BLAST0SeqDataFree(ptr -> seq);
  661.    return MemFree(ptr);
  662. }
  663.  
  664.  
  665. /**************************************************
  666. *
  667. *    BLAST0SequenceAsnRead()
  668. *
  669. **************************************************/
  670.  
  671. BLAST0SequencePtr LIBCALL
  672. BLAST0SequenceAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  673. {
  674.    DataVal av;
  675.    AsnTypePtr atp;
  676.    Boolean isError = FALSE;
  677.    AsnReadFunc func;
  678.    BLAST0SequencePtr ptr;
  679.  
  680.    if (! loaded)
  681.    {
  682.       if (! objblst2AsnLoad()) {
  683.          return NULL;
  684.       }
  685.    }
  686.  
  687.    if (aip == NULL) {
  688.       return NULL;
  689.    }
  690.  
  691.    if (orig == NULL) {         /* BLAST0Sequence ::= (self contained) */
  692.       atp = AsnReadId(aip, amp, BLAST0_SEQUENCE);
  693.    } else {
  694.       atp = AsnLinkType(orig, BLAST0_SEQUENCE);
  695.    }
  696.    /* link in local tree */
  697.    if (atp == NULL) {
  698.       return NULL;
  699.    }
  700.  
  701.    ptr = BLAST0SequenceNew();
  702.    if (ptr == NULL) {
  703.       goto erret;
  704.    }
  705.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  706.       goto erret;
  707.    }
  708.  
  709.    atp = AsnReadId(aip,amp, atp);
  710.    func = NULL;
  711.  
  712.    if (atp == BLAST0_SEQUENCE_desc) {
  713.       ptr -> desc = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0SeqDescAsnRead, (AsnOptFreeFunc) BLAST0SeqDescFree);
  714.       if (isError && ptr -> desc == NULL) {
  715.          goto erret;
  716.       }
  717.       atp = AsnReadId(aip,amp, atp);
  718.    }
  719.    if (atp == BLAST0_SEQUENCE_length) {
  720.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  721.          goto erret;
  722.       }
  723.       ptr -> length = av.intvalue;
  724.       atp = AsnReadId(aip,amp, atp);
  725.    }
  726.    if (atp == BLAST0_SEQUENCE_gcode) {
  727.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  728.          goto erret;
  729.       }
  730.       ptr -> gcode = av.intvalue;
  731.       ptr -> OBbits__ |= 1<<0;
  732.       atp = AsnReadId(aip,amp, atp);
  733.    }
  734.    if (atp == BLAST0_SEQUENCE_seq) {
  735.       ptr -> seq = BLAST0SeqDataAsnRead(aip, atp);
  736.       if (aip -> io_failure) {
  737.          goto erret;
  738.       }
  739.       atp = AsnReadId(aip,amp, atp);
  740.    }
  741.  
  742.    if (AsnReadVal(aip, atp, &av) <= 0) {
  743.       goto erret;
  744.    }
  745.    /* end struct */
  746.  
  747. ret:
  748.    AsnUnlinkType(orig);       /* unlink local tree */
  749.    return ptr;
  750.  
  751. erret:
  752.    aip -> io_failure = TRUE;
  753.    ptr = BLAST0SequenceFree(ptr);
  754.    goto ret;
  755. }
  756.  
  757.  
  758.  
  759. /**************************************************
  760. *
  761. *    BLAST0SequenceAsnWrite()
  762. *
  763. **************************************************/
  764. Boolean LIBCALL 
  765. BLAST0SequenceAsnWrite(BLAST0SequencePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  766. {
  767.    DataVal av;
  768.    AsnTypePtr atp;
  769.    Boolean retval = FALSE;
  770.  
  771.    if (! loaded)
  772.    {
  773.       if (! objblst2AsnLoad()) {
  774.          return FALSE;
  775.       }
  776.    }
  777.  
  778.    if (aip == NULL) {
  779.       return FALSE;
  780.    }
  781.  
  782.    atp = AsnLinkType(orig, BLAST0_SEQUENCE);   /* link local tree */
  783.    if (atp == NULL) {
  784.       return FALSE;
  785.    }
  786.  
  787.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  788.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  789.       goto erret;
  790.    }
  791.  
  792.    AsnGenericUserSeqOfAsnWrite(ptr -> desc, (AsnWriteFunc) BLAST0SeqDescAsnWrite, aip, BLAST0_SEQUENCE_desc, BLAST0_SEQUENCE_desc_E);
  793.    av.intvalue = ptr -> length;
  794.    retval = AsnWrite(aip, BLAST0_SEQUENCE_length,  &av);
  795.    if (ptr -> gcode || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> gcode;
  796.       retval = AsnWrite(aip, BLAST0_SEQUENCE_gcode,  &av);
  797.    }
  798.    if (ptr -> seq != NULL) {
  799.       if ( ! BLAST0SeqDataAsnWrite(ptr -> seq, aip, BLAST0_SEQUENCE_seq)) {
  800.          goto erret;
  801.       }
  802.    }
  803.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  804.       goto erret;
  805.    }
  806.    retval = TRUE;
  807.  
  808. erret:
  809.    AsnUnlinkType(orig);       /* unlink local tree */
  810.    return retval;
  811. }
  812.  
  813.  
  814.  
  815. /**************************************************
  816. *
  817. *    BLAST0KABlkNew()
  818. *
  819. **************************************************/
  820.  
  821. BLAST0KABlkPtr LIBCALL
  822. BLAST0KABlkNew(void)
  823. {
  824.    BLAST0KABlkPtr ptr = MemNew((size_t) sizeof(BLAST0KABlk));
  825.  
  826.    return ptr;
  827.  
  828. }
  829.  
  830.  
  831. /**************************************************
  832. *
  833. *    BLAST0KABlkFree()
  834. *
  835. **************************************************/
  836.  
  837. BLAST0KABlkPtr LIBCALL
  838. BLAST0KABlkFree(BLAST0KABlkPtr ptr)
  839. {
  840.  
  841.    if(ptr == NULL) {
  842.       return NULL;
  843.    }
  844.    AsnGenericBaseSeqOfFree(ptr -> frames ,ASNCODE_INTVAL_SLOT);
  845.    return MemFree(ptr);
  846. }
  847.  
  848.  
  849. /**************************************************
  850. *
  851. *    BLAST0KABlkAsnRead()
  852. *
  853. **************************************************/
  854.  
  855. BLAST0KABlkPtr LIBCALL
  856. BLAST0KABlkAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  857. {
  858.    DataVal av;
  859.    AsnTypePtr atp;
  860.    Boolean isError = FALSE;
  861.    AsnReadFunc func;
  862.    BLAST0KABlkPtr ptr;
  863.  
  864.    if (! loaded)
  865.    {
  866.       if (! objblst2AsnLoad()) {
  867.          return NULL;
  868.       }
  869.    }
  870.  
  871.    if (aip == NULL) {
  872.       return NULL;
  873.    }
  874.  
  875.    if (orig == NULL) {         /* BLAST0KABlk ::= (self contained) */
  876.       atp = AsnReadId(aip, amp, BLAST0_KA_BLK);
  877.    } else {
  878.       atp = AsnLinkType(orig, BLAST0_KA_BLK);
  879.    }
  880.    /* link in local tree */
  881.    if (atp == NULL) {
  882.       return NULL;
  883.    }
  884.  
  885.    ptr = BLAST0KABlkNew();
  886.    if (ptr == NULL) {
  887.       goto erret;
  888.    }
  889.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  890.       goto erret;
  891.    }
  892.  
  893.    atp = AsnReadId(aip,amp, atp);
  894.    func = NULL;
  895.  
  896.    if (atp == BLAST0_KA_BLK_matid) {
  897.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  898.          goto erret;
  899.       }
  900.       ptr -> matid = av.intvalue;
  901.       atp = AsnReadId(aip,amp, atp);
  902.    }
  903.    if (atp == BLAST0_KA_BLK_frames) {
  904.       ptr -> frames = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
  905.       if (isError && ptr -> frames == NULL) {
  906.          goto erret;
  907.       }
  908.       atp = AsnReadId(aip,amp, atp);
  909.    }
  910.    if (atp == BLAST0_KA_BLK_lambda) {
  911.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  912.          goto erret;
  913.       }
  914.       ptr -> lambda = av.realvalue;
  915.       atp = AsnReadId(aip,amp, atp);
  916.    }
  917.    if (atp == BLAST0_KA_BLK_k) {
  918.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  919.          goto erret;
  920.       }
  921.       ptr -> k = av.realvalue;
  922.       atp = AsnReadId(aip,amp, atp);
  923.    }
  924.    if (atp == BLAST0_KA_BLK_h) {
  925.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  926.          goto erret;
  927.       }
  928.       ptr -> h = av.realvalue;
  929.       atp = AsnReadId(aip,amp, atp);
  930.    }
  931.  
  932.    if (AsnReadVal(aip, atp, &av) <= 0) {
  933.       goto erret;
  934.    }
  935.    /* end struct */
  936.  
  937. ret:
  938.    AsnUnlinkType(orig);       /* unlink local tree */
  939.    return ptr;
  940.  
  941. erret:
  942.    aip -> io_failure = TRUE;
  943.    ptr = BLAST0KABlkFree(ptr);
  944.    goto ret;
  945. }
  946.  
  947.  
  948.  
  949. /**************************************************
  950. *
  951. *    BLAST0KABlkAsnWrite()
  952. *
  953. **************************************************/
  954. Boolean LIBCALL 
  955. BLAST0KABlkAsnWrite(BLAST0KABlkPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  956. {
  957.    DataVal av;
  958.    AsnTypePtr atp;
  959.    Boolean retval = FALSE;
  960.  
  961.    if (! loaded)
  962.    {
  963.       if (! objblst2AsnLoad()) {
  964.          return FALSE;
  965.       }
  966.    }
  967.  
  968.    if (aip == NULL) {
  969.       return FALSE;
  970.    }
  971.  
  972.    atp = AsnLinkType(orig, BLAST0_KA_BLK);   /* link local tree */
  973.    if (atp == NULL) {
  974.       return FALSE;
  975.    }
  976.  
  977.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  978.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  979.       goto erret;
  980.    }
  981.  
  982.    av.intvalue = ptr -> matid;
  983.    retval = AsnWrite(aip, BLAST0_KA_BLK_matid,  &av);
  984.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> frames ,ASNCODE_INTVAL_SLOT, aip, BLAST0_KA_BLK_frames, BLAST0_KA_BLK_frames_E);
  985.    av.realvalue = ptr -> lambda;
  986.    retval = AsnWrite(aip, BLAST0_KA_BLK_lambda,  &av);
  987.    av.realvalue = ptr -> k;
  988.    retval = AsnWrite(aip, BLAST0_KA_BLK_k,  &av);
  989.    av.realvalue = ptr -> h;
  990.    retval = AsnWrite(aip, BLAST0_KA_BLK_h,  &av);
  991.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  992.       goto erret;
  993.    }
  994.    retval = TRUE;
  995.  
  996. erret:
  997.    AsnUnlinkType(orig);       /* unlink local tree */
  998.    return retval;
  999. }
  1000.  
  1001.  
  1002.  
  1003. /**************************************************
  1004. *
  1005. *    BLAST0DbDescNew()
  1006. *
  1007. **************************************************/
  1008.  
  1009. BLAST0DbDescPtr LIBCALL
  1010. BLAST0DbDescNew(void)
  1011. {
  1012.    BLAST0DbDescPtr ptr = MemNew((size_t) sizeof(BLAST0DbDesc));
  1013.  
  1014.    return ptr;
  1015.  
  1016. }
  1017.  
  1018.  
  1019. /**************************************************
  1020. *
  1021. *    BLAST0DbDescFree()
  1022. *
  1023. **************************************************/
  1024.  
  1025. BLAST0DbDescPtr LIBCALL
  1026. BLAST0DbDescFree(BLAST0DbDescPtr ptr)
  1027. {
  1028.  
  1029.    if(ptr == NULL) {
  1030.       return NULL;
  1031.    }
  1032.    MemFree(ptr -> name);
  1033.    MemFree(ptr -> def);
  1034.    MemFree(ptr -> rel_date);
  1035.    MemFree(ptr -> bld_date);
  1036.    return MemFree(ptr);
  1037. }
  1038.  
  1039.  
  1040. /**************************************************
  1041. *
  1042. *    BLAST0DbDescAsnRead()
  1043. *
  1044. **************************************************/
  1045.  
  1046. BLAST0DbDescPtr LIBCALL
  1047. BLAST0DbDescAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1048. {
  1049.    DataVal av;
  1050.    AsnTypePtr atp;
  1051.    Boolean isError = FALSE;
  1052.    AsnReadFunc func;
  1053.    BLAST0DbDescPtr ptr;
  1054.  
  1055.    if (! loaded)
  1056.    {
  1057.       if (! objblst2AsnLoad()) {
  1058.          return NULL;
  1059.       }
  1060.    }
  1061.  
  1062.    if (aip == NULL) {
  1063.       return NULL;
  1064.    }
  1065.  
  1066.    if (orig == NULL) {         /* BLAST0DbDesc ::= (self contained) */
  1067.       atp = AsnReadId(aip, amp, BLAST0_DB_DESC);
  1068.    } else {
  1069.       atp = AsnLinkType(orig, BLAST0_DB_DESC);
  1070.    }
  1071.    /* link in local tree */
  1072.    if (atp == NULL) {
  1073.       return NULL;
  1074.    }
  1075.  
  1076.    ptr = BLAST0DbDescNew();
  1077.    if (ptr == NULL) {
  1078.       goto erret;
  1079.    }
  1080.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  1081.       goto erret;
  1082.    }
  1083.  
  1084.    atp = AsnReadId(aip,amp, atp);
  1085.    func = NULL;
  1086.  
  1087.    if (atp == BLAST0_DB_DESC_name) {
  1088.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1089.          goto erret;
  1090.       }
  1091.       ptr -> name = av.ptrvalue;
  1092.       atp = AsnReadId(aip,amp, atp);
  1093.    }
  1094.    if (atp == BLAST0_DB_DESC_type) {
  1095.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1096.          goto erret;
  1097.       }
  1098.       ptr -> type = av.intvalue;
  1099.       atp = AsnReadId(aip,amp, atp);
  1100.    }
  1101.    if (atp == BLAST0_DB_DESC_def) {
  1102.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1103.          goto erret;
  1104.       }
  1105.       ptr -> def = av.ptrvalue;
  1106.       atp = AsnReadId(aip,amp, atp);
  1107.    }
  1108.    if (atp == BLAST0_DB_DESC_rel_date) {
  1109.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1110.          goto erret;
  1111.       }
  1112.       ptr -> rel_date = av.ptrvalue;
  1113.       atp = AsnReadId(aip,amp, atp);
  1114.    }
  1115.    if (atp == BLAST0_DB_DESC_bld_date) {
  1116.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1117.          goto erret;
  1118.       }
  1119.       ptr -> bld_date = av.ptrvalue;
  1120.       atp = AsnReadId(aip,amp, atp);
  1121.    }
  1122.    if (atp == BLAST0_DB_DESC_count) {
  1123.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1124.          goto erret;
  1125.       }
  1126.       ptr -> count = av.intvalue;
  1127.       ptr -> OBbits__ |= 1<<0;
  1128.       atp = AsnReadId(aip,amp, atp);
  1129.    }
  1130.    if (atp == BLAST0_DB_DESC_totlen) {
  1131.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1132.          goto erret;
  1133.       }
  1134.       ptr -> totlen = av.intvalue;
  1135.       ptr -> OBbits__ |= 1<<1;
  1136.       atp = AsnReadId(aip,amp, atp);
  1137.    }
  1138.    if (atp == BLAST0_DB_DESC_maxlen) {
  1139.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1140.          goto erret;
  1141.       }
  1142.       ptr -> maxlen = av.intvalue;
  1143.       ptr -> OBbits__ |= 1<<2;
  1144.       atp = AsnReadId(aip,amp, atp);
  1145.    }
  1146.  
  1147.    if (AsnReadVal(aip, atp, &av) <= 0) {
  1148.       goto erret;
  1149.    }
  1150.    /* end struct */
  1151.  
  1152. ret:
  1153.    AsnUnlinkType(orig);       /* unlink local tree */
  1154.    return ptr;
  1155.  
  1156. erret:
  1157.    aip -> io_failure = TRUE;
  1158.    ptr = BLAST0DbDescFree(ptr);
  1159.    goto ret;
  1160. }
  1161.  
  1162.  
  1163.  
  1164. /**************************************************
  1165. *
  1166. *    BLAST0DbDescAsnWrite()
  1167. *
  1168. **************************************************/
  1169. Boolean LIBCALL 
  1170. BLAST0DbDescAsnWrite(BLAST0DbDescPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  1171. {
  1172.    DataVal av;
  1173.    AsnTypePtr atp;
  1174.    Boolean retval = FALSE;
  1175.  
  1176.    if (! loaded)
  1177.    {
  1178.       if (! objblst2AsnLoad()) {
  1179.          return FALSE;
  1180.       }
  1181.    }
  1182.  
  1183.    if (aip == NULL) {
  1184.       return FALSE;
  1185.    }
  1186.  
  1187.    atp = AsnLinkType(orig, BLAST0_DB_DESC);   /* link local tree */
  1188.    if (atp == NULL) {
  1189.       return FALSE;
  1190.    }
  1191.  
  1192.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  1193.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  1194.       goto erret;
  1195.    }
  1196.  
  1197.    if (ptr -> name != NULL) {
  1198.       av.ptrvalue = ptr -> name;
  1199.       retval = AsnWrite(aip, BLAST0_DB_DESC_name,  &av);
  1200.    }
  1201.    av.intvalue = ptr -> type;
  1202.    retval = AsnWrite(aip, BLAST0_DB_DESC_type,  &av);
  1203.    if (ptr -> def != NULL) {
  1204.       av.ptrvalue = ptr -> def;
  1205.       retval = AsnWrite(aip, BLAST0_DB_DESC_def,  &av);
  1206.    }
  1207.    if (ptr -> rel_date != NULL) {
  1208.       av.ptrvalue = ptr -> rel_date;
  1209.       retval = AsnWrite(aip, BLAST0_DB_DESC_rel_date,  &av);
  1210.    }
  1211.    if (ptr -> bld_date != NULL) {
  1212.       av.ptrvalue = ptr -> bld_date;
  1213.       retval = AsnWrite(aip, BLAST0_DB_DESC_bld_date,  &av);
  1214.    }
  1215.    if (ptr -> count || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> count;
  1216.       retval = AsnWrite(aip, BLAST0_DB_DESC_count,  &av);
  1217.    }
  1218.    if (ptr -> totlen || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> totlen;
  1219.       retval = AsnWrite(aip, BLAST0_DB_DESC_totlen,  &av);
  1220.    }
  1221.    if (ptr -> maxlen || (ptr -> OBbits__ & (1<<2) )){   av.intvalue = ptr -> maxlen;
  1222.       retval = AsnWrite(aip, BLAST0_DB_DESC_maxlen,  &av);
  1223.    }
  1224.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  1225.       goto erret;
  1226.    }
  1227.    retval = TRUE;
  1228.  
  1229. erret:
  1230.    AsnUnlinkType(orig);       /* unlink local tree */
  1231.    return retval;
  1232. }
  1233.  
  1234.  
  1235.  
  1236. /**************************************************
  1237. *
  1238. *    BLAST0ResultNew()
  1239. *
  1240. **************************************************/
  1241.  
  1242. BLAST0ResultPtr LIBCALL
  1243. BLAST0ResultNew(void)
  1244. {
  1245.    BLAST0ResultPtr ptr = MemNew((size_t) sizeof(BLAST0Result));
  1246.  
  1247.    return ptr;
  1248.  
  1249. }
  1250.  
  1251.  
  1252. /**************************************************
  1253. *
  1254. *    BLAST0ResultFree()
  1255. *
  1256. **************************************************/
  1257.  
  1258. BLAST0ResultPtr LIBCALL
  1259. BLAST0ResultFree(BLAST0ResultPtr ptr)
  1260. {
  1261.  
  1262.    if(ptr == NULL) {
  1263.       return NULL;
  1264.    }
  1265.    BLAST0HistogramFree(ptr -> hist);
  1266.    AsnGenericUserSeqOfFree(ptr -> hitlists, (AsnOptFreeFunc) BLAST0HitListFree);
  1267.    return MemFree(ptr);
  1268. }
  1269.  
  1270.  
  1271. /**************************************************
  1272. *
  1273. *    BLAST0ResultAsnRead()
  1274. *
  1275. **************************************************/
  1276.  
  1277. BLAST0ResultPtr LIBCALL
  1278. BLAST0ResultAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1279. {
  1280.    DataVal av;
  1281.    AsnTypePtr atp;
  1282.    Boolean isError = FALSE;
  1283.    AsnReadFunc func;
  1284.    BLAST0ResultPtr ptr;
  1285.  
  1286.    if (! loaded)
  1287.    {
  1288.       if (! objblst2AsnLoad()) {
  1289.          return NULL;
  1290.       }
  1291.    }
  1292.  
  1293.    if (aip == NULL) {
  1294.       return NULL;
  1295.    }
  1296.  
  1297.    if (orig == NULL) {         /* BLAST0Result ::= (self contained) */
  1298.       atp = AsnReadId(aip, amp, BLAST0_RESULT);
  1299.    } else {
  1300.       atp = AsnLinkType(orig, BLAST0_RESULT);
  1301.    }
  1302.    /* link in local tree */
  1303.    if (atp == NULL) {
  1304.       return NULL;
  1305.    }
  1306.  
  1307.    ptr = BLAST0ResultNew();
  1308.    if (ptr == NULL) {
  1309.       goto erret;
  1310.    }
  1311.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  1312.       goto erret;
  1313.    }
  1314.  
  1315.    atp = AsnReadId(aip,amp, atp);
  1316.    func = NULL;
  1317.  
  1318.    if (atp == BLAST0_RESULT_hist) {
  1319.       ptr -> hist = BLAST0HistogramAsnRead(aip, atp);
  1320.       if (aip -> io_failure) {
  1321.          goto erret;
  1322.       }
  1323.       atp = AsnReadId(aip,amp, atp);
  1324.    }
  1325.    if (atp == BLAST0_RESULT_count) {
  1326.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1327.          goto erret;
  1328.       }
  1329.       ptr -> count = av.intvalue;
  1330.       atp = AsnReadId(aip,amp, atp);
  1331.    }
  1332.    if (atp == BLAST0_RESULT_hitlists) {
  1333.       ptr -> hitlists = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0HitListAsnRead, (AsnOptFreeFunc) BLAST0HitListFree);
  1334.       if (isError && ptr -> hitlists == NULL) {
  1335.          goto erret;
  1336.       }
  1337.       atp = AsnReadId(aip,amp, atp);
  1338.    }
  1339.  
  1340.    if (AsnReadVal(aip, atp, &av) <= 0) {
  1341.       goto erret;
  1342.    }
  1343.    /* end struct */
  1344.  
  1345. ret:
  1346.    AsnUnlinkType(orig);       /* unlink local tree */
  1347.    return ptr;
  1348.  
  1349. erret:
  1350.    aip -> io_failure = TRUE;
  1351.    ptr = BLAST0ResultFree(ptr);
  1352.    goto ret;
  1353. }
  1354.  
  1355.  
  1356.  
  1357. /**************************************************
  1358. *
  1359. *    BLAST0ResultAsnWrite()
  1360. *
  1361. **************************************************/
  1362. Boolean LIBCALL 
  1363. BLAST0ResultAsnWrite(BLAST0ResultPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  1364. {
  1365.    DataVal av;
  1366.    AsnTypePtr atp;
  1367.    Boolean retval = FALSE;
  1368.  
  1369.    if (! loaded)
  1370.    {
  1371.       if (! objblst2AsnLoad()) {
  1372.          return FALSE;
  1373.       }
  1374.    }
  1375.  
  1376.    if (aip == NULL) {
  1377.       return FALSE;
  1378.    }
  1379.  
  1380.    atp = AsnLinkType(orig, BLAST0_RESULT);   /* link local tree */
  1381.    if (atp == NULL) {
  1382.       return FALSE;
  1383.    }
  1384.  
  1385.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  1386.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  1387.       goto erret;
  1388.    }
  1389.  
  1390.    if (ptr -> hist != NULL) {
  1391.       if ( ! BLAST0HistogramAsnWrite(ptr -> hist, aip, BLAST0_RESULT_hist)) {
  1392.          goto erret;
  1393.       }
  1394.    }
  1395.    av.intvalue = ptr -> count;
  1396.    retval = AsnWrite(aip, BLAST0_RESULT_count,  &av);
  1397.    AsnGenericUserSeqOfAsnWrite(ptr -> hitlists, (AsnWriteFunc) BLAST0HitListAsnWrite, aip, BLAST0_RESULT_hitlists, BLAST0_RESULT_hitlists_E);
  1398.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  1399.       goto erret;
  1400.    }
  1401.    retval = TRUE;
  1402.  
  1403. erret:
  1404.    AsnUnlinkType(orig);       /* unlink local tree */
  1405.    return retval;
  1406. }
  1407.  
  1408.  
  1409.  
  1410. /**************************************************
  1411. *
  1412. *    BLAST0MatrixNew()
  1413. *
  1414. **************************************************/
  1415.  
  1416. BLAST0MatrixPtr LIBCALL
  1417. BLAST0MatrixNew(void)
  1418. {
  1419.    BLAST0MatrixPtr ptr = MemNew((size_t) sizeof(BLAST0Matrix));
  1420.  
  1421.    return ptr;
  1422.  
  1423. }
  1424.  
  1425.  
  1426. /**************************************************
  1427. *
  1428. *    Scores_scaled_intsNew()
  1429. *
  1430. **************************************************/
  1431. static 
  1432. Scores_scaled_intsPtr LIBCALL
  1433. Scores_scaled_intsNew(void)
  1434. {
  1435.    Scores_scaled_intsPtr ptr = MemNew((size_t) sizeof(Scores_scaled_ints));
  1436.  
  1437.    return ptr;
  1438.  
  1439. }
  1440.  
  1441.  
  1442. /**************************************************
  1443. *
  1444. *    BLAST0MatrixFree()
  1445. *
  1446. **************************************************/
  1447.  
  1448. BLAST0MatrixPtr LIBCALL
  1449. BLAST0MatrixFree(BLAST0MatrixPtr ptr)
  1450. {
  1451.  
  1452.    if(ptr == NULL) {
  1453.       return NULL;
  1454.    }
  1455.    MemFree(ptr -> name);
  1456.    AsnGenericBaseSeqOfFree(ptr -> comments ,ASNCODE_PTRVAL_SLOT);
  1457.    Scores_scoresFree(ptr -> Scores_scores);
  1458.    return MemFree(ptr);
  1459. }
  1460.  
  1461.  
  1462. /**************************************************
  1463. *
  1464. *    Scores_scoresFree()
  1465. *
  1466. **************************************************/
  1467. static 
  1468. Scores_scoresPtr LIBCALL
  1469. Scores_scoresFree(ValNodePtr anp)
  1470. {
  1471.    Pointer pnt;
  1472.  
  1473.    if (anp == NULL) {
  1474.       return NULL;
  1475.    }
  1476.  
  1477.    pnt = anp->data.ptrvalue;
  1478.    switch (anp->choice)
  1479.    {
  1480.    default:
  1481.       break;
  1482.    case Scores_scores_Scores_ScaledInts:
  1483.       Scores_scaled_intsFree(anp -> data.ptrvalue);
  1484.       break;
  1485.    case Scores_scores_reals:
  1486.       AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_REALVAL_SLOT);
  1487.       break;
  1488.    }
  1489.    return MemFree(anp);
  1490. }
  1491.  
  1492.  
  1493. /**************************************************
  1494. *
  1495. *    Scores_scaled_intsFree()
  1496. *
  1497. **************************************************/
  1498. static 
  1499. Scores_scaled_intsPtr LIBCALL
  1500. Scores_scaled_intsFree(Scores_scaled_intsPtr ptr)
  1501. {
  1502.  
  1503.    if(ptr == NULL) {
  1504.       return NULL;
  1505.    }
  1506.    AsnGenericBaseSeqOfFree(ptr -> ints ,ASNCODE_INTVAL_SLOT);
  1507.    return MemFree(ptr);
  1508. }
  1509.  
  1510.  
  1511. /**************************************************
  1512. *
  1513. *    BLAST0MatrixAsnRead()
  1514. *
  1515. **************************************************/
  1516.  
  1517. BLAST0MatrixPtr LIBCALL
  1518. BLAST0MatrixAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1519. {
  1520.    DataVal av;
  1521.    AsnTypePtr atp;
  1522.    Boolean isError = FALSE;
  1523.    AsnReadFunc func;
  1524.    BLAST0MatrixPtr ptr;
  1525.  
  1526.    if (! loaded)
  1527.    {
  1528.       if (! objblst2AsnLoad()) {
  1529.          return NULL;
  1530.       }
  1531.    }
  1532.  
  1533.    if (aip == NULL) {
  1534.       return NULL;
  1535.    }
  1536.  
  1537.    if (orig == NULL) {         /* BLAST0Matrix ::= (self contained) */
  1538.       atp = AsnReadId(aip, amp, BLAST0_MATRIX);
  1539.    } else {
  1540.       atp = AsnLinkType(orig, BLAST0_MATRIX);
  1541.    }
  1542.    /* link in local tree */
  1543.    if (atp == NULL) {
  1544.       return NULL;
  1545.    }
  1546.  
  1547.    ptr = BLAST0MatrixNew();
  1548.    if (ptr == NULL) {
  1549.       goto erret;
  1550.    }
  1551.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  1552.       goto erret;
  1553.    }
  1554.  
  1555.    atp = AsnReadId(aip,amp, atp);
  1556.    func = NULL;
  1557.  
  1558.    if (atp == BLAST0_MATRIX_matid) {
  1559.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1560.          goto erret;
  1561.       }
  1562.       ptr -> matid = av.intvalue;
  1563.       atp = AsnReadId(aip,amp, atp);
  1564.    }
  1565.    if (atp == BLAST0_MATRIX_name) {
  1566.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1567.          goto erret;
  1568.       }
  1569.       ptr -> name = av.ptrvalue;
  1570.       atp = AsnReadId(aip,amp, atp);
  1571.    }
  1572.    if (atp == BLAST0_MATRIX_comments) {
  1573.       ptr -> comments = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  1574.       if (isError && ptr -> comments == NULL) {
  1575.          goto erret;
  1576.       }
  1577.       atp = AsnReadId(aip,amp, atp);
  1578.    }
  1579.    if (atp == BLAST0_MATRIX_qalpha) {
  1580.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1581.          goto erret;
  1582.       }
  1583.       ptr -> qalpha = av.intvalue;
  1584.       atp = AsnReadId(aip,amp, atp);
  1585.    }
  1586.    if (atp == BLAST0_MATRIX_salpha) {
  1587.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1588.          goto erret;
  1589.       }
  1590.       ptr -> salpha = av.intvalue;
  1591.       atp = AsnReadId(aip,amp, atp);
  1592.    }
  1593.    if (atp == BLAST0_MATRIX_scores) {
  1594.       ptr -> Scores_scores = Scores_scoresAsnRead(aip, atp);
  1595.       if (aip -> io_failure) {
  1596.          goto erret;
  1597.       }
  1598.       atp = AsnReadId(aip,amp, atp);
  1599.    }
  1600.  
  1601.    if (AsnReadVal(aip, atp, &av) <= 0) {
  1602.       goto erret;
  1603.    }
  1604.    /* end struct */
  1605.  
  1606. ret:
  1607.    AsnUnlinkType(orig);       /* unlink local tree */
  1608.    return ptr;
  1609.  
  1610. erret:
  1611.    aip -> io_failure = TRUE;
  1612.    ptr = BLAST0MatrixFree(ptr);
  1613.    goto ret;
  1614. }
  1615.  
  1616.  
  1617.  
  1618. /**************************************************
  1619. *
  1620. *    Scores_scoresAsnRead()
  1621. *
  1622. **************************************************/
  1623. static 
  1624. Scores_scoresPtr LIBCALL
  1625. Scores_scoresAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1626. {
  1627.    DataVal av;
  1628.    AsnTypePtr atp;
  1629.    ValNodePtr anp;
  1630.    Uint1 choice;
  1631.    Boolean isError = FALSE;
  1632.    Boolean nullIsError = FALSE;
  1633.    AsnReadFunc func;
  1634.  
  1635.    if (! loaded)
  1636.    {
  1637.       if (! objblst2AsnLoad()) {
  1638.          return NULL;
  1639.       }
  1640.    }
  1641.  
  1642.    if (aip == NULL) {
  1643.       return NULL;
  1644.    }
  1645.  
  1646.    if (orig == NULL) {         /* Scores_scores ::= (self contained) */
  1647.       atp = AsnReadId(aip, amp, BLAST0_MATRIX_scores);
  1648.    } else {
  1649.       atp = AsnLinkType(orig, BLAST0_MATRIX_scores);    /* link in local tree */
  1650.    }
  1651.    if (atp == NULL) {
  1652.       return NULL;
  1653.    }
  1654.  
  1655.    anp = ValNodeNew(NULL);
  1656.    if (anp == NULL) {
  1657.       goto erret;
  1658.    }
  1659.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  1660.       goto erret;
  1661.    }
  1662.  
  1663.    func = NULL;
  1664.  
  1665.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  1666.    if (atp == NULL) {
  1667.       goto erret;
  1668.    }
  1669.    if (atp == MATRIX_scores_scaled_ints) {
  1670.       choice = Scores_scores_Scores_ScaledInts;
  1671.       func = (AsnReadFunc) Scores_scaled_intsAsnRead;
  1672.    }
  1673.    else if (atp == BLAST0_MATRIX_scores_reals) {
  1674.       choice = Scores_scores_reals;
  1675.       anp -> data.ptrvalue = 
  1676.       AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_REALVAL_SLOT, &isError);
  1677.       if (isError && anp -> data.ptrvalue == NULL) {
  1678.          goto erret;
  1679.       }
  1680.    }
  1681.    anp->choice = choice;
  1682.    if (func != NULL)
  1683.    {
  1684.       anp->data.ptrvalue = (* func)(aip, atp);
  1685.       if (aip -> io_failure) goto erret;
  1686.  
  1687.       if (nullIsError && anp->data.ptrvalue == NULL) {
  1688.          goto erret;
  1689.       }
  1690.    }
  1691.  
  1692. ret:
  1693.    AsnUnlinkType(orig);       /* unlink local tree */
  1694.    return anp;
  1695.  
  1696. erret:
  1697.    anp = MemFree(anp);
  1698.    aip -> io_failure = TRUE;
  1699.    goto ret;
  1700. }
  1701.  
  1702.  
  1703. /**************************************************
  1704. *
  1705. *    Scores_scaled_intsAsnRead()
  1706. *
  1707. **************************************************/
  1708. static 
  1709. Scores_scaled_intsPtr LIBCALL
  1710. Scores_scaled_intsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1711. {
  1712.    DataVal av;
  1713.    AsnTypePtr atp;
  1714.    Boolean isError = FALSE;
  1715.    AsnReadFunc func;
  1716.    Scores_scaled_intsPtr ptr;
  1717.  
  1718.    if (! loaded)
  1719.    {
  1720.       if (! objblst2AsnLoad()) {
  1721.          return NULL;
  1722.       }
  1723.    }
  1724.  
  1725.    if (aip == NULL) {
  1726.       return NULL;
  1727.    }
  1728.  
  1729.    if (orig == NULL) {         /* Scores_scaled_ints ::= (self contained) */
  1730.       atp = AsnReadId(aip, amp, MATRIX_scores_scaled_ints);
  1731.    } else {
  1732.       atp = AsnLinkType(orig, MATRIX_scores_scaled_ints);
  1733.    }
  1734.    /* link in local tree */
  1735.    if (atp == NULL) {
  1736.       return NULL;
  1737.    }
  1738.  
  1739.    ptr = Scores_scaled_intsNew();
  1740.    if (ptr == NULL) {
  1741.       goto erret;
  1742.    }
  1743.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  1744.       goto erret;
  1745.    }
  1746.  
  1747.    atp = AsnReadId(aip,amp, atp);
  1748.    func = NULL;
  1749.  
  1750.    if (atp == scores_scaled_ints_scale) {
  1751.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  1752.          goto erret;
  1753.       }
  1754.       ptr -> scale = av.realvalue;
  1755.       atp = AsnReadId(aip,amp, atp);
  1756.    }
  1757.    if (atp == MATRIX_scores_scaled_ints_ints) {
  1758.       ptr -> ints = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
  1759.       if (isError && ptr -> ints == NULL) {
  1760.          goto erret;
  1761.       }
  1762.       atp = AsnReadId(aip,amp, atp);
  1763.    }
  1764.  
  1765.    if (AsnReadVal(aip, atp, &av) <= 0) {
  1766.       goto erret;
  1767.    }
  1768.    /* end struct */
  1769.  
  1770. ret:
  1771.    AsnUnlinkType(orig);       /* unlink local tree */
  1772.    return ptr;
  1773.  
  1774. erret:
  1775.    aip -> io_failure = TRUE;
  1776.    ptr = Scores_scaled_intsFree(ptr);
  1777.    goto ret;
  1778. }
  1779.  
  1780.  
  1781.  
  1782. /**************************************************
  1783. *
  1784. *    BLAST0MatrixAsnWrite()
  1785. *
  1786. **************************************************/
  1787. Boolean LIBCALL 
  1788. BLAST0MatrixAsnWrite(BLAST0MatrixPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  1789. {
  1790.    DataVal av;
  1791.    AsnTypePtr atp;
  1792.    Boolean retval = FALSE;
  1793.  
  1794.    if (! loaded)
  1795.    {
  1796.       if (! objblst2AsnLoad()) {
  1797.          return FALSE;
  1798.       }
  1799.    }
  1800.  
  1801.    if (aip == NULL) {
  1802.       return FALSE;
  1803.    }
  1804.  
  1805.    atp = AsnLinkType(orig, BLAST0_MATRIX);   /* link local tree */
  1806.    if (atp == NULL) {
  1807.       return FALSE;
  1808.    }
  1809.  
  1810.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  1811.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  1812.       goto erret;
  1813.    }
  1814.  
  1815.    av.intvalue = ptr -> matid;
  1816.    retval = AsnWrite(aip, BLAST0_MATRIX_matid,  &av);
  1817.    if (ptr -> name != NULL) {
  1818.       av.ptrvalue = ptr -> name;
  1819.       retval = AsnWrite(aip, BLAST0_MATRIX_name,  &av);
  1820.    }
  1821.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> comments ,ASNCODE_PTRVAL_SLOT, aip, BLAST0_MATRIX_comments, BLAST0_MATRIX_comments_E);
  1822.    av.intvalue = ptr -> qalpha;
  1823.    retval = AsnWrite(aip, BLAST0_MATRIX_qalpha,  &av);
  1824.    av.intvalue = ptr -> salpha;
  1825.    retval = AsnWrite(aip, BLAST0_MATRIX_salpha,  &av);
  1826.    if (ptr -> Scores_scores != NULL) {
  1827.       if ( ! Scores_scoresAsnWrite(ptr -> Scores_scores, aip, BLAST0_MATRIX_scores)) {
  1828.          goto erret;
  1829.       }
  1830.    }
  1831.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  1832.       goto erret;
  1833.    }
  1834.    retval = TRUE;
  1835.  
  1836. erret:
  1837.    AsnUnlinkType(orig);       /* unlink local tree */
  1838.    return retval;
  1839. }
  1840.  
  1841.  
  1842.  
  1843. /**************************************************
  1844. *
  1845. *    Scores_scoresAsnWrite()
  1846. *
  1847. **************************************************/
  1848. static Boolean LIBCALL 
  1849. Scores_scoresAsnWrite(Scores_scoresPtr anp, AsnIoPtr aip, AsnTypePtr orig)
  1850.  
  1851. {
  1852.    DataVal av;
  1853.    AsnTypePtr atp, writetype = NULL;
  1854.    Pointer pnt;
  1855.    AsnWriteFunc func = NULL;
  1856.    Boolean retval = FALSE;
  1857.  
  1858.    if (! loaded)
  1859.    {
  1860.       if (! objblst2AsnLoad())
  1861.       return FALSE;
  1862.    }
  1863.  
  1864.    if (aip == NULL)
  1865.    return FALSE;
  1866.  
  1867.    atp = AsnLinkType(orig, BLAST0_MATRIX_scores);   /* link local tree */
  1868.    if (atp == NULL) {
  1869.       return FALSE;
  1870.    }
  1871.  
  1872.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  1873.  
  1874.    av.ptrvalue = (Pointer)anp;
  1875.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  1876.       goto erret;
  1877.    }
  1878.  
  1879.    pnt = anp->data.ptrvalue;
  1880.    switch (anp->choice)
  1881.    {
  1882.    case Scores_scores_Scores_ScaledInts:
  1883.       writetype = MATRIX_scores_scaled_ints;
  1884.       func = (AsnWriteFunc) Scores_scaled_intsAsnWrite;
  1885.       break;
  1886.    case Scores_scores_reals:
  1887.       retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_REALVAL_SLOT, aip, BLAST0_MATRIX_scores_reals, BLAST0_MATRIX_scores_reals_E);            break;
  1888.    }
  1889.    if (writetype != NULL) {
  1890.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  1891.    }
  1892.    if (!retval) {
  1893.       goto erret;
  1894.    }
  1895.    retval = TRUE;
  1896.  
  1897. erret:
  1898.    AsnUnlinkType(orig);       /* unlink local tree */
  1899.    return retval;
  1900. }
  1901.  
  1902.  
  1903. /**************************************************
  1904. *
  1905. *    Scores_scaled_intsAsnWrite()
  1906. *
  1907. **************************************************/
  1908. static Boolean LIBCALL 
  1909. Scores_scaled_intsAsnWrite(Scores_scaled_intsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  1910. {
  1911.    DataVal av;
  1912.    AsnTypePtr atp;
  1913.    Boolean retval = FALSE;
  1914.  
  1915.    if (! loaded)
  1916.    {
  1917.       if (! objblst2AsnLoad()) {
  1918.          return FALSE;
  1919.       }
  1920.    }
  1921.  
  1922.    if (aip == NULL) {
  1923.       return FALSE;
  1924.    }
  1925.  
  1926.    atp = AsnLinkType(orig, MATRIX_scores_scaled_ints);   /* link local tree */
  1927.    if (atp == NULL) {
  1928.       return FALSE;
  1929.    }
  1930.  
  1931.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  1932.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  1933.       goto erret;
  1934.    }
  1935.  
  1936.    av.realvalue = ptr -> scale;
  1937.    retval = AsnWrite(aip, scores_scaled_ints_scale,  &av);
  1938.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> ints ,ASNCODE_INTVAL_SLOT, aip, MATRIX_scores_scaled_ints_ints, scores_scaled_ints_ints_E);
  1939.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  1940.       goto erret;
  1941.    }
  1942.    retval = TRUE;
  1943.  
  1944. erret:
  1945.    AsnUnlinkType(orig);       /* unlink local tree */
  1946.    return retval;
  1947. }
  1948.  
  1949.  
  1950.  
  1951. /**************************************************
  1952. *
  1953. *    BLAST0StatusNew()
  1954. *
  1955. **************************************************/
  1956.  
  1957. BLAST0StatusPtr LIBCALL
  1958. BLAST0StatusNew(void)
  1959. {
  1960.    BLAST0StatusPtr ptr = MemNew((size_t) sizeof(BLAST0Status));
  1961.  
  1962.    return ptr;
  1963.  
  1964. }
  1965.  
  1966.  
  1967. /**************************************************
  1968. *
  1969. *    BLAST0StatusFree()
  1970. *
  1971. **************************************************/
  1972.  
  1973. BLAST0StatusPtr LIBCALL
  1974. BLAST0StatusFree(BLAST0StatusPtr ptr)
  1975. {
  1976.  
  1977.    if(ptr == NULL) {
  1978.       return NULL;
  1979.    }
  1980.    MemFree(ptr -> reason);
  1981.    return MemFree(ptr);
  1982. }
  1983.  
  1984.  
  1985. /**************************************************
  1986. *
  1987. *    BLAST0StatusAsnRead()
  1988. *
  1989. **************************************************/
  1990.  
  1991. BLAST0StatusPtr LIBCALL
  1992. BLAST0StatusAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  1993. {
  1994.    DataVal av;
  1995.    AsnTypePtr atp;
  1996.    Boolean isError = FALSE;
  1997.    AsnReadFunc func;
  1998.    BLAST0StatusPtr ptr;
  1999.  
  2000.    if (! loaded)
  2001.    {
  2002.       if (! objblst2AsnLoad()) {
  2003.          return NULL;
  2004.       }
  2005.    }
  2006.  
  2007.    if (aip == NULL) {
  2008.       return NULL;
  2009.    }
  2010.  
  2011.    if (orig == NULL) {         /* BLAST0Status ::= (self contained) */
  2012.       atp = AsnReadId(aip, amp, BLAST0_STATUS);
  2013.    } else {
  2014.       atp = AsnLinkType(orig, BLAST0_STATUS);
  2015.    }
  2016.    /* link in local tree */
  2017.    if (atp == NULL) {
  2018.       return NULL;
  2019.    }
  2020.  
  2021.    ptr = BLAST0StatusNew();
  2022.    if (ptr == NULL) {
  2023.       goto erret;
  2024.    }
  2025.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  2026.       goto erret;
  2027.    }
  2028.  
  2029.    atp = AsnReadId(aip,amp, atp);
  2030.    func = NULL;
  2031.  
  2032.    if (atp == BLAST0_STATUS_code) {
  2033.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2034.          goto erret;
  2035.       }
  2036.       ptr -> code = av.intvalue;
  2037.       atp = AsnReadId(aip,amp, atp);
  2038.    }
  2039.    if (atp == BLAST0_STATUS_reason) {
  2040.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2041.          goto erret;
  2042.       }
  2043.       ptr -> reason = av.ptrvalue;
  2044.       atp = AsnReadId(aip,amp, atp);
  2045.    }
  2046.  
  2047.    if (AsnReadVal(aip, atp, &av) <= 0) {
  2048.       goto erret;
  2049.    }
  2050.    /* end struct */
  2051.  
  2052. ret:
  2053.    AsnUnlinkType(orig);       /* unlink local tree */
  2054.    return ptr;
  2055.  
  2056. erret:
  2057.    aip -> io_failure = TRUE;
  2058.    ptr = BLAST0StatusFree(ptr);
  2059.    goto ret;
  2060. }
  2061.  
  2062.  
  2063.  
  2064. /**************************************************
  2065. *
  2066. *    BLAST0StatusAsnWrite()
  2067. *
  2068. **************************************************/
  2069. Boolean LIBCALL 
  2070. BLAST0StatusAsnWrite(BLAST0StatusPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  2071. {
  2072.    DataVal av;
  2073.    AsnTypePtr atp;
  2074.    Boolean retval = FALSE;
  2075.  
  2076.    if (! loaded)
  2077.    {
  2078.       if (! objblst2AsnLoad()) {
  2079.          return FALSE;
  2080.       }
  2081.    }
  2082.  
  2083.    if (aip == NULL) {
  2084.       return FALSE;
  2085.    }
  2086.  
  2087.    atp = AsnLinkType(orig, BLAST0_STATUS);   /* link local tree */
  2088.    if (atp == NULL) {
  2089.       return FALSE;
  2090.    }
  2091.  
  2092.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  2093.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  2094.       goto erret;
  2095.    }
  2096.  
  2097.    av.intvalue = ptr -> code;
  2098.    retval = AsnWrite(aip, BLAST0_STATUS_code,  &av);
  2099.    if (ptr -> reason != NULL) {
  2100.       av.ptrvalue = ptr -> reason;
  2101.       retval = AsnWrite(aip, BLAST0_STATUS_reason,  &av);
  2102.    }
  2103.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  2104.       goto erret;
  2105.    }
  2106.    retval = TRUE;
  2107.  
  2108. erret:
  2109.    AsnUnlinkType(orig);       /* unlink local tree */
  2110.    return retval;
  2111. }
  2112.  
  2113.  
  2114.  
  2115. /**************************************************
  2116. *
  2117. *    BLAST0OutblkFree()
  2118. *
  2119. **************************************************/
  2120.  
  2121. BLAST0OutblkPtr LIBCALL
  2122. BLAST0OutblkFree(ValNodePtr anp)
  2123. {
  2124.  
  2125.    if (anp == NULL) {
  2126.       return NULL;
  2127.    }
  2128.  
  2129.    AsnGenericChoiceSeqOfFree(anp, (AsnOptFreeFunc) BLAST0Outblk_elementFree);    
  2130.    return NULL;
  2131. }
  2132.  
  2133.  
  2134. /**************************************************
  2135. *
  2136. *    BLAST0OutblkAsnRead()
  2137. *
  2138. **************************************************/
  2139.  
  2140. BLAST0OutblkPtr LIBCALL
  2141. BLAST0OutblkAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  2142. {
  2143.  
  2144.  
  2145.    DataVal av;
  2146.    AsnTypePtr atp;
  2147.    ValNodePtr anp;
  2148.    Uint1 choice;
  2149.    Boolean isError = FALSE;
  2150.    AsnReadFunc func;
  2151.  
  2152.    if (! loaded)
  2153.    {
  2154.       if (! objblst2AsnLoad()) {
  2155.          return NULL;
  2156.       }
  2157.    }
  2158.  
  2159.    if (aip == NULL) {
  2160.       return NULL;
  2161.    }
  2162.  
  2163.    if (orig == NULL) {         /* BLAST0Outblk_element ::= (self contained) */
  2164.       atp = AsnReadId(aip, amp, BLAST0_OUTBLK);
  2165.    } else {
  2166.       atp = AsnLinkType(orig, BLAST0_OUTBLK);    /* link in local tree */
  2167.    }
  2168.    if (atp == NULL) {
  2169.       return NULL;
  2170.    }
  2171.  
  2172.    anp =
  2173.    AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError,
  2174.    (AsnReadFunc) BLAST0Outblk_elementAsnRead, (AsnOptFreeFunc) BLAST0Outblk_elementFree);
  2175.    if (isError) 
  2176.    goto erret;
  2177.  
  2178.  
  2179. ret:
  2180.    AsnUnlinkType(orig);       /* unlink local tree */
  2181.    return anp;
  2182.  
  2183. erret:
  2184.    aip -> io_failure = TRUE;
  2185.    goto ret;
  2186. }
  2187.  
  2188.  
  2189. /**************************************************
  2190. *
  2191. *    BLAST0OutblkAsnWrite()
  2192. *
  2193. **************************************************/
  2194. Boolean LIBCALL 
  2195. BLAST0OutblkAsnWrite(ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig)
  2196.  
  2197. {
  2198.    DataVal av;
  2199.    AsnTypePtr atp, writetype = NULL;
  2200.    Pointer pnt;
  2201.    AsnWriteFunc func = NULL;
  2202.    Boolean retval = FALSE;
  2203.  
  2204.    if (! loaded)
  2205.    {
  2206.       if (! objblst2AsnLoad())
  2207.       return FALSE;
  2208.    }
  2209.  
  2210.    if (aip == NULL)
  2211.    return FALSE;
  2212.  
  2213.    atp = AsnLinkType(orig, BLAST0_OUTBLK);   /* link local tree */
  2214.    if (atp == NULL) {
  2215.       return FALSE;
  2216.    }
  2217.  
  2218.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  2219.  
  2220.    av.ptrvalue = (Pointer)anp;
  2221.    retval = AsnGenericChoiceSeqOfAsnWrite(anp, 
  2222.    (AsnWriteFunc) BLAST0Outblk_elementAsnWrite, aip, atp, BLAST0_OUTBLK_E);
  2223. erret:
  2224.    AsnUnlinkType(orig);       /* unlink local tree */
  2225.    return retval;
  2226. }
  2227.  
  2228.  
  2229. /**************************************************
  2230. *
  2231. *    BLAST0Outblk_elementAsnWrite()
  2232. *
  2233. **************************************************/
  2234. Boolean LIBCALL 
  2235. BLAST0Outblk_elementAsnWrite(BLAST0Outblk_elementPtr anp, AsnIoPtr aip, AsnTypePtr orig)
  2236.  
  2237. {
  2238.    DataVal av;
  2239.    AsnTypePtr atp, writetype = NULL;
  2240.    Pointer pnt;
  2241.    AsnWriteFunc func = NULL;
  2242.    Boolean retval = FALSE;
  2243.  
  2244.    if (! loaded)
  2245.    {
  2246.       if (! objblst2AsnLoad())
  2247.       return FALSE;
  2248.    }
  2249.  
  2250.    if (aip == NULL)
  2251.    return FALSE;
  2252.  
  2253.    atp = AsnLinkType(orig, BLAST0_OUTBLK_E);   /* link local tree */
  2254.    if (atp == NULL) {
  2255.       return FALSE;
  2256.    }
  2257.  
  2258.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  2259.  
  2260.    av.ptrvalue = (Pointer)anp;
  2261.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  2262.       goto erret;
  2263.    }
  2264.  
  2265.    pnt = anp->data.ptrvalue;
  2266.    switch (anp->choice)
  2267.    {
  2268.    case BLAST0Outblk_preface:
  2269.       writetype = BLAST0_OUTBLK_E_preface;
  2270.       func = (AsnWriteFunc) BLAST0PrefaceAsnWrite;
  2271.       break;
  2272.    case BLAST0Outblk_query:
  2273.       writetype = BLAST0_OUTBLK_E_query;
  2274.       func = (AsnWriteFunc) BLAST0SequenceAsnWrite;
  2275.       break;
  2276.    case BLAST0Outblk_dbdesc:
  2277.       writetype = BLAST0_OUTBLK_E_dbdesc;
  2278.       func = (AsnWriteFunc) BLAST0DbDescAsnWrite;
  2279.       break;
  2280.    case BLAST0Outblk_matrix:
  2281.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0MatrixAsnWrite, aip, BLAST0_OUTBLK_E_matrix, BLAST0_OUTBLK_E_matrix_E);
  2282.       break;
  2283.    case BLAST0Outblk_kablk:
  2284.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0KABlkAsnWrite, aip, BLAST0_OUTBLK_E_kablk, BLAST0_OUTBLK_E_kablk_E);
  2285.       break;
  2286.    case BLAST0Outblk_job_start:
  2287.       writetype = BLAST0_OUTBLK_E_job_start;
  2288.       func = (AsnWriteFunc) BLAST0JobDescAsnWrite;
  2289.       break;
  2290.    case BLAST0Outblk_job_progress:
  2291.       writetype = BLAST0_OUTBLK_E_job_progress;
  2292.       func = (AsnWriteFunc) BLAST0JobProgressAsnWrite;
  2293.       break;
  2294.    case BLAST0Outblk_job_done:
  2295.       writetype = BLAST0_OUTBLK_E_job_done;
  2296.       func = (AsnWriteFunc) BLAST0JobProgressAsnWrite;
  2297.       break;
  2298.    case BLAST0Outblk_result:
  2299.       writetype = BLAST0_OUTBLK_E_result;
  2300.       func = (AsnWriteFunc) BLAST0ResultAsnWrite;
  2301.       break;
  2302.    case BLAST0Outblk_parms:
  2303.       retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, BLAST0_OUTBLK_E_parms, BLAST0_OUTBLK_E_parms_E);            break;
  2304.    case BLAST0Outblk_stats:
  2305.       retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, BLAST0_OUTBLK_E_stats, BLAST0_OUTBLK_E_stats_E);            break;
  2306.    case BLAST0Outblk_warning:
  2307.       writetype = BLAST0_OUTBLK_E_warning;
  2308.       func = (AsnWriteFunc) BLAST0StatusAsnWrite;
  2309.       break;
  2310.    case BLAST0Outblk_status:
  2311.       writetype = BLAST0_OUTBLK_E_status;
  2312.       func = (AsnWriteFunc) BLAST0StatusAsnWrite;
  2313.       break;
  2314.    }
  2315.    if (writetype != NULL) {
  2316.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  2317.    }
  2318.    if (!retval) {
  2319.       goto erret;
  2320.    }
  2321.    retval = TRUE;
  2322.  
  2323. erret:
  2324.    AsnUnlinkType(orig);       /* unlink local tree */
  2325.    return retval;
  2326. }
  2327.  
  2328.  
  2329. /**************************************************
  2330. *
  2331. *    BLAST0Outblk_elementAsnRead()
  2332. *
  2333. **************************************************/
  2334.  
  2335. BLAST0Outblk_elementPtr LIBCALL
  2336. BLAST0Outblk_elementAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  2337. {
  2338.    DataVal av;
  2339.    AsnTypePtr atp;
  2340.    ValNodePtr anp;
  2341.    Uint1 choice;
  2342.    Boolean isError = FALSE;
  2343.    Boolean nullIsError = FALSE;
  2344.    AsnReadFunc func;
  2345.  
  2346.    if (! loaded)
  2347.    {
  2348.       if (! objblst2AsnLoad()) {
  2349.          return NULL;
  2350.       }
  2351.    }
  2352.  
  2353.    if (aip == NULL) {
  2354.       return NULL;
  2355.    }
  2356.  
  2357.    if (orig == NULL) {         /* BLAST0Outblk_element ::= (self contained) */
  2358.       atp = AsnReadId(aip, amp, BLAST0_OUTBLK_E);
  2359.    } else {
  2360.       atp = AsnLinkType(orig, BLAST0_OUTBLK_E);    /* link in local tree */
  2361.    }
  2362.    if (atp == NULL) {
  2363.       return NULL;
  2364.    }
  2365.  
  2366.    anp = ValNodeNew(NULL);
  2367.    if (anp == NULL) {
  2368.       goto erret;
  2369.    }
  2370.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  2371.       goto erret;
  2372.    }
  2373.  
  2374.    func = NULL;
  2375.  
  2376.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  2377.    if (atp == NULL) {
  2378.       goto erret;
  2379.    }
  2380.    if (atp == BLAST0_OUTBLK_E_preface) {
  2381.       choice = BLAST0Outblk_preface;
  2382.       func = (AsnReadFunc) BLAST0PrefaceAsnRead;
  2383.    }
  2384.    else if (atp == BLAST0_OUTBLK_E_query) {
  2385.       choice = BLAST0Outblk_query;
  2386.       func = (AsnReadFunc) BLAST0SequenceAsnRead;
  2387.    }
  2388.    else if (atp == BLAST0_OUTBLK_E_dbdesc) {
  2389.       choice = BLAST0Outblk_dbdesc;
  2390.       func = (AsnReadFunc) BLAST0DbDescAsnRead;
  2391.    }
  2392.    else if (atp == BLAST0_OUTBLK_E_matrix) {
  2393.       choice = BLAST0Outblk_matrix;
  2394.       anp -> data.ptrvalue =
  2395.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0MatrixAsnRead,             (AsnOptFreeFunc) BLAST0MatrixFree);
  2396.       if (isError && anp -> data.ptrvalue == NULL) {
  2397.          goto erret;
  2398.       }
  2399.    }
  2400.    else if (atp == BLAST0_OUTBLK_E_kablk) {
  2401.       choice = BLAST0Outblk_kablk;
  2402.       anp -> data.ptrvalue =
  2403.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0KABlkAsnRead,             (AsnOptFreeFunc) BLAST0KABlkFree);
  2404.       if (isError && anp -> data.ptrvalue == NULL) {
  2405.          goto erret;
  2406.       }
  2407.    }
  2408.    else if (atp == BLAST0_OUTBLK_E_job_start) {
  2409.       choice = BLAST0Outblk_job_start;
  2410.       func = (AsnReadFunc) BLAST0JobDescAsnRead;
  2411.    }
  2412.    else if (atp == BLAST0_OUTBLK_E_job_progress) {
  2413.       choice = BLAST0Outblk_job_progress;
  2414.       func = (AsnReadFunc) BLAST0JobProgressAsnRead;
  2415.    }
  2416.    else if (atp == BLAST0_OUTBLK_E_job_done) {
  2417.       choice = BLAST0Outblk_job_done;
  2418.       func = (AsnReadFunc) BLAST0JobProgressAsnRead;
  2419.    }
  2420.    else if (atp == BLAST0_OUTBLK_E_result) {
  2421.       choice = BLAST0Outblk_result;
  2422.       func = (AsnReadFunc) BLAST0ResultAsnRead;
  2423.    }
  2424.    else if (atp == BLAST0_OUTBLK_E_parms) {
  2425.       choice = BLAST0Outblk_parms;
  2426.       anp -> data.ptrvalue = 
  2427.       AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  2428.       if (isError && anp -> data.ptrvalue == NULL) {
  2429.          goto erret;
  2430.       }
  2431.    }
  2432.    else if (atp == BLAST0_OUTBLK_E_stats) {
  2433.       choice = BLAST0Outblk_stats;
  2434.       anp -> data.ptrvalue = 
  2435.       AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  2436.       if (isError && anp -> data.ptrvalue == NULL) {
  2437.          goto erret;
  2438.       }
  2439.    }
  2440.    else if (atp == BLAST0_OUTBLK_E_warning) {
  2441.       choice = BLAST0Outblk_warning;
  2442.       func = (AsnReadFunc) BLAST0StatusAsnRead;
  2443.    }
  2444.    else if (atp == BLAST0_OUTBLK_E_status) {
  2445.       choice = BLAST0Outblk_status;
  2446.       func = (AsnReadFunc) BLAST0StatusAsnRead;
  2447.    }
  2448.    anp->choice = choice;
  2449.    if (func != NULL)
  2450.    {
  2451.       anp->data.ptrvalue = (* func)(aip, atp);
  2452.       if (aip -> io_failure) goto erret;
  2453.  
  2454.       if (nullIsError && anp->data.ptrvalue == NULL) {
  2455.          goto erret;
  2456.       }
  2457.    }
  2458.  
  2459. ret:
  2460.    AsnUnlinkType(orig);       /* unlink local tree */
  2461.    return anp;
  2462.  
  2463. erret:
  2464.    anp = MemFree(anp);
  2465.    aip -> io_failure = TRUE;
  2466.    goto ret;
  2467. }
  2468.  
  2469.  
  2470. /**************************************************
  2471. *
  2472. *    BLAST0Outblk_elementFree()
  2473. *
  2474. **************************************************/
  2475.  
  2476. BLAST0Outblk_elementPtr LIBCALL
  2477. BLAST0Outblk_elementFree(ValNodePtr anp)
  2478. {
  2479.    Pointer pnt;
  2480.  
  2481.    if (anp == NULL) {
  2482.       return NULL;
  2483.    }
  2484.  
  2485.    pnt = anp->data.ptrvalue;
  2486.    switch (anp->choice)
  2487.    {
  2488.    default:
  2489.       break;
  2490.    case BLAST0Outblk_preface:
  2491.       BLAST0PrefaceFree(anp -> data.ptrvalue);
  2492.       break;
  2493.    case BLAST0Outblk_query:
  2494.       BLAST0SequenceFree(anp -> data.ptrvalue);
  2495.       break;
  2496.    case BLAST0Outblk_dbdesc:
  2497.       BLAST0DbDescFree(anp -> data.ptrvalue);
  2498.       break;
  2499.    case BLAST0Outblk_matrix:
  2500.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0MatrixFree);
  2501.       break;
  2502.    case BLAST0Outblk_kablk:
  2503.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0KABlkFree);
  2504.       break;
  2505.    case BLAST0Outblk_job_start:
  2506.       BLAST0JobDescFree(anp -> data.ptrvalue);
  2507.       break;
  2508.    case BLAST0Outblk_job_progress:
  2509.       BLAST0JobProgressFree(anp -> data.ptrvalue);
  2510.       break;
  2511.    case BLAST0Outblk_job_done:
  2512.       BLAST0JobProgressFree(anp -> data.ptrvalue);
  2513.       break;
  2514.    case BLAST0Outblk_result:
  2515.       BLAST0ResultFree(anp -> data.ptrvalue);
  2516.       break;
  2517.    case BLAST0Outblk_parms:
  2518.       AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
  2519.       break;
  2520.    case BLAST0Outblk_stats:
  2521.       AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
  2522.       break;
  2523.    case BLAST0Outblk_warning:
  2524.       BLAST0StatusFree(anp -> data.ptrvalue);
  2525.       break;
  2526.    case BLAST0Outblk_status:
  2527.       BLAST0StatusFree(anp -> data.ptrvalue);
  2528.       break;
  2529.    }
  2530.    return MemFree(anp);
  2531. }
  2532.  
  2533.  
  2534. /**************************************************
  2535. *
  2536. *    BLAST0RequestFree()
  2537. *
  2538. **************************************************/
  2539.  
  2540. BLAST0RequestPtr LIBCALL
  2541. BLAST0RequestFree(ValNodePtr anp)
  2542. {
  2543.    Pointer pnt;
  2544.  
  2545.    if (anp == NULL) {
  2546.       return NULL;
  2547.    }
  2548.  
  2549.    pnt = anp->data.ptrvalue;
  2550.    switch (anp->choice)
  2551.    {
  2552.    default:
  2553.       break;
  2554.    case BLAST0Request_hello:
  2555.       MemFree(anp -> data.ptrvalue);
  2556.       break;
  2557.    case BLAST0Request_usage_info:
  2558.       MemFree(anp -> data.ptrvalue);
  2559.       break;
  2560.    case BLAST0Request_matrix_get:
  2561.       MemFree(anp -> data.ptrvalue);
  2562.       break;
  2563.    case BLAST0Request_search:
  2564.       BLAST0SearchFree(anp -> data.ptrvalue);
  2565.       break;
  2566.    }
  2567.    return MemFree(anp);
  2568. }
  2569.  
  2570.  
  2571. /**************************************************
  2572. *
  2573. *    BLAST0RequestAsnRead()
  2574. *
  2575. **************************************************/
  2576.  
  2577. BLAST0RequestPtr LIBCALL
  2578. BLAST0RequestAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  2579. {
  2580.    DataVal av;
  2581.    AsnTypePtr atp;
  2582.    ValNodePtr anp;
  2583.    Uint1 choice;
  2584.    Boolean isError = FALSE;
  2585.    Boolean nullIsError = FALSE;
  2586.    AsnReadFunc func;
  2587.  
  2588.    if (! loaded)
  2589.    {
  2590.       if (! objblst2AsnLoad()) {
  2591.          return NULL;
  2592.       }
  2593.    }
  2594.  
  2595.    if (aip == NULL) {
  2596.       return NULL;
  2597.    }
  2598.  
  2599.    if (orig == NULL) {         /* BLAST0Request ::= (self contained) */
  2600.       atp = AsnReadId(aip, amp, BLAST0_REQUEST);
  2601.    } else {
  2602.       atp = AsnLinkType(orig, BLAST0_REQUEST);    /* link in local tree */
  2603.    }
  2604.    if (atp == NULL) {
  2605.       return NULL;
  2606.    }
  2607.  
  2608.    anp = ValNodeNew(NULL);
  2609.    if (anp == NULL) {
  2610.       goto erret;
  2611.    }
  2612.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  2613.       goto erret;
  2614.    }
  2615.  
  2616.    func = NULL;
  2617.  
  2618.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  2619.    if (atp == NULL) {
  2620.       goto erret;
  2621.    }
  2622.    if (atp == BLAST0_REQUEST_hello) {
  2623.       choice = BLAST0Request_hello;
  2624.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2625.          goto erret;
  2626.       }
  2627.       anp->data.ptrvalue = av.ptrvalue;
  2628.    }
  2629.    else if (atp == BLAST0_REQUEST_motd) {
  2630.       choice = BLAST0Request_motd;
  2631.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2632.          goto erret;
  2633.       }
  2634.       anp->data.boolvalue = av.boolvalue;
  2635.    }
  2636.    else if (atp == BLAST0_REQUEST_prog_info) {
  2637.       choice = BLAST0Request_prog_info;
  2638.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2639.          goto erret;
  2640.       }
  2641.       anp->data.boolvalue = av.boolvalue;
  2642.    }
  2643.    else if (atp == BLAST0_REQUEST_usage_info) {
  2644.       choice = BLAST0Request_usage_info;
  2645.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2646.          goto erret;
  2647.       }
  2648.       anp->data.ptrvalue = av.ptrvalue;
  2649.    }
  2650.    else if (atp == BLAST0_REQUEST_db_info) {
  2651.       choice = BLAST0Request_db_info;
  2652.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2653.          goto erret;
  2654.       }
  2655.       anp->data.boolvalue = av.boolvalue;
  2656.    }
  2657.    else if (atp == BLAST0_REQUEST_matrix_info) {
  2658.       choice = BLAST0Request_matrix_info;
  2659.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2660.          goto erret;
  2661.       }
  2662.       anp->data.boolvalue = av.boolvalue;
  2663.    }
  2664.    else if (atp == BLAST0_REQUEST_matrix_get) {
  2665.       choice = BLAST0Request_matrix_get;
  2666.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2667.          goto erret;
  2668.       }
  2669.       anp->data.ptrvalue = av.ptrvalue;
  2670.    }
  2671.    else if (atp == BLAST0_REQUEST_search) {
  2672.       choice = BLAST0Request_search;
  2673.       func = (AsnReadFunc) BLAST0SearchAsnRead;
  2674.    }
  2675.    else if (atp == BLAST0_REQUEST_goodbye) {
  2676.       choice = BLAST0Request_goodbye;
  2677.       if (AsnReadVal(aip, atp, &av) <= 0) {
  2678.          goto erret;
  2679.       }
  2680.       anp->data.boolvalue = av.boolvalue;
  2681.    }
  2682.    anp->choice = choice;
  2683.    if (func != NULL)
  2684.    {
  2685.       anp->data.ptrvalue = (* func)(aip, atp);
  2686.       if (aip -> io_failure) goto erret;
  2687.  
  2688.       if (nullIsError && anp->data.ptrvalue == NULL) {
  2689.          goto erret;
  2690.       }
  2691.    }
  2692.  
  2693. ret:
  2694.    AsnUnlinkType(orig);       /* unlink local tree */
  2695.    return anp;
  2696.  
  2697. erret:
  2698.    anp = MemFree(anp);
  2699.    aip -> io_failure = TRUE;
  2700.    goto ret;
  2701. }
  2702.  
  2703.  
  2704. /**************************************************
  2705. *
  2706. *    BLAST0RequestAsnWrite()
  2707. *
  2708. **************************************************/
  2709. Boolean LIBCALL 
  2710. BLAST0RequestAsnWrite(BLAST0RequestPtr anp, AsnIoPtr aip, AsnTypePtr orig)
  2711.  
  2712. {
  2713.    DataVal av;
  2714.    AsnTypePtr atp, writetype = NULL;
  2715.    Pointer pnt;
  2716.    AsnWriteFunc func = NULL;
  2717.    Boolean retval = FALSE;
  2718.  
  2719.    if (! loaded)
  2720.    {
  2721.       if (! objblst2AsnLoad())
  2722.       return FALSE;
  2723.    }
  2724.  
  2725.    if (aip == NULL)
  2726.    return FALSE;
  2727.  
  2728.    atp = AsnLinkType(orig, BLAST0_REQUEST);   /* link local tree */
  2729.    if (atp == NULL) {
  2730.       return FALSE;
  2731.    }
  2732.  
  2733.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  2734.  
  2735.    av.ptrvalue = (Pointer)anp;
  2736.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  2737.       goto erret;
  2738.    }
  2739.  
  2740.    pnt = anp->data.ptrvalue;
  2741.    switch (anp->choice)
  2742.    {
  2743.    case BLAST0Request_hello:
  2744.       av.ptrvalue = anp->data.ptrvalue;
  2745.       retval = AsnWrite(aip, BLAST0_REQUEST_hello, &av);
  2746.       break;
  2747.    case BLAST0Request_motd:
  2748.       av.boolvalue = anp->data.boolvalue;
  2749.       retval = AsnWrite(aip, BLAST0_REQUEST_motd, &av);
  2750.       break;
  2751.    case BLAST0Request_prog_info:
  2752.       av.boolvalue = anp->data.boolvalue;
  2753.       retval = AsnWrite(aip, BLAST0_REQUEST_prog_info, &av);
  2754.       break;
  2755.    case BLAST0Request_usage_info:
  2756.       av.ptrvalue = anp->data.ptrvalue;
  2757.       retval = AsnWrite(aip, BLAST0_REQUEST_usage_info, &av);
  2758.       break;
  2759.    case BLAST0Request_db_info:
  2760.       av.boolvalue = anp->data.boolvalue;
  2761.       retval = AsnWrite(aip, BLAST0_REQUEST_db_info, &av);
  2762.       break;
  2763.    case BLAST0Request_matrix_info:
  2764.       av.boolvalue = anp->data.boolvalue;
  2765.       retval = AsnWrite(aip, BLAST0_REQUEST_matrix_info, &av);
  2766.       break;
  2767.    case BLAST0Request_matrix_get:
  2768.       av.ptrvalue = anp->data.ptrvalue;
  2769.       retval = AsnWrite(aip, BLAST0_REQUEST_matrix_get, &av);
  2770.       break;
  2771.    case BLAST0Request_search:
  2772.       writetype = BLAST0_REQUEST_search;
  2773.       func = (AsnWriteFunc) BLAST0SearchAsnWrite;
  2774.       break;
  2775.    case BLAST0Request_goodbye:
  2776.       av.boolvalue = anp->data.boolvalue;
  2777.       retval = AsnWrite(aip, BLAST0_REQUEST_goodbye, &av);
  2778.       break;
  2779.    }
  2780.    if (writetype != NULL) {
  2781.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  2782.    }
  2783.    if (!retval) {
  2784.       goto erret;
  2785.    }
  2786.    retval = TRUE;
  2787.  
  2788. erret:
  2789.    AsnUnlinkType(orig);       /* unlink local tree */
  2790.    return retval;
  2791. }
  2792.  
  2793.  
  2794. /**************************************************
  2795. *
  2796. *    BLAST0SearchNew()
  2797. *
  2798. **************************************************/
  2799.  
  2800. BLAST0SearchPtr LIBCALL
  2801. BLAST0SearchNew(void)
  2802. {
  2803.    BLAST0SearchPtr ptr = MemNew((size_t) sizeof(BLAST0Search));
  2804.  
  2805.    ptr -> return_matrix = 1;
  2806.    ptr -> return_query = 1;
  2807.    ptr -> return_BLAST0result = 1;
  2808.    ptr -> return_query_seq_in_seg = 1;
  2809.    ptr -> return_db_seq_in_seg = 1;
  2810.    return ptr;
  2811.  
  2812. }
  2813.  
  2814.  
  2815. /**************************************************
  2816. *
  2817. *    BLAST0SearchFree()
  2818. *
  2819. **************************************************/
  2820.  
  2821. BLAST0SearchPtr LIBCALL
  2822. BLAST0SearchFree(BLAST0SearchPtr ptr)
  2823. {
  2824.  
  2825.    if(ptr == NULL) {
  2826.       return NULL;
  2827.    }
  2828.    MemFree(ptr -> program);
  2829.    MemFree(ptr -> database);
  2830.    BLAST0SequenceFree(ptr -> query);
  2831.    AsnGenericBaseSeqOfFree(ptr -> options ,ASNCODE_PTRVAL_SLOT);
  2832.    return MemFree(ptr);
  2833. }
  2834.  
  2835.  
  2836. /**************************************************
  2837. *
  2838. *    BLAST0SearchAsnRead()
  2839. *
  2840. **************************************************/
  2841.  
  2842. BLAST0SearchPtr LIBCALL
  2843. BLAST0SearchAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  2844. {
  2845.    DataVal av;
  2846.    AsnTypePtr atp;
  2847.    Boolean isError = FALSE;
  2848.    AsnReadFunc func;
  2849.    BLAST0SearchPtr ptr;
  2850.  
  2851.    if (! loaded)
  2852.    {
  2853.       if (! objblst2AsnLoad()) {
  2854.          return NULL;
  2855.       }
  2856.    }
  2857.  
  2858.    if (aip == NULL) {
  2859.       return NULL;
  2860.    }
  2861.  
  2862.    if (orig == NULL) {         /* BLAST0Search ::= (self contained) */
  2863.       atp = AsnReadId(aip, amp, BLAST0_SEARCH);
  2864.    } else {
  2865.       atp = AsnLinkType(orig, BLAST0_SEARCH);
  2866.    }
  2867.    /* link in local tree */
  2868.    if (atp == NULL) {
  2869.       return NULL;
  2870.    }
  2871.  
  2872.    ptr = BLAST0SearchNew();
  2873.    if (ptr == NULL) {
  2874.       goto erret;
  2875.    }
  2876.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  2877.       goto erret;
  2878.    }
  2879.  
  2880.    atp = AsnReadId(aip,amp, atp);
  2881.    func = NULL;
  2882.  
  2883.    if (atp == BLAST0_SEARCH_program) {
  2884.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2885.          goto erret;
  2886.       }
  2887.       ptr -> program = av.ptrvalue;
  2888.       atp = AsnReadId(aip,amp, atp);
  2889.    }
  2890.    if (atp == BLAST0_SEARCH_database) {
  2891.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2892.          goto erret;
  2893.       }
  2894.       ptr -> database = av.ptrvalue;
  2895.       atp = AsnReadId(aip,amp, atp);
  2896.    }
  2897.    if (atp == BLAST0_SEARCH_query) {
  2898.       ptr -> query = BLAST0SequenceAsnRead(aip, atp);
  2899.       if (aip -> io_failure) {
  2900.          goto erret;
  2901.       }
  2902.       atp = AsnReadId(aip,amp, atp);
  2903.    }
  2904.    if (atp == BLAST0_SEARCH_options) {
  2905.       ptr -> options = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  2906.       if (isError && ptr -> options == NULL) {
  2907.          goto erret;
  2908.       }
  2909.       atp = AsnReadId(aip,amp, atp);
  2910.    }
  2911.    if (atp == BLAST0_SEARCH_return_matrix) {
  2912.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2913.          goto erret;
  2914.       }
  2915.       ptr -> return_matrix = av.boolvalue;
  2916.       atp = AsnReadId(aip,amp, atp);
  2917.    }
  2918.    if (atp == BLAST0_SEARCH_return_query) {
  2919.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2920.          goto erret;
  2921.       }
  2922.       ptr -> return_query = av.boolvalue;
  2923.       atp = AsnReadId(aip,amp, atp);
  2924.    }
  2925.    if (atp == SEARCH_return_BLAST0result) {
  2926.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2927.          goto erret;
  2928.       }
  2929.       ptr -> return_BLAST0result = av.boolvalue;
  2930.       atp = AsnReadId(aip,amp, atp);
  2931.    }
  2932.    if (atp == SEARCH_return_query_seq_in_seg) {
  2933.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2934.          goto erret;
  2935.       }
  2936.       ptr -> return_query_seq_in_seg = av.boolvalue;
  2937.       atp = AsnReadId(aip,amp, atp);
  2938.    }
  2939.    if (atp == SEARCH_return_db_seq_in_seg) {
  2940.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  2941.          goto erret;
  2942.       }
  2943.       ptr -> return_db_seq_in_seg = av.boolvalue;
  2944.       atp = AsnReadId(aip,amp, atp);
  2945.    }
  2946.  
  2947.    if (AsnReadVal(aip, atp, &av) <= 0) {
  2948.       goto erret;
  2949.    }
  2950.    /* end struct */
  2951.  
  2952. ret:
  2953.    AsnUnlinkType(orig);       /* unlink local tree */
  2954.    return ptr;
  2955.  
  2956. erret:
  2957.    aip -> io_failure = TRUE;
  2958.    ptr = BLAST0SearchFree(ptr);
  2959.    goto ret;
  2960. }
  2961.  
  2962.  
  2963.  
  2964. /**************************************************
  2965. *
  2966. *    BLAST0SearchAsnWrite()
  2967. *
  2968. **************************************************/
  2969. Boolean LIBCALL 
  2970. BLAST0SearchAsnWrite(BLAST0SearchPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  2971. {
  2972.    DataVal av;
  2973.    AsnTypePtr atp;
  2974.    Boolean retval = FALSE;
  2975.  
  2976.    if (! loaded)
  2977.    {
  2978.       if (! objblst2AsnLoad()) {
  2979.          return FALSE;
  2980.       }
  2981.    }
  2982.  
  2983.    if (aip == NULL) {
  2984.       return FALSE;
  2985.    }
  2986.  
  2987.    atp = AsnLinkType(orig, BLAST0_SEARCH);   /* link local tree */
  2988.    if (atp == NULL) {
  2989.       return FALSE;
  2990.    }
  2991.  
  2992.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  2993.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  2994.       goto erret;
  2995.    }
  2996.  
  2997.    if (ptr -> program != NULL) {
  2998.       av.ptrvalue = ptr -> program;
  2999.       retval = AsnWrite(aip, BLAST0_SEARCH_program,  &av);
  3000.    }
  3001.    if (ptr -> database != NULL) {
  3002.       av.ptrvalue = ptr -> database;
  3003.       retval = AsnWrite(aip, BLAST0_SEARCH_database,  &av);
  3004.    }
  3005.    if (ptr -> query != NULL) {
  3006.       if ( ! BLAST0SequenceAsnWrite(ptr -> query, aip, BLAST0_SEARCH_query)) {
  3007.          goto erret;
  3008.       }
  3009.    }
  3010.    retval = AsnGenericBaseSeqOfAsnWrite(ptr -> options ,ASNCODE_PTRVAL_SLOT, aip, BLAST0_SEARCH_options, BLAST0_SEARCH_options_E);
  3011.    av.boolvalue = ptr -> return_matrix;
  3012.    retval = AsnWrite(aip, BLAST0_SEARCH_return_matrix,  &av);
  3013.    av.boolvalue = ptr -> return_query;
  3014.    retval = AsnWrite(aip, BLAST0_SEARCH_return_query,  &av);
  3015.    av.boolvalue = ptr -> return_BLAST0result;
  3016.    retval = AsnWrite(aip, SEARCH_return_BLAST0result,  &av);
  3017.    av.boolvalue = ptr -> return_query_seq_in_seg;
  3018.    retval = AsnWrite(aip, SEARCH_return_query_seq_in_seg,  &av);
  3019.    av.boolvalue = ptr -> return_db_seq_in_seg;
  3020.    retval = AsnWrite(aip, SEARCH_return_db_seq_in_seg,  &av);
  3021.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  3022.       goto erret;
  3023.    }
  3024.    retval = TRUE;
  3025.  
  3026. erret:
  3027.    AsnUnlinkType(orig);       /* unlink local tree */
  3028.    return retval;
  3029. }
  3030.  
  3031.  
  3032.  
  3033. /**************************************************
  3034. *
  3035. *    BLAST0ResponseFree()
  3036. *
  3037. **************************************************/
  3038.  
  3039. BLAST0ResponsePtr LIBCALL
  3040. BLAST0ResponseFree(ValNodePtr anp)
  3041. {
  3042.    Pointer pnt;
  3043.  
  3044.    if (anp == NULL) {
  3045.       return NULL;
  3046.    }
  3047.  
  3048.    pnt = anp->data.ptrvalue;
  3049.    switch (anp->choice)
  3050.    {
  3051.    default:
  3052.       break;
  3053.    case BLAST0Response_hello:
  3054.       MemFree(anp -> data.ptrvalue);
  3055.       break;
  3056.    case BLAST0Response_motd:
  3057.       MemFree(anp -> data.ptrvalue);
  3058.       break;
  3059.    case BLAST0Response_prog_info:
  3060.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0PrefaceFree);
  3061.       break;
  3062.    case BLAST0Response_usage_info:
  3063.       BLAST0PrefaceFree(anp -> data.ptrvalue);
  3064.       break;
  3065.    case BLAST0Response_db_info:
  3066.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0DbDescFree);
  3067.       break;
  3068.    case BLAST0Response_matrix_info:
  3069.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0MatrixFree);
  3070.       break;
  3071.    case BLAST0Response_ack:
  3072.       BLAST0AckFree(anp -> data.ptrvalue);
  3073.       break;
  3074.    case BLAST0Response_goodbye:
  3075.       BLAST0AckFree(anp -> data.ptrvalue);
  3076.       break;
  3077.    case BLAST0Response_queued:
  3078.       BLAST0QueuedFree(anp -> data.ptrvalue);
  3079.       break;
  3080.    case BLAST0Response_preface:
  3081.       BLAST0PrefaceFree(anp -> data.ptrvalue);
  3082.       break;
  3083.    case BLAST0Response_query:
  3084.       BLAST0SequenceFree(anp -> data.ptrvalue);
  3085.       break;
  3086.    case BLAST0Response_dbdesc:
  3087.       BLAST0DbDescFree(anp -> data.ptrvalue);
  3088.       break;
  3089.    case BLAST0Response_matrix:
  3090.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0MatrixFree);
  3091.       break;
  3092.    case BLAST0Response_kablk:
  3093.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0KABlkFree);
  3094.       break;
  3095.    case BLAST0Response_job_start:
  3096.       BLAST0JobDescFree(anp -> data.ptrvalue);
  3097.       break;
  3098.    case BLAST0Response_job_progress:
  3099.       BLAST0JobProgressFree(anp -> data.ptrvalue);
  3100.       break;
  3101.    case BLAST0Response_job_done:
  3102.       BLAST0JobProgressFree(anp -> data.ptrvalue);
  3103.       break;
  3104.    case BLAST0Response_score_defs:
  3105.       AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) BLAST0ScoreInfoFree);
  3106.       break;
  3107.    case BLAST0Response_result:
  3108.       BLAST0ResultFree(anp -> data.ptrvalue);
  3109.       break;
  3110.    case BLAST0Response_seqalign:
  3111.       SeqAlignSetFree(anp -> data.ptrvalue);
  3112.       break;
  3113.    case BLAST0Response_parms:
  3114.       AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
  3115.       break;
  3116.    case BLAST0Response_stats:
  3117.       AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
  3118.       break;
  3119.    case BLAST0Response_warning:
  3120.       BLAST0StatusFree(anp -> data.ptrvalue);
  3121.       break;
  3122.    case BLAST0Response_status:
  3123.       BLAST0StatusFree(anp -> data.ptrvalue);
  3124.       break;
  3125.    }
  3126.    return MemFree(anp);
  3127. }
  3128.  
  3129.  
  3130. /**************************************************
  3131. *
  3132. *    BLAST0ResponseAsnRead()
  3133. *
  3134. **************************************************/
  3135.  
  3136. BLAST0ResponsePtr LIBCALL
  3137. BLAST0ResponseAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  3138. {
  3139.    DataVal av;
  3140.    AsnTypePtr atp;
  3141.    ValNodePtr anp;
  3142.    Uint1 choice;
  3143.    Boolean isError = FALSE;
  3144.    Boolean nullIsError = FALSE;
  3145.    AsnReadFunc func;
  3146.  
  3147.    if (! loaded)
  3148.    {
  3149.       if (! objblst2AsnLoad()) {
  3150.          return NULL;
  3151.       }
  3152.    }
  3153.  
  3154.    if (aip == NULL) {
  3155.       return NULL;
  3156.    }
  3157.  
  3158.    if (orig == NULL) {         /* BLAST0Response ::= (self contained) */
  3159.       atp = AsnReadId(aip, amp, BLAST0_RESPONSE);
  3160.    } else {
  3161.       atp = AsnLinkType(orig, BLAST0_RESPONSE);    /* link in local tree */
  3162.    }
  3163.    if (atp == NULL) {
  3164.       return NULL;
  3165.    }
  3166.  
  3167.    anp = ValNodeNew(NULL);
  3168.    if (anp == NULL) {
  3169.       goto erret;
  3170.    }
  3171.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  3172.       goto erret;
  3173.    }
  3174.  
  3175.    func = NULL;
  3176.  
  3177.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  3178.    if (atp == NULL) {
  3179.       goto erret;
  3180.    }
  3181.    if (atp == BLAST0_RESPONSE_hello) {
  3182.       choice = BLAST0Response_hello;
  3183.       if (AsnReadVal(aip, atp, &av) <= 0) {
  3184.          goto erret;
  3185.       }
  3186.       anp->data.ptrvalue = av.ptrvalue;
  3187.    }
  3188.    else if (atp == BLAST0_RESPONSE_motd) {
  3189.       choice = BLAST0Response_motd;
  3190.       if (AsnReadVal(aip, atp, &av) <= 0) {
  3191.          goto erret;
  3192.       }
  3193.       anp->data.ptrvalue = av.ptrvalue;
  3194.    }
  3195.    else if (atp == BLAST0_RESPONSE_prog_info) {
  3196.       choice = BLAST0Response_prog_info;
  3197.       anp -> data.ptrvalue =
  3198.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0PrefaceAsnRead,             (AsnOptFreeFunc) BLAST0PrefaceFree);
  3199.       if (isError && anp -> data.ptrvalue == NULL) {
  3200.          goto erret;
  3201.       }
  3202.    }
  3203.    else if (atp == BLAST0_RESPONSE_usage_info) {
  3204.       choice = BLAST0Response_usage_info;
  3205.       func = (AsnReadFunc) BLAST0PrefaceAsnRead;
  3206.    }
  3207.    else if (atp == BLAST0_RESPONSE_db_info) {
  3208.       choice = BLAST0Response_db_info;
  3209.       anp -> data.ptrvalue =
  3210.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0DbDescAsnRead,             (AsnOptFreeFunc) BLAST0DbDescFree);
  3211.       if (isError && anp -> data.ptrvalue == NULL) {
  3212.          goto erret;
  3213.       }
  3214.    }
  3215.    else if (atp == BLAST0_RESPONSE_matrix_info) {
  3216.       choice = BLAST0Response_matrix_info;
  3217.       anp -> data.ptrvalue =
  3218.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0MatrixAsnRead,             (AsnOptFreeFunc) BLAST0MatrixFree);
  3219.       if (isError && anp -> data.ptrvalue == NULL) {
  3220.          goto erret;
  3221.       }
  3222.    }
  3223.    else if (atp == BLAST0_RESPONSE_ack) {
  3224.       choice = BLAST0Response_ack;
  3225.       func = (AsnReadFunc) BLAST0AckAsnRead;
  3226.    }
  3227.    else if (atp == BLAST0_RESPONSE_goodbye) {
  3228.       choice = BLAST0Response_goodbye;
  3229.       func = (AsnReadFunc) BLAST0AckAsnRead;
  3230.    }
  3231.    else if (atp == BLAST0_RESPONSE_queued) {
  3232.       choice = BLAST0Response_queued;
  3233.       func = (AsnReadFunc) BLAST0QueuedAsnRead;
  3234.    }
  3235.    else if (atp == BLAST0_RESPONSE_preface) {
  3236.       choice = BLAST0Response_preface;
  3237.       func = (AsnReadFunc) BLAST0PrefaceAsnRead;
  3238.    }
  3239.    else if (atp == BLAST0_RESPONSE_query) {
  3240.       choice = BLAST0Response_query;
  3241.       func = (AsnReadFunc) BLAST0SequenceAsnRead;
  3242.    }
  3243.    else if (atp == BLAST0_RESPONSE_dbdesc) {
  3244.       choice = BLAST0Response_dbdesc;
  3245.       func = (AsnReadFunc) BLAST0DbDescAsnRead;
  3246.    }
  3247.    else if (atp == BLAST0_RESPONSE_matrix) {
  3248.       choice = BLAST0Response_matrix;
  3249.       anp -> data.ptrvalue =
  3250.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0MatrixAsnRead,             (AsnOptFreeFunc) BLAST0MatrixFree);
  3251.       if (isError && anp -> data.ptrvalue == NULL) {
  3252.          goto erret;
  3253.       }
  3254.    }
  3255.    else if (atp == BLAST0_RESPONSE_kablk) {
  3256.       choice = BLAST0Response_kablk;
  3257.       anp -> data.ptrvalue =
  3258.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0KABlkAsnRead,             (AsnOptFreeFunc) BLAST0KABlkFree);
  3259.       if (isError && anp -> data.ptrvalue == NULL) {
  3260.          goto erret;
  3261.       }
  3262.    }
  3263.    else if (atp == BLAST0_RESPONSE_job_start) {
  3264.       choice = BLAST0Response_job_start;
  3265.       func = (AsnReadFunc) BLAST0JobDescAsnRead;
  3266.    }
  3267.    else if (atp == BLAST0_RESPONSE_job_progress) {
  3268.       choice = BLAST0Response_job_progress;
  3269.       func = (AsnReadFunc) BLAST0JobProgressAsnRead;
  3270.    }
  3271.    else if (atp == BLAST0_RESPONSE_job_done) {
  3272.       choice = BLAST0Response_job_done;
  3273.       func = (AsnReadFunc) BLAST0JobProgressAsnRead;
  3274.    }
  3275.    else if (atp == BLAST0_RESPONSE_score_defs) {
  3276.       choice = BLAST0Response_score_defs;
  3277.       anp -> data.ptrvalue =
  3278.       AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0ScoreInfoAsnRead,             (AsnOptFreeFunc) BLAST0ScoreInfoFree);
  3279.       if (isError && anp -> data.ptrvalue == NULL) {
  3280.          goto erret;
  3281.       }
  3282.    }
  3283.    else if (atp == BLAST0_RESPONSE_result) {
  3284.       choice = BLAST0Response_result;
  3285.       func = (AsnReadFunc) BLAST0ResultAsnRead;
  3286.    }
  3287.    else if (atp == BLAST0_RESPONSE_seqalign) {
  3288.       choice = BLAST0Response_seqalign;
  3289.       func = (AsnReadFunc) SeqAlignSetAsnRead;
  3290.    }
  3291.    else if (atp == BLAST0_RESPONSE_parms) {
  3292.       choice = BLAST0Response_parms;
  3293.       anp -> data.ptrvalue = 
  3294.       AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  3295.       if (isError && anp -> data.ptrvalue == NULL) {
  3296.          goto erret;
  3297.       }
  3298.    }
  3299.    else if (atp == BLAST0_RESPONSE_stats) {
  3300.       choice = BLAST0Response_stats;
  3301.       anp -> data.ptrvalue = 
  3302.       AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
  3303.       if (isError && anp -> data.ptrvalue == NULL) {
  3304.          goto erret;
  3305.       }
  3306.    }
  3307.    else if (atp == BLAST0_RESPONSE_warning) {
  3308.       choice = BLAST0Response_warning;
  3309.       func = (AsnReadFunc) BLAST0StatusAsnRead;
  3310.    }
  3311.    else if (atp == BLAST0_RESPONSE_status) {
  3312.       choice = BLAST0Response_status;
  3313.       func = (AsnReadFunc) BLAST0StatusAsnRead;
  3314.    }
  3315.    anp->choice = choice;
  3316.    if (func != NULL)
  3317.    {
  3318.       anp->data.ptrvalue = (* func)(aip, atp);
  3319.       if (aip -> io_failure) goto erret;
  3320.  
  3321.       if (nullIsError && anp->data.ptrvalue == NULL) {
  3322.          goto erret;
  3323.       }
  3324.    }
  3325.  
  3326. ret:
  3327.    AsnUnlinkType(orig);       /* unlink local tree */
  3328.    return anp;
  3329.  
  3330. erret:
  3331.    anp = MemFree(anp);
  3332.    aip -> io_failure = TRUE;
  3333.    goto ret;
  3334. }
  3335.  
  3336.  
  3337. /**************************************************
  3338. *
  3339. *    BLAST0ResponseAsnWrite()
  3340. *
  3341. **************************************************/
  3342. Boolean LIBCALL 
  3343. BLAST0ResponseAsnWrite(BLAST0ResponsePtr anp, AsnIoPtr aip, AsnTypePtr orig)
  3344.  
  3345. {
  3346.    DataVal av;
  3347.    AsnTypePtr atp, writetype = NULL;
  3348.    Pointer pnt;
  3349.    AsnWriteFunc func = NULL;
  3350.    Boolean retval = FALSE;
  3351.  
  3352.    if (! loaded)
  3353.    {
  3354.       if (! objblst2AsnLoad())
  3355.       return FALSE;
  3356.    }
  3357.  
  3358.    if (aip == NULL)
  3359.    return FALSE;
  3360.  
  3361.    atp = AsnLinkType(orig, BLAST0_RESPONSE);   /* link local tree */
  3362.    if (atp == NULL) {
  3363.       return FALSE;
  3364.    }
  3365.  
  3366.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  3367.  
  3368.    av.ptrvalue = (Pointer)anp;
  3369.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  3370.       goto erret;
  3371.    }
  3372.  
  3373.    pnt = anp->data.ptrvalue;
  3374.    switch (anp->choice)
  3375.    {
  3376.    case BLAST0Response_hello:
  3377.       av.ptrvalue = anp->data.ptrvalue;
  3378.       retval = AsnWrite(aip, BLAST0_RESPONSE_hello, &av);
  3379.       break;
  3380.    case BLAST0Response_motd:
  3381.       av.ptrvalue = anp->data.ptrvalue;
  3382.       retval = AsnWrite(aip, BLAST0_RESPONSE_motd, &av);
  3383.       break;
  3384.    case BLAST0Response_prog_info:
  3385.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0PrefaceAsnWrite, aip, BLAST0_RESPONSE_prog_info, BLAST0_RESPONSE_prog_info_E);
  3386.       break;
  3387.    case BLAST0Response_usage_info:
  3388.       writetype = BLAST0_RESPONSE_usage_info;
  3389.       func = (AsnWriteFunc) BLAST0PrefaceAsnWrite;
  3390.       break;
  3391.    case BLAST0Response_db_info:
  3392.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0DbDescAsnWrite, aip, BLAST0_RESPONSE_db_info, BLAST0_RESPONSE_db_info_E);
  3393.       break;
  3394.    case BLAST0Response_matrix_info:
  3395.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0MatrixAsnWrite, aip, BLAST0_RESPONSE_matrix_info, BLAST0_RESPONSE_matrix_info_E);
  3396.       break;
  3397.    case BLAST0Response_ack:
  3398.       writetype = BLAST0_RESPONSE_ack;
  3399.       func = (AsnWriteFunc) BLAST0AckAsnWrite;
  3400.       break;
  3401.    case BLAST0Response_goodbye:
  3402.       writetype = BLAST0_RESPONSE_goodbye;
  3403.       func = (AsnWriteFunc) BLAST0AckAsnWrite;
  3404.       break;
  3405.    case BLAST0Response_queued:
  3406.       writetype = BLAST0_RESPONSE_queued;
  3407.       func = (AsnWriteFunc) BLAST0QueuedAsnWrite;
  3408.       break;
  3409.    case BLAST0Response_preface:
  3410.       writetype = BLAST0_RESPONSE_preface;
  3411.       func = (AsnWriteFunc) BLAST0PrefaceAsnWrite;
  3412.       break;
  3413.    case BLAST0Response_query:
  3414.       writetype = BLAST0_RESPONSE_query;
  3415.       func = (AsnWriteFunc) BLAST0SequenceAsnWrite;
  3416.       break;
  3417.    case BLAST0Response_dbdesc:
  3418.       writetype = BLAST0_RESPONSE_dbdesc;
  3419.       func = (AsnWriteFunc) BLAST0DbDescAsnWrite;
  3420.       break;
  3421.    case BLAST0Response_matrix:
  3422.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0MatrixAsnWrite, aip, BLAST0_RESPONSE_matrix, BLAST0_RESPONSE_matrix_E);
  3423.       break;
  3424.    case BLAST0Response_kablk:
  3425.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0KABlkAsnWrite, aip, BLAST0_RESPONSE_kablk, BLAST0_RESPONSE_kablk_E);
  3426.       break;
  3427.    case BLAST0Response_job_start:
  3428.       writetype = BLAST0_RESPONSE_job_start;
  3429.       func = (AsnWriteFunc) BLAST0JobDescAsnWrite;
  3430.       break;
  3431.    case BLAST0Response_job_progress:
  3432.       writetype = BLAST0_RESPONSE_job_progress;
  3433.       func = (AsnWriteFunc) BLAST0JobProgressAsnWrite;
  3434.       break;
  3435.    case BLAST0Response_job_done:
  3436.       writetype = BLAST0_RESPONSE_job_done;
  3437.       func = (AsnWriteFunc) BLAST0JobProgressAsnWrite;
  3438.       break;
  3439.    case BLAST0Response_score_defs:
  3440.       retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) BLAST0ScoreInfoAsnWrite, aip, BLAST0_RESPONSE_score_defs, BLAST0_RESPONSE_score_defs_E);
  3441.       break;
  3442.    case BLAST0Response_result:
  3443.       writetype = BLAST0_RESPONSE_result;
  3444.       func = (AsnWriteFunc) BLAST0ResultAsnWrite;
  3445.       break;
  3446.    case BLAST0Response_seqalign:
  3447.       writetype = BLAST0_RESPONSE_seqalign;
  3448.       func = (AsnWriteFunc) SeqAlignSetAsnWrite;
  3449.       break;
  3450.    case BLAST0Response_parms:
  3451.       retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, BLAST0_RESPONSE_parms, BLAST0_RESPONSE_parms_E);            break;
  3452.    case BLAST0Response_stats:
  3453.       retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, BLAST0_RESPONSE_stats, BLAST0_RESPONSE_stats_E);            break;
  3454.    case BLAST0Response_warning:
  3455.       writetype = BLAST0_RESPONSE_warning;
  3456.       func = (AsnWriteFunc) BLAST0StatusAsnWrite;
  3457.       break;
  3458.    case BLAST0Response_status:
  3459.       writetype = BLAST0_RESPONSE_status;
  3460.       func = (AsnWriteFunc) BLAST0StatusAsnWrite;
  3461.       break;
  3462.    }
  3463.    if (writetype != NULL) {
  3464.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  3465.    }
  3466.    if (!retval) {
  3467.       goto erret;
  3468.    }
  3469.    retval = TRUE;
  3470.  
  3471. erret:
  3472.    AsnUnlinkType(orig);       /* unlink local tree */
  3473.    return retval;
  3474. }
  3475.  
  3476.  
  3477. /**************************************************
  3478. *
  3479. *    BLAST0AckNew()
  3480. *
  3481. **************************************************/
  3482.  
  3483. BLAST0AckPtr LIBCALL
  3484. BLAST0AckNew(void)
  3485. {
  3486.    BLAST0AckPtr ptr = MemNew((size_t) sizeof(BLAST0Ack));
  3487.  
  3488.    return ptr;
  3489.  
  3490. }
  3491.  
  3492.  
  3493. /**************************************************
  3494. *
  3495. *    BLAST0AckFree()
  3496. *
  3497. **************************************************/
  3498.  
  3499. BLAST0AckPtr LIBCALL
  3500. BLAST0AckFree(BLAST0AckPtr ptr)
  3501. {
  3502.  
  3503.    if(ptr == NULL) {
  3504.       return NULL;
  3505.    }
  3506.    MemFree(ptr -> reason);
  3507.    return MemFree(ptr);
  3508. }
  3509.  
  3510.  
  3511. /**************************************************
  3512. *
  3513. *    BLAST0AckAsnRead()
  3514. *
  3515. **************************************************/
  3516.  
  3517. BLAST0AckPtr LIBCALL
  3518. BLAST0AckAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  3519. {
  3520.    DataVal av;
  3521.    AsnTypePtr atp;
  3522.    Boolean isError = FALSE;
  3523.    AsnReadFunc func;
  3524.    BLAST0AckPtr ptr;
  3525.  
  3526.    if (! loaded)
  3527.    {
  3528.       if (! objblst2AsnLoad()) {
  3529.          return NULL;
  3530.       }
  3531.    }
  3532.  
  3533.    if (aip == NULL) {
  3534.       return NULL;
  3535.    }
  3536.  
  3537.    if (orig == NULL) {         /* BLAST0Ack ::= (self contained) */
  3538.       atp = AsnReadId(aip, amp, BLAST0_ACK);
  3539.    } else {
  3540.       atp = AsnLinkType(orig, BLAST0_ACK);
  3541.    }
  3542.    /* link in local tree */
  3543.    if (atp == NULL) {
  3544.       return NULL;
  3545.    }
  3546.  
  3547.    ptr = BLAST0AckNew();
  3548.    if (ptr == NULL) {
  3549.       goto erret;
  3550.    }
  3551.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  3552.       goto erret;
  3553.    }
  3554.  
  3555.    atp = AsnReadId(aip,amp, atp);
  3556.    func = NULL;
  3557.  
  3558.    if (atp == BLAST0_ACK_code) {
  3559.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3560.          goto erret;
  3561.       }
  3562.       ptr -> code = av.intvalue;
  3563.       atp = AsnReadId(aip,amp, atp);
  3564.    }
  3565.    if (atp == BLAST0_ACK_reason) {
  3566.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3567.          goto erret;
  3568.       }
  3569.       ptr -> reason = av.ptrvalue;
  3570.       atp = AsnReadId(aip,amp, atp);
  3571.    }
  3572.  
  3573.    if (AsnReadVal(aip, atp, &av) <= 0) {
  3574.       goto erret;
  3575.    }
  3576.    /* end struct */
  3577.  
  3578. ret:
  3579.    AsnUnlinkType(orig);       /* unlink local tree */
  3580.    return ptr;
  3581.  
  3582. erret:
  3583.    aip -> io_failure = TRUE;
  3584.    ptr = BLAST0AckFree(ptr);
  3585.    goto ret;
  3586. }
  3587.  
  3588.  
  3589.  
  3590. /**************************************************
  3591. *
  3592. *    BLAST0AckAsnWrite()
  3593. *
  3594. **************************************************/
  3595. Boolean LIBCALL 
  3596. BLAST0AckAsnWrite(BLAST0AckPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  3597. {
  3598.    DataVal av;
  3599.    AsnTypePtr atp;
  3600.    Boolean retval = FALSE;
  3601.  
  3602.    if (! loaded)
  3603.    {
  3604.       if (! objblst2AsnLoad()) {
  3605.          return FALSE;
  3606.       }
  3607.    }
  3608.  
  3609.    if (aip == NULL) {
  3610.       return FALSE;
  3611.    }
  3612.  
  3613.    atp = AsnLinkType(orig, BLAST0_ACK);   /* link local tree */
  3614.    if (atp == NULL) {
  3615.       return FALSE;
  3616.    }
  3617.  
  3618.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  3619.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  3620.       goto erret;
  3621.    }
  3622.  
  3623.    av.intvalue = ptr -> code;
  3624.    retval = AsnWrite(aip, BLAST0_ACK_code,  &av);
  3625.    if (ptr -> reason != NULL) {
  3626.       av.ptrvalue = ptr -> reason;
  3627.       retval = AsnWrite(aip, BLAST0_ACK_reason,  &av);
  3628.    }
  3629.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  3630.       goto erret;
  3631.    }
  3632.    retval = TRUE;
  3633.  
  3634. erret:
  3635.    AsnUnlinkType(orig);       /* unlink local tree */
  3636.    return retval;
  3637. }
  3638.  
  3639.  
  3640.  
  3641. /**************************************************
  3642. *
  3643. *    BLAST0QueuedNew()
  3644. *
  3645. **************************************************/
  3646.  
  3647. BLAST0QueuedPtr LIBCALL
  3648. BLAST0QueuedNew(void)
  3649. {
  3650.    BLAST0QueuedPtr ptr = MemNew((size_t) sizeof(BLAST0Queued));
  3651.  
  3652.    return ptr;
  3653.  
  3654. }
  3655.  
  3656.  
  3657. /**************************************************
  3658. *
  3659. *    BLAST0QueuedFree()
  3660. *
  3661. **************************************************/
  3662.  
  3663. BLAST0QueuedPtr LIBCALL
  3664. BLAST0QueuedFree(BLAST0QueuedPtr ptr)
  3665. {
  3666.  
  3667.    if(ptr == NULL) {
  3668.       return NULL;
  3669.    }
  3670.    MemFree(ptr -> name);
  3671.    return MemFree(ptr);
  3672. }
  3673.  
  3674.  
  3675. /**************************************************
  3676. *
  3677. *    BLAST0QueuedAsnRead()
  3678. *
  3679. **************************************************/
  3680.  
  3681. BLAST0QueuedPtr LIBCALL
  3682. BLAST0QueuedAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  3683. {
  3684.    DataVal av;
  3685.    AsnTypePtr atp;
  3686.    Boolean isError = FALSE;
  3687.    AsnReadFunc func;
  3688.    BLAST0QueuedPtr ptr;
  3689.  
  3690.    if (! loaded)
  3691.    {
  3692.       if (! objblst2AsnLoad()) {
  3693.          return NULL;
  3694.       }
  3695.    }
  3696.  
  3697.    if (aip == NULL) {
  3698.       return NULL;
  3699.    }
  3700.  
  3701.    if (orig == NULL) {         /* BLAST0Queued ::= (self contained) */
  3702.       atp = AsnReadId(aip, amp, BLAST0_QUEUED);
  3703.    } else {
  3704.       atp = AsnLinkType(orig, BLAST0_QUEUED);
  3705.    }
  3706.    /* link in local tree */
  3707.    if (atp == NULL) {
  3708.       return NULL;
  3709.    }
  3710.  
  3711.    ptr = BLAST0QueuedNew();
  3712.    if (ptr == NULL) {
  3713.       goto erret;
  3714.    }
  3715.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  3716.       goto erret;
  3717.    }
  3718.  
  3719.    atp = AsnReadId(aip,amp, atp);
  3720.    func = NULL;
  3721.  
  3722.    if (atp == BLAST0_QUEUED_name) {
  3723.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3724.          goto erret;
  3725.       }
  3726.       ptr -> name = av.ptrvalue;
  3727.       atp = AsnReadId(aip,amp, atp);
  3728.    }
  3729.    if (atp == BLAST0_QUEUED_length) {
  3730.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3731.          goto erret;
  3732.       }
  3733.       ptr -> length = av.intvalue;
  3734.       atp = AsnReadId(aip,amp, atp);
  3735.    }
  3736.  
  3737.    if (AsnReadVal(aip, atp, &av) <= 0) {
  3738.       goto erret;
  3739.    }
  3740.    /* end struct */
  3741.  
  3742. ret:
  3743.    AsnUnlinkType(orig);       /* unlink local tree */
  3744.    return ptr;
  3745.  
  3746. erret:
  3747.    aip -> io_failure = TRUE;
  3748.    ptr = BLAST0QueuedFree(ptr);
  3749.    goto ret;
  3750. }
  3751.  
  3752.  
  3753.  
  3754. /**************************************************
  3755. *
  3756. *    BLAST0QueuedAsnWrite()
  3757. *
  3758. **************************************************/
  3759. Boolean LIBCALL 
  3760. BLAST0QueuedAsnWrite(BLAST0QueuedPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  3761. {
  3762.    DataVal av;
  3763.    AsnTypePtr atp;
  3764.    Boolean retval = FALSE;
  3765.  
  3766.    if (! loaded)
  3767.    {
  3768.       if (! objblst2AsnLoad()) {
  3769.          return FALSE;
  3770.       }
  3771.    }
  3772.  
  3773.    if (aip == NULL) {
  3774.       return FALSE;
  3775.    }
  3776.  
  3777.    atp = AsnLinkType(orig, BLAST0_QUEUED);   /* link local tree */
  3778.    if (atp == NULL) {
  3779.       return FALSE;
  3780.    }
  3781.  
  3782.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  3783.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  3784.       goto erret;
  3785.    }
  3786.  
  3787.    if (ptr -> name != NULL) {
  3788.       av.ptrvalue = ptr -> name;
  3789.       retval = AsnWrite(aip, BLAST0_QUEUED_name,  &av);
  3790.    }
  3791.    av.intvalue = ptr -> length;
  3792.    retval = AsnWrite(aip, BLAST0_QUEUED_length,  &av);
  3793.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  3794.       goto erret;
  3795.    }
  3796.    retval = TRUE;
  3797.  
  3798. erret:
  3799.    AsnUnlinkType(orig);       /* unlink local tree */
  3800.    return retval;
  3801. }
  3802.  
  3803.  
  3804.  
  3805. /**************************************************
  3806. *
  3807. *    BLAST0ScoreInfoNew()
  3808. *
  3809. **************************************************/
  3810.  
  3811. BLAST0ScoreInfoPtr LIBCALL
  3812. BLAST0ScoreInfoNew(void)
  3813. {
  3814.    BLAST0ScoreInfoPtr ptr = MemNew((size_t) sizeof(BLAST0ScoreInfo));
  3815.  
  3816.    return ptr;
  3817.  
  3818. }
  3819.  
  3820.  
  3821. /**************************************************
  3822. *
  3823. *    BLAST0ScoreInfoFree()
  3824. *
  3825. **************************************************/
  3826.  
  3827. BLAST0ScoreInfoPtr LIBCALL
  3828. BLAST0ScoreInfoFree(BLAST0ScoreInfoPtr ptr)
  3829. {
  3830.  
  3831.    if(ptr == NULL) {
  3832.       return NULL;
  3833.    }
  3834.    MemFree(ptr -> tag);
  3835.    MemFree(ptr -> desc);
  3836.    return MemFree(ptr);
  3837. }
  3838.  
  3839.  
  3840. /**************************************************
  3841. *
  3842. *    BLAST0ScoreInfoAsnRead()
  3843. *
  3844. **************************************************/
  3845.  
  3846. BLAST0ScoreInfoPtr LIBCALL
  3847. BLAST0ScoreInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  3848. {
  3849.    DataVal av;
  3850.    AsnTypePtr atp;
  3851.    Boolean isError = FALSE;
  3852.    AsnReadFunc func;
  3853.    BLAST0ScoreInfoPtr ptr;
  3854.  
  3855.    if (! loaded)
  3856.    {
  3857.       if (! objblst2AsnLoad()) {
  3858.          return NULL;
  3859.       }
  3860.    }
  3861.  
  3862.    if (aip == NULL) {
  3863.       return NULL;
  3864.    }
  3865.  
  3866.    if (orig == NULL) {         /* BLAST0ScoreInfo ::= (self contained) */
  3867.       atp = AsnReadId(aip, amp, BLAST0_SCORE_INFO);
  3868.    } else {
  3869.       atp = AsnLinkType(orig, BLAST0_SCORE_INFO);
  3870.    }
  3871.    /* link in local tree */
  3872.    if (atp == NULL) {
  3873.       return NULL;
  3874.    }
  3875.  
  3876.    ptr = BLAST0ScoreInfoNew();
  3877.    if (ptr == NULL) {
  3878.       goto erret;
  3879.    }
  3880.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  3881.       goto erret;
  3882.    }
  3883.  
  3884.    atp = AsnReadId(aip,amp, atp);
  3885.    func = NULL;
  3886.  
  3887.    if (atp == BLAST0_SCORE_INFO_sid) {
  3888.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3889.          goto erret;
  3890.       }
  3891.       ptr -> sid = av.intvalue;
  3892.       atp = AsnReadId(aip,amp, atp);
  3893.    }
  3894.    if (atp == BLAST0_SCORE_INFO_tag) {
  3895.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3896.          goto erret;
  3897.       }
  3898.       ptr -> tag = av.ptrvalue;
  3899.       atp = AsnReadId(aip,amp, atp);
  3900.    }
  3901.    if (atp == BLAST0_SCORE_INFO_desc) {
  3902.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  3903.          goto erret;
  3904.       }
  3905.       ptr -> desc = av.ptrvalue;
  3906.       atp = AsnReadId(aip,amp, atp);
  3907.    }
  3908.  
  3909.    if (AsnReadVal(aip, atp, &av) <= 0) {
  3910.       goto erret;
  3911.    }
  3912.    /* end struct */
  3913.  
  3914. ret:
  3915.    AsnUnlinkType(orig);       /* unlink local tree */
  3916.    return ptr;
  3917.  
  3918. erret:
  3919.    aip -> io_failure = TRUE;
  3920.    ptr = BLAST0ScoreInfoFree(ptr);
  3921.    goto ret;
  3922. }
  3923.  
  3924.  
  3925.  
  3926. /**************************************************
  3927. *
  3928. *    BLAST0ScoreInfoAsnWrite()
  3929. *
  3930. **************************************************/
  3931. Boolean LIBCALL 
  3932. BLAST0ScoreInfoAsnWrite(BLAST0ScoreInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  3933. {
  3934.    DataVal av;
  3935.    AsnTypePtr atp;
  3936.    Boolean retval = FALSE;
  3937.  
  3938.    if (! loaded)
  3939.    {
  3940.       if (! objblst2AsnLoad()) {
  3941.          return FALSE;
  3942.       }
  3943.    }
  3944.  
  3945.    if (aip == NULL) {
  3946.       return FALSE;
  3947.    }
  3948.  
  3949.    atp = AsnLinkType(orig, BLAST0_SCORE_INFO);   /* link local tree */
  3950.    if (atp == NULL) {
  3951.       return FALSE;
  3952.    }
  3953.  
  3954.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  3955.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  3956.       goto erret;
  3957.    }
  3958.  
  3959.    av.intvalue = ptr -> sid;
  3960.    retval = AsnWrite(aip, BLAST0_SCORE_INFO_sid,  &av);
  3961.    if (ptr -> tag != NULL) {
  3962.       av.ptrvalue = ptr -> tag;
  3963.       retval = AsnWrite(aip, BLAST0_SCORE_INFO_tag,  &av);
  3964.    }
  3965.    if (ptr -> desc != NULL) {
  3966.       av.ptrvalue = ptr -> desc;
  3967.       retval = AsnWrite(aip, BLAST0_SCORE_INFO_desc,  &av);
  3968.    }
  3969.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  3970.       goto erret;
  3971.    }
  3972.    retval = TRUE;
  3973.  
  3974. erret:
  3975.    AsnUnlinkType(orig);       /* unlink local tree */
  3976.    return retval;
  3977. }
  3978.  
  3979.  
  3980.  
  3981. /**************************************************
  3982. *
  3983. *    BLAST0SeqUsageNew()
  3984. *
  3985. **************************************************/
  3986.  
  3987. BLAST0SeqUsagePtr LIBCALL
  3988. BLAST0SeqUsageNew(void)
  3989. {
  3990.    BLAST0SeqUsagePtr ptr = MemNew((size_t) sizeof(BLAST0SeqUsage));
  3991.  
  3992.    return ptr;
  3993.  
  3994. }
  3995.  
  3996.  
  3997. /**************************************************
  3998. *
  3999. *    BLAST0SeqUsageFree()
  4000. *
  4001. **************************************************/
  4002.  
  4003. BLAST0SeqUsagePtr LIBCALL
  4004. BLAST0SeqUsageFree(BLAST0SeqUsagePtr ptr)
  4005. {
  4006.  
  4007.    if(ptr == NULL) {
  4008.       return NULL;
  4009.    }
  4010.    return MemFree(ptr);
  4011. }
  4012.  
  4013.  
  4014. /**************************************************
  4015. *
  4016. *    BLAST0SeqUsageAsnRead()
  4017. *
  4018. **************************************************/
  4019.  
  4020. BLAST0SeqUsagePtr LIBCALL
  4021. BLAST0SeqUsageAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4022. {
  4023.    DataVal av;
  4024.    AsnTypePtr atp;
  4025.    Boolean isError = FALSE;
  4026.    AsnReadFunc func;
  4027.    BLAST0SeqUsagePtr ptr;
  4028.  
  4029.    if (! loaded)
  4030.    {
  4031.       if (! objblst2AsnLoad()) {
  4032.          return NULL;
  4033.       }
  4034.    }
  4035.  
  4036.    if (aip == NULL) {
  4037.       return NULL;
  4038.    }
  4039.  
  4040.    if (orig == NULL) {         /* BLAST0SeqUsage ::= (self contained) */
  4041.       atp = AsnReadId(aip, amp, BLAST0_SEQ_USAGE);
  4042.    } else {
  4043.       atp = AsnLinkType(orig, BLAST0_SEQ_USAGE);
  4044.    }
  4045.    /* link in local tree */
  4046.    if (atp == NULL) {
  4047.       return NULL;
  4048.    }
  4049.  
  4050.    ptr = BLAST0SeqUsageNew();
  4051.    if (ptr == NULL) {
  4052.       goto erret;
  4053.    }
  4054.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4055.       goto erret;
  4056.    }
  4057.  
  4058.    atp = AsnReadId(aip,amp, atp);
  4059.    func = NULL;
  4060.  
  4061.    if (atp == BLAST0_SEQ_USAGE_raw) {
  4062.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4063.          goto erret;
  4064.       }
  4065.       ptr -> raw = av.intvalue;
  4066.       atp = AsnReadId(aip,amp, atp);
  4067.    }
  4068.    if (atp == BLAST0_SEQ_USAGE_cooked) {
  4069.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4070.          goto erret;
  4071.       }
  4072.       ptr -> cooked = av.intvalue;
  4073.       atp = AsnReadId(aip,amp, atp);
  4074.    }
  4075.  
  4076.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4077.       goto erret;
  4078.    }
  4079.    /* end struct */
  4080.  
  4081. ret:
  4082.    AsnUnlinkType(orig);       /* unlink local tree */
  4083.    return ptr;
  4084.  
  4085. erret:
  4086.    aip -> io_failure = TRUE;
  4087.    ptr = BLAST0SeqUsageFree(ptr);
  4088.    goto ret;
  4089. }
  4090.  
  4091.  
  4092.  
  4093. /**************************************************
  4094. *
  4095. *    BLAST0SeqUsageAsnWrite()
  4096. *
  4097. **************************************************/
  4098. Boolean LIBCALL 
  4099. BLAST0SeqUsageAsnWrite(BLAST0SeqUsagePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4100. {
  4101.    DataVal av;
  4102.    AsnTypePtr atp;
  4103.    Boolean retval = FALSE;
  4104.  
  4105.    if (! loaded)
  4106.    {
  4107.       if (! objblst2AsnLoad()) {
  4108.          return FALSE;
  4109.       }
  4110.    }
  4111.  
  4112.    if (aip == NULL) {
  4113.       return FALSE;
  4114.    }
  4115.  
  4116.    atp = AsnLinkType(orig, BLAST0_SEQ_USAGE);   /* link local tree */
  4117.    if (atp == NULL) {
  4118.       return FALSE;
  4119.    }
  4120.  
  4121.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  4122.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  4123.       goto erret;
  4124.    }
  4125.  
  4126.    av.intvalue = ptr -> raw;
  4127.    retval = AsnWrite(aip, BLAST0_SEQ_USAGE_raw,  &av);
  4128.    av.intvalue = ptr -> cooked;
  4129.    retval = AsnWrite(aip, BLAST0_SEQ_USAGE_cooked,  &av);
  4130.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  4131.       goto erret;
  4132.    }
  4133.    retval = TRUE;
  4134.  
  4135. erret:
  4136.    AsnUnlinkType(orig);       /* unlink local tree */
  4137.    return retval;
  4138. }
  4139.  
  4140.  
  4141.  
  4142. /**************************************************
  4143. *
  4144. *    BLAST0HistogramNew()
  4145. *
  4146. **************************************************/
  4147.  
  4148. BLAST0HistogramPtr LIBCALL
  4149. BLAST0HistogramNew(void)
  4150. {
  4151.    BLAST0HistogramPtr ptr = MemNew((size_t) sizeof(BLAST0Histogram));
  4152.  
  4153.    return ptr;
  4154.  
  4155. }
  4156.  
  4157.  
  4158. /**************************************************
  4159. *
  4160. *    BLAST0HistogramFree()
  4161. *
  4162. **************************************************/
  4163.  
  4164. BLAST0HistogramPtr LIBCALL
  4165. BLAST0HistogramFree(BLAST0HistogramPtr ptr)
  4166. {
  4167.  
  4168.    if(ptr == NULL) {
  4169.       return NULL;
  4170.    }
  4171.    AsnGenericUserSeqOfFree(ptr -> bar, (AsnOptFreeFunc) BLAST0HistogramBarFree);
  4172.    return MemFree(ptr);
  4173. }
  4174.  
  4175.  
  4176. /**************************************************
  4177. *
  4178. *    BLAST0HistogramAsnRead()
  4179. *
  4180. **************************************************/
  4181.  
  4182. BLAST0HistogramPtr LIBCALL
  4183. BLAST0HistogramAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4184. {
  4185.    DataVal av;
  4186.    AsnTypePtr atp;
  4187.    Boolean isError = FALSE;
  4188.    AsnReadFunc func;
  4189.    BLAST0HistogramPtr ptr;
  4190.  
  4191.    if (! loaded)
  4192.    {
  4193.       if (! objblst2AsnLoad()) {
  4194.          return NULL;
  4195.       }
  4196.    }
  4197.  
  4198.    if (aip == NULL) {
  4199.       return NULL;
  4200.    }
  4201.  
  4202.    if (orig == NULL) {         /* BLAST0Histogram ::= (self contained) */
  4203.       atp = AsnReadId(aip, amp, BLAST0_HISTOGRAM);
  4204.    } else {
  4205.       atp = AsnLinkType(orig, BLAST0_HISTOGRAM);
  4206.    }
  4207.    /* link in local tree */
  4208.    if (atp == NULL) {
  4209.       return NULL;
  4210.    }
  4211.  
  4212.    ptr = BLAST0HistogramNew();
  4213.    if (ptr == NULL) {
  4214.       goto erret;
  4215.    }
  4216.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4217.       goto erret;
  4218.    }
  4219.  
  4220.    atp = AsnReadId(aip,amp, atp);
  4221.    func = NULL;
  4222.  
  4223.    if (atp == BLAST0_HISTOGRAM_expect) {
  4224.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4225.          goto erret;
  4226.       }
  4227.       ptr -> expect = av.realvalue;
  4228.       atp = AsnReadId(aip,amp, atp);
  4229.    }
  4230.    if (atp == BLAST0_HISTOGRAM_observed) {
  4231.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4232.          goto erret;
  4233.       }
  4234.       ptr -> observed = av.intvalue;
  4235.       atp = AsnReadId(aip,amp, atp);
  4236.    }
  4237.    if (atp == BLAST0_HISTOGRAM_base) {
  4238.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4239.          goto erret;
  4240.       }
  4241.       ptr -> base = av.intvalue;
  4242.       atp = AsnReadId(aip,amp, atp);
  4243.    }
  4244.    if (atp == BLAST0_HISTOGRAM_nbars) {
  4245.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4246.          goto erret;
  4247.       }
  4248.       ptr -> nbars = av.intvalue;
  4249.       atp = AsnReadId(aip,amp, atp);
  4250.    }
  4251.    if (atp == BLAST0_HISTOGRAM_bar) {
  4252.       ptr -> bar = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0HistogramBarAsnRead, (AsnOptFreeFunc) BLAST0HistogramBarFree);
  4253.       if (isError && ptr -> bar == NULL) {
  4254.          goto erret;
  4255.       }
  4256.       atp = AsnReadId(aip,amp, atp);
  4257.    }
  4258.  
  4259.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4260.       goto erret;
  4261.    }
  4262.    /* end struct */
  4263.  
  4264. ret:
  4265.    AsnUnlinkType(orig);       /* unlink local tree */
  4266.    return ptr;
  4267.  
  4268. erret:
  4269.    aip -> io_failure = TRUE;
  4270.    ptr = BLAST0HistogramFree(ptr);
  4271.    goto ret;
  4272. }
  4273.  
  4274.  
  4275.  
  4276. /**************************************************
  4277. *
  4278. *    BLAST0HistogramAsnWrite()
  4279. *
  4280. **************************************************/
  4281. Boolean LIBCALL 
  4282. BLAST0HistogramAsnWrite(BLAST0HistogramPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4283. {
  4284.    DataVal av;
  4285.    AsnTypePtr atp;
  4286.    Boolean retval = FALSE;
  4287.  
  4288.    if (! loaded)
  4289.    {
  4290.       if (! objblst2AsnLoad()) {
  4291.          return FALSE;
  4292.       }
  4293.    }
  4294.  
  4295.    if (aip == NULL) {
  4296.       return FALSE;
  4297.    }
  4298.  
  4299.    atp = AsnLinkType(orig, BLAST0_HISTOGRAM);   /* link local tree */
  4300.    if (atp == NULL) {
  4301.       return FALSE;
  4302.    }
  4303.  
  4304.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  4305.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  4306.       goto erret;
  4307.    }
  4308.  
  4309.    av.realvalue = ptr -> expect;
  4310.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_expect,  &av);
  4311.    av.intvalue = ptr -> observed;
  4312.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_observed,  &av);
  4313.    av.intvalue = ptr -> base;
  4314.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_base,  &av);
  4315.    av.intvalue = ptr -> nbars;
  4316.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_nbars,  &av);
  4317.    AsnGenericUserSeqOfAsnWrite(ptr -> bar, (AsnWriteFunc) BLAST0HistogramBarAsnWrite, aip, BLAST0_HISTOGRAM_bar, BLAST0_HISTOGRAM_bar_E);
  4318.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  4319.       goto erret;
  4320.    }
  4321.    retval = TRUE;
  4322.  
  4323. erret:
  4324.    AsnUnlinkType(orig);       /* unlink local tree */
  4325.    return retval;
  4326. }
  4327.  
  4328.  
  4329.  
  4330. /**************************************************
  4331. *
  4332. *    BLAST0HitListNew()
  4333. *
  4334. **************************************************/
  4335.  
  4336. BLAST0HitListPtr LIBCALL
  4337. BLAST0HitListNew(void)
  4338. {
  4339.    BLAST0HitListPtr ptr = MemNew((size_t) sizeof(BLAST0HitList));
  4340.  
  4341.    return ptr;
  4342.  
  4343. }
  4344.  
  4345.  
  4346. /**************************************************
  4347. *
  4348. *    BLAST0HitListFree()
  4349. *
  4350. **************************************************/
  4351.  
  4352. BLAST0HitListPtr LIBCALL
  4353. BLAST0HitListFree(BLAST0HitListPtr ptr)
  4354. {
  4355.  
  4356.    if(ptr == NULL) {
  4357.       return NULL;
  4358.    }
  4359.    AsnGenericUserSeqOfFree(ptr -> kablk, (AsnOptFreeFunc) BLAST0KABlkFree);
  4360.    AsnGenericUserSeqOfFree(ptr -> hsps, (AsnOptFreeFunc) BLAST0HSPFree);
  4361.    AsnGenericUserSeqOfFree(ptr -> seqs, (AsnOptFreeFunc) BLAST0SequenceFree);
  4362.    return MemFree(ptr);
  4363. }
  4364.  
  4365.  
  4366. /**************************************************
  4367. *
  4368. *    BLAST0HitListAsnRead()
  4369. *
  4370. **************************************************/
  4371.  
  4372. BLAST0HitListPtr LIBCALL
  4373. BLAST0HitListAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4374. {
  4375.    DataVal av;
  4376.    AsnTypePtr atp;
  4377.    Boolean isError = FALSE;
  4378.    AsnReadFunc func;
  4379.    BLAST0HitListPtr ptr;
  4380.  
  4381.    if (! loaded)
  4382.    {
  4383.       if (! objblst2AsnLoad()) {
  4384.          return NULL;
  4385.       }
  4386.    }
  4387.  
  4388.    if (aip == NULL) {
  4389.       return NULL;
  4390.    }
  4391.  
  4392.    if (orig == NULL) {         /* BLAST0HitList ::= (self contained) */
  4393.       atp = AsnReadId(aip, amp, BLAST0_HITLIST);
  4394.    } else {
  4395.       atp = AsnLinkType(orig, BLAST0_HITLIST);
  4396.    }
  4397.    /* link in local tree */
  4398.    if (atp == NULL) {
  4399.       return NULL;
  4400.    }
  4401.  
  4402.    ptr = BLAST0HitListNew();
  4403.    if (ptr == NULL) {
  4404.       goto erret;
  4405.    }
  4406.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4407.       goto erret;
  4408.    }
  4409.  
  4410.    atp = AsnReadId(aip,amp, atp);
  4411.    func = NULL;
  4412.  
  4413.    if (atp == BLAST0_HITLIST_count) {
  4414.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4415.          goto erret;
  4416.       }
  4417.       ptr -> count = av.intvalue;
  4418.       atp = AsnReadId(aip,amp, atp);
  4419.    }
  4420.    if (atp == BLAST0_HITLIST_kablk) {
  4421.       ptr -> kablk = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0KABlkAsnRead, (AsnOptFreeFunc) BLAST0KABlkFree);
  4422.       if (isError && ptr -> kablk == NULL) {
  4423.          goto erret;
  4424.       }
  4425.       atp = AsnReadId(aip,amp, atp);
  4426.    }
  4427.    if (atp == BLAST0_HITLIST_hsps) {
  4428.       ptr -> hsps = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0HSPAsnRead, (AsnOptFreeFunc) BLAST0HSPFree);
  4429.       if (isError && ptr -> hsps == NULL) {
  4430.          goto erret;
  4431.       }
  4432.       atp = AsnReadId(aip,amp, atp);
  4433.    }
  4434.    if (atp == BLAST0_HITLIST_seqs) {
  4435.       ptr -> seqs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0SequenceAsnRead, (AsnOptFreeFunc) BLAST0SequenceFree);
  4436.       if (isError && ptr -> seqs == NULL) {
  4437.          goto erret;
  4438.       }
  4439.       atp = AsnReadId(aip,amp, atp);
  4440.    }
  4441.  
  4442.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4443.       goto erret;
  4444.    }
  4445.    /* end struct */
  4446.  
  4447. ret:
  4448.    AsnUnlinkType(orig);       /* unlink local tree */
  4449.    return ptr;
  4450.  
  4451. erret:
  4452.    aip -> io_failure = TRUE;
  4453.    ptr = BLAST0HitListFree(ptr);
  4454.    goto ret;
  4455. }
  4456.  
  4457.  
  4458.  
  4459. /**************************************************
  4460. *
  4461. *    BLAST0HitListAsnWrite()
  4462. *
  4463. **************************************************/
  4464. Boolean LIBCALL 
  4465. BLAST0HitListAsnWrite(BLAST0HitListPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4466. {
  4467.    DataVal av;
  4468.    AsnTypePtr atp;
  4469.    Boolean retval = FALSE;
  4470.  
  4471.    if (! loaded)
  4472.    {
  4473.       if (! objblst2AsnLoad()) {
  4474.          return FALSE;
  4475.       }
  4476.    }
  4477.  
  4478.    if (aip == NULL) {
  4479.       return FALSE;
  4480.    }
  4481.  
  4482.    atp = AsnLinkType(orig, BLAST0_HITLIST);   /* link local tree */
  4483.    if (atp == NULL) {
  4484.       return FALSE;
  4485.    }
  4486.  
  4487.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  4488.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  4489.       goto erret;
  4490.    }
  4491.  
  4492.    av.intvalue = ptr -> count;
  4493.    retval = AsnWrite(aip, BLAST0_HITLIST_count,  &av);
  4494.    AsnGenericUserSeqOfAsnWrite(ptr -> kablk, (AsnWriteFunc) BLAST0KABlkAsnWrite, aip, BLAST0_HITLIST_kablk, BLAST0_HITLIST_kablk_E);
  4495.    AsnGenericUserSeqOfAsnWrite(ptr -> hsps, (AsnWriteFunc) BLAST0HSPAsnWrite, aip, BLAST0_HITLIST_hsps, BLAST0_HITLIST_hsps_E);
  4496.    AsnGenericUserSeqOfAsnWrite(ptr -> seqs, (AsnWriteFunc) BLAST0SequenceAsnWrite, aip, BLAST0_HITLIST_seqs, BLAST0_HITLIST_seqs_E);
  4497.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  4498.       goto erret;
  4499.    }
  4500.    retval = TRUE;
  4501.  
  4502. erret:
  4503.    AsnUnlinkType(orig);       /* unlink local tree */
  4504.    return retval;
  4505. }
  4506.  
  4507.  
  4508.  
  4509. /**************************************************
  4510. *
  4511. *    BLAST0HistogramBarNew()
  4512. *
  4513. **************************************************/
  4514.  
  4515. BLAST0HistogramBarPtr LIBCALL
  4516. BLAST0HistogramBarNew(void)
  4517. {
  4518.    BLAST0HistogramBarPtr ptr = MemNew((size_t) sizeof(BLAST0HistogramBar));
  4519.  
  4520.    return ptr;
  4521.  
  4522. }
  4523.  
  4524.  
  4525. /**************************************************
  4526. *
  4527. *    BLAST0HistogramBarFree()
  4528. *
  4529. **************************************************/
  4530.  
  4531. BLAST0HistogramBarPtr LIBCALL
  4532. BLAST0HistogramBarFree(BLAST0HistogramBarPtr ptr)
  4533. {
  4534.  
  4535.    if(ptr == NULL) {
  4536.       return NULL;
  4537.    }
  4538.    return MemFree(ptr);
  4539. }
  4540.  
  4541.  
  4542. /**************************************************
  4543. *
  4544. *    BLAST0HistogramBarAsnRead()
  4545. *
  4546. **************************************************/
  4547.  
  4548. BLAST0HistogramBarPtr LIBCALL
  4549. BLAST0HistogramBarAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4550. {
  4551.    DataVal av;
  4552.    AsnTypePtr atp;
  4553.    Boolean isError = FALSE;
  4554.    AsnReadFunc func;
  4555.    BLAST0HistogramBarPtr ptr;
  4556.  
  4557.    if (! loaded)
  4558.    {
  4559.       if (! objblst2AsnLoad()) {
  4560.          return NULL;
  4561.       }
  4562.    }
  4563.  
  4564.    if (aip == NULL) {
  4565.       return NULL;
  4566.    }
  4567.  
  4568.    if (orig == NULL) {         /* BLAST0HistogramBar ::= (self contained) */
  4569.       atp = AsnReadId(aip, amp, BLAST0_HISTOGRAM_BAR);
  4570.    } else {
  4571.       atp = AsnLinkType(orig, BLAST0_HISTOGRAM_BAR);
  4572.    }
  4573.    /* link in local tree */
  4574.    if (atp == NULL) {
  4575.       return NULL;
  4576.    }
  4577.  
  4578.    ptr = BLAST0HistogramBarNew();
  4579.    if (ptr == NULL) {
  4580.       goto erret;
  4581.    }
  4582.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4583.       goto erret;
  4584.    }
  4585.  
  4586.    atp = AsnReadId(aip,amp, atp);
  4587.    func = NULL;
  4588.  
  4589.    if (atp == BLAST0_HISTOGRAM_BAR_x) {
  4590.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4591.          goto erret;
  4592.       }
  4593.       ptr -> x = av.realvalue;
  4594.       atp = AsnReadId(aip,amp, atp);
  4595.    }
  4596.    if (atp == BLAST0_HISTOGRAM_BAR_n) {
  4597.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4598.          goto erret;
  4599.       }
  4600.       ptr -> n = av.intvalue;
  4601.       atp = AsnReadId(aip,amp, atp);
  4602.    }
  4603.  
  4604.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4605.       goto erret;
  4606.    }
  4607.    /* end struct */
  4608.  
  4609. ret:
  4610.    AsnUnlinkType(orig);       /* unlink local tree */
  4611.    return ptr;
  4612.  
  4613. erret:
  4614.    aip -> io_failure = TRUE;
  4615.    ptr = BLAST0HistogramBarFree(ptr);
  4616.    goto ret;
  4617. }
  4618.  
  4619.  
  4620.  
  4621. /**************************************************
  4622. *
  4623. *    BLAST0HistogramBarAsnWrite()
  4624. *
  4625. **************************************************/
  4626. Boolean LIBCALL 
  4627. BLAST0HistogramBarAsnWrite(BLAST0HistogramBarPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4628. {
  4629.    DataVal av;
  4630.    AsnTypePtr atp;
  4631.    Boolean retval = FALSE;
  4632.  
  4633.    if (! loaded)
  4634.    {
  4635.       if (! objblst2AsnLoad()) {
  4636.          return FALSE;
  4637.       }
  4638.    }
  4639.  
  4640.    if (aip == NULL) {
  4641.       return FALSE;
  4642.    }
  4643.  
  4644.    atp = AsnLinkType(orig, BLAST0_HISTOGRAM_BAR);   /* link local tree */
  4645.    if (atp == NULL) {
  4646.       return FALSE;
  4647.    }
  4648.  
  4649.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  4650.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  4651.       goto erret;
  4652.    }
  4653.  
  4654.    av.realvalue = ptr -> x;
  4655.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_BAR_x,  &av);
  4656.    av.intvalue = ptr -> n;
  4657.    retval = AsnWrite(aip, BLAST0_HISTOGRAM_BAR_n,  &av);
  4658.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  4659.       goto erret;
  4660.    }
  4661.    retval = TRUE;
  4662.  
  4663. erret:
  4664.    AsnUnlinkType(orig);       /* unlink local tree */
  4665.    return retval;
  4666. }
  4667.  
  4668.  
  4669.  
  4670. /**************************************************
  4671. *
  4672. *    BLAST0HSPNew()
  4673. *
  4674. **************************************************/
  4675.  
  4676. BLAST0HSPPtr LIBCALL
  4677. BLAST0HSPNew(void)
  4678. {
  4679.    BLAST0HSPPtr ptr = MemNew((size_t) sizeof(BLAST0HSP));
  4680.  
  4681.    return ptr;
  4682.  
  4683. }
  4684.  
  4685.  
  4686. /**************************************************
  4687. *
  4688. *    BLAST0HSPFree()
  4689. *
  4690. **************************************************/
  4691.  
  4692. BLAST0HSPPtr LIBCALL
  4693. BLAST0HSPFree(BLAST0HSPPtr ptr)
  4694. {
  4695.  
  4696.    if(ptr == NULL) {
  4697.       return NULL;
  4698.    }
  4699.    ScoreSetFree(ptr -> scores);
  4700.    AsnGenericUserSeqOfFree(ptr -> segs, (AsnOptFreeFunc) BLAST0SegmentFree);
  4701.    return MemFree(ptr);
  4702. }
  4703.  
  4704.  
  4705. /**************************************************
  4706. *
  4707. *    BLAST0HSPAsnRead()
  4708. *
  4709. **************************************************/
  4710.  
  4711. BLAST0HSPPtr LIBCALL
  4712. BLAST0HSPAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4713. {
  4714.    DataVal av;
  4715.    AsnTypePtr atp;
  4716.    Boolean isError = FALSE;
  4717.    AsnReadFunc func;
  4718.    BLAST0HSPPtr ptr;
  4719.  
  4720.    if (! loaded)
  4721.    {
  4722.       if (! objblst2AsnLoad()) {
  4723.          return NULL;
  4724.       }
  4725.    }
  4726.  
  4727.    if (aip == NULL) {
  4728.       return NULL;
  4729.    }
  4730.  
  4731.    if (orig == NULL) {         /* BLAST0HSP ::= (self contained) */
  4732.       atp = AsnReadId(aip, amp, BLAST0_HSP);
  4733.    } else {
  4734.       atp = AsnLinkType(orig, BLAST0_HSP);
  4735.    }
  4736.    /* link in local tree */
  4737.    if (atp == NULL) {
  4738.       return NULL;
  4739.    }
  4740.  
  4741.    ptr = BLAST0HSPNew();
  4742.    if (ptr == NULL) {
  4743.       goto erret;
  4744.    }
  4745.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4746.       goto erret;
  4747.    }
  4748.  
  4749.    atp = AsnReadId(aip,amp, atp);
  4750.    func = NULL;
  4751.  
  4752.    if (atp == BLAST0_HSP_matid) {
  4753.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4754.          goto erret;
  4755.       }
  4756.       ptr -> matid = av.intvalue;
  4757.       atp = AsnReadId(aip,amp, atp);
  4758.    }
  4759.    if (atp == BLAST0_HSP_scores) {
  4760.       ptr -> scores = ScoreSetAsnRead(aip, atp);
  4761.       if (aip -> io_failure) {
  4762.          goto erret;
  4763.       }
  4764.       atp = AsnReadId(aip,amp, atp);
  4765.    }
  4766.    if (atp == BLAST0_HSP_len) {
  4767.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  4768.          goto erret;
  4769.       }
  4770.       ptr -> len = av.intvalue;
  4771.       atp = AsnReadId(aip,amp, atp);
  4772.    }
  4773.    if (atp == BLAST0_HSP_segs) {
  4774.       ptr -> segs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BLAST0SegmentAsnRead, (AsnOptFreeFunc) BLAST0SegmentFree);
  4775.       if (isError && ptr -> segs == NULL) {
  4776.          goto erret;
  4777.       }
  4778.       atp = AsnReadId(aip,amp, atp);
  4779.    }
  4780.  
  4781.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4782.       goto erret;
  4783.    }
  4784.    /* end struct */
  4785.  
  4786. ret:
  4787.    AsnUnlinkType(orig);       /* unlink local tree */
  4788.    return ptr;
  4789.  
  4790. erret:
  4791.    aip -> io_failure = TRUE;
  4792.    ptr = BLAST0HSPFree(ptr);
  4793.    goto ret;
  4794. }
  4795.  
  4796.  
  4797.  
  4798. /**************************************************
  4799. *
  4800. *    BLAST0HSPAsnWrite()
  4801. *
  4802. **************************************************/
  4803. Boolean LIBCALL 
  4804. BLAST0HSPAsnWrite(BLAST0HSPPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4805. {
  4806.    DataVal av;
  4807.    AsnTypePtr atp;
  4808.    Boolean retval = FALSE;
  4809.  
  4810.    if (! loaded)
  4811.    {
  4812.       if (! objblst2AsnLoad()) {
  4813.          return FALSE;
  4814.       }
  4815.    }
  4816.  
  4817.    if (aip == NULL) {
  4818.       return FALSE;
  4819.    }
  4820.  
  4821.    atp = AsnLinkType(orig, BLAST0_HSP);   /* link local tree */
  4822.    if (atp == NULL) {
  4823.       return FALSE;
  4824.    }
  4825.  
  4826.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  4827.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  4828.       goto erret;
  4829.    }
  4830.  
  4831.    av.intvalue = ptr -> matid;
  4832.    retval = AsnWrite(aip, BLAST0_HSP_matid,  &av);
  4833.    if (ptr -> scores != NULL) {
  4834.       if ( ! ScoreSetAsnWrite(ptr -> scores, aip, BLAST0_HSP_scores)) {
  4835.          goto erret;
  4836.       }
  4837.    }
  4838.    av.intvalue = ptr -> len;
  4839.    retval = AsnWrite(aip, BLAST0_HSP_len,  &av);
  4840.    AsnGenericUserSeqOfAsnWrite(ptr -> segs, (AsnWriteFunc) BLAST0SegmentAsnWrite, aip, BLAST0_HSP_segs, BLAST0_HSP_segs_E);
  4841.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  4842.       goto erret;
  4843.    }
  4844.    retval = TRUE;
  4845.  
  4846. erret:
  4847.    AsnUnlinkType(orig);       /* unlink local tree */
  4848.    return retval;
  4849. }
  4850.  
  4851.  
  4852.  
  4853. /**************************************************
  4854. *
  4855. *    BLAST0SegmentNew()
  4856. *
  4857. **************************************************/
  4858.  
  4859. BLAST0SegmentPtr LIBCALL
  4860. BLAST0SegmentNew(void)
  4861. {
  4862.    BLAST0SegmentPtr ptr = MemNew((size_t) sizeof(BLAST0Segment));
  4863.  
  4864.    return ptr;
  4865.  
  4866. }
  4867.  
  4868.  
  4869. /**************************************************
  4870. *
  4871. *    BLAST0SegmentFree()
  4872. *
  4873. **************************************************/
  4874.  
  4875. BLAST0SegmentPtr LIBCALL
  4876. BLAST0SegmentFree(BLAST0SegmentPtr ptr)
  4877. {
  4878.  
  4879.    if(ptr == NULL) {
  4880.       return NULL;
  4881.    }
  4882.    BLAST0SeqIntervalFree(ptr -> loc);
  4883.    BLAST0SeqDataFree(ptr -> str);
  4884.    BLAST0SeqDataFree(ptr -> str_raw);
  4885.    return MemFree(ptr);
  4886. }
  4887.  
  4888.  
  4889. /**************************************************
  4890. *
  4891. *    BLAST0SegmentAsnRead()
  4892. *
  4893. **************************************************/
  4894.  
  4895. BLAST0SegmentPtr LIBCALL
  4896. BLAST0SegmentAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  4897. {
  4898.    DataVal av;
  4899.    AsnTypePtr atp;
  4900.    Boolean isError = FALSE;
  4901.    AsnReadFunc func;
  4902.    BLAST0SegmentPtr ptr;
  4903.  
  4904.    if (! loaded)
  4905.    {
  4906.       if (! objblst2AsnLoad()) {
  4907.          return NULL;
  4908.       }
  4909.    }
  4910.  
  4911.    if (aip == NULL) {
  4912.       return NULL;
  4913.    }
  4914.  
  4915.    if (orig == NULL) {         /* BLAST0Segment ::= (self contained) */
  4916.       atp = AsnReadId(aip, amp, BLAST0_SEGMENT);
  4917.    } else {
  4918.       atp = AsnLinkType(orig, BLAST0_SEGMENT);
  4919.    }
  4920.    /* link in local tree */
  4921.    if (atp == NULL) {
  4922.       return NULL;
  4923.    }
  4924.  
  4925.    ptr = BLAST0SegmentNew();
  4926.    if (ptr == NULL) {
  4927.       goto erret;
  4928.    }
  4929.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  4930.       goto erret;
  4931.    }
  4932.  
  4933.    atp = AsnReadId(aip,amp, atp);
  4934.    func = NULL;
  4935.  
  4936.    if (atp == BLAST0_SEGMENT_loc) {
  4937.       ptr -> loc = BLAST0SeqIntervalAsnRead(aip, atp);
  4938.       if (aip -> io_failure) {
  4939.          goto erret;
  4940.       }
  4941.       atp = AsnReadId(aip,amp, atp);
  4942.    }
  4943.    if (atp == BLAST0_SEGMENT_str) {
  4944.       ptr -> str = BLAST0SeqDataAsnRead(aip, atp);
  4945.       if (aip -> io_failure) {
  4946.          goto erret;
  4947.       }
  4948.       atp = AsnReadId(aip,amp, atp);
  4949.    }
  4950.    if (atp == BLAST0_SEGMENT_str_raw) {
  4951.       ptr -> str_raw = BLAST0SeqDataAsnRead(aip, atp);
  4952.       if (aip -> io_failure) {
  4953.          goto erret;
  4954.       }
  4955.       atp = AsnReadId(aip,amp, atp);
  4956.    }
  4957.  
  4958.    if (AsnReadVal(aip, atp, &av) <= 0) {
  4959.       goto erret;
  4960.    }
  4961.    /* end struct */
  4962.  
  4963. ret:
  4964.    AsnUnlinkType(orig);       /* unlink local tree */
  4965.    return ptr;
  4966.  
  4967. erret:
  4968.    aip -> io_failure = TRUE;
  4969.    ptr = BLAST0SegmentFree(ptr);
  4970.    goto ret;
  4971. }
  4972.  
  4973.  
  4974.  
  4975. /**************************************************
  4976. *
  4977. *    BLAST0SegmentAsnWrite()
  4978. *
  4979. **************************************************/
  4980. Boolean LIBCALL 
  4981. BLAST0SegmentAsnWrite(BLAST0SegmentPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  4982. {
  4983.    DataVal av;
  4984.    AsnTypePtr atp;
  4985.    Boolean retval = FALSE;
  4986.  
  4987.    if (! loaded)
  4988.    {
  4989.       if (! objblst2AsnLoad()) {
  4990.          return FALSE;
  4991.       }
  4992.    }
  4993.  
  4994.    if (aip == NULL) {
  4995.       return FALSE;
  4996.    }
  4997.  
  4998.    atp = AsnLinkType(orig, BLAST0_SEGMENT);   /* link local tree */
  4999.    if (atp == NULL) {
  5000.       return FALSE;
  5001.    }
  5002.  
  5003.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5004.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  5005.       goto erret;
  5006.    }
  5007.  
  5008.    if (ptr -> loc != NULL) {
  5009.       if ( ! BLAST0SeqIntervalAsnWrite(ptr -> loc, aip, BLAST0_SEGMENT_loc)) {
  5010.          goto erret;
  5011.       }
  5012.    }
  5013.    if (ptr -> str != NULL) {
  5014.       if ( ! BLAST0SeqDataAsnWrite(ptr -> str, aip, BLAST0_SEGMENT_str)) {
  5015.          goto erret;
  5016.       }
  5017.    }
  5018.    if (ptr -> str_raw != NULL) {
  5019.       if ( ! BLAST0SeqDataAsnWrite(ptr -> str_raw, aip, BLAST0_SEGMENT_str_raw)) {
  5020.          goto erret;
  5021.       }
  5022.    }
  5023.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  5024.       goto erret;
  5025.    }
  5026.    retval = TRUE;
  5027.  
  5028. erret:
  5029.    AsnUnlinkType(orig);       /* unlink local tree */
  5030.    return retval;
  5031. }
  5032.  
  5033.  
  5034.  
  5035. /**************************************************
  5036. *
  5037. *    BLAST0SeqIntervalNew()
  5038. *
  5039. **************************************************/
  5040.  
  5041. BLAST0SeqIntervalPtr LIBCALL
  5042. BLAST0SeqIntervalNew(void)
  5043. {
  5044.    BLAST0SeqIntervalPtr ptr = MemNew((size_t) sizeof(BLAST0SeqInterval));
  5045.  
  5046.    return ptr;
  5047.  
  5048. }
  5049.  
  5050.  
  5051. /**************************************************
  5052. *
  5053. *    BLAST0SeqIntervalFree()
  5054. *
  5055. **************************************************/
  5056.  
  5057. BLAST0SeqIntervalPtr LIBCALL
  5058. BLAST0SeqIntervalFree(BLAST0SeqIntervalPtr ptr)
  5059. {
  5060.  
  5061.    if(ptr == NULL) {
  5062.       return NULL;
  5063.    }
  5064.    return MemFree(ptr);
  5065. }
  5066.  
  5067.  
  5068. /**************************************************
  5069. *
  5070. *    BLAST0SeqIntervalAsnRead()
  5071. *
  5072. **************************************************/
  5073.  
  5074. BLAST0SeqIntervalPtr LIBCALL
  5075. BLAST0SeqIntervalAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  5076. {
  5077.    DataVal av;
  5078.    AsnTypePtr atp;
  5079.    Boolean isError = FALSE;
  5080.    AsnReadFunc func;
  5081.    BLAST0SeqIntervalPtr ptr;
  5082.  
  5083.    if (! loaded)
  5084.    {
  5085.       if (! objblst2AsnLoad()) {
  5086.          return NULL;
  5087.       }
  5088.    }
  5089.  
  5090.    if (aip == NULL) {
  5091.       return NULL;
  5092.    }
  5093.  
  5094.    if (orig == NULL) {         /* BLAST0SeqInterval ::= (self contained) */
  5095.       atp = AsnReadId(aip, amp, BLAST0_SEQ_INTERVAL);
  5096.    } else {
  5097.       atp = AsnLinkType(orig, BLAST0_SEQ_INTERVAL);
  5098.    }
  5099.    /* link in local tree */
  5100.    if (atp == NULL) {
  5101.       return NULL;
  5102.    }
  5103.  
  5104.    ptr = BLAST0SeqIntervalNew();
  5105.    if (ptr == NULL) {
  5106.       goto erret;
  5107.    }
  5108.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  5109.       goto erret;
  5110.    }
  5111.  
  5112.    atp = AsnReadId(aip,amp, atp);
  5113.    func = NULL;
  5114.  
  5115.    if (atp == BLAST0_SEQ_INTERVAL_strand) {
  5116.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  5117.          goto erret;
  5118.       }
  5119.       ptr -> strand = av.intvalue;
  5120.       ptr -> OBbits__ |= 1<<0;
  5121.       atp = AsnReadId(aip,amp, atp);
  5122.    }
  5123.    if (atp == BLAST0_SEQ_INTERVAL_from) {
  5124.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  5125.          goto erret;
  5126.       }
  5127.       ptr -> from = av.intvalue;
  5128.       atp = AsnReadId(aip,amp, atp);
  5129.    }
  5130.    if (atp == BLAST0_SEQ_INTERVAL_to) {
  5131.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  5132.          goto erret;
  5133.       }
  5134.       ptr -> to = av.intvalue;
  5135.       atp = AsnReadId(aip,amp, atp);
  5136.    }
  5137.  
  5138.    if (AsnReadVal(aip, atp, &av) <= 0) {
  5139.       goto erret;
  5140.    }
  5141.    /* end struct */
  5142.  
  5143. ret:
  5144.    AsnUnlinkType(orig);       /* unlink local tree */
  5145.    return ptr;
  5146.  
  5147. erret:
  5148.    aip -> io_failure = TRUE;
  5149.    ptr = BLAST0SeqIntervalFree(ptr);
  5150.    goto ret;
  5151. }
  5152.  
  5153.  
  5154.  
  5155. /**************************************************
  5156. *
  5157. *    BLAST0SeqIntervalAsnWrite()
  5158. *
  5159. **************************************************/
  5160. Boolean LIBCALL 
  5161. BLAST0SeqIntervalAsnWrite(BLAST0SeqIntervalPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  5162. {
  5163.    DataVal av;
  5164.    AsnTypePtr atp;
  5165.    Boolean retval = FALSE;
  5166.  
  5167.    if (! loaded)
  5168.    {
  5169.       if (! objblst2AsnLoad()) {
  5170.          return FALSE;
  5171.       }
  5172.    }
  5173.  
  5174.    if (aip == NULL) {
  5175.       return FALSE;
  5176.    }
  5177.  
  5178.    atp = AsnLinkType(orig, BLAST0_SEQ_INTERVAL);   /* link local tree */
  5179.    if (atp == NULL) {
  5180.       return FALSE;
  5181.    }
  5182.  
  5183.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5184.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  5185.       goto erret;
  5186.    }
  5187.  
  5188.    if (ptr -> strand || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> strand;
  5189.       retval = AsnWrite(aip, BLAST0_SEQ_INTERVAL_strand,  &av);
  5190.    }
  5191.    av.intvalue = ptr -> from;
  5192.    retval = AsnWrite(aip, BLAST0_SEQ_INTERVAL_from,  &av);
  5193.    av.intvalue = ptr -> to;
  5194.    retval = AsnWrite(aip, BLAST0_SEQ_INTERVAL_to,  &av);
  5195.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  5196.       goto erret;
  5197.    }
  5198.    retval = TRUE;
  5199.  
  5200. erret:
  5201.    AsnUnlinkType(orig);       /* unlink local tree */
  5202.    return retval;
  5203. }
  5204.  
  5205.  
  5206.  
  5207. /**************************************************
  5208. *
  5209. *    BLAST0SeqDataFree()
  5210. *
  5211. **************************************************/
  5212.  
  5213. BLAST0SeqDataPtr LIBCALL
  5214. BLAST0SeqDataFree(ValNodePtr anp)
  5215. {
  5216.    Pointer pnt;
  5217.  
  5218.    if (anp == NULL) {
  5219.       return NULL;
  5220.    }
  5221.  
  5222.    pnt = anp->data.ptrvalue;
  5223.    switch (anp->choice)
  5224.    {
  5225.    default:
  5226.       break;
  5227.    case BLAST0SeqData_ncbistdaa:
  5228.       BSFree(anp -> data.ptrvalue);
  5229.       break;
  5230.    case BLAST0SeqData_ncbi2na:
  5231.       BSFree(anp -> data.ptrvalue);
  5232.       break;
  5233.    case BLAST0SeqData_ncbi4na:
  5234.       BSFree(anp -> data.ptrvalue);
  5235.       break;
  5236.    }
  5237.    return MemFree(anp);
  5238. }
  5239.  
  5240.  
  5241. /**************************************************
  5242. *
  5243. *    BLAST0SeqDataAsnRead()
  5244. *
  5245. **************************************************/
  5246.  
  5247. BLAST0SeqDataPtr LIBCALL
  5248. BLAST0SeqDataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  5249. {
  5250.    DataVal av;
  5251.    AsnTypePtr atp;
  5252.    ValNodePtr anp;
  5253.    Uint1 choice;
  5254.    Boolean isError = FALSE;
  5255.    Boolean nullIsError = FALSE;
  5256.    AsnReadFunc func;
  5257.  
  5258.    if (! loaded)
  5259.    {
  5260.       if (! objblst2AsnLoad()) {
  5261.          return NULL;
  5262.       }
  5263.    }
  5264.  
  5265.    if (aip == NULL) {
  5266.       return NULL;
  5267.    }
  5268.  
  5269.    if (orig == NULL) {         /* BLAST0SeqData ::= (self contained) */
  5270.       atp = AsnReadId(aip, amp, BLAST0_SEQ_DATA);
  5271.    } else {
  5272.       atp = AsnLinkType(orig, BLAST0_SEQ_DATA);    /* link in local tree */
  5273.    }
  5274.    if (atp == NULL) {
  5275.       return NULL;
  5276.    }
  5277.  
  5278.    anp = ValNodeNew(NULL);
  5279.    if (anp == NULL) {
  5280.       goto erret;
  5281.    }
  5282.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  5283.       goto erret;
  5284.    }
  5285.  
  5286.    func = NULL;
  5287.  
  5288.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  5289.    if (atp == NULL) {
  5290.       goto erret;
  5291.    }
  5292.    if (atp == BLAST0_SEQ_DATA_ncbistdaa) {
  5293.       choice = BLAST0SeqData_ncbistdaa;
  5294.       if (AsnReadVal(aip, atp, &av) <= 0) {
  5295.          goto erret;
  5296.       }
  5297.       anp->data.ptrvalue = av.ptrvalue;
  5298.    }
  5299.    else if (atp == BLAST0_SEQ_DATA_ncbi2na) {
  5300.       choice = BLAST0SeqData_ncbi2na;
  5301.       if (AsnReadVal(aip, atp, &av) <= 0) {
  5302.          goto erret;
  5303.       }
  5304.       anp->data.ptrvalue = av.ptrvalue;
  5305.    }
  5306.    else if (atp == BLAST0_SEQ_DATA_ncbi4na) {
  5307.       choice = BLAST0SeqData_ncbi4na;
  5308.       if (AsnReadVal(aip, atp, &av) <= 0) {
  5309.          goto erret;
  5310.       }
  5311.       anp->data.ptrvalue = av.ptrvalue;
  5312.    }
  5313.    anp->choice = choice;
  5314.    if (func != NULL)
  5315.    {
  5316.       anp->data.ptrvalue = (* func)(aip, atp);
  5317.       if (aip -> io_failure) goto erret;
  5318.  
  5319.       if (nullIsError && anp->data.ptrvalue == NULL) {
  5320.          goto erret;
  5321.       }
  5322.    }
  5323.  
  5324. ret:
  5325.    AsnUnlinkType(orig);       /* unlink local tree */
  5326.    return anp;
  5327.  
  5328. erret:
  5329.    anp = MemFree(anp);
  5330.    aip -> io_failure = TRUE;
  5331.    goto ret;
  5332. }
  5333.  
  5334.  
  5335. /**************************************************
  5336. *
  5337. *    BLAST0SeqDataAsnWrite()
  5338. *
  5339. **************************************************/
  5340. Boolean LIBCALL 
  5341. BLAST0SeqDataAsnWrite(BLAST0SeqDataPtr anp, AsnIoPtr aip, AsnTypePtr orig)
  5342.  
  5343. {
  5344.    DataVal av;
  5345.    AsnTypePtr atp, writetype = NULL;
  5346.    Pointer pnt;
  5347.    AsnWriteFunc func = NULL;
  5348.    Boolean retval = FALSE;
  5349.  
  5350.    if (! loaded)
  5351.    {
  5352.       if (! objblst2AsnLoad())
  5353.       return FALSE;
  5354.    }
  5355.  
  5356.    if (aip == NULL)
  5357.    return FALSE;
  5358.  
  5359.    atp = AsnLinkType(orig, BLAST0_SEQ_DATA);   /* link local tree */
  5360.    if (atp == NULL) {
  5361.       return FALSE;
  5362.    }
  5363.  
  5364.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5365.  
  5366.    av.ptrvalue = (Pointer)anp;
  5367.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  5368.       goto erret;
  5369.    }
  5370.  
  5371.    pnt = anp->data.ptrvalue;
  5372.    switch (anp->choice)
  5373.    {
  5374.    case BLAST0SeqData_ncbistdaa:
  5375.       av.ptrvalue = anp->data.ptrvalue;
  5376.       retval = AsnWrite(aip, BLAST0_SEQ_DATA_ncbistdaa, &av);
  5377.       break;
  5378.    case BLAST0SeqData_ncbi2na:
  5379.       av.ptrvalue = anp->data.ptrvalue;
  5380.       retval = AsnWrite(aip, BLAST0_SEQ_DATA_ncbi2na, &av);
  5381.       break;
  5382.    case BLAST0SeqData_ncbi4na:
  5383.       av.ptrvalue = anp->data.ptrvalue;
  5384.       retval = AsnWrite(aip, BLAST0_SEQ_DATA_ncbi4na, &av);
  5385.       break;
  5386.    }
  5387.    if (writetype != NULL) {
  5388.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  5389.    }
  5390.    if (!retval) {
  5391.       goto erret;
  5392.    }
  5393.    retval = TRUE;
  5394.  
  5395. erret:
  5396.    AsnUnlinkType(orig);       /* unlink local tree */
  5397.    return retval;
  5398. }
  5399.  
  5400.  
  5401. /**************************************************
  5402. *
  5403. *    BLAST0SeqDescNew()
  5404. *
  5405. **************************************************/
  5406.  
  5407. BLAST0SeqDescPtr LIBCALL
  5408. BLAST0SeqDescNew(void)
  5409. {
  5410.    BLAST0SeqDescPtr ptr = MemNew((size_t) sizeof(BLAST0SeqDesc));
  5411.  
  5412.    return ptr;
  5413.  
  5414. }
  5415.  
  5416.  
  5417. /**************************************************
  5418. *
  5419. *    BLAST0SeqDescFree()
  5420. *
  5421. **************************************************/
  5422.  
  5423. BLAST0SeqDescPtr LIBCALL
  5424. BLAST0SeqDescFree(BLAST0SeqDescPtr ptr)
  5425. {
  5426.  
  5427.    if(ptr == NULL) {
  5428.       return NULL;
  5429.    }
  5430.    BLAST0SeqIdFree(ptr -> id);
  5431.    MemFree(ptr -> defline);
  5432.    return MemFree(ptr);
  5433. }
  5434.  
  5435.  
  5436. /**************************************************
  5437. *
  5438. *    BLAST0SeqDescAsnRead()
  5439. *
  5440. **************************************************/
  5441.  
  5442. BLAST0SeqDescPtr LIBCALL
  5443. BLAST0SeqDescAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  5444. {
  5445.    DataVal av;
  5446.    AsnTypePtr atp;
  5447.    Boolean isError = FALSE;
  5448.    AsnReadFunc func;
  5449.    BLAST0SeqDescPtr ptr;
  5450.  
  5451.    if (! loaded)
  5452.    {
  5453.       if (! objblst2AsnLoad()) {
  5454.          return NULL;
  5455.       }
  5456.    }
  5457.  
  5458.    if (aip == NULL) {
  5459.       return NULL;
  5460.    }
  5461.  
  5462.    if (orig == NULL) {         /* BLAST0SeqDesc ::= (self contained) */
  5463.       atp = AsnReadId(aip, amp, BLAST0_SEQ_DESC);
  5464.    } else {
  5465.       atp = AsnLinkType(orig, BLAST0_SEQ_DESC);
  5466.    }
  5467.    /* link in local tree */
  5468.    if (atp == NULL) {
  5469.       return NULL;
  5470.    }
  5471.  
  5472.    ptr = BLAST0SeqDescNew();
  5473.    if (ptr == NULL) {
  5474.       goto erret;
  5475.    }
  5476.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
  5477.       goto erret;
  5478.    }
  5479.  
  5480.    atp = AsnReadId(aip,amp, atp);
  5481.    func = NULL;
  5482.  
  5483.    if (atp == BLAST0_SEQ_DESC_id) {
  5484.       ptr -> id = BLAST0SeqIdAsnRead(aip, atp);
  5485.       if (aip -> io_failure) {
  5486.          goto erret;
  5487.       }
  5488.       atp = AsnReadId(aip,amp, atp);
  5489.    }
  5490.    if (atp == BLAST0_SEQ_DESC_defline) {
  5491.       if ( AsnReadVal(aip, atp, &av) <= 0) {
  5492.          goto erret;
  5493.       }
  5494.       ptr -> defline = av.ptrvalue;
  5495.       atp = AsnReadId(aip,amp, atp);
  5496.    }
  5497.  
  5498.    if (AsnReadVal(aip, atp, &av) <= 0) {
  5499.       goto erret;
  5500.    }
  5501.    /* end struct */
  5502.  
  5503. ret:
  5504.    AsnUnlinkType(orig);       /* unlink local tree */
  5505.    return ptr;
  5506.  
  5507. erret:
  5508.    aip -> io_failure = TRUE;
  5509.    ptr = BLAST0SeqDescFree(ptr);
  5510.    goto ret;
  5511. }
  5512.  
  5513.  
  5514.  
  5515. /**************************************************
  5516. *
  5517. *    BLAST0SeqDescAsnWrite()
  5518. *
  5519. **************************************************/
  5520. Boolean LIBCALL 
  5521. BLAST0SeqDescAsnWrite(BLAST0SeqDescPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
  5522. {
  5523.    DataVal av;
  5524.    AsnTypePtr atp;
  5525.    Boolean retval = FALSE;
  5526.  
  5527.    if (! loaded)
  5528.    {
  5529.       if (! objblst2AsnLoad()) {
  5530.          return FALSE;
  5531.       }
  5532.    }
  5533.  
  5534.    if (aip == NULL) {
  5535.       return FALSE;
  5536.    }
  5537.  
  5538.    atp = AsnLinkType(orig, BLAST0_SEQ_DESC);   /* link local tree */
  5539.    if (atp == NULL) {
  5540.       return FALSE;
  5541.    }
  5542.  
  5543.    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5544.    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
  5545.       goto erret;
  5546.    }
  5547.  
  5548.    if (ptr -> id != NULL) {
  5549.       if ( ! BLAST0SeqIdAsnWrite(ptr -> id, aip, BLAST0_SEQ_DESC_id)) {
  5550.          goto erret;
  5551.       }
  5552.    }
  5553.    if (ptr -> defline != NULL) {
  5554.       av.ptrvalue = ptr -> defline;
  5555.       retval = AsnWrite(aip, BLAST0_SEQ_DESC_defline,  &av);
  5556.    }
  5557.    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
  5558.       goto erret;
  5559.    }
  5560.    retval = TRUE;
  5561.  
  5562. erret:
  5563.    AsnUnlinkType(orig);       /* unlink local tree */
  5564.    return retval;
  5565. }
  5566.  
  5567.  
  5568.  
  5569. /**************************************************
  5570. *
  5571. *    BLAST0SeqIdFree()
  5572. *
  5573. **************************************************/
  5574.  
  5575. BLAST0SeqIdPtr LIBCALL
  5576. BLAST0SeqIdFree(ValNodePtr anp)
  5577. {
  5578.  
  5579.    if (anp == NULL) {
  5580.       return NULL;
  5581.    }
  5582.  
  5583.    AsnGenericChoiceSeqOfFree(anp, (AsnOptFreeFunc) BLAST0SeqId_elementFree);    
  5584.    return NULL;
  5585. }
  5586.  
  5587.  
  5588. /**************************************************
  5589. *
  5590. *    BLAST0SeqIdAsnRead()
  5591. *
  5592. **************************************************/
  5593.  
  5594. BLAST0SeqIdPtr LIBCALL
  5595. BLAST0SeqIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  5596. {
  5597.  
  5598.  
  5599.    DataVal av;
  5600.    AsnTypePtr atp;
  5601.    ValNodePtr anp;
  5602.    Uint1 choice;
  5603.    Boolean isError = FALSE;
  5604.    AsnReadFunc func;
  5605.  
  5606.    if (! loaded)
  5607.    {
  5608.       if (! objblst2AsnLoad()) {
  5609.          return NULL;
  5610.       }
  5611.    }
  5612.  
  5613.    if (aip == NULL) {
  5614.       return NULL;
  5615.    }
  5616.  
  5617.    if (orig == NULL) {         /* BLAST0SeqId_element ::= (self contained) */
  5618.       atp = AsnReadId(aip, amp, BLAST0_SEQ_ID);
  5619.    } else {
  5620.       atp = AsnLinkType(orig, BLAST0_SEQ_ID);    /* link in local tree */
  5621.    }
  5622.    if (atp == NULL) {
  5623.       return NULL;
  5624.    }
  5625.  
  5626.    anp =
  5627.    AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError,
  5628.    (AsnReadFunc) BLAST0SeqId_elementAsnRead, (AsnOptFreeFunc) BLAST0SeqId_elementFree);
  5629.    if (isError) 
  5630.    goto erret;
  5631.  
  5632.  
  5633. ret:
  5634.    AsnUnlinkType(orig);       /* unlink local tree */
  5635.    return anp;
  5636.  
  5637. erret:
  5638.    aip -> io_failure = TRUE;
  5639.    goto ret;
  5640. }
  5641.  
  5642.  
  5643. /**************************************************
  5644. *
  5645. *    BLAST0SeqIdAsnWrite()
  5646. *
  5647. **************************************************/
  5648. Boolean LIBCALL 
  5649. BLAST0SeqIdAsnWrite(ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig)
  5650.  
  5651. {
  5652.    DataVal av;
  5653.    AsnTypePtr atp, writetype = NULL;
  5654.    Pointer pnt;
  5655.    AsnWriteFunc func = NULL;
  5656.    Boolean retval = FALSE;
  5657.  
  5658.    if (! loaded)
  5659.    {
  5660.       if (! objblst2AsnLoad())
  5661.       return FALSE;
  5662.    }
  5663.  
  5664.    if (aip == NULL)
  5665.    return FALSE;
  5666.  
  5667.    atp = AsnLinkType(orig, BLAST0_SEQ_ID);   /* link local tree */
  5668.    if (atp == NULL) {
  5669.       return FALSE;
  5670.    }
  5671.  
  5672.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5673.  
  5674.    av.ptrvalue = (Pointer)anp;
  5675.    retval = AsnGenericChoiceSeqOfAsnWrite(anp, 
  5676.    (AsnWriteFunc) BLAST0SeqId_elementAsnWrite, aip, atp, BLAST0_SEQ_ID_E);
  5677. erret:
  5678.    AsnUnlinkType(orig);       /* unlink local tree */
  5679.    return retval;
  5680. }
  5681.  
  5682.  
  5683. /**************************************************
  5684. *
  5685. *    BLAST0SeqId_elementAsnWrite()
  5686. *
  5687. **************************************************/
  5688. Boolean LIBCALL 
  5689. BLAST0SeqId_elementAsnWrite(BLAST0SeqId_elementPtr anp, AsnIoPtr aip, AsnTypePtr orig)
  5690.  
  5691. {
  5692.    DataVal av;
  5693.    AsnTypePtr atp, writetype = NULL;
  5694.    Pointer pnt;
  5695.    AsnWriteFunc func = NULL;
  5696.    Boolean retval = FALSE;
  5697.  
  5698.    if (! loaded)
  5699.    {
  5700.       if (! objblst2AsnLoad())
  5701.       return FALSE;
  5702.    }
  5703.  
  5704.    if (aip == NULL)
  5705.    return FALSE;
  5706.  
  5707.    atp = AsnLinkType(orig, BLAST0_SEQ_ID_E);   /* link local tree */
  5708.    if (atp == NULL) {
  5709.       return FALSE;
  5710.    }
  5711.  
  5712.    if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
  5713.  
  5714.    av.ptrvalue = (Pointer)anp;
  5715.    if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
  5716.       goto erret;
  5717.    }
  5718.  
  5719.    pnt = anp->data.ptrvalue;
  5720.    switch (anp->choice)
  5721.    {
  5722.    case BLAST0SeqId_giid:
  5723.       av.intvalue = anp->data.intvalue;
  5724.       retval = AsnWrite(aip, BLAST0_SEQ_ID_E_giid, &av);
  5725.       break;
  5726.    case BLAST0SeqId_textid:
  5727.       av.ptrvalue = anp->data.ptrvalue;
  5728.       retval = AsnWrite(aip, BLAST0_SEQ_ID_E_textid, &av);
  5729.       break;
  5730.    }
  5731.    if (writetype != NULL) {
  5732.       retval = (* func)(pnt, aip, writetype);   /* write it out */
  5733.    }
  5734.    if (!retval) {
  5735.       goto erret;
  5736.    }
  5737.    retval = TRUE;
  5738.  
  5739. erret:
  5740.    AsnUnlinkType(orig);       /* unlink local tree */
  5741.    return retval;
  5742. }
  5743.  
  5744.  
  5745. /**************************************************
  5746. *
  5747. *    BLAST0SeqId_elementAsnRead()
  5748. *
  5749. **************************************************/
  5750.  
  5751. BLAST0SeqId_elementPtr LIBCALL
  5752. BLAST0SeqId_elementAsnRead(AsnIoPtr aip, AsnTypePtr orig)
  5753. {
  5754.    DataVal av;
  5755.    AsnTypePtr atp;
  5756.    ValNodePtr anp;
  5757.    Uint1 choice;
  5758.    Boolean isError = FALSE;
  5759.    Boolean nullIsError = FALSE;
  5760.    AsnReadFunc func;
  5761.  
  5762.    if (! loaded)
  5763.    {
  5764.       if (! objblst2AsnLoad()) {
  5765.          return NULL;
  5766.       }
  5767.    }
  5768.  
  5769.    if (aip == NULL) {
  5770.       return NULL;
  5771.    }
  5772.  
  5773.    if (orig == NULL) {         /* BLAST0SeqId_element ::= (self contained) */
  5774.       atp = AsnReadId(aip, amp, BLAST0_SEQ_ID_E);
  5775.    } else {
  5776.       atp = AsnLinkType(orig, BLAST0_SEQ_ID_E);    /* link in local tree */
  5777.    }
  5778.    if (atp == NULL) {
  5779.       return NULL;
  5780.    }
  5781.  
  5782.    anp = ValNodeNew(NULL);
  5783.    if (anp == NULL) {
  5784.       goto erret;
  5785.    }
  5786.    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
  5787.       goto erret;
  5788.    }
  5789.  
  5790.    func = NULL;
  5791.  
  5792.    atp = AsnReadId(aip, amp, atp);  /* find the choice */
  5793.    if (atp == NULL) {
  5794.       goto erret;
  5795.    }
  5796.    if (atp == BLAST0_SEQ_ID_E_giid) {
  5797.       choice = BLAST0SeqId_giid;
  5798.       if (AsnReadVal(aip, atp, &av) <= 0) {
  5799.          goto erret;
  5800.       }
  5801.       anp->data.intvalue = av.intvalue;
  5802.    }
  5803.    else if (atp == BLAST0_SEQ_ID_E_textid) {
  5804.       choice = BLAST0SeqId_textid;
  5805.       if (AsnReadVal(aip, atp, &av) <= 0) {
  5806.          goto erret;
  5807.       }
  5808.       anp->data.ptrvalue = av.ptrvalue;
  5809.    }
  5810.    anp->choice = choice;
  5811.    if (func != NULL)
  5812.    {
  5813.       anp->data.ptrvalue = (* func)(aip, atp);
  5814.       if (aip -> io_failure) goto erret;
  5815.  
  5816.       if (nullIsError && anp->data.ptrvalue == NULL) {
  5817.          goto erret;
  5818.       }
  5819.    }
  5820.  
  5821. ret:
  5822.    AsnUnlinkType(orig);       /* unlink local tree */
  5823.    return anp;
  5824.  
  5825. erret:
  5826.    anp = MemFree(anp);
  5827.    aip -> io_failure = TRUE;
  5828.    goto ret;
  5829. }
  5830.  
  5831.  
  5832. /**************************************************
  5833. *
  5834. *    BLAST0SeqId_elementFree()
  5835. *
  5836. **************************************************/
  5837.  
  5838. BLAST0SeqId_elementPtr LIBCALL
  5839. BLAST0SeqId_elementFree(ValNodePtr anp)
  5840. {
  5841.    Pointer pnt;
  5842.  
  5843.    if (anp == NULL) {
  5844.       return NULL;
  5845.    }
  5846.  
  5847.    pnt = anp->data.ptrvalue;
  5848.    switch (anp->choice)
  5849.    {
  5850.    default:
  5851.       break;
  5852.    case BLAST0SeqId_textid:
  5853.       MemFree(anp -> data.ptrvalue);
  5854.       break;
  5855.    }
  5856.    return MemFree(anp);
  5857. }
  5858.