1 /* import.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: import.c
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 6/18/95
31 *
32 * $Revision: 6.86 $
33 *
34 * File Description:
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date Name Description of modification
39 * ------- ---------- -----------------------------------------------------
40 *
41 *
42 * ==========================================================================
43 */
44
45 #include <import.h>
46 #include <objfdef.h>
47 #include <gbfeat.h>
48 #include <gbftdef.h>
49 #include <gather.h>
50 #include <subutil.h> /* TOPOLOGY_xxx definitions */
51 #include <explore.h>
52 #include <toasn3.h>
53
54 #define IMPORT_PAGE 0
55 #define ENUM_PAGE 0
56 #define REGION_PAGE 0
57 #define COMMON_PAGE 1
58 #define LOCATION_PAGE 2
59
60 #define NUM_PAGES 8
61
62 typedef struct imprtform {
63 FEATURE_FORM_BLOCK
64 SeqEntryPtr sep;
65 GrouP pages [NUM_PAGES];
66 DialoG foldertabs;
67 Int2 currentPage;
68 } ImprtForm, PNTR ImprtFormPtr;
69
70 typedef struct importpage {
71 DIALOG_MESSAGE_BLOCK
72 ImprtFormPtr ifp;
73 Handle key;
74 TexT loc;
75 EnumFieldAssoc PNTR alist;
76 } ImportPage, PNTR ImportPagePtr;
77
import_featdef_alist(Boolean notJustImpFeats,Boolean allowPeptideFeats,Boolean allowRnaImpFeats)78 extern EnumFieldAssocPtr import_featdef_alist (Boolean notJustImpFeats, Boolean allowPeptideFeats, Boolean allowRnaImpFeats)
79
80 {
81 EnumFieldAssocPtr alist;
82 EnumFieldAssocPtr ap;
83 FeatDefPtr curr;
84 Int2 fdn;
85 Int2 i;
86 Uint1 key;
87 CharPtr label = NULL;
88 CharPtr str;
89 Uint2 subtype;
90
91 fdn = FeatDefNum ();
92 alist = MemNew (sizeof (EnumFieldAssoc) * (fdn + 2));
93 if (alist == NULL) {
94 Message (MSG_ERROR, "in import_featdef_alist: no room");
95 } else {
96 i = 0;
97 ap = alist;
98 ap->name = StringSave (" ");
99 ap->value = (UIEnum) 0;
100 ap++;
101 i++;
102 curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
103 while (curr != NULL) {
104 if (key != FEATDEF_BAD && !IsRegulatorySubtype(key)) {
105 if (notJustImpFeats || curr->seqfeat_key == SEQFEAT_IMP) {
106 subtype = curr->featdef_key;
107 if (subtype != FEATDEF_IMP &&
108 subtype != FEATDEF_Imp_CDS &&
109 subtype != FEATDEF_source &&
110 subtype != FEATDEF_virion &&
111 subtype != FEATDEF_mutation &&
112 subtype != FEATDEF_allele &&
113 subtype != FEATDEF_site_ref &&
114 subtype != FEATDEF_gap &&
115 subtype != FEATDEF_misc_RNA &&
116 subtype != FEATDEF_satellite &&
117 subtype != FEATDEF_repeat_unit &&
118 subtype != FEATDEF_conflict &&
119 subtype != FEATDEF_LTR &&
120 subtype != FEATDEF_assembly_gap) {
121 if (allowPeptideFeats ||
122 (subtype != FEATDEF_mat_peptide &&
123 subtype != FEATDEF_sig_peptide &&
124 subtype != FEATDEF_transit_peptide)) {
125 if (allowRnaImpFeats ||
126 (subtype != FEATDEF_misc_RNA &&
127 subtype != FEATDEF_precursor_RNA)) {
128 if (StringCmp (curr->typelabel, "RNA") == 0) {
129 str = StringSave ("misc_RNA");
130 } else {
131 str = StringSave (curr->typelabel);
132 }
133 if (*str == '-') {
134 *str = '~';
135 }
136 ap->name = str;
137 ap->value = key;
138 ap++;
139 i++;
140 }
141 }
142 }
143 }
144 }
145 curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
146 }
147 ap->name = NULL;
148 }
149 return alist;
150 }
151
gap_featdef_alist(void)152 static EnumFieldAssocPtr gap_featdef_alist (void)
153
154 {
155 EnumFieldAssocPtr alist;
156 EnumFieldAssocPtr ap;
157
158 alist = MemNew (sizeof (EnumFieldAssoc) * (4));
159 if (alist == NULL) {
160 Message (MSG_ERROR, "in gap_featdef_alist: no room");
161 } else {
162 ap = alist;
163 ap->name = StringSave (" ");
164 ap->value = (UIEnum) 0;
165 ap++;
166 ap->name = StringSave ("gap");
167 ap->value = (UIEnum) FEATDEF_gap;
168 ap++;
169 ap->name = NULL;
170 }
171 return alist;
172 }
173
ImpFeatPtrToImportPage(DialoG d,Pointer data)174 static void ImpFeatPtrToImportPage (DialoG d, Pointer data)
175
176 {
177 EnumFieldAssocPtr ap;
178 Int2 i;
179 ImportPagePtr ipp;
180 ImpFeatPtr ifp;
181
182 ipp = (ImportPagePtr) GetObjectExtra (d);
183 ifp = (ImpFeatPtr) data;
184 if (ipp != NULL) {
185 if (ifp != NULL) {
186 for (i = 1, ap = ipp->alist; ap->name != NULL; i++, ap++) {
187 if (StringCmp (ap->name, ifp->key) == 0) {
188 SetValue (ipp->key, i);
189 SetTitle (ipp->loc, ifp->loc);
190 return;
191 }
192 }
193 }
194 SetValue (ipp->key, 1);
195 SetTitle (ipp->loc, "");
196 }
197 }
198
ImportPageToImpFeatPtr(DialoG d)199 static Pointer ImportPageToImpFeatPtr (DialoG d)
200
201 {
202 EnumFieldAssocPtr ap;
203 Int2 i;
204 ImportPagePtr ipp;
205 ImpFeatPtr ifp;
206 UIEnum val;
207
208 ifp = NULL;
209 ipp = (ImportPagePtr) GetObjectExtra (d);
210 if (ipp != NULL) {
211 ifp = ImpFeatNew ();
212 if (ifp != NULL) {
213 ifp->loc = SaveStringFromText (ipp->loc);
214 val = GetValue (ipp->key);
215 if (val > 1) {
216 for (i = 1, ap = ipp->alist; ap->name != NULL; i++, ap++) {
217 if (i == val) {
218 ifp->key = StringSave (ap->name);
219 return (Pointer) ifp;
220 }
221 }
222 } else {
223 ifp->key = StringSave ("misc_feature");
224 }
225 }
226 }
227 return (Pointer) ifp;
228 }
229
CleanupImportPage(GraphiC g,VoidPtr data)230 static void CleanupImportPage (GraphiC g, VoidPtr data)
231
232 {
233 ImportPagePtr ipp;
234 Int2 j;
235
236 ipp = (ImportPagePtr) data;
237 if (ipp != NULL) {
238 if (ipp->alist != NULL) {
239 for (j = 0; ipp->alist [j].name != NULL; j++) {
240 MemFree (ipp->alist [j].name);
241 }
242 }
243 MemFree (ipp->alist);
244 }
245 MemFree (data);
246 }
247
248
ChangeKey(Handle obj)249 static void ChangeKey (Handle obj)
250
251 {
252 Char ch;
253 Int2 expev;
254 Int2 geneval;
255 HelpMessageFunc helpfunc;
256 ImprtFormPtr ifp;
257 ImpFeatPtr imp;
258 ImprtFormPtr newifp;
259 ObjMgrPtr omp;
260 ObjMgrTypePtr omtp;
261 CharPtr ptr;
262 SeqEntryPtr sep;
263 SeqFeatPtr sfp;
264 Char title [128];
265 WindoW w;
266
267 ifp = (ImprtFormPtr) GetObjectExtra (obj);
268 if (ifp != NULL) {
269 sfp = SeqFeatNew ();
270 if (sfp != NULL) {
271 sfp->data.choice = FindFeatFromFeatDefType (ifp->this_subtype);
272 sfp->data.value.ptrvalue = DialogToPointer (ifp->data);
273 sfp->comment = SaveStringFromText (ifp->comment);
274 ptr = sfp->comment;
275 if (ptr != NULL) {
276 ch = *ptr;
277 while (ch != '\0') {
278 if (ch < ' ' || ch > '~') {
279 *ptr = '~';
280 }
281 ptr++;
282 ch = *ptr;
283 }
284 }
285 expev = GetValue (ifp->evidence);
286 if (expev > 0 && expev <= 3) {
287 sfp->exp_ev = expev - 1;
288 } else {
289 sfp->exp_ev = 0;
290 }
291 sfp->partial = GetStatus (ifp->partial);
292 sfp->excpt = GetStatus (ifp->exception);
293 sfp->title = NULL;
294 sfp->product = DialogToPointer (ifp->product);
295 sfp->location = DialogToPointer (ifp->location);
296 sfp->cit = DialogToPointer (ifp->featcits);
297 sfp->dbxref = DialogToPointer (ifp->dbxrefs);
298 sfp->qual = DialogToPointer (ifp->gbquals);
299 CleanupEvidenceGBQuals (&(sfp->qual));
300 VisStringDialogToGbquals (sfp, ifp->experiment, "experiment");
301 InferenceDialogToGBQuals (ifp->inference, sfp, TRUE);
302 geneval = GetValue (ifp->gene);
303 sep = GetTopSeqEntryForEntityID (ifp->input_entityID);
304 StringCpy (title, "Feature");
305 if (sfp != NULL && sfp->data.value.ptrvalue != NULL) {
306 imp = (ImpFeatPtr) sfp->data.value.ptrvalue;
307 StringNCpy_0 (title, imp->key, sizeof (title));
308 if (StringHasNoText (title)) {
309 StringCpy (title, "Feature");
310 }
311 }
312 w = (WindoW) CreateImportForm (-50, -33, title, sfp, sep,
313 StdFeatFormActnProc);
314 newifp = (ImprtFormPtr) GetObjectExtra (w);
315 if (newifp != NULL) {
316 newifp->input_entityID = ifp->input_entityID;
317 newifp->input_itemID = ifp->input_itemID;
318 newifp->input_itemtype = ifp->input_itemtype;
319 newifp->this_itemtype = ifp->this_itemtype;
320 newifp->this_subtype = ifp->this_subtype;
321 if (sfp != NULL) {
322 omp = ObjMgrGet ();
323 if (omp != NULL) {
324 omtp = ObjMgrTypeFind (omp, OBJ_SEQFEAT, NULL, NULL);
325 if (omtp != NULL && omtp->subtypefunc != NULL) {
326 newifp->this_subtype = (*(omtp->subtypefunc)) (sfp);
327 }
328 }
329 }
330 SendMessageToForm (newifp->form, VIB_MSG_INIT);
331 SetValue (newifp->gene, geneval);
332 if (sfp != NULL) {
333 PointerToForm (newifp->form, (Pointer) sfp);
334 }
335 }
336 Remove (ifp->form);
337 Show (w);
338 Select (w);
339 helpfunc = (HelpMessageFunc) GetAppProperty ("HelpMessageProc");
340 if (helpfunc != NULL) {
341 helpfunc ("Features", title);
342 }
343 }
344 SeqFeatFree (sfp);
345 Update ();
346 }
347 }
348
CreateImportDialog(GrouP h,CharPtr title,ImprtFormPtr ifp,Boolean allowPeptideFeats,SeqFeatPtr sfp,Boolean is_gap)349 static DialoG CreateImportDialog (GrouP h, CharPtr title, ImprtFormPtr ifp,
350 Boolean allowPeptideFeats, SeqFeatPtr sfp, Boolean is_gap)
351
352 {
353 EnumFieldAssocPtr ap;
354 GrouP f;
355 ImportPagePtr ipp;
356 GrouP m;
357 GrouP p;
358 PrompT ppt;
359 GrouP s;
360 CharPtr str;
361 Boolean usePopup;
362 PrompT x;
363
364 p = HiddenGroup (h, 1, 0, NULL);
365 SetGroupSpacing (p, 10, 10);
366
367 ipp = (ImportPagePtr) MemNew (sizeof (ImportPage));
368 if (ipp != NULL) {
369
370 SetObjectExtra (p, ipp, CleanupImportPage);
371 ipp->dialog = (DialoG) p;
372 ipp->todialog = ImpFeatPtrToImportPage;
373 ipp->fromdialog = ImportPageToImpFeatPtr;
374 ipp->testdialog = NULL;
375
376 if (title != NULL && title [0] != '\0') {
377 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
378 } else {
379 s = HiddenGroup (p, 0, -2, NULL);
380 }
381 m = HiddenGroup (s, -1, 0, NULL);
382 /*
383 SetGroupSpacing (m, 10, 10);
384 */
385
386 ipp->ifp = ifp;
387 if (is_gap) {
388 ipp->alist = gap_featdef_alist ();
389 } else {
390 ipp->alist = import_featdef_alist (FALSE, allowPeptideFeats, FALSE);
391 }
392
393 ppt = StaticPrompt (m, "Changing feature key will recreate the window.",
394 0, 0, programFont, 'c');
395 f = HiddenGroup (m, -2, 0, NULL);
396
397 #ifdef WIN_MOTIF
398 usePopup = FALSE;
399 #else
400 usePopup = TRUE;
401 #endif
402
403 x = NULL;
404 #ifndef WIN_MOTIF
405 x = StaticPrompt (f, "Key", 0, 0, programFont, 'l');
406 #endif
407 if (usePopup) {
408 if (is_gap) {
409 ipp->key = (Handle) PopupList (f, TRUE, (PupActnProc) ChangeKey);
410 } else {
411 ipp->key = (Handle) PopupList (f, TRUE, (PupActnProc) ChangeKey);
412 }
413 SetObjectExtra (ipp->key, ifp, NULL);
414 InitEnumPopup ((PopuP) ipp->key, ipp->alist, NULL);
415 SetEnumPopup ((PopuP) ipp->key, ipp->alist, (UIEnum) 0);
416 } else {
417 ipp->key = (Handle) SingleList (f, 12, 3, (LstActnProc) ChangeKey);
418 SetObjectExtra (ipp->key, ifp, NULL);
419 for (ap = ipp->alist; ap->name != NULL; ap++) {
420 ListItem ((LisT) ipp->key, ap->name);
421 }
422 SetValue (ipp->key, 0);
423 }
424 if (Nlm_GetAppProperty ("SequinUseImpFeatLocField") != NULL) {
425 StaticPrompt (f, "Loc", 0, dialogTextHeight, programFont, 'l');
426 ipp->loc = DialogText (f, "", 15, NULL);
427 }
428 AlignObjects (ALIGN_VERTICAL, (HANDLE) ipp->key, (HANDLE) x, NULL);
429 for (ap = ipp->alist; ap->name != NULL; ap++) {
430 str = ap->name;
431 if (*str == '~') {
432 *str = '-';
433 }
434 }
435 AlignObjects (ALIGN_CENTER, (HANDLE) ppt, (HANDLE) f, NULL);
436 }
437
438 return (DialoG) p;
439 }
440
SetImportImportExportItems(ImprtFormPtr ifp)441 static void SetImportImportExportItems (ImprtFormPtr ifp)
442
443 {
444 IteM exportItm;
445 IteM importItm;
446
447 if (ifp != NULL) {
448 importItm = FindFormMenuItem ((BaseFormPtr) ifp, VIB_MSG_IMPORT);
449 exportItm = FindFormMenuItem ((BaseFormPtr) ifp, VIB_MSG_EXPORT);
450 switch (ifp->currentPage) {
451 case IMPORT_PAGE :
452 SafeSetTitle (importItm, "Import...");
453 SafeSetTitle (exportItm, "Export...");
454 SafeDisable (importItm);
455 SafeDisable (exportItm);
456 break;
457 case COMMON_PAGE :
458 SafeSetTitle (importItm, "Import...");
459 SafeSetTitle (exportItm, "Export...");
460 SafeDisable (importItm);
461 SafeDisable (exportItm);
462 break;
463 case LOCATION_PAGE :
464 SafeSetTitle (importItm, "Import SeqLoc...");
465 SafeSetTitle (exportItm, "Export SeqLoc...");
466 SafeEnable (importItm);
467 SafeEnable (exportItm);
468 break;
469 default :
470 break;
471 }
472 }
473 }
474
ChangeImportPage(VoidPtr data,Int2 newval,Int2 oldval)475 static void ChangeImportPage (VoidPtr data, Int2 newval, Int2 oldval)
476
477 {
478 ImprtFormPtr ifp;
479
480 ifp = (ImprtFormPtr) data;
481 if (ifp != NULL) {
482 ifp->currentPage = newval;
483 SafeHide (ifp->pages [oldval]);
484 SafeShow (ifp->pages [newval]);
485 switch (newval) {
486 case IMPORT_PAGE :
487 SendMessageToDialog (ifp->data, VIB_MSG_ENTER);
488 break;
489 case COMMON_PAGE :
490 break;
491 case LOCATION_PAGE :
492 SendMessageToDialog (ifp->location, VIB_MSG_ENTER);
493 break;
494 default :
495 break;
496 }
497 SetImportImportExportItems (ifp);
498 Update ();
499 }
500 }
501
ImportImportForm(ForM f,CharPtr filename)502 static Boolean ImportImportForm (ForM f, CharPtr filename)
503
504 {
505 ImprtFormPtr ifp;
506
507 ifp = (ImprtFormPtr) GetObjectExtra (f);
508 if (ifp != NULL) {
509 switch (ifp->currentPage) {
510 case LOCATION_PAGE :
511 return ImportDialog (ifp->location, filename);
512 default :
513 break;
514 }
515 }
516 return FALSE;
517 }
518
ExportImportForm(ForM f,CharPtr filename)519 static Boolean ExportImportForm (ForM f, CharPtr filename)
520
521 {
522 ImprtFormPtr ifp;
523
524 ifp = (ImprtFormPtr) GetObjectExtra (f);
525 if (ifp != NULL) {
526 switch (ifp->currentPage) {
527 case LOCATION_PAGE :
528 return ExportDialog (ifp->location, filename);
529 default :
530 break;
531 }
532 }
533 return FALSE;
534 }
535
536 static CharPtr importFormTabs [] = {
537 NULL, "Properties", "Location", NULL
538 };
539
540 extern DialoG CreateQualsDialog (GrouP h, Uint2 rows, Int2 spacing,
541 Int2 width1, Int2 width2);
542
ImportFormMessage(ForM f,Int2 mssg)543 static void ImportFormMessage (ForM f, Int2 mssg)
544
545 {
546 ImprtFormPtr ifp;
547
548 ifp = (ImprtFormPtr) GetObjectExtra (f);
549 if (ifp != NULL) {
550 switch (mssg) {
551 case VIB_MSG_INIT :
552 StdInitFeatFormProc (f);
553 break;
554 case VIB_MSG_IMPORT :
555 ImportImportForm (f, NULL);
556 break;
557 case VIB_MSG_EXPORT :
558 ExportImportForm (f, NULL);
559 break;
560 case VIB_MSG_CLOSE :
561 Remove (f);
562 break;
563 case VIB_MSG_CUT :
564 StdCutTextProc (NULL);
565 break;
566 case VIB_MSG_COPY :
567 StdCopyTextProc (NULL);
568 break;
569 case VIB_MSG_PASTE :
570 StdPasteTextProc (NULL);
571 break;
572 case VIB_MSG_DELETE :
573 if (ifp->currentPage == LOCATION_PAGE) {
574 PointerToDialog (ifp->location, NULL);
575 } else {
576 StdDeleteTextProc (NULL);
577 }
578 break;
579 default :
580 if (ifp->appmessage != NULL) {
581 ifp->appmessage (f, mssg);
582 }
583 break;
584 }
585 }
586 }
587
ImportFormActivate(WindoW w)588 static void ImportFormActivate (WindoW w)
589
590 {
591 ImprtFormPtr ifp;
592
593 ifp = (ImprtFormPtr) GetObjectExtra (w);
594 if (ifp != NULL) {
595 if (ifp->activate != NULL) {
596 ifp->activate (w);
597 }
598 SetImportImportExportItems (ifp);
599 }
600 }
601
602 extern DialoG NewCreateImportFields (GrouP h, CharPtr name, SeqFeatPtr sfp, Boolean allowProductGBQual);
603
CreateImportForm(Int2 left,Int2 top,CharPtr title,SeqFeatPtr sfp,SeqEntryPtr sep,FormActnFunc actproc)604 extern ForM CreateImportForm (Int2 left, Int2 top, CharPtr title,
605 SeqFeatPtr sfp, SeqEntryPtr sep,
606 FormActnFunc actproc)
607
608 {
609 Boolean allowPeptideFeats;
610 Boolean allowProductGBQual;
611 ButtoN b;
612 GrouP c;
613 GrouP g;
614 GrouP h;
615 Boolean hasGeneControl;
616 ImprtFormPtr ifp;
617 ImpFeatPtr imp;
618 Boolean is_gap = FALSE;
619 GrouP s;
620 StdEditorProcsPtr sepp;
621 WindoW w;
622 GrouP x;
623 GrouP z;
624 Boolean indexerVersion;
625
626 w = NULL;
627 ifp = (ImprtFormPtr) MemNew (sizeof (ImprtForm));
628 if (ifp != NULL) {
629 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
630 SetObjectExtra (w, ifp, StdFeatFormCleanupProc);
631 ifp->form = (ForM) w;
632 ifp->actproc = actproc;
633 ifp->toform = StdSeqFeatPtrToFeatFormProc;
634 ifp->fromform = NULL;
635 ifp->formmessage = ImportFormMessage;
636 ifp->testform = NULL;
637 ifp->importform = ImportImportForm;
638 ifp->exportform = ExportImportForm;
639
640 #ifndef WIN_MAC
641 CreateStdEditorFormMenus (w);
642 #endif
643
644 ifp->activate = NULL;
645 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
646 if (sepp != NULL) {
647 ifp->activate = sepp->activateForm;
648 ifp->appmessage = sepp->handleMessages;
649 }
650 SetActivate (w, ImportFormActivate);
651
652 g = HiddenGroup (w, -1, 0, NULL);
653 SetGroupSpacing (g, 3, 10);
654
655 if (sfp != NULL && sfp->data.choice == SEQFEAT_IMP) {
656 imp = (ImpFeatPtr) sfp->data.value.ptrvalue;
657 if (imp != NULL && StringICmp (imp->key, "gap") == 0) {
658 is_gap = TRUE;
659 }
660 }
661
662 ifp->sep = sep;
663 importFormTabs [0] = NULL;
664 if (title == NULL || *title == '\0') {
665 title = "misc_feature";
666 }
667 importFormTabs [0] = title;
668 ifp->foldertabs = CreateFolderTabs (g, importFormTabs, IMPORT_PAGE,
669 0, 0, SYSTEM_FOLDER_TAB,
670 ChangeImportPage, (Pointer) ifp);
671 ifp->currentPage = IMPORT_PAGE;
672
673 h = HiddenGroup (g, 0, 0, NULL);
674
675 s = HiddenGroup (h, -1, 0, NULL);
676 SetGroupSpacing (s, 3, 10);
677 allowPeptideFeats = FALSE;
678 allowProductGBQual = FALSE;
679 if (StringICmp (title, "mat_peptide") == 0 ||
680 StringICmp (title, "sig_peptide") == 0 ||
681 StringICmp (title, "transit_peptide") == 0) {
682 allowPeptideFeats = TRUE;
683 allowProductGBQual = TRUE;
684 } else if (StringICmp (title, "misc_RNA") == 0 ||
685 StringICmp (title, "C_region") == 0 ||
686 StringICmp (title, "D_segment") == 0 ||
687 StringICmp (title, "exon") == 0 ||
688 StringICmp (title, "J_segment") == 0 ||
689 StringICmp (title, "misc_feature") == 0 ||
690 StringICmp (title, "N_region") == 0 ||
691 StringICmp (title, "S_region") == 0 ||
692 StringICmp (title, "V_region") == 0 ||
693 StringICmp (title, "V_segment") == 0 ||
694 StringICmp (title, "variation") == 0) {
695 allowProductGBQual = TRUE;
696 }
697 ifp->data = CreateImportDialog (s, NULL, ifp, allowPeptideFeats, sfp, is_gap);
698 x = HiddenGroup (s, -1, 0, NULL);
699 if (StringICmp (importFormTabs [0], "source") == 0) {
700 z = HiddenGroup (x, -4, 0, NULL);
701 SetGroupSpacing (z, -1, 0);
702 StaticPrompt (z, "Qualifier", 7 * stdCharWidth, 0, programFont, 'c');
703 StaticPrompt (z, "Value", 10 * stdCharWidth, 0, programFont, 'c');
704 ifp->gbquals = CreateQualsDialog (x, 5, -1, 7, 10);
705 } else {
706 ifp->gbquals = NewCreateImportFields (x, importFormTabs [0], sfp, allowProductGBQual);
707 /* old version: ifp->gbquals = CreateImportFields (x, importFormTabs [0], sfp, allowProductGBQual); */
708 }
709 AlignObjects (ALIGN_CENTER, (HANDLE) ifp->data, (HANDLE) x, NULL);
710 ifp->pages [IMPORT_PAGE] = s;
711 Hide (ifp->pages [IMPORT_PAGE]);
712 importFormTabs [0] = NULL;
713
714 s = HiddenGroup (h, -1, 0, NULL);
715 hasGeneControl = TRUE;
716 if (StringICmp (title, "operon") == 0) {
717 hasGeneControl = FALSE;
718 }
719 CreateCommonFeatureGroup (s, (FeatureFormPtr) ifp, sfp, hasGeneControl, TRUE);
720 ifp->pages [COMMON_PAGE] = s;
721 Hide (ifp->pages [COMMON_PAGE]);
722
723 s = HiddenGroup (h, -1, 0, NULL);
724 ifp->location = CreateIntervalEditorDialogEx (s, NULL, 4, 2, sep, TRUE, FALSE,
725 TRUE, TRUE, FALSE,
726 (FeatureFormPtr) ifp,
727 StdFeatIntEdPartialCallback);
728 ifp->pages [LOCATION_PAGE] = s;
729 Hide (ifp->pages [LOCATION_PAGE]);
730
731 AlignObjects (ALIGN_CENTER, (HANDLE) ifp->pages [IMPORT_PAGE],
732 (HANDLE) ifp->pages [COMMON_PAGE], (HANDLE) ifp->pages [LOCATION_PAGE],
733 NULL);
734 AlignObjects (ALIGN_CENTER, (HANDLE) ifp->foldertabs, (HANDLE) h, NULL);
735
736 c = HiddenGroup (w, 3, 0, NULL);
737 b = PushButton (c, "Accept", StdFeatFormAcceptButtonProc);
738 SetObjectExtra (b, ifp, NULL);
739 PushButton (c, "Cancel", StdCancelButtonProc);
740 indexerVersion = (Boolean) (GetAppProperty ("InternalNcbiSequin") != NULL);
741 if (sfp == NULL && indexerVersion) {
742 ifp->leave_dlg_up = CheckBox (c, "Leave Dialog Up", NULL);
743 }
744
745 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
746 RealizeWindow (w);
747
748 SendMessageToDialog (ifp->data, VIB_MSG_INIT);
749 SendMessageToDialog (ifp->location, VIB_MSG_INIT);
750 Show (ifp->pages [ifp->currentPage]);
751 SendMessageToDialog (ifp->data, VIB_MSG_ENTER);
752 Update ();
753 }
754 return (ForM) w;
755 }
756
ImportGenFunc(Pointer data)757 extern Int2 LIBCALLBACK ImportGenFunc (Pointer data)
758
759 {
760 EnumFieldAssocPtr ap;
761 FeatDefPtr curr;
762 HelpMessageFunc helpfunc;
763 Int2 i;
764 ImprtFormPtr ifp;
765 ImpFeatPtr imp;
766 ImportPagePtr ipp;
767 Uint1 key;
768 CharPtr label = NULL;
769 ObjMgrPtr omp;
770 OMProcControlPtr ompcp;
771 ObjMgrTypePtr omtp;
772 OMUserDataPtr omudp;
773 ObjMgrProcPtr proc;
774 SeqEntryPtr sep;
775 SeqFeatPtr sfp;
776 Uint2 subtype;
777 Char title [64];
778 WindoW w;
779
780 ompcp = (OMProcControlPtr) data;
781 sfp = NULL;
782 sep = NULL;
783 imp = NULL;
784 subtype = FEATDEF_IMP;
785 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
786 proc = ompcp->proc;
787 switch (ompcp->input_itemtype) {
788 case OBJ_SEQFEAT :
789 sfp = (SeqFeatPtr) ompcp->input_data;
790 if (sfp != NULL && sfp->data.choice != SEQFEAT_IMP) {
791 return OM_MSG_RET_ERROR;
792 }
793 break;
794 case OBJ_BIOSEQ :
795 break;
796 case OBJ_BIOSEQSET :
797 break;
798 case 0 :
799 break;
800 default :
801 return OM_MSG_RET_ERROR;
802 }
803 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
804 ompcp->input_itemtype, ompcp->proc->procid);
805 if (omudp != NULL) {
806 ifp = (ImprtFormPtr) omudp->userdata.ptrvalue;
807 if (ifp != NULL) {
808 Select (ifp->form);
809 }
810 return OM_MSG_RET_DONE;
811 }
812 sep = GetTopSeqEntryForEntityID (ompcp->input_entityID);
813 StringCpy (title, "Feature");
814 if (sfp != NULL && sfp->data.value.ptrvalue != NULL) {
815 imp = (ImpFeatPtr) sfp->data.value.ptrvalue;
816 StringNCpy_0 (title, imp->key, sizeof (title));
817 if (StringHasNoText (title)) {
818 StringCpy (title, "Feature");
819 }
820 } else if (proc->subinputtype > 0) {
821 subtype = proc->subinputtype;
822 curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
823 while (curr != NULL) {
824 if (key != FEATDEF_BAD && curr->seqfeat_key == SEQFEAT_IMP) {
825 if (subtype == curr->featdef_key) {
826 StringNCpy_0 (title, curr->typelabel, sizeof (title));
827 break;
828 }
829 }
830 curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
831 }
832 }
833 w = (WindoW) CreateImportForm (-50, -33, title, sfp, sep,
834 StdFeatFormActnProc);
835 ifp = (ImprtFormPtr) GetObjectExtra (w);
836 if (ifp != NULL) {
837 ifp->input_entityID = ompcp->input_entityID;
838 ifp->input_itemID = ompcp->input_itemID;
839 ifp->input_itemtype = ompcp->input_itemtype;
840 ifp->this_itemtype = OBJ_SEQFEAT;
841 ifp->this_subtype = subtype;
842 ifp->procid = ompcp->proc->procid;
843 ifp->proctype = ompcp->proc->proctype;
844 ifp->userkey = OMGetNextUserKey ();
845 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
846 OMPROC_EDIT, ifp->userkey);
847 if (omudp != NULL) {
848 omudp->userdata.ptrvalue = (Pointer) ifp;
849 omudp->messagefunc = StdVibrantEditorMsgFunc;
850 }
851 if (sfp != NULL) {
852 omp = ObjMgrGet ();
853 if (omp != NULL) {
854 omtp = ObjMgrTypeFind (omp, OBJ_SEQFEAT, NULL, NULL);
855 if (omtp != NULL && omtp->subtypefunc != NULL) {
856 ifp->this_subtype = (*(omtp->subtypefunc)) (sfp);
857 }
858 }
859 }
860 SendMessageToForm (ifp->form, VIB_MSG_INIT);
861 if (sfp != NULL) {
862 PointerToForm (ifp->form, (Pointer) sfp);
863 SetClosestParentIfDuplicating ((BaseFormPtr) ifp);
864 } else {
865 ipp = (ImportPagePtr) GetObjectExtra (ifp->data);
866 if (ipp != NULL) {
867 for (i = 1, ap = ipp->alist; ap->name != NULL; i++, ap++) {
868 if (StringCmp (ap->name, title) == 0) {
869 SetValue (ipp->key, i);
870 SetTitle (ipp->loc, "");
871 break;
872 }
873 }
874 }
875 SetNewFeatureDefaultInterval ((FeatureFormPtr) ifp);
876 }
877 }
878 Show (w);
879 Select (w);
880 helpfunc = (HelpMessageFunc) GetAppProperty ("HelpMessageProc");
881 if (helpfunc != NULL) {
882 helpfunc ("Features", title);
883 }
884 return OM_MSG_RET_DONE;
885 }
886
887
888 typedef struct enumpage {
889 DIALOG_MESSAGE_BLOCK
890 PopuP key;
891 EnumFieldAssocPtr alist;
892 } EnumPage, PNTR EnumPagePtr;
893
894 typedef struct enumform {
895 FEATURE_FORM_BLOCK
896 SeqEntryPtr sep;
897 GrouP pages [NUM_PAGES];
898 DialoG foldertabs;
899 Int2 currentPage;
900 } EnumForm, PNTR EnumFormPtr;
901
902 extern EnumFieldAssoc enum_bond_alist [];
ENUM_ALIST(enum_bond_alist)903 ENUM_ALIST(enum_bond_alist)
904 {"Disulfide", 1},
905 {"Thioester", 2},
906 {"Crosslink", 3},
907 {"Thioether", 4},
908 {"Other", 255},
909 END_ENUM_ALIST
910
911 extern EnumFieldAssoc enum_site_alist [];
ENUM_ALIST(enum_site_alist)912 ENUM_ALIST(enum_site_alist)
913 {"Active", 1},
914 {"Binding", 2},
915 {"Cleavage", 3},
916 {"Inhibit", 4},
917 {"Modified", 5},
918 {"Glycosylation", 6},
919 {"Myristoylation", 7},
920 {"Mutagenized", 8},
921 {"Metal-binding", 9},
922 {"Phosphorylation", 10},
923 {"Acetylation", 11},
924 {"Amidation", 12},
925 {"Methylation", 13},
926 {"Hydroxylation", 14},
927 {"Sulfatation", 15},
928 {"Oxidative-deamination", 16},
929 {"Pyrrolidone-carboxylic-acid", 17},
930 {"Gamma-carboxyglutamic-acid", 18},
931 {"Blocked", 19},
932 {"Lipid-binding", 20},
933 {"np-binding", 21},
934 {"DNA-binding", 22},
935 {"Signal-peptide", 23},
936 {"Transit-peptide", 24},
937 {"Transmembrane-region", 25},
938 {"Nitrosylation", 26},
939 {"Other", 255},
940 END_ENUM_ALIST
941
942 static ENUM_ALIST(enum_psec_alist)
943 {"Helix", 1},
944 {"Sheet", 2},
945 {"Turn", 3},
946 END_ENUM_ALIST
947
948 static void EnumFeatPtrToEnumPage (DialoG d, Pointer data)
949
950 {
951 EnumPagePtr epp;
952 Int4Ptr intptr;
953 Int4 val;
954
955 epp = (EnumPagePtr) GetObjectExtra (d);
956 intptr = (Int4Ptr) data;
957 if (epp != NULL) {
958 val = *intptr;
959 SetEnumPopup (epp->key, epp->alist, (UIEnum) val);
960 }
961 }
962
EnumPageToEnumFeatPtr(DialoG d)963 static Pointer EnumPageToEnumFeatPtr (DialoG d)
964
965 {
966 EnumPagePtr epp;
967 Int4Ptr intptr;
968 UIEnum val;
969
970 intptr = NULL;
971 epp = (EnumPagePtr) GetObjectExtra (d);
972 if (epp != NULL) {
973 if (GetEnumPopup (epp->key, epp->alist, &val)) {
974 epp->intvalue = (Int4) val;
975 intptr = (&epp->intvalue);
976 }
977 }
978 return (Pointer) intptr;
979 }
980
CreateEnumDialog(GrouP h,CharPtr title,Uint2 subtype)981 static DialoG CreateEnumDialog (GrouP h, CharPtr title, Uint2 subtype)
982
983 {
984 EnumPagePtr epp;
985 GrouP f;
986 GrouP m;
987 GrouP p;
988 GrouP s;
989
990 p = HiddenGroup (h, 1, 0, NULL);
991 SetGroupSpacing (p, 10, 10);
992
993 epp = (EnumPagePtr) MemNew (sizeof (EnumPage));
994 if (epp != NULL) {
995
996 SetObjectExtra (p, epp, StdCleanupExtraProc);
997 epp->dialog = (DialoG) p;
998 epp->todialog = EnumFeatPtrToEnumPage;
999 epp->fromdialog = EnumPageToEnumFeatPtr;
1000 epp->testdialog = NULL;
1001
1002 if (title != NULL && title [0] != '\0') {
1003 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
1004 } else {
1005 s = HiddenGroup (p, 0, -2, NULL);
1006 }
1007 m = HiddenGroup (s, -1, 0, NULL);
1008 /*
1009 SetGroupSpacing (m, 10, 10);
1010 */
1011
1012 switch (subtype) {
1013 case FEATDEF_BOND :
1014 epp->alist = enum_bond_alist;
1015 break;
1016 case FEATDEF_SITE :
1017 epp->alist = enum_site_alist;
1018 break;
1019 case FEATDEF_PSEC_STR :
1020 epp->alist = enum_psec_alist;
1021 break;
1022 default :
1023 Message (MSG_FATAL, "Unknown enumerated feature type");
1024 return NULL;
1025 }
1026
1027 f = HiddenGroup (m, -2, 0, NULL);
1028 StaticPrompt (f, "Type", 0, popupMenuHeight, programFont, 'l');
1029 epp->key = PopupList (f, TRUE, NULL);
1030 SetObjectExtra (epp->key, epp, NULL);
1031 InitEnumPopup (epp->key, epp->alist, NULL);
1032 /*
1033 SetEnumPopup (epp->key, epp->alist, (UIEnum) 0);
1034 */
1035 }
1036
1037 return (DialoG) p;
1038 }
1039
SetEnumImportExportItems(EnumFormPtr efp)1040 static void SetEnumImportExportItems (EnumFormPtr efp)
1041
1042 {
1043 IteM exportItm;
1044 IteM importItm;
1045
1046 if (efp != NULL) {
1047 importItm = FindFormMenuItem ((BaseFormPtr) efp, VIB_MSG_IMPORT);
1048 exportItm = FindFormMenuItem ((BaseFormPtr) efp, VIB_MSG_EXPORT);
1049 switch (efp->currentPage) {
1050 case ENUM_PAGE :
1051 SafeSetTitle (importItm, "Import...");
1052 SafeSetTitle (exportItm, "Export...");
1053 SafeDisable (importItm);
1054 SafeDisable (exportItm);
1055 break;
1056 case COMMON_PAGE :
1057 SafeSetTitle (importItm, "Import...");
1058 SafeSetTitle (exportItm, "Export...");
1059 SafeDisable (importItm);
1060 SafeDisable (exportItm);
1061 break;
1062 case LOCATION_PAGE :
1063 SafeSetTitle (importItm, "Import SeqLoc...");
1064 SafeSetTitle (exportItm, "Export SeqLoc...");
1065 SafeEnable (importItm);
1066 SafeEnable (exportItm);
1067 break;
1068 default :
1069 break;
1070 }
1071 }
1072 }
1073
ChangeEnumPage(VoidPtr data,Int2 newval,Int2 oldval)1074 static void ChangeEnumPage (VoidPtr data, Int2 newval, Int2 oldval)
1075
1076 {
1077 EnumFormPtr efp;
1078
1079 efp = (EnumFormPtr) data;
1080 if (efp != NULL) {
1081 efp->currentPage = newval;
1082 SafeHide (efp->pages [oldval]);
1083 SafeShow (efp->pages [newval]);
1084 switch (newval) {
1085 case ENUM_PAGE :
1086 SendMessageToDialog (efp->data, VIB_MSG_ENTER);
1087 break;
1088 case COMMON_PAGE :
1089 break;
1090 case LOCATION_PAGE :
1091 SendMessageToDialog (efp->location, VIB_MSG_ENTER);
1092 break;
1093 default :
1094 break;
1095 }
1096 SetEnumImportExportItems (efp);
1097 Update ();
1098 }
1099 }
1100
ImportEnumForm(ForM f,CharPtr filename)1101 static Boolean ImportEnumForm (ForM f, CharPtr filename)
1102
1103 {
1104 EnumFormPtr efp;
1105
1106 efp = (EnumFormPtr) GetObjectExtra (f);
1107 if (efp != NULL) {
1108 switch (efp->currentPage) {
1109 case LOCATION_PAGE :
1110 return ImportDialog (efp->location, filename);
1111 default :
1112 break;
1113 }
1114 }
1115 return FALSE;
1116 }
1117
ExportEnumForm(ForM f,CharPtr filename)1118 static Boolean ExportEnumForm (ForM f, CharPtr filename)
1119
1120 {
1121 EnumFormPtr efp;
1122
1123 efp = (EnumFormPtr) GetObjectExtra (f);
1124 if (efp != NULL) {
1125 switch (efp->currentPage) {
1126 case LOCATION_PAGE :
1127 return ExportDialog (efp->location, filename);
1128 default :
1129 break;
1130 }
1131 }
1132 return FALSE;
1133 }
1134
1135 static CharPtr enumFormTabs [] = {
1136 NULL, "Properties", "Location", NULL
1137 };
1138
EnumFormMessage(ForM f,Int2 mssg)1139 static void EnumFormMessage (ForM f, Int2 mssg)
1140
1141 {
1142 EnumFormPtr efp;
1143
1144 efp = (EnumFormPtr) GetObjectExtra (f);
1145 if (efp != NULL) {
1146 switch (mssg) {
1147 case VIB_MSG_INIT :
1148 StdInitFeatFormProc (f);
1149 break;
1150 case VIB_MSG_IMPORT :
1151 ImportEnumForm (f, NULL);
1152 break;
1153 case VIB_MSG_EXPORT :
1154 ExportEnumForm (f, NULL);
1155 break;
1156 case VIB_MSG_CLOSE :
1157 Remove (f);
1158 break;
1159 case VIB_MSG_CUT :
1160 StdCutTextProc (NULL);
1161 break;
1162 case VIB_MSG_COPY :
1163 StdCopyTextProc (NULL);
1164 break;
1165 case VIB_MSG_PASTE :
1166 StdPasteTextProc (NULL);
1167 break;
1168 case VIB_MSG_DELETE :
1169 if (efp->currentPage == LOCATION_PAGE) {
1170 PointerToDialog (efp->location, NULL);
1171 } else {
1172 StdDeleteTextProc (NULL);
1173 }
1174 break;
1175 default :
1176 if (efp->appmessage != NULL) {
1177 efp->appmessage (f, mssg);
1178 }
1179 break;
1180 }
1181 }
1182 }
1183
EnumFormActivate(WindoW w)1184 static void EnumFormActivate (WindoW w)
1185
1186 {
1187 EnumFormPtr efp;
1188
1189 efp = (EnumFormPtr) GetObjectExtra (w);
1190 if (efp != NULL) {
1191 if (efp->activate != NULL) {
1192 efp->activate (w);
1193 }
1194 SetEnumImportExportItems (efp);
1195 }
1196 }
1197
1198 extern DialoG CreateBondEditorDialog (GrouP h, CharPtr title, SeqEntryPtr sep);
1199
CreateEnumForm(Int2 left,Int2 top,CharPtr title,SeqFeatPtr sfp,SeqEntryPtr sep,Uint2 subtype,FormActnFunc actproc)1200 extern ForM CreateEnumForm (Int2 left, Int2 top, CharPtr title,
1201 SeqFeatPtr sfp, SeqEntryPtr sep,
1202 Uint2 subtype, FormActnFunc actproc)
1203
1204 {
1205 ButtoN b;
1206 GrouP c;
1207 EnumFormPtr efp;
1208 GrouP g;
1209 GrouP h;
1210 GrouP s;
1211 StdEditorProcsPtr sepp;
1212 WindoW w;
1213
1214 w = NULL;
1215 efp = (EnumFormPtr) MemNew (sizeof (EnumForm));
1216 if (efp != NULL) {
1217 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
1218 SetObjectExtra (w, efp, StdFeatFormCleanupProc);
1219 efp->form = (ForM) w;
1220 efp->actproc = actproc;
1221 efp->toform = StdSeqFeatPtrToFeatFormProc;
1222 efp->fromform = NULL;
1223 efp->formmessage = EnumFormMessage;
1224 efp->testform = NULL;
1225 efp->importform = ImportEnumForm;
1226 efp->exportform = ExportEnumForm;
1227
1228 #ifndef WIN_MAC
1229 CreateStdEditorFormMenus (w);
1230 #endif
1231
1232 efp->activate = NULL;
1233 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
1234 if (sepp != NULL) {
1235 efp->activate = sepp->activateForm;
1236 efp->appmessage = sepp->handleMessages;
1237 }
1238 SetActivate (w, EnumFormActivate);
1239
1240 g = HiddenGroup (w, -1, 0, NULL);
1241 SetGroupSpacing (g, 3, 10);
1242
1243 efp->sep = sep;
1244 enumFormTabs [0] = NULL;
1245 if (title != NULL && *title != '\0') {
1246 enumFormTabs [0] = title;
1247 } else if (subtype == FEATDEF_BOND) {
1248 enumFormTabs [0] = "Bond";
1249 } else if (subtype == FEATDEF_SITE) {
1250 enumFormTabs [0] = "Site";
1251 } else if (subtype == FEATDEF_PSEC_STR) {
1252 enumFormTabs [0] = "Secondary Structure";
1253 }
1254 efp->foldertabs = CreateFolderTabs (g, enumFormTabs, ENUM_PAGE,
1255 0, 0, SYSTEM_FOLDER_TAB,
1256 ChangeEnumPage, (Pointer) efp);
1257 efp->currentPage = ENUM_PAGE;
1258
1259 h = HiddenGroup (g, 0, 0, NULL);
1260
1261 s = HiddenGroup (h, -1, 0, NULL);
1262 SetGroupSpacing (s, 3, 10);
1263 efp->data = CreateEnumDialog (s, NULL, subtype);
1264 efp->pages [ENUM_PAGE] = s;
1265 Hide (efp->pages [ENUM_PAGE]);
1266 enumFormTabs [0] = NULL;
1267
1268 s = HiddenGroup (h, -1, 0, NULL);
1269 CreateCommonFeatureGroup (s, (FeatureFormPtr) efp, sfp, TRUE, TRUE);
1270 efp->pages [COMMON_PAGE] = s;
1271 Hide (efp->pages [COMMON_PAGE]);
1272
1273 s = HiddenGroup (h, -1, 0, NULL);
1274 if (subtype == FEATDEF_BOND) {
1275 efp->location = CreateBondEditorDialog (s, NULL, sep);
1276 } else {
1277 efp->location = CreateIntervalEditorDialogEx (s, NULL, 4, 2, sep, TRUE, TRUE,
1278 TRUE, TRUE, FALSE,
1279 (FeatureFormPtr) efp,
1280 StdFeatIntEdPartialCallback);
1281 }
1282 efp->pages [LOCATION_PAGE] = s;
1283 Hide (efp->pages [LOCATION_PAGE]);
1284
1285 AlignObjects (ALIGN_CENTER, (HANDLE) efp->pages [ENUM_PAGE],
1286 (HANDLE) efp->pages [COMMON_PAGE], (HANDLE) efp->pages [LOCATION_PAGE],
1287 NULL);
1288 AlignObjects (ALIGN_CENTER, (HANDLE) efp->foldertabs, (HANDLE) h, NULL);
1289
1290 c = HiddenGroup (w, 2, 0, NULL);
1291 b = PushButton (c, "Accept", StdFeatFormAcceptButtonProc);
1292 SetObjectExtra (b, efp, NULL);
1293 PushButton (c, "Cancel", StdCancelButtonProc);
1294 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
1295 RealizeWindow (w);
1296
1297 SendMessageToDialog (efp->data, VIB_MSG_INIT);
1298 SendMessageToDialog (efp->location, VIB_MSG_INIT);
1299 Show (efp->pages [efp->currentPage]);
1300 SendMessageToDialog (efp->data, VIB_MSG_ENTER);
1301 Update ();
1302 }
1303 return (ForM) w;
1304 }
1305
EnumGenFunc(Pointer data)1306 extern Int2 LIBCALLBACK EnumGenFunc (Pointer data)
1307
1308 {
1309 EnumFormPtr efp;
1310 HelpMessageFunc helpfunc;
1311 OMProcControlPtr ompcp;
1312 OMUserDataPtr omudp;
1313 ObjMgrProcPtr proc;
1314 SeqEntryPtr sep;
1315 SeqFeatPtr sfp;
1316 Uint2 subtype;
1317 WindoW w;
1318
1319 ompcp = (OMProcControlPtr) data;
1320 w = NULL;
1321 sfp = NULL;
1322 sep = NULL;
1323 subtype = 0;
1324 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
1325 proc = ompcp->proc;
1326 switch (ompcp->input_itemtype)
1327 {
1328 case OBJ_SEQFEAT :
1329 sfp = (SeqFeatPtr) ompcp->input_data;
1330 if (sfp != NULL &&
1331 (sfp->data.choice != SEQFEAT_BOND &&
1332 sfp->data.choice != SEQFEAT_SITE &&
1333 sfp->data.choice != SEQFEAT_PSEC_STR)) {
1334 return OM_MSG_RET_ERROR;
1335 }
1336 if (sfp != NULL) {
1337 if (sfp->data.choice == SEQFEAT_BOND) {
1338 subtype = FEATDEF_BOND;
1339 } else if (sfp->data.choice == SEQFEAT_SITE) {
1340 subtype = FEATDEF_SITE;
1341 } else if (sfp->data.choice == SEQFEAT_PSEC_STR) {
1342 subtype = FEATDEF_PSEC_STR;
1343 } else {
1344 return OM_MSG_RET_ERROR;
1345 }
1346 }
1347 break;
1348 case OBJ_BIOSEQ :
1349 break;
1350 case OBJ_BIOSEQSET :
1351 break;
1352 case 0 :
1353 break;
1354 default :
1355 return OM_MSG_RET_ERROR;
1356 }
1357 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
1358 ompcp->input_itemtype, ompcp->proc->procid);
1359 if (omudp != NULL) {
1360 efp = (EnumFormPtr) omudp->userdata.ptrvalue;
1361 if (efp != NULL) {
1362 Select (efp->form);
1363 }
1364 return OM_MSG_RET_DONE;
1365 }
1366 sep = GetTopSeqEntryForEntityID (ompcp->input_entityID);
1367 if (sfp == NULL) {
1368 subtype = proc->subinputtype;
1369 }
1370 if (subtype == FEATDEF_BOND) {
1371 w = (WindoW) CreateEnumForm (-50, -33, "Bond",
1372 sfp, sep, subtype,
1373 StdFeatFormActnProc);
1374 } else if (subtype == FEATDEF_SITE) {
1375 w = (WindoW) CreateEnumForm (-50, -33, "Site",
1376 sfp, sep, subtype,
1377 StdFeatFormActnProc);
1378 } else if (subtype == FEATDEF_PSEC_STR) {
1379 w = (WindoW) CreateEnumForm (-50, -33, "Secondary Structure",
1380 sfp, sep, subtype,
1381 StdFeatFormActnProc);
1382 } else {
1383 return OM_MSG_RET_ERROR;
1384 }
1385 efp = (EnumFormPtr) GetObjectExtra (w);
1386 if (efp != NULL) {
1387 efp->input_entityID = ompcp->input_entityID;
1388 efp->input_itemID = ompcp->input_itemID;
1389 efp->input_itemtype = ompcp->input_itemtype;
1390 efp->this_itemtype = OBJ_SEQFEAT;
1391 efp->this_subtype = subtype;
1392 efp->procid = ompcp->proc->procid;
1393 efp->proctype = ompcp->proc->proctype;
1394 efp->userkey = OMGetNextUserKey ();
1395 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
1396 OMPROC_EDIT, efp->userkey);
1397 if (omudp != NULL) {
1398 omudp->userdata.ptrvalue = (Pointer) efp;
1399 omudp->messagefunc = StdVibrantEditorMsgFunc;
1400 }
1401
1402 SendMessageToForm (efp->form, VIB_MSG_INIT);
1403 if (sfp != NULL) {
1404 PointerToForm (efp->form, (Pointer) sfp);
1405 SetClosestParentIfDuplicating ((BaseFormPtr) efp);
1406 } else {
1407 SetNewFeatureDefaultInterval ((FeatureFormPtr) efp);
1408 }
1409 }
1410 Show (w);
1411 Select (w);
1412 helpfunc = (HelpMessageFunc) GetAppProperty ("HelpMessageProc");
1413 if (helpfunc != NULL) {
1414 if (subtype == FEATDEF_BOND) {
1415 helpfunc ("Features", "Bond");
1416 } else if (subtype == FEATDEF_SITE) {
1417 helpfunc ("Features", "Site");
1418 } else if (subtype == FEATDEF_PSEC_STR) {
1419 helpfunc ("Features", "Secondary Structure");
1420 }
1421 }
1422 return OM_MSG_RET_DONE;
1423 }
1424
1425
1426 typedef struct regionform {
1427 FEATURE_FORM_BLOCK
1428 SeqEntryPtr sep;
1429 GrouP pages [NUM_PAGES];
1430 DialoG foldertabs;
1431 Int2 currentPage;
1432 } RegionForm, PNTR RegionFormPtr;
1433
1434 typedef struct regionpage {
1435 DIALOG_MESSAGE_BLOCK
1436 TexT region;
1437 ButtoN convertToMiscFeat;
1438 RegionFormPtr rfp;
1439 } RegionPage, PNTR RegionPagePtr;
1440
CharPtrToRegionPage(DialoG d,Pointer data)1441 static void CharPtrToRegionPage (DialoG d, Pointer data)
1442
1443 {
1444 RegionFormPtr rfp;
1445 RegionPagePtr rpp;
1446 CharPtr str;
1447
1448 rpp = (RegionPagePtr) GetObjectExtra (d);
1449 str = (CharPtr) data;
1450 if (rpp != NULL) {
1451 rfp = rpp->rfp;
1452 if (rfp->this_subtype == FEATDEF_COMMENT) return;
1453 if (rfp->this_subtype == FEATDEF_misc_feature) return;
1454 if (str != NULL) {
1455 SafeSetTitle (rpp->region, str);
1456 } else {
1457 SafeSetTitle (rpp->region, "");
1458 }
1459 }
1460 }
1461
RegionPageToCharPtr(DialoG d)1462 static Pointer RegionPageToCharPtr (DialoG d)
1463
1464 {
1465 ImpFeatPtr ifp;
1466 RegionFormPtr rfp;
1467 RegionPagePtr rpp;
1468 CharPtr str;
1469
1470 str = NULL;
1471 rpp = (RegionPagePtr) GetObjectExtra (d);
1472 if (rpp != NULL) {
1473 rfp = rpp->rfp;
1474 if (rfp->this_subtype == FEATDEF_misc_feature) {
1475 if (GetStatus (rpp->convertToMiscFeat)) {
1476 ifp = ImpFeatNew ();
1477 if (ifp != NULL) {
1478 ifp->key = StringSave ("misc_feature");
1479 }
1480 return (Pointer) ifp;
1481 } else {
1482 return NULL;
1483 }
1484 }
1485 if (rfp->this_subtype == FEATDEF_COMMENT) return NULL;
1486 str = SaveStringFromText (rpp->region);
1487 if (str == NULL) {
1488 str = StringSave ("");
1489 }
1490 }
1491 return (Pointer) str;
1492 }
1493
CreateRegionDialog(GrouP h,CharPtr title,CharPtr str,Uint2 subtype,RegionFormPtr rfp)1494 static DialoG CreateRegionDialog (GrouP h, CharPtr title, CharPtr str,
1495 Uint2 subtype, RegionFormPtr rfp)
1496
1497 {
1498 GrouP m;
1499 GrouP p;
1500 RegionPagePtr rpp;
1501 GrouP s;
1502
1503 p = HiddenGroup (h, 1, 0, NULL);
1504 SetGroupSpacing (p, 10, 10);
1505
1506 rpp = (RegionPagePtr) MemNew (sizeof (RegionPage));
1507 if (rpp != NULL) {
1508
1509 SetObjectExtra (p, rpp, StdCleanupExtraProc);
1510 rpp->dialog = (DialoG) p;
1511 rpp->todialog = CharPtrToRegionPage;
1512 rpp->fromdialog = RegionPageToCharPtr;
1513 rpp->testdialog = NULL;
1514
1515 rpp->rfp = rfp;
1516
1517 if (title != NULL && title [0] != '\0') {
1518 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
1519 } else {
1520 s = HiddenGroup (p, 0, -2, NULL);
1521 }
1522 m = HiddenGroup (s, 2, 0, NULL);
1523
1524 if (subtype == FEATDEF_REGION) {
1525 StaticPrompt (m, "Name", 0, dialogTextHeight, programFont, 'c');
1526 rpp->region = DialogText (m, "", 20, NULL);
1527 } else if (subtype == FEATDEF_COMMENT) {
1528 StaticPrompt (m, "Enter comment in Properties page", 0, 0, programFont, 'c');
1529 }
1530 if (GetAppProperty ("InternalNcbiSequin") != NULL) {
1531 rpp->convertToMiscFeat = CheckBox (p, "Convert to misc_feat", NULL);
1532 AlignObjects (ALIGN_CENTER, (HANDLE) s, (HANDLE) rpp->convertToMiscFeat, NULL);
1533 }
1534 }
1535
1536 return (DialoG) p;
1537 }
1538
SetRegionImportExportItems(RegionFormPtr rfp)1539 static void SetRegionImportExportItems (RegionFormPtr rfp)
1540
1541 {
1542 IteM exportItm;
1543 IteM importItm;
1544
1545 if (rfp != NULL) {
1546 importItm = FindFormMenuItem ((BaseFormPtr) rfp, VIB_MSG_IMPORT);
1547 exportItm = FindFormMenuItem ((BaseFormPtr) rfp, VIB_MSG_EXPORT);
1548 switch (rfp->currentPage) {
1549 case REGION_PAGE :
1550 SafeSetTitle (importItm, "Import...");
1551 SafeSetTitle (exportItm, "Export...");
1552 SafeDisable (importItm);
1553 SafeDisable (exportItm);
1554 break;
1555 case COMMON_PAGE :
1556 SafeSetTitle (importItm, "Import...");
1557 SafeSetTitle (exportItm, "Export...");
1558 SafeDisable (importItm);
1559 SafeDisable (exportItm);
1560 break;
1561 case LOCATION_PAGE :
1562 SafeSetTitle (importItm, "Import SeqLoc...");
1563 SafeSetTitle (exportItm, "Export SeqLoc...");
1564 SafeEnable (importItm);
1565 SafeEnable (exportItm);
1566 break;
1567 default :
1568 break;
1569 }
1570 }
1571 }
1572
ChangeRegionPage(VoidPtr data,Int2 newval,Int2 oldval)1573 static void ChangeRegionPage (VoidPtr data, Int2 newval, Int2 oldval)
1574
1575 {
1576 RegionFormPtr rfp;
1577
1578 rfp = (RegionFormPtr) data;
1579 if (rfp != NULL) {
1580 rfp->currentPage = newval;
1581 SafeHide (rfp->pages [oldval]);
1582 SafeShow (rfp->pages [newval]);
1583 switch (newval) {
1584 case REGION_PAGE :
1585 break;
1586 case COMMON_PAGE :
1587 break;
1588 case LOCATION_PAGE :
1589 SendMessageToDialog (rfp->location, VIB_MSG_ENTER);
1590 break;
1591 default :
1592 break;
1593 }
1594 SetRegionImportExportItems (rfp);
1595 Update ();
1596 }
1597 }
1598
ImportRegionForm(ForM f,CharPtr filename)1599 static Boolean ImportRegionForm (ForM f, CharPtr filename)
1600
1601 {
1602 RegionFormPtr rfp;
1603
1604 rfp = (RegionFormPtr) GetObjectExtra (f);
1605 if (rfp != NULL) {
1606 switch (rfp->currentPage) {
1607 case LOCATION_PAGE :
1608 return ImportDialog (rfp->location, filename);
1609 default :
1610 break;
1611 }
1612 }
1613 return FALSE;
1614 }
1615
ExportRegionForm(ForM f,CharPtr filename)1616 static Boolean ExportRegionForm (ForM f, CharPtr filename)
1617
1618 {
1619 RegionFormPtr rfp;
1620
1621 rfp = (RegionFormPtr) GetObjectExtra (f);
1622 if (rfp != NULL) {
1623 switch (rfp->currentPage) {
1624 case LOCATION_PAGE :
1625 return ExportDialog (rfp->location, filename);
1626 default :
1627 break;
1628 }
1629 }
1630 return FALSE;
1631 }
1632
1633 static CharPtr regionFormTabs [] = {
1634 "Region", "Properties", "Location", NULL
1635 };
1636
1637 static CharPtr commentFormTabs [] = {
1638 "Comment", "Properties", "Location", NULL
1639 };
1640
RegionFormMessage(ForM f,Int2 mssg)1641 static void RegionFormMessage (ForM f, Int2 mssg)
1642
1643 {
1644 RegionFormPtr rfp;
1645
1646 rfp = (RegionFormPtr) GetObjectExtra (f);
1647 if (rfp != NULL) {
1648 switch (mssg) {
1649 case VIB_MSG_INIT :
1650 StdInitFeatFormProc (f);
1651 break;
1652 case VIB_MSG_IMPORT :
1653 ImportRegionForm (f, NULL);
1654 break;
1655 case VIB_MSG_EXPORT :
1656 ExportRegionForm (f, NULL);
1657 break;
1658 case VIB_MSG_CLOSE :
1659 Remove (f);
1660 break;
1661 case VIB_MSG_CUT :
1662 StdCutTextProc (NULL);
1663 break;
1664 case VIB_MSG_COPY :
1665 StdCopyTextProc (NULL);
1666 break;
1667 case VIB_MSG_PASTE :
1668 StdPasteTextProc (NULL);
1669 break;
1670 case VIB_MSG_DELETE :
1671 if (rfp->currentPage == LOCATION_PAGE) {
1672 PointerToDialog (rfp->location, NULL);
1673 } else {
1674 StdDeleteTextProc (NULL);
1675 }
1676 break;
1677 default :
1678 if (rfp->appmessage != NULL) {
1679 rfp->appmessage (f, mssg);
1680 }
1681 break;
1682 }
1683 }
1684 }
1685
RegionFormActivate(WindoW w)1686 static void RegionFormActivate (WindoW w)
1687
1688 {
1689 RegionFormPtr rfp;
1690
1691 rfp = (RegionFormPtr) GetObjectExtra (w);
1692 if (rfp != NULL) {
1693 if (rfp->activate != NULL) {
1694 rfp->activate (w);
1695 }
1696 SetRegionImportExportItems (rfp);
1697 }
1698 }
1699
CreateRegionOrCommentForm(Int2 left,Int2 top,CharPtr title,SeqFeatPtr sfp,SeqEntryPtr sep,Uint2 subtype,FormActnFunc actproc)1700 extern ForM CreateRegionOrCommentForm (Int2 left, Int2 top, CharPtr title,
1701 SeqFeatPtr sfp, SeqEntryPtr sep,
1702 Uint2 subtype, FormActnFunc actproc)
1703
1704 {
1705 ButtoN b;
1706 GrouP c;
1707 GrouP g;
1708 GrouP h;
1709 RegionFormPtr rfp;
1710 GrouP s;
1711 StdEditorProcsPtr sepp;
1712 CharPtr str;
1713 WindoW w;
1714
1715 w = NULL;
1716 rfp = (RegionFormPtr) MemNew (sizeof (RegionForm));
1717 if (rfp != NULL) {
1718 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
1719 SetObjectExtra (w, rfp, StdFeatFormCleanupProc);
1720 rfp->form = (ForM) w;
1721 rfp->actproc = actproc;
1722 rfp->toform = StdSeqFeatPtrToFeatFormProc;
1723 rfp->fromform = NULL;
1724 rfp->formmessage = RegionFormMessage;
1725 rfp->testform = NULL;
1726 rfp->importform = ImportRegionForm;
1727 rfp->exportform = ExportRegionForm;
1728
1729 #ifndef WIN_MAC
1730 CreateStdEditorFormMenus (w);
1731 #endif
1732
1733 rfp->activate = NULL;
1734 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
1735 if (sepp != NULL) {
1736 rfp->activate = sepp->activateForm;
1737 rfp->appmessage = sepp->handleMessages;
1738 }
1739 SetActivate (w, RegionFormActivate);
1740
1741 g = HiddenGroup (w, -1, 0, NULL);
1742 SetGroupSpacing (g, 3, 10);
1743
1744 rfp->sep = sep;
1745 if (subtype == FEATDEF_REGION) {
1746 rfp->foldertabs = CreateFolderTabs (g, regionFormTabs, REGION_PAGE,
1747 0, 0, SYSTEM_FOLDER_TAB,
1748 ChangeRegionPage, (Pointer) rfp);
1749 } else if (subtype == FEATDEF_COMMENT) {
1750 rfp->foldertabs = CreateFolderTabs (g, commentFormTabs, REGION_PAGE,
1751 0, 0, SYSTEM_FOLDER_TAB,
1752 ChangeRegionPage, (Pointer) rfp);
1753 } else {
1754 Message (MSG_FATAL, "Region or Comment Feature error");
1755 }
1756 rfp->currentPage = REGION_PAGE;
1757
1758 h = HiddenGroup (g, 0, 0, NULL);
1759
1760 s = HiddenGroup (h, -1, 0, NULL);
1761 str = NULL;
1762 if (sfp != NULL && sfp->data.choice == SEQFEAT_REGION) {
1763 str = sfp->data.value.ptrvalue;
1764 }
1765 rfp->data = CreateRegionDialog (s, NULL, str, subtype, rfp);
1766 /*
1767 if (subtype == FEATDEF_COMMENT) {
1768 rfp->data = NULL;
1769 }
1770 */
1771 rfp->pages [REGION_PAGE] = s;
1772 Hide (rfp->pages [REGION_PAGE]);
1773
1774 s = HiddenGroup (h, -1, 0, NULL);
1775 CreateCommonFeatureGroup (s, (FeatureFormPtr) rfp, sfp, TRUE, TRUE);
1776 rfp->pages [COMMON_PAGE] = s;
1777 Hide (rfp->pages [COMMON_PAGE]);
1778
1779 s = HiddenGroup (h, -1, 0, NULL);
1780 rfp->location = CreateIntervalEditorDialogEx (s, NULL, 4, 2, sep, TRUE, TRUE,
1781 TRUE, TRUE, FALSE,
1782 (FeatureFormPtr) rfp,
1783 StdFeatIntEdPartialCallback);
1784 rfp->pages [LOCATION_PAGE] = s;
1785 Hide (rfp->pages [LOCATION_PAGE]);
1786
1787 AlignObjects (ALIGN_CENTER, (HANDLE) rfp->pages [REGION_PAGE],
1788 (HANDLE) rfp->pages [COMMON_PAGE], (HANDLE) rfp->pages [LOCATION_PAGE],
1789 NULL);
1790 AlignObjects (ALIGN_CENTER, (HANDLE) rfp->foldertabs, (HANDLE) h, NULL);
1791
1792 c = HiddenGroup (w, 2, 0, NULL);
1793 b = PushButton (c, "Accept", StdFeatFormAcceptButtonProc);
1794 SetObjectExtra (b, rfp, NULL);
1795 PushButton (c, "Cancel", StdCancelButtonProc);
1796 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
1797 RealizeWindow (w);
1798
1799 SendMessageToDialog (rfp->data, VIB_MSG_INIT);
1800 SendMessageToDialog (rfp->location, VIB_MSG_INIT);
1801 Show (rfp->pages [rfp->currentPage]);
1802 SendMessageToDialog (rfp->data, VIB_MSG_ENTER);
1803 Update ();
1804 }
1805 return (ForM) w;
1806 }
1807
CopyRegionNameToComment(RegionPagePtr rpp,RegionFormPtr rfp)1808 static void CopyRegionNameToComment (RegionPagePtr rpp, RegionFormPtr rfp)
1809 {
1810 CharPtr old_comment = NULL;
1811 CharPtr region_name = NULL;
1812 CharPtr new_comment = NULL;
1813 Int4 new_comment_len;
1814
1815 if (rpp == NULL || rfp == NULL)
1816 {
1817 return;
1818 }
1819
1820 region_name = SaveStringFromText (rpp->region);
1821 if (StringHasNoText (region_name))
1822 {
1823 region_name = MemFree (region_name);
1824 }
1825 else
1826 {
1827 old_comment = SaveStringFromText (rfp->comment);
1828 if (StringHasNoText (old_comment))
1829 {
1830 SetTitle (rfp->comment, region_name);
1831 }
1832 else
1833 {
1834 new_comment_len = StringLen (region_name) + StringLen (old_comment) + 3;
1835 new_comment = (CharPtr) MemNew (new_comment_len * sizeof (Char));
1836 if (new_comment != NULL)
1837 {
1838 StringCpy (new_comment, region_name);
1839 StringCat (new_comment, "; ");
1840 StringCat (new_comment, old_comment);
1841 SetTitle (rfp->comment, new_comment);
1842 }
1843 region_name = MemFree (region_name);
1844 }
1845 old_comment = MemFree (old_comment);
1846 }
1847 }
1848
MoveToNucSequence(RegionFormPtr rfp)1849 static void MoveToNucSequence (RegionFormPtr rfp)
1850 {
1851 SeqLocPtr slp;
1852 BioseqPtr bsp;
1853 ValNodePtr prods, vnp;
1854 SeqFeatPtr cds = NULL;
1855 SeqLocPtr new_location;
1856
1857 if (rfp == NULL) return;
1858
1859 slp = DialogToPointer (rfp->location);
1860 bsp = BioseqFindFromSeqLoc (slp);
1861 if (bsp != NULL && ISA_aa (bsp->mol))
1862 {
1863 prods = SeqMgrGetSfpProductList (bsp);
1864 for (vnp = prods; vnp != NULL && cds == NULL; vnp = vnp->next)
1865 {
1866 cds = (SeqFeatPtr) vnp->data.ptrvalue;
1867 if (cds == NULL) continue;
1868 if (cds->data.choice != SEQFEAT_CDREGION)
1869 {
1870 cds = NULL;
1871 }
1872 }
1873 if (cds != NULL)
1874 {
1875 new_location = aaLoc_to_dnaLoc (cds, slp);
1876 PointerToDialog (rfp->location, new_location);
1877 SeqLocFree (new_location);
1878 }
1879 }
1880 SeqLocFree (slp);
1881 }
1882
RegionOrCommentFeatFormActnProc(ForM f)1883 static void RegionOrCommentFeatFormActnProc (ForM f)
1884
1885 {
1886 RegionFormPtr rfp;
1887 RegionPagePtr rpp;
1888
1889 rfp = (RegionFormPtr) GetObjectExtra (f);
1890 if (rfp != NULL) {
1891 rpp = (RegionPagePtr) GetObjectExtra (rfp->data);
1892 if (rpp != NULL && GetStatus (rpp->convertToMiscFeat)) {
1893 rfp->this_subtype = FEATDEF_misc_feature;
1894 CopyRegionNameToComment (rpp, rfp);
1895 /* move feature to nucleotide sequence if on protein sequence */
1896 MoveToNucSequence (rfp);
1897 }
1898 }
1899 if (FeatFormReplaceWithoutUpdateProc (f)) {
1900 if (rfp != NULL) {
1901 GetRidOfEmptyFeatsDescStrings (rfp->input_entityID, NULL);
1902 if (GetAppProperty ("InternalNcbiSequin") != NULL) {
1903 ExtendGeneFeatIfOnMRNA (rfp->input_entityID, NULL);
1904 }
1905 ObjMgrSendMsg (OM_MSG_UPDATE, rfp->input_entityID,
1906 rfp->input_itemID, rfp->input_itemtype);
1907 }
1908 }
1909 }
1910
RegionOrCommentGenFunc(Pointer data)1911 extern Int2 LIBCALLBACK RegionOrCommentGenFunc (Pointer data)
1912
1913 {
1914 OMProcControlPtr ompcp;
1915 OMUserDataPtr omudp;
1916 ObjMgrProcPtr proc;
1917 RegionFormPtr rfp;
1918 SeqEntryPtr sep;
1919 SeqFeatPtr sfp;
1920 Uint2 subtype;
1921 CharPtr title;
1922 WindoW w;
1923
1924 ompcp = (OMProcControlPtr) data;
1925 sfp = NULL;
1926 sep = NULL;
1927 subtype = 0;
1928 title = NULL;
1929 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
1930 proc = ompcp->proc;
1931 switch (ompcp->input_itemtype) {
1932 case OBJ_SEQFEAT :
1933 sfp = (SeqFeatPtr) ompcp->input_data;
1934 if (sfp != NULL &&
1935 (sfp->data.choice != SEQFEAT_REGION &&
1936 sfp->data.choice != SEQFEAT_COMMENT)) {
1937 return OM_MSG_RET_ERROR;
1938 }
1939 break;
1940 case OBJ_BIOSEQ :
1941 break;
1942 case OBJ_BIOSEQSET :
1943 break;
1944 case 0 :
1945 break;
1946 default :
1947 return OM_MSG_RET_ERROR;
1948 }
1949 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
1950 ompcp->input_itemtype, ompcp->proc->procid);
1951 if (omudp != NULL) {
1952 rfp = (RegionFormPtr) omudp->userdata.ptrvalue;
1953 if (rfp != NULL) {
1954 Select (rfp->form);
1955 }
1956 return OM_MSG_RET_DONE;
1957 }
1958 if (sfp != NULL) {
1959 if (sfp->data.choice == SEQFEAT_REGION) {
1960 subtype = FEATDEF_REGION;
1961 } else if (sfp->data.choice == SEQFEAT_COMMENT) {
1962 subtype = FEATDEF_COMMENT;
1963 }
1964 } else if (proc->subinputtype > 0) {
1965 subtype = proc->subinputtype;
1966 }
1967 if (subtype == FEATDEF_REGION) {
1968 title = "Region";
1969 } else if (subtype == FEATDEF_COMMENT) {
1970 title = "Comment";
1971 } else {
1972 return OM_MSG_RET_ERROR;
1973 }
1974 sep = GetTopSeqEntryForEntityID (ompcp->input_entityID);
1975 w = (WindoW) CreateRegionOrCommentForm (-50, -33, title, sfp, sep,
1976 subtype, RegionOrCommentFeatFormActnProc);
1977 rfp = (RegionFormPtr) GetObjectExtra (w);
1978 if (rfp != NULL) {
1979 rfp->input_entityID = ompcp->input_entityID;
1980 rfp->input_itemID = ompcp->input_itemID;
1981 rfp->input_itemtype = ompcp->input_itemtype;
1982 rfp->this_itemtype = OBJ_SEQFEAT;
1983 rfp->this_subtype = subtype;
1984 rfp->procid = ompcp->proc->procid;
1985 rfp->proctype = ompcp->proc->proctype;
1986 rfp->userkey = OMGetNextUserKey ();
1987 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
1988 OMPROC_EDIT, rfp->userkey);
1989 if (omudp != NULL) {
1990 omudp->userdata.ptrvalue = (Pointer) rfp;
1991 omudp->messagefunc = StdVibrantEditorMsgFunc;
1992 }
1993 SendMessageToForm (rfp->form, VIB_MSG_INIT);
1994 if (sfp != NULL) {
1995 PointerToForm (rfp->form, (Pointer) sfp);
1996 SetClosestParentIfDuplicating ((BaseFormPtr) rfp);
1997 } else {
1998 SetNewFeatureDefaultInterval ((FeatureFormPtr) rfp);
1999 }
2000 }
2001 Show (w);
2002 Select (w);
2003 return OM_MSG_RET_DONE;
2004 }
2005
2006
2007 typedef struct molinfopage {
2008 DIALOG_MESSAGE_BLOCK
2009 PopuP moltype;
2010 PopuP technique;
2011 PopuP complete;
2012 GrouP expGrp;
2013 TexT explain;
2014 EnumFieldAssoc PNTR moltypeAlist;
2015 EnumFieldAssoc PNTR techniqueAlist;
2016 EnumFieldAssoc PNTR completeAlist;
2017 } MolInfoPage, PNTR MolInfoPagePtr;
2018
2019 typedef struct molinfoform {
2020 DESCRIPTOR_FORM_BLOCK
2021 PopuP molPopup;
2022 PopuP topologyPopup;
2023 PopuP strandPopup;
2024 } MolInfoForm, PNTR MolInfoFormPtr;
2025
ENUM_ALIST(molinfo_biomol_alist)2026 static ENUM_ALIST(molinfo_biomol_alist)
2027 {" ", 0},
2028 {"Genomic DNA or RNA", 1},
2029 {"Precursor RNA", 2},
2030 {"mRNA [cDNA]", 3},
2031 {"Ribosomal RNA", 4},
2032 {"Transfer RNA", 5},
2033 {"Small nuclear RNA", 6},
2034 {"Small cytoplasmic RNA", 7},
2035 {"Peptide", 8},
2036 {"Other-Genetic", 9},
2037 {"Genomic-mRNA", 10},
2038 {"cRNA", 11},
2039 {"Small nucleolar RNA", 12},
2040 {"Transcribed RNA", 13},
2041 {"Non-coding RNA", 14},
2042 {"Transfer-messenger RNA", 15},
2043 {"Other", 255},
2044 END_ENUM_ALIST
2045
2046 extern CharPtr GetMoleculeTypeName (Uint1 mol_val)
2047 {
2048 Int4 i;
2049 for (i = 0; i < sizeof (molinfo_biomol_alist) / sizeof (EnumFieldAssoc); i++) {
2050 if (molinfo_biomol_alist[i].value == mol_val) {
2051 return molinfo_biomol_alist[i].name;
2052 }
2053 }
2054 return NULL;
2055 }
2056
2057
ENUM_ALIST(molinfo_biomol_nuc_alist)2058 static ENUM_ALIST(molinfo_biomol_nuc_alist)
2059 {" ", 0},
2060 {"Genomic DNA or RNA", 1},
2061 {"Precursor RNA", 2},
2062 {"mRNA [cDNA]", 3},
2063 {"Ribosomal RNA", 4},
2064 {"Transfer RNA", 5},
2065 {"Small nuclear RNA", 6},
2066 {"Small cytoplasmic RNA", 7},
2067 {"Other-Genetic", 9},
2068 {"Genomic-mRNA", 10},
2069 {"cRNA", 11},
2070 {"Small nucleolar RNA", 12},
2071 {"Transcribed RNA", 13},
2072 {"Non-coding RNA", 14},
2073 {"Transfer-messenger RNA", 15},
2074 {"Other", 255},
2075 END_ENUM_ALIST
2076
2077 static ENUM_ALIST(molinfo_biomol_nucX_alist)
2078 {" ", 0},
2079 {"Genomic DNA", 253},
2080 {"Genomic RNA", 254},
2081 {"Precursor RNA", 2},
2082 {"mRNA [cDNA]", 3},
2083 {"Ribosomal RNA", 4},
2084 {"Transfer RNA", 5},
2085 {"Small nuclear RNA", 6},
2086 {"Small cytoplasmic RNA", 7},
2087 {"Other-Genetic", 9},
2088 {"Genomic-mRNA", 10},
2089 {"cRNA", 11},
2090 {"Small nucleolar RNA", 12},
2091 {"Transcribed RNA", 13},
2092 {"Non-coding RNA", 14},
2093 {"Transfer-messenger RNA", 15},
2094 {"Other", 255},
2095 END_ENUM_ALIST
2096
2097 static ENUM_ALIST(molinfo_biomol_prot_alist)
2098 {" ", 0},
2099 {"Peptide", 8},
2100 {"Other", 255},
2101 END_ENUM_ALIST
2102
2103 static ENUM_ALIST(molinfo_tech_alist)
2104 {" ", 0},
2105 {"Standard", 1},
2106 {"EST", 2},
2107 {"STS", 3},
2108 {"Survey", 4},
2109 {"Genetic Map", 5},
2110 {"Physical Map", 6},
2111 {"Derived", 7},
2112 {"Concept-Trans", 8},
2113 {"Seq-Pept", 9},
2114 {"Both", 10},
2115 {"Seq-Pept-Overlap", 11},
2116 {"Seq-Pept-Homol", 12},
2117 {"Concept-Trans-A", 13},
2118 {"HTGS 0", 18},
2119 {"HTGS 1", 14},
2120 {"HTGS 2", 15},
2121 {"HTGS 3", 16},
2122 {"FLI_cDNA", 17},
2123 {"HTC", 19},
2124 {"WGS", 20},
2125 {"Barcode", 21},
2126 {"Composite-WGS-HTGS", 22},
2127 {"TSA", 23},
2128 {"Targeted", 24},
2129 {"Other:", 255},
2130 END_ENUM_ALIST
2131
2132 static ENUM_ALIST(molinfo_tech_nuc_alist)
2133 {" ", 0},
2134 {"Standard", 1},
2135 {"EST", 2},
2136 {"STS", 3},
2137 {"Survey", 4},
2138 {"Genetic Map", 5},
2139 {"Physical Map", 6},
2140 {"Derived", 7},
2141 {"HTGS 0", 18},
2142 {"HTGS 1", 14},
2143 {"HTGS 2", 15},
2144 {"HTGS 3", 16},
2145 {"FLI_cDNA", 17},
2146 {"HTC", 19},
2147 {"WGS", 20},
2148 {"Barcode", 21},
2149 {"Composite-WGS-HTGS", 22},
2150 {"TSA", 23},
2151 {"Targeted", 24},
2152 {"Other:", 255},
2153 END_ENUM_ALIST
2154
2155 static ENUM_ALIST(molinfo_tech_prot_alist)
2156 {" ", 0},
2157 {"Concept-Trans", 8},
2158 {"Seq-Pept", 9},
2159 {"Both", 10},
2160 {"Seq-Pept-Overlap", 11},
2161 {"Seq-Pept-Homol", 12},
2162 {"Concept-Trans-A", 13},
2163 {"Other:", 255},
2164 END_ENUM_ALIST
2165
2166 static ENUM_ALIST(molinfo_complete_alist)
2167 {" ", 0},
2168 {"Complete", 1},
2169 {"Partial", 2},
2170 {"No Left", 3},
2171 {"No Right", 4},
2172 {"No Ends", 5},
2173 {"Has Left", 6},
2174 {"Has Right", 7},
2175 {"Other", 255},
2176 END_ENUM_ALIST
2177
2178 static ENUM_ALIST(molinfo_complete_nuc_alist)
2179 {" ", 0},
2180 {"Complete", 1},
2181 {"Partial", 2},
2182 {"No 5'", 3},
2183 {"No 3'", 4},
2184 {"No Ends", 5},
2185 {"Has 5'", 6},
2186 {"Has 3'", 7},
2187 {"Other", 255},
2188 END_ENUM_ALIST
2189
2190 static ENUM_ALIST(molinfo_complete_prot_alist)
2191 {" ", 0},
2192 {"Complete", 1},
2193 {"Partial", 2},
2194 {"No NH3", 3},
2195 {"No CO2", 4},
2196 {"No Ends", 5},
2197 {"Has NH3", 6},
2198 {"Has CO2", 7},
2199 {"Other", 255},
2200 END_ENUM_ALIST
2201
2202 static Uint1 check_biomol (Uint1 biomol)
2203
2204 {
2205 if (biomol > MOLECULE_TYPE_TMRNA && biomol < 253) return 0;
2206 return biomol;
2207 }
2208
check_technique(Uint1 tech)2209 static Uint1 check_technique (Uint1 tech)
2210
2211 {
2212 if (tech > MI_TECH_targeted && tech != MI_TECH_other) return 0;
2213 return tech;
2214 }
2215
check_complete(Uint1 completeness)2216 static Uint1 check_complete (Uint1 completeness)
2217
2218 {
2219 if (completeness > 7 && completeness != 255) return 0;
2220 return completeness;
2221 }
2222
MolInfoPtrToMolInfoPage(DialoG d,Pointer data)2223 static void MolInfoPtrToMolInfoPage (DialoG d, Pointer data)
2224
2225 {
2226 MolInfoPtr mip;
2227 MolInfoPagePtr mpp;
2228
2229 mpp = (MolInfoPagePtr) GetObjectExtra (d);
2230 mip = (MolInfoPtr) data;
2231 if (mpp != NULL) {
2232 SetEnumPopup (mpp->moltype, mpp->moltypeAlist,
2233 (UIEnum) check_biomol (mip->biomol));
2234 SetEnumPopup (mpp->technique, mpp->techniqueAlist,
2235 (UIEnum) check_technique (mip->tech));
2236 SetEnumPopup (mpp->complete, mpp->completeAlist,
2237 (UIEnum) check_complete (mip->completeness));
2238 SetTitle (mpp->explain, mip->techexp);
2239 if (mip->tech == 255) {
2240 SafeShow (mpp->expGrp);
2241 } else {
2242 SafeHide (mpp->expGrp);
2243 }
2244 }
2245 }
2246
MolInfoPageToMolInfoPtr(DialoG d)2247 static Pointer MolInfoPageToMolInfoPtr (DialoG d)
2248
2249 {
2250 MolInfoPtr mip;
2251 MolInfoPagePtr mpp;
2252 UIEnum val;
2253
2254 mip = NULL;
2255 mpp = (MolInfoPagePtr) GetObjectExtra (d);
2256 if (mpp != NULL) {
2257 mip = MolInfoNew ();
2258 if (mip != NULL) {
2259 if (GetEnumPopup (mpp->moltype, mpp->moltypeAlist, &val)) {
2260 mip->biomol = (Uint1) val;
2261 }
2262 if (GetEnumPopup (mpp->technique, mpp->techniqueAlist, &val)) {
2263 mip->tech = (Uint1) val;
2264 }
2265 if (GetEnumPopup (mpp->complete, mpp->completeAlist, &val)) {
2266 mip->completeness = (Uint1) val;
2267 }
2268 if (mip->tech == 255) {
2269 mip->techexp = SaveStringFromText (mpp->explain);
2270 }
2271 }
2272 }
2273 return (Pointer) mip;
2274 }
2275
ChangeTech(PopuP p)2276 static void ChangeTech (PopuP p)
2277
2278 {
2279 MolInfoPagePtr mpp;
2280 UIEnum val;
2281
2282 mpp = (MolInfoPagePtr) GetObjectExtra (p);
2283 if (mpp != NULL) {
2284 if (GetEnumPopup (mpp->technique, mpp->techniqueAlist, &val)) {
2285 if (val == 255) {
2286 SafeShow (mpp->expGrp);
2287 } else {
2288 SafeHide (mpp->expGrp);
2289 }
2290 }
2291 }
2292 }
2293
2294 static CharPtr labels [] = {
2295 "Molecule", "Technique", NULL
2296 };
2297
CreateMolInfoDialog(GrouP h,CharPtr title,Uint1 biomol,Uint1 tech,Boolean showComplete,Boolean nucsOK,Boolean protsOK,Boolean separateGenomicDNAandRNA)2298 extern DialoG CreateMolInfoDialog (GrouP h, CharPtr title, Uint1 biomol, Uint1 tech,
2299 Boolean showComplete, Boolean nucsOK, Boolean protsOK,
2300 Boolean separateGenomicDNAandRNA)
2301
2302 {
2303 GrouP f;
2304 GrouP m;
2305 MolInfoPagePtr mpp;
2306 GrouP p;
2307 GrouP s;
2308 Int2 wid;
2309 GrouP x;
2310
2311 p = HiddenGroup (h, 1, 0, NULL);
2312 SetGroupSpacing (p, 10, 10);
2313
2314 mpp = (MolInfoPagePtr) MemNew (sizeof (MolInfoPage));
2315 if (mpp != NULL) {
2316
2317 SetObjectExtra (p, mpp, StdCleanupExtraProc);
2318 mpp->dialog = (DialoG) p;
2319 mpp->todialog = MolInfoPtrToMolInfoPage;
2320 mpp->fromdialog = MolInfoPageToMolInfoPtr;
2321 mpp->testdialog = NULL;
2322
2323 if (title != NULL && title [0] != '\0') {
2324 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
2325 } else {
2326 s = HiddenGroup (p, 0, -2, NULL);
2327 }
2328 m = HiddenGroup (s, -1, 0, NULL);
2329 /*
2330 SetGroupSpacing (m, 10, 10);
2331 */
2332
2333 if (showComplete) {
2334 f = HiddenGroup (m, -3, 0, NULL);
2335 } else {
2336 f = HiddenGroup (m, -2, 0, NULL);
2337 }
2338
2339 SelectFont (programFont);
2340 wid = MaxStringWidths (labels);
2341
2342 if (nucsOK && protsOK) {
2343 mpp->moltypeAlist = molinfo_biomol_alist;
2344 mpp->techniqueAlist = molinfo_tech_alist;
2345 mpp->completeAlist = molinfo_complete_alist;
2346 } else if (nucsOK) {
2347 if (separateGenomicDNAandRNA) {
2348 mpp->moltypeAlist = molinfo_biomol_nucX_alist;
2349 mpp->techniqueAlist = molinfo_tech_nuc_alist;
2350 mpp->completeAlist = molinfo_complete_nuc_alist;
2351 } else {
2352 mpp->moltypeAlist = molinfo_biomol_nuc_alist;
2353 mpp->techniqueAlist = molinfo_tech_nuc_alist;
2354 mpp->completeAlist = molinfo_complete_nuc_alist;
2355 }
2356 } else if (protsOK) {
2357 mpp->moltypeAlist = molinfo_biomol_prot_alist;
2358 mpp->techniqueAlist = molinfo_tech_prot_alist;
2359 mpp->completeAlist = molinfo_complete_prot_alist;
2360 } else {
2361 mpp->moltypeAlist = molinfo_biomol_alist;
2362 mpp->techniqueAlist = molinfo_tech_alist;
2363 mpp->completeAlist = molinfo_complete_alist;
2364 }
2365
2366 StaticPrompt (f, "Molecule",
2367 wid, popupMenuHeight, programFont, 'l');
2368 mpp->moltype = PopupList (f, TRUE, NULL);
2369 SetObjectExtra (mpp->moltype, mpp, NULL);
2370 InitEnumPopup (mpp->moltype, mpp->moltypeAlist, NULL);
2371 SetEnumPopup (mpp->moltype, mpp->moltypeAlist, biomol);
2372
2373 x = NULL;
2374 if (showComplete) {
2375 x = HiddenGroup (f, 2, 0, NULL);
2376 StaticPrompt (x, "Completedness",
2377 0, popupMenuHeight, programFont, 'l');
2378 mpp->complete = PopupList (x, TRUE, NULL);
2379 SetObjectExtra (mpp->complete, mpp, NULL);
2380 InitEnumPopup (mpp->complete, mpp->completeAlist, NULL);
2381 SetEnumPopup (mpp->complete, mpp->completeAlist, 0);
2382 }
2383
2384 StaticPrompt (f, "Technique",
2385 wid, popupMenuHeight, programFont, 'l');
2386 mpp->technique = PopupList (f, TRUE, ChangeTech);
2387 SetObjectExtra (mpp->technique, mpp, NULL);
2388 InitEnumPopup (mpp->technique, mpp->techniqueAlist, NULL);
2389 SetEnumPopup (mpp->technique, mpp->techniqueAlist, 0);
2390 SetEnumPopup (mpp->technique, mpp->techniqueAlist, tech);
2391
2392 mpp->expGrp = HiddenGroup (f, -2, 0, NULL);
2393 SetGroupSpacing (mpp->expGrp, 0, 0);
2394 /*
2395 StaticPrompt (mpp->expGrp, "Explanation",
2396 0, dialogTextHeight, programFont, 'l');
2397 */
2398 mpp->explain = DialogText (mpp->expGrp, "", 10, NULL);
2399 SetObjectExtra (mpp->explain, mpp, NULL);
2400 if (showComplete) {
2401 AlignObjects (ALIGN_LEFT, (HANDLE) mpp->explain,
2402 (HANDLE) x, NULL);
2403 AlignObjects (ALIGN_RIGHT, (HANDLE) mpp->explain,
2404 (HANDLE) mpp->complete, NULL);
2405 AlignObjects (ALIGN_RIGHT, (HANDLE) mpp->explain,
2406 (HANDLE) x, NULL);
2407 } else {
2408 AlignObjects (ALIGN_RIGHT, (HANDLE) mpp->technique,
2409 (HANDLE) mpp->explain, NULL);
2410 AlignObjects (ALIGN_LEFT, (HANDLE) mpp->technique,
2411 (HANDLE) mpp->explain, NULL);
2412 }
2413 Hide (mpp->expGrp);
2414 }
2415
2416 return (DialoG) p;
2417 }
2418
2419 /************ Bioseq field editors ************/
2420
ENUM_ALIST(mol_alist)2421 static ENUM_ALIST(mol_alist)
2422 {" ", 0}, /* Unknown? */
2423 {"DNA", Seq_mol_dna}, /* 1 */
2424 {"RNA", Seq_mol_rna}, /* 2 */
2425 {"Protein", Seq_mol_aa}, /* 3 */
2426 {"Nucleotide", Seq_mol_na}, /* 4 */
2427 {"Other", Seq_mol_other}, /* 255 */
2428 END_ENUM_ALIST
2429
2430 extern CharPtr GetMoleculeClassName (Uint1 mol_val)
2431 {
2432 Int4 i;
2433 for (i = 0; i < sizeof (mol_alist) / sizeof (EnumFieldAssoc); i++) {
2434 if (mol_alist[i].value == mol_val) {
2435 return mol_alist[i].name;
2436 }
2437 }
2438 return NULL;
2439 }
2440
ENUM_ALIST(topology_alist)2441 static ENUM_ALIST(topology_alist)
2442 {" ", 0}, /* Unknown? */
2443 {"Linear", TOPOLOGY_LINEAR}, /* 1 */
2444 {"Circular", TOPOLOGY_CIRCULAR}, /* 2 */
2445 {"Tandem", TOPOLOGY_TANDEM}, /* 3 */
2446 {"Other", 255}, /* Other? */
2447 END_ENUM_ALIST
2448
2449 extern CharPtr GetMoleculeTopologyName (Uint1 mol_val)
2450 {
2451 Int4 i;
2452 for (i = 0; i < sizeof (topology_alist) / sizeof (EnumFieldAssoc); i++) {
2453 if (topology_alist[i].value == mol_val) {
2454 return topology_alist[i].name;
2455 }
2456 }
2457 return NULL;
2458 }
2459
ENUM_ALIST(strand_alist)2460 static ENUM_ALIST(strand_alist)
2461 {" ", Seq_strand_unknown}, /* 0 */
2462 {"Single", Seq_strand_plus}, /* 1 */
2463 {"Double", Seq_strand_minus}, /* 2 */
2464 {"Mixed", Seq_strand_both}, /* 3 */
2465 {"Mixed Rev", Seq_strand_both_rev}, /* 4 */
2466 {"Other", Seq_strand_other}, /* 255 */
2467 END_ENUM_ALIST
2468
2469 static Uint1 check_mol (Uint1 mol)
2470 {
2471 if (mol > Seq_mol_na && mol != Seq_mol_other) return 0;
2472 return mol;
2473 }
2474
check_topology(Uint1 topology)2475 static Uint1 check_topology (Uint1 topology)
2476 {
2477 if (topology > TOPOLOGY_TANDEM && topology != 255) return 0;
2478 return topology;
2479 }
2480
check_strand(Uint1 strand)2481 static Uint1 check_strand (Uint1 strand)
2482 {
2483 /* if (strand == Seq_strand_both_rev) return Seq_strand_other; ??? */
2484 if (strand > Seq_strand_both_rev && strand != Seq_strand_other)
2485 return Seq_strand_unknown;
2486 return strand;
2487 }
2488
UpdateSeqInstGatherFunc(GatherContextPtr gcp)2489 static Boolean UpdateSeqInstGatherFunc (GatherContextPtr gcp)
2490
2491 {
2492 BioseqPtr bsp;
2493 MolInfoFormPtr mfp;
2494 UIEnum val;
2495
2496 if (gcp == NULL) return TRUE;
2497 mfp = (MolInfoFormPtr) gcp->userdata;
2498 if (mfp == NULL) return TRUE;
2499 if (gcp->thistype == OBJ_BIOSEQ && gcp->thisitem != NULL) {
2500 bsp = (BioseqPtr) gcp->thisitem;
2501 if (GetEnumPopup (mfp->molPopup, mol_alist, &val)) {
2502 /* also convert data if switching from na to aa or aa to na */
2503 if (ISA_na (bsp->mol) && ISA_aa (val)) {
2504 BioseqConvert (bsp, Seq_code_ncbieaa);
2505 }
2506 else if (ISA_aa (bsp->mol) && ISA_na (val)) {
2507 BioseqConvert (bsp, Seq_code_ncbi2na);
2508 }
2509 bsp->mol = (Uint1) val;
2510 }
2511 if (GetEnumPopup (mfp->strandPopup, strand_alist, &val)) {
2512 bsp->strand = (Uint1) val;
2513 }
2514 if (GetEnumPopup (mfp->topologyPopup, topology_alist, &val)) {
2515 bsp->topology = (Uint1) val;
2516 }
2517 }
2518 return TRUE;
2519 }
2520
UpdateSeqInstFlags(GatherContextPtr gcp)2521 static Boolean UpdateSeqInstFlags (GatherContextPtr gcp)
2522
2523 {
2524 GatherScope gs;
2525 MolInfoFormPtr mfp;
2526 SeqEntryPtr sep;
2527
2528 if (gcp == NULL || gcp->userdata == NULL) return TRUE;
2529 mfp = (MolInfoFormPtr) gcp->userdata;
2530 if (gcp->parenttype == OBJ_BIOSEQ || gcp->parenttype == OBJ_BIOSEQSET) {
2531 sep = SeqMgrGetSeqEntryForData (gcp->parentitem);
2532 if (sep != NULL) {
2533 MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
2534 gs.seglevels = 1;
2535 gs.scope = sep;
2536 MemSet((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
2537 gs.ignore[OBJ_BIOSEQ] = FALSE;
2538 gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
2539 gs.ignore[OBJ_SEQANNOT] = FALSE;
2540 gs.ignore[OBJ_SEQDESC] = FALSE;
2541 GatherEntity (mfp->input_entityID, (Pointer) mfp, UpdateSeqInstGatherFunc, &gs);
2542 }
2543 }
2544 return TRUE;
2545 }
2546
CollectSeqInstGatherFunc(GatherContextPtr gcp)2547 static Boolean CollectSeqInstGatherFunc (GatherContextPtr gcp)
2548
2549 {
2550 BioseqPtr bsp;
2551 MolInfoFormPtr mfp;
2552
2553 if (gcp == NULL) return TRUE;
2554 mfp = (MolInfoFormPtr) gcp->userdata;
2555 if (mfp == NULL) return TRUE;
2556 if (gcp->thistype == OBJ_BIOSEQ && gcp->thisitem != NULL) {
2557 bsp = (BioseqPtr) gcp->thisitem;
2558 SetEnumPopup (mfp->molPopup, mol_alist,
2559 (UIEnum) check_mol (bsp->mol));
2560 SetEnumPopup (mfp->strandPopup, strand_alist,
2561 (UIEnum) check_strand (bsp->strand));
2562 SetEnumPopup (mfp->topologyPopup, topology_alist,
2563 (UIEnum) check_topology (bsp->topology));
2564 }
2565 return TRUE;
2566 }
2567
CollectSeqInstFlags(GatherContextPtr gcp)2568 static Boolean CollectSeqInstFlags (GatherContextPtr gcp)
2569
2570 {
2571 GatherScope gs;
2572 MolInfoFormPtr mfp;
2573 SeqEntryPtr sep;
2574
2575 if (gcp == NULL || gcp->userdata == NULL) return TRUE;
2576 mfp = (MolInfoFormPtr) gcp->userdata;
2577 if (gcp->parenttype == OBJ_BIOSEQ || gcp->parenttype == OBJ_BIOSEQSET) {
2578 sep = SeqMgrGetSeqEntryForData (gcp->parentitem);
2579 if (sep != NULL) {
2580 MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
2581 gs.seglevels = 1;
2582 gs.scope = sep;
2583 MemSet((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
2584 gs.ignore[OBJ_BIOSEQ] = FALSE;
2585 gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
2586 gs.ignore[OBJ_SEQANNOT] = FALSE;
2587 gs.ignore[OBJ_SEQDESC] = FALSE;
2588 GatherEntity (mfp->input_entityID, (Pointer) mfp, CollectSeqInstGatherFunc, &gs);
2589 }
2590 }
2591 return TRUE;
2592 }
2593
MolInfoDescFormActnProc(ForM f)2594 static void MolInfoDescFormActnProc (ForM f)
2595
2596 {
2597 MolInfoFormPtr mfp;
2598
2599 mfp = (MolInfoFormPtr) GetObjectExtra (f);
2600 if (mfp != NULL) {
2601 DescFormReplaceWithoutUpdateProc (f);
2602 if (mfp->input_itemtype == OBJ_SEQDESC) {
2603 GatherItem (mfp->input_entityID, mfp->input_itemID, mfp->input_itemtype,
2604 (Pointer) mfp, UpdateSeqInstFlags);
2605 }
2606 GetRidOfEmptyFeatsDescStrings (mfp->input_entityID, NULL);
2607 if (GetAppProperty ("InternalNcbiSequin") != NULL) {
2608 ExtendGeneFeatIfOnMRNA (mfp->input_entityID, NULL);
2609 }
2610 ObjMgrSendMsg (OM_MSG_UPDATE, mfp->input_entityID,
2611 mfp->input_itemID, mfp->input_itemtype);
2612 }
2613 }
2614
MolInfoFormMessage(ForM f,Int2 mssg)2615 static void MolInfoFormMessage (ForM f, Int2 mssg)
2616
2617 {
2618 MolInfoFormPtr mfp;
2619
2620 mfp = (MolInfoFormPtr) GetObjectExtra (f);
2621 if (mfp != NULL) {
2622 switch (mssg) {
2623 case VIB_MSG_CLOSE :
2624 Remove (f);
2625 break;
2626 case VIB_MSG_CUT :
2627 StdCutTextProc (NULL);
2628 break;
2629 case VIB_MSG_COPY :
2630 StdCopyTextProc (NULL);
2631 break;
2632 case VIB_MSG_PASTE :
2633 StdPasteTextProc (NULL);
2634 break;
2635 case VIB_MSG_DELETE :
2636 StdDeleteTextProc (NULL);
2637 break;
2638 default :
2639 if (mfp->appmessage != NULL) {
2640 mfp->appmessage (f, mssg);
2641 }
2642 break;
2643 }
2644 }
2645 }
2646
CreateMolInfoForm(Int2 left,Int2 top,Int2 width,Int2 height,CharPtr title,Uint1 biomol,Uint1 tech,Boolean nucsOK,Boolean protsOK,FormActnFunc actproc)2647 extern ForM CreateMolInfoForm (Int2 left, Int2 top, Int2 width, Int2 height,
2648 CharPtr title, Uint1 biomol, Uint1 tech,
2649 Boolean nucsOK, Boolean protsOK, FormActnFunc actproc)
2650
2651 {
2652 ButtoN b;
2653 GrouP c;
2654 GrouP g;
2655 MolInfoFormPtr mfp;
2656 PrompT p;
2657 GrouP q;
2658 StdEditorProcsPtr sepp;
2659 WindoW w;
2660
2661 w = NULL;
2662 mfp = (MolInfoFormPtr) MemNew (sizeof (MolInfoForm));
2663 if (mfp != NULL) {
2664 w = FixedWindow (left, top, width, height, title, StdCloseWindowProc);
2665 SetObjectExtra (w, mfp, StdDescFormCleanupProc);
2666 mfp->form = (ForM) w;
2667 mfp->actproc = actproc;
2668 mfp->formmessage = MolInfoFormMessage;
2669
2670 #ifndef WIN_MAC
2671 CreateStdEditorFormMenus (w);
2672 #endif
2673 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
2674 if (sepp != NULL) {
2675 SetActivate (w, sepp->activateForm);
2676 mfp->appmessage = sepp->handleMessages;
2677 }
2678
2679 g = HiddenGroup (w, -1, 0, NULL);
2680 mfp->data = CreateMolInfoDialog (g, NULL, biomol, tech, TRUE, nucsOK, protsOK, FALSE);
2681
2682 p = StaticPrompt (w, "Biological characteristics of sequences:",
2683 0, stdLineHeight, programFont, 'c');
2684
2685 q = HiddenGroup (w, 6, 0, NULL);
2686 StaticPrompt (q, "Class", 0, popupMenuHeight, programFont, 'c');
2687 mfp->molPopup = PopupList (q, TRUE, NULL);
2688 InitEnumPopup (mfp->molPopup, mol_alist, NULL);
2689 StaticPrompt (q, "Topology", 0, popupMenuHeight, programFont, 'c');
2690 mfp->topologyPopup = PopupList (q, TRUE, NULL);
2691 InitEnumPopup (mfp->topologyPopup, topology_alist, NULL);
2692 StaticPrompt (q, "Strand", 0, popupMenuHeight, programFont, 'c');
2693 mfp->strandPopup = PopupList (q, TRUE, NULL);
2694 InitEnumPopup (mfp->strandPopup, strand_alist, NULL);
2695
2696 SetGroupSpacing (q, 15, 2);
2697 c = HiddenGroup (w, 2, 0, NULL);
2698 b = PushButton (c, "Accept", StdAcceptFormButtonProc);
2699 SetObjectExtra (b, mfp, NULL);
2700 PushButton (c, "Cancel", StdCancelButtonProc);
2701 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) p, (HANDLE) q, (HANDLE) c, NULL);
2702 RealizeWindow (w);
2703 }
2704 return (ForM) w;
2705 }
2706
MolInfoGenFunc(Pointer data)2707 extern Int2 LIBCALLBACK MolInfoGenFunc (Pointer data)
2708
2709 {
2710 MolInfoFormPtr mfp;
2711 OMProcControlPtr ompcp;
2712 OMUserDataPtr omudp;
2713 ValNodePtr sdp;
2714 WindoW w;
2715
2716 ompcp = (OMProcControlPtr) data;
2717 sdp = NULL;
2718 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
2719 switch (ompcp->input_itemtype) {
2720 case OBJ_SEQDESC :
2721 sdp = (ValNodePtr) ompcp->input_data;
2722 if (sdp != NULL && sdp->choice != Seq_descr_molinfo) {
2723 return OM_MSG_RET_ERROR;
2724 }
2725 break;
2726 case OBJ_BIOSEQ :
2727 break;
2728 case OBJ_BIOSEQSET :
2729 break;
2730 case 0 :
2731 break;
2732 default :
2733 return OM_MSG_RET_ERROR;
2734 }
2735 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
2736 ompcp->input_itemtype, ompcp->proc->procid);
2737 if (omudp != NULL) {
2738 mfp = (MolInfoFormPtr) omudp->userdata.ptrvalue;
2739 if (mfp != NULL) {
2740 Select (mfp->form);
2741 }
2742 return OM_MSG_RET_DONE;
2743 }
2744 w = (WindoW) CreateMolInfoForm (-50, -33, -10, -10,
2745 "Molecule Information", 0, 0, TRUE, TRUE,
2746 MolInfoDescFormActnProc);
2747 mfp = (MolInfoFormPtr) GetObjectExtra (w);
2748 if (mfp != NULL) {
2749 mfp->input_entityID = ompcp->input_entityID;
2750 mfp->input_itemID = ompcp->input_itemID;
2751 mfp->input_itemtype = ompcp->input_itemtype;
2752 mfp->this_itemtype = OBJ_SEQDESC;
2753 mfp->this_subtype = Seq_descr_molinfo;
2754 mfp->procid = ompcp->proc->procid;
2755 mfp->proctype = ompcp->proc->proctype;
2756 mfp->userkey = OMGetNextUserKey ();
2757 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
2758 OMPROC_EDIT, mfp->userkey);
2759 if (omudp != NULL) {
2760 omudp->userdata.ptrvalue = (Pointer) mfp;
2761 omudp->messagefunc = StdVibrantEditorMsgFunc;
2762 }
2763 SendMessageToDialog (mfp->data, VIB_MSG_INIT);
2764 if (sdp != NULL) {
2765 PointerToDialog (mfp->data, (Pointer) sdp->data.ptrvalue);
2766 if (mfp->input_itemtype == OBJ_SEQDESC) {
2767 GatherItem (mfp->input_entityID, mfp->input_itemID, mfp->input_itemtype,
2768 (Pointer) mfp, CollectSeqInstFlags);
2769 }
2770 SetClosestParentIfDuplicating ((BaseFormPtr) mfp);
2771 }
2772 }
2773 Show (w);
2774 Select (w);
2775 return OM_MSG_RET_DONE;
2776 }
2777
2778
2779 typedef struct gbblockpage {
2780 DIALOG_MESSAGE_BLOCK
2781 TexT source;
2782 TexT origin;
2783 TexT date;
2784 TexT div;
2785 TexT taxonomy;
2786 ButtoN htgsDraft;
2787 ButtoN htgsFulltop;
2788 ButtoN htgsActivefin;
2789 ButtoN htgsCancelled;
2790 ButtoN tpaExperimental;
2791 ButtoN tpaInferential;
2792 ButtoN tpaReassembly;
2793 ButtoN tpaSpecialistDb;
2794 ButtoN barCode;
2795 ButtoN unordered;
2796 DialoG kywds;
2797 DialoG xaccns;
2798 DialoG entryDate;
2799 } GenBankPage, PNTR GenBankPagePtr;
2800
2801 typedef struct gbblockform {
2802 DESCRIPTOR_FORM_BLOCK
2803 DialoG gbppxaccns;
2804 ButtoN xaccnstohistory;
2805 ButtoN xleaveoldhistory;
2806 } GenBankForm, PNTR GenBankFormPtr;
2807
GBBlockPtrToGenBankPage(DialoG d,Pointer data)2808 static void GBBlockPtrToGenBankPage (DialoG d, Pointer data)
2809
2810 {
2811 GBBlockPtr gbp;
2812 GenBankPagePtr gpp;
2813 ValNodePtr head;
2814 Boolean isActivefin = FALSE;
2815 Boolean isCancelled = FALSE;
2816 Boolean isDraft = FALSE;
2817 Boolean isFulltop = FALSE;
2818 Boolean isExperimental = FALSE;
2819 Boolean isInferential = FALSE;
2820 Boolean isReassembly = FALSE;
2821 Boolean isBarcode = FALSE;
2822 Boolean isSpecialistDb = FALSE;
2823 Boolean isUnordered = FALSE;
2824 CharPtr str;
2825 ValNodePtr vnp;
2826
2827 gpp = (GenBankPagePtr) GetObjectExtra (d);
2828 gbp = (GBBlockPtr) data;
2829 if (gpp != NULL) {
2830 SetTitle (gpp->source, gbp->source);
2831 SetTitle (gpp->origin, gbp->origin);
2832 SetTitle (gpp->date, gbp->date);
2833 SetTitle (gpp->div, gbp->div);
2834 SetTitle (gpp->taxonomy, gbp->taxonomy);
2835 for (head = NULL, vnp = gbp->keywords; vnp != NULL; vnp = vnp->next) {
2836 str = (CharPtr) vnp->data.ptrvalue;
2837 if (StringICmp (str, "HTGS_DRAFT") != 0 &&
2838 StringICmp (str, "HTGS_FULLTOP") != 0 &&
2839 StringICmp (str, "HTGS_ACTIVEFIN") != 0 &&
2840 StringICmp (str, "HTGS_CANCELLED") != 0 &&
2841 StringICmp (str, "TPA:EXPERIMENTAL") != 0 &&
2842 StringICmp (str, "TPA:INFERENTIAL") != 0 &&
2843 StringICmp (str, "TPA:REASSEMBLY") != 0 &&
2844 StringICmp (str, "TPA:ASSEMBLY") != 0 &&
2845 StringICmp (str, "TPA:SPECIALIST_DB") != 0 &&
2846 StringICmp (str, "BARCODE") != 0 &&
2847 StringICmp (str, "UNORDERED") != 0) {
2848 ValNodeCopyStr (&head, 0, str);
2849 }
2850 }
2851 PointerToDialog (gpp->kywds, head);
2852 ValNodeFreeData (head);
2853 PointerToDialog (gpp->xaccns, gbp->extra_accessions);
2854 PointerToDialog (gpp->entryDate, gbp->entry_date);
2855 isDraft = FALSE;
2856 for (vnp = gbp->keywords; vnp != NULL; vnp = vnp->next) {
2857 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_DRAFT") == 0) {
2858 isDraft = TRUE;
2859 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_FULLTOP") == 0) {
2860 isFulltop = TRUE;
2861 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_ACTIVEFIN") == 0) {
2862 isActivefin = TRUE;
2863 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_CANCELLED") == 0) {
2864 isCancelled = TRUE;
2865 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:EXPERIMENTAL") == 0 ||
2866 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA_EXPERIMENTAL") == 0) {
2867 isExperimental = TRUE;
2868 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:INFERENTIAL") == 0 ||
2869 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA_INFERENTIAL") == 0) {
2870 isInferential = TRUE;
2871 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:REASSEMBLY") == 0 ||
2872 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA_REASSEMBLY") == 0) {
2873 isReassembly = TRUE;
2874 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:ASSEMBLY") == 0 ||
2875 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA_ASSEMBLY") == 0) {
2876 isReassembly = TRUE;
2877 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:SPECIALIST_DB") == 0 ||
2878 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA_SPECIALIST_DB") == 0) {
2879 isSpecialistDb = TRUE;
2880 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "BARCODE") == 0) {
2881 isBarcode = TRUE;
2882 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "UNORDERED") == 0) {
2883 isUnordered = TRUE;
2884 }
2885 }
2886 SafeSetStatus (gpp->htgsDraft, isDraft);
2887 SafeSetStatus (gpp->htgsFulltop, isFulltop);
2888 SafeSetStatus (gpp->htgsActivefin, isActivefin);
2889 SafeSetStatus (gpp->htgsCancelled, isCancelled);
2890 SafeSetStatus (gpp->tpaExperimental, isExperimental);
2891 SafeSetStatus (gpp->tpaInferential, isInferential);
2892 SafeSetStatus (gpp->tpaReassembly, isReassembly);
2893 SafeSetStatus (gpp->tpaSpecialistDb, isSpecialistDb);
2894 SafeSetStatus (gpp->barCode, isBarcode);
2895 SafeSetStatus (gpp->unordered, isUnordered);
2896 }
2897 }
2898
GenBankPageToGBBlockPtr(DialoG d)2899 static Pointer GenBankPageToGBBlockPtr (DialoG d)
2900
2901 {
2902 GBBlockPtr gbp;
2903 GenBankPagePtr gpp;
2904 Boolean noActivefin;
2905 Boolean noCancelled;
2906 Boolean noDraft;
2907 Boolean noFulltop;
2908 Boolean noExperimental;
2909 Boolean noInferential;
2910 Boolean noReassembly;
2911 Boolean noBarcode;
2912 Boolean noSpecialistDb;
2913 Boolean noUnordered;
2914 ValNodePtr keywords1 = NULL;
2915 ValNodePtr keywords2 = NULL;
2916 ValNodePtr vnp;
2917
2918 gbp = NULL;
2919 gpp = (GenBankPagePtr) GetObjectExtra (d);
2920 if (gpp != NULL) {
2921 gbp = GBBlockNew ();
2922 if (gbp != NULL) {
2923 gbp->source = SaveStringFromText (gpp->source);
2924 gbp->origin = SaveStringFromText (gpp->origin);
2925 gbp->date = SaveStringFromText (gpp->date);
2926 gbp->div = SaveStringFromText (gpp->div);
2927 gbp->taxonomy = SaveStringFromTextAndStripNewlines (gpp->taxonomy);
2928 keywords1 = DialogToPointer (gpp->kywds);
2929 gbp->extra_accessions = DialogToPointer (gpp->xaccns);
2930 gbp->entry_date = DialogToPointer (gpp->entryDate);
2931 if (GetStatus (gpp->htgsDraft)) {
2932 noDraft = TRUE;
2933 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2934 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_DRAFT") == 0) {
2935 noDraft = FALSE;
2936 }
2937 }
2938 if (noDraft) {
2939 ValNodeCopyStr (&keywords2, 0, "HTGS_DRAFT");
2940 }
2941 }
2942 if (GetStatus (gpp->htgsFulltop)) {
2943 noFulltop = TRUE;
2944 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2945 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_FULLTOP") == 0) {
2946 noFulltop = FALSE;
2947 }
2948 }
2949 if (noFulltop) {
2950 ValNodeCopyStr (&keywords2, 0, "HTGS_FULLTOP");
2951 }
2952 }
2953 if (GetStatus (gpp->htgsActivefin)) {
2954 noActivefin = TRUE;
2955 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2956 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_ACTIVEFIN") == 0) {
2957 noActivefin = FALSE;
2958 }
2959 }
2960 if (noActivefin) {
2961 ValNodeCopyStr (&keywords2, 0, "HTGS_ACTIVEFIN");
2962 }
2963 }
2964 if (GetStatus (gpp->htgsCancelled)) {
2965 noCancelled = TRUE;
2966 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2967 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_CANCELLED") == 0) {
2968 noCancelled = FALSE;
2969 }
2970 }
2971 if (noCancelled) {
2972 ValNodeCopyStr (&keywords2, 0, "HTGS_CANCELLED");
2973 }
2974 }
2975 if (GetStatus (gpp->tpaExperimental)) {
2976 noExperimental = TRUE;
2977 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2978 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:EXPERIMENTAL") == 0) {
2979 noExperimental = FALSE;
2980 }
2981 }
2982 if (noExperimental) {
2983 ValNodeCopyStr (&keywords2, 0, "TPA:experimental");
2984 }
2985 }
2986 if (GetStatus (gpp->tpaInferential)) {
2987 noInferential = TRUE;
2988 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
2989 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:INFERENTIAL") == 0) {
2990 noInferential = FALSE;
2991 }
2992 }
2993 if (noInferential) {
2994 ValNodeCopyStr (&keywords2, 0, "TPA:inferential");
2995 }
2996 }
2997 if (GetStatus (gpp->tpaReassembly)) {
2998 noReassembly = TRUE;
2999 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
3000 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:REASSEMBLY") == 0) {
3001 noReassembly = FALSE;
3002 } else if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:ASSEMBLY") == 0) {
3003 noReassembly = FALSE;
3004 }
3005 }
3006 if (noReassembly) {
3007 ValNodeCopyStr (&keywords2, 0, "TPA:assembly");
3008 }
3009 }
3010 if (GetStatus (gpp->tpaSpecialistDb)) {
3011 noSpecialistDb = TRUE;
3012 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
3013 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:SPECIALIST_DB") == 0) {
3014 noSpecialistDb = FALSE;
3015 }
3016 }
3017 if (noSpecialistDb) {
3018 ValNodeCopyStr (&keywords2, 0, "TPA:specialist_db");
3019 }
3020 }
3021 if (GetStatus (gpp->barCode)) {
3022 noBarcode = TRUE;
3023 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
3024 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "BARCODE") == 0) {
3025 noBarcode = FALSE;
3026 }
3027 }
3028 if (noBarcode) {
3029 ValNodeCopyStr (&keywords2, 0, "BARCODE");
3030 }
3031 }
3032 if (GetStatus (gpp->unordered)) {
3033 noUnordered = TRUE;
3034 for (vnp = keywords1; vnp != NULL; vnp = vnp->next) {
3035 if (StringICmp ((CharPtr) vnp->data.ptrvalue, "UNORDERED") == 0) {
3036 noUnordered = FALSE;
3037 }
3038 }
3039 if (noUnordered) {
3040 ValNodeCopyStr (&keywords2, 0, "UNORDERED");
3041 }
3042 }
3043 gbp->keywords = ValNodeLink (&keywords2, keywords1);
3044 }
3045 }
3046 return (Pointer) gbp;
3047 }
3048
DeleteKeywordProc(ButtoN b)3049 static void DeleteKeywordProc (ButtoN b)
3050
3051 {
3052 GenBankPagePtr gpp;
3053
3054 gpp = (GenBankPagePtr) GetObjectExtra (b);
3055 if (gpp != NULL) {
3056 PointerToDialog (gpp->kywds, NULL);
3057 SafeSetStatus (gpp->htgsDraft, FALSE);
3058 SafeSetStatus (gpp->htgsFulltop, FALSE);
3059 SafeSetStatus (gpp->htgsActivefin, FALSE);
3060 SafeSetStatus (gpp->htgsCancelled, FALSE);
3061 SafeSetStatus (gpp->tpaExperimental, FALSE);
3062 SafeSetStatus (gpp->tpaInferential, FALSE);
3063 SafeSetStatus (gpp->tpaReassembly, FALSE);
3064 SafeSetStatus (gpp->tpaSpecialistDb, FALSE);
3065 SafeSetStatus (gpp->barCode, FALSE);
3066 SafeSetStatus (gpp->unordered, FALSE);
3067 }
3068 }
3069
CreateGenBankDialog(GrouP h,CharPtr title,ValNodePtr sdp,GenBankFormPtr gfp)3070 static DialoG CreateGenBankDialog (GrouP h, CharPtr title, ValNodePtr sdp, GenBankFormPtr gfp)
3071
3072 {
3073 ButtoN b;
3074 GrouP f1, f2, f3, f4, f5;
3075 GBBlockPtr gbp;
3076 Boolean genome;
3077 GenBankPagePtr gpp;
3078 Boolean internal;
3079 GrouP m;
3080 GrouP p;
3081 GrouP s;
3082 Boolean showKeywords;
3083 ValNodePtr vnp;
3084
3085 p = HiddenGroup (h, 1, 0, NULL);
3086 SetGroupSpacing (p, 10, 10);
3087
3088 gpp = (GenBankPagePtr) MemNew (sizeof (GenBankPage));
3089 if (gpp) {
3090
3091 SetObjectExtra (p, gpp, StdCleanupExtraProc);
3092 gpp->dialog = (DialoG) p;
3093 gpp->todialog = GBBlockPtrToGenBankPage;
3094 gpp->fromdialog = GenBankPageToGBBlockPtr;
3095 gpp->testdialog = NULL;
3096
3097 if (title != NULL && title [0] != '\0') {
3098 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
3099 } else {
3100 s = HiddenGroup (p, 0, -2, NULL);
3101 }
3102 m = HiddenGroup (s, -1, 0, NULL);
3103 /*
3104 SetGroupSpacing (m, 10, 10);
3105 */
3106
3107 gbp = NULL;
3108 if (sdp != NULL && sdp->choice == Seq_descr_genbank && sdp->data.ptrvalue != NULL) {
3109 gbp = (GBBlockPtr) sdp->data.ptrvalue;
3110 }
3111 internal = (Boolean) (GetAppProperty ("InternalNcbiSequin") != NULL);
3112 genome = (Boolean) (GetAppProperty ("GenomeCenterSequin") != NULL);
3113
3114 f1 = HiddenGroup (m, 1, 0, NULL);
3115
3116 if ((! genome) || (gbp != NULL && gbp->div != NULL)) {
3117 StaticPrompt (f1, "Division", 0, 0, programFont, 'c');
3118 gpp->div = DialogText (f1, "", 15, NULL);
3119 }
3120
3121 if (internal || (gbp != NULL && gbp->origin != NULL)) {
3122 StaticPrompt (f1, "Origin", 0, 0, programFont, 'c');
3123 gpp->origin = DialogText (f1, "", 15, NULL);
3124 }
3125
3126 if (internal || (gbp != NULL && gbp->date != NULL)) {
3127 StaticPrompt (f1, "(Old Date)", 0, 0, programFont, 'c');
3128 gpp->date = DialogText (f1, "", 15, NULL);
3129 }
3130
3131 if (internal || (gbp != NULL && gbp->source != NULL)) {
3132 StaticPrompt (f1, "Source", 0, 0, programFont, 'c');
3133 gpp->source = DialogText (f1, "", 15, NULL);
3134 }
3135
3136 if (internal || (gbp != NULL && gbp->taxonomy != NULL)) {
3137 StaticPrompt (f1, "Taxonomy", 0, 0, programFont, 'c');
3138 gpp->taxonomy = ScrollText (f1, 15, 5, programFont, TRUE, NULL);
3139 }
3140
3141 f3 = HiddenGroup (m, 0, 5, NULL);
3142 if (internal || genome || (gbp != NULL && gbp->extra_accessions != NULL)) {
3143 StaticPrompt (f3, "Secondary Accessions", 0, 0, programFont, 'c');
3144 gpp->xaccns = CreateVisibleStringDialog (f3, 3, -1, 15);
3145 if (internal || genome) {
3146 gfp->gbppxaccns = gpp->xaccns;
3147 gfp->xaccnstohistory = CheckBox (f3, "Copy to Bioseq-history.replaces", NULL);
3148 if (! internal) {
3149 SetStatus (gfp->xaccnstohistory, TRUE);
3150 Hide (gfp->xaccnstohistory);
3151 }
3152 gfp->xleaveoldhistory = CheckBox (f3, "Retain old Bioseq-history.replaces", NULL);
3153 }
3154 }
3155
3156 b = NULL;
3157 f5 = NULL;
3158 f2 = HiddenGroup (m, 0, 3, NULL);
3159 showKeywords = FALSE;
3160 if (gbp != NULL && gbp->keywords != NULL) {
3161 vnp = gbp->keywords;
3162 if (vnp->next != NULL ||
3163 StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_DRAFT") != 0 ||
3164 StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_FULLTOP") != 0 ||
3165 StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_ACTIVEFIN") != 0 ||
3166 StringICmp ((CharPtr) vnp->data.ptrvalue, "HTGS_CANCELLED") != 0 ||
3167 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:EXPERIMENTAL") != 0 ||
3168 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:INFERENTIAL") != 0 ||
3169 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:REASSEMBLY") != 0 ||
3170 StringICmp ((CharPtr) vnp->data.ptrvalue, "TPA:ASSEMBLY") != 0 ||
3171 StringICmp ((CharPtr) vnp->data.ptrvalue, "BARCODE") != 0) {
3172 showKeywords = TRUE;
3173 }
3174 }
3175 if (internal || showKeywords) {
3176 StaticPrompt (f2, "Keywords", 0, 0, programFont, 'c');
3177 gpp->kywds = CreateVisibleStringDialog (f2, 3, -1, 15);
3178 }
3179 if (internal || genome || (gbp != NULL && gbp->keywords != NULL)) {
3180 f5 = HiddenGroup (f2, 2, 0, NULL);
3181 gpp->htgsDraft = CheckBox (f5, "HTGS_DRAFT", NULL);
3182 gpp->htgsFulltop = CheckBox (f5, "HTGS_FULLTOP", NULL);
3183 gpp->htgsActivefin = CheckBox (f5, "HTGS_ACTIVEFIN", NULL);
3184 gpp->htgsCancelled = CheckBox (f5, "HTGS_CANCELLED", NULL);
3185 gpp->tpaExperimental = CheckBox (f5, "TPA:EXPERIMENTAL", NULL);
3186 gpp->tpaInferential = CheckBox (f5, "TPA:INFERENTIAL", NULL);
3187 gpp->tpaReassembly = CheckBox (f5, "TPA:ASSEMBLY", NULL);
3188 gpp->tpaSpecialistDb = CheckBox (f5, "TPA:SPECIALIST_DB", NULL);
3189 gpp->barCode = CheckBox (f5, "BARCODE", NULL);
3190 gpp->unordered = CheckBox (f5, "UNORDERED", NULL);
3191 }
3192 if (internal) {
3193 b = PushButton (m, "Delete All Keywords", DeleteKeywordProc);
3194 SetObjectExtra (b, gpp, NULL);
3195 }
3196
3197 f4 = HiddenGroup (m, 2, 0, NULL);
3198 if (internal || (gbp != NULL && gbp->entry_date != NULL)) {
3199 gpp->entryDate = CreateDateDialog (f4, "");
3200 }
3201
3202 AlignObjects (ALIGN_CENTER, (HANDLE) f1, (HANDLE) f2, (HANDLE) f3,
3203 (HANDLE) f4, (HANDLE) b, (HANDLE) f5, NULL);
3204 }
3205
3206 return (DialoG) p;
3207 }
3208
GenBankFormMessage(ForM f,Int2 mssg)3209 static void GenBankFormMessage (ForM f, Int2 mssg)
3210
3211 {
3212 GenBankFormPtr gfp;
3213
3214 gfp = (GenBankFormPtr) GetObjectExtra (f);
3215 if (gfp != NULL) {
3216 switch (mssg) {
3217 case VIB_MSG_CLOSE :
3218 Remove (f);
3219 break;
3220 case VIB_MSG_CUT :
3221 StdCutTextProc (NULL);
3222 break;
3223 case VIB_MSG_COPY :
3224 StdCopyTextProc (NULL);
3225 break;
3226 case VIB_MSG_PASTE :
3227 StdPasteTextProc (NULL);
3228 break;
3229 case VIB_MSG_DELETE :
3230 StdDeleteTextProc (NULL);
3231 break;
3232 default :
3233 if (gfp->appmessage != NULL) {
3234 gfp->appmessage (f, mssg);
3235 }
3236 break;
3237 }
3238 }
3239 }
3240
CreateGenBankForm(Int2 left,Int2 top,CharPtr title,ValNodePtr sdp,SeqEntryPtr sep,FormActnFunc actproc)3241 extern ForM CreateGenBankForm (Int2 left, Int2 top, CharPtr title,
3242 ValNodePtr sdp, SeqEntryPtr sep,
3243 FormActnFunc actproc)
3244
3245 {
3246 ButtoN b;
3247 GrouP c;
3248 GrouP g;
3249 GenBankFormPtr gfp;
3250 StdEditorProcsPtr sepp;
3251 WindoW w;
3252
3253 w = NULL;
3254 gfp = (GenBankFormPtr) MemNew (sizeof (GenBankForm));
3255 if (gfp != NULL) {
3256 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
3257 SetObjectExtra (w, gfp, StdDescFormCleanupProc);
3258 gfp->form = (ForM) w;
3259 gfp->actproc = actproc;
3260 gfp->formmessage = GenBankFormMessage;
3261
3262 #ifndef WIN_MAC
3263 CreateStdEditorFormMenus (w);
3264 #endif
3265
3266 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
3267 if (sepp != NULL) {
3268 SetActivate (w, sepp->activateForm);
3269 gfp->appmessage = sepp->handleMessages;
3270 }
3271
3272 g = HiddenGroup (w, -1, 0, NULL);
3273 gfp->xaccnstohistory = NULL;
3274 gfp->xleaveoldhistory = NULL;
3275 gfp->gbppxaccns = NULL;
3276 gfp->data = CreateGenBankDialog (g, NULL, sdp, gfp);
3277
3278 c = HiddenGroup (w, 2, 0, NULL);
3279 b = PushButton (c, "Accept", StdAcceptFormButtonProc);
3280 SetObjectExtra (b, gfp, NULL);
3281 PushButton (c, "Cancel", StdCancelButtonProc);
3282 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
3283 RealizeWindow (w);
3284 }
3285 return (ForM) w;
3286 }
3287
GetLowestStackSeqEntryForGBB(GatherContextPtr gcp)3288 static Boolean GetLowestStackSeqEntryForGBB (GatherContextPtr gcp)
3289
3290 {
3291 BaseFormPtr bfp;
3292 Int2 i;
3293
3294 if (gcp == NULL) return TRUE;
3295 bfp = (BaseFormPtr) gcp->userdata;
3296 if (bfp == NULL) return TRUE;
3297 if (gcp->gatherstack != NULL && gcp->numstack > 0) {
3298 for (i = 0; i < gcp->numstack; i++) {
3299 if (gcp->gatherstack [i].itemtype == OBJ_BIOSEQ ||
3300 gcp->gatherstack [i].itemtype == OBJ_BIOSEQSET) {
3301 bfp->input_itemID = gcp->gatherstack [i].itemID;
3302 bfp->input_itemtype = gcp->gatherstack [i].itemtype;
3303 }
3304 }
3305 }
3306 return FALSE;
3307 }
3308
ParseSecAccessionRange(CharPtr accn,CharPtr prefix,Int4Ptr startp,Int4Ptr stopp,Int2Ptr digitsp)3309 static Boolean ParseSecAccessionRange (
3310 CharPtr accn,
3311 CharPtr prefix,
3312 Int4Ptr startp,
3313 Int4Ptr stopp,
3314 Int2Ptr digitsp
3315 )
3316
3317 {
3318 Char ch;
3319 Int2 digits;
3320 CharPtr ptr, tmp;
3321 Int4 start, stop;
3322 long int val;
3323
3324 if (StringHasNoText (accn)) return FALSE;
3325 if (prefix == NULL || startp == NULL || stopp == NULL || digitsp == NULL) return FALSE;
3326
3327 ptr = accn;
3328 ch = *ptr;
3329 while (IS_ALPHA (ch)) {
3330 *prefix = ch;
3331 prefix++;
3332 ptr++;
3333 ch = *ptr;
3334 }
3335 *prefix = '\0';
3336
3337 tmp = StringChr (ptr, '-');
3338 if (tmp == NULL) return FALSE;
3339 *tmp = '\0';
3340 tmp++;
3341
3342 if (sscanf (ptr, "%ld", &val) != 1 || val < 1) return FALSE;
3343 start = (Int4) val;
3344
3345 digits = 0;
3346 while (IS_DIGIT (ch)) {
3347 digits++;
3348 ptr++;
3349 ch = *ptr;
3350 }
3351
3352 ptr = tmp;
3353 ch = *ptr;
3354 while (IS_ALPHA (ch)) {
3355 ptr++;
3356 ch = *ptr;
3357 }
3358
3359 if (sscanf (ptr, "%ld", &val) != 1 || val < 1) return FALSE;
3360 stop = (Int4) val;
3361
3362 *startp = start;
3363 *stopp = stop;
3364 *digitsp = digits;
3365
3366 return TRUE;
3367 }
3368
ExpandSecondaries(SeqDescrPtr sdp,Pointer userdata)3369 static void ExpandSecondaries (SeqDescrPtr sdp, Pointer userdata)
3370
3371 {
3372 CharPtr accn;
3373 ValNodePtr curr, last, next, vnp;
3374 Int2 digits, j;
3375 GBBlockPtr gbp;
3376 Int4 idx;
3377 Char numbers [32];
3378 Char prefix [16];
3379 Int4 start, stop;
3380 Char tmp [64];
3381
3382 if (sdp == NULL || sdp->choice != Seq_descr_genbank) return;
3383 gbp = (GBBlockPtr) sdp->data.ptrvalue;
3384 if (gbp == NULL) return;
3385
3386 vnp = gbp->extra_accessions;
3387 while (vnp != NULL) {
3388 next = vnp->next;
3389 last = vnp;
3390 accn = (CharPtr) vnp->data.ptrvalue;
3391 if (StringChr (accn, '-') != NULL) {
3392 if (ParseSecAccessionRange (accn, prefix, &start, &stop, &digits)) {
3393 for (idx = start; idx <= stop; idx++) {
3394 sprintf (numbers, "%*ld", digits, (long) idx);
3395 for (j = 0; j < digits && numbers [j] != '\0'; j++) {
3396 if (numbers [j] == ' ') {
3397 numbers [j] = '0';
3398 }
3399 }
3400 StringCpy (tmp, prefix);
3401 StringCat (tmp, numbers);
3402 if (idx == start) {
3403 vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
3404 vnp->data.ptrvalue = StringSave (tmp);
3405 } else {
3406 curr = ValNodeCopyStr (NULL, 0, tmp);
3407 if (curr != NULL) {
3408 curr->next = last->next;
3409 last->next = curr;
3410 last = curr;
3411 }
3412 }
3413 }
3414 }
3415 }
3416 vnp = next;
3417 }
3418 }
3419
GenBankFormActnProc(ForM f)3420 static void GenBankFormActnProc (ForM f)
3421
3422 {
3423 BioseqPtr bsp;
3424 Boolean changehist;
3425 GenBankFormPtr gfp;
3426 SeqHistPtr hist;
3427 Char prefix [20];
3428 SeqEntryPtr sep;
3429 SeqIdPtr sip;
3430 TextSeqIdPtr tsip;
3431 ValNodePtr tmp;
3432 ValNodePtr vnp;
3433 Uint4 whichdb;
3434
3435 gfp = (GenBankFormPtr) GetObjectExtra (f);
3436 if (gfp != NULL) {
3437 vnp = NULL;
3438 changehist = (Boolean) (gfp->xaccnstohistory != NULL &&
3439 GetStatus (gfp->xaccnstohistory));
3440 if (changehist) {
3441 vnp = DialogToPointer (gfp->gbppxaccns);
3442 }
3443 if (DescFormReplaceWithoutUpdateProc (f)) {
3444 GetRidOfEmptyFeatsDescStrings (gfp->input_entityID, NULL);
3445 if (GetAppProperty ("InternalNcbiSequin") != NULL) {
3446 ExtendGeneFeatIfOnMRNA (gfp->input_entityID, NULL);
3447 }
3448 if (changehist) {
3449 GatherItem (gfp->input_entityID, gfp->input_itemID, gfp->input_itemtype,
3450 (Pointer) gfp, GetLowestStackSeqEntryForGBB);
3451 bsp = GetBioseqGivenIDs (gfp->input_entityID, gfp->input_itemID, gfp->input_itemtype);
3452 if (bsp != NULL) {
3453 hist = bsp->hist;
3454 if (hist != NULL) {
3455 if (! GetStatus (gfp->xleaveoldhistory)) {
3456 hist->replace_ids = SeqIdSetFree (hist->replace_ids);
3457 }
3458 } else {
3459 hist = SeqHistNew ();
3460 bsp->hist = hist;
3461 }
3462 if (hist != NULL && vnp != NULL) {
3463 for (tmp = vnp; tmp != NULL; tmp = tmp->next) {
3464 sip = ValNodeNew (hist->replace_ids);
3465 if (hist->replace_ids == NULL) {
3466 hist->replace_ids = sip;
3467 }
3468 if (sip != NULL) {
3469 tsip = TextSeqIdNew ();
3470 StringNCpy_0 (prefix, (CharPtr) tmp->data.ptrvalue, sizeof (prefix));
3471 /*
3472 ptr = &(prefix [0]);
3473 ch = *ptr;
3474 while (ch != '\0' && IS_ALPHA (ch)) {
3475 ptr++;
3476 ch = *ptr;
3477 }
3478 *ptr = '\0';
3479 */
3480 whichdb = WHICH_db_accession (prefix);
3481 if (ACCN_IS_EMBL (whichdb)) {
3482 sip->choice = SEQID_EMBL;
3483 } else if (ACCN_IS_DDBJ (whichdb)) {
3484 sip->choice = SEQID_DDBJ;
3485 } else {
3486 sip->choice = SEQID_GENBANK;
3487 }
3488 sip->data.ptrvalue = (Pointer) tsip;
3489 if (tsip != NULL) {
3490 tsip->accession = StringSave (tmp->data.ptrvalue);
3491 }
3492 }
3493 }
3494 }
3495 if (hist != NULL) {
3496 if (hist->assembly == NULL && hist->replace_date == NULL &&
3497 hist->replace_ids == NULL && hist->replaced_by_date == NULL &&
3498 hist->replaced_by_ids == NULL && hist->deleted_date == NULL &&
3499 (! hist->deleted)) {
3500 bsp->hist = SeqHistFree (bsp->hist);
3501 }
3502 }
3503 }
3504 ValNodeFreeData (vnp);
3505 }
3506 sep = GetTopSeqEntryForEntityID (gfp->input_entityID);
3507 VisitDescriptorsInSep (sep, NULL, ExpandSecondaries);
3508 ObjMgrSendMsg (OM_MSG_UPDATE, gfp->input_entityID,
3509 gfp->input_itemID, gfp->input_itemtype);
3510 }
3511 }
3512 }
3513
GenBankGenFunc(Pointer data)3514 extern Int2 LIBCALLBACK GenBankGenFunc (Pointer data)
3515
3516 {
3517 BioseqPtr bsp;
3518 GenBankFormPtr gfp;
3519 OMProcControlPtr ompcp;
3520 OMUserDataPtr omudp;
3521 ValNodePtr sdp;
3522 SeqEntryPtr sep;
3523 WindoW w;
3524
3525 ompcp = (OMProcControlPtr) data;
3526 sdp = NULL;
3527 sep = NULL;
3528 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
3529 switch (ompcp->input_itemtype) {
3530 case OBJ_SEQDESC :
3531 sdp = (ValNodePtr) ompcp->input_data;
3532 if (sdp != NULL && sdp->choice != Seq_descr_genbank) {
3533 return OM_MSG_RET_ERROR;
3534 }
3535 break;
3536 case OBJ_BIOSEQ :
3537 break;
3538 case OBJ_BIOSEQSET :
3539 break;
3540 case 0 :
3541 break;
3542 default :
3543 return OM_MSG_RET_ERROR;
3544 }
3545 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
3546 ompcp->input_itemtype, ompcp->proc->procid);
3547 if (omudp != NULL) {
3548 gfp = (GenBankFormPtr) omudp->userdata.ptrvalue;
3549 if (gfp != NULL) {
3550 Select (gfp->form);
3551 }
3552 return OM_MSG_RET_DONE;
3553 }
3554 sep = GetTopSeqEntryForEntityID (ompcp->input_entityID);
3555 w = (WindoW) CreateGenBankForm (-50, -33, "GenBank Block", sdp, sep,
3556 GenBankFormActnProc);
3557 gfp = (GenBankFormPtr) GetObjectExtra (w);
3558 if (gfp != NULL) {
3559 gfp->input_entityID = ompcp->input_entityID;
3560 gfp->input_itemID = ompcp->input_itemID;
3561 gfp->input_itemtype = ompcp->input_itemtype;
3562 gfp->this_itemtype = OBJ_SEQDESC;
3563 gfp->this_subtype = Seq_descr_genbank;
3564 gfp->procid = ompcp->proc->procid;
3565 gfp->proctype = ompcp->proc->proctype;
3566 gfp->userkey = OMGetNextUserKey ();
3567
3568 /* Don't allow history update for proteins */
3569
3570 bsp = GetBioseqGivenIDs (gfp->input_entityID,
3571 gfp->input_itemID,
3572 gfp->input_itemtype);
3573 if (bsp != NULL && ISA_aa (bsp->mol)) {
3574 SetStatus (gfp->xaccnstohistory, FALSE);
3575 SafeDisable (gfp->xaccnstohistory);
3576 }
3577
3578 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
3579 OMPROC_EDIT, gfp->userkey);
3580 if (omudp != NULL) {
3581 omudp->userdata.ptrvalue = (Pointer) gfp;
3582 omudp->messagefunc = StdVibrantEditorMsgFunc;
3583 }
3584 SendMessageToDialog (gfp->data, VIB_MSG_INIT);
3585 if (sdp != NULL) {
3586 PointerToDialog (gfp->data, (Pointer) sdp->data.ptrvalue);
3587 SetClosestParentIfDuplicating ((BaseFormPtr) gfp);
3588 }
3589 }
3590 Show (w);
3591 Select (w);
3592 return OM_MSG_RET_DONE;
3593 }
3594
3595
3596 typedef struct visstrpage {
3597 DIALOG_MESSAGE_BLOCK
3598 TexT title;
3599 } VisStrPage, PNTR VisStrPagePtr;
3600
3601 typedef struct visstrform {
3602 DESCRIPTOR_FORM_BLOCK
3603 Uint1 subtype;
3604 } VisStrForm, PNTR VisStrFormPtr;
3605
CharPtrToVisStrPage(DialoG d,Pointer data)3606 static void CharPtrToVisStrPage (DialoG d, Pointer data)
3607
3608 {
3609 CharPtr title;
3610 VisStrPagePtr vpp;
3611
3612 vpp = (VisStrPagePtr) GetObjectExtra (d);
3613 title = (CharPtr) data;
3614 if (vpp != NULL) {
3615 SetTitle (vpp->title, title);
3616 }
3617 }
3618
VisStrPageToCharPtr(DialoG d)3619 static Pointer VisStrPageToCharPtr (DialoG d)
3620
3621 {
3622 CharPtr title;
3623 VisStrPagePtr vpp;
3624 ValNodePtr find_list = NULL;
3625
3626 title = NULL;
3627 vpp = (VisStrPagePtr) GetObjectExtra (d);
3628 if (vpp != NULL) {
3629 title = SaveStringFromText (vpp->title);
3630 title = StripNewlines (title);
3631 SpecialCharFindWithContext (&title, &find_list, NULL, NULL);
3632 FixSpecialCharactersForStringsInList (find_list, "Special characters are not permitted.", TRUE);
3633 if (find_list != NULL) {
3634 PointerToDialog (d, title);
3635 find_list = FreeContextList (find_list);
3636 }
3637 }
3638 return (Pointer) title;
3639 }
3640
VisStrDialogMessage(DialoG d,Int2 mssg)3641 static void VisStrDialogMessage (DialoG d, Int2 mssg)
3642
3643 {
3644 VisStrPagePtr vpp;
3645
3646 vpp = (VisStrPagePtr) GetObjectExtra (d);
3647 if (vpp != NULL) {
3648 switch (mssg) {
3649 case VIB_MSG_ENTER :
3650 Select (vpp->title);
3651 break;
3652 default :
3653 break;
3654 }
3655 }
3656 }
3657
CreateVisStrDialog(GrouP h,CharPtr title,Uint2 subtype)3658 static DialoG CreateVisStrDialog (GrouP h, CharPtr title, Uint2 subtype)
3659
3660 {
3661 GrouP f;
3662 CharPtr label;
3663 GrouP m;
3664 GrouP p;
3665 GrouP s;
3666 VisStrPagePtr vpp;
3667
3668 p = HiddenGroup (h, 1, 0, NULL);
3669 SetGroupSpacing (p, 10, 10);
3670
3671 vpp = (VisStrPagePtr) MemNew (sizeof (VisStrPage));
3672 if (vpp) {
3673
3674 SetObjectExtra (p, vpp, StdCleanupExtraProc);
3675 vpp->dialog = (DialoG) p;
3676 vpp->todialog = CharPtrToVisStrPage;
3677 vpp->fromdialog = VisStrPageToCharPtr;
3678 vpp->testdialog = NULL;
3679 vpp->dialogmessage = VisStrDialogMessage;
3680
3681 if (title != NULL && title [0] != '\0') {
3682 s = NormalGroup (p, 0, -2, title, systemFont, NULL);
3683 } else {
3684 s = HiddenGroup (p, 0, -2, NULL);
3685 }
3686 m = HiddenGroup (s, -1, 0, NULL);
3687 /*
3688 SetGroupSpacing (m, 10, 10);
3689 */
3690
3691 f = HiddenGroup (m, 0, 2, NULL);
3692 if (subtype == Seq_descr_title) {
3693 label = "Title";
3694 } else if (subtype == Seq_descr_comment) {
3695 label = "Comment";
3696 } else if (subtype == Seq_descr_name) {
3697 label = "Name";
3698 } else if (subtype == Seq_descr_region) {
3699 label = "Region";
3700 } else {
3701 label = "Title";
3702 }
3703 StaticPrompt (f, label, 0, 0, programFont, 'c');
3704 vpp->title = ScrollText (f, 25, 15, programFont, TRUE, NULL);
3705 }
3706
3707 return (DialoG) p;
3708 }
3709
VisStrFormMessage(ForM f,Int2 mssg)3710 static void VisStrFormMessage (ForM f, Int2 mssg)
3711
3712 {
3713 VisStrFormPtr vfp;
3714
3715 vfp = (VisStrFormPtr) GetObjectExtra (f);
3716 if (vfp != NULL) {
3717 switch (mssg) {
3718 case VIB_MSG_ENTER :
3719 SendMessageToDialog (vfp->data, VIB_MSG_ENTER);
3720 break;
3721 case VIB_MSG_CLOSE :
3722 Remove (f);
3723 break;
3724 case VIB_MSG_CUT :
3725 StdCutTextProc (NULL);
3726 break;
3727 case VIB_MSG_COPY :
3728 StdCopyTextProc (NULL);
3729 break;
3730 case VIB_MSG_PASTE :
3731 StdPasteTextProc (NULL);
3732 break;
3733 case VIB_MSG_DELETE :
3734 StdDeleteTextProc (NULL);
3735 break;
3736 default :
3737 if (vfp->appmessage != NULL) {
3738 vfp->appmessage (f, mssg);
3739 }
3740 break;
3741 }
3742 }
3743 }
3744
3745
3746 static CharPtr citInCommentMsg =
3747 "This comment looks like it has citation references in [#] form.\n\
3748 You should put comments about references in the REMARK section by\n\
3749 double clicking on the reference and launching its editor.\n\
3750 Continue saving this comment?";
3751
3752
3753 typedef struct replacevisstr {
3754 Uint1 subtype;
3755 CharPtr deleteThis;
3756 CharPtr replaceWith;
3757 Boolean replace_all;
3758 } ReplaceVisStrData, PNTR ReplaceVisStrPtr;
3759
ReplaceAllCallback(SeqDescrPtr sdp,Pointer data)3760 static void ReplaceAllCallback (SeqDescrPtr sdp, Pointer data)
3761
3762 {
3763 ReplaceVisStrPtr rp;
3764
3765 if ((rp = (ReplaceVisStrPtr) data) == NULL || sdp == NULL || sdp->choice != rp->subtype) {
3766 return;
3767 }
3768
3769 if (StringCmp (sdp->data.ptrvalue, rp->deleteThis) == 0) {
3770 sdp->data.ptrvalue = MemFree (sdp->data.ptrvalue);
3771 sdp->data.ptrvalue = StringSave (rp->replaceWith);
3772 }
3773 }
3774
3775
3776 extern const CharPtr kDoNotEditTitle = "You are manually editing a title. If you continue, the title will not be automatically updated if the taxonomy information changes. Are you sure you want to do this? It is a very bad idea.";
3777
ReplaceAllVisibleStringsButtonProc(ButtoN b)3778 static void ReplaceAllVisibleStringsButtonProc (ButtoN b)
3779 {
3780 VisStrFormPtr vfp;
3781 Boolean suspicious = FALSE;
3782 SeqEntryPtr sep;
3783 ReplaceVisStrData rd;
3784 SeqDescrPtr sdp_orig;
3785 SeqMgrDescContext context;
3786
3787 vfp = (VisStrFormPtr) GetObjectExtra (b);
3788 if (vfp == NULL) {
3789 return;
3790 }
3791
3792 sep = GetTopSeqEntryForEntityID (vfp->input_entityID);
3793
3794 rd.subtype = vfp->subtype;
3795 rd.replaceWith = DialogToPointer (vfp->data);
3796 if (rd.replaceWith == NULL || StringHasNoText (rd.replaceWith)) {
3797 Message (MSG_ERROR, "Must supply text!");
3798 rd.replaceWith = MemFree (rd.replaceWith);
3799 return;
3800 }
3801
3802 sdp_orig = SeqMgrGetDesiredDescriptor (vfp->input_entityID, NULL, vfp->input_itemID, 0, NULL, &context);
3803 if (sdp_orig == NULL || sdp_orig->choice != vfp->subtype) {
3804 Message (MSG_ERROR, "Unable to find original descriptor!");
3805 Remove (vfp->form);
3806 rd.replaceWith = MemFree (rd.replaceWith);
3807 return;
3808 }
3809 rd.deleteThis = StringSave (sdp_orig->data.ptrvalue);
3810
3811 if (vfp->subtype == Seq_descr_comment) {
3812 suspicious = SerialNumberInString (rd.replaceWith);
3813 }
3814 if (suspicious) {
3815 if (Message (MSG_OKC, "%s", citInCommentMsg) == ANS_CANCEL) {
3816 rd.deleteThis = MemFree (rd.deleteThis);
3817 rd.replaceWith = MemFree (rd.replaceWith);
3818 return;
3819 }
3820 }
3821 if (vfp->subtype == Seq_descr_title) {
3822 if (Message(MSG_OKC, "%s", kDoNotEditTitle) == ANS_CANCEL) {
3823 rd.deleteThis = MemFree(rd.deleteThis);
3824 rd.replaceWith = MemFree(rd.replaceWith);
3825 return;
3826 }
3827 RemoveAutodefObjects(sep);
3828 }
3829
3830 VisitDescriptorsInSep (sep, &rd, ReplaceAllCallback);
3831
3832 GetRidOfEmptyFeatsDescStrings (vfp->input_entityID, NULL);
3833 ObjMgrSetDirtyFlag (vfp->input_entityID, TRUE);
3834 ObjMgrSendMsg (OM_MSG_UPDATE, vfp->input_entityID,
3835 vfp->input_itemID, vfp->input_itemtype);
3836 Remove (vfp->form);
3837 }
3838
3839
CreateVisStrForm(Int2 left,Int2 top,CharPtr title,Uint2 subtype,FormActnFunc actproc,SeqDescrPtr sdp)3840 extern ForM CreateVisStrForm (Int2 left, Int2 top, CharPtr title,
3841 Uint2 subtype, FormActnFunc actproc, SeqDescrPtr sdp)
3842
3843 {
3844 ButtoN b;
3845 GrouP c;
3846 GrouP g;
3847 StdEditorProcsPtr sepp;
3848 VisStrFormPtr vfp;
3849 WindoW w;
3850
3851 w = NULL;
3852 vfp = (VisStrFormPtr) MemNew (sizeof (VisStrForm));
3853 if (vfp != NULL) {
3854 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
3855 SetObjectExtra (w, vfp, StdDescFormCleanupProc);
3856 vfp->form = (ForM) w;
3857 vfp->actproc = actproc;
3858 vfp->formmessage = VisStrFormMessage;
3859 vfp->subtype = (Uint1)subtype;
3860
3861 #ifndef WIN_MAC
3862 CreateStdEditorFormMenus (w);
3863 #endif
3864
3865 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
3866 if (sepp != NULL) {
3867 SetActivate (w, sepp->activateForm);
3868 vfp->appmessage = sepp->handleMessages;
3869 }
3870
3871 g = HiddenGroup (w, -1, 0, NULL);
3872 vfp->data = CreateVisStrDialog (g, NULL, subtype);
3873
3874 c = HiddenGroup (w, 3, 0, NULL);
3875
3876 if (sdp == NULL) {
3877 b = PushButton (c, "Accept", StdAcceptFormButtonProc);
3878 SetObjectExtra (b, vfp, NULL);
3879 } else {
3880 b = PushButton (c, "Replace All", ReplaceAllVisibleStringsButtonProc);
3881 SetObjectExtra (b, vfp, NULL);
3882 b = PushButton (c, "Replace This", StdAcceptFormButtonProc);
3883 SetObjectExtra (b, vfp, NULL);
3884 }
3885
3886 PushButton (c, "Cancel", StdCancelButtonProc);
3887 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
3888 RealizeWindow (w);
3889 }
3890 return (ForM) w;
3891 }
3892
VisStrDescFormActnProc(ForM f)3893 static void VisStrDescFormActnProc (ForM f)
3894
3895 {
3896 OMProcControl ompc;
3897 CharPtr str;
3898 Boolean suspicious;
3899 VisStrFormPtr vfp;
3900 SeqEntryPtr sep;
3901
3902 vfp = (VisStrFormPtr) GetObjectExtra (f);
3903 if (vfp != NULL) {
3904 str = DialogToPointer (vfp->data);
3905 if (str == NULL || StringHasNoText (str)) {
3906 MemSet ((Pointer) &ompc, 0, sizeof (OMProcControl));
3907 ompc.do_not_reload_from_cache = TRUE;
3908 ompc.input_entityID = vfp->input_entityID;
3909 ompc.input_itemID = vfp->input_itemID;
3910 ompc.input_itemtype = vfp->input_itemtype;
3911 if (! DetachDataForProc (&ompc, FALSE)) {
3912 Message (MSG_ERROR, "DetachDataForProc failed");
3913 }
3914 GetRidOfEmptyFeatsDescStrings (vfp->input_entityID, NULL);
3915 ObjMgrSetDirtyFlag (vfp->input_entityID, TRUE);
3916 ObjMgrSendMsg (OM_MSG_UPDATE, vfp->input_entityID,
3917 vfp->input_itemID, vfp->input_itemtype);
3918 MemFree (str);
3919 return;
3920 }
3921 suspicious = FALSE;
3922 if (vfp->subtype == Seq_descr_comment) {
3923 suspicious = SerialNumberInString (str);
3924 }
3925 MemFree (str);
3926 if (vfp->subtype == Seq_descr_title) {
3927 if (Message(MSG_OKC, kDoNotEditTitle) == ANS_CANCEL) {
3928 Remove(f);
3929 return;
3930 }
3931 }
3932 if (suspicious) {
3933 if (Message (MSG_OKC, "%s", citInCommentMsg) == ANS_CANCEL) {
3934 Remove (f);
3935 return;
3936 }
3937 }
3938 if (DescFormReplaceWithoutUpdateProc (f)) {
3939 if (vfp->subtype == Seq_descr_title) {
3940 sep = GetTopSeqEntryForEntityID(vfp->input_entityID);
3941 RemoveAutodefObjects(sep);
3942 }
3943
3944 GetRidOfEmptyFeatsDescStrings (vfp->input_entityID, NULL);
3945 if (GetAppProperty ("InternalNcbiSequin") != NULL) {
3946 ExtendGeneFeatIfOnMRNA (vfp->input_entityID, NULL);
3947 }
3948 ObjMgrSetDirtyFlag (vfp->input_entityID, TRUE);
3949 ObjMgrSendMsg (OM_MSG_UPDATE, vfp->input_entityID,
3950 vfp->input_itemID, vfp->input_itemtype);
3951 }
3952 }
3953 }
3954
VisStrGenFunc(Pointer data)3955 extern Int2 LIBCALLBACK VisStrGenFunc (Pointer data)
3956
3957 {
3958 OMProcControlPtr ompcp;
3959 OMUserDataPtr omudp;
3960 ObjMgrProcPtr proc;
3961 ValNodePtr sdp;
3962 Uint2 subtype = 0;
3963 VisStrFormPtr vfp;
3964 WindoW w;
3965
3966 ompcp = (OMProcControlPtr) data;
3967 sdp = NULL;
3968 subtype = 0;
3969 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
3970 proc = ompcp->proc;
3971 switch (ompcp->input_itemtype) {
3972 case OBJ_SEQDESC :
3973 sdp = (ValNodePtr) ompcp->input_data;
3974 if (sdp != NULL &&
3975 (sdp->choice != Seq_descr_title &&
3976 sdp->choice != Seq_descr_comment &&
3977 sdp->choice != Seq_descr_name &&
3978 sdp->choice != Seq_descr_region)) {
3979 return OM_MSG_RET_ERROR;
3980 }
3981 if (sdp != NULL) {
3982 subtype = sdp->choice;
3983 }
3984 break;
3985 case OBJ_BIOSEQ :
3986 break;
3987 case OBJ_BIOSEQSET :
3988 break;
3989 case 0 :
3990 break;
3991 default :
3992 return OM_MSG_RET_ERROR;
3993 }
3994 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
3995 ompcp->input_itemtype, ompcp->proc->procid);
3996 if (omudp != NULL) {
3997 vfp = (VisStrFormPtr) omudp->userdata.ptrvalue;
3998 if (vfp != NULL) {
3999 Select (vfp->form);
4000 }
4001 return OM_MSG_RET_DONE;
4002 }
4003 if (sdp == NULL) {
4004 subtype = proc->subinputtype;
4005 }
4006 if (subtype == Seq_descr_title) {
4007 w = (WindoW) CreateVisStrForm (-50, -33, "Title",
4008 subtype, VisStrDescFormActnProc, sdp);
4009 } else if (subtype == Seq_descr_comment) {
4010 w = (WindoW) CreateVisStrForm (-50, -33, "Comment",
4011 subtype, VisStrDescFormActnProc, sdp);
4012 } else if (subtype == Seq_descr_name) {
4013 w = (WindoW) CreateVisStrForm (-50, -33, "Name",
4014 subtype, VisStrDescFormActnProc, sdp);
4015 } else if (subtype == Seq_descr_region) {
4016 w = (WindoW) CreateVisStrForm (-50, -33, "Region",
4017 subtype, VisStrDescFormActnProc, sdp);
4018 } else {
4019 return OM_MSG_RET_ERROR;
4020 }
4021 vfp = (VisStrFormPtr) GetObjectExtra (w);
4022 if (vfp != NULL) {
4023 vfp->input_entityID = ompcp->input_entityID;
4024 vfp->input_itemID = ompcp->input_itemID;
4025 vfp->input_itemtype = ompcp->input_itemtype;
4026 vfp->this_itemtype = OBJ_SEQDESC;
4027 vfp->this_subtype = subtype;
4028 vfp->procid = ompcp->proc->procid;
4029 vfp->proctype = ompcp->proc->proctype;
4030 vfp->userkey = OMGetNextUserKey ();
4031 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
4032 OMPROC_EDIT, vfp->userkey);
4033 if (omudp != NULL) {
4034 omudp->userdata.ptrvalue = (Pointer) vfp;
4035 omudp->messagefunc = StdVibrantEditorMsgFunc;
4036 }
4037 SendMessageToDialog (vfp->data, VIB_MSG_INIT);
4038 if (sdp != NULL) {
4039 PointerToDialog (vfp->data, (Pointer) sdp->data.ptrvalue);
4040 SetClosestParentIfDuplicating ((BaseFormPtr) vfp);
4041 }
4042 }
4043 Show (w);
4044 Select (w);
4045 return OM_MSG_RET_DONE;
4046 }
4047
4048 #ifdef OS_UNIX_DARWIN
4049 /* avoid a namespace conflict with Carbon's DateTimeUtils.h */
4050 # define DateForm nlm_DateForm
4051 #endif
4052
4053 typedef struct dateform {
4054 DESCRIPTOR_FORM_BLOCK
4055 } DateForm, PNTR DateFormPtr;
4056
DateFormMessage(ForM f,Int2 mssg)4057 static void DateFormMessage (ForM f, Int2 mssg)
4058
4059 {
4060 DateFormPtr dfp;
4061
4062 dfp = (DateFormPtr) GetObjectExtra (f);
4063 if (dfp != NULL) {
4064 switch (mssg) {
4065 case VIB_MSG_CLOSE :
4066 Remove (f);
4067 break;
4068 case VIB_MSG_CUT :
4069 StdCutTextProc (NULL);
4070 break;
4071 case VIB_MSG_COPY :
4072 StdCopyTextProc (NULL);
4073 break;
4074 case VIB_MSG_PASTE :
4075 StdPasteTextProc (NULL);
4076 break;
4077 case VIB_MSG_DELETE :
4078 StdDeleteTextProc (NULL);
4079 break;
4080 default :
4081 if (dfp->appmessage != NULL) {
4082 dfp->appmessage (f, mssg);
4083 }
4084 break;
4085 }
4086 }
4087 }
4088
CreateDateForm(Int2 left,Int2 top,CharPtr title,FormActnFunc actproc)4089 extern ForM CreateDateForm (Int2 left, Int2 top, CharPtr title,
4090 FormActnFunc actproc)
4091
4092 {
4093 ButtoN b;
4094 GrouP c;
4095 DateFormPtr dfp;
4096 GrouP g;
4097 StdEditorProcsPtr sepp;
4098 WindoW w;
4099
4100 w = NULL;
4101 dfp = (DateFormPtr) MemNew (sizeof (DateForm));
4102 if (dfp != NULL) {
4103 w = FixedWindow (left, top, -10, -10, title, StdCloseWindowProc);
4104 SetObjectExtra (w, dfp, StdDescFormCleanupProc);
4105 dfp->form = (ForM) w;
4106 dfp->actproc = actproc;
4107 dfp->formmessage = DateFormMessage;
4108
4109 #ifndef WIN_MAC
4110 CreateStdEditorFormMenus (w);
4111 #endif
4112
4113 sepp = (StdEditorProcsPtr) GetAppProperty ("StdEditorForm");
4114 if (sepp != NULL) {
4115 SetActivate (w, sepp->activateForm);
4116 dfp->appmessage = sepp->handleMessages;
4117 }
4118
4119 g = HiddenGroup (w, -1, 0, NULL);
4120 dfp->data = CreateDateDialog (g, NULL);
4121
4122 c = HiddenGroup (w, 2, 0, NULL);
4123 b = PushButton (c, "Accept", StdAcceptFormButtonProc);
4124 SetObjectExtra (b, dfp, NULL);
4125 PushButton (c, "Cancel", StdCancelButtonProc);
4126 AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
4127 RealizeWindow (w);
4128 }
4129 return (ForM) w;
4130 }
4131
DateGenFunc(Pointer data)4132 extern Int2 LIBCALLBACK DateGenFunc (Pointer data)
4133
4134 {
4135 DateFormPtr dfp;
4136 Uint2 itemtype = 0;
4137 OMProcControlPtr ompcp;
4138 OMUserDataPtr omudp;
4139 ObjMgrProcPtr proc;
4140 ValNodePtr sdp;
4141 CharPtr title;
4142 Uint2 subtype = 0;
4143 WindoW w;
4144
4145 ompcp = (OMProcControlPtr) data;
4146 sdp = NULL;
4147 itemtype = 0;
4148 subtype = 0;
4149 if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
4150 title = "Date";
4151 proc = ompcp->proc;
4152 switch (ompcp->input_itemtype) {
4153 case OBJ_SEQDESC :
4154 sdp = (ValNodePtr) ompcp->input_data;
4155 if (sdp != NULL &&
4156 (sdp->choice != Seq_descr_create_date &&
4157 sdp->choice != Seq_descr_update_date)) {
4158 return OM_MSG_RET_ERROR;
4159 }
4160 itemtype = OBJ_SEQDESC;
4161 if (sdp != NULL) {
4162 subtype = sdp->choice;
4163 }
4164 break;
4165 case OBJ_BIOSEQ :
4166 break;
4167 case OBJ_BIOSEQSET :
4168 break;
4169 case 0 :
4170 break;
4171 default :
4172 return OM_MSG_RET_ERROR;
4173 }
4174 omudp = ItemAlreadyHasEditor (ompcp->input_entityID, ompcp->input_itemID,
4175 ompcp->input_itemtype, ompcp->proc->procid);
4176 if (omudp != NULL) {
4177 dfp = (DateFormPtr) omudp->userdata.ptrvalue;
4178 if (dfp != NULL) {
4179 Select (dfp->form);
4180 }
4181 return OM_MSG_RET_DONE;
4182 }
4183 if (sdp != NULL) {
4184 if (sdp->choice == Seq_descr_create_date) {
4185 title = "Create Date";
4186 } else {
4187 title = "Update Date";
4188 }
4189 } else {
4190 itemtype = proc->inputtype;
4191 subtype = proc->subinputtype;
4192 if (itemtype == OBJ_SEQDESC && subtype == Seq_descr_create_date) {
4193 title = "Create Date";
4194 } else if (itemtype == OBJ_SEQDESC && subtype == Seq_descr_update_date) {
4195 title = "Update Date";
4196 } else {
4197 return OM_MSG_RET_ERROR;
4198 }
4199 }
4200 w = (WindoW) CreateDateForm (-50, -33, title, StdDescFormActnProc);
4201 dfp = (DateFormPtr) GetObjectExtra (w);
4202 if (dfp != NULL) {
4203 dfp->input_entityID = ompcp->input_entityID;
4204 dfp->input_itemID = ompcp->input_itemID;
4205 dfp->input_itemtype = ompcp->input_itemtype;
4206 dfp->this_itemtype = itemtype;
4207 dfp->this_subtype = subtype;
4208 dfp->procid = ompcp->proc->procid;
4209 dfp->proctype = ompcp->proc->proctype;
4210 dfp->userkey = OMGetNextUserKey ();
4211 omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
4212 OMPROC_EDIT, dfp->userkey);
4213 if (omudp != NULL) {
4214 omudp->userdata.ptrvalue = (Pointer) dfp;
4215 omudp->messagefunc = StdVibrantEditorMsgFunc;
4216 }
4217 SendMessageToDialog (dfp->data, VIB_MSG_INIT);
4218 if (sdp != NULL) {
4219 PointerToDialog (dfp->data, (Pointer) sdp->data.ptrvalue);
4220 SetClosestParentIfDuplicating ((BaseFormPtr) dfp);
4221 }
4222 }
4223 Show (w);
4224 Select (w);
4225 return OM_MSG_RET_DONE;
4226 }
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239