~ubuntu-branches/ubuntu/saucy/ncbi-tools6/saucy-proposed

« back to all changes in this revision

Viewing changes to tools/toasn3.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2009-08-11 22:03:47 UTC
  • mfrom: (1.4.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090811220347-g4b6lzdvphvvbpiu
* New upstream release.
* debian/libncbi6.symbols: update accordingly.
* debian/control: clean up obsolete or redundant relationship declarations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
static char const rcsid[] = "$Id: toasn3.c,v 6.106 2008/11/10 18:17:13 kans Exp $";
 
1
static char const rcsid[] = "$Id: toasn3.c,v 6.112 2009/06/04 16:14:29 kans Exp $";
2
2
 
3
3
/*****************************************************************************
4
4
*
33
33
#endif
34
34
#define THIS_MODULE this_module
35
35
 
 
36
 
36
37
#define num_bond 5
37
38
static CharPtr feat_bond[num_bond] = {NULL, "disulfide bond", "thiolester bond", "xlink bond", "thioether bond"};
38
39
 
955
956
Int4 SeqEntryToAsn3 (SeqEntryPtr sep, Boolean strip_old, Boolean source_correct, Boolean taxserver, SeqEntryFunc taxfun)
956
957
{
957
958
    return SeqEntryToAsn3Ex(sep, strip_old, source_correct, 
958
 
            taxserver, taxfun, NULL);
 
959
            taxserver, taxfun, NULL, FALSE);
959
960
}
960
961
static Boolean is_equiv(SeqEntryPtr sep)
961
962
{
1037
1038
*        txfun - Taxon3ReplaceOrgInSeqEntry
1038
1039
*        taxmerge - Tax3MergeSourceDescr
1039
1040
*****************************************************************************/
1040
 
Int4 SeqEntryToAsn3Ex (SeqEntryPtr sep, Boolean strip_old, Boolean source_correct, Boolean taxserver, SeqEntryFunc taxfun, SeqEntryFunc taxmerge)
 
1041
Int4 SeqEntryToAsn3Ex (SeqEntryPtr sep, Boolean strip_old, Boolean source_correct, Boolean taxserver, SeqEntryFunc taxfun, SeqEntryFunc taxmerge, Boolean gpipeMode)
1041
1042
{
1042
1043
    ToAsn3 ta;
1043
1044
    OrgFixPtr ofp = NULL;
1061
1062
    if (sep == NULL) {
1062
1063
        return ERR_INPUT;
1063
1064
    }
 
1065
 
 
1066
    RemoveAllNcbiCleanupUserObjects (sep);
 
1067
 
1064
1068
    update_date_pos = GetUpdateDatePos (sep);
1065
1069
    RemoveEmptyTitleAndPubGenAsOnlyPub (sep);
1066
1070
    if (source_correct) {
1068
1072
    }
1069
1073
    toporg(sep);
1070
1074
    SeqEntryExplore(sep, (Pointer)(&ta), FindOrg);
1071
 
    
 
1075
 
1072
1076
    if (ta.had_biosource) {    
1073
1077
/* entry is in asn.1 spec 3.0 already do the checks only */
1074
1078
        retval |= INFO_ASNNEW;
1102
1106
        EntryChangeGBSource(sep); 
1103
1107
        SeqEntryExplore (sep, NULL, FixProtMolInfo);
1104
1108
        SeqEntryExplore (sep, NULL, FuseMolInfos);
1105
 
        SeqEntryExplore(sep, NULL, StripProtXref);
 
1109
        if (! gpipeMode) {
 
1110
          SeqEntryExplore(sep, NULL, StripProtXref);
 
1111
        }
1106
1112
        SeqEntryExplore(sep, (Pointer)(&qm), CheckMaps);
1107
1113
        /*
1108
1114
        if (qm.same == TRUE) {
1172
1178
    EntryChangeGBSource(sep); 
1173
1179
    SeqEntryExplore (sep, NULL, FixProtMolInfo);
1174
1180
    SeqEntryExplore (sep, NULL, FuseMolInfos);
1175
 
    SeqEntryExplore(sep, NULL, StripProtXref);
 
1181
    if (! gpipeMode) {
 
1182
      SeqEntryExplore(sep, NULL, StripProtXref);
 
1183
    }
1176
1184
    SeqEntryExplore(sep, (Pointer)(&qm), CheckMaps);
1177
1185
    /*
1178
1186
    if (qm.same == TRUE) {
3327
3335
 
3328
3336
static void ChangeGBDiv (SeqEntryPtr sep, Pointer data, Int4 index, Int2 indent)
3329
3337
{
3330
 
    BioseqPtr         bsp=NULL;
3331
 
    BioseqSetPtr     bssp;
3332
 
    ValNodePtr        descr=NULL, vnp;
3333
 
    CharPtr            div;
3334
 
    GBBlockPtr        gbp;
3335
 
    MolInfoPtr        mfp=NULL;
3336
 
    Int2 i;
 
3338
    BioseqPtr     bsp = NULL;
 
3339
    BioseqSetPtr  bssp;
 
3340
    ValNodePtr    descr = NULL, vnp;
 
3341
    CharPtr       div;
 
3342
    GBBlockPtr    gbp;
 
3343
    Int2          i;
 
3344
    Boolean       is_patent = FALSE;
 
3345
    MolInfoPtr    mfp = NULL;
 
3346
    SeqIdPtr      sip;
3337
3347
 
3338
3348
    div = (CharPtr) data;
3339
3349
    if (IS_Bioseq(sep)) {
3340
3350
        bsp = (BioseqPtr)(sep->data.ptrvalue);
3341
3351
        descr = bsp->descr;
 
3352
        for (sip = bsp->id; sip != NULL; sip = sip->next) {
 
3353
          if (sip->choice == SEQID_PATENT) {
 
3354
            is_patent = TRUE;
 
3355
          }
 
3356
        }
3342
3357
    } else {
3343
3358
        bssp = (BioseqSetPtr)(sep->data.ptrvalue);
3344
3359
        descr = bssp->descr;
3352
3367
    for (vnp = descr; vnp != NULL; vnp = vnp->next) {
3353
3368
        if (vnp->choice == Seq_descr_genbank) {
3354
3369
            gbp = (GBBlockPtr) vnp->data.ptrvalue;
3355
 
            if (gbp == NULL) {
3356
 
                return;
3357
 
            }
 
3370
            if (gbp == NULL) continue;
3358
3371
            if (mfp) {
3359
3372
                if (mfp->tech == MI_TECH_htgs_0 || 
3360
3373
                        mfp->tech == MI_TECH_htgs_1 || 
3365
3378
                    CheckKeywords(gbp, mfp->tech);
3366
3379
                }
3367
3380
            }
3368
 
            if (gbp->div == NULL) {
3369
 
                return;
3370
 
            }
 
3381
            if (gbp->div == NULL) continue;
3371
3382
            for (i=0; i < TOTAL_TECH; i++) {
3372
3383
                if (StringCmp(gbp->div, check_tech[i].name) == 0) {
3373
3384
                    break;
3401
3412
                    gbp->div = MemFree(gbp->div);
3402
3413
                } else if (StringCmp(gbp->div, "UNC") == 0) {
3403
3414
                    gbp->div = MemFree(gbp->div);
 
3415
                } else if (StringCmp(gbp->div, "PAT") == 0 && is_patent) {
 
3416
                    gbp->div = MemFree(gbp->div);
3404
3417
                }
3405
3418
            } 
3406
3419
        }
3415
3428
  OrgNamePtr  onp;
3416
3429
} GBSourceData, PNTR GBSourcePtr;
3417
3430
 
3418
 
static Boolean AbbrevStrICmp (CharPtr str, CharPtr gbpsrc)
 
3431
static Boolean AbbrevStrIEql (CharPtr str, CharPtr gbpsrc)
3419
3432
 
3420
3433
{
3421
3434
  Char     buf [200];
3442
3455
  *ptr = '\0';
3443
3456
  StringCat (ptr, str);
3444
3457
 
3445
 
  return StringICmp (buf, gbpsrc);
 
3458
  return (Boolean) (StringICmp (buf, gbpsrc) == 0);
3446
3459
}
3447
3460
 
3448
3461
static Boolean CanDeleteGBSource (GBSourcePtr gsp, CharPtr gbpsrc)
3477
3490
      ptr++;
3478
3491
      ch = *ptr;
3479
3492
    }
 
3493
  } else {
 
3494
    str = StringStr (gbpsrc, "strain)");
 
3495
    if (str != NULL) return FALSE; /* do not handle this case for now */
3480
3496
  }
3481
3497
  if (foundStrain) {
3482
3498
    *str = '\0';
3505
3521
  if (StringDoesHaveText (gsp->common) && StringICmp (gsp->common, gbpsrc) == 0) return TRUE;
3506
3522
  if (StringDoesHaveText (gsp->oldname) && StringICmp (gsp->oldname, gbpsrc) == 0) return TRUE;
3507
3523
 
3508
 
  if (StringDoesHaveText (gsp->taxname) && AbbrevStrICmp (gsp->taxname, gbpsrc) == 0) return TRUE;
3509
 
  if (StringDoesHaveText (gsp->oldname) && AbbrevStrICmp (gsp->oldname, gbpsrc) == 0) return TRUE;
 
3524
  if (StringDoesHaveText (gsp->taxname) && AbbrevStrIEql (gsp->taxname, gbpsrc)) return TRUE;
 
3525
  if (StringDoesHaveText (gsp->oldname) && AbbrevStrIEql (gsp->oldname, gbpsrc)) return TRUE;
3510
3526
 
3511
3527
 
3512
3528
  return FALSE;
3513
3529
}
3514
3530
 
 
3531
static void TrimPeriodFromEnd (CharPtr str)
 
3532
 
 
3533
{
 
3534
  size_t  len;
 
3535
 
 
3536
  len = StringLen (str);
 
3537
  if (len < 2) return;
 
3538
  if (str [len - 1] == '.') {
 
3539
    str [len - 1] = '\0';
 
3540
  }
 
3541
}
 
3542
 
3515
3543
static void ChangeGBSource (SeqEntryPtr sep, Pointer data, Int4 index, Int2 indent)
3516
3544
{
3517
3545
    BioseqPtr    bsp;
3544
3572
            } else if (len > 6 && StringCmp (s + len - 5, " rRNA.") == 0) {
3545
3573
              s [len - 6] = '\0';
3546
3574
            }
 
3575
            TrimPeriodFromEnd (s);
 
3576
            /*
3547
3577
            if (*(s+StringLen(s)-1) =='.') {
3548
3578
                *(s+StringLen(s)-1) = '\0';
3549
3579
            }
 
3580
            */
3550
3581
            if (CanDeleteGBSource (gsp, s)) {
3551
3582
                gbp->source = MemFree (gbp->source);
3552
3583
            }
3608
3639
        if (StringDoesHaveText (orp->taxname)) {
3609
3640
          gsd.taxname = StringSave (orp->taxname);
3610
3641
          TrimSpacesAndJunkFromEnds (gsd.taxname, FALSE);
 
3642
          TrimPeriodFromEnd (gsd.taxname);
3611
3643
        }
3612
3644
        if (StringDoesHaveText (orp->common)) {
3613
3645
          gsd.common = StringSave (orp->common);
3614
3646
          TrimSpacesAndJunkFromEnds (gsd.common, FALSE);
 
3647
          TrimPeriodFromEnd (gsd.common);
3615
3648
        }
3616
3649
        onp = orp->orgname;
3617
3650
        if (onp != NULL) {
3621
3654
            if (omp->subtype == ORGMOD_strain) {
3622
3655
              gsd.strain = StringSave (omp->subname);
3623
3656
              TrimSpacesAndJunkFromEnds (gsd.strain, FALSE);
 
3657
              TrimPeriodFromEnd (gsd.strain);
3624
3658
            } else if (omp->subtype == ORGMOD_old_name) {
3625
3659
              gsd.oldname = StringSave (omp->subname);
3626
3660
              TrimSpacesAndJunkFromEnds (gsd.oldname, FALSE);
 
3661
              TrimPeriodFromEnd (gsd.oldname);
3627
3662
            }
3628
3663
          }
3629
3664
          if (StringDoesHaveText (onp->div)) {