~ubuntu-branches/ubuntu/raring/ncbi-tools6/raring

« back to all changes in this revision

Viewing changes to sequin/sequin7.c

  • Committer: Package Import Robot
  • Author(s): Aaron M. Ucko
  • Date: 2011-09-05 18:55:02 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110905185502-iuvmoe65ytljhckn
Tags: 6.1.20110713-1
* New upstream release.
* debian/*.symbols: update accordingly.
* make/makeshlb.unx: link libcn3dOGL.so against -lm for sqrt.
* doc/man/*.1: update for new release.
* debian/rules:
  - (VIB): add asnmacro, as upstream takes care to publish binaries thereof.
  - Retire obsolete multiarch-unaware checks for libpthread.
  - Fully modernize Debhelper usage; in particular, transition to overrides.
* debian/compat: advance to 9 per rules modernization.
* debian/ncbi-tools-bin.install: add asnmacro.
* make/makenet.unx: link asnmacro only against libraries it directly needs.
* doc/man/asnmacro.1: give asnmacro a man page.
* doc/man/Psequin.1: list it in SEE ALSO.
* network/id1arch/idfetch.c: revert redundant change (from #295110).
* Convert to multiarch.
  - debian/rules: Install libraries (and ncbithr.o) to multiarch directories.
  - debian/lib*.install: match multiarch library paths.
  - debian/control:
    + Build-Depends: debhelper (>= 8.1.3~), implying a recent dpkg-dev.
    + Set Multi-Arch: as appropriate across the board, and specify
      Pre-Depends: ${misc:Pre-Depends} for runtime libraries.
* debian/*.lintian-overrides: drop leading slashes for Lintian 2.5.x.
* debian/control: Standards-Version: 3.9.2 (already compliant).

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   1/3/98
31
31
*
32
 
* $Revision: 6.388 $
 
32
* $Revision: 6.410 $
33
33
*
34
34
* File Description: 
35
35
*
390
390
  return hgt;
391
391
}
392
392
 
 
393
static void DoNetConf (ButtoN b)
 
394
 
 
395
{
 
396
  NetConfigureProc ((IteM) b);
 
397
}
 
398
 
393
399
extern ForM CreateStartupForm (Int2 left, Int2 top, CharPtr title,
394
400
                               BtnActnProc startFa2htgs,
395
401
                               BtnActnProc startPhrap,
452
458
    d = HiddenGroup (k, 4, 0, ChangeDestination);
453
459
    RadioButton (d, "GenBank");
454
460
    RadioButton (d, "EMBL");
455
 
    RadioButton (d, "DDBJ");
456
461
    if (GetAppParam ("SEQUIN", "PREFERENCES", "DATABASE", NULL, str, sizeof (str))) {
457
462
      if (StringICmp (str, "GenBank") == 0) {
458
463
        SetValue (d, 1);
459
464
      } else if (StringICmp (str, "EMBL") == 0) {
460
465
        SetValue (d, 2);
461
 
      } else if (StringICmp (str, "DDBJ") == 0) {
462
 
        SetValue (d, 3);
463
466
      } else {
464
467
        SetValue (d, 1);
465
468
      }
490
493
    if (fetchFromNet != NULL) {
491
494
      b = PushButton (c, "Download From Entrez", fetchFromNet);
492
495
      SetObjectExtra (b, sfp, NULL);
 
496
    } else {
 
497
      b = PushButton (c, "Network Configure", DoNetConf);
 
498
      SetObjectExtra (b, sfp, NULL);
493
499
    }
494
500
    b = PushButton (c, "Show Help", showHelp);
495
501
    SetObjectExtra (b, sfp, NULL);
805
811
  FormatFormPtr  ffp;
806
812
  GrouP          g1, g2, g3;
807
813
  GrouP          h;
 
814
  GrouP          wizards = NULL;
808
815
  PrompT         ppt;
809
816
  Char           str [32];
810
817
  WindoW         w;
836
843
      }
837
844
    }
838
845
 
 
846
 
839
847
    ppt = StaticPrompt (g1, "Submission type", 0, 0, programFont, 'l');
840
848
    ffp->package = HiddenGroup (g1, 2, 0, EnableOrDisableFormats);
841
849
    SetObjectExtra (ffp->package, ffp, NULL);
881
889
    b = PushButton (c, " Next Form >> ", goToNext);
882
890
    SetObjectExtra (b, ffp, NULL);
883
891
 
884
 
    AlignObjects (ALIGN_LEFT, (HANDLE) g1, (HANDLE) g2, (HANDLE) g3, NULL);
 
892
    AlignObjects (ALIGN_LEFT, (HANDLE) g1, (HANDLE) g2, (HANDLE) g3, (HANDLE) wizards, NULL);
885
893
    AlignObjects (ALIGN_CENTER, (HANDLE) h, (HANDLE) c, NULL);
886
894
 
887
895
    RealizeWindow (w);
8427
8435
}
8428
8436
 
8429
8437
 
8430
 
static Int2 CorrectRNAStrandednessForEntityID (Uint2 entityID, Boolean use_smart)
 
8438
NLM_EXTERN Int2 CorrectRNAStrandednessForEntityID (Uint2 entityID, Boolean use_smart)
8431
8439
 
8432
8440
{
8433
8441
  SeqEntryPtr             sep;
11295
11303
  ValNodePtr       list = NULL, vnp;
11296
11304
  BioseqPtr        bsp = NULL;
11297
11305
  SeqLocPtr        delete_loc;
11298
 
  Int4             len, loc_left = -1, loc_right = -1;
 
11306
  Int4             loc_left = -1, loc_right = -1;
11299
11307
  
11300
11308
  vnp = item_list;
11301
11309
  while (vnp != NULL)
11988
11996
static void RefreshBarcodeList (Pointer data)
11989
11997
{
11990
11998
  BarcodeToolPtr vstp;
11991
 
  ValNodePtr pass_fail_list = NULL, vnp;
 
11999
  ValNodePtr pass_list = NULL;
11992
12000
  Int4       num_fail = 0, num_pass = 0;
11993
12001
  Char       msg[30];
11994
12002
 
11998
12006
  PointerToDialog (vstp->clickable_list, NULL);
11999
12007
  vstp->item_list = BarcodeTestResultsListFree (vstp->item_list);
12000
12008
 
12001
 
  vstp->item_list = GetBarcodeFailedAccessionList(vstp->top_sep, vstp->cfg);
 
12009
  vstp->item_list = GetBarcodePassFail(vstp->top_sep, vstp->cfg);
 
12010
  pass_list = BarcodeTestResultsExtractPass(&(vstp->item_list));
 
12011
  num_pass = ValNodeLen (pass_list);
 
12012
  pass_list = BarcodeTestResultsListFree (pass_list);
 
12013
  num_fail = ValNodeLen (vstp->item_list);
12002
12014
  PointerToDialog (vstp->clickable_list, vstp->item_list);  
12003
12015
 
12004
 
  pass_fail_list = GetBarcodePassFail (vstp->top_sep, vstp->cfg);
12005
 
  for (vnp = pass_fail_list; vnp != NULL; vnp = vnp->next) 
12006
 
  {
12007
 
    if (PassBarcodeTests(vnp->data.ptrvalue)) 
12008
 
    {
12009
 
      num_pass ++;
12010
 
    }
12011
 
    else
12012
 
    {
12013
 
      num_fail++;
12014
 
    }
12015
 
  }
12016
 
  pass_fail_list = BarcodeTestResultsListFree (pass_fail_list);
12017
12016
  sprintf (msg, "%d pass, %d fail", num_pass, num_fail);
12018
12017
  SetTitle (vstp->pass_fail_summary, msg);
12019
12018
}
12248
12247
{
12249
12248
  BarcodeToolPtr vstp;
12250
12249
  LogInfoPtr     lip;
12251
 
  ValNodePtr     object_list;
12252
 
  SeqEntryPtr    sep;
 
12250
  ValNodePtr     vnp;
 
12251
  BarcodeTestResultsPtr res;
 
12252
  Char                  id_txt[100];
12253
12253
 
12254
12254
  vstp = (BarcodeToolPtr) GetObjectExtra (b);
12255
12255
  if (vstp == NULL) return;
12256
12256
 
12257
 
  sep = GetTopSeqEntryForEntityID (vstp->input_entityID);
12258
 
  object_list = GetBarcodeLowTraceList(sep);
12259
 
 
12260
 
  if (object_list == NULL)
12261
 
  {
12262
 
    Message (MSG_ERROR, "No low-trace entries found");
12263
 
    return;
 
12257
  lip = OpenLog ("BARCODE Keywords Removed");
 
12258
  for (vnp = vstp->item_list; vnp != NULL; vnp = vnp->next) {
 
12259
    res = (BarcodeTestResultsPtr) vnp->data.ptrvalue;
 
12260
    if (res->failed_tests[eBarcodeTest_LowTrace]) {
 
12261
      if (RemoveBarcodeKeywordFromBioseq (res->bsp))
 
12262
      {
 
12263
        SeqIdWrite (SeqIdFindBest (res->bsp->id, SEQID_GENBANK), id_txt, PRINTID_REPORT, sizeof (id_txt) - 1);
 
12264
        fprintf (lip->fp, "%s\n", id_txt);
 
12265
      }
 
12266
    }
12264
12267
  }
12265
 
  
12266
 
  lip = OpenLog ("BARCODE Keywords Removed");
12267
 
  RemoveBarcodeKeywordsFromObjectList (lip->fp, object_list);
12268
 
  object_list = ValNodeFree (object_list);
12269
12268
 
12270
12269
  RefreshBarcodeList (vstp);
12271
12270
  RedrawBarcodeTool (vstp);  
12275
12274
  ObjMgrSendMsg (OM_MSG_UPDATE, vstp->input_entityID, 0, 0);
12276
12275
  Update();
12277
12276
 
12278
 
  lip->data_in_log = TRUE;
12279
12277
  CloseLog (lip);
12280
12278
  lip = FreeLog (lip);
12281
12279
}
12426
12424
}
12427
12425
 
12428
12426
 
 
12427
static void BarcodeTestMissingPrimerAndCountryReport (ButtoN b)
 
12428
{
 
12429
  BarcodeToolPtr vstp;
 
12430
  ValNodePtr     object_list, vnp;
 
12431
  BarcodeTestResultsPtr res;
 
12432
  CharPtr               barcode_id, genbank_id, what;
 
12433
  LogInfoPtr     lip;
 
12434
 
 
12435
  vstp = (BarcodeToolPtr) GetObjectExtra (b);
 
12436
  if (vstp == NULL) return;
 
12437
 
 
12438
  object_list = GetBarcodePassFail (vstp->top_sep, vstp->cfg);
 
12439
  lip = OpenLog ("BARCODE Compliance");
 
12440
  for (vnp = object_list; vnp != NULL; vnp = vnp->next)
 
12441
  {
 
12442
    res = (BarcodeTestResultsPtr) vnp->data.ptrvalue;
 
12443
    barcode_id = BarcodeTestBarcodeIdString (res->bsp);
 
12444
    genbank_id = BarcodeTestGenbankIdString (res->bsp);
 
12445
    if (res->failed_tests[eBarcodeTest_Primers]) {
 
12446
      if (res->failed_tests[eBarcodeTest_Country]) {
 
12447
        what = "primers and country";
 
12448
      } else {
 
12449
        what = "primers";
 
12450
      }
 
12451
    } else if (res->failed_tests[eBarcodeTest_Country]) {
 
12452
      what = "country";
 
12453
    } else {
 
12454
      what = NULL;
 
12455
    }
 
12456
 
 
12457
    if (what != NULL) {
 
12458
      fprintf (lip->fp, "%s\t%s\t Missing %s\n", barcode_id, genbank_id, what);
 
12459
      lip->data_in_log = TRUE;
 
12460
    }
 
12461
 
 
12462
    barcode_id = MemFree (barcode_id);
 
12463
    genbank_id = MemFree (genbank_id);
 
12464
  }
 
12465
 
 
12466
  if (!lip->data_in_log) {
 
12467
    Message (MSG_OK, "No sequences are missing primers or country");
 
12468
  }
 
12469
  CloseLog (lip);
 
12470
  lip = FreeLog (lip);
 
12471
  object_list = BarcodeTestResultsListFree (object_list);
 
12472
}
 
12473
 
 
12474
 
12429
12475
extern DialoG BarcodeTestResultsDisplay (GrouP h, BarcodeTestConfigPtr cfg);
12430
12476
 
12431
12477
static void BarcodeTestMakeTagTable (ButtoN b)
13098
13144
} StripReportCollectData, PNTR StripReportCollectPtr;
13099
13145
 
13100
13146
 
13101
 
static void FindMissingKeywordsCallback (BioseqPtr bsp, Pointer data)
13102
 
{
13103
 
  Char             id_buf[255];
13104
 
  StripReportCollectPtr  s;
13105
 
  BarcodeTestResultsPtr  res;
13106
 
  CharPtr                reasons, tmp;
13107
 
 
13108
 
  if (bsp == NULL || !HasBARCODETech (bsp) || (s = (StripReportCollectPtr) data) == NULL || BioseqHasBarcodeKeyword(bsp)) {
13109
 
    return;
13110
 
  } else {
13111
 
    res = BarcodeTestResultsForBioseq(bsp, s->cfg);
13112
 
    reasons = GetBarcodeTestFailureReasons (res);
13113
 
    res = BarcodeTestResultsFree (res);
13114
 
 
13115
 
    SeqIdWrite (SeqIdFindBest (bsp->id, SEQID_GENBANK), id_buf, PRINTID_TEXTID_ACC_ONLY, sizeof (id_buf) - 1);
13116
 
 
13117
 
    ValNodeAddPointer (&(s->strip_report_list), 0, StripReportNew(id_buf, reasons));
13118
 
    reasons = MemFree (reasons);
13119
 
  }
13120
 
}
13121
 
 
13122
 
 
13123
13147
static void ProcessOneFrameFindFile (CharPtr filename, Pointer userdata)
13124
13148
 
13125
13149
{
13198
13222
{
13199
13223
  BarcodeToolPtr drfp;
13200
13224
  StripReportCollectData sd;
13201
 
  ValNodePtr     vnp;
 
13225
  ValNodePtr     list, vnp;
13202
13226
  SeqEntryPtr    sep;
13203
13227
  LogInfoPtr     lip;
13204
13228
  Char           path [PATH_MAX];
13205
13229
  CharPtr        cp;
13206
13230
  StripReportPtr sp;
13207
13231
  Boolean        require_keyword;
 
13232
  BarcodeTestResultsPtr  res;
 
13233
  CharPtr                reasons;
 
13234
  Char                   id_buf[255];
13208
13235
 
13209
13236
  drfp = (BarcodeToolPtr) GetObjectExtra (b);
13210
13237
  if (drfp == NULL) return;
13218
13245
  }
13219
13246
  require_keyword = sd.cfg->require_keyword;
13220
13247
  sd.cfg->require_keyword = FALSE;
13221
 
  VisitBioseqsInSep (sep, &sd, FindMissingKeywordsCallback);
 
13248
  list = GetBarcodePassFail (sep, sd.cfg);
13222
13249
  sd.cfg->require_keyword = require_keyword;
13223
13250
  if (drfp->cfg == NULL) {
13224
13251
    sd.cfg = BarcodeTestConfigFree (sd.cfg);
13225
13252
  }
13226
13253
 
 
13254
  for (vnp = list; vnp != NULL; vnp = vnp->next) {
 
13255
    res = (BarcodeTestResultsPtr) vnp->data.ptrvalue;
 
13256
    if (res != NULL && !BioseqHasBarcodeKeyword(res->bsp)) {
 
13257
      reasons = GetBarcodeTestFailureReasons (res);
 
13258
      SeqIdWrite (SeqIdFindBest (res->bsp->id, SEQID_GENBANK), id_buf, PRINTID_TEXTID_ACC_ONLY, sizeof (id_buf) - 1);
 
13259
      ValNodeAddPointer (&(sd.strip_report_list), 0, StripReportNew(id_buf, reasons));
 
13260
      reasons = MemFree (reasons);
 
13261
    }
 
13262
  }
 
13263
  list = BarcodeTestResultsListFree(list);
 
13264
 
13227
13265
  path [0] = '\0';
13228
13266
  if (GetInputFileName (path, sizeof (path), NULL, "TEXT")) {    
13229
13267
    cp = StringRChr (path, '\\');
13321
13359
  c4 = HiddenGroup (h, 6, 0, NULL);
13322
13360
  SetGroupSpacing (c4, 10, 10);
13323
13361
 
13324
 
  b = PushButton (c4, "Compliance Report", BarcodeTestComplianceReport);
13325
 
  SetObjectExtra (b, drfp, NULL);
13326
 
  b = PushButton (c4, "iBOL Compliance Report", BarcodeTestIbolComplianceReport);
 
13362
  b = PushButton (c4, "Compliance Report", BarcodeTestIbolComplianceReport);
13327
13363
  SetObjectExtra (b, drfp, NULL);  
13328
13364
  b = PushButton (c4, "Failure Report", BarcodeReportButton);
13329
13365
  SetObjectExtra (b, drfp, NULL);
13333
13369
  SetObjectExtra (b, drfp, NULL);
13334
13370
  b = PushButton (c4, "Barcode Strip Report", MakeBarcodeStripReport);
13335
13371
  SetObjectExtra (b, drfp, NULL);
13336
 
 
13337
 
 
 
13372
  b = PushButton (c4, "Missing Country and Primers Report", BarcodeTestMissingPrimerAndCountryReport);
 
13373
  SetObjectExtra (b, drfp, NULL);
13338
13374
 
13339
13375
  c5 = HiddenGroup (h, 5, 0, NULL);
13340
13376
  SetGroupSpacing (c5, 10, 10);
13357
13393
  SetObjectExtra (b, drfp, NULL);
13358
13394
  b = PushButton (c3, "Remove BARCODE Tech from Selected", RemoveSelectedTechBtn);
13359
13395
  SetObjectExtra (b, drfp, NULL);
 
13396
#if 0
13360
13397
  b = PushButton (c3, "Remove BARCODE Keyword from Low Trace", RemoveBarcodeKeywordsFromLowTrace);
13361
13398
  SetObjectExtra (b, drfp, NULL);
 
13399
#endif
13362
13400
 
13363
13401
  c = HiddenGroup (h, 4, 0, NULL);
13364
13402
  SetGroupSpacing (c, 10, 10);
14318
14356
}
14319
14357
 
14320
14358
 
14321
 
static void AddAltitudeToSubSourceNote (BioSourcePtr biop, CharPtr extra_text)
14322
 
{
14323
 
  SubSourcePtr ssp;
14324
 
  CharPtr      new_note, new_note_fmt = "%s%saltitude:%s";
14325
 
 
14326
 
  if (biop == NULL || StringHasNoText (extra_text))
14327
 
  {
14328
 
    return;
14329
 
  }
14330
 
 
14331
 
  ssp = biop->subtype;
14332
 
  while (ssp != NULL && ssp->subtype != SUBSRC_other)
14333
 
  {
14334
 
    ssp = ssp->next;
14335
 
  }
14336
 
  if (ssp == NULL) 
14337
 
  {
14338
 
    ssp = SubSourceNew ();
14339
 
    ssp->subtype = SUBSRC_other;
14340
 
    ssp->next = biop->subtype;
14341
 
    biop->subtype = ssp;
14342
 
  }
14343
 
  new_note = (CharPtr) MemNew (sizeof (Char) * (StringLen (ssp->name)
14344
 
                                                + StringLen (extra_text)
14345
 
                                                + StringLen (new_note_fmt)));
14346
 
  sprintf (new_note, new_note_fmt, ssp->name == NULL ? "" : ssp->name,
14347
 
                                   ssp->name == NULL ? "" : "; ",
14348
 
                                   extra_text);
14349
 
  ssp->name = MemFree (ssp->name);
14350
 
  ssp->name = new_note;
14351
 
}
14352
 
 
14353
 
 
14354
 
static void LatLonAutocorrectList (FILE *fp, ValNodePtr object_list)
14355
 
{
14356
 
  ValNodePtr vnp;
14357
 
  SeqDescrPtr sdp;
14358
 
  BioSourcePtr biop;
14359
 
  SubSourcePtr bad_ssp;
14360
 
  CharPtr      fix, extra_text;
14361
 
 
14362
 
  if (fp == NULL || object_list == NULL) return;
14363
 
 
14364
 
  for (vnp = object_list; vnp != NULL; vnp = vnp->next)
14365
 
  {
14366
 
    if (vnp->choice != OBJ_SEQDESC) continue;
14367
 
    sdp = vnp->data.ptrvalue;
14368
 
    if (sdp != NULL && sdp->choice == Seq_descr_source)
14369
 
    {
14370
 
      biop = (BioSourcePtr) sdp->data.ptrvalue;
14371
 
      bad_ssp = FindBadLatLon (biop);
14372
 
      if (bad_ssp != NULL)
14373
 
      {
14374
 
        fix = FixLatLonFormat (bad_ssp->name);
14375
 
        if (fix != NULL) 
14376
 
        {
14377
 
          extra_text = StringChr (fix, ',');
14378
 
          if (extra_text != NULL)
14379
 
          {
14380
 
            *extra_text = 0;
14381
 
            extra_text++;
14382
 
            while (isspace (*extra_text)) 
14383
 
            {
14384
 
              extra_text++;
14385
 
            }
14386
 
          }
14387
 
          fprintf (fp, "Corrected %s to %s\n", bad_ssp->name, fix);
14388
 
          bad_ssp->name = MemFree (bad_ssp->name);
14389
 
          bad_ssp->name = fix;
14390
 
          if (extra_text != NULL) 
14391
 
          {
14392
 
            AddAltitudeToSubSourceNote (biop, extra_text);
14393
 
            fprintf (fp, "Moved %s to subsource note\n", extra_text);
14394
 
          }
14395
 
        }
14396
 
        else
14397
 
        {
14398
 
          fprintf (fp, "Unable to correct %s\n", bad_ssp->name);
14399
 
        }
14400
 
      }
14401
 
    }
14402
 
  }
14403
 
}
14404
 
 
14405
 
 
14406
14359
static void LatLonAutocorrect (ButtoN b)
14407
14360
{
14408
14361
  BarcodeToolPtr    drfp;
15426
15379
 
15427
15380
static void FindTaxnames (SeqDescrPtr sdp, Pointer data)
15428
15381
{
15429
 
  if (sdp != NULL && data != NULL && sdp->choice == Seq_descr_source) {
 
15382
  BioSourcePtr biop;
 
15383
 
 
15384
  if (sdp != NULL && data != NULL 
 
15385
      && sdp->choice == Seq_descr_source 
 
15386
      && (biop = (BioSourcePtr) sdp->data.ptrvalue) != NULL
 
15387
      && biop->org != NULL
 
15388
      && (!HasTaxonomyID(biop) || StringNCmp (biop->org->taxname, "uncultured", 10) != 0)) {
15430
15389
    ValNodeAddPointer ((ValNodePtr PNTR) data, OBJ_SEQDESC, sdp);
15431
15390
  }
15432
15391
}
15460
15419
 
15461
15420
NLM_EXTERN BioSourcePtr GetBioSourceFromObject (Uint1 choice, Pointer data);
15462
15421
 
 
15422
 
15463
15423
static void TaxFixAutocorrectList (FILE *fp, ValNodePtr tax_fix_list)
15464
15424
{
15465
15425
  ValNodePtr vnp;
15480
15440
        biop->org = OrgRefNew();
15481
15441
      }
15482
15442
      fprintf (fp, "Corrected %s to %s\n", biop->org->taxname == NULL ? "missing name" : biop->org->taxname, t->suggested_fix);
 
15443
      RemoveOldName(biop->org);
15483
15444
      SetTaxNameAndRemoveTaxRef (biop->org, StringSave (t->suggested_fix));
15484
15445
    }
15485
15446
  }
15495
15456
  drfp = (BarcodeToolPtr) GetObjectExtra (b);
15496
15457
  if (drfp == NULL) return;
15497
15458
 
15498
 
  ApplyBulkEditorToObjectList (drfp->clickable_list);
 
15459
  ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15499
15460
 
15500
15461
  object_list = DialogToPointer (drfp->clickable_list);
15501
15462
 
15519
15480
    object_list = ValNodeFree (object_list);
15520
15481
  }
15521
15482
 
 
15483
  ForceCleanupEntityID (drfp->input_entityID);
 
15484
  Select (drfp->form);
15522
15485
  RefreshTaxFixTool (drfp);
15523
15486
  RedrawBarcodeTool (drfp);  
15524
15487
 
15573
15536
    return;
15574
15537
  }
15575
15538
 
15576
 
  ApplyBulkEditorToObjectList (drfp->clickable_list);
 
15539
  ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15577
15540
  PointerToDialog (drfp->clickable_list, NULL);
15578
15541
 
15579
15542
  for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
15630
15593
  drfp = (BarcodeToolPtr) GetObjectExtra (b);
15631
15594
  if (drfp == NULL) return;
15632
15595
 
15633
 
  ApplyBulkEditorToObjectList (drfp->clickable_list);
 
15596
  ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15634
15597
  PointerToDialog (drfp->clickable_list, NULL);
15635
15598
 
15636
15599
  for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
15646
15609
}
15647
15610
 
15648
15611
 
 
15612
static CharPtr s_UntrimmableWords[] = { "sp.", "cf.", "aff.", "bacterium", "archaeon", NULL };
 
15613
 
 
15614
static void TrimTaxFix (ButtoN b)
 
15615
{
 
15616
  BarcodeToolPtr    drfp;
 
15617
  ValNodePtr        vnp;
 
15618
  TaxFixItemPtr     t;
 
15619
  CharPtr           word_break;
 
15620
  Int4              i;
 
15621
  Boolean           no_fix;
 
15622
 
 
15623
  drfp = (BarcodeToolPtr) GetObjectExtra (b);
 
15624
  if (drfp == NULL) return;
 
15625
 
 
15626
  ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
 
15627
  PointerToDialog (drfp->clickable_list, NULL);
 
15628
 
 
15629
  for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
 
15630
    t = (TaxFixItemPtr) vnp->data.ptrvalue;
 
15631
    if (t == NULL) {
 
15632
      continue;
 
15633
    }
 
15634
    no_fix = FALSE;
 
15635
    word_break = StringRChr (t->suggested_fix, ' ');
 
15636
    if (word_break == NULL
 
15637
      || word_break == t->suggested_fix
 
15638
      || word_break - t->suggested_fix == 10 && StringNICmp (t->suggested_fix, "uncultured ", 11) == 0) {
 
15639
      /* not trimming this one */
 
15640
      no_fix = TRUE;
 
15641
    } else {
 
15642
      for (i = 0; s_UntrimmableWords[i] != NULL && !no_fix; i++) {
 
15643
        if (StringCmp (word_break + 1, s_UntrimmableWords[i]) == 0) {
 
15644
          no_fix = TRUE;
 
15645
        }
 
15646
      }
 
15647
    }
 
15648
    if (!no_fix) {
 
15649
      *word_break = 0;
 
15650
    }
 
15651
  }
 
15652
        
 
15653
  PointerToDialog (drfp->clickable_list, drfp->item_list);
 
15654
  RedrawBarcodeTool (drfp);  
 
15655
}
 
15656
 
 
15657
 
15649
15658
static void CleanupTaxFixTool (GraphiC g, VoidPtr data)
15650
15659
 
15651
15660
{
15699
15708
  drfp->bfp = bfp;
15700
15709
  drfp->input_entityID = bfp->input_entityID;
15701
15710
  drfp->top_sep = GetTopSeqEntryForEntityID (drfp->input_entityID);
15702
 
  w = FixedWindow (-50, -33, -10, -10, "Tax Fix Tool", StdCloseWindowProc);
 
15711
  w = FixedWindow (-50, -33, -10, -10, "Uncultured Tax Fix Tool", StdCloseWindowProc);
15703
15712
  SetObjectExtra (w, drfp, CleanupTaxFixTool);
15704
15713
  drfp->form = (ForM) w;
15705
15714
  drfp->formmessage = BarcodeToolMessage;
15731
15740
 
15732
15741
  RefreshTaxFixTool (drfp);
15733
15742
 
15734
 
  c = HiddenGroup (h, 7, 0, NULL);
 
15743
  c = HiddenGroup (h, 8, 0, NULL);
15735
15744
  SetGroupSpacing (c, 10, 10);
15736
15745
 
15737
15746
  b = PushButton (c, "Apply Corrections", TaxFixAutocorrect);
15744
15753
  SetObjectExtra (b, drfp, NULL);
15745
15754
  b = PushButton (c, "Add bacterium", TaxFixAddBacterium);
15746
15755
  SetObjectExtra (b, drfp, NULL);
 
15756
  b = PushButton (c, "Trim Suggestion", TrimTaxFix);
 
15757
  SetObjectExtra (b, drfp, NULL);
15747
15758
  b = PushButton (c, "Copy Taxname to Correction", TaxFixCopyNameToCorrection);
15748
15759
  SetObjectExtra (b, drfp, NULL);
15749
15760
 
15752
15763
  AlignObjects (ALIGN_CENTER, (HANDLE) drfp->clickable_list, (HANDLE) c, NULL);
15753
15764
 
15754
15765
  RealizeWindow (w);
 
15766
  SetBulkEditorSortColumn (drfp->clickable_list, 1);
15755
15767
  
15756
15768
  Show (w);
15757
15769
 
16134
16146
}
16135
16147
 
16136
16148
 
 
16149
typedef struct trimnopts {
 
16150
  ValNodePtr best_list;
 
16151
  Int4 max_dist;
 
16152
  Int4 min_stretch_len;
 
16153
} TrimNOptsData, PNTR TrimNOptsPtr;
 
16154
 
16137
16155
static void GetTrimIntervalWithoutNStretchesAtEnds (BioseqPtr bsp, Pointer userdata)
16138
16156
{
16139
 
  ValNodePtr PNTR best_list;
16140
 
  Int2       ctr, pos, i, begin = 0, chop5 = -1, chop3 = -1;
 
16157
  TrimNOptsPtr opts;
 
16158
  Int2       ctr;
 
16159
  Int4       pos, i, begin = 0, chop5 = -1, chop3 = -1;
16141
16160
  Char       buf1[51];
16142
16161
  Int4       len = 50, this_stretch = 0;
16143
16162
  StreamFlgType flags = STREAM_CORRECT_INVAL | STREAM_EXPAND_GAPS;
16144
16163
  NTrimIntervalPtr ntrim;
16145
16164
 
16146
 
  if (bsp == NULL || (best_list = (ValNodePtr PNTR) userdata) == NULL) {
 
16165
  if (bsp == NULL || (opts = (TrimNOptsPtr) userdata) == NULL) {
16147
16166
    return;
16148
16167
  }
16149
16168
 
16158
16177
        }
16159
16178
        this_stretch++;
16160
16179
      } else {
16161
 
        if (begin < 20 && this_stretch >= 5) {
 
16180
        if (this_stretch >= opts->min_stretch_len) {
 
16181
          i = i;
 
16182
        }
 
16183
        if (begin < opts->max_dist && this_stretch >= opts->min_stretch_len) {
16162
16184
          chop5 = pos + i;
16163
16185
        }
16164
 
        if (pos + i > bsp->length - 20 && this_stretch >= 5) {
 
16186
        if (pos + i > bsp->length - opts->max_dist && this_stretch >= opts->min_stretch_len) {
16165
16187
          chop3 = begin - 1;
16166
16188
        }
16167
16189
        this_stretch = 0;
16170
16192
    pos += len;
16171
16193
  }
16172
16194
  if (chop5 > -1 || chop3 > -1) {
 
16195
    if (chop5 > -1 && chop3 > -1 && chop5 + chop3 > bsp->length - 200) {
 
16196
      if (chop3 > chop5) {
 
16197
        chop3 = -1;
 
16198
      } else {
 
16199
        chop5 = -1;
 
16200
      }
 
16201
    }
 
16202
        
16173
16203
    ntrim = NTrimIntervalNew (chop5 > -1 ? chop5 : 0, bsp);
16174
16204
    NTrimIntervalSetStop (ntrim, chop3 > -1 ? chop3 : bsp->length - 1);
16175
 
    ValNodeAddPointer (best_list, 0, ntrim);
 
16205
    ValNodeAddPointer (&(opts->best_list), 0, ntrim);
16176
16206
  }
16177
16207
}
16178
16208
 
16187
16217
  TexT min_len;
16188
16218
  /* controls for end trimming */
16189
16219
  DialoG end_display;
 
16220
  TexT max_dist;
 
16221
  TexT min_stretch_len;
16190
16222
} SeqTrimToolData, PNTR SeqTrimToolPtr;
16191
16223
 
16192
16224
 
16210
16242
  CharPtr str;
16211
16243
  Char    buf[50];
16212
16244
  Int2    page;
 
16245
  TrimNOptsData opts;
16213
16246
 
16214
16247
  SeqTrimToolPtr vstp = (SeqTrimToolPtr) data;
16215
16248
 
16242
16275
    PointerToDialog (vstp->clickable_list, NULL);
16243
16276
    vstp->item_list = ValNodeFreeData (vstp->item_list);
16244
16277
 
16245
 
    VisitBioseqsInSep (vstp->top_sep, &(vstp->item_list), GetTrimIntervalWithoutNStretchesAtEnds);
 
16278
    MemSet (&opts, 0, sizeof (TrimNOptsData));
 
16279
    str = SaveStringFromText (vstp->max_dist);
 
16280
    opts.max_dist = atoi (str);
 
16281
    str = MemFree (str);
 
16282
    str = SaveStringFromText (vstp->min_stretch_len);
 
16283
    opts.min_stretch_len = atoi (str);
 
16284
    str = MemFree (str);
 
16285
    VisitBioseqsInSep (vstp->top_sep, &opts, GetTrimIntervalWithoutNStretchesAtEnds);
 
16286
    vstp->item_list = opts.best_list;
16246
16287
 
16247
16288
    PointerToDialog (vstp->clickable_list, vstp->item_list);
16248
16289
 
16500
16541
  drfp->pages[1] = HiddenGroup (page_grp, -1, 0, NULL);
16501
16542
  /* page for trimming ends with stretches */
16502
16543
  drfp->end_display = TrimSequenceEndDisplay(drfp->pages[1]);
 
16544
  opts = HiddenGroup (drfp->pages[1], 2, 0, NULL);
 
16545
  SetGroupSpacing (opts, 10, 10);
 
16546
  StaticPrompt (opts, "Maximum distance between N stretch and sequence end", 0, dialogTextHeight, programFont, 'r');
 
16547
  drfp->max_dist =DialogText (opts, "50", 10, NULL);
 
16548
  StaticPrompt (opts, "Minimum length of N stretch", 0, dialogTextHeight, programFont, 'r');
 
16549
  drfp->min_stretch_len = DialogText (opts, "15", 10, NULL);
 
16550
  AlignObjects (ALIGN_CENTER, (HANDLE) drfp->end_display, (HANDLE) opts, NULL);
16503
16551
 
16504
16552
  AlignObjects (ALIGN_CENTER, (HANDLE) drfp->pages[0], (HANDLE) drfp->pages[1], NULL);
16505
16553
 
16638
16686
    FileClose (fp);
16639
16687
    cp = StringRChr (path, '\\');
16640
16688
    if (cp == NULL) {
16641
 
      cp = StringRChr (path, '//');
 
16689
      cp = StringRChr (path, '/');
16642
16690
    }
16643
16691
    if (cp != NULL) {
16644
16692
      *(cp +1) = 0;