Debian Codegraph @

w4/gifcommand.c

raw
1 /* File: gifcommand.c
2 * Author: Fred Wobus ([email protected])
3 * Copyright (C) J Thierry-Mieg and R Durbin, 1999
4 * -------------------------------------------------------------------
5 * Acedb is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
19 * -------------------------------------------------------------------
20 * This file is part of the ACEDB genome database package, written by
21 * Richard Durbin (Sanger Centre, UK) [email protected], and
22 * Jean Thierry-Mieg (CRBM du CNRS, France) [email protected]
23 *
24 * Description:
25 * Exported functions:
26 * gifControl - function that deals with giface-commands
27 * gets called from command.c, if the kernel
28 * command parser can't deal with a command
29 * because it interact with graphical modules.
30 * HISTORY:
31 * Last edited: Jun 15 11:25 2006 (edgrif)
32 * * Jan 27 16:05 1999 (fw): created this module to accomodate
33 * the function gifControl() from gifacemain.c
34 * Created: Wed Jan 27 16:04:40 1999 (fw)
35 * CVS info: $Id: gifcommand.c,v 1.44 2006/06/15 10:43:35 edgrif Exp $
36 *-------------------------------------------------------------------
37 */
38
39 #include <wh/acedb.h>
40 #include <wh/aceio.h>
41 #include <wh/command.h>
42 #include <wh/session.h>
43 #include <wh/lex.h>
44 #include <whooks/sysclass.h>
45 #include <wh/query.h>
46 #include <wh/display.h>
47 #include <wh/update.h>
48 #include <wh/fmap.h> /* for fMapGifXxx. */
49 #include <wh/pepgifcommand.h> /* for pepGifCommandXxxx */
50
51 #include <wh/smapconvert.h>
52
53 /* #include <wh/gmap.h> cannot include because of clashes with MAP2GRAPH macros */
54 extern void gMapDrawGIF (ACEIN command_in, ACEOUT result_out);
55 extern void pMapDrawGIF (ACEIN command_in, ACEOUT result_out);
56
57
58 /* Holds state for the current gif command execution. */
59 typedef struct _GIFCommandStruct
60 {
61 BOOL quiet ;
62 } GIFCommandStruct, *GIFCommand ;
63
64
65
66
67 /*********************************/
68 /******** giface submenu ********/
69
70 /* General GIF commands. */
71 enum {GIF_QUIET = 300} ;
72
73 enum {GIF_FMAP_RECALC = 400, GIF_DO_SMAP} ;
74
75 enum {GIF_FEX_SEQGET = 600, GIF_FEX_SEQFEATURES} ;
76
77 enum {GIF_SMAP_SEQGET = 700, GIF_SMAP_SEQFEATURES} ;
78
79 enum {GIF_DASDNA = 800, GIF_DASTYPES, GIF_DASGFF} ;
80
81
82 /* NOTE: If you change the functionality of these options
83 * you have to update the documentation file whelp/Giface.html
84 * to reflect your changes.
85 * ALSO NOTE: If you add any new commands you must increment the number in the
86 * first member of the options[] array to be the total number of commands.
87 */
88 static FREEOPT options[] =
89 {
90 /* Total command number + cmdline prompt */
91 { 33, "acedb-gif" },
92
93 /* General functions. */
94 { -1, "Quit" }, /* quit command simulates EOF */
95 { '?', "? : this list of commands. Multiple commands ';' separated accepted" },
96 { GIF_QUIET,
97 "quiet -on | -off :\n"
98 "\tTurn quiet mode on or off, when \"on\" commands produce only their output\n"
99 "\twithout any extra comments (e.g. \"NNN Active Objects\" etc.).\n"
100 "\tQuiet mode makes parsing command output easier because either the first line\n"
101 "\tis an acedb comment because the command failed or there are no acedb comments in the output.\n"
102 "\t-off (default) verbose output\n"
103 "\t-on no comments unless there is an error.\n"},
104 { 'd', "dimensions [-D displaytype] x y : image size in pixel for all or the specified displaytype" },
105 { 'D', "display [-D displaytype] [-view view] [class key] : graphic display [for the current key]" },
106 { 'B', "psdump [-e] [-c] filename : save active graph as postscript" },
107 { 'A', "gifdump filename : save active graph as a gif" },
108 { 'M', "mouseclick x y: simulate a left button click on the active graph" },
109
110 { 'm', "map map [-view view] [-coords x1 x2] [-hideheader] [-whole]: does not write - use gif after" },
111
112 { 'P', "pmap [-clone <name>] | [-contig <name> <coord>] : physical map" },
113
114 /* fmap/sequence operations. */
115 { 'S', "seqget [[class:]object [-coords x1 x2]] [-noclip] [-source | -method]: sets current sequence for future ops on same line - if no name then get from active graph\n"
116 "\t-coords specify start/end of section of sequence to get\n"
117 "\t-noclip specify that features should not be clipped to x1, x2 but have their full extent mapped."
118 "\t[-source source(s)] specify a set of sources from which objects should be included/excluded in the virtual sequence."
119 "\t[-method methods(s)] specify a set of methods from which objects should be included/excluded in the virtual sequence."
120 "\tN.B. source and method must be the last option."
121 },
122 { 'X', "seqdisplay [-visible_coords v1 v2] [-new] [-title title] : works on current sequence, use gif or ps to actually dump the display\n"
123 "\t-new make a new sequence, current one is preserved (for use only with xremote currently)\n"
124 "\t-title give your own title to the sequence"
125 },
126 { 'n', "seqdna [-file fname] <-coords x1 x2> : works on current sequence <coords deprecated - use seqget>" },
127 { 'f', "seqfeatures [-quiet] [-file fname] [-version 1|2] [-list [features | keys]] [-source source(s)] [-feature feature(s)] <-coords x1 x2> : works on current sequence, quiet means only GFF in output, source(s)/feature(s) are '|' separated lists, <coords deprecated - use seqget>" },
128 { 'g', "seqactions [-dna] [-gf_features] [-hide_header] [-rev_comp] : works on current sequence" },
129 { 'c', "seqcolumns {-on name} {-off name} {-list}: works on active sequence" },
130 /* NB seqcolumns will work BEFORE seqdisplay() now */
131 { 'a', "seqalign [-file fname] [-coords x1 x2] : must follow a seqdisplay <or sequence, which is deprecated>" },
132 { 's', "sequence sequence [-coords x1 x2] : <deprecated - use seqget ; seqdisplay>" },
133 { GIF_DO_SMAP, "smap -coords x1 x2 -from class:object -to class:object : maps cordinates between related sequences." },
134 { GIF_FMAP_RECALC, "seqrecalc causes the sequence to be recalculated for the active graph." },
135
136 { 'e', "EMBL filename : embl dump keyset to filename.embl" },
137
138 {500, "pepget <protein | peptide> [-coords x1 x2] : sets current protein for future ops on same line" },
139 {501, "pepseq [-file fname] <-coords x1 x2> : exports current petide sequence" },
140 {502, "pepalign [-file fname] <-coords x1 x2> : exports homols of current peptide" },
141
142 { 'K', "makemaps -gmap | -pmap | -cmap | -alpha | -all | -seqmap file | -seqclonemap file : makes cached maps and sorted class keysets" },
143 { 'U', "update [-all] : add one official update, or all" },
144
145
146 /* Trial code which allows choosing of sets of methods before the fmap is */
147 /* built, its made to use the new smap code so must be compiled with the */
148 /* smapConvert code not the fmapConvert code. */
149 { 'E', "edseqget [sequence [-coords x1 x2]] : sets current sequence for future ops on same line - if no name then get from active graph" },
150
151 /* Trial code using smap but NO fmap to get a sequence.... */
152 { GIF_SMAP_SEQGET, "smapseqget sequence [-coords x1 x2] : sets current sequence for future." },
153 { GIF_SMAP_SEQFEATURES, "smapseqfeatures [-file fname] [-version 1|2] [-list] [-source source(s)] [-feature feature(s)] <-coords x1 x2> : works on current sequence, source(s)/feature(s) are '|' separated lists, <coords deprecated - use seqget>" },
154
155
156 /* Trial code to use the fex routines to do a gff dump. */
157 { GIF_FEX_SEQGET, "fexseqget [sequence [-coords x1 x2]] : sets current sequence for future ops on same line." },
158 { GIF_FEX_SEQFEATURES, "fexseqfeatures [-file fname] [-version 1|2] [-list] [-source source(s)] [-feature feature(s)] : works on current sequence, source(s)/feature(s) are '|' separated lists." },
159
160
161 /* To support DAS format output. */
162 {GIF_DASTYPES, "dastypes : gets types for current sequence.." },
163 {GIF_DASDNA, "dasdna : gets dna for current sequence.." },
164 {GIF_DASGFF, "dasgff : gets features for current sequence.." }
165
166 } ;
167
168
169 /*
170 * Implements the gif menu/functions, e.g. seqget etc. Is called by a number of
171 * components, e.g. tace, xace (fmap), the gif version of the server.
172 *
173 */
174 void gifControl(KEYSET ks, ACEIN fi, ACEOUT fo, BOOL quiet)
175 {
176 GIFCommandStruct gif_cmd ;
177 int option ;
178 char *word = NULL ;
179 FeatureMap seqLook = NULL ;
180 PepGifCommand pepLook = NULL ;
181 BOOL oldisGifDisplay = isGifDisplay ;
182 void *fex_seq = NULL ;
183 SMapFeatureMap smap_features = NULL ;
184
185 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
186 GTimer* timer ;
187
188 timer = g_timer_new() ;
189 g_timer_start(timer) ;
190 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
191
192 gif_cmd.quiet = quiet ;
193
194 while (TRUE)
195 {
196 if (aceInOptPrompt (fi, &option, options))
197 switch (option)
198 {
199 /**** end of input / quit command ****/
200 case -1:
201 goto finish ; /* only way to break out of while-loop */
202
203 case '?': /* help */
204 {
205 int i ;
206 for (i = 1 ; i <= options[0].key ; i++)
207 aceOutPrint (fo, "// %s\n", options[i].text) ;
208 }
209 break ;
210
211 case GIF_QUIET: /* Set quiet mode for commands a la Unix. */
212 {
213 char *cp ;
214 while ((cp = aceInWord(fi)))
215 {
216 if (strcmp (cp, "-on") == 0)
217 gif_cmd.quiet = TRUE ;
218 else if (strcmp(cp, "-off") == 0)
219 gif_cmd.quiet = FALSE ;
220 }
221 break ;
222 }
223 case 'd': /* dimensions in pixels */
224 {
225 KEY displayKey = 0;
226 char *cp;
227 int xpixels, ypixels;
228
229 if ((cp = aceInWord(fi)))
230 {
231 if (strcmp(cp, "-D") == 0)
232 {
233 if ((cp = aceInWord (fi)))
234 {
235 if (displayIsObjectGeneric(cp, &displayKey))
236 {
237 if (aceInInt (fi,&xpixels) &&
238 aceInInt (fi,&ypixels) &&
239 xpixels > 0 && ypixels > 0)
240 {
241 displaySetSize(name(displayKey),
242 xpixels, ypixels);
243 break;
244 }
245 }
246 else
247 {
248 aceOutPrint (fo, "// Error : unsuitable display type %s\n", cp);
249 break;
250 }
251 }
252 else
253 {
254 aceOutPrint (fo, "// Error: -D must be followed by a display type\n") ;
255 break ;
256 }
257 }
258 else
259 {
260 aceInBack(fi);
261
262 if (aceInInt (fi,&xpixels) &&
263 aceInInt (fi,&ypixels) &&
264 xpixels > 0 && ypixels > 0)
265 {
266 displaySetSizes(xpixels, ypixels);
267 break;
268 }
269 }
270 }
271
272 aceOutPrint (fo, "// Usage: dimensions [-D displaytype] x y : "
273 "image size in pixel for all or the specified displaytype\n") ;
274 }
275 break ;
276
277 case 'D': /* display an object */
278 /* only displays single objects, multiple objects is an error. */
279 { KEYSET kA ;
280 KEY classKey = 0, displayKey = 0, view = 0 ;
281 char *cp ;
282 KEY _VView, mm;
283
284 lexaddkey("View", &mm, _VMainClasses);
285 _VView = KEYKEY(mm);
286
287 while ((cp = aceInWord(fi)))
288 {
289 if (*cp != '-')
290 { aceInBack(fi) ; break ; }
291 if (!strcmp(cp, "-D")) /* -D displaytype */
292 {
293 if (!(cp = aceInWord(fi)))
294 { aceOutPrint (fo, "// Error: -D must be followed by a display type\n") ;
295 break ;
296 }
297
298 if (!displayIsObjectGeneric(cp, &displayKey))
299 { aceOutPrint (fo, "// Error: unsuitable display type %s\n", cp) ;
300 break ;
301 }
302 }
303 else if (!strcmp(cp, "-view")) /* -view view */
304 { if (!(cp = aceInWord(fi)))
305 { aceOutPrint (fo, "// Error: -view must be followed by a view name\n") ;
306 break ;
307 }
308 if (!lexword2key (cp, &view, _VView))
309 { aceOutPrint (fo, "// Error: unknown view %s\n", cp) ;
310 break ;
311 }
312 }
313 }
314
315 if (aceInCheck (fi,"ww")) /* [class name] */
316 { cp = aceInWord(fi) ;
317 if (!lexword2key (cp, &classKey, _VClass))
318 { aceOutPrint (fo, "// Error: bad class name %s\n", cp) ;
319 break ;
320 }
321 kA = query(0, messprintf("Find %s \"%s\"",
322 name(classKey), aceInWord(fi))) ;
323 }
324 else if (!ks)
325 { aceOutPrint (fo, "// Error: no active list\n") ;
326 break ;
327 }
328 else
329 kA = ks ;
330
331 if (!keySetMax (kA))
332 { aceOutPrint (fo, "// Error: active list is empty\n") ;
333 break ;
334 }
335 if (keySetMax(kA) == 1)
336 display (keySet(kA,0), view, displayKey ? name(displayKey) : 0) ;
337 else
338 aceOutPrint (fo, "// Error: can not display multiple objects\n") ;
339
340 /* Only destroy the keySet if we created a new one, DON'T destroy */
341 /* the keyset we were passed in !! */
342 if (kA != ks) keySetDestroy (kA) ;
343 }
344 break;
345
346 case 'B': /* dump the active graph as PostScript */
347 {
348 BOOL colour = FALSE, EPSF = FALSE;
349 word = aceInWord(fi) ;
350
351 while ((strcmp(word, "-e") == 0) || (strcmp(word, "-c") == 0))
352 {
353 if (strcmp(word, "-e") == 0)
354 EPSF = TRUE;
355 if (strcmp(word, "-c") == 0)
356 colour = TRUE;
357 word = aceInWord(fi);
358 }
359
360 if (!graphActive())
361 aceOutPrint (fo, "// psdump error : no active graph\n") ;
362 if (!word || !*word)
363 aceOutPrint (fo, "// Usage: psdump -e -c filename: dump the active graph in file as PostScript\n") ;
364 else
365 {
366 char fileName[MAXPATHLEN] ;
367 ACEOUT ps_out;
368 BOOL rotation ;
369 float scale ;
370 int pages ;
371 int err;
372 char *fp = filGetFullPath(word, 0);
373
374 strcpy (fileName, fp);
375 messfree(fp);
376
377 if (strcmp(filGetExtension(word), "ps") != 0)
378 strcat (fileName, ".ps");
379
380 ps_out = aceOutCreateToFile(fileName, "w", 0);
381 if (ps_out)
382 {
383 graphPSdefaults(graphActive(), PAPERTYPE_A4,
384 &rotation, &scale, &pages) ;
385
386 err = graphPS(graphActive(), ps_out,
387 NULL,
388 colour, EPSF, rotation,
389 PAPERTYPE_A4, scale, pages) ;
390 if (err == ESUCCESS)
391 aceOutPrint (fo,
392 "// I wrote the active graph "
393 "to file %s\n", fileName) ;
394 else
395 aceOutPrint (fo,
396 "// ERROR: Failed to write to "
397 "file %s (%s)\n",
398 fileName, messErrnoText(err)) ;
399 aceOutDestroy(ps_out);
400 }
401 }
402 }
403 break;
404
405 case 'A': /* dump a GIF of the active graph */
406 {
407 word = aceInWord(fi) ;
408
409 if (!graphActive())
410 aceOutPrint (fo, "// gifdump error : no active graph\n") ;
411 else if (!word || !*word)
412 aceOutPrint (fo, "// Usage gifdump filename: dump the active graph in file\n") ;
413 else if (strcmp(word,"-") == 0)
414 { /* LS 2 Mar 98 dump GIF to standard output */
415
416 if (graphGIF(graphActive(), fo, TRUE) == ESUCCESS)
417 graphBoxInfoFile (fo);
418 else
419 aceOutPrint (fo, "// ERROR: Failed to write GIF data\n");
420 }
421 else
422 {
423 char fileName[MAXPATHLEN];
424 ACEOUT gif_out, boxes_out;
425 char *fp = filGetFullPath(word, 0);
426
427 strcpy (fileName, fp);
428 messfree(fp);
429
430 if (strcmp(filGetExtension(fileName), "gif") == 0)
431 fileName[strlen(fileName)-4] = '\0';
432
433 gif_out = aceOutCreateToFile(messprintf("%s.gif", fileName),
434 "wb", 0);
435
436 if (gif_out)
437 {
438 int err = graphGIF(graphActive(), gif_out, FALSE);
439 if (err == ESUCCESS)
440 aceOutPrint (fo,
441 "// I wrote the active graph to file %s\n",
442 fileName) ;
443 else
444 aceOutPrint (fo,
445 "// ERROR: Failed to write to "
446 "file %s (%s)\n",
447 fileName, messErrnoText(err)) ;
448
449 aceOutDestroy(gif_out);
450 }
451 boxes_out = aceOutCreateToFile(messprintf("%s.boxes",
452 fileName),
453 "w", 0);
454 if (boxes_out)
455 {
456 graphBoxInfoFile (boxes_out) ;
457 aceOutDestroy (boxes_out);
458 }
459 }
460 }
461 break;
462
463 case 'M' : /* mouseclick x y */
464 {
465 int xClick, yClick;
466
467 if (!graphActive())
468 aceOutPrint (fo, "// mouseclick error : no active graph\n");
469 else if (!aceInInt (fi,&xClick) || !aceInInt (fi,&yClick))
470 aceOutPrint (fo, "// Usage: mouseclick x y - simulates a left button click in the active graph\n") ;
471 else
472 graphGIFLeftDown (xClick, yClick) ;
473 }
474 break;
475
476 case 'm': /* map/view draw */
477 {
478 gMapDrawGIF (fi, fo);
479 }
480 break ;
481
482 case 'P': /* pmap draw */
483 {
484 pMapDrawGIF (fi, fo);
485 }
486 break ;
487
488
489 /* Sequence/fmap based operations. */
490
491 case 'S': /* get sequence, init fMap package */
492 seqLook = fMapGifGet (fi, fo, seqLook) ; /* destroys existing seqLook */
493 break ;
494
495 case 'X': /* sequence display */
496 if (seqLook) fMapGifDisplay (fi, fo, seqLook) ;
497 else aceOutPrint (fo, "// gif seqdisplay without active sequence\n") ;
498 break ;
499
500 case 'n': /* dna dump */
501 if (seqLook)
502 fMapGifDNA (fi, fo, seqLook, gif_cmd.quiet) ;
503 else
504 aceOutPrint (fo, "// gif seqdna without active sequence\n") ;
505 break ;
506
507 case 'f': /* feature dump */
508 if (seqLook)
509 fMapGifFeatures(fi, fo, seqLook, gif_cmd.quiet) ;
510 else
511 aceOutPrint (fo, "// gif seqfeatures without active sequence\n") ;
512 break ;
513
514 case 'g': /* actions */
515 if (seqLook) fMapGifActions (fi, fo, seqLook) ;
516 else aceOutPrint (fo, "// gif seqactions without active sequence\n") ;
517 break ;
518
519 case 'c': /* column control */
520 if (seqLook) fMapGifColumns (fi, fo, seqLook) ;
521 else aceOutPrint (fo, "// gif seqcolumns without active sequence\n") ;
522 break ;
523
524 case 'a': /* alignment */
525 if (seqLook) fMapGifAlign (fi, fo, seqLook) ;
526 else aceOutPrint (fo, "// gif seqalign without displayed active sequence\n") ;
527 break ;
528
529 case 's': /* sequence draw - deprecated */
530 seqLook = fMapGifGet (fi, fo, seqLook) ;
531 if (seqLook) fMapGifDisplay (fi, fo, seqLook) ;
532 else aceOutPrint (fo, "// gif seqdisplay without active sequence\n") ;
533 break ;
534
535 case GIF_FMAP_RECALC: /* do recalculate of sequence. */
536 fMapGifRecalculate(fi, fo, seqLook) ;
537 break ;
538
539 case GIF_DO_SMAP:
540 commandDoSMap(fi, fo) ;
541 break;
542
543 case 500: /* get protein */
544 pepLook = pepGifCommandGet (fi, fo, pepLook) ;
545 break ;
546
547 case 501: /* dna dump */
548 if (pepLook) pepGifCommandSeq (fi, fo, pepLook) ;
549 else aceOutPrint (fo, "// gif pepseq without active protein\n") ;
550 break ;
551
552 case 502: /* feature dump */
553 if (pepLook) pepGifCommandAlign (fi, fo, pepLook) ;
554 else aceOutPrint (fo, "// gif pepalign without active protein\n") ;
555 break ;
556
557 /*------------------------------------------------------------*/
558
559 case 'e': /* EMBL dump */
560 { extern void emblDumpKeySetFile (KEYSET kset, char *fname) ;
561 if ((word = aceInWord(fi)))
562 emblDumpKeySetFile (ks, word) ;
563 else
564 aceOutPrint (fo, "// Usage: EMBL filename\n") ;
565 }
566 break ;
567
568 /*------------------------------------------------------------*/
569
570 case 'K': /* make cached maps */
571 { extern void gMapMakeAll(void) ;
572 extern void pMapMakeAll(void) ;
573 extern void cMapMakeAll(void) ;
574 extern void sMapMake (FILE *fil, BOOL isSeq) ;
575 char *filname ;
576 FILE *fil ;
577
578 /* must save rest of free card, else sessionWriteAccess() destroys */
579 /* useless with aceIn cardKeep = strnew (freepos(), 0) ; */
580 if (!sessionGainWriteAccess())
581 { aceOutPrint (fo, "// Error: can't get write access\n") ;
582 break ;
583 }
584 /* freeforcecard (cardKeep) ; messfree (cardKeep) ; */
585
586 while (aceInStep (fi, '-') && (word = aceInWord(fi)))
587 {
588 /* cardKeep = strnew (freepos(), 0) again useless now save because freesubs used in some *MakeAll */
589
590 if (!strcmp (word, "gmap"))
591 gMapMakeAll () ;
592 else if (!strcmp (word, "pmap"))
593 pMapMakeAll () ;
594 else if (!strcmp (word, "cmap"))
595 cMapMakeAll () ;
596 else if (!strcmp (word, "alpha"))
597 lexAlphaMakeAll () ;
598 else if (!strcmp (word, "all"))
599 { pMapMakeAll () ;
600 gMapMakeAll () ;
601 cMapMakeAll () ;
602 lexAlphaMakeAll () ;
603 }
604 else if (!strcmp (word, "seqmap"))
605 {
606 if (!(word = aceInWord(fi)))
607 aceOutPrint (fo, "// Error: makemaps -seqmap "
608 "requires a file name\n") ;
609 else if (!(fil = fopen (word, "w")))
610 aceOutPrint (fo, "// Error: makemaps -seqmap "
611 "failed to open file %s\n", word) ;
612 else
613 {
614 filname = strnew (word, 0) ;
615 sMapMake (fil, TRUE) ;
616 aceOutPrint (fo, "// Sequence-* map file written to %s\n",
617 filname) ;
618 messfree (filname) ;
619 fclose (fil) ;
620 }
621 }
622 else if (!strcmp (word, "seqclonemap"))
623 {
624 if (!(word = aceInWord(fi)))
625 aceOutPrint (fo, "// Error: makemaps -seqclonemap "
626 "requires a file name\n") ;
627 else if (!(fil = fopen (word, "w")))
628 aceOutPrint (fo, "// Error: makemaps -seqclonemap "
629 "failed to open file %s\n", word) ;
630 else
631 {
632 filname = strnew (word, 0) ;
633 sMapMake (fil, FALSE) ;
634 aceOutPrint (fo, "// Sequence-* Clone map file written to %s\n",
635 filname) ;
636 messfree (filname) ;
637 fclose (fil) ;
638 }
639 }
640 else
641 aceOutPrint (fo, "// Usage: makemaps -gmap | -pmap | -cmap | -alpha | -all | -seqmap file | -seqclonemap file\n") ;
642
643 /* freeforcecard (cardKeep) ; messfree (cardKeep) ; useless with aceIn */
644 }
645
646 if (aceInWord(fi)) /* i.e. something not starting with '-' */
647 {
648 aceOutPrint (fo, "// unrecognized option %s\n", word) ;
649 aceOutPrint (fo, "// Usage: makemaps -gmap | -pmap | -cmap | -alpha | -all | -seqmap file | -seqclonemap file\n") ;
650 }
651 }
652 break ;
653
654 case 'U': /* add updates */
655 if ((word = aceInWord(fi)))
656 {
657 if (!strcmp (word, "-all"))
658 updateDoAction (TRUE) ;
659 else
660 aceOutPrint (fo, "// Usage: update [-all]\n") ;
661 }
662 else
663 updateDoAction (FALSE) ;
664 break ;
665
666
667
668
669 /* NEW FUNCTIONS TESTING... */
670
671 /* my new sequence smap convert type with choosing of features */
672 /* ahead of smapconvert. This is NOT fex based. */
673 case 'E': /* get sequence, init fMap package */
674
675 seqLook = fMapEdGifGet (fi, fo, seqLook) ; /* destroys existing seqLook */
676
677 break ;
678
679 /* My new smap based functions to do gff dumping. */
680 case GIF_SMAP_SEQGET: /* Get the sequence. */
681 {
682 smap_features = sMapFeaturesCreate(fi, fo, smap_features) ;
683 /* destroys any existing fex_seq. */
684 break ;
685 }
686
687 case GIF_SMAP_SEQFEATURES: /* feature dump */
688 {
689 if (smap_features)
690 sMapFeaturesGFF(fi, fo, smap_features) ;
691 else
692 aceOutPrint (fo, "// gif smapseqfeatures without active sequence\n") ;
693 break ;
694 }
695
696
697 /* My new fex based functions to do gff dumping. */
698 case GIF_FEX_SEQGET: /* Get the sequence. */
699 aceOutPrint (fo, "// not supported yet...\n") ;
700 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
701 fex_seq = gffFexGetSeq(fi, fo, fex_seq) ; /* destroys any existing fex_seq. */
702 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
703
704 break ;
705
706 case GIF_FEX_SEQFEATURES: /* Dump the features as GFF */
707 if (fex_seq)
708 aceOutPrint (fo, "// not supported yet...\n") ;
709 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
710 gffFexFeatures(fi, fo, fex_seq) ;
711 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
712
713 else
714 aceOutPrint (fo, "// gif fexseqfeatures without active sequence\n") ;
715 break ;
716
717
718 /* DAS functions. */
719 case GIF_DASTYPES:
720 aceOutPrint (fo, "// DAS types command.\n") ;
721 break ;
722
723 case GIF_DASDNA:
724 if (seqLook)
725 dasDNA (fi, fo, seqLook) ;
726 else
727 aceOutPrint (fo, "// gif dasdna without active sequence\n") ;
728 break ;
729
730 case GIF_DASGFF:
731 if (seqLook)
732 dasGFF(fi, fo, seqLook) ;
733 else
734 aceOutPrint (fo, "// gif dasgff without active sequence\n") ;
735 break ;
736
737 } /* end-switch (key) */
738
739 } /* end-while(TRUE) */
740
741
742
743 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
744 printf("Elapsed time: %g\n", g_timer_elapsed(timer, NULL)) ;
745 g_timer_destroy(timer) ;
746 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
747
748
749
750 /* This function can be called in one of two ways: as a result of using */
751 /* giface/sgifaceserver, or using the xremote facility of xace. For the */
752 /* former it is crucial that the below stuff is freed, for the latter it */
753 /* should not be freed as this will leave xace with nothing to display. */
754 finish:
755
756 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
757 /* Currently the fex stuff will always be destroyed, its only intended for */
758 /* use from giface/server. */
759 if (fex_seq)
760 gffFexDestroySeq(fex_seq) ;
761 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
762
763 if (smap_features)
764 sMapFeaturesDestroy(smap_features) ;
765
766 if (isGifDisplay) /* yuch global. */
767 {
768 /* must kill seqLook before graphCleanup, else will not
769 know if seqLook had a graph and is already destroyed */
770 if (seqLook)
771 fMapDestroy (seqLook) ;
772 if (pepLook)
773 pepGifCommandDestroy (pepLook) ;
774
775 graphCleanUp () ; /* kill all graphs except active graph */
776 graphDestroy () ; /* kill active graph */
777 }
778
779 isGifDisplay = oldisGifDisplay ;
780
781 return;
782 } /* gifControl */
783
784 /**************************************************/
785 /**************************************************/
786
787