~ubuntu-branches/debian/experimental/ncbi-tools6/experimental

« back to all changes in this revision

Viewing changes to api/seqport.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-07-14 19:43:15 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080714194315-ed44u9ek7txva2rz
Tags: 6.1.20080302-3
tools/readdb.c: enable madvise()-based code on all glibc (hence all
Debian) systems, not just Linux.  (Closes: #490437.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*   
30
30
* Version Creation Date: 7/13/91
31
31
*
32
 
* $Revision: 6.159 $
 
32
* $Revision: 6.172 $
33
33
*
34
34
* File Description:  Ports onto Bioseqs
35
35
*
39
39
* -------  ----------  -----------------------------------------------------
40
40
*
41
41
* $Log: seqport.c,v $
 
42
* Revision 6.172  2008/02/12 18:56:52  bollin
 
43
* Made ReverseSeqData and ComplementSeqData extern
 
44
*
 
45
* Revision 6.171  2007/12/28 16:27:58  kans
 
46
* in SeqPortStreamSetup, on failure, return -1 if count was 0 to ensure failure signal
 
47
*
 
48
* Revision 6.170  2007/12/04 19:00:21  kans
 
49
* SeqPortStreamSeqLoc uses scope to get local (segset) components while allowing multiple simultaneous StreamCache objects
 
50
*
 
51
* Revision 6.169  2007/05/30 18:10:06  kans
 
52
* added KNOWN_GAP_AS_PLUS to distinguish known-length from unknown-length gaps, use for validation
 
53
*
 
54
* Revision 6.168  2007/05/07 13:28:35  kans
 
55
* added casts for Seq-data.gap (SeqDataPtr, SeqGapPtr, ByteStorePtr)
 
56
*
 
57
* Revision 6.167  2006/12/26 17:40:27  kans
 
58
* improvements to SeqPortStreamGap so it properly distinguishes virtual as plus symbol if requested
 
59
*
 
60
* Revision 6.166  2006/12/20 20:08:24  kans
 
61
* added SUPPRESS_VIRT_SEQ and STREAM_VIRT_AS_PLUS, moved STREAM_CORRECT_INVAL
 
62
*
 
63
* Revision 6.165  2006/12/18 15:42:57  kans
 
64
* made MakeCodeBreakList public so validator can check for unnecessary transl excepts
 
65
*
 
66
* Revision 6.164  2006/12/14 14:57:24  kans
 
67
* improvements to gap loops in StreamCacheGetResidue
 
68
*
 
69
* Revision 6.163  2006/12/13 23:10:00  kans
 
70
* StreamCacheGetResidue now handles all gap expansion flag choices
 
71
*
 
72
* Revision 6.162  2006/11/15 18:02:59  kans
 
73
* ProteinFromCdRegionExEx and TransTableTranslateCdRegionEx take farProdFetchOK argument
 
74
*
 
75
* Revision 6.161  2006/11/13 20:35:55  kans
 
76
* STREAM_ALLOW_NEG_GIS also allows gi zero, used for internal purposes
 
77
*
 
78
* Revision 6.160  2006/11/06 17:16:38  kans
 
79
* added stream flag to allow negative gi numbers by NCBI ID group
 
80
*
42
81
* Revision 6.159  2006/09/20 17:54:19  kans
43
82
* SeqPortStreamWork checks stack depth overflow indicating recursive sequence definition
44
83
*
1590
1629
                                                SeqPortSetUpAlphabet(spps, 
1591
1630
slitp->seq_data_type, newcode);
1592
1631
                                                if (slitp->seq_data != NULL)
1593
 
                                                        spps->bp = 
 
1632
                                                        spps->bp = (ByteStorePtr)
1594
1633
slitp->seq_data;
1595
1634
                                                else
1596
1635
                                                {
1681
1720
        curr_code = BioseqGetCode(bsp);
1682
1721
 
1683
1722
                SeqPortSetUpAlphabet(spp, curr_code, newcode);
1684
 
                spp->bp = bsp->seq_data;
 
1723
                spp->bp = (ByteStorePtr) bsp->seq_data;
1685
1724
 
1686
1725
         /* allocate fast lookup caches for 2na or 4na to iupacna or 4na conversion */
1687
1726
 
2617
2656
  CharPtr            tmp;
2618
2657
  Boolean            failed;
2619
2658
  Int2               depth;
 
2659
  SeqEntryPtr        scope;
2620
2660
} StreamData, PNTR StreamDataPtr;
2621
2661
 
2622
2662
/* prototype for main internal recursive processing function */
2634
2674
static Int4 SeqPortStreamGap (
2635
2675
  Int4 length,
2636
2676
  Boolean is_na,
2637
 
  StreamDataPtr sdp 
 
2677
  Boolean is_virt,
 
2678
  Boolean is_known,
 
2679
  StreamDataPtr sdp
2638
2680
)
2639
2681
 
2640
2682
{
2641
2683
  Char     buf [4004];
2642
 
  Char     ch;
2643
 
  Boolean  expand_gaps, many_dashes, single_dash;
 
2684
  Char     ch, gapchar = '-';
 
2685
  Boolean  expand_gaps, many_dashes, many_pluses, single_dash;
2644
2686
  Int4     len;
2645
2687
 
2646
2688
  if (sdp == NULL) return 0;
2647
2689
 
 
2690
  many_pluses = FALSE;
 
2691
  if (is_virt) {
 
2692
    if ((sdp->flags & SUPPRESS_VIRT_SEQ) != 0) return 0;
 
2693
    if ((sdp->flags & STREAM_VIRT_AS_PLUS) != 0) {
 
2694
      many_pluses = TRUE;
 
2695
      gapchar = '+';
 
2696
    }
 
2697
  } else if (is_known) {
 
2698
    if ((sdp->flags & KNOWN_GAP_AS_PLUS) != 0) {
 
2699
      many_pluses = TRUE;
 
2700
      gapchar = '+';
 
2701
    }
 
2702
  }
 
2703
 
2648
2704
  expand_gaps = (Boolean) ((sdp->flags & STREAM_GAP_MASK) == STREAM_EXPAND_GAPS);
2649
2705
  single_dash = (Boolean) ((sdp->flags & STREAM_GAP_MASK) == GAP_TO_SINGLE_DASH);
2650
2706
  many_dashes = (Boolean) ((sdp->flags & STREAM_GAP_MASK) == EXPAND_GAPS_TO_DASHES);
2657
2713
 
2658
2714
    /* if only indicating gap presence, send one gap character, return 0 count */
2659
2715
 
2660
 
    buf [0] = '-';
 
2716
    buf [0] = gapchar;
2661
2717
    buf [1] = '\0';
2662
2718
 
2663
2719
    sdp->proc (buf, sdp->userdata);
2669
2725
 
2670
2726
  if (length < 1) return 0;
2671
2727
 
2672
 
  if (many_dashes) {
2673
 
    ch = '-';
 
2728
  if (many_dashes || many_pluses) {
 
2729
    ch = gapchar;
2674
2730
  } else if (is_na) {
2675
2731
    ch = 'N';
2676
2732
  } else {
2876
2932
 
2877
2933
  if (bsp == NULL || sdp == NULL) return 0;
2878
2934
  if (bsp->repr != Seq_repr_raw && bsp->repr != Seq_repr_const) return 0;
2879
 
  bs = bsp->seq_data;
 
2935
 
 
2936
  is_na = (Boolean) ISA_na (bsp->mol);
 
2937
 
 
2938
  if (bsp->seq_data_type == Seq_code_gap) {
 
2939
 
 
2940
    /* support for new Seq-data.gap */
 
2941
 
 
2942
    count += SeqPortStreamGap (stop - start + 1, is_na, FALSE, FALSE, sdp);
 
2943
 
 
2944
    return count;
 
2945
  }
 
2946
 
 
2947
  /* otherwise Seq-data is a byte store */
 
2948
 
 
2949
  bs = (ByteStorePtr) bsp->seq_data;
2880
2950
  if (bs == NULL) return 0;
2881
2951
 
2882
2952
  alphabet = bsp->seq_data_type;
2883
2953
 
2884
 
  is_na = (Boolean) ISA_na (bsp->mol);
2885
 
 
2886
2954
  if (strand == Seq_strand_minus && is_na) {
2887
2955
    revcomp = TRUE;
2888
2956
  }
2947
3015
)
2948
3016
 
2949
3017
{
2950
 
  Bioseq  bsq;
2951
 
  Int4    count = 0;
 
3018
  Bioseq   bsq;
 
3019
  Int4     count = 0;
 
3020
  Boolean  is_known = TRUE;
2952
3021
 
2953
3022
  if (slitp == NULL || sdp == NULL) return 0;
2954
3023
 
2956
3025
 
2957
3026
  if (slitp->length < 1) return 0;
2958
3027
 
2959
 
  if (slitp->seq_data == NULL) {
2960
 
 
2961
 
    /* literal without sequence data is a virtual gap */
2962
 
 
2963
 
    count += SeqPortStreamGap (stop - start + 1, is_na, sdp);
 
3028
  if (slitp->seq_data == NULL || slitp->seq_data_type == Seq_code_gap) {
 
3029
 
 
3030
    /* literal without sequence data is a virtual gap, also handle new gap type */
 
3031
 
 
3032
    if (slitp->fuzz != NULL) {
 
3033
      is_known = FALSE;
 
3034
    }
 
3035
 
 
3036
    count += SeqPortStreamGap (stop - start + 1, is_na, FALSE, is_known, sdp);
2964
3037
 
2965
3038
    return count;
2966
3039
  }
3002
3075
)
3003
3076
 
3004
3077
{
3005
 
  BioseqPtr bsp;
3006
 
  Char      buf [64];
3007
 
  Int4      count = 0;
3008
 
  Char      pid [64];
3009
 
  SeqIdPtr  sip;
 
3078
  BioseqPtr    bsp;
 
3079
  Char         buf [64];
 
3080
  Int4         count = 0;
 
3081
  SeqEntryPtr  oldscope = NULL;
 
3082
  Char         pid [64];
 
3083
  SeqIdPtr     sip;
3010
3084
#ifdef OS_UNIX
3011
 
  Int2      attempts;
3012
 
  CharPtr   str;
3013
 
  int       val = 0;
 
3085
  Int2         attempts;
 
3086
  CharPtr      str;
 
3087
  int          val = 0;
3014
3088
#endif
3015
3089
 
3016
3090
  if (slp == NULL || sdp == NULL) return 0;
3018
3092
  sip = SeqLocId (slp);
3019
3093
  if (sip == NULL) return 0;
3020
3094
 
3021
 
  if (sip->choice == SEQID_GI && sip->data.intvalue <= 0) {
3022
 
 
3023
 
    /* gi 0 or negative is always a data error, just report and bail */
 
3095
  if (sip->choice == SEQID_GI && sip->data.intvalue <= 0 &&
 
3096
      (Boolean) ((sdp->flags & STREAM_ALLOW_NEG_GIS) == 0)) {
 
3097
    
 
3098
    /* gi 0 is always a data error, just report and bail */
 
3099
    /* negative gi sometimes used in-house, allow if flag set */
3024
3100
 
3025
3101
    SeqIdWrite (sip, buf, PRINTID_FASTA_SHORT, sizeof (buf) - 1);
3026
3102
    if (parentID != NULL) {
3033
3109
    return 0;
3034
3110
  }
3035
3111
 
 
3112
  oldscope = SeqEntrySetScope (sdp->scope);
3036
3113
  bsp = BioseqLockById (sip);
 
3114
  SeqEntrySetScope (oldscope);
3037
3115
 
3038
3116
#ifdef OS_UNIX
3039
3117
  if (bsp == NULL) {
3069
3147
          sleep (stream_retry_sleep);
3070
3148
        }
3071
3149
 
 
3150
        oldscope = SeqEntrySetScope (sdp->scope);
3072
3151
        bsp = BioseqLockById (sip);
 
3152
        SeqEntrySetScope (oldscope);
3073
3153
        attempts++;
3074
3154
      }
3075
3155
      if (bsp != NULL) {
3480
3560
  switch (bsp->repr) {
3481
3561
 
3482
3562
    case Seq_repr_virtual :
3483
 
      count += SeqPortStreamGap (stop - start + 1, ISA_na (bsp->mol), sdp);
 
3563
      count += SeqPortStreamGap (stop - start + 1, ISA_na (bsp->mol), TRUE, FALSE, sdp);
3484
3564
      break;
3485
3565
 
3486
3566
    case Seq_repr_raw :
3547
3627
  Char        ch, lttr;
3548
3628
  CharPtr     complementBase = " TVGH  CD  M KN   YSAABW R ";
3549
3629
  Int4        count = 0, from, to;
 
3630
  Uint2       entityID;
3550
3631
  Int2        i;
3551
3632
  StreamData  sd;
3552
3633
  SeqLocPtr   slp;
3593
3674
 
3594
3675
  if (bsp != NULL) {
3595
3676
 
 
3677
    entityID = ObjMgrGetEntityIDForPointer (bsp);
 
3678
    sd.scope = GetTopSeqEntryForEntityID (entityID);
 
3679
 
3596
3680
    count += SeqPortStreamWork (bsp, start, stop, strand, &sd);
3597
3681
 
3598
3682
  } else if (loc != NULL) {
3599
3683
 
 
3684
    sd.scope = SeqEntryGetScope ();
 
3685
 
3600
3686
    slp = SeqLocFindNext (loc, NULL);
3601
3687
    while (slp != NULL) {
3602
3688
 
3613
3699
  /* return number of bases or residues streamed to callback */
3614
3700
 
3615
3701
  if (sd.failed) {
 
3702
    if (count  < 1) return -1;
3616
3703
    return -count;
3617
3704
  }
3618
3705
 
3691
3778
  return TRUE;
3692
3779
}
3693
3780
 
3694
 
NLM_EXTERN Uint1 StreamCacheGetResidue (
 
3781
static Boolean StreamCacheRefreshBuffer (
3695
3782
  StreamCache PNTR scp
3696
3783
)
3697
3784
 
3698
3785
{
3699
 
  Bioseq     bsq;
3700
 
  SeqLocPtr  loc;
3701
 
  Uint1      residue = '\0';
3702
 
  SeqLoc     sl;
3703
 
  SeqLocPtr  slp;
3704
 
  Int4       stop;
 
3786
  Bioseq         bsq;
 
3787
  StreamFlgType  flags;
 
3788
  SeqLocPtr      loc;
 
3789
  SeqLoc         sl;
 
3790
  SeqLocPtr      slp;
 
3791
  Int4           stop;
3705
3792
 
3706
 
  if (scp == NULL) return residue;
 
3793
  if (scp == NULL) return FALSE;
3707
3794
 
3708
3795
  if (scp->ctr >= scp->total) {
3709
3796
    scp->offset += (Int4) scp->total;
3710
3797
    scp->ctr = 0;
3711
3798
    scp->total = 0;
3712
3799
 
3713
 
    if (scp->offset < 0 || scp->offset >= scp->length) return residue;
 
3800
    MemSet ((Pointer) &(scp->buf), 0, sizeof (scp->buf));
 
3801
 
 
3802
    if (scp->offset < 0 || scp->offset >= scp->length) return FALSE;
3714
3803
 
3715
3804
    stop = MIN (scp->offset + 4000L, scp->length);
3716
3805
 
 
3806
    flags = scp->flags;
 
3807
    if ((flags & STREAM_GAP_MASK) == GAP_TO_SINGLE_DASH || (flags & STREAM_GAP_MASK) == 0) {
 
3808
      /* if expand_gaps_to_dashes not equal to gaps_to_single_dash + stream_gap_mask, need to clear other bits first */
 
3809
      flags |= EXPAND_GAPS_TO_DASHES;
 
3810
    }
 
3811
    if ((flags & SUPPRESS_VIRT_SEQ) != 0) {
 
3812
      flags ^= SUPPRESS_VIRT_SEQ;
 
3813
      flags |= STREAM_VIRT_AS_PLUS;
 
3814
    }
 
3815
 
3717
3816
    if (scp->bsp != NULL) {
3718
3817
 
3719
3818
      SeqPortStreamInt (scp->bsp, scp->offset, stop - 1, Seq_strand_plus,
3720
 
                        scp->flags, (Pointer) &(scp->buf), NULL);
 
3819
                        flags, (Pointer) &(scp->buf), NULL);
3721
3820
 
3722
3821
    } else if (scp->slp != NULL) {
3723
3822
 
3741
3840
        sl.data.ptrvalue = (Pointer) slp->data.ptrvalue;
3742
3841
        sl.next = NULL;
3743
3842
      }
 
3843
 
3744
3844
      SeqPortStreamInt (&bsq, scp->offset, stop - 1, Seq_strand_plus,
3745
 
                        scp->flags, (Pointer) &(scp->buf), NULL);
 
3845
                        flags, (Pointer) &(scp->buf), NULL);
3746
3846
    }
3747
3847
 
3748
3848
    scp->total = StringLen (scp->buf);
3749
3849
  }
3750
3850
 
 
3851
  return TRUE;
 
3852
}
 
3853
 
 
3854
NLM_EXTERN Uint1 StreamCacheGetResidue (
 
3855
  StreamCache PNTR scp
 
3856
)
 
3857
 
 
3858
{
 
3859
  Uint1  residue = '\0';
 
3860
 
 
3861
  if (scp == NULL) return '\0';
 
3862
 
 
3863
  if (scp->ctr >= scp->total) {
 
3864
    if (! StreamCacheRefreshBuffer (scp)) return '\0';
 
3865
  }
 
3866
 
3751
3867
  if (scp->ctr < scp->total) {
3752
3868
    residue = scp->buf [(int) scp->ctr];
3753
3869
    (scp->ctr)++;
 
3870
 
 
3871
    if (residue == '-') {
 
3872
    
 
3873
      if ((scp->flags & STREAM_GAP_MASK) == 0) {
 
3874
        while (residue == '-') {
 
3875
          if (scp->ctr >= scp->total) {
 
3876
            if (! StreamCacheRefreshBuffer (scp)) return '\0';
 
3877
          }
 
3878
 
 
3879
          while (scp->ctr < scp->total && residue == '-') {
 
3880
            residue = scp->buf [(int) scp->ctr];
 
3881
            (scp->ctr)++;
 
3882
          }
 
3883
        }
 
3884
        if (residue == '-') return '\0';
 
3885
 
 
3886
      } else if ((scp->flags & STREAM_GAP_MASK) == GAP_TO_SINGLE_DASH) {
 
3887
 
 
3888
        while (residue == '-') {
 
3889
          if (scp->ctr >= scp->total) {
 
3890
            if (! StreamCacheRefreshBuffer (scp)) return '-';
 
3891
          }
 
3892
 
 
3893
          while (scp->ctr < scp->total && residue == '-') {
 
3894
            residue = scp->buf [(int) scp->ctr];
 
3895
            if (residue != '-') return '-';
 
3896
            (scp->ctr)++;
 
3897
          }
 
3898
        }
 
3899
      }
 
3900
 
 
3901
    } else if (residue == '+') {
 
3902
 
 
3903
      if ((scp->flags & SUPPRESS_VIRT_SEQ) != 0) {
 
3904
        while (residue == '+') {
 
3905
          if (scp->ctr >= scp->total) {
 
3906
            if (! StreamCacheRefreshBuffer (scp)) return '\0';
 
3907
          }
 
3908
 
 
3909
          while (scp->ctr < scp->total && residue == '+') {
 
3910
            residue = scp->buf [(int) scp->ctr];
 
3911
            (scp->ctr)++;
 
3912
          }
 
3913
        }
 
3914
        if (residue == '+') return '\0';
 
3915
      }
 
3916
    }
3754
3917
  }
3755
3918
 
3756
3919
  return residue;
3788
3951
*
3789
3952
********************************************************************************/
3790
3953
 
3791
 
NLM_EXTERN ByteStorePtr ProteinFromCdRegionExEx (SeqFeatPtr sfp, Boolean include_stop, Boolean remove_trailingX, BoolPtr altStartP)
 
3954
NLM_EXTERN ByteStorePtr ProteinFromCdRegionExEx (SeqFeatPtr sfp, Boolean include_stop, Boolean remove_trailingX, BoolPtr altStartP, Boolean farProdFetchOK)
3792
3955
 
3793
3956
{
3794
3957
  ByteStorePtr   bs;
3833
3996
  tableExists = (Boolean) (tbl != NULL);
3834
3997
 
3835
3998
  bs = TransTableTranslateCdRegionEx (&tbl, sfp, include_stop, remove_trailingX,
3836
 
                                      FALSE, altStartP);
 
3999
                                      FALSE, altStartP, farProdFetchOK);
3837
4000
 
3838
4001
  /* save FSA in genetic code-specific app property name */
3839
4002
 
3847
4010
NLM_EXTERN ByteStorePtr ProteinFromCdRegionEx (SeqFeatPtr sfp, Boolean include_stop, Boolean remove_trailingX)
3848
4011
 
3849
4012
{
3850
 
  return ProteinFromCdRegionExEx (sfp, include_stop, remove_trailingX, NULL);
 
4013
  return ProteinFromCdRegionExEx (sfp, include_stop, remove_trailingX, NULL, TRUE);
3851
4014
}
3852
4015
 
3853
4016
NLM_EXTERN ByteStorePtr ProteinFromCdRegionExWithTrailingCodonHandling
5075
5238
        return retval;
5076
5239
}
5077
5240
 
5078
 
static Boolean ComplementSeqData (Uint1 seqtype, Int4 seqlen, ByteStorePtr bysp)
 
5241
NLM_EXTERN Boolean ComplementSeqData (Uint1 seqtype, Int4 seqlen, SeqDataPtr sdp)
5079
5242
{
5080
5243
        SeqCodeTablePtr sctp;
5081
 
        long                    readbyte, bslen;
 
5244
        ByteStorePtr    bysp;
 
5245
        long                readbyte, bslen;
5082
5246
        Uint1           byte = 0, byte_to, newbyte = 0, residue;
5083
5247
        Uint1           comp, bitctr, mask, lshift, rshift, bc;
5084
5248
        
 
5249
        if (seqtype == Seq_code_gap) return FALSE;
 
5250
 
 
5251
    bysp = (ByteStorePtr) sdp;
5085
5252
        if (bysp == NULL)
5086
5253
        {
5087
5254
                ErrPostEx(SEV_ERROR,0,0, "Error:  no sequence data\n");
5248
5415
} /* BioseqComplement */
5249
5416
 
5250
5417
 
5251
 
static Boolean LIBCALL ReverseSeqData (Uint1 seqtype, Int4 seqlen, ByteStorePtr bysp1)
 
5418
NLM_EXTERN Boolean LIBCALL ReverseSeqData (Uint1 seqtype, Int4 seqlen, SeqDataPtr sdp)
5252
5419
{
5253
 
        ByteStorePtr    bysp2 = '\0';
 
5420
        ByteStorePtr    bysp1, bysp2 = '\0';
5254
5421
        long            readbyte, bslen = 0;
5255
5422
        Int4            count = 0;
5256
5423
        Uint1   byte = 0, byte2, byte_to = 0, byte_to2, newbyte = 0;
5257
5424
        Uint1           newbyte2, finalbyte, residue, residue2, bitctr, bc2 = 0;
5258
5425
        Uint1           bitctr2, mask, mask2, lshift, rshift, bc = 0, jagged;
5259
5426
        
 
5427
        if (seqtype == Seq_code_gap) return FALSE;
 
5428
 
 
5429
    bysp1 = (ByteStorePtr) sdp;
 
5430
 
5260
5431
  if (bysp1 == NULL)
5261
5432
  {
5262
5433
    ErrPostEx(SEV_ERROR,0,0, "Error:  No sequence data\n");
6528
6699
  return bases;
6529
6700
}
6530
6701
 
6531
 
static ValNodePtr MakeCodeBreakList (SeqLocPtr cdslocation, Int4 len, CodeBreakPtr cbp, Uint1 frame)
 
6702
NLM_EXTERN ValNodePtr MakeCodeBreakList (SeqLocPtr cdslocation, Int4 len, CodeBreakPtr cbp, Uint1 frame)
6532
6703
 
6533
6704
{
6534
6705
  Int4        adjust = 0, pos, pos1, pos2;
6587
6758
  Boolean include_stop,
6588
6759
  Boolean remove_trailingX,
6589
6760
  Boolean no_stop_at_end_of_complete_cds,
6590
 
  BoolPtr altStartP
 
6761
  BoolPtr altStartP,
 
6762
  Boolean farProdFetchOK
6591
6763
)
6592
6764
 
6593
6765
{
6658
6830
 
6659
6831
  no_start = FALSE;
6660
6832
  part_loc = SeqLocPartialCheck (location);
6661
 
  part_prod = SeqLocPartialCheck (product);
 
6833
  part_prod = SeqLocPartialCheckEx (product, farProdFetchOK);
6662
6834
  if ((part_loc & SLP_START) /* || (part_prod & SLP_START) */) {
6663
6835
    no_start = TRUE;
6664
6836
  }
6845
7017
{
6846
7018
  return TransTableTranslateCommon (tblptr, location, NULL, FALSE, genCode,
6847
7019
                                    frame, NULL, include_stop,
6848
 
                                    remove_trailingX, FALSE, NULL);
 
7020
                                    remove_trailingX, FALSE, NULL, TRUE);
6849
7021
}
6850
7022
 
6851
7023
NLM_EXTERN ByteStorePtr TransTableTranslateCdRegionEx (
6854
7026
  Boolean include_stop,
6855
7027
  Boolean remove_trailingX,
6856
7028
  Boolean no_stop_at_end_of_complete_cds,
6857
 
  BoolPtr altStartP
 
7029
  BoolPtr altStartP,
 
7030
  Boolean farProdFetchOK
6858
7031
)
6859
7032
 
6860
7033
{
6883
7056
  return TransTableTranslateCommon (tblptr, cds->location, cds->product, partial3,
6884
7057
                                    genCode, crp->frame, crp->code_break,
6885
7058
                                    include_stop, remove_trailingX,
6886
 
                                    no_stop_at_end_of_complete_cds, altStartP);
 
7059
                                    no_stop_at_end_of_complete_cds, altStartP, farProdFetchOK);
6887
7060
}
6888
7061
 
6889
7062
NLM_EXTERN ByteStorePtr TransTableTranslateCdRegion (
6896
7069
 
6897
7070
{
6898
7071
  return TransTableTranslateCdRegionEx (tblptr, cds, include_stop, remove_trailingX,
6899
 
                                        no_stop_at_end_of_complete_cds, NULL);
 
7072
                                        no_stop_at_end_of_complete_cds, NULL, TRUE);
6900
7073
}
6901
7074
 
6902
7075
/* allow reuse of translation tables by saving as AppProperty */
8855
9028
  if (slp != NULL) {
8856
9029
    slp->length = len;
8857
9030
    ValNodeAddPointer (seq_ext, (Int2) 2, (Pointer) slp);
8858
 
    slp->seq_data = BSNew (slp->length);
 
9031
    slp->seq_data = (SeqDataPtr) BSNew (slp->length);
8859
9032
    slp->seq_data_type = Seq_code_iupacna;
8860
 
    AddBasesToByteStore (slp->seq_data, str);
 
9033
    AddBasesToByteStore ((ByteStorePtr) slp->seq_data, str);
8861
9034
  }
8862
9035
  return len;
8863
9036
}
9066
9239
    
9067
9240
  MemFree (bases);
9068
9241
 
9069
 
  bsp->seq_data = BSFree (bsp->seq_data);
 
9242
  bsp->seq_data = SeqDataFree (bsp->seq_data, bsp->seq_data_type);
9070
9243
  bsp->seq_data_type = 0;
9071
9244
  bsp->repr = Seq_repr_delta;
9072
9245
  bsp->seq_ext_type = 4;