~ubuntu-branches/ubuntu/precise/ncbi-tools6/precise

« back to all changes in this revision

Viewing changes to object/objtseq.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <asn.h>
 
2
 
 
3
#define NLM_GENERATED_CODE_PROTO
 
4
 
 
5
#include <objtseq.h>
 
6
 
 
7
static Boolean loaded = FALSE;
 
8
 
 
9
#include <asntseq.h>
 
10
 
 
11
#ifndef NLM_EXTERN_LOADS
 
12
#define NLM_EXTERN_LOADS {}
 
13
#endif
 
14
 
 
15
NLM_EXTERN Boolean LIBCALL
 
16
objtseqAsnLoad(void)
 
17
{
 
18
 
 
19
   if ( ! loaded) {
 
20
      NLM_EXTERN_LOADS
 
21
 
 
22
      if ( ! AsnLoad ())
 
23
      return FALSE;
 
24
      loaded = TRUE;
 
25
   }
 
26
 
 
27
   return TRUE;
 
28
}
 
29
 
 
30
 
 
31
 
 
32
/**************************************************
 
33
*    Generated object loaders for Module NCBI-TSeq
 
34
*    Generated using ASNCODE Revision: 6.14 at Jun 28, 2002 12:46 PM
 
35
*
 
36
**************************************************/
 
37
 
 
38
 
 
39
/**************************************************
 
40
*
 
41
*    TSeqNew()
 
42
*
 
43
**************************************************/
 
44
NLM_EXTERN 
 
45
TSeqPtr LIBCALL
 
46
TSeqNew(void)
 
47
{
 
48
   TSeqPtr ptr = MemNew((size_t) sizeof(TSeq));
 
49
 
 
50
   return ptr;
 
51
 
 
52
}
 
53
 
 
54
 
 
55
/**************************************************
 
56
*
 
57
*    TSeqFree()
 
58
*
 
59
**************************************************/
 
60
NLM_EXTERN 
 
61
TSeqPtr LIBCALL
 
62
TSeqFree(TSeqPtr ptr)
 
63
{
 
64
 
 
65
   if(ptr == NULL) {
 
66
      return NULL;
 
67
   }
 
68
   MemFree(ptr -> accver);
 
69
   MemFree(ptr -> sid);
 
70
   MemFree(ptr -> local);
 
71
   MemFree(ptr -> orgname);
 
72
   MemFree(ptr -> defline);
 
73
   MemFree(ptr -> sequence);
 
74
   return MemFree(ptr);
 
75
}
 
76
 
 
77
 
 
78
/**************************************************
 
79
*
 
80
*    TSeqAsnRead()
 
81
*
 
82
**************************************************/
 
83
NLM_EXTERN 
 
84
TSeqPtr LIBCALL
 
85
TSeqAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
86
{
 
87
   DataVal av;
 
88
   AsnTypePtr atp;
 
89
   Boolean isError = FALSE;
 
90
   AsnReadFunc func;
 
91
   TSeqPtr ptr;
 
92
 
 
93
   if (! loaded)
 
94
   {
 
95
      if (! objtseqAsnLoad()) {
 
96
         return NULL;
 
97
      }
 
98
   }
 
99
 
 
100
   if (aip == NULL) {
 
101
      return NULL;
 
102
   }
 
103
 
 
104
   if (orig == NULL) {         /* TSeq ::= (self contained) */
 
105
      atp = AsnReadId(aip, amp, TSEQ);
 
106
   } else {
 
107
      atp = AsnLinkType(orig, TSEQ);
 
108
   }
 
109
   /* link in local tree */
 
110
   if (atp == NULL) {
 
111
      return NULL;
 
112
   }
 
113
 
 
114
   ptr = TSeqNew();
 
115
   if (ptr == NULL) {
 
116
      goto erret;
 
117
   }
 
118
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
119
      goto erret;
 
120
   }
 
121
 
 
122
   atp = AsnReadId(aip,amp, atp);
 
123
   func = NULL;
 
124
 
 
125
   if (atp == TSEQ_seqtype) {
 
126
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
127
         goto erret;
 
128
      }
 
129
      ptr -> seqtype = av.intvalue;
 
130
      atp = AsnReadId(aip,amp, atp);
 
131
   }
 
132
   if (atp == TSEQ_gi) {
 
133
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
134
         goto erret;
 
135
      }
 
136
      ptr -> gi = av.intvalue;
 
137
      ptr -> OBbits__ |= 1<<0;
 
138
      atp = AsnReadId(aip,amp, atp);
 
139
   }
 
140
   if (atp == TSEQ_accver) {
 
141
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
142
         goto erret;
 
143
      }
 
144
      ptr -> accver = av.ptrvalue;
 
145
      atp = AsnReadId(aip,amp, atp);
 
146
   }
 
147
   if (atp == TSEQ_sid) {
 
148
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
149
         goto erret;
 
150
      }
 
151
      ptr -> sid = av.ptrvalue;
 
152
      atp = AsnReadId(aip,amp, atp);
 
153
   }
 
154
   if (atp == TSEQ_local) {
 
155
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
156
         goto erret;
 
157
      }
 
158
      ptr -> local = av.ptrvalue;
 
159
      atp = AsnReadId(aip,amp, atp);
 
160
   }
 
161
   if (atp == TSEQ_taxid) {
 
162
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
163
         goto erret;
 
164
      }
 
165
      ptr -> taxid = av.intvalue;
 
166
      ptr -> OBbits__ |= 1<<1;
 
167
      atp = AsnReadId(aip,amp, atp);
 
168
   }
 
169
   if (atp == TSEQ_orgname) {
 
170
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
171
         goto erret;
 
172
      }
 
173
      ptr -> orgname = av.ptrvalue;
 
174
      atp = AsnReadId(aip,amp, atp);
 
175
   }
 
176
   if (atp == TSEQ_defline) {
 
177
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
178
         goto erret;
 
179
      }
 
180
      ptr -> defline = av.ptrvalue;
 
181
      atp = AsnReadId(aip,amp, atp);
 
182
   }
 
183
   if (atp == TSEQ_length) {
 
184
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
185
         goto erret;
 
186
      }
 
187
      ptr -> length = av.intvalue;
 
188
      atp = AsnReadId(aip,amp, atp);
 
189
   }
 
190
   if (atp == TSEQ_sequence) {
 
191
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
192
         goto erret;
 
193
      }
 
194
      ptr -> sequence = av.ptrvalue;
 
195
      atp = AsnReadId(aip,amp, atp);
 
196
   }
 
197
 
 
198
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
199
      goto erret;
 
200
   }
 
201
   /* end struct */
 
202
 
 
203
ret:
 
204
   AsnUnlinkType(orig);       /* unlink local tree */
 
205
   return ptr;
 
206
 
 
207
erret:
 
208
   aip -> io_failure = TRUE;
 
209
   ptr = TSeqFree(ptr);
 
210
   goto ret;
 
211
}
 
212
 
 
213
 
 
214
 
 
215
/**************************************************
 
216
*
 
217
*    TSeqAsnWrite()
 
218
*
 
219
**************************************************/
 
220
NLM_EXTERN Boolean LIBCALL 
 
221
TSeqAsnWrite(TSeqPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
222
{
 
223
   DataVal av;
 
224
   AsnTypePtr atp;
 
225
   Boolean retval = FALSE;
 
226
 
 
227
   if (! loaded)
 
228
   {
 
229
      if (! objtseqAsnLoad()) {
 
230
         return FALSE;
 
231
      }
 
232
   }
 
233
 
 
234
   if (aip == NULL) {
 
235
      return FALSE;
 
236
   }
 
237
 
 
238
   atp = AsnLinkType(orig, TSEQ);   /* link local tree */
 
239
   if (atp == NULL) {
 
240
      return FALSE;
 
241
   }
 
242
 
 
243
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
244
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
245
      goto erret;
 
246
   }
 
247
 
 
248
   av.intvalue = ptr -> seqtype;
 
249
   retval = AsnWrite(aip, TSEQ_seqtype,  &av);
 
250
   if (ptr -> gi || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> gi;
 
251
      retval = AsnWrite(aip, TSEQ_gi,  &av);
 
252
   }
 
253
   if (ptr -> accver != NULL) {
 
254
      av.ptrvalue = ptr -> accver;
 
255
      retval = AsnWrite(aip, TSEQ_accver,  &av);
 
256
   }
 
257
   if (ptr -> sid != NULL) {
 
258
      av.ptrvalue = ptr -> sid;
 
259
      retval = AsnWrite(aip, TSEQ_sid,  &av);
 
260
   }
 
261
   if (ptr -> local != NULL) {
 
262
      av.ptrvalue = ptr -> local;
 
263
      retval = AsnWrite(aip, TSEQ_local,  &av);
 
264
   }
 
265
   if (ptr -> taxid || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> taxid;
 
266
      retval = AsnWrite(aip, TSEQ_taxid,  &av);
 
267
   }
 
268
   if (ptr -> orgname != NULL) {
 
269
      av.ptrvalue = ptr -> orgname;
 
270
      retval = AsnWrite(aip, TSEQ_orgname,  &av);
 
271
   }
 
272
   if (ptr -> defline != NULL) {
 
273
      av.ptrvalue = ptr -> defline;
 
274
      retval = AsnWrite(aip, TSEQ_defline,  &av);
 
275
   }
 
276
   av.intvalue = ptr -> length;
 
277
   retval = AsnWrite(aip, TSEQ_length,  &av);
 
278
   if (ptr -> sequence != NULL) {
 
279
      av.ptrvalue = ptr -> sequence;
 
280
      retval = AsnWrite(aip, TSEQ_sequence,  &av);
 
281
   }
 
282
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
283
      goto erret;
 
284
   }
 
285
   retval = TRUE;
 
286
 
 
287
erret:
 
288
   AsnUnlinkType(orig);       /* unlink local tree */
 
289
   return retval;
 
290
}
 
291
 
 
292
 
 
293
 
 
294
/**************************************************
 
295
*
 
296
*    TSeqSetFree()
 
297
*
 
298
**************************************************/
 
299
NLM_EXTERN 
 
300
TSeqSetPtr LIBCALL
 
301
TSeqSetFree(TSeqSetPtr ptr)
 
302
{
 
303
 
 
304
   if(ptr == NULL) {
 
305
      return NULL;
 
306
   }
 
307
   AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) TSeqFree);
 
308
   return NULL;
 
309
}
 
310
 
 
311
 
 
312
/**************************************************
 
313
*
 
314
*    TSeqSetAsnRead()
 
315
*
 
316
**************************************************/
 
317
NLM_EXTERN 
 
318
TSeqSetPtr LIBCALL
 
319
TSeqSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
320
{
 
321
   AsnTypePtr atp;
 
322
   Boolean isError = FALSE;
 
323
   AsnReadFunc func;
 
324
   TSeqSetPtr ptr;
 
325
 
 
326
   if (! loaded)
 
327
   {
 
328
      if (! objtseqAsnLoad()) {
 
329
         return NULL;
 
330
      }
 
331
   }
 
332
 
 
333
   if (aip == NULL) {
 
334
      return NULL;
 
335
   }
 
336
 
 
337
   if (orig == NULL) {         /* TSeqSet ::= (self contained) */
 
338
      atp = AsnReadId(aip, amp, TSEQSET);
 
339
   } else {
 
340
      atp = AsnLinkType(orig, TSEQSET);
 
341
   }
 
342
   /* link in local tree */
 
343
   if (atp == NULL) {
 
344
      return NULL;
 
345
   }
 
346
 
 
347
   func = NULL;
 
348
 
 
349
   ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) TSeqAsnRead, (AsnOptFreeFunc) TSeqFree);
 
350
   if (isError && ptr  == NULL) {
 
351
      goto erret;
 
352
   }
 
353
 
 
354
 
 
355
 
 
356
ret:
 
357
   AsnUnlinkType(orig);       /* unlink local tree */
 
358
   return ptr;
 
359
 
 
360
erret:
 
361
   aip -> io_failure = TRUE;
 
362
   ptr = TSeqSetFree(ptr);
 
363
   goto ret;
 
364
}
 
365
 
 
366
 
 
367
 
 
368
/**************************************************
 
369
*
 
370
*    TSeqSetAsnWrite()
 
371
*
 
372
**************************************************/
 
373
NLM_EXTERN Boolean LIBCALL 
 
374
TSeqSetAsnWrite(TSeqSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
375
{
 
376
   AsnTypePtr atp;
 
377
   Boolean retval = FALSE;
 
378
 
 
379
   if (! loaded)
 
380
   {
 
381
      if (! objtseqAsnLoad()) {
 
382
         return FALSE;
 
383
      }
 
384
   }
 
385
 
 
386
   if (aip == NULL) {
 
387
      return FALSE;
 
388
   }
 
389
 
 
390
   atp = AsnLinkType(orig, TSEQSET);   /* link local tree */
 
391
   if (atp == NULL) {
 
392
      return FALSE;
 
393
   }
 
394
 
 
395
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
396
   retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) TSeqAsnWrite, aip, atp, TSEQSET_E);
 
397
   retval = TRUE;
 
398
 
 
399
erret:
 
400
   AsnUnlinkType(orig);       /* unlink local tree */
 
401
   return retval;
 
402
}
 
403
 
 
404
/* manually added */
 
405
 
 
406
#include <seqport.h>
 
407
#include <gather.h>
 
408
#include <tofasta.h>
 
409
 
 
410
static void LIBCALLBACK SaveTseqSequence (
 
411
  CharPtr sequence,
 
412
  Pointer userdata
 
413
)
 
414
 
 
415
{
 
416
  Char          ch;
 
417
  CharPtr       str;
 
418
  CharPtr       tmp;
 
419
  CharPtr PNTR  tmpp;
 
420
 
 
421
  tmpp = (CharPtr PNTR) userdata;
 
422
  tmp = *tmpp;
 
423
 
 
424
  str = sequence;
 
425
  if (sequence == NULL) return;
 
426
  ch = *str;
 
427
  while (ch != '\0') {
 
428
    if (ch == '\n' || ch == '\r' || ch == '\t') {
 
429
      *str = ' ';
 
430
    }
 
431
    str++;
 
432
    ch = *str;
 
433
  }
 
434
  TrimSpacesAroundString (sequence);
 
435
 
 
436
  tmp = StringMove (tmp, sequence);
 
437
 
 
438
  *tmpp = tmp;
 
439
}
 
440
 
 
441
NLM_EXTERN TSeqPtr BioseqToTSeq (BioseqPtr bsp)
 
442
 
 
443
{
 
444
        TSeqPtr tsp;
 
445
        SeqIdPtr sip;
 
446
        Char buf[255];
 
447
        CharPtr accession = NULL, organism = NULL, title = NULL;
 
448
        CharPtr seq;
 
449
        Uint1 seqcode;
 
450
        ValNodePtr vnp;
 
451
        BioSourcePtr biosp;
 
452
        OrgRefPtr orp;
 
453
        DbtagPtr dbp;
 
454
        ObjectIdPtr oip;
 
455
 
 
456
        if (bsp == NULL) return NULL;
 
457
        tsp = TSeqNew ();
 
458
        if (ISA_aa(bsp->mol))
 
459
                tsp->seqtype = TSeq_seqtype_protein;
 
460
        else
 
461
                tsp->seqtype = TSeq_seqtype_nucleotide;
 
462
 
 
463
        for (sip = bsp->id; sip != NULL; sip = sip->next)
 
464
        {
 
465
                switch (sip->choice)
 
466
                {
 
467
                        case SEQID_GI:
 
468
                                tsp->gi = sip->data.intvalue;
 
469
                                break;
 
470
                        case SEQID_GENBANK:
 
471
                        case SEQID_DDBJ:
 
472
                        case SEQID_EMBL:
 
473
                        case SEQID_SWISSPROT:
 
474
                    case SEQID_OTHER:
 
475
                    case SEQID_TPG:
 
476
                    case SEQID_TPE:
 
477
                    case SEQID_TPD:
 
478
                                SeqIdWrite(sip, buf, PRINTID_TEXTID_ACC_VER, 250);
 
479
                                tsp->accver = StringSave(buf);
 
480
                                break;
 
481
                        default:
 
482
                                SeqIdWrite(sip, buf, PRINTID_FASTA_SHORT, 250);
 
483
                                tsp->sid = StringSave(buf);
 
484
                                break;
 
485
                }
 
486
        }
 
487
 
 
488
        CreateDefLine(NULL, bsp, buf, 250, 0, accession, organism);
 
489
        tsp->defline = StringSave(buf);
 
490
 
 
491
        vnp = GetNextDescriptorUnindexed (bsp, Seq_descr_source, NULL);
 
492
        if (vnp != NULL && vnp->data.ptrvalue != NULL) {
 
493
                biosp = (BioSourcePtr)(vnp->data.ptrvalue);
 
494
                orp = biosp->org;
 
495
                if (orp != NULL) {
 
496
                        if (orp->taxname != NULL)
 
497
                                tsp->orgname = StringSave(orp->taxname);
 
498
                        else if (orp->common != NULL)
 
499
                                tsp->orgname = StringSave(orp->common);
 
500
 
 
501
                        for (vnp = orp->db; vnp != NULL; vnp = vnp->next)
 
502
                        {
 
503
                                dbp = (DbtagPtr)(vnp->data.ptrvalue);
 
504
                                if (! StringICmp("taxon", dbp->db))
 
505
                                {
 
506
                                        oip = dbp->tag;
 
507
                                        tsp->taxid = oip->id;
 
508
                                        break;
 
509
                                }
 
510
                        }
 
511
                }
 
512
        }
 
513
 
 
514
        tsp->length = bsp->length;
 
515
        
 
516
        if (ISA_aa(bsp->mol))
 
517
        {
 
518
                seqcode = Seq_code_ncbieaa;
 
519
        }
 
520
        else
 
521
        {
 
522
                seqcode = Seq_code_iupacna;
 
523
        }
 
524
 
 
525
        seq = MemNew(bsp->length + 1);
 
526
        if (seq != NULL) {
 
527
                tsp->sequence = seq;
 
528
                SeqPortStream (bsp, STREAM_EXPAND_GAPS, (Pointer) &seq, SaveTseqSequence);
 
529
        }
 
530
 
 
531
        return tsp;
 
532
}
 
533
 
 
534
NLM_EXTERN Boolean AsnPrintString (CharPtr the_string, AsnIoPtr aip);
 
535
 
 
536
static void LIBCALLBACK TSeqStreamProc (CharPtr sequence, Pointer userdata)
 
537
 
 
538
{
 
539
  AsnIoPtr  aip;
 
540
 
 
541
  aip = (AsnIoPtr) userdata;
 
542
 
 
543
  AsnPrintString (sequence, aip);
 
544
}
 
545
 
 
546
static Boolean LIBCALL StreamTSeq (Pointer object, AsnIoPtr aip)
 
547
 
 
548
{
 
549
  SeqPortStream ((BioseqPtr) object, STREAM_EXPAND_GAPS, (Pointer) aip, TSeqStreamProc);
 
550
  return TRUE;
 
551
}
 
552
 
 
553
static TSeqPtr BioseqToMiniTSeq (BioseqPtr bsp)
 
554
 
 
555
{
 
556
        TSeqPtr tsp;
 
557
        SeqIdPtr sip;
 
558
        Char buf[255];
 
559
        CharPtr accession = NULL, organism = NULL, title = NULL;
 
560
        Uint1 seqcode;
 
561
        ValNodePtr vnp;
 
562
        BioSourcePtr biosp;
 
563
        OrgRefPtr orp;
 
564
        DbtagPtr dbp;
 
565
        ObjectIdPtr oip;
 
566
 
 
567
        if (bsp == NULL) return NULL;
 
568
        tsp = TSeqNew ();
 
569
        if (ISA_aa(bsp->mol))
 
570
                tsp->seqtype = TSeq_seqtype_protein;
 
571
        else
 
572
                tsp->seqtype = TSeq_seqtype_nucleotide;
 
573
 
 
574
        for (sip = bsp->id; sip != NULL; sip = sip->next)
 
575
        {
 
576
                switch (sip->choice)
 
577
                {
 
578
                        case SEQID_GI:
 
579
                                tsp->gi = sip->data.intvalue;
 
580
                                break;
 
581
                        case SEQID_GENBANK:
 
582
                        case SEQID_DDBJ:
 
583
                        case SEQID_EMBL:
 
584
                        case SEQID_SWISSPROT:
 
585
                    case SEQID_OTHER:
 
586
                    case SEQID_TPG:
 
587
                    case SEQID_TPE:
 
588
                    case SEQID_TPD:
 
589
                                SeqIdWrite(sip, buf, PRINTID_TEXTID_ACC_VER, 250);
 
590
                                tsp->accver = StringSave(buf);
 
591
                                break;
 
592
                        default:
 
593
                                SeqIdWrite(sip, buf, PRINTID_FASTA_SHORT, 250);
 
594
                                tsp->sid = StringSave(buf);
 
595
                                break;
 
596
                }
 
597
        }
 
598
 
 
599
        CreateDefLine(NULL, bsp, buf, 250, 0, accession, organism);
 
600
        tsp->defline = StringSave(buf);
 
601
 
 
602
        vnp = GetNextDescriptorUnindexed (bsp, Seq_descr_source, NULL);
 
603
        if (vnp != NULL && vnp->data.ptrvalue != NULL) {
 
604
                biosp = (BioSourcePtr)(vnp->data.ptrvalue);
 
605
                orp = biosp->org;
 
606
                if (orp != NULL) {
 
607
                        if (orp->taxname != NULL)
 
608
                                tsp->orgname = StringSave(orp->taxname);
 
609
                        else if (orp->common != NULL)
 
610
                                tsp->orgname = StringSave(orp->common);
 
611
 
 
612
                        for (vnp = orp->db; vnp != NULL; vnp = vnp->next)
 
613
                        {
 
614
                                dbp = (DbtagPtr)(vnp->data.ptrvalue);
 
615
                                if (! StringICmp("taxon", dbp->db))
 
616
                                {
 
617
                                        oip = dbp->tag;
 
618
                                        tsp->taxid = oip->id;
 
619
                                        break;
 
620
                                }
 
621
                        }
 
622
                }
 
623
        }
 
624
 
 
625
        tsp->length = bsp->length;
 
626
        
 
627
        if (ISA_aa(bsp->mol))
 
628
        {
 
629
                seqcode = Seq_code_ncbieaa;
 
630
        }
 
631
        else
 
632
        {
 
633
                seqcode = Seq_code_iupacna;
 
634
        }
 
635
 
 
636
        /*
 
637
        seq = MemNew(bsp->length + 1);
 
638
        if (seq != NULL) {
 
639
                tsp->sequence = seq;
 
640
                SeqPortStream (bsp, STREAM_EXPAND_GAPS, (Pointer) &seq, SaveTseqSequence);
 
641
        }
 
642
        */
 
643
 
 
644
        return tsp;
 
645
}
 
646
 
 
647
NLM_EXTERN Boolean BioseqAsnWriteAsTSeq (BioseqPtr bsp, AsnIoPtr aip, AsnTypePtr orig)
 
648
{
 
649
   DataVal av;
 
650
   AsnTypePtr atp;
 
651
   Boolean retval = FALSE;
 
652
   TSeqPtr ptr = NULL;
 
653
 
 
654
   if (! loaded)
 
655
   {
 
656
      if (! objtseqAsnLoad()) {
 
657
         return FALSE;
 
658
      }
 
659
   }
 
660
 
 
661
   if (aip == NULL) {
 
662
      return FALSE;
 
663
   }
 
664
 
 
665
   atp = AsnLinkType(orig, TSEQ);   /* link local tree */
 
666
   if (atp == NULL) {
 
667
      return FALSE;
 
668
   }
 
669
 
 
670
   ptr = BioseqToMiniTSeq (bsp);
 
671
 
 
672
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
673
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
674
      goto erret;
 
675
   }
 
676
 
 
677
   av.intvalue = ptr -> seqtype;
 
678
   retval = AsnWrite(aip, TSEQ_seqtype,  &av);
 
679
   if (ptr -> gi || (ptr -> OBbits__ & (1<<0) )){   av.intvalue = ptr -> gi;
 
680
      retval = AsnWrite(aip, TSEQ_gi,  &av);
 
681
   }
 
682
   if (ptr -> accver != NULL) {
 
683
      av.ptrvalue = ptr -> accver;
 
684
      retval = AsnWrite(aip, TSEQ_accver,  &av);
 
685
   }
 
686
   if (ptr -> sid != NULL) {
 
687
      av.ptrvalue = ptr -> sid;
 
688
      retval = AsnWrite(aip, TSEQ_sid,  &av);
 
689
   }
 
690
   if (ptr -> local != NULL) {
 
691
      av.ptrvalue = ptr -> local;
 
692
      retval = AsnWrite(aip, TSEQ_local,  &av);
 
693
   }
 
694
   if (ptr -> taxid || (ptr -> OBbits__ & (1<<1) )){   av.intvalue = ptr -> taxid;
 
695
      retval = AsnWrite(aip, TSEQ_taxid,  &av);
 
696
   }
 
697
   if (ptr -> orgname != NULL) {
 
698
      av.ptrvalue = ptr -> orgname;
 
699
      retval = AsnWrite(aip, TSEQ_orgname,  &av);
 
700
   }
 
701
   if (ptr -> defline != NULL) {
 
702
      av.ptrvalue = ptr -> defline;
 
703
      retval = AsnWrite(aip, TSEQ_defline,  &av);
 
704
   }
 
705
   av.intvalue = ptr -> length;
 
706
   retval = AsnWrite(aip, TSEQ_length,  &av);
 
707
   if (bsp != NULL) {
 
708
      av.ptrvalue = bsp; /* pass bsp to SeqPortStream */
 
709
      retval = AsnWriteEx(aip, TSEQ_sequence,  &av, StreamTSeq);
 
710
   }
 
711
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
712
      goto erret;
 
713
   }
 
714
   retval = TRUE;
 
715
 
 
716
erret:
 
717
   AsnUnlinkType(orig);       /* unlink local tree */
 
718
   TSeqFree (ptr);
 
719
   return retval;
 
720
}
 
721