392
392
static void TaxonValidate (SeqEntryPtr sep, ValidStructPtr vsp);
395
static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
398
Boolean allRawOrSeg = TRUE;
399
MsgAnswer ans = ANS_OK;
407
if (entityID < 1) return FALSE;
396
eOkToWriteEntity_Cancel = 0,
397
eOkToWriteEntity_Continue,
398
eOkToWriteEntity_Validate
401
static EOkToWriteEntity GetValidationCancelContinue (ValidStructPtr vsp, Boolean allow_review)
407
ModalAcceptCancelData acd;
408
CharPtr msg, msg_format = "Reject %d, Error %d, Warning %d, Info %d";
409
EOkToWriteEntity rval = eOkToWriteEntity_Cancel;
411
acd.accepted = FALSE;
412
acd.cancelled = FALSE;
413
acd.third_option = FALSE;
415
w = ModalWindow(-20, -13, -10, -10, NULL);
416
h = HiddenGroup (w, -1, 0, NULL);
417
SetGroupSpacing (h, 10, 10);
419
prompts = HiddenGroup (h, -1, 0, NULL);
420
SetGroupSpacing (prompts, 10, 10);
421
p1 = StaticPrompt (prompts, "Submission failed validation test with:", 0, 0, programFont, 'l');
423
msg = (CharPtr) MemNew (sizeof (Char) * (StringLen (msg_format) + 75));
424
sprintf (msg, msg_format,
425
(int) vsp->errors [4], (int) vsp->errors [3],
426
(int) vsp->errors [2], (int) vsp->errors [1]);
427
p2 = StaticPrompt (h, msg, 0, 0, programFont, 'l');
429
AlignObjects (ALIGN_CENTER, (HANDLE) p1, (HANDLE) p2, NULL);
431
c = HiddenGroup (h, 3, 0, NULL);
432
SetGroupSpacing (c, 10, 10);
433
b = PushButton (c, "Continue", ModalAcceptButton);
434
SetObjectExtra (b, &acd, NULL);
436
b = PushButton (c, "Review Errors", ModalThirdOptionButton);
437
SetObjectExtra (b, &acd, NULL);
439
b = PushButton (c, "Cancel", ModalCancelButton);
440
SetObjectExtra (b, &acd, NULL);
441
AlignObjects (ALIGN_CENTER, (HANDLE) prompts, (HANDLE) c, NULL);
445
while (!acd.accepted && ! acd.cancelled && ! acd.third_option)
447
ProcessExternalEvent ();
452
if (acd.third_option)
454
rval = eOkToWriteEntity_Validate;
456
else if (acd.accepted)
458
rval = eOkToWriteEntity_Continue;
462
rval = eOkToWriteEntity_Cancel;
468
static EOkToWriteEntity OkayToWriteTheEntity (Uint2 entityID, ForM f, Boolean allow_review)
471
Boolean allRawOrSeg = TRUE;
472
EOkToWriteEntity rval = eOkToWriteEntity_Continue;
480
if (entityID < 1) return 0;
408
481
sep = GetTopSeqEntryForEntityID (entityID);
409
if (sep == NULL) return FALSE;
482
if (sep == NULL) return 0;
411
if (!FixSpecialCharacters (entityID)) return FALSE;
484
if (!FixSpecialCharacters (entityID)) return 0;
413
486
if (GetSequinAppParam ("PREFERENCES", "ASKBEFOREVALIDATE", NULL, str, sizeof (str))) {
414
487
if (StringICmp (str, "TRUE") == 0) {
415
488
if (! (subtoolMode ||smartnetMode || backupMode) ) {
416
if (Message (MSG_YN, "Do you wish to validate this entry?") == ANS_NO) return TRUE;
489
if (Message (MSG_YN, "Do you wish to validate this entry?") == ANS_NO) return 1;
476
549
if (subtoolMode || smartnetMode || backupMode) {
477
ans = Message (MSG_OKC, "%s\nReject %d, Error %d, Warning %d, Info %d\n%s",
478
"Submission failed validation test with:",
479
(int) vsp->errors [4], (int) vsp->errors [3],
480
(int) vsp->errors [2], (int) vsp->errors [1],
550
rval = GetValidationCancelContinue (vsp, allow_review);
483
ans = Message (MSG_OKC, validFailMsg);
552
if (Message (MSG_OKC, validFailMsg) == ANS_CANCEL) {
553
rval = eOkToWriteEntity_Cancel;
486
557
ValidStructFree (vsp);
491
/*SetChecklistValue (checklistForm, 5);*/
497
564
static void ReplaceString (CharPtr PNTR target, CharPtr newstr)
690
static ValNodePtr ExtractGivenSeqDescrUserObject (ValNodePtr PNTR headptr, CharPtr str, CharPtr cls)
694
ValNodePtr last = NULL, vnp;
698
if (headptr == NULL) return NULL;
701
while (vnp != NULL) {
703
if (vnp->choice == Seq_descr_user) {
704
uop = (UserObjectPtr) vnp->data.ptrvalue;
706
if (StringDoesHaveText (cls)) {
707
if (StringICmp (uop->_class, cls) == 0) {
711
if (StringDoesHaveText (str)) {
714
if (StringICmp (oip->str, str) == 0) {
723
*headptr = vnp->next;
725
last->next = vnp->next;
738
typedef struct propgenbankdata {
743
} PropGenbankData, PNTR PropGenBankPtr;
745
static void DoPropagateFromGenBankBioseqSet (
754
SeqEntryPtr seqentry;
755
ValNodePtr smartuserobj;
756
ValNodePtr sourcedescr;
759
if (seqset == NULL) return;
760
if (seqset->_class != BioseqseqSet_class_genbank) return;
761
pgp = (PropGenBankPtr) userdata;
762
if (pgp == NULL) return;
764
seqentry = seqset->seq_set;
765
sourcedescr = seqset->descr;
766
if (sourcedescr == NULL) return;
768
/* if only descriptor is tracking user object, skip */
769
if (sourcedescr->next == NULL && sourcedescr->choice == Seq_descr_user) {
770
uop = (UserObjectPtr) sourcedescr->data.ptrvalue;
771
if (uop != NULL && StringICmp (uop->_class, "SMART_V1.0") == 0) return;
774
/* optionally ask if propagation is desired */
777
if (Message (MSG_YN, "Propagate descriptors from top-level set?") == ANS_NO) {
783
if (pgp->bail) return;
785
/* disconnect descriptors from parent bssp */
786
seqset->descr = NULL;
788
/* extract tracking user object */
789
smartuserobj = ExtractGivenSeqDescrUserObject (&sourcedescr, NULL, "SMART_V1.0");
791
while (seqentry != NULL) {
792
if (seqentry->data.ptrvalue != NULL) {
793
if (seqentry->choice == 1) {
794
bsp = (BioseqPtr) seqentry->data.ptrvalue;
795
ValNodeLink (&(bsp->descr),
796
AsnIoMemCopy ((Pointer) sourcedescr,
797
(AsnReadFunc) SeqDescrAsnRead,
798
(AsnWriteFunc) SeqDescrAsnWrite));
799
} else if (seqentry->choice == 2) {
800
bssp = (BioseqSetPtr) seqentry->data.ptrvalue;
801
ValNodeLink (&(bssp->descr),
802
AsnIoMemCopy ((Pointer) sourcedescr,
803
(AsnReadFunc) SeqDescrAsnRead,
804
(AsnWriteFunc) SeqDescrAsnWrite));
808
seqentry = seqentry->next;
811
/* free extracted original descriptors now that copies are propagated */
812
SeqDescrFree (sourcedescr);
814
/* restore tracking user object */
815
if (smartuserobj != NULL) {
816
ValNodeLink (&(seqset->descr), smartuserobj);
820
VisitSetsInSet (seqset, userdata, DoPropagateFromGenBankBioseqSet);
623
823
extern Boolean PropagateFromGenBankBioseqSet (SeqEntryPtr sep, Boolean ask)
629
SeqEntryPtr seqentry;
630
ValNodePtr sourcedescr;
633
if (sep->choice == 2 && sep->data.ptrvalue != NULL) {
634
bssp = (BioseqSetPtr) sep->data.ptrvalue;
635
_class = bssp->_class;
636
sourcedescr = bssp->descr;
637
if (sourcedescr == NULL) return FALSE;
640
if (Message (MSG_YN, "Propagate descriptors from top-level set?") == ANS_NO) return FALSE;
642
seqentry = bssp->seq_set;
643
while (seqentry != NULL) {
644
if (seqentry->data.ptrvalue != NULL) {
645
if (seqentry->choice == 1) {
646
bsp = (BioseqPtr) seqentry->data.ptrvalue;
647
ValNodeLink (&(bsp->descr),
648
AsnIoMemCopy ((Pointer) sourcedescr,
649
(AsnReadFunc) SeqDescrAsnRead,
650
(AsnWriteFunc) SeqDescrAsnWrite));
651
} else if (seqentry->choice == 2) {
652
bssp = (BioseqSetPtr) seqentry->data.ptrvalue;
653
ValNodeLink (&(bssp->descr),
654
AsnIoMemCopy ((Pointer) sourcedescr,
655
(AsnReadFunc) SeqDescrAsnRead,
656
(AsnWriteFunc) SeqDescrAsnWrite));
659
seqentry = seqentry->next;
661
bssp = (BioseqSetPtr) sep->data.ptrvalue;
662
bssp->descr = SeqDescrFree (bssp->descr);
829
if (sep == NULL) return FALSE;
830
if (! IS_Bioseq_set (sep)) return FALSE;
832
bssp = (BioseqSetPtr) sep->data.ptrvalue;
833
if (bssp == NULL) return FALSE;
834
if (bssp->_class != BioseqseqSet_class_genbank) return FALSE;
836
MemSet ((Pointer) &pdp, 0, sizeof (PropGenbankData));
842
DoPropagateFromGenBankBioseqSet (bssp, (Pointer) &pdp);
670
847
static void ForcePropagate (IteM i)
1392
1595
update = TRUE; /* because of NormalizeDescriptorOrder */
1393
1596
SeqMgrClearFeatureIndexes (bfp->input_entityID, NULL);
1395
if (! OkayToWriteTheEntity (bfp->input_entityID, f)) {
1396
if (update && bfp != NULL) {
1397
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1599
continue_cancel_validate = OkayToWriteTheEntity (bfp->input_entityID, f, TRUE);
1600
if (continue_cancel_validate == eOkToWriteEntity_Cancel) {
1601
if (update && bfp != NULL) {
1602
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1605
} else if (continue_cancel_validate == eOkToWriteEntity_Validate) {
1606
/* launch validator */
1607
LaunchValidatorForDone (bfp, sep, SmartnetDoneValidateFunc, SmartnetDoneNoValidateFunc);
1401
1611
/* ans = Message (MSG_YN, "Reset Update Date?"); */
1504
1740
NormalizeDescriptorOrder (sep);
1505
1741
update = TRUE; /* because of NormalizeDescriptorOrder */
1507
bfp = (BaseFormPtr) GetObjectExtra (i);
1743
bfp = (BaseFormPtr) GetObjectExtra (form);
1508
1744
if (bfp != NULL) {
1511
1747
SeqMgrClearFeatureIndexes (bfp->input_entityID, NULL);
1512
if (! OkayToWriteTheEntity (subtoolEntityID, f)) {
1513
if (update && bfp != NULL) {
1514
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1749
continue_review_cancel = OkayToWriteTheEntity (subtoolEntityID, f, validate);
1750
if (continue_review_cancel == eOkToWriteEntity_Cancel) {
1751
if (update && bfp != NULL) {
1752
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1755
} else if (continue_review_cancel == eOkToWriteEntity_Validate) {
1756
/* launch validator */
1757
LaunchValidatorForDone (bfp, sep, SubtoolDoneValidateFunc, SubtoolDoneNoValidateFunc);
1518
1761
/* ans = Message (MSG_YN, "Reset Update Date?"); */
1849
static void LaunchValidatorForDone (BaseFormPtr bfp, SeqEntryPtr sep, FormActnFunc revalProc, FormActnFunc continueProc)
1854
Boolean allRawOrSeg = TRUE;
1855
ErrHookProc oldErrHook;
1862
vsp = ValidStructNew ();
1864
/*SetChecklistValue (checklistForm, 6);*/
1867
if (GetSequinAppParam ("SETTINGS", "VALIDATEVERBOSITY", NULL, buf, sizeof (buf))) {
1868
if (! StrToInt (buf, &verbosity)) {
1873
CreateValidateWindowExEx (ValidNotify, "Sequin Validation Errors",
1874
programFont, SEV_INFO, verbosity, bfp, revalProc, continueProc, TRUE);
1875
ClearValidateWindow ();
1876
SeqEntryExplore (sep, (Pointer) (&allRawOrSeg), CheckForCookedBioseqs);
1878
vsp->useSeqMgrIndexes = TRUE;
1881
vsp->suppressContext = ShouldSetSuppressContext ();
1882
vsp->justShowAccession = ShouldSetJustShowAccession ();
1883
oldErrHook = ErrSetHandler (ValidErrHook);
1884
oldErrSev = ErrSetMessageLevel (SEV_NONE);
1885
vsp->validateAlignments = TRUE;
1886
vsp->alignFindRemoteBsp = TRUE;
1887
vsp->doSeqHistAssembly = FALSE;
1888
for (j = 0; j < 6; j++) {
1889
vsp->errors [j] = 0;
1891
vsp->errfunc = ValidErrCallback;
1892
ValidateSeqEntry (sep, vsp);
1893
if (indexerVersion && useEntrez) {
1894
TaxonValidate (sep, vsp);
1896
ErrSetMessageLevel (oldErrSev);
1897
ErrSetHandler (oldErrHook);
1901
for (j = 0; j < 6; j++) {
1902
errors += vsp->errors [j];
1906
Message (MSG_OK, "Validation test succeeded.");
1907
FreeValidateWindow ();
1909
RepopulateValidateFilter ();
1911
ValidStructFree (vsp);
1912
/*SetChecklistValue (checklistForm, 5);*/
1593
1919
static void ProcessDoneButton (ForM f)
1596
1922
Boolean allRawOrSeg = TRUE;
1597
1923
BaseFormPtr bfp;
1601
ErrHookProc oldErrHook;
1602
1926
ErrSev oldErrSev;
1603
1927
SeqEntryPtr sep;
1606
1929
ValidStructPtr vsp;
1607
1930
CharPtr fmt_no_file = "Submission is now written. Please e-mail to %s.%s";
1608
1931
CharPtr missing_annot = " Please include a brief summary of your submission within your correspondence.";
1659
1982
ArrowCursor ();
1661
1984
if (ReviewErrorsForValidationFailure ()) {
1664
vsp = ValidStructNew ();
1666
/*SetChecklistValue (checklistForm, 6);*/
1669
if (GetSequinAppParam ("SETTINGS", "VALIDATEVERBOSITY", NULL, buf, sizeof (buf))) {
1670
if (! StrToInt (buf, &verbosity)) {
1675
CreateValidateWindowEx (ValidNotify, "Sequin Validation Errors",
1676
programFont, SEV_INFO, verbosity, bfp, ProcessDoneButton, TRUE);
1677
ClearValidateWindow ();
1678
SeqEntryExplore (sep, (Pointer) (&allRawOrSeg), CheckForCookedBioseqs);
1680
vsp->useSeqMgrIndexes = TRUE;
1683
vsp->suppressContext = ShouldSetSuppressContext ();
1684
vsp->justShowAccession = ShouldSetJustShowAccession ();
1685
oldErrHook = ErrSetHandler (ValidErrHook);
1686
oldErrSev = ErrSetMessageLevel (SEV_NONE);
1687
vsp->validateAlignments = TRUE;
1688
vsp->alignFindRemoteBsp = TRUE;
1689
vsp->doSeqHistAssembly = FALSE;
1690
for (j = 0; j < 6; j++) {
1691
vsp->errors [j] = 0;
1693
vsp->errfunc = ValidErrCallback;
1694
ValidateSeqEntry (sep, vsp);
1695
if (indexerVersion && useEntrez) {
1696
TaxonValidate (sep, vsp);
1698
ErrSetMessageLevel (oldErrSev);
1699
ErrSetHandler (oldErrHook);
1703
for (j = 0; j < 6; j++) {
1704
errors += vsp->errors [j];
1708
Message (MSG_OK, "Validation test succeeded.");
1709
FreeValidateWindow ();
1711
RepopulateValidateFilter ();
1713
ValidStructFree (vsp);
1714
/*SetChecklistValue (checklistForm, 5);*/
1985
LaunchValidatorForDone (bfp, sep, ProcessDoneButton, NULL);