/* Title: ted File: ted.c Purpose: Main module Last update: 23 June 1992 Change log: 28.11.90 SD put undesirables under STLOUIS compilation flag 22.07.91 LFW put in -enzyme as a command line option for STLOUIS 30.07.91 SD fixed bug in MRC switch 17.09.91 LFW changed MRC switch to !AUTO_CLIP and STLOUIS flag to DEF_OUT to more accurately reflect the use of the flags 26.11.91 SD Added SCF format 23-Jun-92 SD Some ugly code in DEF_OUT option */ /* This module contains the C language entry point `main' and initialisation for the X system. */ /* ---- Includes ---- */ #include "dialogues.h" /* IMPORT: inputSeq, outputSeq, quitApplication */ #include "display.h" /* IMPORT: createDisplay */ #include "help.h" /* IMPORT: createHelpShell, help */ #include "seq.h" /* IMPORT: Seq, NULLBaseNum */ #include "seqIOEdit.h" /* IMPORT: isDotNum, stripDotNum */ #include /* IMPORT: stderr, fprintf */ #include "mystdlib.h" /* IMPORT: exit */ #include #include #include #include #include /* ---- Static variables ---- */ static String fallback_resources[] = { /* The application */ "Xted.minWidth: 550", "Xted.minHeight: 250", "Xted*magnif: 90", /* Labels have no borders and are not resized */ "Xted*Label.borderWidth: 0", "Xted*Label.top: ChainTop", "Xted*Label.bottom: ChainTop", "Xted*Label.left: ChainLeft", "Xted*Label.right: ChainLeft", /* Buttons are not resized */ "Xted*Command.top: ChainTop", "Xted*Command.bottom: ChainTop", "Xted*Command.left: ChainLeft", "Xted*Command.right: ChainLeft", /* All the toggles are one-of-many */ "Xted*Toggle.Translations: #override \\n\ : highlight(Always) \\n\ : unhighlight() \\n\ ,: set() notify()", "Xted.mainForm.title.label: Trace editor", "Xted.mainForm.version.label: \ June 1991", "Xted.mainForm.seqNamePrompt.label: Input:", "Xted.mainForm.seqNamePrompt.height: 13", "Xted.mainForm.seqName.label: NONE", "Xted.mainForm.seqName.resizable: True", "Xted.mainForm.seqName.height: 13", "Xted.mainForm.NorigBasesPrompt.label: Bases:", "Xted.mainForm.NorigBasesPrompt.height: 13", "Xted.mainForm.NorigBases.label: ", "Xted.mainForm.NorigBases.resizable: True", "Xted.mainForm.strand.label: Strand: Top", "Xted.mainForm.strand.resizable: True", /* Display forms have no border */ "Xted.mainForm.Form.borderWidth: 0", /* The edit mode toggles */ "Xted.mainForm.Toggle.top: ChainTop", "Xted.mainForm.Toggle.bottom: ChainTop", "Xted.mainForm.Toggle.left: ChainLeft", "Xted.mainForm.Toggle.right: ChainLeft", "Xted.mainForm.edmodelab.label: Mode:", "Xted.mainForm.adjustL.label: Adj left cut", "Xted.mainForm.edSeq.label: Edit seq", "Xted.mainForm.adjustR.label: Adj right cut", "Xted.mainForm.edSeq.state: True", /* Default toggle */ "Xted.mainForm.adjustL.height: 13", "Xted.mainForm.edSeq.height: 13", "Xted.mainForm.adjustR.height: 13", /* The magnification slider */ "Xted.mainForm.maglab.top: ChainTop", "Xted.mainForm.maglab.bottom: ChainTop", "Xted.mainForm.maglab.left: ChainLeft", "Xted.mainForm.maglab.right: ChainLeft", "Xted.mainForm.maglab.label: Mag:", "Xted.mainForm.maglab.height: 13", "Xted.mainForm.magscr.top: ChainTop", "Xted.mainForm.magscr.bottom: ChainTop", "Xted.mainForm.magscr.left: ChainLeft", "Xted.mainForm.magscr.right: ChainLeft", "Xted.mainForm.magscr.orientation: horizontal", "Xted.mainForm.magscr.length: 100", "Xted.mainForm.magscr.height: 13", "Xted.mainForm.scaleDown.label: Scale down", "Xted.mainForm.scaleDown.height: 13", "Xted.mainForm.scaleUp.label: Scale up", "Xted.mainForm.scaleUp.height: 13", "Xted.mainForm.switch.label: Switch", "Xted.mainForm.switch.height: 13", /* The main display: a viewport containing a form containing graphs */ "Xted.mainForm.viewport.top: ChainTop", "Xted.mainForm.viewport.bottom: ChainBottom", "Xted.mainForm.viewport.left: ChainLeft", "Xted.mainForm.viewport.right: ChainRight", "Xted.mainForm.viewport.allowHoriz: True", "Xted.mainForm.viewport.forcebars: True", "Xted.mainForm.viewport.width: 700", "Xted.mainForm.viewport.vpForm.Graph.resizable: True", "Xted.mainForm.viewport.vpForm.Graph.top: ChainTop", "Xted.mainForm.viewport.vpForm.Graph.bottom: ChainTop", "Xted.mainForm.viewport.vpForm.Graph.left: ChainLeft", "Xted.mainForm.viewport.vpForm.Graph.right: ChainRight", "Xted.mainForm.viewport.vpForm.trace.top: ChainTop", "Xted.mainForm.viewport.vpForm.trace.bottom: ChainBottom", "Xted.mainForm.viewport.vpForm.Graph.font: -misc-*-bold-*15-*", /* The text graph heights are dynamically set to accomodate the font */ "Xted.mainForm.viewport.vpForm.trace.height: 150", /* The graphs are dynamically initially set to fill the viewport */ "Xted.mainForm.viewport.vpForm.Graph.dimBackground: grey", "Xted.mainForm.viewport.vpForm.Graph.graphColour1: green", "Xted.mainForm.viewport.vpForm.Graph.graphColour2: purple", "Xted.mainForm.viewport.vpForm.Graph.graphColour3: black", "Xted.mainForm.viewport.vpForm.Graph.graphColour4: red", /* Dummy widget - we only care about its width */ "Xted.mainForm.dummy.top: ChainTop", "Xted.mainForm.dummy.bottom: ChainBottom", "Xted.mainForm.dummy.left: ChainLeft", "Xted.mainForm.dummy.right: ChainRight", "Xted.mainForm.dummy.width: 700", /* Dialogues */ "Xted*input.ioForm.ioPrompt.label: Input a file", "Xted*search.ioForm.ioPrompt.label: Search for string or base number", "Xted*output.ioForm.ioPrompt.label: Save a file", "Xted*check.ioForm.ioPrompt.label: \ The existing sequence has been altered.\\n\ Do you really want to overwrite it?", "Xted*checkwrite.ioForm.ioPrompt.label: \ This output file already exists.\\n\ Do you really want to overwrite it?", "Xted*quit.ioForm.ioPrompt.label: \ The existing sequence has been altered.\\n\ Do you really want to quit?", "Xted*check.ioForm..translations: #override \\n\ Return: CRAction()", "Xted*quit.ioForm..translations: #override \\n\ Return: CRAction()", "Xted*ioForm.namePrompt.label: File name:", "Xted*ioForm.nameVal.width: 200", "Xted*ioForm.nameVal.translations: #override \\n\ Return: CRAction()", "Xted*ioForm.formatPrompt.label: File format:", "Xted*ioForm.formatBox.borderWidth: 0", "Xted*ioForm.formatBox.orientation: horizontal", "Xted*ioForm.formatBox.plainFmt.label: Plain", "Xted*ioForm.formatBox.abiFmt.label: ABI", "Xted*ioForm.formatBox.abiFmt.state: True", /* Default toggle */ "Xted*ioForm.formatBox.alfFmt.label: ALF", "Xted*ioForm.formatBox.alfFmt.state: False", "Xted*ioForm.formatBox.scfFmt.label: SCF", "Xted*ioForm.formatBox.scfFmt.state: False", "Xted*ioForm.formatBox.bottomFmt.label: Bottom", "Xted*ioForm.formatBox.topFmt.label: Top", "Xted*ioForm.formatBox.topFmt.state: True", /* Default toggle */ /* The `default' button for the dialogue has a wider border */ "Xted*input.ioForm.OK.borderWidth: 3", "Xted*output.ioForm.OK.borderWidth: 3", "Xted*check.ioForm.Cancel.borderWidth: 3", "Xted*quit.ioForm.Cancel.borderWidth: 3", /* Help shell widget */ "Xted.Help.width: 525", "Xted.Help.height: 200", "Xted.Help.minWidth: 525", "Xted.Help.maxWidth: 525", "Xted.Help.minHeight: 150", "Xted.Help.title: ted help", "Xted.Help.form.rmButton.label: Remove help", "Xted.Help.form.rmButton.top: ChainTop", "Xted.Help.form.rmButton.bottom: ChainTop", "Xted.Help.form.rmButton.left: ChainLeft", "Xted.Help.form.rmButton.right: ChainLeft", "Xted.Help.form.text.top: ChainTop", "Xted.Help.form.text.bottom: ChainBottom", "Xted.Help.form.text.left: ChainLeft", "Xted.Help.form.text.right: ChainRight", NULL, }; /* The command line arguments and how to parse them into resources. */ static XrmOptionDescRec options[] = { {"-PLN", "PLN", XrmoptionSepArg, NULL}, {"-ABI", "ABI", XrmoptionSepArg, NULL}, {"-ALF", "ALF", XrmoptionSepArg, NULL}, {"-SCF", "SCF", XrmoptionSepArg, NULL}, {"-output", "output", XrmoptionSepArg, NULL}, {"-baseNum", "baseNum", XrmoptionSepArg, NULL}, {"-mag", "mag", XrmoptionSepArg, NULL}, {"-astring", "astring", XrmoptionSepArg, NULL}, {"-bottom", "bottom", XrmoptionSepArg, NULL}, {"-raw", "raw", XrmoptionSepArg, NULL}, {"-enzyme","enzyme",XrmoptionSepArg,NULL}, }; /* Where to put the command line arguments when we dig them out of the resources. */ typedef struct { String plain; String ABI; String ALF; String SCF; String output; int baseNum; int mag; String astring; int bottom; String raw; String enzyme; } AppResources; /* Dig the command line arguments out of resources and into the above structure. */ static XtResource tedResources[] = { {"PLN", "Plain", XtRString, sizeof(String), XtOffset(AppResources *, plain), XtRImmediate, NULL}, {"ABI", "ABI", XtRString, sizeof(String), XtOffset(AppResources *, ABI), XtRImmediate, NULL}, {"ALF", "ALF", XtRString, sizeof(String), XtOffset(AppResources *, ALF), XtRImmediate, NULL}, {"SCF", "SCF", XtRString, sizeof(String), XtOffset(AppResources *, SCF), XtRImmediate, NULL}, {"output", "output", XtRString, sizeof(String), XtOffset(AppResources *, output), XtRImmediate, NULL}, {"baseNum", "baseNum", XtRInt, sizeof(int), XtOffset(AppResources *, baseNum), XtRImmediate, (XtPointer) NULLBaseNum}, {"mag", "mag", XtRInt, sizeof(int), XtOffset(AppResources *, mag), XtRImmediate, NULL}, {"astring", "astring", XtRString, sizeof(String), XtOffset(AppResources *, astring), XtRImmediate, NULL}, {"bottom", "bottom", XtRInt, sizeof(int), XtOffset(AppResources *, bottom), XtRImmediate, NULL}, {"raw", "raw", XtRString, sizeof(String), XtOffset(AppResources *, raw), XtRImmediate, NULL}, {"enzyme", "enzyme", XtRString, sizeof(String), XtOffset(AppResources *, enzyme), XtRImmediate, NULL}, }; typedef struct { int magnif; String enz; } AppData, *AppDataPtr; #define XtNmagnif "magnif" #define XtCMagnif "Magnif" #define XtNenz "enz" #define XtCEnz "Enz" static XtResource resources[] = { { XtNmagnif, XtCMagnif, XtRInt, sizeof(int), XtOffset(AppDataPtr, magnif), XtRImmediate, (caddr_t)30 /* default is 30, although you can override that from the app-defaults file or on the command line */ }, { XtNenz, XtCEnz, XtRString, sizeof(String), XtOffset(AppDataPtr, enz), XtRImmediate, NULL } }; /* ---- Callbacks ---- */ static void inputCallback(Widget widget, XtPointer client_data, XtPointer call_data) { inputSeq(widget); } static void searchCallback(Widget widget, XtPointer client_data, XtPointer call_data) { inputSearchString(widget); } static void outputCallback(Widget widget, XtPointer client_data, XtPointer call_data) /* client_data contains the default (NULL) or command line specified output file name to be used. */ { /* this next statement was added by lfw 10/16/90, to assure that a default output filename of inputfilename.seq will be assigned.*/ if (client_data!=NULL) sprintf(o_fn,"%s",client_data); #ifdef DEF_OUT if (isDotNum(o_fn) != -1) stripDotNum(o_fn); if (!isDotSeq(o_fn)) strcat(o_fn,".seq"); /* ** This is an aweful way of accomplishing something very simple { char junk[strlen(o_fn)+5]; strcpy(junk,o_fn); sprintf(o_fn,"%s.seq",junk); } */ #endif outputSeq(widget, (String) o_fn); } static void helpCallback(Widget widget, XtPointer client_data, XtPointer call_data) { help(); } static void infoCallback(Widget widget, XtPointer client_data, XtPointer call_data) { information(widget); } static void quitCallback(Widget widget, XtPointer client_data, XtPointer call_data) { /* Quit the application */ quitApplication(widget); } /* ---- Internal functions ---- */ static void usage(int argc, char **argv) { int i; if (argc != 1) { fprintf(stderr, "%s: unknown option%s:", argv[0], (argc>2)?"s":""); for (i=1; i