1 /*===========================================================================
2 *
3 * PUBLIC DOMAIN NOTICE
4 * National Center for Biotechnology Information
5 *
6 * This software/database is a "United States Government Work" under the
7 * terms of the United States Copyright Act. It was written as part of
8 * the author's official duties as a United States Government employee and
9 * thus cannot be copyrighted. This software/database is freely available
10 * to the public for use. The National Library of Medicine and the U.S.
11 * Government have not placed any restriction on its use or reproduction.
12 *
13 * Although all reasonable efforts have been taken to ensure the accuracy
14 * and reliability of the software and data, the NLM and the U.S.
15 * Government do not and cannot warrant the performance or results that
16 * may be obtained by using this software or data. The NLM and the U.S.
17 * Government disclaim all warranties, express or implied, including
18 * warranties of performance, merchantability or fitness for any particular
19 * purpose.
20 *
21 * Please cite the author in any work or product based on this material.
22 *
23 * ===========================================================================
24 *
25 * File Name: interface.c
26 *
27 * Author: Yanli Wang
28 *
29 * Initial Version Creation Date: 03/09/1997
30 *
31 * File Description:
32 * An interactive tool for taxonomy assignment to structure sequence
33 *
34 *
35 * Modifications:
36 * --------------------------------------------------------------------------
37 * $Log: interface.c,v $
38 * Revision 1.1 2002/12/17 15:13:43 ywang
39 * pdbeast related tools updated
40 *
41 *
42 * ==========================================================================
43 */
44
45 #include <vibrant.h>
46 #include <document.h>
47 #include <ncbi.h>
48 #include <ncbistr.h>
49 #include <taxinc.h>
50 #include <objseq.h>
51 #include <objsset.h>
52 #include <objfeat.h>
53 #include <objblock.h>
54
55 #include "para.h"
56 #include "interface.h"
57
58
59 Args myargs[8] = {
60 {"Text Input Seq-entry File Directory","/net/keystone/usr/people/ywang/work/taxonomy/RawBioseq/", NULL,NULL,TRUE,'h',ARG_STRING,0.0,0,NULL},
61 {"Binary Input Seq-entry File Directory","/net/clobber/usr/people8/bryant/MMDB.Bioseq/", NULL,NULL,TRUE,'i',ARG_STRING,0.0,0,NULL},
62 {"Text Output Seq-entry File Directory","/net/keystone/usr/people/ywang/work/taxonomy/Bioseq_text/", NULL,NULL,TRUE,'n',ARG_STRING,0.0,0,NULL},
63 {"Binary Output Seq-entry File Directory","/net/keystone/usr/people/ywang/work/taxonomy/Bioseq_binary/", NULL,NULL,TRUE,'o',ARG_STRING,0.0,0,NULL},
64 {"PDB File Directory","/usr/ncbi/db/pdb/Mirror/Current/", NULL,NULL,TRUE,'p',ARG_STRING,0.0,0,NULL},
65 {"Entry Code List File Directory","/net/keystone/usr/people/ywang/work/taxonomy/index/", NULL,NULL,TRUE,'b',ARG_STRING,0.0,0,NULL},
66 {"List File Name","all.OCT96", NULL,NULL,TRUE,'c',ARG_FILE_IN,0.0,0,NULL},
67 {"Log errors to file named:","log.pdbeast.April",NULL,NULL,TRUE,'l',ARG_FILE_OUT, 0.0,0,NULL}};
68
69 extern Char EntryCode[120];
70 extern Char pdbsource_str[10240];
71 extern OrgRefPtr my_org;
72 extern OrgRefPtr my_org_chain[MaxChainNum];
73 extern Int4 nchain;
74 extern Char chain[MaxChainNum];
75 extern Boolean chain_assign[MaxChainNum];
76 extern Char chain_orgName[MaxChainNum][120];
77 extern Char CurrentOrgName[120];
78 extern Char selected_chain, last_click_chain;
79 extern Int2 selected_chain_num;
80 extern Boolean AllAssign, PartAssign;
81 extern Boolean SingleChain;
82 extern Boolean TextInEntry, TextOutEntry;
83 extern Boolean TaxAssign, EntryOpen;
84 extern Boolean SingleEntry, EntryFromList;
85 extern Boolean BioOrg_chain[MaxChainNum];
86
87 static ButtoN accept;
88 static ButtoN ListEntry_start;
89 static ButtoN ListEntry_next;
90 static ButtoN ListEntry_specific;
91 static ButtoN Entry_accept;
92 ButtoN Tax_accept;
93 ButtoN Tax_all_accept;
94 ButtoN Tax_part_accept;
95 ButtoN Tax_finish;
96 ButtoN Tax_reject;
97 ButtoN ReLookup_accept;
98 ButtoN ReLookup_reject;
99 ButtoN PdbOpen;
100 ButtoN PdbClose;
101 static ButtoN Source_string_accept;
102 static ButtoN Pdbfile_string_accept;
103 static GrouP category;
104 static PaneL drawing;
105 static GrouP features;
106 static TexT species;
107 static TexT Entry_code;
108 static TexT Source_string;
109 static TexT Pdbfile_string;
110 static ButtoN check[4];
111 static PoinT lastPt;
112 static MenU s1;
113 static MenU s2;
114 static MenU s3;
115 static LisT l;
116 static GrouP infilemode;
117 static GrouP outfilemode;
118
119 static LisT lBlastChain;
120 static ButtoN BlastSearchAccept;
121
122 static InitProc();
123 static void QuitProc(IteM i);
124 static void EnableProc(GraphiC g);
125 static void AcceptProc(ButtoN b);
126 static void ListProc(LisT l);
127 static void ButtonProc(ButtoN b);
128 static void MenuProc(IteM i);
129 static void ListOpenProc(ChoicE c);
130 static void EntryProc(IteM i);
131 static void EntryOpenProc(ButtoN b);
132 static void AddStringProc(ButtoN b);
133 static void ReLookupProc(ButtoN b);
134 static void TaxAcceptProc(ButtoN b);
135 static void SourceStringAcceptProc(ButtoN b);
136 static void PdbfileStringAcceptProc(ButtoN b);
137 static void ReLookupRejectProc(ButtoN b);
138 static void TaxAllAcceptProc(ButtoN b);
139 static void TaxPartAcceptProc(ButtoN b);
140 static void TaxPartAssignProc(LisT lchain);
141 static void TaxFinishProc(ButtoN b);
142 static void PdbOpenProc(ButtoN b);
143 static void PdbCloseProc(ButtoN b);
144 static void ListEntryStartProc(ButtoN b);
145 static void ListEntryNextProc(ButtoN b);
146 static void ListEntrySpecificProc(ButtoN b);
147 static void InFileTypeProc(GrouP infilemode);
148 static void OutFileTypeProc(GrouP outfilemode);
149 static void ListUpdateProc(ChoicE c);
150
151 static void ListBlastChainProc(LisT l);
152 static void BlastSearchAcceptProc(ButtoN b);
153
154 /*-------------- main starts here --------------------------*/
Main(void)155 extern Int2 Main (void)
156 {
157
158 RecT r1, r2;
159
160 #ifdef WIN_MAC
161 m = AppleMenu (NULL);
162 DeskAccGroup(m);
163 m = PulldownMenu(NULL, "File");
164
165 s = SubMenu(m, "Open");
166 i = CommandItem(m, "Quit/Q", QuitProc);
167 #endif
168
169 InitProc(GetArgc(), GetArgv());
170
171 w = RoundWindow(-50, -33, -10, -10, "PDBeast: Taxonomy Assignment", NULL);
172
173 #ifndef WIN_MAC
174
175 SetUpDrawingTools();
176 /* Red();
177 SetColor(5); */
178 InvertColors();
179
180 wpdb = RoundWindow(-53, -33, -10, -10, "PDB File Display", NULL);
181 p = StaticPrompt(wpdb, "Pdb File", 0, dialogTextHeight, systemFont, '1');
182 Advance(wpdb);
183 PdbOpen = DefaultButton(wpdb, "Open", PdbOpenProc);
184 Break(wpdb);
185
186 p = StaticPrompt(wpdb, "Blast Search", 0, dialogTextHeight, systemFont, '1');
187 Advance(wpdb);
188 lBlastChain = SingleList(wpdb, 10, 3, ListBlastChainProc);
189 Advance(wpdb);
190 BlastSearchAccept = DefaultButton(wpdb, "Send Query", BlastSearchAcceptProc);
191 Break(wpdb);
192
193 p = StaticPrompt(wpdb, "String Search", 0, dialogTextHeight, systemFont, '1');
194 Advance(wpdb);
195 Pdbfile_string = DialogText(wpdb, "", 15, NULL);
196 Advance(wpdb);
197 Pdbfile_string_accept = DefaultButton(wpdb, "Find", PdbfileStringAcceptProc);
198 Break(wpdb);
199
200 pdbfile_panel = DocumentPanel(wpdb, 650, 20*stdLineHeight);
201 Break(wpdb);
202 p = StaticPrompt(wpdb," ", 0, dialogTextHeight, systemFont, '1');
203 Advance(wpdb);
204 PdbClose = PushButton(wpdb,"Close", PdbCloseProc);
205 Break(wpdb);
206
207 m = PulldownMenu(w, "File");
208 s1 = SubMenu(m, "Open");
209 i = CommandItem(s1, "Entry", EntryProc);
210 s2 = SubMenu(s1, "List");
211 c = ChoiceGroup(s2, ListOpenProc);
212 ChoiceItem(c, myargs[6].strvalue);
213
214 /* s3 = SubMenu(m, "Update");
215 c = ChoiceGroup(s3, ListUpdateProc);
216 ChoiceItem(c, myargs[6].strvalue); */
217
218 i = CommandItem(m, "Quit/Q", QuitProc);
219
220 /* edit = PulldownMenu(w, "Edit");
221 i = CommandItem(edit, "cut", StdCutTextProc);
222 i = CommandItem(edit, "copy", StdCopyTextProc);
223 i = CommandItem(edit, "paste", StdPasteTextProc); */
224 #endif
225
226 infilemode = NormalGroup(w, 3, 0, "Data Mode of Input Entry",systemFont, InFileTypeProc);
227 RadioButton(infilemode, "Text");
228 RadioButton(infilemode, "Binary");
229 /* SafeSetValue(infilemode, 2); */
230 GetPosition(infilemode, &r1);
231
232 outfilemode = NormalGroup(w, 3, 0, "Data Mode of Output Entry",systemFont, OutFileTypeProc);
233 RadioButton(outfilemode, "Text");
234 RadioButton(outfilemode, "Binary");
235 /* SafeSetValue(outfilemode, 2); */
236 r2.top = r1.top; r2.bottom = r1.bottom;
237 r2.left = r1.right + 80;
238 r2. right = r2.left + r1.right - r1.left;
239 SetPosition(outfilemode, &r2);
240 Break(w);
241
242 p = StaticPrompt(w, "Seq-entry", 0, dialogTextHeight, systemFont, '1');
243 Advance (w);
244 l = SingleList(w, 20, 3, ListProc);
245 Disable(l);
246 Advance(w);
247 ListEntry_start = DefaultButton(w, "Start", ListEntryStartProc);
248 Disable(ListEntry_start);
249 Advance(w);
250 ListEntry_next = DefaultButton(w, "Next", ListEntryNextProc);
251 Disable(ListEntry_next);
252 Advance(w);
253 ListEntry_specific = DefaultButton(w, "Specific", ListEntrySpecificProc);
254 Disable(ListEntry_specific);
255 Break(w);
256
257 p = StaticPrompt(w, "Enter Entry Code", 0, dialogTextHeight, systemFont, '1');
258 Advance (w);
259 Entry_code = DialogText(w, "", 15, (TxtActnProc) EnableProc);
260 Select(Entry_code);
261 Advance (w);
262 Entry_accept = DefaultButton(w, "Open", EntryOpenProc);
263 Disable(Entry_accept);
264 Break(w);
265
266 p = StaticPrompt(w, "Chain", 0, dialogTextHeight, systemFont, '1');
267 chain_panel = DocumentPanel(w, 200, stdLineHeight);
268 Break(w);
269 p = StaticPrompt(w, "Pdb Source:", 0, dialogTextHeight, systemFont, '1');
270 pdb_source = ScrollText(w, 38, 3, systemFont, TRUE, NULL);
271 Advance(w);
272 Break(w);
273 p = StaticPrompt(w, "Taxonomy Data:", 0, dialogTextHeight, systemFont, '1');
274 org = DocumentPanel(w,400,6*stdLineHeight);
275 Break(w);
276
277 p = StaticPrompt(w, "Taxonomy Accept?", 0, dialogTextHeight, systemFont, '1');
278 Break(w);
279 Tax_accept = DefaultButton(w, "Yes", TaxAcceptProc);
280 Advance(w);
281 p = StaticPrompt(w, "to ", 0, dialogTextHeight, systemFont, '1');
282 Advance(w);
283 Tax_all_accept = DefaultButton(w, "All", TaxAllAcceptProc);
284 Disable(Tax_all_accept);
285 Advance(w);
286 p = StaticPrompt(w, " or ", 0, dialogTextHeight, systemFont, '1');
287 Advance(w);
288 Tax_part_accept = DefaultButton(w, "Chain", TaxPartAcceptProc);
289 Disable(Tax_part_accept);
290 Advance(w);
291 lchain = SingleList(w, 2, 4, TaxPartAssignProc);
292 Advance(w);
293 Tax_finish = DefaultButton(w, "All Done", TaxFinishProc);
294 Disable(Tax_finish);
295 Break(w);
296 Tax_reject = DefaultButton(w, "No", ReLookupProc);
297 Disable(Tax_accept);
298 Disable(Tax_reject);
299 Break(w);
300
301 p = StaticPrompt(w, "Look up Taxonomy Database with another String?", 0, dialogTextHeight, systemFont, '1');
302 Advance(w);
303 ReLookup_accept = DefaultButton(w, "Yes", AddStringProc);
304 Advance(w);
305 ReLookup_reject = DefaultButton(w, "No", ReLookupRejectProc);
306 Disable(ReLookup_accept);
307 Disable(ReLookup_reject);
308 Break(w);
309
310 p = StaticPrompt(w,"Search Taxonomy Database with", 0, dialogTextHeight, systemFont, '1');
311 Advance(w);
312 Source_string = DialogText(w, "", 15, NULL);
313 Advance(w);
314 Source_string_accept = DefaultButton(w, "Start", SourceStringAcceptProc);
315 Disable(Source_string_accept);
316 Break(w);
317
318 Show(w);
319 Show(wpdb);
320 ProcessEvents();
321
322 return 0;
323 }
324 /*-------------------------------------------------*/
PrintArg()325 PrintArg(){
326
327 printf("\t -aid Text Input Seq-entry File Directory\n");
328 printf("\t -bid Binary Input Seq-entry File Directory\n");
329 printf("\t -aod Text Output Seq-entry File Directory\n");
330 printf("\t -bod Binary Output Seq-entry File Directory\n");
331 printf("\t -PDBpath PDB File Directory\n");
332 printf("\t -ListPath Entry Code List File Directory\n");
333 printf("\t -ListName Entry Code List File Name\n");
334 printf("\t -Logfile File Name For Log Errors\n");
335 printf("\t -im Input File Mode: 'a' for text / 'b' for binary \n");
336 printf("\t -om Output File Mode: 'a' for text /'b' for binary \n");
337
338 return;
339
340 }
341 /*-------------- Initialize -----------------------*/
InitProc(argc,argv)342 static InitProc(argc, argv)
343 int argc;
344 char *argv[];
345 {
346
347 Char listname[120], Command[120], str[120];
348 Char my_argu[120];
349
350 /* if (!GetArgs("PDBeast", 8, myargs)) return 1; */ /* turn off window args */
351
352 TextInEntry = FALSE;
353 TextOutEntry = FALSE;
354
355
356 if(argc == 1){
357 PrintArg();
358 exit (1);
359 }
360 else{
361 while(--argc > 0){
362 *++argv;
363 if(StringCmp(*argv, "-aid") == 0) {
364 sscanf(*++argv, "%s", my_argu);
365 myargs[0].strvalue = StringSave(my_argu);
366 }
367 else if (StringCmp(*argv, "-bid") == 0) {
368 sscanf(*++argv, "%s", my_argu);
369 myargs[1].strvalue = StringSave(my_argu);
370 }
371 else if (StringCmp(*argv, "-aod") == 0) {
372 sscanf(*++argv, "%s", my_argu);
373 myargs[2].strvalue = StringSave(my_argu);
374 }
375 else if (StringCmp(*argv, "-bod") == 0) {
376 sscanf(*++argv, "%s", my_argu);
377 myargs[3].strvalue = StringSave(my_argu);
378 }
379 else if (StringCmp(*argv, "-PDBpath") == 0) {
380 sscanf(*++argv, "%s", my_argu);
381 myargs[4].strvalue = StringSave(my_argu);
382 }
383 else if (StringCmp(*argv, "-ListPath") == 0) {
384 sscanf(*++argv, "%s", my_argu);
385 myargs[5].strvalue = StringSave(my_argu);
386 }
387 else if (StringCmp(*argv, "-ListName") == 0) {
388 sscanf(*++argv, "%s", my_argu);
389 myargs[6].strvalue = StringSave(my_argu);
390 }
391 else if (StringCmp(*argv, "-Logfile") == 0) {
392 sscanf(*++argv, "%s", my_argu);
393 myargs[7].strvalue = StringSave(my_argu);
394 }
395 else if (StringCmp(*argv, "-im") == 0) {
396 sscanf(*++argv, "%s", str);
397 if(StringCmp(str, "a") == 0) TextInEntry = TRUE;
398 else if(StringCmp(str, "b") == 0) TextInEntry = FALSE;
399 }
400 else if (StringCmp(*argv, "-om") == 0) {
401 sscanf(*++argv, "%s", str);
402 if(StringCmp(str, "a") == 0) TextOutEntry = TRUE;
403 else if(StringCmp(str, "b") == 0)TextOutEntry = FALSE;
404 }
405 }
406 }
407
408
409 printf("calling Init\n");
410 Init();
411 printf("returned from Init\n");
412
413 log_pdbeast = FileOpen(myargs[7].strvalue, "w");
414
415 StringCpy(listname, myargs[5].strvalue);
416 StringCat(listname, myargs[6].strvalue);
417
418 /* if(FileLength(listname) != 0){
419 sprintf(Command, "cp %s %s.bak", listname, listname);
420 system(Command);
421 } */
422
423 }
424 /*-------------------------------------------------*/
DoListUpdate()425 void DoListUpdate()
426 {
427
428 Int4 n = 0;
429 Char fullname[120], str[120];
430
431 SetValue(c, 0);
432
433 StringCpy(fullname, myargs[5].strvalue);
434 StringCat(fullname, myargs[6].strvalue);
435 seq_list = FileOpen(fullname, "r");
436
437 if(seq_list == NULL) {
438 Message(MSG_OK, "File %s can not be opened!", fullname);
439 return;
440 }
441
442 entry_num = 0;
443 while(feof(seq_list) == 0){
444
445 if(fscanf(seq_list, "%s", str) == EOF) break;
446
447 sscanf(str, "%4s", seq_entry[entry_num]);
448
449 if(StringLen(EntryCode) != 0) {
450 if(StringNCmp(seq_entry[entry_num], EntryCode, 4) != 0){
451 sscanf(str + 4, "%c\n", &seq_entry_TaxState[entry_num]);
452 }
453 }
454
455 entry_num++;
456 }
457
458
459 FileClose(seq_list);
460
461 seq_list = FileOpen(fullname, "w");
462
463 if(seq_list == NULL) {
464 Message(MSG_OK, "File %s can not be opened!", fullname);
465 return;
466 }
467
468 n = 0;
469
470 for(n = 0 ; n < entry_num; n++){
471 fprintf(seq_list, "%4s%c\n", seq_entry[n], seq_entry_TaxState[n]);
472 }
473
474 FileClose(seq_list);
475 }
476 /*-------------------------------------------------*/
CheckUpdate()477 void CheckUpdate()
478 {
479
480 MsgAnswer ans;
481
482 if(EntryListOn){
483 ans = Message(MSG_YN, "Do you want to update control list?");
484 if(ans == ANS_YES){
485 DoListUpdate();
486 EntryListOn = FALSE;
487 return;
488 }
489
490 }
491
492 return;
493
494 }
495 /*------------------------------------------------------------------*/
QuitProc(IteM i)496 static void QuitProc(IteM i)
497 {
498
499 /* CheckUpdate(); */
500
501 Close();
502
503 FileClose(log_pdbeast);
504
505 QuitProgram();
506 }
507 /*------------------------------------------------------------------*/
EnableProc(GraphiC g)508 static void EnableProc(GraphiC g)
509 {
510 Char str[32];
511 GetTitle (species, str, sizeof(str));
512 if (StringLen(str) == 0 || GetValue(category) == 0)
513 {
514 Disable (accept);
515 }
516 else
517 {
518 Enable (accept);
519 }
520 }
521 /*------------------------------------------------------------------*/
ButtonProc(ButtoN b)522 static void ButtonProc(ButtoN b) {
523 }
524 /*------------------------------------------------------------------*/
ListProc(LisT l)525 static void ListProc(LisT l) {
526 Int2 val;
527
528 val = GetValue(l);
529 if(val == 0) printf("Chose one entry from the list to start, please!\n");
530 else {
531
532 Enable(ListEntry_start);
533 Enable(ListEntry_next);
534 Enable(ListEntry_specific);
535 }
536
537 }
538 /*-----------------------------------------------------------------*/
CheckProc(Int2 current_zone)539 Int2 CheckProc(Int2 current_zone)
540 {
541 MsgAnswer ans;
542
543 if( !TaxAssign) {
544 if(StringLen(EntryCode) != 0){
545 CloseCurrentEntry();
546 if(current_zone == 3) {
547 Message(MSG_OK, "Taxonomy has NOT been assigned for previous entry ' %s ', You may do it again later! ", EntryCode);
548 fprintf(log_pdbeast, "Taxonomy has NOT been assigned for %s\n\n", EntryCode);
549 return(1);
550 }
551 else if(current_zone == 1) {
552 Message(MSG_OK, "Taxonomy has NOT been assigned forprevious entry ' %s ', You may do it again later by using the Specific button! ", EntryCode);
553 fprintf(log_pdbeast, "Taxonomy has NOT been assigned for %s\n\n", EntryCode);
554 return(1);
555 }
556 else {
557 ans = Message(MSG_YN, "Taxonomy has NOT been assigned for current entry ' %s ', Do you want to skip and revise later?", EntryCode);
558 if (ans == ANS_YES) {
559 seq_entry_TaxState[index_num[current_seq_entry_num]] = '?';
560 if(EntryFromList) DoListUpdate();
561 fprintf(log_pdbeast, "Taxonomy has NOT been assigned for %s\n\n", EntryCode);
562 return(1);
563 }
564 else {
565 Message(MSG_OK, " Click on Start ", EntryCode);
566 redo = TRUE;
567
568 return(-1);
569 }
570 }
571 }
572 }
573
574 return;
575
576 }
577 /*------------------------------------------------------------------*/
ListOpenProc(ChoicE c)578 static void ListOpenProc(ChoicE c)
579 {
580 Int4 val,n;
581 Int4 unassign_seq_num;
582
583 Char fullname[120];
584 Char str[120];
585
586 /* CheckUpdate(); */
587
588 Disable(ListEntry_start);
589 Disable(ListEntry_next);
590 Disable(ListEntry_specific);
591
592 Hide(Entry_code);
593 Reset(Entry_code);
594 Show(Entry_code);
595 Disable(Entry_accept);
596
597 current_seq_entry_num = 0;
598
599 StringCpy(fullname, myargs[5].strvalue);
600 StringCat(fullname, myargs[6].strvalue);
601
602 seq_list = FileOpen(fullname, "r");
603 if(seq_list == NULL){
604 Message(MSG_OK, " Entry list file ' %s ' not found!", fullname);
605 exit(1);
606 }
607 else{
608 entry_num = 0;
609
610 while(feof(seq_list) == 0){
611
612 if(fscanf(seq_list, "%s", str) == EOF) break;
613 sscanf(str, "%4s%c", seq_entry[entry_num], &seq_entry_TaxState[entry_num]);
614
615 entry_num++;
616
617 }
618 }
619
620 FileClose(seq_list);
621
622 Hide(l);
623 Reset(l);
624 Show(l);
625
626 SetValue(l, 0);
627 SetValue(c, 0);
628
629 unassign_seq_num = 0;
630
631 for( n = 0; n <= entry_num; n++){
632 if(seq_entry_TaxState[n] != '+' && seq_entry_TaxState[n] != '*'){
633 ListItem(l, seq_entry[n]);
634 index_num[unassign_seq_num] = n;
635 unassign_seq_num++;
636 }
637 }
638
639 Enable(l);
640
641 EntryListOn = TRUE;
642
643 Message(MSG_OK, "Chose one entry from the current list and click button Start please!");
644
645
646 }
647 /*------------------------------------------------------------------*/
ListUpdateProc(ChoicE c)648 static void ListUpdateProc(ChoicE c)
649 {
650
651 DoListUpdate();
652
653 }
654 /*------------------------------------------------------------------*/
EntryProc(IteM i)655 static void EntryProc(IteM i)
656 {
657
658 /* CheckUpdate(); */
659
660 Hide(l);
661 Reset(l);
662 Show(l);
663 Disable(ListEntry_start);
664 Disable(ListEntry_next);
665 Disable(ListEntry_specific);
666
667 Hide(Entry_code);
668 Reset(Entry_code);
669 Show(Entry_code);
670 Enable(Entry_accept);
671
672 }
673 /*-----------------------------------------------------------------*/
My_Reset1()674 static void My_Reset1()
675 {
676
677 TaxAssign = FALSE;
678 EntryOpen = FALSE;
679
680 Hide(chain_panel);
681 Reset(chain_panel);
682 Show(chain_panel);
683
684 Hide(pdb_source);
685 Reset(pdb_source);
686 Show(pdb_source);
687
688 Hide(org);
689 Reset(org);
690 Show(org);
691
692 Hide(Source_string);
693 Reset(Source_string);
694 Show(Source_string);
695
696 Hide(lchain);
697 Reset(lchain);
698 Show(lchain);
699
700 Hide(pdbfile_panel);
701 Reset(pdbfile_panel);
702 Show(pdbfile_panel);
703
704 Disable(Tax_accept);
705 Disable(Tax_all_accept);
706 Disable(Tax_part_accept);
707 Disable(Tax_finish);
708 Disable(Tax_reject);
709 Disable(ReLookup_accept);
710 Disable(ReLookup_reject);
711 Disable(Source_string_accept);
712
713 }
714 /*------------------------------------------------------------------*/
EntryOpenProc(ButtoN b)715 static void EntryOpenProc(ButtoN b)
716 {
717 Char fullname[120];
718 Int2 current_zone, CheckProcReturn;
719
720
721 current_zone = 3;
722 CheckProcReturn = CheckProc(current_zone);
723 if(CheckProcReturn == -1) return;
724
725 My_Reset1();
726
727 GetTitle(Entry_code, EntryCode, sizeof(EntryCode));
728 printf("Entry Code: %s\n", EntryCode);
729
730 SingleEntry = TRUE;
731 EntryFromList = FALSE;
732 GoToEntry();
733
734 }
735 /*------------------------------------------------------------------*/
AddStringProc(ButtoN b)736 static void AddStringProc(ButtoN b)
737 {
738
739 Enable(Source_string_accept);
740
741 }
742 /*------------------------------------------------------------------*/
ReLookupProc(ButtoN b)743 static void ReLookupProc(ButtoN b)
744 {
745
746 Enable(ReLookup_accept);
747 Enable(ReLookup_reject);
748
749 }
750 /*------------------------------------------------------------------*/
TaxAcceptProc(ButtoN b)751 static void TaxAcceptProc(ButtoN b)
752 {
753
754 if(SingleChain) {
755 AllAssign = TRUE;
756 PartAssign = FALSE;
757
758 Disable(Tax_all_accept);
759 selected_chain =' ';
760
761 if(AssignOrg()){
762 WriteEntry();
763 if(EntryFromList && !SingleEntry) seq_entry_TaxState[index_num[current_seq_entry_num]] = '+';
764 if(EntryFromList) DoListUpdate();
765 }
766
767 Disable(Tax_part_accept);
768 Disable(Tax_accept);
769 Disable(Tax_reject);
770
771
772 }
773
774
775 else {
776 Enable(Tax_all_accept);
777 Enable(Tax_part_accept);
778 }
779
780 Disable(Tax_accept);
781 Disable(Tax_reject);
782
783 }
784 /*-----------------------------------------------------------------*/
TaxAllAcceptProc(ButtoN b)785 static void TaxAllAcceptProc(ButtoN b)
786 {
787 Int2 n;
788
789 AllAssign = TRUE;
790 PartAssign = FALSE;
791
792 Disable(Tax_all_accept);
793 selected_chain =' ';
794
795 for(n = 0; n < nchain; n++){
796 chain_assign[n] = TRUE;
797 }
798
799 if(AssignOrg()){
800 WriteEntry();
801 if(EntryFromList && !SingleEntry) seq_entry_TaxState[index_num[current_seq_entry_num]] = '+';
802 if(EntryFromList) DoListUpdate();
803 }
804
805 Disable(Tax_part_accept);
806 Disable(Tax_accept);
807 Disable(Tax_reject);
808
809 }
810 /*------------------------------------------------------------------*/
TaxPartAcceptProc(ButtoN b)811 static void TaxPartAcceptProc(ButtoN b)
812 {
813
814 Int2 n;
815 Char single_chain;
816
817 Hide(lchain);
818 Reset(lchain);
819 Show(lchain);
820
821 Enable(Tax_finish);
822 Disable(Tax_all_accept);
823 Enable(ReLookup_accept);
824 Enable(ReLookup_reject);
825
826 AllAssign = FALSE;
827 PartAssign = TRUE;
828
829
830 for(n = 0; n < nchain; n++){
831 single_chain = chain[n];
832 ListItem(lchain, &single_chain);
833 }
834
835 }
836 /*------------------------------------------------------------------*/
SourceStringAcceptProc(ButtoN b)837 static void SourceStringAcceptProc(ButtoN b)
838 {
839
840 Char str[1024];
841
842 GetTitle(Source_string, str, sizeof(str));
843 if (StringLen(str) == 0) Disable(Source_string_accept);
844 else{
845 StringCpy(pdbsource_str, str);
846 my_org = (OrgRefPtr) GetOrgRef(pdbsource_str);
847 }
848
849 }
850 /*------------------------------------------------------------------*/
ReLookupRejectProc(ButtoN b)851 static void ReLookupRejectProc(ButtoN b)
852 {
853
854 Disable(Tax_accept);
855 Disable(Tax_reject);
856 Disable(ReLookup_accept);
857 Disable(ReLookup_reject);
858 Disable(Source_string_accept);
859 Disable(ReLookup_reject);
860 }
861 /*-----------------------------------------------------------------*/
TaxPartAssignProc(LisT lchain)862 static void TaxPartAssignProc(LisT lchain)
863 {
864
865 Int2 val;
866 MsgAnswer ans;
867
868 /* AllAssign = FALSE;
869 PartAssign = TRUE; */
870
871 val = GetValue(lchain);
872
873 selected_chain_num = val - 1;
874 selected_chain = chain[selected_chain_num];
875
876 if(chain_assign[selected_chain_num]){
877 ans = Message(MSG_YN, "Tax for chain '%c' has been assigned as ' %s ', do you want to reassign?", chain[selected_chain_num], chain_orgName[selected_chain_num]);
878 if(ans == ANS_NO) return;
879 }
880
881 my_org_chain[selected_chain_num] = AsnIoMemCopy(my_org, (AsnReadFunc) OrgRefAsnRead, (AsnWriteFunc) OrgRefAsnWrite);
882
883 chain_assign[selected_chain_num] = TRUE;
884 StringCpy(chain_orgName[selected_chain_num], CurrentOrgName);
885
886 Message(MSG_POST, "Orgname for chain '%c' is ' %s '\n", chain[selected_chain_num], chain_orgName[selected_chain_num]);
887
888 }
889 /*---------------------------------------------------------*/
TaxFinishProc(ButtoN b)890 static void TaxFinishProc(ButtoN b)
891 {
892 Int2 n, assign = 0, unassign = 0, num_chain_taxed = 0;
893 Char unassigned_chain[1024], chain_taxed[1024], str[12];
894 MsgAnswer ans;
895
896 StringCpy(unassigned_chain, "Chain: ");
897 StringCpy(chain_taxed, " ");
898 for(n = 0; n < nchain; n++){
899 if(!chain_assign[n]){
900 unassign++;
901 sprintf(str, "%c ", chain[n]);
902 StringCat(unassigned_chain, str);
903 if(BioOrg_chain[n]) {
904 StringCat(chain_taxed, str);
905 num_chain_taxed++;
906 }
907 }
908 else assign++;
909 }
910
911 if(unassign > 0){
912 if(num_chain_taxed == 0) ans = Message(MSG_YN, "%s has(have) not been assigned tax, Revise now?", unassigned_chain);
913 else if(unassign == num_chain_taxed) ans = Message(MSG_YN, "%s has(have) not been assigned tax, but they all have predefined tax. Revise now?", unassigned_chain);
914 else if(unassign > num_chain_taxed) ans = Message(MSG_YN, "%s has(have) not been assigned tax. Among which, chain %s has(have) predefined tax. Revise now?", unassigned_chain, chain_taxed);
915
916 if( ans == ANS_YES) return;
917 else {
918 ans = Message(MSG_YN, "Revise later?");
919 if( ans == ANS_YES){
920 if(EntryFromList && !SingleEntry) seq_entry_TaxState[index_num[current_seq_entry_num]] = '?';
921 if(EntryFromList) DoListUpdate();
922 return;
923 }
924 }
925 }
926
927
928 if(AssignOrg()){
929 WriteEntry();
930 if(assign == nchain) seq_entry_TaxState[index_num[current_seq_entry_num]] = '+';
931 else seq_entry_TaxState[index_num[current_seq_entry_num]] = '*';
932 if(EntryFromList) DoListUpdate();
933 }
934
935 Disable(ReLookup_accept);
936 Disable(ReLookup_reject);
937 Disable(Source_string_accept);
938
939 Disable(Tax_all_accept);
940 Disable(Tax_part_accept);
941
942 Disable(Tax_accept);
943 Disable(Tax_reject);
944
945 Disable(Tax_finish);
946
947 }
948 /*---------convert from upper to low case------------*/
IOtolow(s)949 IOtolow( s )
950 char s[];
951 {
952 int m ;
953
954 m = 'a' - 'A';
955 while (*s != '\0') {
956 if( 'A' <= *s && *s <= 'Z' ) *s += m;
957 s++;
958 }
959 }
960 /*-------------- Display ----------------------------------*/
DisplayChainForBlastSearch()961 void DisplayChainForBlastSearch()
962 {
963 Int2 n;
964 Char single_chain;
965
966 Hide(lBlastChain);
967 Reset(lBlastChain);
968 Show(lBlastChain);
969
970 if(nchain == 1) ListItem(lBlastChain, EntryCode);
971 else {
972 for(n = 0; n < nchain; n++){
973 single_chain = chain[n];
974 ListItem(lBlastChain, &single_chain);
975 }
976 }
977
978 }
979 /*-------------- Display ----------------------------------*/
PDBFileDisplay()980 void PDBFileDisplay()
981 {
982 Char pdbfile[120], line[120];
983 Char EntryCode_lc[120];
984 FILE *fp, *fp_log;
985 Char path[PATH_MAX];
986
987 StringCpy(EntryCode_lc, EntryCode);
988 IOtolow(EntryCode_lc);
989
990 StringCpy(pdbfile, myargs[4].strvalue);
991 StringCat(pdbfile, "pdb");
992
993 StringCat(pdbfile, EntryCode_lc);
994 StringCat(pdbfile, ".ent");
995
996 TmpNam (path);
997
998 fp = FileOpen(pdbfile, "r");
999 if( fp != NULL){
1000 fp_log = FileOpen(path, "w");
1001 while(fgets(line, 120, fp)){
1002 if(StringNCmp(line, "ATOM ", 6) == 0) break;
1003 fprintf(fp_log, "%s\n", line);
1004 }
1005
1006 FileClose(fp);
1007 FileClose(fp_log);
1008 DisplayFile(pdbfile_panel, path, programFont);
1009 FileRemove (path);
1010 }
1011 else Message(MSG_OK, "PDB file ' %s ' does not exists!", pdbfile);
1012
1013 }
1014 /*---------------------------------------------------------*/
PdbOpenProc(ButtoN b)1015 static void PdbOpenProc(ButtoN b)
1016 {
1017 PDBFileDisplay();
1018 DisplayChainForBlastSearch();
1019 }
1020 /*--------------------------------------------------------*/
PdbCloseProc(ButtoN b)1021 static void PdbCloseProc(ButtoN b)
1022 {
1023
1024 Hide(pdbfile_panel);
1025 Reset(pdbfile_panel);
1026 Show(pdbfile_panel);
1027
1028 }
1029 /*---------------------------------------------------------*/
TextSearch()1030 TextSearch()
1031 {
1032 Char str[1024], line[120], path[PATH_MAX];
1033 CharPtr string_search = NULL;
1034 Int4 BarValue, LineNumber = 0;
1035
1036 FILE *fp;
1037
1038 BaR bar;
1039
1040 bar = GetSlateVScrollBar( (SlatE) pdbfile_panel);
1041 BarValue = GetBarValue(bar);
1042
1043 GetTitle(Pdbfile_string, str, sizeof(str));
1044 if(StringLen(str) == 0) Message(MSG_OK, "put in a string first, please!");
1045 else {
1046
1047 TmpNam (path);
1048
1049 fp = FileOpen(path, "w");
1050 SaveDocument(pdbfile_panel, fp);
1051 FileClose(fp);
1052
1053 fp = FileOpen(path, "r");
1054
1055 while(fgets(line, 120, fp)){
1056 if(LineNumber >= BarValue) {
1057 string_search = StringSearch(line, str);
1058 }
1059 if(string_search != NULL) {
1060 BarValue = LineNumber;
1061 SetBarValue(bar, BarValue);
1062 break;
1063 }
1064 LineNumber++;
1065
1066 }
1067 if(string_search == NULL) Message(MSG_OK, "Not found!\n");
1068
1069 FileClose(fp);
1070 }
1071
1072 FileRemove (path);
1073
1074 }
1075 /*---------------------------------------------------------*/
PdbfileStringAcceptProc(ButtoN b)1076 static void PdbfileStringAcceptProc(ButtoN b)
1077 {
1078
1079 TextSearch();
1080
1081 }
1082 /*--------------------------------------------------------*/
ListEntryStartProc(ButtoN b)1083 static void ListEntryStartProc(ButtoN b)
1084 {
1085 Int2 val;
1086 Int2 current_zone, CheckProcReturn;
1087
1088
1089 Disable(Entry_accept);
1090
1091 if(!redo){
1092 current_zone = 1;
1093 CheckProcReturn = CheckProc(current_zone);
1094 if(CheckProcReturn == -1) return;
1095 }
1096
1097 redo = FALSE;
1098
1099 My_Reset1();
1100
1101 Hide(Entry_code);
1102 Reset(Entry_code);
1103 Show(Entry_code);
1104
1105 val = GetValue(l);
1106
1107 current_seq_entry_num = val - 1;
1108 StringCpy(EntryCode, seq_entry[index_num[current_seq_entry_num]]);
1109 SingleEntry = FALSE;
1110 EntryFromList = TRUE;
1111 GoToEntry();
1112 if(index_num[current_seq_entry_num] >= entry_num - 1) {
1113 Disable(ListEntry_next);
1114 Message(MSG_OK, "The last entry in the current list has been done! You may quit program or open the updated list to work on the entry which has been missed before!");
1115 }
1116
1117 return;
1118
1119 }
1120 /*--------------------------------------------------------*/
ListEntryNextProc(ButtoN b)1121 static void ListEntryNextProc(ButtoN b)
1122 {
1123
1124 Int2 current_zone, CheckProcReturn;
1125
1126 Disable(Entry_accept);
1127
1128 current_zone = 2;
1129 CheckProcReturn = CheckProc(current_zone);
1130 if(CheckProcReturn == -1) return;
1131
1132 My_Reset1();
1133
1134 Hide(Entry_code);
1135 Reset(Entry_code);
1136 Show(Entry_code);
1137
1138 current_seq_entry_num++;
1139
1140
1141 if(index_num[current_seq_entry_num] <= entry_num - 1){
1142 StringCpy(EntryCode, seq_entry[index_num[current_seq_entry_num]]);
1143 SetValue(l, current_seq_entry_num + 1);
1144
1145 SingleEntry = FALSE;
1146 EntryFromList = TRUE;
1147
1148 GoToEntry();
1149 }
1150
1151 if(index_num[current_seq_entry_num] >= entry_num - 1) {
1152 Disable(ListEntry_next);
1153 Message(MSG_OK, "The last entry in the current list has been done! You may quit program or open the updated list to work on the entry which has been missed before!");
1154 }
1155
1156 }
1157 /*--------------------------------------------------------*/
ListEntrySpecificProc(ButtoN b)1158 static void ListEntrySpecificProc(ButtoN b)
1159 {
1160
1161 if(TaxAssign) {
1162 My_Reset1();
1163 TaxAssign = TRUE;
1164 }
1165 else My_Reset1();
1166
1167 Enable(Entry_accept);
1168
1169 }
1170 /*-------------------------------------------------------*/
InFileTypeProc(GrouP infilemode)1171 static void InFileTypeProc(GrouP infilemode)
1172 {
1173
1174 Int2 val;
1175
1176 val = GetValue(infilemode);
1177
1178 if(val == 1) TextInEntry = TRUE;
1179 else if(val == 2) TextInEntry = FALSE;
1180
1181 }
1182 /*-------------------------------------------------------*/
OutFileTypeProc(GrouP outfilemode)1183 static void OutFileTypeProc(GrouP outfilemode)
1184 {
1185
1186 Int2 val;
1187
1188 val = GetValue(outfilemode);
1189
1190 if(val == 1) TextOutEntry = TRUE;
1191 else if(val == 2) TextOutEntry = FALSE;
1192
1193 }
1194 /*-------------------------------------------------------*/
ListBlastChainProc(LisT l)1195 static void ListBlastChainProc(LisT l)
1196 {
1197 Int2 val = 0;
1198
1199 val = GetValue(l);
1200 if(val == 0) Disable(BlastSearchAccept);
1201 }
1202 /*-------------------------------------------------------*/
BlastSearchAcceptProc(ButtoN b)1203 static void BlastSearchAcceptProc(ButtoN b)
1204 {
1205 Int2 val = 0;
1206
1207 val = GetValue(lBlastChain);
1208 selected_chain_num = val - 1;
1209
1210 PDBeastSendBlastSearch(selected_chain_num);
1211 }
1212