393
static void DoNetConf (ButtoN b)
396
NetConfigureProc ((IteM) b);
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) {
459
464
} else if (StringICmp (str, "EMBL") == 0) {
461
} else if (StringICmp (str, "DDBJ") == 0) {
490
493
if (fetchFromNet != NULL) {
491
494
b = PushButton (c, "Download From Entrez", fetchFromNet);
492
495
SetObjectExtra (b, sfp, NULL);
497
b = PushButton (c, "Network Configure", DoNetConf);
498
SetObjectExtra (b, sfp, NULL);
494
500
b = PushButton (c, "Show Help", showHelp);
495
501
SetObjectExtra (b, sfp, NULL);
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);
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);
887
895
RealizeWindow (w);
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;
11300
11308
vnp = item_list;
11301
11309
while (vnp != NULL)
11988
11996
static void RefreshBarcodeList (Pointer data)
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];
11998
12006
PointerToDialog (vstp->clickable_list, NULL);
11999
12007
vstp->item_list = BarcodeTestResultsListFree (vstp->item_list);
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);
12004
pass_fail_list = GetBarcodePassFail (vstp->top_sep, vstp->cfg);
12005
for (vnp = pass_fail_list; vnp != NULL; vnp = vnp->next)
12007
if (PassBarcodeTests(vnp->data.ptrvalue))
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);
12249
12248
BarcodeToolPtr vstp;
12250
12249
LogInfoPtr lip;
12251
ValNodePtr object_list;
12251
BarcodeTestResultsPtr res;
12254
12254
vstp = (BarcodeToolPtr) GetObjectExtra (b);
12255
12255
if (vstp == NULL) return;
12257
sep = GetTopSeqEntryForEntityID (vstp->input_entityID);
12258
object_list = GetBarcodeLowTraceList(sep);
12260
if (object_list == NULL)
12262
Message (MSG_ERROR, "No low-trace entries found");
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))
12263
SeqIdWrite (SeqIdFindBest (res->bsp->id, SEQID_GENBANK), id_txt, PRINTID_REPORT, sizeof (id_txt) - 1);
12264
fprintf (lip->fp, "%s\n", id_txt);
12266
lip = OpenLog ("BARCODE Keywords Removed");
12267
RemoveBarcodeKeywordsFromObjectList (lip->fp, object_list);
12268
object_list = ValNodeFree (object_list);
12270
12269
RefreshBarcodeList (vstp);
12271
12270
RedrawBarcodeTool (vstp);
12427
static void BarcodeTestMissingPrimerAndCountryReport (ButtoN b)
12429
BarcodeToolPtr vstp;
12430
ValNodePtr object_list, vnp;
12431
BarcodeTestResultsPtr res;
12432
CharPtr barcode_id, genbank_id, what;
12435
vstp = (BarcodeToolPtr) GetObjectExtra (b);
12436
if (vstp == NULL) return;
12438
object_list = GetBarcodePassFail (vstp->top_sep, vstp->cfg);
12439
lip = OpenLog ("BARCODE Compliance");
12440
for (vnp = object_list; vnp != NULL; vnp = vnp->next)
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";
12451
} else if (res->failed_tests[eBarcodeTest_Country]) {
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;
12462
barcode_id = MemFree (barcode_id);
12463
genbank_id = MemFree (genbank_id);
12466
if (!lip->data_in_log) {
12467
Message (MSG_OK, "No sequences are missing primers or country");
12470
lip = FreeLog (lip);
12471
object_list = BarcodeTestResultsListFree (object_list);
12429
12475
extern DialoG BarcodeTestResultsDisplay (GrouP h, BarcodeTestConfigPtr cfg);
12431
12477
static void BarcodeTestMakeTagTable (ButtoN b)
13098
13144
} StripReportCollectData, PNTR StripReportCollectPtr;
13101
static void FindMissingKeywordsCallback (BioseqPtr bsp, Pointer data)
13104
StripReportCollectPtr s;
13105
BarcodeTestResultsPtr res;
13106
CharPtr reasons, tmp;
13108
if (bsp == NULL || !HasBARCODETech (bsp) || (s = (StripReportCollectPtr) data) == NULL || BioseqHasBarcodeKeyword(bsp)) {
13111
res = BarcodeTestResultsForBioseq(bsp, s->cfg);
13112
reasons = GetBarcodeTestFailureReasons (res);
13113
res = BarcodeTestResultsFree (res);
13115
SeqIdWrite (SeqIdFindBest (bsp->id, SEQID_GENBANK), id_buf, PRINTID_TEXTID_ACC_ONLY, sizeof (id_buf) - 1);
13117
ValNodeAddPointer (&(s->strip_report_list), 0, StripReportNew(id_buf, reasons));
13118
reasons = MemFree (reasons);
13123
13147
static void ProcessOneFrameFindFile (CharPtr filename, Pointer userdata)
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);
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);
13263
list = BarcodeTestResultsListFree(list);
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);
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);
13372
b = PushButton (c4, "Missing Country and Primers Report", BarcodeTestMissingPrimerAndCountryReport);
13373
SetObjectExtra (b, drfp, NULL);
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);
13360
13397
b = PushButton (c3, "Remove BARCODE Keyword from Low Trace", RemoveBarcodeKeywordsFromLowTrace);
13361
13398
SetObjectExtra (b, drfp, NULL);
13363
13401
c = HiddenGroup (h, 4, 0, NULL);
13364
13402
SetGroupSpacing (c, 10, 10);
14321
static void AddAltitudeToSubSourceNote (BioSourcePtr biop, CharPtr extra_text)
14324
CharPtr new_note, new_note_fmt = "%s%saltitude:%s";
14326
if (biop == NULL || StringHasNoText (extra_text))
14331
ssp = biop->subtype;
14332
while (ssp != NULL && ssp->subtype != SUBSRC_other)
14338
ssp = SubSourceNew ();
14339
ssp->subtype = SUBSRC_other;
14340
ssp->next = biop->subtype;
14341
biop->subtype = ssp;
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 ? "" : "; ",
14349
ssp->name = MemFree (ssp->name);
14350
ssp->name = new_note;
14354
static void LatLonAutocorrectList (FILE *fp, ValNodePtr object_list)
14359
SubSourcePtr bad_ssp;
14360
CharPtr fix, extra_text;
14362
if (fp == NULL || object_list == NULL) return;
14364
for (vnp = object_list; vnp != NULL; vnp = vnp->next)
14366
if (vnp->choice != OBJ_SEQDESC) continue;
14367
sdp = vnp->data.ptrvalue;
14368
if (sdp != NULL && sdp->choice == Seq_descr_source)
14370
biop = (BioSourcePtr) sdp->data.ptrvalue;
14371
bad_ssp = FindBadLatLon (biop);
14372
if (bad_ssp != NULL)
14374
fix = FixLatLonFormat (bad_ssp->name);
14377
extra_text = StringChr (fix, ',');
14378
if (extra_text != NULL)
14382
while (isspace (*extra_text))
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)
14392
AddAltitudeToSubSourceNote (biop, extra_text);
14393
fprintf (fp, "Moved %s to subsource note\n", extra_text);
14398
fprintf (fp, "Unable to correct %s\n", bad_ssp->name);
14406
14359
static void LatLonAutocorrect (ButtoN b)
14408
14361
BarcodeToolPtr drfp;
15427
15380
static void FindTaxnames (SeqDescrPtr sdp, Pointer data)
15429
if (sdp != NULL && data != NULL && sdp->choice == Seq_descr_source) {
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);
15480
15440
biop->org = OrgRefNew();
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));
15495
15456
drfp = (BarcodeToolPtr) GetObjectExtra (b);
15496
15457
if (drfp == NULL) return;
15498
ApplyBulkEditorToObjectList (drfp->clickable_list);
15459
ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15500
15461
object_list = DialogToPointer (drfp->clickable_list);
15576
ApplyBulkEditorToObjectList (drfp->clickable_list);
15539
ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15577
15540
PointerToDialog (drfp->clickable_list, NULL);
15579
15542
for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
15630
15593
drfp = (BarcodeToolPtr) GetObjectExtra (b);
15631
15594
if (drfp == NULL) return;
15633
ApplyBulkEditorToObjectList (drfp->clickable_list);
15596
ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15634
15597
PointerToDialog (drfp->clickable_list, NULL);
15636
15599
for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
15612
static CharPtr s_UntrimmableWords[] = { "sp.", "cf.", "aff.", "bacterium", "archaeon", NULL };
15614
static void TrimTaxFix (ButtoN b)
15616
BarcodeToolPtr drfp;
15619
CharPtr word_break;
15623
drfp = (BarcodeToolPtr) GetObjectExtra (b);
15624
if (drfp == NULL) return;
15626
ApplyBulkEditorToObjectList (drfp->clickable_list, FALSE);
15627
PointerToDialog (drfp->clickable_list, NULL);
15629
for (vnp = drfp->item_list; vnp != NULL; vnp = vnp->next) {
15630
t = (TaxFixItemPtr) vnp->data.ptrvalue;
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 */
15642
for (i = 0; s_UntrimmableWords[i] != NULL && !no_fix; i++) {
15643
if (StringCmp (word_break + 1, s_UntrimmableWords[i]) == 0) {
15653
PointerToDialog (drfp->clickable_list, drfp->item_list);
15654
RedrawBarcodeTool (drfp);
15649
15658
static void CleanupTaxFixTool (GraphiC g, VoidPtr data)
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;
15732
15741
RefreshTaxFixTool (drfp);
15734
c = HiddenGroup (h, 7, 0, NULL);
15743
c = HiddenGroup (h, 8, 0, NULL);
15735
15744
SetGroupSpacing (c, 10, 10);
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);
16149
typedef struct trimnopts {
16150
ValNodePtr best_list;
16152
Int4 min_stretch_len;
16153
} TrimNOptsData, PNTR TrimNOptsPtr;
16137
16155
static void GetTrimIntervalWithoutNStretchesAtEnds (BioseqPtr bsp, Pointer userdata)
16139
ValNodePtr PNTR best_list;
16140
Int2 ctr, pos, i, begin = 0, chop5 = -1, chop3 = -1;
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;
16146
if (bsp == NULL || (best_list = (ValNodePtr PNTR) userdata) == NULL) {
16165
if (bsp == NULL || (opts = (TrimNOptsPtr) userdata) == NULL) {
16159
16178
this_stretch++;
16161
if (begin < 20 && this_stretch >= 5) {
16180
if (this_stretch >= opts->min_stretch_len) {
16183
if (begin < opts->max_dist && this_stretch >= opts->min_stretch_len) {
16162
16184
chop5 = pos + i;
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;
16167
16189
this_stretch = 0;
16172
16194
if (chop5 > -1 || chop3 > -1) {
16195
if (chop5 > -1 && chop3 > -1 && chop5 + chop3 > bsp->length - 200) {
16196
if (chop3 > chop5) {
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);
16242
16275
PointerToDialog (vstp->clickable_list, NULL);
16243
16276
vstp->item_list = ValNodeFreeData (vstp->item_list);
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;
16247
16288
PointerToDialog (vstp->clickable_list, vstp->item_list);
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);
16504
16552
AlignObjects (ALIGN_CENTER, (HANDLE) drfp->pages[0], (HANDLE) drfp->pages[1], NULL);