From 15feb1c6c9d8d38b8d8e69435c15accb2629b4e7 Mon Sep 17 00:00:00 2001 From: Kuoi Date: Sun, 9 Apr 2023 02:17:32 +0800 Subject: [PATCH] fix: April 2023 archlinux --- CORE/BuiltIn.c | 2680 +++++++++++++++++++++------------------------- CORE/Genbank.c | 594 +++++----- CORE/HGLfile.c | 954 +++++++++-------- CORE/ParseMenu.c | 700 ++++++------ 4 files changed, 2341 insertions(+), 2587 deletions(-) diff --git a/CORE/BuiltIn.c b/CORE/BuiltIn.c index 6fcc470..18f4768 100755 --- a/CORE/BuiltIn.c +++ b/CORE/BuiltIn.c @@ -1,14 +1,15 @@ -#include #include +#include #include -#include -#include -#include -#include #include +#include +#include #include -#include "menudefs.h" +#include +#include + #include "defines.h" +#include "menudefs.h" /* Copyright (c) 1989-1990, University of Illinois board of trustees. All @@ -24,13 +25,10 @@ All rights reserved. Textsw comments_tsw; NA_Sequence *this_elem; - - -Open(mnu,mnuitm) -Menu mnu; +Open(mnu, mnuitm) Menu mnu; Menu_item mnuitm; { - extern Frame frame,pframe; + extern Frame frame, pframe; extern Panel popup; /* extern char FileName[]; @@ -38,36 +36,36 @@ Menu_item mnuitm; if(pframe) xv_destroy_safe(pframe); - pframe = xv_create(frame,FRAME_CMD, + pframe = xv_create(frame,FRAME_CMD, FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, + FRAME_DONE_PROC,FrameDone, FRAME_SHOW_RESIZE_CORNER,FALSE, - WIN_DESIRED_HEIGHT,100, - WIN_DESIRED_WIDTH,300, + WIN_DESIRED_HEIGHT,100, + WIN_DESIRED_WIDTH,300, FRAME_LABEL,"Open...", - XV_X,300, - XV_Y,150, - WIN_SHOW,FALSE, - 0); + XV_X,300, + XV_Y,150, + WIN_SHOW,FALSE, + 0); popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_HORIZONTAL, - 0); + PANEL_LAYOUT,PANEL_HORIZONTAL, + 0); popup = xv_get(pframe,FRAME_CMD_PANEL); popup = xv_get(pframe,FRAME_CMD_PANEL); (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"OK", + PANEL_LABEL_STRING,"OK", PANEL_NOTIFY_PROC,OpenFileName, - 0); + 0); (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"Cancel", - PANEL_NOTIFY_PROC,DONT, - 0); + PANEL_LABEL_STRING,"Cancel", + PANEL_NOTIFY_PROC,DONT, + 0); (void)xv_set(popup, - PANEL_LAYOUT,PANEL_VERTICAL, + PANEL_LAYOUT,PANEL_VERTICAL, 0); (void)xv_create(popup,PANEL_TEXT, @@ -83,114 +81,90 @@ Menu_item mnuitm; (void)xv_set(pframe,XV_SHOW,TRUE,0); */ - (void)load_file(frame,300,150,NULL); - return(XV_OK); + (void)load_file(frame, 300, 150, NULL); + return (XV_OK); } - -SaveAs(mnu,mnuitm) -Menu mnu; +SaveAs(mnu, mnuitm) Menu mnu; Menu_item mnuitm; { - extern Frame frame,pframe; + extern Frame frame, pframe; extern Panel popup; extern char FileName[]; extern NA_Alignment *DataSet; NA_Alignment *aln; - if(pframe) - xv_destroy_safe(pframe); + if (pframe) xv_destroy_safe(pframe); - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - aln = (NA_Alignment*)DataSet; + aln = (NA_Alignment *)DataSet; - pframe = xv_create(frame,FRAME_CMD, - FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, - FRAME_SHOW_RESIZE_CORNER,FALSE, - WIN_DESIRED_HEIGHT,100, - WIN_DESIRED_WIDTH,300, - FRAME_LABEL,"Save alignment as...", - XV_X,300, - XV_Y,150, - WIN_SHOW,FALSE, - 0); + pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE, + FRAME_DONE_PROC, FrameDone, FRAME_SHOW_RESIZE_CORNER, + FALSE, WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, + 300, FRAME_LABEL, "Save alignment as...", XV_X, 300, + XV_Y, 150, WIN_SHOW, FALSE, 0); -/* - popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_HORIZONTAL, - 0); -*/ + /* + popup = xv_find(pframe,PANEL, + PANEL_LAYOUT,PANEL_HORIZONTAL, + 0); + */ - popup = xv_get(pframe,FRAME_CMD_PANEL); - (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"OK", - PANEL_NOTIFY_PROC,SaveAsFileName, - 0); + popup = xv_get(pframe, FRAME_CMD_PANEL); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "OK", + PANEL_NOTIFY_PROC, SaveAsFileName, 0); - (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"Cancel", - PANEL_NOTIFY_PROC,DONT, - 0); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "Cancel", + PANEL_NOTIFY_PROC, DONT, 0); - (void)xv_set(popup, - PANEL_LAYOUT,PANEL_VERTICAL, - 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); - (void)xv_create(popup,PANEL_CHOICE, - PANEL_LAYOUT,PANEL_HORIZONTAL, - PANEL_NOTIFY_PROC,SaveFormat, - PANEL_LABEL_STRING,"Format:", - PANEL_CHOICE_STRING,0,"Genbank", - PANEL_CHOICE_STRING,1,"Flat file", - PANEL_CHOICE_STRING,2,"GDE", - PANEL_VALUE,aln->format == GENBANK?0: - (aln->format == GDE)?2:1, - 0); + (void)xv_create(popup, PANEL_CHOICE, PANEL_LAYOUT, PANEL_HORIZONTAL, + PANEL_NOTIFY_PROC, SaveFormat, PANEL_LABEL_STRING, + "Format:", PANEL_CHOICE_STRING, 0, "Genbank", + PANEL_CHOICE_STRING, 1, "Flat file", + PANEL_CHOICE_STRING, 2, "GDE", PANEL_VALUE, + aln->format == GENBANK ? 0 + : (aln->format == GDE) ? 2 + : 1, + 0); - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,20, - PANEL_LABEL_STRING,"File name?", - PANEL_NOTIFY_PROC,SetFilename, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_VALUE,FileName, - 0); + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, 20, + PANEL_LABEL_STRING, "File name?", PANEL_NOTIFY_PROC, + SetFilename, PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_VALUE, + FileName, 0); window_fit(popup); window_fit(pframe); - (void)xv_set(pframe,XV_SHOW,TRUE,0); + (void)xv_set(pframe, XV_SHOW, TRUE, 0); - return(XV_OK); + return (XV_OK); } - -SaveFormat(item,event) -Panel_item item; +SaveFormat(item, event) Panel_item item; Event *event; { extern NA_Alignment *DataSet; NA_Alignment *aln; int format; - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - format = xv_get(item,PANEL_VALUE); - DataSet->format = (format == 0)? - GENBANK:(format == 1)? NA_FLAT:GDE; - return(XV_OK); + format = xv_get(item, PANEL_VALUE); + DataSet->format = (format == 0) ? GENBANK + : (format == 1) ? NA_FLAT + : GDE; + return (XV_OK); } - -SaveAsFileName(item,event) -Panel_item item; +SaveAsFileName(item, event) Panel_item item; Event *event; { extern NA_Alignment *DataSet; - extern char FileName[]; /* rtm 18.III.98 */ + extern char FileName[]; /* rtm 18.III.98 */ char *file; int j; @@ -198,111 +172,97 @@ Event *event; file = FileName; DONT(); - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - switch( ((NA_Alignment*)DataSet)->format ) - { - case GENBANK: - WriteGen(DataSet,file,ALL,FALSE); - break; - case NA_FLAT: - WriteNA_Flat(DataSet,file,ALL,FALSE); - break; - case GDE: - WriteGDE(DataSet,file,ALL,FALSE); - break; - default: - fprintf(stderr,"Unknown file type for write\n"); - break; + switch (((NA_Alignment *)DataSet)->format) { + case GENBANK: + WriteGen(DataSet, file, ALL, FALSE); + break; + case NA_FLAT: + WriteNA_Flat(DataSet, file, ALL, FALSE); + break; + case GDE: + WriteGDE(DataSet, file, ALL, FALSE); + break; + default: + fprintf(stderr, "Unknown file type for write\n"); + break; } - return(XV_OK); + return (XV_OK); } - - -act_on_it_lf(filename,data) -char filename[]; +act_on_it_lf(filename, data) char filename[]; Xv_opaque data; { - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; Xv_window view; - Scrollbar hscroll,vscroll; + Scrollbar hscroll, vscroll; int j; - if(filename == NULL) - return(XV_OK); + if (filename == NULL) return (XV_OK); LoadData(filename); - for(j=0;jna_ddata = (char*)SetNADData - ((NA_Alignment*)DataSet,EditCan,EditNameCan); - return(XV_OK); + if (DataSet != NULL) + ((NA_Alignment *)DataSet)->na_ddata = (char *)SetNADData( + (NA_Alignment *)DataSet, EditCan, EditNameCan); + return (XV_OK); } -act_on_it_sf(){ -} +act_on_it_sf() {} -OpenFileName(item,event) -Panel_item item; +OpenFileName(item, event) Panel_item item; Event *event; { - extern char FileName[]; /* rtm 18.III.98 */ - extern Canvas EditCan,EditNameCan; - extern NA_Alignment *DataSet; - Xv_window view; + extern char FileName[]; /* rtm 18.III.98 */ + extern Canvas EditCan, EditNameCan; + extern NA_Alignment *DataSet; + Xv_window view; - char *file; - int j; - NA_DisplayData *ddata; - Scrollbar hscroll,vscroll; + char *file; + int j; + NA_DisplayData *ddata; + Scrollbar hscroll, vscroll; /* -* major kluge in progress, if event is NULL, then item is -* really a pointer to the name of a file to be read in -*/ + * major kluge in progress, if event is NULL, then item is + * really a pointer to the name of a file to be read in + */ - if(event != NULL) + if (event != NULL) file = FileName; else - file = (char*)item; + file = (char *)item; DONT(); LoadData(file); - for(j=0;jna_ddata = (char*)SetNADData - ((NA_Alignment*)DataSet,EditCan,EditNameCan); - return(XV_OK); + if (DataSet != NULL) + ((NA_Alignment *)DataSet)->na_ddata = (char *)SetNADData( + (NA_Alignment *)DataSet, EditCan, EditNameCan); + return (XV_OK); } - /* Copyright (c) 1989, University of Illinois board of trustees. All rights reserved. Written by Steven Smith at the Center for Prokaryote Genome @@ -330,289 +289,239 @@ Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory. All rights reserved. */ - -ChangeDisplay(item,event) -Panel_item item; +ChangeDisplay(item, event) Panel_item item; Event *event; { extern Canvas EditCan; - extern Frame pframe,frame; + extern Frame pframe, frame; extern Panel popup; extern NA_Alignment *DataSet; - extern EditMode,EditDir,DisplayAttr; + extern EditMode, EditDir, DisplayAttr; extern int SCALE; NA_DisplayData *na_dd; - int color,font_size; + int color, font_size; GC gc; Display *dpy; Xv_font font; - if(DataSet == NULL) - { + if (DataSet == NULL) { Warning("Must load a dataset first"); - return(XV_OK); + return (XV_OK); } - na_dd = (NA_DisplayData*)(((NA_Alignment*)DataSet)->na_ddata); - if(na_dd == NULL) - { + na_dd = (NA_DisplayData *)(((NA_Alignment *)DataSet)->na_ddata); + if (na_dd == NULL) { Warning("Must load a dataset first"); - return(XV_OK); + return (XV_OK); } - switch(na_dd->color_type) - { - case COLOR_MONO: - color = 0; - break; - case COLOR_LOOKUP: - color = 1; - break; - case COLOR_ALN_MASK: - color = 2; - break; - case COLOR_SEQ_MASK: - color = 3; - break; - case COLOR_STRAND: - color = 4; - break; - default: - break; + switch (na_dd->color_type) { + case COLOR_MONO: + color = 0; + break; + case COLOR_LOOKUP: + color = 1; + break; + case COLOR_ALN_MASK: + color = 2; + break; + case COLOR_SEQ_MASK: + color = 3; + break; + case COLOR_STRAND: + color = 4; + break; + default: + break; } xv_destroy_safe(pframe); - pframe = xv_create(frame,FRAME_CMD, - FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, - FRAME_SHOW_RESIZE_CORNER,FALSE, - FRAME_LABEL,"Properties", - XV_X,300, - XV_Y,150, - WIN_SHOW,FALSE, - 0); + pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE, + FRAME_DONE_PROC, FrameDone, FRAME_SHOW_RESIZE_CORNER, + FALSE, FRAME_LABEL, "Properties", XV_X, 300, XV_Y, + 150, WIN_SHOW, FALSE, 0); -/* - popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_HORIZONTAL, - 0); -*/ + /* + popup = xv_find(pframe,PANEL, + PANEL_LAYOUT,PANEL_HORIZONTAL, + 0); + */ - popup = xv_get(pframe,FRAME_CMD_PANEL); - (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"OK", - PANEL_NOTIFY_PROC,ChDisplayDone, - 0); + popup = xv_get(pframe, FRAME_CMD_PANEL); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "OK", + PANEL_NOTIFY_PROC, ChDisplayDone, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL,0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); - (void)xv_create(popup,PANEL_CHOICE_STACK, - PANEL_LAYOUT,PANEL_VERTICAL, - PANEL_LABEL_STRING,"Color type", - PANEL_NOTIFY_PROC,ChColor, - PANEL_CHOICE_STRING,0,"Monochrome", - PANEL_CHOICE_STRING,1,"Character->color", - PANEL_CHOICE_STRING,2,"Alignment color mask", - PANEL_CHOICE_STRING,3,"Sequence color mask", - PANEL_CHOICE_STRING,4,"Strand->color", - PANEL_CHOOSE_NONE,FALSE, - PANEL_VALUE,color, - 0); + (void)xv_create(popup, PANEL_CHOICE_STACK, PANEL_LAYOUT, PANEL_VERTICAL, + PANEL_LABEL_STRING, "Color type", PANEL_NOTIFY_PROC, + ChColor, PANEL_CHOICE_STRING, 0, "Monochrome", + PANEL_CHOICE_STRING, 1, "Character->color", + PANEL_CHOICE_STRING, 2, "Alignment color mask", + PANEL_CHOICE_STRING, 3, "Sequence color mask", + PANEL_CHOICE_STRING, 4, "Strand->color", + PANEL_CHOOSE_NONE, FALSE, PANEL_VALUE, color, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_HORIZONTAL,0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_HORIZONTAL, 0); dpy = (Display *)xv_get(EditCan, XV_DISPLAY); - gc = DefaultGC(dpy,DefaultScreen(dpy)); + gc = DefaultGC(dpy, DefaultScreen(dpy)); - font = xv_get(frame,XV_FONT); - switch(xv_get(font,FONT_SCALE)) - { - case WIN_SCALE_EXTRALARGE: - font_size = 0; - break; - case WIN_SCALE_LARGE: - font_size = 1; - break; - case WIN_SCALE_MEDIUM: - font_size = 2; - break; - case WIN_SCALE_SMALL: - font_size = 3; - break; - default: - font_size = 2; - break; + font = xv_get(frame, XV_FONT); + switch (xv_get(font, FONT_SCALE)) { + case WIN_SCALE_EXTRALARGE: + font_size = 0; + break; + case WIN_SCALE_LARGE: + font_size = 1; + break; + case WIN_SCALE_MEDIUM: + font_size = 2; + break; + case WIN_SCALE_SMALL: + font_size = 3; + break; + default: + font_size = 2; + break; } - (void)xv_create(popup,PANEL_CHOICE_STACK, - PANEL_LAYOUT,PANEL_VERTICAL, - PANEL_NOTIFY_PROC,ChFontSize, - PANEL_LABEL_STRING,"Font Size", - PANEL_CHOICE_STRING,0,"Extra large", - PANEL_CHOICE_STRING,1,"Large", - PANEL_CHOICE_STRING,2,"Medium", - PANEL_CHOICE_STRING,3,"Small", - PANEL_CHOOSE_NONE,FALSE, - PANEL_VALUE,font_size, - 0); + (void)xv_create(popup, PANEL_CHOICE_STACK, PANEL_LAYOUT, PANEL_VERTICAL, + PANEL_NOTIFY_PROC, ChFontSize, PANEL_LABEL_STRING, + "Font Size", PANEL_CHOICE_STRING, 0, "Extra large", + PANEL_CHOICE_STRING, 1, "Large", PANEL_CHOICE_STRING, 2, + "Medium", PANEL_CHOICE_STRING, 3, "Small", + PANEL_CHOOSE_NONE, FALSE, PANEL_VALUE, font_size, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL,0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); - (void)xv_create(popup,PANEL_CHOICE, - PANEL_LAYOUT,PANEL_HORIZONTAL, - PANEL_NOTIFY_PROC,ChEditMode, - PANEL_LABEL_STRING,"Editing mode", - PANEL_CHOICE_STRING,0,"Insert", - PANEL_CHOICE_STRING,1,"Check", - PANEL_VALUE,EditMode, - 0); + (void)xv_create(popup, PANEL_CHOICE, PANEL_LAYOUT, PANEL_HORIZONTAL, + PANEL_NOTIFY_PROC, ChEditMode, PANEL_LABEL_STRING, + "Editing mode", PANEL_CHOICE_STRING, 0, "Insert", + PANEL_CHOICE_STRING, 1, "Check", PANEL_VALUE, EditMode, + 0); - (void)xv_create(popup,PANEL_CHECK_BOX, - PANEL_LAYOUT,PANEL_VERTICAL, - PANEL_CHOICE_STRINGS, - "Inverted","Lock vertical scroll","Key clicks","Message panel", - 0, - PANEL_NOTIFY_PROC,ChDisAttr, - PANEL_VALUE,DisplayAttr, - 0); + (void)xv_create(popup, PANEL_CHECK_BOX, PANEL_LAYOUT, PANEL_VERTICAL, + PANEL_CHOICE_STRINGS, "Inverted", + "Lock vertical scroll", "Key clicks", "Message panel", + 0, PANEL_NOTIFY_PROC, ChDisAttr, PANEL_VALUE, + DisplayAttr, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_HORIZONTAL,0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_HORIZONTAL, 0); - (void)xv_create(popup,PANEL_CHOICE, - PANEL_LAYOUT,PANEL_VERTICAL, - PANEL_NOTIFY_PROC,ChEditDir, - PANEL_LABEL_STRING,"Insertion", - PANEL_CHOICE_STRING,0,"Right of cursor", - PANEL_CHOICE_STRING,1,"Left of cursor", - PANEL_VALUE,EditDir, - 0); - - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL,0); - (void)xv_create(popup,PANEL_SLIDER, - PANEL_LABEL_STRING,"Scale:", - PANEL_MIN_VALUE,1, - PANEL_MAX_VALUE,20, - PANEL_VALUE,SCALE, - PANEL_NOTIFY_PROC,SetScale, - 0); + (void)xv_create(popup, PANEL_CHOICE, PANEL_LAYOUT, PANEL_VERTICAL, + PANEL_NOTIFY_PROC, ChEditDir, PANEL_LABEL_STRING, + "Insertion", PANEL_CHOICE_STRING, 0, "Right of cursor", + PANEL_CHOICE_STRING, 1, "Left of cursor", PANEL_VALUE, + EditDir, 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + (void)xv_create(popup, PANEL_SLIDER, PANEL_LABEL_STRING, + "Scale:", PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 20, + PANEL_VALUE, SCALE, PANEL_NOTIFY_PROC, SetScale, 0); window_fit(popup); window_fit(pframe); - (void)xv_set(pframe,XV_SHOW,TRUE,0); + (void)xv_set(pframe, XV_SHOW, TRUE, 0); - return(XV_OK); -} - -SetScale(item,event) -Panel_item item; -Event *event; -{ - extern int SCALE; - SCALE = xv_get(item,PANEL_VALUE); return (XV_OK); } - -ChColor(item,event) -Panel_item item; +SetScale(item, event) Panel_item item; Event *event; { - int i,j; + extern int SCALE; + SCALE = xv_get(item, PANEL_VALUE); + return (XV_OK); +} + +ChColor(item, event) Panel_item item; +Event *event; +{ + int i, j; NA_DisplayData *ddata; extern NA_Alignment *DataSet; - if(DataSet == NULL) - return(XV_OK); - ddata = (NA_DisplayData*)((NA_Alignment*)DataSet) ->na_ddata; + if (DataSet == NULL) return (XV_OK); + ddata = (NA_DisplayData *)((NA_Alignment *)DataSet)->na_ddata; - switch(xv_get(item,PANEL_VALUE)) - { - case 0: - ddata->color_type = COLOR_MONO; - break; - case 1: - ddata->color_type = COLOR_LOOKUP; - break; - case 2: - ddata->color_type = COLOR_ALN_MASK; - break; - case 3: - ddata->color_type = COLOR_SEQ_MASK; - break; - case 4: - ddata->color_type = COLOR_STRAND; - break; - default: - break; + switch (xv_get(item, PANEL_VALUE)) { + case 0: + ddata->color_type = COLOR_MONO; + break; + case 1: + ddata->color_type = COLOR_LOOKUP; + break; + case 2: + ddata->color_type = COLOR_ALN_MASK; + break; + case 3: + ddata->color_type = COLOR_SEQ_MASK; + break; + case 4: + ddata->color_type = COLOR_STRAND; + break; + default: + break; } - return(XV_OK); + return (XV_OK); } - -ChFontSize(item,event) -Panel_item item; +ChFontSize(item, event) Panel_item item; Event *event; { - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; - int i,j,fnt_style; + int i, j, fnt_style; GC gc; Display *dpy; XGCValues gcv; Xv_font font; extern Frame frame; - font = xv_get(frame,XV_FONT); - fnt_style = (int)xv_get(font,FONT_STYLE); + font = xv_get(frame, XV_FONT); + fnt_style = (int)xv_get(font, FONT_STYLE); dpy = (Display *)xv_get(EditCan, XV_DISPLAY); - gc = DefaultGC(dpy,DefaultScreen(dpy)); + gc = DefaultGC(dpy, DefaultScreen(dpy)); - switch(xv_get(item,PANEL_VALUE)) - { - case 0: - font = (Xv_font)xv_find(frame,FONT, - FONT_FAMILY,FONT_FAMILY_DEFAULT_FIXEDWIDTH, - FONT_STYLE,fnt_style, - FONT_SCALE,WIN_SCALE_EXTRALARGE, - 0); - break; - case 1: - font = (Xv_font)xv_find(frame,FONT, - FONT_FAMILY,FONT_FAMILY_DEFAULT_FIXEDWIDTH, - FONT_STYLE,fnt_style, - FONT_SCALE,WIN_SCALE_LARGE, - 0); - break; - case 2: - font = (Xv_font)xv_find(frame,FONT, - FONT_FAMILY,FONT_FAMILY_DEFAULT_FIXEDWIDTH, - FONT_STYLE,fnt_style, - FONT_SCALE,WIN_SCALE_MEDIUM, - 0); - break; - case 3: - font = (Xv_font)xv_find(frame,FONT, - FONT_FAMILY,FONT_FAMILY_DEFAULT_FIXEDWIDTH, - FONT_STYLE,fnt_style, - FONT_SCALE,WIN_SCALE_SMALL, - 0); - break; - default: - break; + switch (xv_get(item, PANEL_VALUE)) { + case 0: + font = (Xv_font)xv_find( + frame, FONT, FONT_FAMILY, + FONT_FAMILY_DEFAULT_FIXEDWIDTH, FONT_STYLE, + fnt_style, FONT_SCALE, WIN_SCALE_EXTRALARGE, 0); + break; + case 1: + font = (Xv_font)xv_find(frame, FONT, FONT_FAMILY, + FONT_FAMILY_DEFAULT_FIXEDWIDTH, + FONT_STYLE, fnt_style, + FONT_SCALE, WIN_SCALE_LARGE, 0); + break; + case 2: + font = (Xv_font)xv_find( + frame, FONT, FONT_FAMILY, + FONT_FAMILY_DEFAULT_FIXEDWIDTH, FONT_STYLE, + fnt_style, FONT_SCALE, WIN_SCALE_MEDIUM, 0); + break; + case 3: + font = (Xv_font)xv_find(frame, FONT, FONT_FAMILY, + FONT_FAMILY_DEFAULT_FIXEDWIDTH, + FONT_STYLE, fnt_style, + FONT_SCALE, WIN_SCALE_SMALL, 0); + break; + default: + break; } - (void)xv_set(frame,XV_FONT,font,0); - gcv.font = (Font)xv_get(font,XV_XID); + (void)xv_set(frame, XV_FONT, font, 0); + gcv.font = (Font)xv_get(font, XV_XID); - if(gcv.font != (Font) NULL) - XChangeGC(dpy,gc,GCFont,&gcv); + if (gcv.font != (Font)NULL) XChangeGC(dpy, gc, GCFont, &gcv); - (void)SetNADData(DataSet,EditCan,EditNameCan); - return(XV_OK); + (void)SetNADData(DataSet, EditCan, EditNameCan); + return (XV_OK); } - ChDisplayDone() { extern Frame frame; @@ -620,103 +529,75 @@ ChDisplayDone() DONT(); RepaintAll(FALSE); - return(XV_OK); + return (XV_OK); } -SetProtection(item,event) -Panel_item item; +SetProtection(item, event) Panel_item item; Event *event; { int j; unsigned int current_prot; NA_Alignment *aln; - int mismatch_prot = FALSE,num_selected = 0; + int mismatch_prot = FALSE, num_selected = 0; - extern Frame pframe,frame; + extern Frame pframe, frame; extern Panel popup; extern NA_Alignment *DataSet; + if (DataSet == NULL) return (XV_OK); - if(DataSet == NULL) - return(XV_OK); + aln = (NA_Alignment *)DataSet; + if (aln->numelements == 0) return (XV_OK); - aln = (NA_Alignment*)DataSet; - if(aln->numelements == 0) - return(XV_OK); - - for(j=0;jnumelements;j++) - if(aln->element[j].selected) - { + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].selected) { current_prot = aln->element[j].protect; num_selected++; } - for(j=0;jnumelements;j++) - if(aln->element[j].selected && aln->element[j].protect - != current_prot) - { - current_prot=0; + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].selected && + aln->element[j].protect != current_prot) { + current_prot = 0; mismatch_prot = TRUE; } xv_destroy_safe(pframe); - pframe = xv_create(frame,FRAME_CMD, - FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, - FRAME_SHOW_RESIZE_CORNER,FALSE, - WIN_DESIRED_HEIGHT,100, - WIN_DESIRED_WIDTH,300, - XV_X,300, - XV_Y,150, - XV_SHOW,FALSE, - 0); + pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE, + FRAME_DONE_PROC, FrameDone, FRAME_SHOW_RESIZE_CORNER, + FALSE, WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, + 300, XV_X, 300, XV_Y, 150, XV_SHOW, FALSE, 0); + /* + popup = xv_find(pframe,PANEL, + PANEL_LAYOUT,PANEL_VERTICAL, + 0); + */ + popup = xv_get(pframe, FRAME_CMD_PANEL); -/* - popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_VERTICAL, - 0); -*/ - popup = xv_get(pframe,FRAME_CMD_PANEL); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "Done", + PANEL_NOTIFY_PROC, DONT, 0); + if (mismatch_prot) + (void)xv_create(popup, PANEL_MESSAGE, PANEL_LABEL_STRING, + "Warning: Current protections differ", NULL); + if (num_selected == 0) + (void)xv_create(popup, PANEL_MESSAGE, PANEL_LABEL_STRING, + "Warning: No sequences selected", NULL); - (void)xv_create(popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"Done", - PANEL_NOTIFY_PROC,DONT, - 0); - if(mismatch_prot) - (void)xv_create(popup,PANEL_MESSAGE, - PANEL_LABEL_STRING, - "Warning: Current protections differ",NULL); - if(num_selected == 0) - (void)xv_create(popup,PANEL_MESSAGE, - PANEL_LABEL_STRING,"Warning: No sequences selected", - NULL); - - - (void)xv_create(popup,PANEL_CHECK_BOX, - PANEL_LAYOUT,PANEL_VERTICAL, - PANEL_CHOOSE_ONE,FALSE, - PANEL_LABEL_STRING,"Allowed modifications:", - PANEL_CHOICE_STRINGS, - "unambiguous characters", - "ambiguous characters", - "alignment gaps", - "translations", - NULL, - PANEL_NOTIFY_PROC,Prot, - PANEL_VALUE,current_prot, - 0); + (void)xv_create(popup, PANEL_CHECK_BOX, PANEL_LAYOUT, PANEL_VERTICAL, + PANEL_CHOOSE_ONE, FALSE, PANEL_LABEL_STRING, + "Allowed modifications:", PANEL_CHOICE_STRINGS, + "unambiguous characters", "ambiguous characters", + "alignment gaps", "translations", NULL, + PANEL_NOTIFY_PROC, Prot, PANEL_VALUE, current_prot, 0); window_fit(popup); window_fit(pframe); - (void)xv_set(pframe,XV_SHOW,TRUE, - FRAME_LABEL,"Set Protections",0); + (void)xv_set(pframe, XV_SHOW, TRUE, FRAME_LABEL, "Set Protections", 0); - return(XV_OK); + return (XV_OK); } - -Prot(item,event) -Panel_item item; +Prot(item, event) Panel_item item; Event *event; { int j; @@ -724,703 +605,572 @@ Event *event; NA_Alignment *aln; extern NA_Alignment *DataSet; + if (DataSet == NULL) return (XV_OK); - if(DataSet == NULL) - return(XV_OK); + aln = (NA_Alignment *)DataSet; + if (aln->numelements == 0) return (XV_OK); - aln = (NA_Alignment*)DataSet; - if(aln->numelements == 0) - return(XV_OK); - - current_prot = xv_get(item,PANEL_VALUE); - for(j=0;jnumelements;j++) - if(aln->element[j].selected) + current_prot = xv_get(item, PANEL_VALUE); + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].selected) aln->element[j].protect = current_prot; - return(XV_OK); + return (XV_OK); } - -SelectAll(item,event) -Panel_item item; +SelectAll(item, event) Panel_item item; Event *event; { int i; extern NA_Alignment *DataSet; extern Canvas EditNameCan; Display *dpy; - NA_Alignment *aln = (NA_Alignment*)DataSet; + NA_Alignment *aln = (NA_Alignment *)DataSet; - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - for(i=0;inumelements;i++) - aln->element[i].selected = TRUE; + for (i = 0; i < aln->numelements; i++) aln->element[i].selected = TRUE; - dpy = (Display*)xv_get(EditNameCan, XV_DISPLAY); - DrawNANames(dpy,xv_get(canvas_paint_window(EditNameCan),XV_XID)); - return(XV_OK); + dpy = (Display *)xv_get(EditNameCan, XV_DISPLAY); + DrawNANames(dpy, xv_get(canvas_paint_window(EditNameCan), XV_XID)); + return (XV_OK); } -SelectBy(item,event) -Panel_item item; +SelectBy(item, event) Panel_item item; Event *event; { extern Panel popup; int i; extern NA_Alignment *DataSet; - extern Frame pframe,frame; + extern Frame pframe, frame; Display *dpy; - NA_Alignment *aln = (NA_Alignment*)DataSet; + NA_Alignment *aln = (NA_Alignment *)DataSet; xv_destroy_safe(pframe); - pframe = xv_create(frame,FRAME_CMD, - FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, - FRAME_SHOW_RESIZE_CORNER,FALSE, - FRAME_LABEL,"Select sequences by name", - WIN_DESIRED_HEIGHT,100, - WIN_DESIRED_WIDTH,300, - XV_X,300, - XV_Y,150, - WIN_SHOW,FALSE, - 0); + pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE, + FRAME_DONE_PROC, FrameDone, FRAME_SHOW_RESIZE_CORNER, + FALSE, FRAME_LABEL, "Select sequences by name", + WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, 300, + XV_X, 300, XV_Y, 150, WIN_SHOW, FALSE, 0); -/* - popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_HORIZONTAL, - 0); -*/ - popup = xv_get(pframe,FRAME_CMD_PANEL); - (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"Done", - PANEL_NOTIFY_PROC,DONT, - 0); + /* + popup = xv_find(pframe,PANEL, + PANEL_LAYOUT,PANEL_HORIZONTAL, + 0); + */ + popup = xv_get(pframe, FRAME_CMD_PANEL); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "Done", + PANEL_NOTIFY_PROC, DONT, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, - 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,20, - PANEL_LABEL_STRING,"Search for?", - PANEL_NOTIFY_PROC,SelectByName, - 0); + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, 20, + PANEL_LABEL_STRING, "Search for?", PANEL_NOTIFY_PROC, + SelectByName, 0); window_fit(popup); window_fit(pframe); - (void)xv_set(pframe,XV_SHOW,TRUE,0); + (void)xv_set(pframe, XV_SHOW, TRUE, 0); - return(XV_OK); + return (XV_OK); } -SelectByName(item,event) -Panel_item item; +SelectByName(item, event) Panel_item item; Event *event; { extern NA_Alignment *DataSet; - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; char search[80]; Display *dpy; Xv_window view; - int i,lastselected; + int i, lastselected; - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - strncpy(search,(char*)(xv_get(item,PANEL_VALUE)),79); + strncpy(search, (char *)(xv_get(item, PANEL_VALUE)), 79); - for(i=0;inumelements;i++) - if(Find(DataSet->element[i].short_name,search)) - { + for (i = 0; i < DataSet->numelements; i++) + if (Find(DataSet->element[i].short_name, search)) { DataSet->element[i].selected = TRUE; lastselected = i; } - dpy = (Display*)xv_get(EditNameCan, XV_DISPLAY); - DrawNANames(dpy,xv_get(canvas_paint_window(EditNameCan),XV_XID)); - view = (Xv_window)xv_get(EditCan,OPENWIN_NTH_VIEW,0); - - OPENWIN_EACH_VIEW(EditCan,(view)) - JumpTo(view, 0,lastselected); + dpy = (Display *)xv_get(EditNameCan, XV_DISPLAY); + DrawNANames(dpy, xv_get(canvas_paint_window(EditNameCan), XV_XID)); + view = (Xv_window)xv_get(EditCan, OPENWIN_NTH_VIEW, 0); + + OPENWIN_EACH_VIEW(EditCan, (view)) + JumpTo(view, 0, lastselected); OPENWIN_END_EACH; - (void)xv_set(item,PANEL_VALUE,"",0); - - return(XV_OK); + (void)xv_set(item, PANEL_VALUE, "", 0); + return (XV_OK); } - -Group(item,event) -Panel_item item; +Group(item, event) Panel_item item; Event *event; { - int j,old_groups = FALSE,result; - extern Canvas EditCan,EditNameCan; + int j, old_groups = FALSE, result; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; extern Frame frame; Display *dpy; NA_Alignment *aln; - NA_Sequence *temp = NULL,*element; + NA_Sequence *temp = NULL, *element; - if(DataSet == NULL) - return(XV_OK); - aln = (NA_Alignment*)DataSet; - if(aln == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); + aln = (NA_Alignment *)DataSet; + if (aln == NULL) return (XV_OK); element = aln->element; - for(j=0;jnumelements;j++) - if((element[j].groupid !=0 ) && element[j].selected) + for (j = 0; j < aln->numelements; j++) + if ((element[j].groupid != 0) && element[j].selected) old_groups = TRUE; - if(old_groups) - { - result = notice_prompt(frame,NULL, - NOTICE_MESSAGE_STRINGS, + if (old_groups) { + result = notice_prompt( + frame, NULL, NOTICE_MESSAGE_STRINGS, "Groups already exist. Do you wish to", - "Merge these groups, create a new group,", - "or cancel?", - NULL, - NOTICE_BUTTON,"Merge groups",1, - NOTICE_BUTTON,"Create new group",2, - NOTICE_BUTTON,"Cancel",3, - 0); - switch(result) - { - case 3: - break; - case 2: - for(j=0;jnumelements;j++) - if(element[j].selected) - RemoveFromGroup(&(element[j])); - for(j=0;jnumelements;j++) - { - if(element[j].selected) - { - element[j].groupid = - aln->numgroups+1; - element[j].groupb = temp; - if(temp != NULL) - temp->groupf = - &(element[j]); - temp = &(element[j]); + "Merge these groups, create a new group,", "or cancel?", + NULL, NOTICE_BUTTON, "Merge groups", 1, NOTICE_BUTTON, + "Create new group", 2, NOTICE_BUTTON, "Cancel", 3, 0); + switch (result) { + case 3: + break; + case 2: + for (j = 0; j < aln->numelements; j++) + if (element[j].selected) + RemoveFromGroup(&(element[j])); + for (j = 0; j < aln->numelements; j++) { + if (element[j].selected) { + element[j].groupid = + aln->numgroups + 1; + element[j].groupb = temp; + if (temp != NULL) + temp->groupf = + &(element[j]); + temp = &(element[j]); + } } - } - if(temp != NULL) - temp->groupf = NULL; - if(temp != NULL) - if(temp->groupb !=NULL) - { - aln->numgroups++; - AdjustGroups(aln); - DrawNANames(xv_get(EditNameCan, - XV_DISPLAY),xv_get - (canvas_paint_window( - EditNameCan),XV_XID)); + if (temp != NULL) temp->groupf = NULL; + if (temp != NULL) + if (temp->groupb != NULL) { + aln->numgroups++; + AdjustGroups(aln); + DrawNANames( + xv_get(EditNameCan, + XV_DISPLAY), + xv_get(canvas_paint_window( + EditNameCan), + XV_XID)); + } + break; + case 1: + temp = NULL; + for (j = 0; j < aln->numelements; j++) { + if (element[j].selected) { + if (temp != NULL) + MergeGroups( + temp, + &(element[j])); + temp = &(element[j]); + } } - break; - case 1: - temp = NULL; - for(j=0;jnumelements;j++) - { - if(element[j].selected) - { - if(temp != NULL) - MergeGroups(temp,&(element[j])); - temp = &(element[j]); - } - } - AdjustGroups(aln); - DrawNANames(xv_get(EditNameCan,XV_DISPLAY), - xv_get(canvas_paint_window(EditNameCan), - XV_XID)); - break; + AdjustGroups(aln); + DrawNANames( + xv_get(EditNameCan, XV_DISPLAY), + xv_get(canvas_paint_window(EditNameCan), + XV_XID)); + break; } } - else - { + else { temp = NULL; - for(j=0;jnumelements;j++) - { - if(element[j].selected) - { - element[j].groupid = aln->numgroups+1; + for (j = 0; j < aln->numelements; j++) { + if (element[j].selected) { + element[j].groupid = aln->numgroups + 1; element[j].groupb = temp; - if(temp != NULL) - temp->groupf = &(element[j]); + if (temp != NULL) temp->groupf = &(element[j]); temp = &(element[j]); } } - if(temp != NULL) - { + if (temp != NULL) { temp->groupf = NULL; - if(temp->groupb !=NULL) - { + if (temp->groupb != NULL) { aln->numgroups++; - DrawNANames(xv_get(EditNameCan, XV_DISPLAY), + DrawNANames( + xv_get(EditNameCan, XV_DISPLAY), xv_get(canvas_paint_window(EditNameCan), - XV_XID)); + XV_XID)); } } } - return(XV_OK); + return (XV_OK); } -RemoveFromGroup(element) -NA_Sequence *element; +RemoveFromGroup(element) NA_Sequence *element; { - if(element == NULL) - return(XV_OK); + if (element == NULL) return (XV_OK); - if(element->groupb) - (NA_Sequence*)(element->groupb)->groupf = element->groupf; + if (element->groupb) + //(NA_Sequence*)(element->groupb)->groupf = element->groupf; + { + NA_Sequence *temp1 = (NA_Sequence *)(element->groupb); + temp1->groupf = element->groupf; + } - if(element->groupf) - (NA_Sequence*)(element->groupf)->groupb = element->groupb; + if (element->groupf) + //(NA_Sequence *)(element->groupf)->groupb = element->groupb; + { + NA_Sequence *temp2 = (NA_Sequence *)(element->groupf); + temp2->groupb = element->groupb; + } element->groupf = NULL; element->groupb = NULL; element->groupid = 0; - return(XV_OK); + return (XV_OK); } - -AdjustGroups(aln) -NA_Alignment *aln; +AdjustGroups(aln) NA_Alignment *aln; { - int i,j,c,done=FALSE; + int i, j, c, done = FALSE; #ifdef HGL return; #else - for(c=0;c<200 && !done;c++) - { - for(j=1;j<=aln->numgroups;j++) - { + for (c = 0; c < 200 && !done; c++) { + for (j = 1; j <= aln->numgroups; j++) { done = FALSE; - for(i=0;inumelements;i++) - { - if(aln->element[i].groupid == j) - { - if(aln->element[i].groupf!=NULL || - aln->element[i].groupb!=NULL) + for (i = 0; i < aln->numelements; i++) { + if (aln->element[i].groupid == j) { + if (aln->element[i].groupf != NULL || + aln->element[i].groupb != NULL) done = TRUE; else aln->element[i].groupid = 0; } } - if(done == FALSE) - { - for(i=0;inumelements;i++) - if(aln->element[i].groupid == + if (done == FALSE) { + for (i = 0; i < aln->numelements; i++) + if (aln->element[i].groupid == aln->numgroups) aln->element[i].groupid = j; aln->numgroups--; } } - if(aln->numgroups == 0) - done = TRUE; + if (aln->numgroups == 0) done = TRUE; } return; #endif } -Ungroup(item,event) -Panel_item item; +Ungroup(item, event) Panel_item item; Event *event; { int j; - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; Display *dpy = (Display *)xv_get(EditNameCan, XV_DISPLAY); NA_Alignment *aln; - NA_Sequence *temp = NULL,*element; + NA_Sequence *temp = NULL, *element; - if(DataSet == NULL) - return(XV_OK); - aln = (NA_Alignment*)DataSet; - if(aln == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); + aln = (NA_Alignment *)DataSet; + if (aln == NULL) return (XV_OK); element = aln->element; - for(j=0;jnumelements;j++) - if(element[j].selected && element[j].groupid != 0) + for (j = 0; j < aln->numelements; j++) + if (element[j].selected && element[j].groupid != 0) RemoveFromGroup(&(element[j])); AdjustGroups(aln); - DrawNANames(dpy,xv_get(canvas_paint_window(EditNameCan),XV_XID)); - return(XV_OK); + DrawNANames(dpy, xv_get(canvas_paint_window(EditNameCan), XV_XID)); + return (XV_OK); } - -MergeGroups(el1,el2) -NA_Sequence *el1,*el2; +MergeGroups(el1, el2) NA_Sequence *el1, *el2; { - int i,j,newid; - NA_Sequence *last,*first,*temp; - newid = MAX(el1->groupid,el2->groupid); - if( el1->groupid == el2->groupid && el1->groupid != 0) return; + int i, j, newid; + NA_Sequence *last, *first, *temp; + newid = MAX(el1->groupid, el2->groupid); + if (el1->groupid == el2->groupid && el1->groupid != 0) return; last = el1; - for(;last->groupf != NULL;) last = last->groupf; + for (; last->groupf != NULL;) last = last->groupf; first = el1; - for(;first->groupb != NULL;) first = first->groupb; - for(;el2->groupf != NULL;) el2 = el2->groupf; + for (; first->groupb != NULL;) first = first->groupb; + for (; el2->groupf != NULL;) el2 = el2->groupf; el2->groupf = first; first->groupb = el2; el2->groupid = newid; - for(;last != NULL; last=last->groupb) last->groupid = newid; + for (; last != NULL; last = last->groupb) last->groupid = newid; return; } +New() { extern NA_Alignment *DataSet; } -New() -{ - extern NA_Alignment *DataSet; -} - - -ModAttr(mnu,mnuitm) -Menu mnu; +ModAttr(mnu, mnuitm) Menu mnu; Menu_item mnuitm; { extern NA_Alignment *DataSet; - extern Frame frame,pframe; + extern Frame frame, pframe; extern Panel popup; extern int BlockInput; /* extern Notify_value; rtm 18.III.98 */ - int cur_type = 0,direction = 0,j,sel_count; + int cur_type = 0, direction = 0, j, sel_count; extern Textsw comments_tsw; Textsw baggage_tsw; char temp[80]; - NA_Alignment *aln = (NA_Alignment*)DataSet; + NA_Alignment *aln = (NA_Alignment *)DataSet; - if(DataSet == NULL) - return(XV_OK); + if (DataSet == NULL) return (XV_OK); - if(aln->na_ddata == NULL) - return(XV_OK); + if (aln->na_ddata == NULL) return (XV_OK); - for(j=0,sel_count = 0;jnumelements;j++) - if(aln->element[j].selected) - { + for (j = 0, sel_count = 0; j < aln->numelements; j++) + if (aln->element[j].selected) { this_elem = &(aln->element[j]); sel_count++; } - if(sel_count == 0) - { + if (sel_count == 0) { Warning("Must select sequence(s) first"); - return(XV_OK); + return (XV_OK); } - if(this_elem->elementtype == RNA) cur_type = 0; - if(this_elem->elementtype == DNA) cur_type = 1; - if(this_elem->elementtype == TEXT) cur_type = 2; - if(this_elem->elementtype == MASK) cur_type = 3; - if(this_elem->elementtype == PROTEIN) cur_type = 4; + if (this_elem->elementtype == RNA) cur_type = 0; + if (this_elem->elementtype == DNA) cur_type = 1; + if (this_elem->elementtype == TEXT) cur_type = 2; + if (this_elem->elementtype == MASK) cur_type = 3; + if (this_elem->elementtype == PROTEIN) cur_type = 4; xv_destroy_safe(pframe); - pframe = xv_create(frame,FRAME_CMD, - FRAME_CMD_PUSHPIN_IN,TRUE, - FRAME_DONE_PROC,FrameDone, - FRAME_SHOW_RESIZE_CORNER,FALSE, - FRAME_LABEL,"Sequence Information", - WIN_DESIRED_HEIGHT,100, - WIN_DESIRED_WIDTH,300, - XV_X,300, - XV_Y,150, - WIN_SHOW,FALSE, - 0); + pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE, + FRAME_DONE_PROC, FrameDone, FRAME_SHOW_RESIZE_CORNER, + FALSE, FRAME_LABEL, "Sequence Information", + WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, 300, + XV_X, 300, XV_Y, 150, WIN_SHOW, FALSE, 0); -/* - popup = xv_find(pframe,PANEL, - PANEL_LAYOUT,PANEL_HORIZONTAL, - 0); -*/ - popup = xv_get(pframe,FRAME_CMD_PANEL); - - (void)xv_create (popup,PANEL_BUTTON, - PANEL_LABEL_STRING,"OK", - PANEL_NOTIFY_PROC,ModAttrDone, - 0); - - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, 0); - - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,20, - PANEL_LABEL_STRING,"Short name", - PANEL_VALUE,this_elem->short_name, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, + /* + popup = xv_find(pframe,PANEL, + PANEL_LAYOUT,PANEL_HORIZONTAL, 0); + */ + popup = xv_get(pframe, FRAME_CMD_PANEL); - (void)xv_create(popup,PANEL_CHOICE_STACK, - PANEL_NOTIFY_PROC,ChAttrType, - PANEL_LABEL_STRING,"Type:", - PANEL_CHOICE_STRINGS, - "RNA", - "DNA", - "TEXT", - "MASK", - "PROTEIN", - 0, - PANEL_VALUE,cur_type, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + (void)xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "OK", + PANEL_NOTIFY_PROC, ModAttrDone, 0); - if(sel_count == 1) - (void)xv_set(popup,PANEL_LAYOUT,PANEL_HORIZONTAL, 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 20, PANEL_LABEL_STRING, "Short name", + PANEL_VALUE, this_elem->short_name, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); + + (void)xv_create(popup, PANEL_CHOICE_STACK, PANEL_NOTIFY_PROC, + ChAttrType, PANEL_LABEL_STRING, + "Type:", PANEL_CHOICE_STRINGS, "RNA", "DNA", "TEXT", + "MASK", "PROTEIN", 0, PANEL_VALUE, cur_type, + PANEL_ITEM_X_GAP, 5, PANEL_ITEM_Y_GAP, 3, 0); + + if (sel_count == 1) + (void)xv_set(popup, PANEL_LAYOUT, PANEL_HORIZONTAL, 0); else - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + (void)xv_create(popup, PANEL_CHOICE_STACK, PANEL_NOTIFY_PROC, + ChAttrType, PANEL_LABEL_STRING, "Strand", + PANEL_CHOICE_STRINGS, "Primary", "Secondary", + "Undefined", 0, PANEL_VALUE, + (this_elem->attr & IS_SECONDARY) ? 1 + : (this_elem->attr & IS_PRIMARY) ? 0 + : 2, + PANEL_ITEM_X_GAP, 5, PANEL_ITEM_Y_GAP, 3, 0); - (void)xv_create(popup,PANEL_CHOICE_STACK, - PANEL_NOTIFY_PROC,ChAttrType, - PANEL_LABEL_STRING,"Strand", - PANEL_CHOICE_STRINGS, - "Primary", - "Secondary", - "Undefined", - 0, - PANEL_VALUE,(this_elem->attr & IS_SECONDARY)?1: - (this_elem->attr & IS_PRIMARY)?0:2, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); - - if(sel_count == 1) - (void)xv_set(popup,PANEL_LAYOUT,PANEL_HORIZONTAL, 0); + if (sel_count == 1) + (void)xv_set(popup, PANEL_LAYOUT, PANEL_HORIZONTAL, 0); else - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + (void)xv_create(popup, PANEL_CHOICE_STACK, PANEL_LAYOUT, + PANEL_HORIZONTAL, PANEL_NOTIFY_PROC, ChAttrType, + PANEL_LABEL_STRING, "Direction", PANEL_CHOICE_STRINGS, + "5' to 3'", "3' to 5'", "Undefined", 0, PANEL_VALUE, + (this_elem->attr & IS_3_TO_5) ? 1 + : (this_elem->attr & IS_5_TO_3) ? 0 + : 2, + PANEL_ITEM_X_GAP, 5, PANEL_ITEM_Y_GAP, 3, 0); - (void)xv_create(popup,PANEL_CHOICE_STACK, - PANEL_LAYOUT,PANEL_HORIZONTAL, - PANEL_NOTIFY_PROC,ChAttrType, - PANEL_LABEL_STRING,"Direction", - PANEL_CHOICE_STRINGS, - "5' to 3'", - "3' to 5'", - "Undefined", - 0, - PANEL_VALUE,(this_elem->attr & IS_3_TO_5)?1: - (this_elem->attr & IS_5_TO_3)?0:2, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "Full name ", + PANEL_VALUE, this_elem->seq_name, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "ID Number ", + PANEL_VALUE, this_elem->id, PANEL_NOTIFY_PROC, + ChAttr, PANEL_NOTIFY_LEVEL, PANEL_ALL, + PANEL_ITEM_X_GAP, 5, PANEL_ITEM_Y_GAP, 3, 0); - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"Full name ", - PANEL_VALUE,this_elem->seq_name, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); - - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"ID Number ", - PANEL_VALUE,this_elem->id, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); - - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"Description", - PANEL_VALUE,this_elem->description, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "Description", + PANEL_VALUE, this_elem->description, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); #ifdef HGL - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"Membrane ", - PANEL_VALUE,this_elem->membrane, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "Membrane ", + PANEL_VALUE, this_elem->membrane, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); #endif - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"Author ", - PANEL_VALUE,this_elem->authority, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "Author ", + PANEL_VALUE, this_elem->authority, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); #ifdef HGL - if(sel_count == 1) - (void)xv_create(popup,PANEL_TEXT, - PANEL_VALUE_DISPLAY_LENGTH,40, - PANEL_LABEL_STRING,"Barcode ", - PANEL_VALUE,this_elem->barcode, - PANEL_NOTIFY_PROC,ChAttr, - PANEL_NOTIFY_LEVEL,PANEL_ALL, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_TEXT, PANEL_VALUE_DISPLAY_LENGTH, + 40, PANEL_LABEL_STRING, "Barcode ", + PANEL_VALUE, this_elem->barcode, + PANEL_NOTIFY_PROC, ChAttr, PANEL_NOTIFY_LEVEL, + PANEL_ALL, PANEL_ITEM_X_GAP, 5, + PANEL_ITEM_Y_GAP, 3, 0); #endif direction = OrigDir(this_elem); - if(sel_count == 1) - { + if (sel_count == 1) { #ifdef HGL - sprintf(temp,"Created on %d/%d/%d %d:%d:%d (%s %s) %s", - this_elem->t_stamp.origin.mm, - this_elem->t_stamp.origin.dd, - this_elem->t_stamp.origin.yy, - this_elem->t_stamp.origin.hr, - this_elem->t_stamp.origin.mn, - this_elem->t_stamp.origin.sc, - (this_elem->attr & IS_ORIG_PRIMARY)?"Primary": - (this_elem->attr & IS_ORIG_SECONDARY)?"Secondary":"Strand ?", - (direction == 1)?"-->": - (direction == -1)?"<--":"<-?->", - this_elem->attr & IS_CIRCULAR? "Circular":""); + sprintf( + temp, "Created on %d/%d/%d %d:%d:%d (%s %s) %s", + this_elem->t_stamp.origin.mm, this_elem->t_stamp.origin.dd, + this_elem->t_stamp.origin.yy, this_elem->t_stamp.origin.hr, + this_elem->t_stamp.origin.mn, this_elem->t_stamp.origin.sc, + (this_elem->attr & IS_ORIG_PRIMARY) ? "Primary" + : (this_elem->attr & IS_ORIG_SECONDARY) ? "Secondary" + : "Strand ?", + (direction == 1) ? "-->" + : (direction == -1) ? "<--" + : "<-?->", + this_elem->attr & IS_CIRCULAR ? "Circular" : ""); #else - sprintf(temp,"Created on %d/%d/%d %d:%d:%d (%s) %s", - this_elem->t_stamp.origin.mm, - this_elem->t_stamp.origin.dd, - this_elem->t_stamp.origin.yy, - this_elem->t_stamp.origin.hr, - this_elem->t_stamp.origin.mn, - this_elem->t_stamp.origin.sc, - (direction == 1)?"-->": - (direction == -1)?"<--":"<-?->", - this_elem->attr & IS_CIRCULAR? "Circular":""); + sprintf( + temp, "Created on %d/%d/%d %d:%d:%d (%s) %s", + this_elem->t_stamp.origin.mm, this_elem->t_stamp.origin.dd, + this_elem->t_stamp.origin.yy, this_elem->t_stamp.origin.hr, + this_elem->t_stamp.origin.mn, this_elem->t_stamp.origin.sc, + (direction == 1) ? "-->" + : (direction == -1) ? "<--" + : "<-?->", + this_elem->attr & IS_CIRCULAR ? "Circular" : ""); #endif - xv_create(popup,PANEL_MESSAGE, - PANEL_LABEL_STRING,temp, - PANEL_ITEM_X_GAP,5, - PANEL_ITEM_Y_GAP,3, - 0); - + xv_create(popup, PANEL_MESSAGE, PANEL_LABEL_STRING, temp, + PANEL_ITEM_X_GAP, 5, PANEL_ITEM_Y_GAP, 3, 0); } - (void)xv_set(popup,PANEL_LAYOUT,PANEL_HORIZONTAL, 0); + (void)xv_set(popup, PANEL_LAYOUT, PANEL_HORIZONTAL, 0); - if(sel_count == 1) - (void)xv_create(popup,PANEL_MESSAGE, - PANEL_LABEL_STRING, - " Comments:", - 0); + if (sel_count == 1) + (void)xv_create(popup, PANEL_MESSAGE, PANEL_LABEL_STRING, + " Comments:", 0); - (void)xv_set(popup,PANEL_LAYOUT,PANEL_VERTICAL, 0); - if(sel_count == 1) + (void)xv_set(popup, PANEL_LAYOUT, PANEL_VERTICAL, 0); + if (sel_count == 1) window_fit_height(popup); else window_fit(popup); - if(sel_count == 1) - { - comments_tsw = xv_create(pframe,TEXTSW, - WIN_INHERIT_COLORS,TRUE, - WIN_BELOW,popup, - XV_X,0, - XV_HEIGHT,(this_elem->baggage)?90:180, - TEXTSW_CONTENTS,this_elem->comments? - this_elem->comments:"", - TEXTSW_READ_ONLY,FALSE, - 0); + if (sel_count == 1) { + comments_tsw = + xv_create(pframe, TEXTSW, WIN_INHERIT_COLORS, TRUE, + WIN_BELOW, popup, XV_X, 0, XV_HEIGHT, + (this_elem->baggage) ? 90 : 180, TEXTSW_CONTENTS, + this_elem->comments ? this_elem->comments : "", + TEXTSW_READ_ONLY, FALSE, 0); window_fit(comments_tsw); - if(this_elem->baggage) - { - baggage_tsw = xv_create(pframe,TEXTSW, - WIN_INHERIT_COLORS,TRUE, - WIN_BELOW,comments_tsw, - XV_X,0, XV_HEIGHT,90, - TEXTSW_CONTENTS,this_elem->baggage? - this_elem->baggage:"", - TEXTSW_READ_ONLY,TRUE, - 0); + if (this_elem->baggage) { + baggage_tsw = xv_create( + pframe, TEXTSW, WIN_INHERIT_COLORS, TRUE, WIN_BELOW, + comments_tsw, XV_X, 0, XV_HEIGHT, 90, + TEXTSW_CONTENTS, + this_elem->baggage ? this_elem->baggage : "", + TEXTSW_READ_ONLY, TRUE, 0); window_fit(baggage_tsw); } window_fit(pframe); - notify_interpose_destroy_func(comments_tsw,SaveComments); + notify_interpose_destroy_func(comments_tsw, SaveComments); } window_fit(pframe); - (void)xv_set(pframe,XV_SHOW,TRUE,0); + (void)xv_set(pframe, XV_SHOW, TRUE, 0); BlockInput = TRUE; - return(XV_OK); + return (XV_OK); } - -Notify_value SaveComments(client,status) +Notify_value SaveComments(client, status) Notify_client client; Destroy_status status; { - int j,numselected = 0,lastselected = 0; + int j, numselected = 0, lastselected = 0; extern NA_Alignment *DataSet; - for(j=0;jnumelements;j++) - if(DataSet->element[j].selected) - { - numselected ++; + for (j = 0; j < DataSet->numelements; j++) + if (DataSet->element[j].selected) { + numselected++; lastselected = j; } - if(numselected == 1) - { + if (numselected == 1) { Cfree(DataSet->element[lastselected].comments); - DataSet->element[lastselected].comments = - Calloc(xv_get(client,TEXTSW_LENGTH)+1,sizeof(char)); + DataSet->element[lastselected].comments = + Calloc(xv_get(client, TEXTSW_LENGTH) + 1, sizeof(char)); DataSet->element[lastselected].comments_len = strlen(DataSet->element[lastselected].comments); - DataSet->element[lastselected].comments_maxlen = - xv_get(client,TEXTSW_LENGTH); + DataSet->element[lastselected].comments_maxlen = + xv_get(client, TEXTSW_LENGTH); - (void)xv_get(client,TEXTSW_CONTENTS,0, - DataSet->element[lastselected].comments, - xv_get(client,TEXTSW_LENGTH)); - - DataSet->element[lastselected].comments[ - xv_get(client,TEXTSW_LENGTH)] = '\0'; + (void)xv_get(client, TEXTSW_CONTENTS, 0, + DataSet->element[lastselected].comments, + xv_get(client, TEXTSW_LENGTH)); + DataSet->element[lastselected] + .comments[xv_get(client, TEXTSW_LENGTH)] = '\0'; } - return(notify_next_destroy_func(client,status)); + return (notify_next_destroy_func(client, status)); } - - -ChAttr(item,event) -Panel_item item; +ChAttr(item, event) Panel_item item; Event *event; { int j; @@ -1429,100 +1179,93 @@ Event *event; NA_Alignment *aln; Panel_setting ps; - if(DataSet == NULL) - return; + if (DataSet == NULL) return; - aln = (NA_Alignment*)DataSet; + aln = (NA_Alignment *)DataSet; - for(j=0;jnumelements;j++) - if(aln->element[j].selected) - this_element = &(aln->element[j]); + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].selected) this_element = &(aln->element[j]); - ps = panel_text_notify(item,event); + ps = panel_text_notify(item, event); - if(Find(xv_get(item,PANEL_LABEL_STRING),"Short name")) - { - strncpy(this_element->short_name,(char *) xv_get(item,PANEL_VALUE),31); - for(j=0;jshort_name);j++) - if(this_element->short_name[j] == ' ') + if (Find(xv_get(item, PANEL_LABEL_STRING), "Short name")) { + strncpy(this_element->short_name, + (char *)xv_get(item, PANEL_VALUE), 31); + for (j = 0; j < strlen(this_element->short_name); j++) + if (this_element->short_name[j] == ' ') this_element->short_name[j] = '_'; } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Full name ")) - { - strncpy(this_element->seq_name,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Full name ")) { + strncpy(this_element->seq_name, + (char *)xv_get(item, PANEL_VALUE), 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Description")) - { - strncpy(this_element->description,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Description")) { + strncpy(this_element->description, + (char *)xv_get(item, PANEL_VALUE), 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Author ")) - { - strncpy(this_element->authority,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Author ")) { + strncpy(this_element->authority, + (char *)xv_get(item, PANEL_VALUE), 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"ID Number ")) - { - strncpy(this_element->id,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "ID Number ")) { + strncpy(this_element->id, (char *)xv_get(item, PANEL_VALUE), + 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Membrane ")) - { - strncpy(this_element->membrane,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Membrane ")) { + strncpy(this_element->membrane, + (char *)xv_get(item, PANEL_VALUE), 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Contig ")) - { - strncpy(this_element->contig,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Contig ")) { + strncpy(this_element->contig, (char *)xv_get(item, PANEL_VALUE), + 79); } - else if(Find(xv_get(item,PANEL_LABEL_STRING),"Barcode ")) - { - strncpy(this_element->barcode,(char *) xv_get(item,PANEL_VALUE),79); + else if (Find(xv_get(item, PANEL_LABEL_STRING), "Barcode ")) { + strncpy(this_element->barcode, + (char *)xv_get(item, PANEL_VALUE), 79); } - - return(ps); + return (ps); } ModAttrDone() { FILE *file; extern Textsw comments_tsw; - int j,maxlen = 20,numselected = 0; - char c,*tempstring; + int j, maxlen = 20, numselected = 0; + char c, *tempstring; extern NA_Alignment *DataSet; - for(j=0;jnumelements;j++) - if(DataSet->element[j].selected) - { + for (j = 0; j < DataSet->numelements; j++) + if (DataSet->element[j].selected) { this_elem = &(DataSet->element[j]); numselected++; } - if(numselected == 1) - { - if(this_elem->comments) - maxlen = strlen(this_elem->comments)+10; + if (numselected == 1) { + if (this_elem->comments) + maxlen = strlen(this_elem->comments) + 10; - tempstring =(char*)Calloc(maxlen,sizeof(char)); - textsw_store_file(comments_tsw,"/tmp/gde_tmp",300,100); + tempstring = (char *)Calloc(maxlen, sizeof(char)); + textsw_store_file(comments_tsw, "/tmp/gde_tmp", 300, 100); - file = fopen("/tmp/gde_tmp","r"); - if(file == NULL) - { + file = fopen("/tmp/gde_tmp", "r"); + if (file == NULL) { Warning("Comments could not be saved"); return XV_OK; } - for(j=0;(c=getc(file))!=EOF;j++) - { - if(j==maxlen-1) - { - maxlen *=2; - tempstring =(char *)Realloc(tempstring,maxlen); + for (j = 0; (c = getc(file)) != EOF; j++) { + if (j == maxlen - 1) { + maxlen *= 2; + tempstring = + (char *)Realloc(tempstring, maxlen); } tempstring[j] = c; } @@ -1532,410 +1275,419 @@ ModAttrDone() unlink("/tmp/gde_tmp"); - if(this_elem->comments) - Cfree(this_elem->comments); + if (this_elem->comments) Cfree(this_elem->comments); this_elem->comments = tempstring; this_elem->comments_len = j; StripSpecial(this_elem->comments); - } DONT(); RepaintAll(TRUE); } - -ChEditMode(item,event) -Panel_item item; +ChEditMode(item, event) Panel_item item; Event *event; { extern EditMode; - EditMode = xv_get(item,PANEL_VALUE); + EditMode = xv_get(item, PANEL_VALUE); - return(XV_OK); + return (XV_OK); } - -ChEditDir(item,event) -Panel_item item; +ChEditDir(item, event) Panel_item item; Event *event; { extern EditDir; - EditDir = xv_get(item,PANEL_VALUE); + EditDir = xv_get(item, PANEL_VALUE); - return(XV_OK); + return (XV_OK); } -ChDisAttr(item,event) -Panel_item item; +ChDisAttr(item, event) Panel_item item; Event *event; { extern DisplayAttr; extern Frame infoframe; extern NA_Alignment *DataSet; - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; - DisplayAttr = xv_get(item,PANEL_VALUE); - (void)SetNADData(DataSet,EditCan,EditNameCan); - if(DisplayAttr & GDE_MESSAGE_PANEL) - (void)xv_set(infoframe,XV_SHOW,TRUE,0); + DisplayAttr = xv_get(item, PANEL_VALUE); + (void)SetNADData(DataSet, EditCan, EditNameCan); + if (DisplayAttr & GDE_MESSAGE_PANEL) + (void)xv_set(infoframe, XV_SHOW, TRUE, 0); else - (void)xv_set(infoframe,XV_SHOW,FALSE,0); - return(XV_OK); + (void)xv_set(infoframe, XV_SHOW, FALSE, 0); + return (XV_OK); } - -ChAttrType(item,event) -Panel_item item; +ChAttrType(item, event) Panel_item item; Event *event; { - int j,current_insert = 0,new_type,type; - extern Canvas EditCan,EditNameCan; + int j, current_insert = 0, new_type, type; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; - extern int Default_DNA_Trans[],Default_NA_RTrans[],Default_RNA_Trans[]; - extern int Default_NA_RTrans[],Default_PROColor_LKUP[],Default_NAColor_LKUP[]; + extern int Default_DNA_Trans[], Default_NA_RTrans[], + Default_RNA_Trans[]; + extern int Default_NA_RTrans[], Default_PROColor_LKUP[], + Default_NAColor_LKUP[]; NA_Alignment *aln; - NA_Sequence *temp = NULL,*element; + NA_Sequence *temp = NULL, *element; - if(DataSet == NULL) - return; - aln = (NA_Alignment*)DataSet; - if(aln == NULL) - return; + if (DataSet == NULL) return; + aln = (NA_Alignment *)DataSet; + if (aln == NULL) return; element = aln->element; + if (strcmp((char *)xv_get(item, PANEL_LABEL_STRING), "Type:") == 0) { + new_type = xv_get(item, PANEL_VALUE); + type = (new_type == 0) ? RNA + : (new_type == 1) ? DNA + : (new_type == 2) ? TEXT + : (new_type == 3) ? MASK + : PROTEIN; - if(strcmp((char *) xv_get(item,PANEL_LABEL_STRING),"Type:") == 0) - { - new_type = xv_get(item,PANEL_VALUE); - type = (new_type == 0)?RNA: - (new_type == 1)?DNA: - (new_type == 2)?TEXT: - (new_type == 3)?MASK: - PROTEIN; - - - for(j=0;jnumelements;j++) - if(element[j].selected) - { - if((element[j].protect & PROT_TRANSLATION) == 0) - { + for (j = 0; j < aln->numelements; j++) + if (element[j].selected) { + if ((element[j].protect & PROT_TRANSLATION) == + 0) { Warning("Protect violation"); - (void)xv_set(item,PANEL_VALUE,element[j].elementtype - ,0); - return(XV_ERROR); + (void)xv_set(item, PANEL_VALUE, + element[j].elementtype, 0); + return (XV_ERROR); } - if(element[j].elementtype == DNA || + if (element[j].elementtype == DNA || element[j].elementtype == RNA) - switch(new_type) - { - case 1: - element[j].tmatrix =Default_DNA_Trans; - element[j].elementtype = type; - element[j].col_lut=Default_NAColor_LKUP; - break; - case 0: - element[j].tmatrix =Default_RNA_Trans; - element[j].elementtype = type; - element[j].col_lut=Default_NAColor_LKUP; - break; - case 4: - case 2: - case 3: - default: - /* - (void)xv_set(item,PANEL_VALUE,old_type,0); -*/ - break; + switch (new_type) { + case 1: + element[j].tmatrix = + Default_DNA_Trans; + element[j].elementtype = + type; + element[j].col_lut = + Default_NAColor_LKUP; + break; + case 0: + element[j].tmatrix = + Default_RNA_Trans; + element[j].elementtype = + type; + element[j].col_lut = + Default_NAColor_LKUP; + break; + case 4: + case 2: + case 3: + default: + /* + (void)xv_set(item,PANEL_VALUE,old_type,0); + */ + break; } else if (element[j].elementtype == PROTEIN) - switch(new_type) - { - case 0: - case 1: - (void)xv_set(item,PANEL_VALUE, - element[j].elementtype ,0); - break; - case 4: - (void)xv_set(item,PANEL_VALUE, - element[j].elementtype ,0); - break; - case 2: - case 3: - element[j].elementtype = type; - element[j].col_lut=Default_PROColor_LKUP; - default: - break; + switch (new_type) { + case 0: + case 1: + (void)xv_set( + item, PANEL_VALUE, + element[j] + .elementtype, + 0); + break; + case 4: + (void)xv_set( + item, PANEL_VALUE, + element[j] + .elementtype, + 0); + break; + case 2: + case 3: + element[j].elementtype = + type; + element[j].col_lut = + Default_PROColor_LKUP; + default: + break; } else if (element[j].elementtype == TEXT) - switch(new_type) - { - case 0: - case 1: - (void)xv_set(item,PANEL_VALUE, - element[j].elementtype ,0); - break; - case 4: - element[j].elementtype=type; - element[j].col_lut=Default_PROColor_LKUP; - break; - case 3: - case 2: - element[j].elementtype=type; - element[j].col_lut=NULL; - break; - default: - break; + switch (new_type) { + case 0: + case 1: + (void)xv_set( + item, PANEL_VALUE, + element[j] + .elementtype, + 0); + break; + case 4: + element[j].elementtype = + type; + element[j].col_lut = + Default_PROColor_LKUP; + break; + case 3: + case 2: + element[j].elementtype = + type; + element[j].col_lut = + NULL; + break; + default: + break; } else if (element[j].elementtype == MASK) - switch(new_type) - { - case 0: - case 1: - (void)xv_set(item,PANEL_VALUE, - element[j].elementtype ,0); - break; - case 4: - element[j].elementtype=type; - element[j].col_lut=Default_PROColor_LKUP; - break; - case 3: - case 2: - element[j].elementtype = type; - element[j].col_lut = NULL; - break; - default: - break; + switch (new_type) { + case 0: + case 1: + (void)xv_set( + item, PANEL_VALUE, + element[j] + .elementtype, + 0); + break; + case 4: + element[j].elementtype = + type; + element[j].col_lut = + Default_PROColor_LKUP; + break; + case 3: + case 2: + element[j].elementtype = + type; + element[j].col_lut = + NULL; + break; + default: + break; } - } } - else if(strcmp((char *) xv_get(item,PANEL_LABEL_STRING),"Direction") == 0) - { - for(j=0;jnumelements;j++) - if(element[j].selected) - switch(xv_get(item,PANEL_VALUE)) - { - case 0: - element[j].attr |= IS_5_TO_3; - element[j].attr &= (0xffff - IS_3_TO_5); - break; - case 1: - element[j].attr |= IS_3_TO_5; - element[j].attr &= (0xffff-IS_5_TO_3); - break; - default: - element[j].attr &= (0xffff-IS_5_TO_3); - element[j].attr &= (0xffff-IS_3_TO_5); - break; + else if (strcmp((char *)xv_get(item, PANEL_LABEL_STRING), + "Direction") == 0) { + for (j = 0; j < aln->numelements; j++) + if (element[j].selected) + switch (xv_get(item, PANEL_VALUE)) { + case 0: + element[j].attr |= IS_5_TO_3; + element[j].attr &= + (0xffff - IS_3_TO_5); + break; + case 1: + element[j].attr |= IS_3_TO_5; + element[j].attr &= + (0xffff - IS_5_TO_3); + break; + default: + element[j].attr &= + (0xffff - IS_5_TO_3); + element[j].attr &= + (0xffff - IS_3_TO_5); + break; } } - else if(strcmp((char *) xv_get(item,PANEL_LABEL_STRING),"Strand") == 0) - { - for(j=0;jnumelements;j++) - if(element[j].selected) - switch(xv_get(item,PANEL_VALUE)) - { - case 0: - element[j].attr |= IS_PRIMARY; - element[j].attr &= (0xffff - IS_SECONDARY); - break; - case 1: - element[j].attr |= IS_SECONDARY; - element[j].attr &= (0xffff - IS_PRIMARY); - break; - default: - element[j].attr &= (0xffff - IS_PRIMARY); - element[j].attr &= (0xffff - IS_SECONDARY); - break; + else if (strcmp((char *)xv_get(item, PANEL_LABEL_STRING), "Strand") == + 0) { + for (j = 0; j < aln->numelements; j++) + if (element[j].selected) + switch (xv_get(item, PANEL_VALUE)) { + case 0: + element[j].attr |= IS_PRIMARY; + element[j].attr &= + (0xffff - IS_SECONDARY); + break; + case 1: + element[j].attr |= IS_SECONDARY; + element[j].attr &= + (0xffff - IS_PRIMARY); + break; + default: + element[j].attr &= + (0xffff - IS_PRIMARY); + element[j].attr &= + (0xffff - IS_SECONDARY); + break; } } - return(XV_OK); + return (XV_OK); } - -SwapElement(aln,e1,e2) -NA_Alignment *aln; -int e1,e2; +SwapElement(aln, e1, e2) NA_Alignment *aln; +int e1, e2; { /* -* Warning, The following code may not be compatable with other -* C compilers. The elements may need to be explicitly copied. -*/ + * Warning, The following code may not be compatable with other + * C compilers. The elements may need to be explicitly copied. + */ NA_Sequence temp; register i; - for(i=0;inumelements;i++) - { - if(aln->element[i].groupf == &(aln->element[e1])) + for (i = 0; i < aln->numelements; i++) { + if (aln->element[i].groupf == &(aln->element[e1])) aln->element[i].groupf = &(aln->element[e2]); - else if(aln->element[i].groupf == &(aln->element[e2])) + else if (aln->element[i].groupf == &(aln->element[e2])) aln->element[i].groupf = &(aln->element[e1]); - if(aln->element[i].groupb == &(aln->element[e1])) + if (aln->element[i].groupb == &(aln->element[e1])) aln->element[i].groupb = &(aln->element[e2]); - else if(aln->element[i].groupb == &(aln->element[e2])) + else if (aln->element[i].groupb == &(aln->element[e2])) aln->element[i].groupb = &(aln->element[e1]); } - temp = aln->element[e1]; aln->element[e1] = aln->element[e2]; aln->element[e2] = temp; return; } -CompressAlign(item,event) -Panel_item item; +CompressAlign(item, event) Panel_item item; Event *event; { - int j,k,offset,pos = 0; + int j, k, offset, pos = 0; int max_wid = -999999; int min_wid = 999999; int min_offset = 99999999; int any_selected = FALSE; int compress_all; - extern Canvas EditCan,EditNameCan; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; extern Frame frame; NA_Base *rev_seq; - char *temp,*mask,*temp_c; + char *temp, *mask, *temp_c; Display *dpy; NA_Sequence *element; - if(DataSet == NULL) - return; + if (DataSet == NULL) return; element = DataSet->element; - switch(notice_prompt(frame,NULL, - NOTICE_MESSAGE_STRINGS,"Removing extra gaps, Do you want to:",NULL, - NOTICE_BUTTON,"Preserve alignment",1, - NOTICE_BUTTON,"Remove all dashes",2, - NOTICE_BUTTON,"Cancel",3,0)) - { - case 1: - compress_all=FALSE; - break; - case 2: - compress_all=TRUE; - break; - case 3: - default: - return(XV_OK); + switch (notice_prompt(frame, NULL, NOTICE_MESSAGE_STRINGS, + "Removing extra gaps, Do you want to:", NULL, + NOTICE_BUTTON, "Preserve alignment", 1, + NOTICE_BUTTON, "Remove all dashes", 2, + NOTICE_BUTTON, "Cancel", 3, 0)) { + case 1: + compress_all = FALSE; + break; + case 2: + compress_all = TRUE; + break; + case 3: + default: + return (XV_OK); } any_selected = FALSE; - for(j=0;jnumelements;j++) - if(element[j].selected) - { - max_wid = MAX(max_wid,element[j].offset + element[j].seqlen); - min_wid = MIN(min_wid,element[j].offset); + for (j = 0; j < DataSet->numelements; j++) + if (element[j].selected) { + max_wid = + MAX(max_wid, element[j].offset + element[j].seqlen); + min_wid = MIN(min_wid, element[j].offset); any_selected = TRUE; } - if(any_selected == FALSE) - return(XV_OK); + if (any_selected == FALSE) return (XV_OK); - mask = Calloc(max_wid - min_wid,sizeof(char)); - temp = Calloc(max_wid - min_wid,sizeof(char)); - temp_c = Calloc(max_wid - min_wid,sizeof(int)); + mask = Calloc(max_wid - min_wid, sizeof(char)); + temp = Calloc(max_wid - min_wid, sizeof(char)); + temp_c = Calloc(max_wid - min_wid, sizeof(int)); - for(j=min_wid;jnumelements;k++) - if(element[k].selected) - { - if(j>=element[k].offset && j< element[k].offset + - element[k].seqlen) - { - switch (element[k].elementtype) - { - case DNA: - case RNA: - if((getelem(&(element[k]),j) & 15) != 0) - mask[j-min_wid] = '1'; - break; - case PROTEIN: - if(getelem(&(element[k]),j) != '-') - mask[j-min_wid] = '1'; - break; - default: - break; + for (j = min_wid; j < max_wid; j++) { + mask[j - min_wid] = '0'; + for (k = 0; k < DataSet->numelements; k++) + if (element[k].selected) { + if (j >= element[k].offset && + j < element[k].offset + element[k].seqlen) { + switch (element[k].elementtype) { + case DNA: + case RNA: + if ((getelem( + &(element[k]), + j) & + 15) != 0) + mask[j - + min_wid] = + '1'; + break; + case PROTEIN: + if (getelem( + &(element[k]), + j) != '-') + mask[j - + min_wid] = + '1'; + break; + default: + break; } } } } - for(j=0;jnumelements;j++) - if(element[j].selected) - if(element[j].protect & PROT_WHITE_SPACE == 0) - { + for (j = 0; j < DataSet->numelements; j++) + if (element[j].selected) + if (element[j].protect & PROT_WHITE_SPACE == 0) { Warning("Some sequences are protected"); - return(XV_OK); + return (XV_OK); } - if(compress_all) - { - for(j=0;jnumelements;j++) - if(element[j].selected) - { + if (compress_all) { + for (j = 0; j < DataSet->numelements; j++) + if (element[j].selected) { this_elem = &(element[j]); offset = this_elem->offset; pos = 0; - for(k=0; kseqlen;k++) - { - if(this_elem->tmatrix && (this_elem-> - sequence[k]& 15)!='\0') - temp[pos++] = this_elem->sequence[k]; + for (k = 0; k < this_elem->seqlen; k++) { + if (this_elem->tmatrix && + (this_elem->sequence[k] & 15) != + '\0') + temp[pos++] = + this_elem->sequence[k]; - else if((this_elem->tmatrix == NULL) && - (this_elem->sequence[k] != '-')) - temp[pos++] = this_elem->sequence[k]; + else if ((this_elem->tmatrix == NULL) && + (this_elem->sequence[k] != + '-')) + temp[pos++] = + this_elem->sequence[k]; } this_elem->seqlen = pos; - for(k=0;ksequence[k] = temp[k]; } - min_offset = MIN(min_offset,offset); + min_offset = MIN(min_offset, offset); } } - else - { + else { /* -* Use the mask to remove all positions where the mask is set to '0' -*/ - for(j=0;jnumelements;j++) - if(element[j].selected) - { + * Use the mask to remove all positions where the mask is + *set to '0' + */ + for (j = 0; j < DataSet->numelements; j++) + if (element[j].selected) { this_elem = &(element[j]); offset = this_elem->offset; pos = 0; - for(k=offset; kseqlen;k++) - { - if(mask[k-min_wid] == '1') - { - temp[(pos++)] = this_elem->sequence[k-offset]; + for (k = offset; k < offset + this_elem->seqlen; + k++) { + if (mask[k - min_wid] == '1') { + temp[(pos++)] = + this_elem + ->sequence[k - offset]; } } this_elem->seqlen = pos; - for(k=0;ksequence[k] = temp[k]; } - min_offset = MIN(min_offset,offset); + min_offset = MIN(min_offset, offset); } } - for(j=0;jnumelements;j++) - { - if(element[j].selected) - { - if(compress_all) - element[j].offset = -(DataSet->rel_offset); + for (j = 0; j < DataSet->numelements; j++) { + if (element[j].selected) { + if (compress_all) + element[j].offset = -(DataSet->rel_offset); else element[j].offset -= min_offset; } @@ -1944,97 +1696,87 @@ Event *event; DataSet->maxlen = 0; - for(j=0;jnumelements;j++) - DataSet->maxlen = MAX(DataSet->maxlen,element[j].seqlen+ - element[j].offset); + for (j = 0; j < DataSet->numelements; j++) + DataSet->maxlen = + MAX(DataSet->maxlen, element[j].seqlen + element[j].offset); Cfree(mask); Cfree(temp); Cfree(temp_c); RepaintAll(FALSE); - return(XV_OK); + return (XV_OK); } - -RevSeqs(item,event) -Panel_item item; +RevSeqs(item, event) Panel_item item; Event *event; { - int j,i,slen,current_insert = 0,offset,*rev_mask; - int min_range = 9999999,max_range = -9999999; - extern Canvas EditCan,EditNameCan; + int j, i, slen, current_insert = 0, offset, *rev_mask; + int min_range = 9999999, max_range = -9999999; + extern Canvas EditCan, EditNameCan; extern NA_Alignment *DataSet; NA_Base *rev_seq; Display *dpy; NA_Alignment *aln; NA_Sequence *element; - if(DataSet == NULL) - return; - aln = (NA_Alignment*)DataSet; + if (DataSet == NULL) return; + aln = (NA_Alignment *)DataSet; - if(aln == NULL) - return; + if (aln == NULL) return; element = aln->element; - - for(j=0;jnumelements;j++) - if(element[j].selected) - { - if(element[j].offsetnumelements; j++) + if (element[j].selected) { + if (element[j].offset < min_range) min_range = element[j].offset; - if(element[j].offset+element[j].seqlen>max_range) - max_range = element[j].offset+element[j].seqlen; + if (element[j].offset + element[j].seqlen > max_range) + max_range = + element[j].offset + element[j].seqlen; } - for(j=0;jnumelements;j++) - if(element[j].selected && (element[j].protect & - PROT_TRANSLATION)) - { + for (j = 0; j < aln->numelements; j++) + if (element[j].selected && + (element[j].protect & PROT_TRANSLATION)) { slen = element[j].seqlen; offset = element[j].offset; - rev_seq =(NA_Base*)Calloc(element[j].seqmaxlen, - sizeof(NA_Base)); - for(i=0;ielement; - for(j=0;jnumelements;j++) - if(element[j].selected && (element[j].protect & - PROT_TRANSLATION)) - { + for (j = 0; j < aln->numelements; j++) + if (element[j].selected && + (element[j].protect & PROT_TRANSLATION)) { char c; - switch(element[j].elementtype) - { - case DNA: - case RNA: - slen = element[j].seqlen; - offset = element[j].offset; - for(i=0;i>k)& - (unsigned char)1; + switch (element[j].elementtype) { + case DNA: + case RNA: + slen = element[j].seqlen; + offset = element[j].offset; + for (i = 0; i < slen; i++) { + /* + * Diddle the four lsb's + */ + temp = '\0'; + temp2 = (unsigned char)getelem( + &(element[j]), i + offset); + for (k = 0; k < 4; k++) { + temp <<= 1; + temp |= + ((unsigned char)(temp2) >> + k) & + (unsigned char)1; + } + putelem( + &(element[j]), i + offset, + (NA_Base)temp | + ((unsigned char)240 & + temp2)); } - putelem(&(element[j]),i+offset,(NA_Base)temp| - ((unsigned char)240 & temp2)); - } - break; - case MASK: - slen = element[j].seqlen; - offset = element[j].offset; - for(i=0;ielement; - ddata = (NA_DisplayData*)(aln->na_ddata); + ddata = (NA_DisplayData *)(aln->na_ddata); tmat = element[ddata->cursor_y].tmatrix; rmat = element[ddata->cursor_y].rmatrix; - - for(j=0;jnumelements;j++) - if(aln->element[j].subselected && DataSet->selection_mask != NULL) - { + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].subselected && + DataSet->selection_mask != NULL) { subselected = TRUE; j = aln->numelements; } - if(subselected) - { - for(j=0;jnumelements;j++) - if(aln->element[j].subselected) - for(i=0;ielement[j].seqlen;i++) - if(aln->selection_mask[i+aln->element[j].offset - - aln->rel_offset] == '1') - { - pos = i+aln->element[j].offset; - base = (char)getelem(&(element[j]), pos); - switch(element[j].elementtype) - { - case DNA: - case RNA: - base = tmat[base]; - base = (base & 32)? (base & 223): - (base | 32); - base = rmat[base]; - putelem(&(element[j]), pos, base); - break; - case TEXT: - case PROTEIN: - base = (base & 32)? (base & 223): (base | 32); - putelem(&(element[j]), pos,base); - break; - case MASK: - default: - base = (base == '0')? - '1':(base == '1')? '0':base; - putelem(&(element[j]), pos,base); - break; + if (subselected) { + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].subselected) + for (i = 0; i < aln->element[j].seqlen; i++) + if (aln->selection_mask + [i + aln->element[j].offset - + aln->rel_offset] == '1') { + pos = + i + aln->element[j].offset; + base = (char)getelem( + &(element[j]), pos); + switch ( + element[j].elementtype) { + case DNA: + case RNA: + base = + tmat[base]; + base = + (base & 32) + ? (base & + 223) + : (base | + 32); + base = + rmat[base]; + putelem( + &(element + [j]), + pos, base); + break; + case TEXT: + case PROTEIN: + base = + (base & 32) + ? (base & + 223) + : (base | + 32); + putelem( + &(element + [j]), + pos, base); + break; + case MASK: + default: + base = + (base == + '0') + ? '1' + : (base == + '1') + ? '0' + : base; + putelem( + &(element + [j]), + pos, base); + break; } - } /* -* Repaint the screen, names not needed -*/ + * Repaint the screen, names not needed + */ RepaintAll(FALSE); } - else - { - base = (char)getelem(&(element[ddata->cursor_y]),ddata->cursor_x); - switch(element[ddata->cursor_y].elementtype) - { - case DNA: - case RNA: - base = tmat[base]; - base = (base & 32)? (base & 223): (base | 32); - base = rmat[base]; - putelem(&(element[ddata->cursor_y]),ddata->cursor_x, - base); - break; - case TEXT: - case PROTEIN: - base = (base & 32)? (base & 223): (base | 32); - putelem(&(element[ddata->cursor_y]), - ddata->cursor_x,base); - break; - case MASK: - default: - base = (base == '0')? '1':(base == '1')? '0':base; - putelem(&(element[ddata->cursor_y]), - ddata->cursor_x,base); - break; + else { + base = + (char)getelem(&(element[ddata->cursor_y]), ddata->cursor_x); + switch (element[ddata->cursor_y].elementtype) { + case DNA: + case RNA: + base = tmat[base]; + base = (base & 32) ? (base & 223) : (base | 32); + base = rmat[base]; + putelem(&(element[ddata->cursor_y]), + ddata->cursor_x, base); + break; + case TEXT: + case PROTEIN: + base = (base & 32) ? (base & 223) : (base | 32); + putelem(&(element[ddata->cursor_y]), + ddata->cursor_x, base); + break; + case MASK: + default: + base = (base == '0') ? '1' + : (base == '1') ? '0' + : base; + putelem(&(element[ddata->cursor_y]), + ddata->cursor_x, base); + break; } } return XV_OK; } -OrigDir(seq) -NA_Sequence *seq; +OrigDir(seq) NA_Sequence *seq; { int test; test = seq->attr; #ifdef HGL - if(test & IS_ORIG_PRIMARY) - if(test & IS_ORIG_5_TO_3) - return(1); - else if(test & IS_ORIG_3_TO_5) - return(-1); + if (test & IS_ORIG_PRIMARY) + if (test & IS_ORIG_5_TO_3) + return (1); + else if (test & IS_ORIG_3_TO_5) + return (-1); - if(test & IS_ORIG_SECONDARY) - if(test & IS_ORIG_5_TO_3) - return(-1); - else if(test & IS_ORIG_3_TO_5) - return(1); + if (test & IS_ORIG_SECONDARY) + if (test & IS_ORIG_5_TO_3) + return (-1); + else if (test & IS_ORIG_3_TO_5) + return (1); #else - if(test & IS_PRIMARY) - return(1); - else if(test & IS_SECONDARY) - return(-1); + if (test & IS_PRIMARY) + return (1); + else if (test & IS_SECONDARY) + return (-1); #endif - - return(0); + return (0); } diff --git a/CORE/Genbank.c b/CORE/Genbank.c index 46cd785..2a921b0 100755 --- a/CORE/Genbank.c +++ b/CORE/Genbank.c @@ -1,10 +1,12 @@ -#include -#include #include -#include +#include +#include +#include #include -#include "menudefs.h" +#include + #include "defines.h" +#include "menudefs.h" /* Copyright (c) 1989-1990, University of Illinois board of trustees. All @@ -19,223 +21,220 @@ Copyright (c) 1993, Steven Smith, all rights reserved. */ -ReadGen(filename,dataset,type) -char *filename; +ReadGen(filename, dataset, type) char *filename; NA_Alignment *dataset; int type; { - register int done = FALSE,len = 0, j=0; - int count,IS_REALLY_AA = FALSE; - char Inline[GBUFSIZ],c; - char *buffer,*gencomments = NULL,fields[8][GBUFSIZ]; - int buflen = 0,genclen = 0,curelem = 0,n = 0,flag = 0; + register int done = FALSE, len = 0, j = 0; + int count, IS_REALLY_AA = FALSE; + char Inline[GBUFSIZ], c; + char *buffer, *gencomments = NULL, fields[8][GBUFSIZ]; + int buflen = 0, genclen = 0, curelem = 0, n = 0, flag = 0; int start_col = -1; NA_Sequence *this_elem; FILE *file; extern int Default_DNA_Trans[], Default_RNA_Trans[]; extern int Default_NA_RTrans[]; - extern int Default_PROColor_LKUP[],Default_NAColor_LKUP[]; + extern int Default_PROColor_LKUP[], Default_NAColor_LKUP[]; - ErrorOut("No such file",file = fopen(filename,"r")); + ErrorOut("No such file", file = fopen(filename, "r")); - for(;fgets(Inline,GBUFSIZ,file) != 0;) - { - if(Inline[strlen(Inline)-1] == '\n') - Inline[strlen(Inline)-1] = '\0'; - if(Find(Inline,"LOCUS")) - { + for (; fgets(Inline, GBUFSIZ, file) != 0;) { + if (Inline[strlen(Inline) - 1] == '\n') + Inline[strlen(Inline) - 1] = '\0'; + if (Find(Inline, "LOCUS")) { curelem = dataset->numelements++; - if(curelem == 0) - { - dataset->element=(NA_Sequence*) - Calloc(5,sizeof(NA_Sequence)); + if (curelem == 0) { + dataset->element = (NA_Sequence *)Calloc( + 5, sizeof(NA_Sequence)); dataset->maxnumelements = 5; } - else if (curelem==dataset->maxnumelements) - { + else if (curelem == dataset->maxnumelements) { (dataset->maxnumelements) *= 2; - dataset->element =(NA_Sequence*) - Realloc(dataset->element, - dataset->maxnumelements * sizeof(NA_Sequence)); + dataset->element = (NA_Sequence *)Realloc( + dataset->element, dataset->maxnumelements * + sizeof(NA_Sequence)); } this_elem = &(dataset->element[curelem]); - n = sscanf(Inline,"%s %s %s %s %s %s %s %s", - fields[0],fields[1],fields[2],fields[3],fields[4], - fields[5],fields[6],fields[7]); - if(IS_REALLY_AA) - { - InitNASeq(this_elem,PROTEIN); + n = sscanf(Inline, "%s %s %s %s %s %s %s %s", fields[0], + fields[1], fields[2], fields[3], fields[4], + fields[5], fields[6], fields[7]); + if (IS_REALLY_AA) { + InitNASeq(this_elem, PROTEIN); } - else if(Find(Inline,"DNA")) - { - InitNASeq(this_elem,DNA); + else if (Find(Inline, "DNA")) { + InitNASeq(this_elem, DNA); } - else if(Find(Inline,"RNA")) - { - InitNASeq(this_elem,RNA); + else if (Find(Inline, "RNA")) { + InitNASeq(this_elem, RNA); } - else if(Find(Inline,"MASK")) - { - InitNASeq(this_elem,MASK); + else if (Find(Inline, "MASK")) { + InitNASeq(this_elem, MASK); } - else if(Find(Inline,"TEXT")) - { - InitNASeq(this_elem,TEXT); + else if (Find(Inline, "TEXT")) { + InitNASeq(this_elem, TEXT); } - else if(Find(Inline,"PROT")) - { - InitNASeq(this_elem,PROTEIN); + else if (Find(Inline, "PROT")) { + InitNASeq(this_elem, PROTEIN); } else - InitNASeq(this_elem,DNA); + InitNASeq(this_elem, DNA); - strncpy(this_elem->short_name,fields[1],31); - AsciiTime(&(this_elem->t_stamp.origin),fields[n-1]); + strncpy(this_elem->short_name, fields[1], 31); + AsciiTime(&(this_elem->t_stamp.origin), fields[n - 1]); this_elem->attr = DEFAULT_X_ATTR; - if( Find(Inline, "Circular") ) + if (Find(Inline, "Circular")) this_elem->attr |= IS_CIRCULAR; gencomments = NULL; genclen = 0; } - else if(Find(Inline,"DEFINITION")) - strncpy(this_elem->description,&(Inline[12]),79); + else if (Find(Inline, "DEFINITION")) + strncpy(this_elem->description, &(Inline[12]), 79); - else if(Find(Inline,"AUTHOR")) - strncpy(this_elem->authority,&(Inline[12]),79); + else if (Find(Inline, "AUTHOR")) + strncpy(this_elem->authority, &(Inline[12]), 79); - else if(Find(Inline," ORGANISM")) - strncpy(this_elem->seq_name,&(Inline[12]),79); + else if (Find(Inline, " ORGANISM")) + strncpy(this_elem->seq_name, &(Inline[12]), 79); - else if(Find(Inline,"ACCESSION")) - strncpy(this_elem->id,&(Inline[12]),79); + else if (Find(Inline, "ACCESSION")) + strncpy(this_elem->id, &(Inline[12]), 79); - else if(Find(Inline,"ORIGIN")) - { + else if (Find(Inline, "ORIGIN")) { done = FALSE; len = 0; - for(;done == FALSE && fgets(Inline,GBUFSIZ,file) != 0;) - { - if(Inline[0] != '/') - { - if(buflen == 0) - { + for (; done == FALSE && + fgets(Inline, GBUFSIZ, file) != 0;) { + if (Inline[0] != '/') { + if (buflen == 0) { buflen = GBUFSIZ; - buffer = Calloc(sizeof(char) , - buflen); + buffer = Calloc(sizeof(char), + buflen); } - else if (len+strlen(Inline) >= buflen) - { + else if (len + strlen(Inline) >= + buflen) { buflen += GBUFSIZ; - buffer = Realloc(buffer, - sizeof(char)*buflen); - for(j=buflen-GBUFSIZ - ;j - element[curelem])); - for(j=0;jelement[curelem])); + for (j = 0; j < len; j++) buffer[j] = '\0'; len = 0; done = TRUE; - dataset->element[curelem].comments - = gencomments; - dataset->element[curelem].comments_len= + dataset->element[curelem].comments = + gencomments; + dataset->element[curelem].comments_len = genclen - 1; - dataset->element[curelem]. - comments_maxlen = genclen; + dataset->element[curelem] + .comments_maxlen = genclen; gencomments = NULL; genclen = 0; } } -/* -* Test if sequence should be converted by the translation table -* If it looks like a protein... -*/ - if(dataset->element[curelem].rmatrix && - IS_REALLY_AA == FALSE) - { - IS_REALLY_AA = CheckType(dataset->element[curelem]. - sequence,dataset->element[curelem].seqlen); + /* + * Test if sequence should be converted by + *the translation table If it looks like a protein... + */ + if (dataset->element[curelem].rmatrix && + IS_REALLY_AA == FALSE) { + IS_REALLY_AA = CheckType( + dataset->element[curelem].sequence, + dataset->element[curelem].seqlen); - if(IS_REALLY_AA == FALSE) - Ascii2NA(dataset->element[curelem].sequence, + if (IS_REALLY_AA == FALSE) + Ascii2NA( + dataset->element[curelem].sequence, dataset->element[curelem].seqlen, dataset->element[curelem].rmatrix); else -/* -* Force the sequence to be AA -*/ + /* + * Force the sequence to be AA + */ { - dataset->element[curelem].elementtype = PROTEIN; - dataset->element[curelem].rmatrix = NULL; - dataset->element[curelem].tmatrix = NULL; + dataset->element[curelem].elementtype = + PROTEIN; + dataset->element[curelem].rmatrix = + NULL; + dataset->element[curelem].tmatrix = + NULL; dataset->element[curelem].col_lut = Default_PROColor_LKUP; } } } - else if (Find(Inline,"ZZZZZ")) - { + else if (Find(Inline, "ZZZZZ")) { Cfree(gencomments); genclen = 0; } - else - { - if (gencomments == NULL) - { + else { + if (gencomments == NULL) { gencomments = String(Inline); - genclen = strlen(gencomments)+1; + genclen = strlen(gencomments) + 1; } - else - { - genclen += strlen(Inline)+1; - gencomments = Realloc(gencomments,genclen * - sizeof(char)); - strncat(gencomments,Inline,GBUFSIZ); - strncat(gencomments,"\n",GBUFSIZ); + else { + genclen += strlen(Inline) + 1; + gencomments = Realloc(gencomments, + genclen * sizeof(char)); + strncat(gencomments, Inline, GBUFSIZ); + strncat(gencomments, "\n", GBUFSIZ); } } } Cfree(buffer); fclose(file); - for(j=0;jnumelements;j++) - dataset->maxlen = MAX(dataset->maxlen, - dataset->element[j].seqlen+dataset->element[j].offset); + for (j = 0; j < dataset->numelements; j++) + dataset->maxlen = + MAX(dataset->maxlen, dataset->element[j].seqlen + + dataset->element[j].offset); return; } - - typedef struct mya { int yy; int mm; @@ -245,7 +244,7 @@ typedef struct mya { int sc; } sA; -AsciiTime(sA *a,char *asciitime) +AsciiTime(sA *a, char *asciitime) { int j; char temp[GBUFSIZ]; @@ -254,186 +253,229 @@ AsciiTime(sA *a,char *asciitime) a->dd = 0; a->yy = 0; a->mm = 0; - sscanf(asciitime,"%d%5c%d",&(a->dd),temp,&(a->yy)); + sscanf(asciitime, "%d%5c%d", &(a->dd), temp, &(a->yy)); temp[5] = '\0'; - for(j=0;j<12;j++) - if(strcmp(temp,month[j]) == 0) - a->mm = j+1; - if(a->dd <0 || a->dd > 31 || a->yy < 0 || a->mm > 11) - SetTime(a); + for (j = 0; j < 12; j++) + if (strcmp(temp, month[j]) == 0) a->mm = j + 1; + if (a->dd < 0 || a->dd > 31 || a->yy < 0 || a->mm > 11) SetTime(a); return; } - -WriteGen(aln,filename,method,maskable) -NA_Alignment *aln; +WriteGen(aln, filename, method, maskable) NA_Alignment *aln; char *filename; -int method,maskable; +int method, maskable; { - int i,j,k,mask = -1; + int i, j, k, mask = -1; FILE *file; NA_Sequence *this_elem; extern char month[12][6]; char c; - if(aln == NULL) - return; - if(aln->na_ddata == NULL) - return; + if (aln == NULL) return; + if (aln->na_ddata == NULL) return; - file = fopen(filename,"w"); - if(file == NULL) - { + file = fopen(filename, "w"); + if (file == NULL) { Warning("Cannot open file for output"); - return(1); + return (1); } - if(maskable && method != SELECT_REGION) - for(j=0;jnumelements;j++) - if(aln->element[j].elementtype == MASK && + if (maskable && method != SELECT_REGION) + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].elementtype == MASK && aln->element[j].selected) mask = j; - for(j=0;jnumelements;j++) - { - if((aln->element[j].selected && j!=mask && method != SELECT_REGION) - ||(aln->element[j].subselected && method == SELECT_REGION) - || (method == ALL)) - { + for (j = 0; j < aln->numelements; j++) { + if ((aln->element[j].selected && j != mask && + method != SELECT_REGION) || + (aln->element[j].subselected && method == SELECT_REGION) || + (method == ALL)) { this_elem = &(aln->element[j]); - fprintf(file, + fprintf( + file, "LOCUS %10s%8d bp %4s %10s %2d%5s%4d\n", - this_elem->short_name,this_elem->seqlen+this_elem->offset, - (this_elem->elementtype == DNA) ? "DNA": - (this_elem->elementtype ==RNA)?"RNA": - (this_elem->elementtype == MASK)?"MASK": - (this_elem->elementtype == PROTEIN)?"PROT":"TEXT", - this_elem->attr & IS_CIRCULAR?"Circular":"", + this_elem->short_name, + this_elem->seqlen + this_elem->offset, + (this_elem->elementtype == DNA) ? "DNA" + : (this_elem->elementtype == RNA) ? "RNA" + : (this_elem->elementtype == MASK) ? "MASK" + : (this_elem->elementtype == PROTEIN) ? "PROT" + : "TEXT", + this_elem->attr & IS_CIRCULAR ? "Circular" : "", this_elem->t_stamp.origin.dd, - month[this_elem->t_stamp.origin.mm-1], - this_elem->t_stamp.origin.yy>1900?this_elem->t_stamp.origin.yy: - this_elem->t_stamp.origin.yy+1900); - if(this_elem->description[0]) - fprintf(file,"DEFINITION %s\n",this_elem->description); - if(this_elem->seq_name[0]) - fprintf(file," ORGANISM %s\n",this_elem->seq_name); - if(this_elem->id[0]) - fprintf(file," ACCESSION %s\n",this_elem->id); - if(this_elem->authority[0]) - fprintf(file," AUTHORS %s\n",this_elem->authority); - if(this_elem->comments) - fprintf(file,"%s\n",this_elem->comments); - fprintf(file,"ORIGIN"); - if(this_elem->tmatrix) - { - if(mask == -1) - { - for(i=0,k=0;kseqlen+this_elem->offset;k++) - { - if(method == SELECT_REGION) - { - if(aln->selection_mask[k] == '1') - { - if(i%60 == 0) - fprintf(file,"\n%9d",i+1); - if(i%10 == 0) - fprintf(file," "); - fprintf(file,"%c",this_elem->tmatrix - [getelem(this_elem,k)]); + month[this_elem->t_stamp.origin.mm - 1], + this_elem->t_stamp.origin.yy > 1900 + ? this_elem->t_stamp.origin.yy + : this_elem->t_stamp.origin.yy + 1900); + if (this_elem->description[0]) + fprintf(file, "DEFINITION %s\n", + this_elem->description); + if (this_elem->seq_name[0]) + fprintf(file, " ORGANISM %s\n", + this_elem->seq_name); + if (this_elem->id[0]) + fprintf(file, " ACCESSION %s\n", + this_elem->id); + if (this_elem->authority[0]) + fprintf(file, " AUTHORS %s\n", + this_elem->authority); + if (this_elem->comments) + fprintf(file, "%s\n", this_elem->comments); + fprintf(file, "ORIGIN"); + if (this_elem->tmatrix) { + if (mask == -1) { + for (i = 0, k = 0; + k < this_elem->seqlen + + this_elem->offset; + k++) { + if (method == SELECT_REGION) { + if (aln->selection_mask + [k] == '1') { + if (i % 60 == 0) + fprintf( + file, + "\n" + "%9" + "d", + i + 1); + if (i % 10 == 0) + fprintf( + file, + " "); + fprintf( + file, "%c", + this_elem->tmatrix + [getelem( + this_elem, + k)]); i++; } } - else - { - if(i%60 == 0) - fprintf(file,"\n%9d",i+1); - if(i%10 == 0) - fprintf(file," "); - fprintf(file,"%c",this_elem->tmatrix - [getelem(this_elem,k)]); + else { + if (i % 60 == 0) + fprintf(file, + "\n%9d", + i + 1); + if (i % 10 == 0) + fprintf(file, + " "); + fprintf( + file, "%c", + this_elem->tmatrix + [getelem( + this_elem, + k)]); i++; } } } - else - { - for(k=0;kseqlen+this_elem->offset;k++) - { - c =(char)getelem(&(aln->element[mask]),k); - if(c != '0' && c!= '-') - { - if(k%60 == 0) - fprintf(file,"\n%9d",k+1); - if(k%10 == 0) - fprintf(file," "); - fprintf(file,"%c",this_elem->tmatrix - [getelem(this_elem,k)]); + else { + for (k = 0; k < this_elem->seqlen + + this_elem->offset; + k++) { + c = (char)getelem( + &(aln->element[mask]), k); + if (c != '0' && c != '-') { + if (k % 60 == 0) + fprintf(file, + "\n%9d", + k + 1); + if (k % 10 == 0) + fprintf(file, + " "); + fprintf( + file, "%c", + this_elem->tmatrix + [getelem( + this_elem, + k)]); } } } } - else - { - if(mask == -1) - { - for(i=0,k=0;kseqlen+this_elem->offset;k++) - { - if(method == SELECT_REGION) - { - if(aln->selection_mask[k] == '1') - { - if(i%60 == 0) - fprintf(file,"\n%9d",i+1); - if(i%10 == 0) - fprintf(file," "); - fprintf(file,"%c", getelem(this_elem,k)); + else { + if (mask == -1) { + for (i = 0, k = 0; + k < this_elem->seqlen + + this_elem->offset; + k++) { + if (method == SELECT_REGION) { + if (aln->selection_mask + [k] == '1') { + if (i % 60 == 0) + fprintf( + file, + "\n" + "%9" + "d", + i + 1); + if (i % 10 == 0) + fprintf( + file, + " "); + fprintf( + file, "%c", + getelem( + this_elem, + k)); i++; } } - else - { - if(i%60 == 0) - fprintf(file,"\n%9d",i+1); - if(i%10 == 0) - fprintf(file," "); - fprintf(file,"%c",getelem(this_elem,k)); + else { + if (i % 60 == 0) + fprintf(file, + "\n%9d", + i + 1); + if (i % 10 == 0) + fprintf(file, + " "); + fprintf( + file, "%c", + getelem(this_elem, + k)); i++; } } } - else - { - for(k=0;kseqlen+this_elem->offset;k++) - { - c =(char)getelem(&(aln->element[mask]),k); - if(c != '0' && c!= '-') - { - if(k%60 == 0) - fprintf(file,"\n%9d",k+1); - if(k%10 == 0) - fprintf(file," "); - fprintf(file,"%c",getelem(this_elem,k)); + else { + for (k = 0; k < this_elem->seqlen + + this_elem->offset; + k++) { + c = (char)getelem( + &(aln->element[mask]), k); + if (c != '0' && c != '-') { + if (k % 60 == 0) + fprintf(file, + "\n%9d", + k + 1); + if (k % 10 == 0) + fprintf(file, + " "); + fprintf( + file, "%c", + getelem(this_elem, + k)); } } } } - fprintf(file,"\n//\n"); + fprintf(file, "\n//\n"); } } fclose(file); return; } - SetTime(sA *a) { - struct tm *tim,*localtime(); + struct tm *tim, *localtime(); long clock; clock = time(0); tim = localtime(&clock); a->yy = tim->tm_year; - a->mm = tim->tm_mon+1; + a->mm = tim->tm_mon + 1; a->dd = tim->tm_mday; a->hr = tim->tm_hour; a->mn = tim->tm_min; @@ -442,24 +484,20 @@ SetTime(sA *a) } /* -* CheckType: Check base composition to see if the sequence -* appears to be an amino acid sequence. If it is, pass back -* TRUE, else FALSE. -*/ -CheckType(seq,len) -char *seq; + * CheckType: Check base composition to see if the sequence + * appears to be an amino acid sequence. If it is, pass back + * TRUE, else FALSE. + */ +CheckType(seq, len) char *seq; int len; { + int j, count1 = 0, count2 = 0; - int j,count1 = 0,count2 = 0; - - for(j=0;j 'a')) - { + for (j = 0; j < len; j++) + if (((seq[j] | 32) < 'z') && ((seq[j] | 32) > 'a')) { count1++; - if(index("ACGTUNacgtun",seq[j]) == NULL) - count2++; + if (index("ACGTUNacgtun", seq[j]) == NULL) count2++; } - return( (count2 > count1/4)?TRUE:FALSE); + return ((count2 > count1 / 4) ? TRUE : FALSE); } diff --git a/CORE/HGLfile.c b/CORE/HGLfile.c index cbfac0a..2354a77 100755 --- a/CORE/HGLfile.c +++ b/CORE/HGLfile.c @@ -1,214 +1,181 @@ -#include -#include #include -#include +#include +#include +#include #include -#include "menudefs.h" -#include "defines.h" +#include +#include "defines.h" +#include "menudefs.h" /* Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory. All rights reserved. */ -ReadGDE(filename,dataset,type) -char *filename; +ReadGDE(filename, dataset, type) char *filename; NA_Alignment *dataset; int type; { - register int done = FALSE,len = 0, j=0; - int success,count,temp = 0; - char Inline[GBUFSIZ],c; - char *buffer,*line,*gencomments = NULL,fields[8][GBUFSIZ]; - int buflen = GBUFSIZ,genclen = 0,curelem = 0,n = 0,flag = 0; - NA_Sequence *this_elem = NULL,temp_elem; + register int done = FALSE, len = 0, j = 0; + int success, count, temp = 0; + char Inline[GBUFSIZ], c; + char *buffer, *line, *gencomments = NULL, fields[8][GBUFSIZ]; + int buflen = GBUFSIZ, genclen = 0, curelem = 0, n = 0, flag = 0; + NA_Sequence *this_elem = NULL, temp_elem; FILE *file; extern int Default_DNA_Trans[], Default_RNA_Trans[]; - extern int OVERWRITE,Default_NA_RTrans[], Default_PROColor_LKUP[]; + extern int OVERWRITE, Default_NA_RTrans[], Default_PROColor_LKUP[]; - ErrorOut("No such file",file = fopen(filename,"r")); + ErrorOut("No such file", file = fopen(filename, "r")); - for(;fgets(Inline,GBUFSIZ,file) != 0;) - { - for(line = Inline;line[0]==' ' || line[0] == '\t';line++); + for (; fgets(Inline, GBUFSIZ, file) != 0;) { + for (line = Inline; line[0] == ' ' || line[0] == '\t'; line++) + ; - if(Find2(line,"{")==0) - { + if (Find2(line, "{") == 0) { this_elem = &temp_elem; - InitNASeq(this_elem,DNA); + InitNASeq(this_elem, DNA); this_elem->offset = -(dataset->rel_offset); } - else if(Find2(line,"type")==0) - { - if(Find(line,"DNA")) - { + else if (Find2(line, "type") == 0) { + if (Find(line, "DNA")) { this_elem->elementtype = DNA; this_elem->tmatrix = Default_DNA_Trans; this_elem->rmatrix = Default_NA_RTrans; } - else if(Find(line,"RNA")) - { + else if (Find(line, "RNA")) { this_elem->elementtype = RNA; this_elem->tmatrix = Default_RNA_Trans; this_elem->rmatrix = Default_NA_RTrans; } - else if(Find(line,"MASK")) - { + else if (Find(line, "MASK")) { this_elem->elementtype = MASK; this_elem->rmatrix = NULL; this_elem->tmatrix = NULL; this_elem->col_lut = NULL; } - else if(Find(line,"TEXT")) - { + else if (Find(line, "TEXT")) { this_elem->elementtype = TEXT; this_elem->rmatrix = NULL; this_elem->tmatrix = NULL; this_elem->col_lut = NULL; } - else if(Find(line,"PROT")) - { + else if (Find(line, "PROT")) { this_elem->elementtype = PROTEIN; this_elem->rmatrix = NULL; this_elem->tmatrix = NULL; this_elem->col_lut = Default_PROColor_LKUP; } -/* - this_elem->attr = DEFAULT_X_ATTR; -*/ + /* + this_elem->attr = + DEFAULT_X_ATTR; + */ } - else if(Find2(line,"circular")==0) - { - sscanf(line,"%*s %d",&temp); - if(temp == 1) - { + else if (Find2(line, "circular") == 0) { + sscanf(line, "%*s %d", &temp); + if (temp == 1) { this_elem->attr |= IS_CIRCULAR; } - else - { + else { this_elem->attr &= ~IS_CIRCULAR; } } - else if(Find2(line,"orig_direction")==0) - { - sscanf(line,"%*s %d",&temp); - if(temp == 1) - { + else if (Find2(line, "orig_direction") == 0) { + sscanf(line, "%*s %d", &temp); + if (temp == 1) { this_elem->attr |= IS_ORIG_5_TO_3; this_elem->attr &= ~IS_ORIG_3_TO_5; } - else - { + else { this_elem->attr |= IS_ORIG_3_TO_5; this_elem->attr &= ~IS_ORIG_5_TO_3; } } - else if(Find2(line,"direction")==0) - { - sscanf(line,"%*s %d",&temp); - if(temp == 1) - { + else if (Find2(line, "direction") == 0) { + sscanf(line, "%*s %d", &temp); + if (temp == 1) { this_elem->attr |= IS_5_TO_3; this_elem->attr &= ~IS_3_TO_5; } - else - { + else { this_elem->attr |= IS_3_TO_5; this_elem->attr &= ~IS_5_TO_3; } } - else if(Find2(line,"orig_strand")==0) - { - sscanf(line,"%*s %d",&temp); - if(temp == 1) - { + else if (Find2(line, "orig_strand") == 0) { + sscanf(line, "%*s %d", &temp); + if (temp == 1) { this_elem->attr |= IS_ORIG_PRIMARY; this_elem->attr &= ~IS_ORIG_SECONDARY; } - else - { + else { this_elem->attr |= IS_ORIG_SECONDARY; this_elem->attr &= ~IS_ORIG_PRIMARY; } } - else if(Find2(line,"strandedness")==0) - { - sscanf(line,"%*s %d",&temp); - if(temp == 1) - { + else if (Find2(line, "strandedness") == 0) { + sscanf(line, "%*s %d", &temp); + if (temp == 1) { this_elem->attr |= IS_PRIMARY; this_elem->attr &= ~IS_SECONDARY; } - else - { + else { this_elem->attr |= IS_SECONDARY; this_elem->attr &= ~IS_PRIMARY; } } - else if(Find2(line,"creator")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->authority); + else if (Find2(line, "creator") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->authority); RemoveQuotes(this_elem->authority); } - else if(Find2(line,"longname")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->seq_name); + else if (Find2(line, "longname") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->seq_name); RemoveQuotes(this_elem->seq_name); } - else if(Find2(line,"descrip")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->description); + else if (Find2(line, "descrip") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->description); RemoveQuotes(this_elem->description); } - else if(Find2(line,"name")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->short_name); + else if (Find2(line, "name") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->short_name); RemoveQuotes(this_elem->short_name); } - else if(Find2(line,"group-ID")==0) - { - sscanf(line,"%*s %d",&(this_elem->groupid)); + else if (Find2(line, "group-ID") == 0) { + sscanf(line, "%*s %d", &(this_elem->groupid)); dataset->numgroups = MAX(this_elem->groupid, dataset->numgroups); } - else if(Find2(line,"sequence-ID")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->id); + else if (Find2(line, "sequence-ID") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->id); RemoveQuotes(this_elem->id); } - else if(Find2(line,"barcode")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->barcode); + else if (Find2(line, "barcode") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->barcode); RemoveQuotes(this_elem->barcode); } - else if(Find2(line,"membrane")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->membrane); + else if (Find2(line, "membrane") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->membrane); RemoveQuotes(this_elem->membrane); } - else if(Find2(line,"contig")==0) - { - sscanf(line,"%*s %[^\n]",this_elem->contig); + else if (Find2(line, "contig") == 0) { + sscanf(line, "%*s %[^\n]", this_elem->contig); RemoveQuotes(this_elem->contig); } - else if(Find2(line,"creation-date")==0) - { - sscanf(line,"%*s %2d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\n", - &(this_elem->t_stamp.origin.mm), - &(this_elem->t_stamp.origin.dd), - &(this_elem->t_stamp.origin.yy), - &(this_elem->t_stamp.origin.hr), - &(this_elem->t_stamp.origin.mn), - &(this_elem->t_stamp.origin.sc)); + else if (Find2(line, "creation-date") == 0) { + sscanf(line, "%*s %2d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\n", + &(this_elem->t_stamp.origin.mm), + &(this_elem->t_stamp.origin.dd), + &(this_elem->t_stamp.origin.yy), + &(this_elem->t_stamp.origin.hr), + &(this_elem->t_stamp.origin.mn), + &(this_elem->t_stamp.origin.sc)); } - else if(Find2(line,"offset")==0) - { - sscanf(line,"%*s %d",&(this_elem->offset)); + else if (Find2(line, "offset") == 0) { + sscanf(line, "%*s %d", &(this_elem->offset)); this_elem->offset -= dataset->rel_offset; } - else if(Find2(line,"comments")==0) - { - if(this_elem->comments_maxlen ==0) + else if (Find2(line, "comments") == 0) { + if (this_elem->comments_maxlen == 0) buflen = 2048; else buflen = this_elem->comments_maxlen; @@ -216,33 +183,31 @@ int type; done = FALSE; len = this_elem->comments_len; - for(;line[0] != '"';line++) - if(line[0] == '\0') - ErrorOut(0,"Error in input file"); + for (; line[0] != '"'; line++) + if (line[0] == '\0') + ErrorOut(0, "Error in input file"); line++; - buffer = Calloc(buflen,sizeof(char)); - for(;!done;) - { - for(j=0;j= buflen) - { - buflen *=2; - buffer = Realloc(buffer, - buflen*sizeof(char)); + buffer = Calloc(buflen, sizeof(char)); + for (; !done;) { + for (j = 0; j < strlen(line); j++) { + if (len + strlen(line) >= buflen) { + buflen *= 2; + buffer = Realloc( + buffer, + buflen * sizeof(char)); } - if(line[j] == '"') done = TRUE; + if (line[j] == '"') + done = TRUE; - else + else buffer[len++] = line[j]; } /* -* Check pad with null -*/ + * Check pad with null + */ buffer[len] = '\0'; - if(!done) - { - if(fgets(Inline,GBUFSIZ,file) == 0) + if (!done) { + if (fgets(Inline, GBUFSIZ, file) == 0) done = TRUE; line = Inline; } @@ -252,120 +217,114 @@ int type; this_elem->comments_maxlen = buflen; RemoveQuotes(this_elem->comments); } - else if(Find2(line,"sequence")==0) - { + else if (Find2(line, "sequence") == 0) { buflen = GBUFSIZ; done = FALSE; len = 0; - buffer = Calloc(buflen,sizeof(char)); - for(;line[0] != '"';line++) - if(line[0] == '\0') - ErrorOut(0,"Error in input file"); + buffer = Calloc(buflen, sizeof(char)); + for (; line[0] != '"'; line++) + if (line[0] == '\0') + ErrorOut(0, "Error in input file"); line++; - for(;!done;) - { - for(j=0;j= buflen) - { - buflen *=2; - buffer = Realloc(buffer, - buflen*sizeof(char)); + for (; !done;) { + for (j = 0; j < strlen(line); j++) { + if (len + strlen(line) >= buflen) { + buflen *= 2; + buffer = Realloc( + buffer, + buflen * sizeof(char)); } - if(line[j] == '"') done = TRUE; + if (line[j] == '"') + done = TRUE; - else - { + else { /* -* If not text, ignore spaces... -*/ - if(this_elem->elementtype !=TEXT) - { - if(line[j]!=' ' && line[j] != - '\t' && line[j] != '\n') - buffer[len++] = line[j]; + * If not + *text, ignore spaces... + */ + if (this_elem->elementtype != + TEXT) { + if (line[j] != ' ' && + line[j] != '\t' && + line[j] != '\n') + buffer[len++] = + line[j]; } - else - if(line[j] != '\t' && line[j] != '\n') - buffer[len++] = line[j]; + else if (line[j] != '\t' && + line[j] != '\n') + buffer[len++] = line[j]; } } - if(!done) - { - if(fgets(Inline,GBUFSIZ,file) == 0) + if (!done) { + if (fgets(Inline, GBUFSIZ, file) == 0) done = TRUE; line = Inline; } } - if(this_elem->rmatrix) - for(j=0;jrmatrix[buffer[j]]; - this_elem->sequence =(NA_Base*)buffer; + if (this_elem->rmatrix) + for (j = 0; j < len; j++) + buffer[j] = + this_elem->rmatrix[buffer[j]]; + this_elem->sequence = (NA_Base *)buffer; this_elem->seqlen = len; this_elem->seqmaxlen = buflen; } - else if (Find2(line,"}")==0) - { - if(this_elem->id[0] == '\0') - strncpy(this_elem->id,uniqueID(),79); - if(this_elem->short_name[0] == '\0') - strncpy(this_elem->short_name,this_elem->id,79); - if(this_elem->seqlen == 0) - this_elem->protect= - PROT_BASE_CHANGES+ - PROT_GREY_SPACE+ - PROT_WHITE_SPACE+ - PROT_TRANSLATION; + else if (Find2(line, "}") == 0) { + if (this_elem->id[0] == '\0') + strncpy(this_elem->id, uniqueID(), 79); + if (this_elem->short_name[0] == '\0') + strncpy(this_elem->short_name, this_elem->id, + 79); + if (this_elem->seqlen == 0) + this_elem->protect = + PROT_BASE_CHANGES + PROT_GREY_SPACE + + PROT_WHITE_SPACE + PROT_TRANSLATION; genclen = 0; -/* -* Make a new sequence entry... -*/ + /* + * Make a new sequence entry... + */ success = -1; - if(OVERWRITE) - success = OverWrite(this_elem,dataset); + if (OVERWRITE) success = OverWrite(this_elem, dataset); - if(success == -1) - { + if (success == -1) { curelem = dataset->numelements++; - if(curelem == 0) - { - dataset->element=(NA_Sequence*) - Calloc(5,sizeof(NA_Sequence)); + if (curelem == 0) { + dataset->element = + (NA_Sequence *)Calloc( + 5, sizeof(NA_Sequence)); dataset->maxnumelements = 5; } - else if (curelem==dataset->maxnumelements) - { + else if (curelem == dataset->maxnumelements) { (dataset->maxnumelements) *= 2; - dataset->element =(NA_Sequence*) - Realloc(dataset->element, - dataset->maxnumelements * sizeof(NA_Sequence)); + dataset->element = + (NA_Sequence *)Realloc( + dataset->element, + dataset->maxnumelements * + sizeof(NA_Sequence)); } dataset->element[curelem] = *this_elem; } } - else if(this_elem != NULL) - { - if (this_elem->baggage == NULL) - { + else if (this_elem != NULL) { + if (this_elem->baggage == NULL) { this_elem->baggage = String(line); this_elem->baggage_maxlen = this_elem->baggage_len = - strlen(this_elem->baggage)+1; + strlen(this_elem->baggage) + 1; } - else - { - this_elem->baggage_len += strlen(line)+1; + else { + this_elem->baggage_len += strlen(line) + 1; this_elem->baggage = Realloc( - this_elem->baggage,this_elem->baggage_len * - sizeof(char)); + this_elem->baggage, + this_elem->baggage_len * sizeof(char)); this_elem->baggage_maxlen = this_elem->baggage_len; - strncat(this_elem->baggage,line,GBUFSIZ); + strncat(this_elem->baggage, line, GBUFSIZ); } } } @@ -377,304 +336,358 @@ int type; return; } -WriteGDE(aln,filename,method,maskable) -NA_Alignment *aln; +WriteGDE(aln, filename, method, maskable) NA_Alignment *aln; char *filename; -int method,maskable; +int method, maskable; { - int i,j,k,mask = -1; + int i, j, k, mask = -1; FILE *file; NA_Sequence *this_elem; extern char month[12][6]; - if(aln == NULL) - return; - if(aln->na_ddata == NULL) - return; + if (aln == NULL) return; + if (aln->na_ddata == NULL) return; - file = fopen(filename,"w"); - if(file == NULL) - { + file = fopen(filename, "w"); + if (file == NULL) { Warning("Cannot open file for output"); - return(1); + return (1); } - if(maskable && method != SELECT_REGION) - for(j=0;jnumelements;j++) - if(aln->element[j].elementtype == MASK && + if (maskable && method != SELECT_REGION) + for (j = 0; j < aln->numelements; j++) + if (aln->element[j].elementtype == MASK && aln->element[j].selected) mask = j; - for(j=0;jnumelements;j++) - { - if((aln->element[j].selected && j!=mask && method!=SELECT_REGION) - || (method == ALL) - || (aln->element[j].subselected && method == SELECT_REGION)) - { + for (j = 0; j < aln->numelements; j++) { + if ((aln->element[j].selected && j != mask && + method != SELECT_REGION) || + (method == ALL) || + (aln->element[j].subselected && method == SELECT_REGION)) { this_elem = &(aln->element[j]); SeqNorm(this_elem); - fprintf(file,"{\n"); - if(this_elem->short_name[0]) - fprintf(file,"name \"%s\"\n",this_elem->short_name); - switch(this_elem->elementtype) - { - case DNA: - fprintf(file,"type \"DNA\"\n"); - break; - case RNA: - fprintf(file,"type \"RNA\"\n"); - break; - case PROTEIN: - fprintf(file,"type \"PROTEIN\"\n"); - break; - case MASK: - fprintf(file,"type \"MASK\"\n"); - break; - case TEXT: - fprintf(file,"type \"TEXT\"\n"); - break; + fprintf(file, "{\n"); + if (this_elem->short_name[0]) + fprintf(file, "name \"%s\"\n", + this_elem->short_name); + switch (this_elem->elementtype) { + case DNA: + fprintf(file, + "type \"DNA\"\n"); + break; + case RNA: + fprintf(file, + "type \"RNA\"\n"); + break; + case PROTEIN: + fprintf(file, + "type \"PROTEIN\"\n"); + break; + case MASK: + fprintf(file, + "type \"MASK\"\n"); + break; + case TEXT: + fprintf(file, + "type \"TEXT\"\n"); + break; } - if(this_elem->seq_name[0]) - fprintf(file,"longname %s\n",this_elem->seq_name); + if (this_elem->seq_name[0]) + fprintf(file, "longname %s\n", + this_elem->seq_name); - if(this_elem->id[0]) - fprintf(file,"sequence-ID \"%s\"\n",this_elem->id); + if (this_elem->id[0]) + fprintf(file, "sequence-ID \"%s\"\n", + this_elem->id); RemoveQuotes(this_elem->barcode); RemoveQuotes(this_elem->contig); - if(this_elem->barcode[0]) - fprintf(file,"barcode \"%s\"\n",this_elem->barcode); - if(this_elem->membrane[0]) - fprintf(file,"membrane \"%s\"\n",this_elem->membrane); - if(this_elem->contig[0]) - fprintf(file,"contig \"%s\"\n",this_elem->contig); - if(this_elem->description[0]) - fprintf(file,"descrip \"%s\"\n",this_elem->description); - if(this_elem->authority[0]) - fprintf(file,"creator \"%s\"\n",this_elem->authority); - if(this_elem->groupid) - fprintf(file,"group-ID %d\n", - this_elem->groupid); - if(this_elem->offset+aln->rel_offset && method!=SELECT_REGION) - fprintf(file,"offset %d\n",this_elem->offset+aln->rel_offset); - if(method == SELECT_REGION) - { -/* -* If selecting a region, the offset should be moved to the first -* non-'0' space in the mask. -*/ - for(k=this_elem->offset;kselection_mask_len && - aln->selection_mask[k] == '0';k++); - fprintf(file,"offset %d\n", aln->rel_offset+k); + if (this_elem->barcode[0]) + fprintf(file, "barcode \"%s\"\n", + this_elem->barcode); + if (this_elem->membrane[0]) + fprintf(file, "membrane \"%s\"\n", + this_elem->membrane); + if (this_elem->contig[0]) + fprintf(file, "contig \"%s\"\n", + this_elem->contig); + if (this_elem->description[0]) + fprintf(file, "descrip \"%s\"\n", + this_elem->description); + if (this_elem->authority[0]) + fprintf(file, "creator \"%s\"\n", + this_elem->authority); + if (this_elem->groupid) + fprintf(file, "group-ID %d\n", + this_elem->groupid); + if (this_elem->offset + aln->rel_offset && + method != SELECT_REGION) + fprintf(file, "offset %d\n", + this_elem->offset + aln->rel_offset); + if (method == SELECT_REGION) { + /* + * If selecting a region, the offset should + *be moved to the first non-'0' space in the + *mask. + */ + for (k = this_elem->offset; + k < aln->selection_mask_len && + aln->selection_mask[k] == '0'; + k++) + ; + fprintf(file, "offset %d\n", + aln->rel_offset + k); } - if(this_elem->t_stamp.origin.mm != 0) - fprintf(file, - "creation-date %2d/%2d/%2d %2d:%2d:%2d\n", + if (this_elem->t_stamp.origin.mm != 0) + fprintf( + file, + "creation-date %2d/%2d/%2d " + "%2d:%2d:%2d\n", this_elem->t_stamp.origin.mm, this_elem->t_stamp.origin.dd, - (this_elem->t_stamp.origin.yy)>1900? - (this_elem->t_stamp.origin.yy-1900): - (this_elem->t_stamp.origin.yy), + (this_elem->t_stamp.origin.yy) > 1900 + ? (this_elem->t_stamp.origin.yy - 1900) + : (this_elem->t_stamp.origin.yy), this_elem->t_stamp.origin.hr, this_elem->t_stamp.origin.mn, this_elem->t_stamp.origin.sc); - if((this_elem->attr & IS_ORIG_5_TO_3) && + if ((this_elem->attr & IS_ORIG_5_TO_3) && ((this_elem->attr & IS_ORIG_3_TO_5) == 0)) - fprintf(file,"orig_direction 1\n"); + fprintf(file, "orig_direction 1\n"); - if((this_elem->attr & IS_CIRCULAR) ) - fprintf(file,"circular 1\n"); + if ((this_elem->attr & IS_CIRCULAR)) + fprintf(file, "circular 1\n"); - if((this_elem->attr & IS_5_TO_3) && + if ((this_elem->attr & IS_5_TO_3) && ((this_elem->attr & IS_3_TO_5) == 0)) - fprintf(file,"direction 1\n"); + fprintf(file, "direction 1\n"); - if((this_elem->attr & IS_ORIG_3_TO_5) && + if ((this_elem->attr & IS_ORIG_3_TO_5) && ((this_elem->attr & IS_ORIG_5_TO_3) == 0)) - fprintf(file,"orig_direction -1\n"); + fprintf(file, "orig_direction -1\n"); - if((this_elem->attr & IS_3_TO_5) && + if ((this_elem->attr & IS_3_TO_5) && ((this_elem->attr & IS_5_TO_3) == 0)) - fprintf(file,"direction -1\n"); + fprintf(file, "direction -1\n"); - if((this_elem->attr & IS_ORIG_PRIMARY) && + if ((this_elem->attr & IS_ORIG_PRIMARY) && ((this_elem->attr & IS_ORIG_SECONDARY) == 0)) - fprintf(file,"orig_strand 1\n"); + fprintf(file, "orig_strand 1\n"); - if((this_elem->attr & IS_PRIMARY) && + if ((this_elem->attr & IS_PRIMARY) && ((this_elem->attr & IS_SECONDARY) == 0)) - fprintf(file,"strandedness 1\n"); + fprintf(file, "strandedness 1\n"); - if(((this_elem->attr & IS_ORIG_PRIMARY) == 0) && + if (((this_elem->attr & IS_ORIG_PRIMARY) == 0) && (this_elem->attr & IS_ORIG_SECONDARY)) - fprintf(file,"orig_strand 2\n"); + fprintf(file, "orig_strand 2\n"); - if(((this_elem->attr & IS_PRIMARY) == 0) && + if (((this_elem->attr & IS_PRIMARY) == 0) && (this_elem->attr & IS_SECONDARY)) - fprintf(file,"strandedness 2\n"); + fprintf(file, "strandedness 2\n"); - if(this_elem->comments != NULL) - { + if (this_elem->comments != NULL) { StripSpecial(this_elem->comments); - fprintf(file,"comments \"%s\"\n",this_elem->comments); + fprintf(file, "comments \"%s\"\n", + this_elem->comments); } - if(this_elem->baggage != NULL) - { - if(this_elem-> - baggage[strlen(this_elem->baggage)-1] == '\n') - fprintf(file,"%s",this_elem->baggage); + if (this_elem->baggage != NULL) { + if (this_elem + ->baggage[strlen(this_elem->baggage) - + 1] == '\n') + fprintf(file, "%s", this_elem->baggage); else - fprintf(file,"%s\n",this_elem->baggage); + fprintf(file, "%s\n", + this_elem->baggage); } - fprintf(file,"sequence \""); - if(this_elem->tmatrix) - { - if(mask == -1) - { - for(k=this_elem->offset;kseqlen+this_elem->offset;k++) - { - if(k%60 == 0) - putc('\n',file); - if(method == SELECT_REGION) - { - if(aln->selection_mask[k] == '1') - putc(this_elem->tmatrix[getelem(this_elem,k)], - file); + fprintf(file, "sequence \""); + if (this_elem->tmatrix) { + if (mask == -1) { + for (k = this_elem->offset; + k < this_elem->seqlen + + this_elem->offset; + k++) { + if (k % 60 == 0) + putc('\n', file); + if (method == SELECT_REGION) { + if (aln->selection_mask + [k] == '1') + putc( + this_elem->tmatrix + [getelem( + this_elem, + k)], + file); } else - putc(this_elem->tmatrix[getelem(this_elem,k)], - file); + putc(this_elem->tmatrix + [getelem( + this_elem, + k)], + file); } } - else - { - for(i=0,k=this_elem->offset;kseqlen+this_elem->offset;k++) - if(aln->element[mask].seqlen+this_elem->offset>k) - if((char)getelem(&(aln->element[mask]),k) != '0' - && ((char)getelem(&(aln->element[mask]),k) != '-')) - { - if(i%60 == 0) - putc('\n',file); - putc(this_elem->tmatrix[getelem(this_elem,k)], - file); - i++; - } - } - fprintf(file,"\"\n"); - } - else - { - if(mask == -1) - { - for(k=this_elem->offset;kseqlen+this_elem->offset;k++) - { - if(k%60 == 0) - putc('\n',file); - if(method == SELECT_REGION) - { - if(aln->selection_mask[k] == '1') - putc(getelem(this_elem,k),file); - } - else - putc(getelem(this_elem,k),file); - } - } - else - { - for(i=0,k=this_elem->offset;kseqlen+this_elem->offset;k++) - if(((aln->element[mask].seqlen)+(aln->element[mask]. - offset)) > k) - if((char)getelem(&(aln->element[mask]),k) == '1') - { - if(i%60 == 0) - putc('\n',file); - putc(getelem(this_elem,k),file); + else { + for (i = 0, k = this_elem->offset; + k < this_elem->seqlen + + this_elem->offset; + k++) + if (aln->element[mask].seqlen + + this_elem->offset > + k) + if ((char)getelem( + &(aln->element + [mask]), + k) != '0' && + ((char)getelem( + &(aln->element + [mask]), + k) != '-')) { + if (i % 60 == 0) + putc( + '\n', + file); + putc( + this_elem->tmatrix + [getelem( + this_elem, + k)], + file); i++; } } - fprintf(file,"\"\n"); + fprintf(file, "\"\n"); } - fprintf(file,"}\n"); + else { + if (mask == -1) { + for (k = this_elem->offset; + k < this_elem->seqlen + + this_elem->offset; + k++) { + if (k % 60 == 0) + putc('\n', file); + if (method == SELECT_REGION) { + if (aln->selection_mask + [k] == '1') + putc( + getelem( + this_elem, + k), + file); + } + else + putc(getelem(this_elem, + k), + file); + } + } + else { + for (i = 0, k = this_elem->offset; + k < this_elem->seqlen + + this_elem->offset; + k++) + if (((aln->element[mask] + .seqlen) + + (aln->element[mask] + .offset)) > k) + if ((char)getelem( + &(aln->element + [mask]), + k) == '1') { + if (i % 60 == 0) + putc( + '\n', + file); + putc( + getelem( + this_elem, + k), + file); + i++; + } + } + fprintf(file, "\"\n"); + } + fprintf(file, "}\n"); } } fclose(file); return; } - -StripSpecial(string) -char *string; +StripSpecial(string) char *string; { - register int i,j,len; + register int i, j, len; len = strlen(string); - for(j=0;j=0 && (string[j]=='\n'||string[j]==' '); j--) + for (j = strlen(string) - 1; + j >= 0 && (string[j] == '\n' || string[j] == ' '); j--) string[j] = '\0'; return; } - - /* -* Normalize seq (remove leading indels in the sequence; -*/ -void SeqNorm(seq) -NA_Sequence *seq; + * Normalize seq (remove leading indels in the sequence; + */ +void SeqNorm(seq) NA_Sequence *seq; { - int len,j,shift_width,trailer; + int len, j, shift_width, trailer; char *sequence; len = seq->seqlen; - sequence =(char*)seq->sequence; + sequence = (char *)seq->sequence; - if(len == 0) return; + if (len == 0) return; - if(seq->tmatrix) - for(shift_width=0; (shift_widthtmatrix) + for (shift_width = 0; (shift_width < len) && + ((sequence[shift_width] & 15) == '\0'); + shift_width++) + ; else - for(shift_width=0; (shift_widthseqlen -= shift_width; seq->offset += shift_width; - for(trailer=seq->seqlen-1;(sequence[trailer] =='-' || - sequence[trailer] == '\0') && trailer>=0; - trailer--) + for (trailer = seq->seqlen - 1; + (sequence[trailer] == '-' || sequence[trailer] == '\0') && + trailer >= 0; + trailer--) sequence[trailer] = '\0'; - seq->seqlen = trailer+1; + seq->seqlen = trailer + 1; return; } @@ -686,14 +699,13 @@ char vname[32]; char *uniqueID() { char hname[32]; /* ,vname[32]; rtm 18.III.98 */ - int hnamelen = 32; + int hnamelen = 32; time_t *tp; static cnt = 0; tp = (time_t *)Calloc(1, sizeof(time_t)); - if(gethostname(hname, 10) == -1) - { + if (gethostname(hname, 10) == -1) { fprintf(stderr, "UniqueID(): Failed to get host name.\n"); exit(1); } @@ -702,98 +714,90 @@ char *uniqueID() sprintf(vname, "%s:%d:%ld", hname, cnt, *tp); cnt++; Cfree(tp); - return(vname); + return (vname); } /* -* OverWrite(), overwrite all non-default data from a sequence entry -* onto any entry with the same ID or short name. -*/ -OverWrite(this,aln) -NA_Sequence *this; + * OverWrite(), overwrite all non-default data from a sequence entry + * onto any entry with the same ID or short name. + */ +OverWrite(this, aln) NA_Sequence *this; NA_Alignment *aln; { - int j,indx = -1; + int j, indx = -1; NA_Sequence *that; - for(j=0;jnumelements;j++) - { - if(Find2(this->id,aln->element[j].id) != -1) - if(Find2(aln->element[j].id,this->id) != -1) - indx = j; + for (j = 0; j < aln->numelements; j++) { + if (Find2(this->id, aln->element[j].id) != -1) + if (Find2(aln->element[j].id, this->id) != -1) indx = j; } - if(indx == -1) - for(j=0;jnumelements;j++) - { - if(Find2(this->short_name,aln->element[j].short_name)!= -1) - if(Find2(aln->element[j].short_name,this->short_name)!= -1) + if (indx == -1) + for (j = 0; j < aln->numelements; j++) { + if (Find2(this->short_name, + aln->element[j].short_name) != -1) + if (Find2(aln->element[j].short_name, + this->short_name) != -1) indx = j; } - if(indx != -1) - { + if (indx != -1) { that = &(aln->element[indx]); - if(this->seq_name[0]) - strcpy(that->seq_name,this->seq_name); - if(this->barcode[0]) - strcpy(that->barcode,this->barcode); - if(this->contig[0]) - strcpy(that->contig,this->contig); - if(this->membrane[0]) - strcpy(that->membrane,this->membrane); - if(this->authority[0]) - strcpy(that->authority,this->authority); - if(this->short_name[0]) - strcpy(that->short_name,this->short_name); - if(this->description[0]) - strcpy(that->description,this->description); - if(this->sequence) - { + if (this->seq_name[0]) strcpy(that->seq_name, this->seq_name); + if (this->barcode[0]) strcpy(that->barcode, this->barcode); + if (this->contig[0]) strcpy(that->contig, this->contig); + if (this->membrane[0]) strcpy(that->membrane, this->membrane); + if (this->authority[0]) + strcpy(that->authority, this->authority); + if (this->short_name[0]) + strcpy(that->short_name, this->short_name); + if (this->description[0]) + strcpy(that->description, this->description); + if (this->sequence) { cfree(that->sequence); that->sequence = this->sequence; that->seqlen = this->seqlen; that->seqmaxlen = this->seqmaxlen; } - if(this->baggage) - { + if (this->baggage) { that->baggage_len += this->baggage_len; that->baggage_maxlen += this->baggage_maxlen; - if(that->baggage) - that->baggage = - Realloc(that->baggage,that->baggage_maxlen*sizeof(char)); + if (that->baggage) + that->baggage = Realloc( + that->baggage, + that->baggage_maxlen * sizeof(char)); else - that->baggage = Calloc(that->baggage_maxlen,sizeof(char)); - strncat(that->baggage,this->baggage,that->baggage_maxlen); + that->baggage = + Calloc(that->baggage_maxlen, sizeof(char)); + strncat(that->baggage, this->baggage, + that->baggage_maxlen); } - if(this->comments) - { + if (this->comments) { that->comments_len += this->comments_len; that->comments_maxlen += this->comments_maxlen; - if(that->comments) - that->comments = - Realloc(that->comments,that->comments_maxlen*sizeof(char)); + if (that->comments) + that->comments = Realloc( + that->comments, + that->comments_maxlen * sizeof(char)); else - that->comments = Calloc(that->comments_maxlen,sizeof(char)); - strncat(that->comments,this->comments,that->comments_maxlen); + that->comments = + Calloc(that->comments_maxlen, sizeof(char)); + strncat(that->comments, this->comments, + that->comments_maxlen); } - if(this->cmask) - { + if (this->cmask) { cfree(that->cmask); that->cmask = this->cmask; } - if(this->offset != that->offset) - that->offset = this->offset; - if(this->attr != 0) - that->attr = this->attr; - if(this->groupid != 0) - { + if (this->offset != that->offset) that->offset = this->offset; + if (this->attr != 0) that->attr = this->attr; + if (this->groupid != 0) { that->groupid = this->groupid; } that->groupb = NULL; that->groupf = NULL; } -/* - NormalizeOffset(aln); - Regroup(aln); - AdjustGroups(aln); -*/ - return(indx); + /* + NormalizeOffset(aln); + Regroup(aln); + AdjustGroups(aln); + */ + return (indx); } diff --git a/CORE/ParseMenu.c b/CORE/ParseMenu.c index 5933f4b..dbc65db 100755 --- a/CORE/ParseMenu.c +++ b/CORE/ParseMenu.c @@ -1,9 +1,10 @@ -#include #include -#include +#include #include -#include "menudefs.h" +#include + #include "defines.h" +#include "menudefs.h" /* ParseMenus(): Read in the menu config file, and generate the internal @@ -24,106 +25,98 @@ int num_menus; ParseMenu() { - int j,curmenu = -1,curitem = 0; - int curchoice = 0 ,curarg = 0,curinput = 0, curoutput = 0; - char Inline[GBUFSIZ],temp[GBUFSIZ],head[GBUFSIZ]; - char tail[GBUFSIZ],*home; + int j, curmenu = -1, curitem = 0; + int curchoice = 0, curarg = 0, curinput = 0, curoutput = 0; + char Inline[GBUFSIZ], temp[GBUFSIZ], head[GBUFSIZ]; + char tail[GBUFSIZ], *home; Gmenu *thismenu; GmenuItem *thisitem; GmenuItemArg *thisarg; - GfileFormat *thisinput,*thisoutput; + GfileFormat *thisinput, *thisoutput; FILE *file; char *resize; -/* -* Open the menu configuration file ".GDEmenus" -* First search the local directory, then the home directory. -*/ - file=fopen(".GDEmenus","r"); - if(file == NULL) - { - home = (char*)getenv("HOME"); - strcpy(temp,home); - strcat(temp,"/.GDEmenus"); + /* + * Open the menu configuration file ".GDEmenus" + * First search the local directory, then the home directory. + */ + file = fopen(".GDEmenus", "r"); + if (file == NULL) { + home = (char *)getenv("HOME"); + strcpy(temp, home); + strcat(temp, "/.GDEmenus"); - file=fopen(temp,"r"); - if(file == NULL) - { - home = (char*)getenv("GDE_HELP_DIR"); - if(home != NULL) - { - strcpy(temp,home); - strcat(temp,"/.GDEmenus"); - file=fopen(temp,"r"); + file = fopen(temp, "r"); + if (file == NULL) { + home = (char *)getenv("GDE_HELP_DIR"); + if (home != NULL) { + strcpy(temp, home); + strcat(temp, "/.GDEmenus"); + file = fopen(temp, "r"); } - if(file == NULL) - Error( - ".GDEmenus file not in the home, local, or $GDE_HELP_DIR directory"); + if (file == NULL) + Error( + ".GDEmenus file not in the home, local, or " + "$GDE_HELP_DIR directory"); } - - } -/* -* Read the .GDEmenus file, and assemble an internal representation -* of the menu/menu-item hierarchy. -*/ + /* + * Read the .GDEmenus file, and assemble an internal representation + * of the menu/menu-item hierarchy. + */ - for(;getline(file,Inline) != EOF;) - { -/* -* menu: chooses menu to use -*/ - if(Inline[0] == '#'); - else if(Find(Inline,"menu:")) - { - crop(Inline,head,temp); + for (; gde_getline(file, Inline) != EOF;) { + /* + * menu: chooses menu to use + */ + if (Inline[0] == '#') + ; + else if (Find(Inline, "menu:")) { + crop(Inline, head, temp); curmenu = -1; - for(j=0;jlabel = - (char*)calloc(strlen(temp)+1,sizeof(char)); + thismenu->label = (char *)calloc( + strlen(temp) + 1, sizeof(char)); - if(thismenu->label == NULL) - Error("Calloc"); - (void)strcpy(thismenu->label,temp); - thismenu->numitems = 0; + if (thismenu->label == NULL) Error("Calloc"); + (void)strcpy(thismenu->label, temp); + thismenu->numitems = 0; } } -/* -* item: chooses menu item to use -*/ - else if(Find(Inline,"item:")) - { + /* + * item: chooses menu item to use + */ + else if (Find(Inline, "item:")) { curarg = -1; curinput = -1; curoutput = -1; - crop(Inline,head,temp); + crop(Inline, head, temp); curitem = thismenu->numitems++; -/* -* Resize the item list for this menu (add one item); -*/ - if(curitem == 0) - resize = (char*)calloc(1,sizeof(GmenuItem)); + /* + * Resize the item list for this menu (add one + *item); + */ + if (curitem == 0) + resize = (char *)calloc(1, sizeof(GmenuItem)); else - resize = realloc(thismenu->item, - thismenu -> numitems*sizeof(GmenuItem) ); + resize = realloc( + thismenu->item, + thismenu->numitems * sizeof(GmenuItem)); - if(resize == NULL) - Error ("Calloc"); - thismenu->item =(GmenuItem*)resize; + if (resize == NULL) Error("Calloc"); + thismenu->item = (GmenuItem *)resize; thisitem = &(thismenu->item[curitem]); - thisitem->label = (char*)calloc(strlen(temp)+1, - sizeof(char)); + thisitem->label = + (char *)calloc(strlen(temp) + 1, sizeof(char)); thisitem->meta = '\0'; thisitem->numinputs = 0; thisitem->numoutputs = 0; @@ -131,74 +124,66 @@ ParseMenu() thisitem->X = 0; thisitem->help = NULL; -/* -* Create new item -*/ + /* + * Create new item + */ - if(thisitem->label == NULL) - Error("Calloc"); - (void)strcpy(thisitem->label,temp); + if (thisitem->label == NULL) Error("Calloc"); + (void)strcpy(thisitem->label, temp); } -/* -* itemmethod: generic command line generated by this item -*/ - else if(Find(Inline,"itemmethod:")) - { - crop(Inline,head,temp); - thisitem->method = - (char*)calloc(strlen(temp)+1,sizeof(char)); - if(thisitem->method == NULL) - Error("Calloc"); - (void)strcpy(thisitem->method,temp); + /* + * itemmethod: generic command line generated by this item + */ + else if (Find(Inline, "itemmethod:")) { + crop(Inline, head, temp); + thisitem->method = + (char *)calloc(strlen(temp) + 1, sizeof(char)); + if (thisitem->method == NULL) Error("Calloc"); + (void)strcpy(thisitem->method, temp); } -/* -* Help file -*/ - else if(Find(Inline,"itemhelp:")) - { - crop(Inline,head,temp); + /* + * Help file + */ + else if (Find(Inline, "itemhelp:")) { + crop(Inline, head, temp); thisitem->help = - (char*)calloc(strlen(temp)+1,sizeof(char)); - if(thisitem->method == NULL) - Error("Calloc"); - (void)strcpy(thisitem->help,temp); + (char *)calloc(strlen(temp) + 1, sizeof(char)); + if (thisitem->method == NULL) Error("Calloc"); + (void)strcpy(thisitem->help, temp); } -/* -* Meta key equiv -*/ - else if(Find(Inline,"itemmeta:")) - { - crop(Inline,head,temp); - thisitem->meta = temp[0]; + /* + * Meta key equiv + */ + else if (Find(Inline, "itemmeta:")) { + crop(Inline, head, temp); + thisitem->meta = temp[0]; } -/* -* arg: defines the symbol for a command line arguement. -* this is used for substitution into the itemmethod -* definition. -*/ + /* + * arg: defines the symbol for a command line arguement. + * this is used for substitution into the + *itemmethod definition. + */ - else if(Find(Inline,"arg:")) - { - crop(Inline,head,temp); - curarg=thisitem->numargs++; - if(curarg == 0) - resize = (char*)calloc(1,sizeof(GmenuItemArg)); + else if (Find(Inline, "arg:")) { + crop(Inline, head, temp); + curarg = thisitem->numargs++; + if (curarg == 0) + resize = + (char *)calloc(1, sizeof(GmenuItemArg)); else - resize = realloc(thisitem->arg, - thisitem->numargs*sizeof(GmenuItemArg) ); - + resize = realloc( + thisitem->arg, + thisitem->numargs * sizeof(GmenuItemArg)); - if(resize == NULL) - Error("arg: Realloc"); + if (resize == NULL) Error("arg: Realloc"); - (thisitem->arg) = (GmenuItemArg*)resize; + (thisitem->arg) = (GmenuItemArg *)resize; thisarg = &(thisitem->arg[curarg]); - thisarg->symbol = (char*)calloc(strlen(temp)+1, - sizeof(char)); - if(thisarg->symbol == NULL) - Error("Calloc"); - (void)strcpy(thisarg->symbol,temp); + thisarg->symbol = + (char *)calloc(strlen(temp) + 1, sizeof(char)); + if (thisarg->symbol == NULL) Error("Calloc"); + (void)strcpy(thisarg->symbol, temp); thisarg->optional = FALSE; thisarg->type = 0; thisarg->min = 0; @@ -208,153 +193,145 @@ ParseMenu() thisarg->textvalue = NULL; thisarg->value = 0; } -/* -* argtype: Defines the type of argument (menu,chooser, text, slider) -*/ - else if(Find(Inline,"argtype:")) - { - crop(Inline,head,temp); - if(strcmp(temp,"text")==0) - { - thisarg->type=TEXTFIELD; + /* + * argtype: Defines the type of argument (menu,chooser, + *text, slider) + */ + else if (Find(Inline, "argtype:")) { + crop(Inline, head, temp); + if (strcmp(temp, "text") == 0) { + thisarg->type = TEXTFIELD; thisarg->textvalue = - (char*)calloc(GBUFSIZ,sizeof(char)); - if(thisarg->textvalue == NULL) - Error("Calloc"); + (char *)calloc(GBUFSIZ, sizeof(char)); + if (thisarg->textvalue == NULL) Error("Calloc"); } - else if(strcmp(temp,"choice_list")==0) - thisarg->type=CHOICE_LIST; - else if(strcmp(temp,"choice_menu")==0) - thisarg->type=CHOICE_MENU; - else if(strcmp(temp,"chooser")==0) - thisarg->type=CHOOSER; - else if(strcmp(temp,"slider")==0) - thisarg->type=SLIDER; + else if (strcmp(temp, "choice_list") == 0) + thisarg->type = CHOICE_LIST; + else if (strcmp(temp, "choice_menu") == 0) + thisarg->type = CHOICE_MENU; + else if (strcmp(temp, "chooser") == 0) + thisarg->type = CHOOSER; + else if (strcmp(temp, "slider") == 0) + thisarg->type = SLIDER; else - Error(sprintf(head,"Unknown argtype %s",temp)); + Error( + sprintf(head, "Unknown argtype %s", temp)); } -/* -* argtext: The default text value of the symbol. -* $argument is replaced by this value if it is not -* changed in the dialog box by the user. -*/ - else if(Find(Inline,"argtext:")) - { - crop(Inline,head,temp); - (void)strcpy(thisarg->textvalue,temp); + /* + * argtext: The default text value of the symbol. + * $argument is replaced by this value if it is not + * changed in the dialog box by the user. + */ + else if (Find(Inline, "argtext:")) { + crop(Inline, head, temp); + (void)strcpy(thisarg->textvalue, temp); } -/* -* arglabel: Text label displayed in the dialog box for -* this argument. It should be a discriptive label. -*/ - else if(Find(Inline,"arglabel:")) - { - crop(Inline,head,temp); - thisarg->label=(char*)calloc(strlen(temp)+1, - sizeof(char)); - if(thisarg->label == NULL) - Error("Calloc"); - (void)strcpy(thisarg->label,temp); + /* + * arglabel: Text label displayed in the dialog box for + * this argument. It should be a discriptive + *label. + */ + else if (Find(Inline, "arglabel:")) { + crop(Inline, head, temp); + thisarg->label = + (char *)calloc(strlen(temp) + 1, sizeof(char)); + if (thisarg->label == NULL) Error("Calloc"); + (void)strcpy(thisarg->label, temp); } -/* -* Argument choice values use the following notation: -* -* argchoice:Displayed value:Method -* -* Where "Displayed value" is the label displayed in the dialog box -* and "Method" is the value passed back on the command line. -*/ - else if(Find(Inline,"argchoice:")) - { - crop(Inline,head,temp); - crop(temp,head,tail); + /* + * Argument choice values use the following notation: + * + * argchoice:Displayed value:Method + * + * Where "Displayed value" is the label displayed in the + *dialog box and "Method" is the value passed back on the + *command line. + */ + else if (Find(Inline, "argchoice:")) { + crop(Inline, head, temp); + crop(temp, head, tail); curchoice = thisarg->numchoices++; - if(curchoice == 0) - resize = (char*)calloc(1,sizeof(GargChoice)); + if (curchoice == 0) + resize = (char *)calloc(1, sizeof(GargChoice)); else - resize = realloc(thisarg->choice, - thisarg->numchoices*sizeof(GargChoice)); + resize = realloc( + thisarg->choice, + thisarg->numchoices * sizeof(GargChoice)); - if(resize == NULL) - Error("argchoice: Realloc"); - thisarg->choice = (GargChoice*)resize; + if (resize == NULL) Error("argchoice: Realloc"); + thisarg->choice = (GargChoice *)resize; (thisarg->choice[curchoice].label) = NULL; (thisarg->choice[curchoice].method) = NULL; (thisarg->choice[curchoice].label) = - (char*)calloc(strlen(head)+1,sizeof(char)); + (char *)calloc(strlen(head) + 1, sizeof(char)); (thisarg->choice[curchoice].method) = - (char*)calloc(strlen(tail)+1,sizeof(char)); + (char *)calloc(strlen(tail) + 1, sizeof(char)); - if(thisarg->choice[curchoice].method == NULL || - thisarg->choice[curchoice].label == NULL) + if (thisarg->choice[curchoice].method == NULL || + thisarg->choice[curchoice].label == NULL) Error("Calloc"); - (void)strcpy(thisarg->choice[curchoice].label,head); - (void)strcpy(thisarg->choice[curchoice].method,tail); + (void)strcpy(thisarg->choice[curchoice].label, head); + (void)strcpy(thisarg->choice[curchoice].method, tail); } -/* -* argmin: Minimum value for a slider -*/ - else if(Find(Inline,"argmin:")) - { - crop(Inline,head,temp); - (void)sscanf(temp,"%d",&(thisarg->min)); + /* + * argmin: Minimum value for a slider + */ + else if (Find(Inline, "argmin:")) { + crop(Inline, head, temp); + (void)sscanf(temp, "%d", &(thisarg->min)); } -/* -* argmax: Maximum value for a slider -*/ - else if(Find(Inline,"argmax:")) - { - crop(Inline,head,temp); - (void)sscanf(temp,"%d",&(thisarg->max)); + /* + * argmax: Maximum value for a slider + */ + else if (Find(Inline, "argmax:")) { + crop(Inline, head, temp); + (void)sscanf(temp, "%d", &(thisarg->max)); } -/* -* argmethod: Command line flag associated with this argument. -* Replaces argument in itemmethod description. -*/ - else if(Find(Inline,"argmethod:")) - { - crop(Inline,head,temp); - thisarg->method = (char*)calloc(GBUFSIZ,strlen(temp)); - if(thisarg->method == NULL) - Error("Calloc"); - (void)strcpy(thisarg->method,tail); + /* + * argmethod: Command line flag associated with this + *argument. Replaces argument in itemmethod description. + */ + else if (Find(Inline, "argmethod:")) { + crop(Inline, head, temp); + thisarg->method = (char *)calloc(GBUFSIZ, strlen(temp)); + if (thisarg->method == NULL) Error("Calloc"); + (void)strcpy(thisarg->method, tail); } -/* -* argvalue: default value for a slider -*/ - else if(Find(Inline,"argvalue:")) - { - crop(Inline,head,temp); - if(thisarg->type == TEXT) - strcpy(thisarg->textvalue,temp); + /* + * argvalue: default value for a slider + */ + else if (Find(Inline, "argvalue:")) { + crop(Inline, head, temp); + if (thisarg->type == TEXT) + strcpy(thisarg->textvalue, temp); else - (void)sscanf(temp,"%d",&(thisarg->value)); + (void)sscanf(temp, "%d", &(thisarg->value)); } -/* -* argoptional: Flag specifying that an arguement is optional -*/ - else if(Find(Inline,"argoptional:")) + /* + * argoptional: Flag specifying that an arguement is + *optional + */ + else if (Find(Inline, "argoptional:")) thisarg->optional = TRUE; -/* -* in: Input file description -*/ - else if(Find(Inline,"in:")) - { - crop(Inline,head,temp); + /* + * in: Input file description + */ + else if (Find(Inline, "in:")) { + crop(Inline, head, temp); curinput = (thisitem->numinputs)++; - if(curinput == 0) - resize = (char*)calloc(1,sizeof(GfileFormat)); + if (curinput == 0) + resize = (char *)calloc(1, sizeof(GfileFormat)); else resize = realloc(thisitem->input, - (thisitem->numinputs)*sizeof(GfileFormat)); + (thisitem->numinputs) * + sizeof(GfileFormat)); - if(resize == NULL) - Error("in: Realloc"); - thisitem->input = (GfileFormat*)resize; + if (resize == NULL) Error("in: Realloc"); + thisitem->input = (GfileFormat *)resize; thisinput = &(thisitem->input)[curinput]; thisinput->save = FALSE; thisinput->overwrite = FALSE; @@ -365,202 +342,181 @@ ParseMenu() thisinput->select = SELECTED; } -/* -* out: Output file description -*/ + /* + * out: Output file description + */ - else if(Find(Inline,"out:")) - { - crop(Inline,head,temp); + else if (Find(Inline, "out:")) { + crop(Inline, head, temp); curoutput = (thisitem->numoutputs)++; - if(curoutput == 0) - resize = (char*)calloc(1,sizeof(GfileFormat)); + if (curoutput == 0) + resize = (char *)calloc(1, sizeof(GfileFormat)); else resize = realloc(thisitem->output, - (thisitem->numoutputs)*sizeof(GfileFormat)); + (thisitem->numoutputs) * + sizeof(GfileFormat)); - if(resize == NULL) - Error("out: Realloc"); - thisitem->output = (GfileFormat*)resize; + if (resize == NULL) Error("out: Realloc"); + thisitem->output = (GfileFormat *)resize; thisoutput = &(thisitem->output)[curoutput]; - thisitem->output = (GfileFormat*)resize; + thisitem->output = (GfileFormat *)resize; thisoutput = &(thisitem->output)[curoutput]; - thisoutput->save = FALSE; + thisoutput->save = FALSE; thisoutput->overwrite = FALSE; thisoutput->format = 0; - thisoutput->symbol= String(temp); + thisoutput->symbol = String(temp); thisoutput->name = NULL; } - else if(Find(Inline,"informat:")) - { - if(thisinput == NULL) - Error("Problem with .GDEmenus"); - crop(Inline,head,tail); - if(Find(tail,"genbank")) + else if (Find(Inline, "informat:")) { + if (thisinput == NULL) Error("Problem with .GDEmenus"); + crop(Inline, head, tail); + if (Find(tail, "genbank")) thisinput->format = GENBANK; - else if(Find(tail,"gde")) + else if (Find(tail, "gde")) thisinput->format = GDE; - else if(Find(tail,"na_flat")) + else if (Find(tail, "na_flat")) thisinput->format = NA_FLAT; - else if(Find(tail,"colormask")) + else if (Find(tail, "colormask")) thisinput->format = COLORMASK; - else if(Find(tail,"flat")) + else if (Find(tail, "flat")) thisinput->format = NA_FLAT; - else if(Find(tail,"status")) + else if (Find(tail, "status")) thisinput->format = STATUS_FILE; - else fprintf(stderr,"Warning, unknown file format %s\n" - ,tail); + else + fprintf(stderr, + "Warning, unknown file format %s\n", + tail); } - else if(Find(Inline,"insave:")) - { - if(thisinput == NULL) - Error("Problem with .GDEmenus"); + else if (Find(Inline, "insave:")) { + if (thisinput == NULL) Error("Problem with .GDEmenus"); thisinput->save = TRUE; } - else if(Find(Inline,"inselect:")) - { - if(thisinput == NULL) - Error("Problem with .GDEmenus"); - crop(Inline,head,tail); - if(Find(tail,"one")) - thisinput->select = SELECT_ONE; - else if(Find(tail,"region")) - thisinput->select = SELECT_REGION; - else if(Find(tail,"all")) - thisinput->select = ALL; + else if (Find(Inline, "inselect:")) { + if (thisinput == NULL) Error("Problem with .GDEmenus"); + crop(Inline, head, tail); + if (Find(tail, "one")) + thisinput->select = SELECT_ONE; + else if (Find(tail, "region")) + thisinput->select = SELECT_REGION; + else if (Find(tail, "all")) + thisinput->select = ALL; } - else if(Find(Inline,"inmask:")) - { - if(thisinput == NULL) - Error("Problem with .GDEmenus"); + else if (Find(Inline, "inmask:")) { + if (thisinput == NULL) Error("Problem with .GDEmenus"); thisinput->maskable = TRUE; } - else if(Find(Inline,"outformat:")) - { - if(thisoutput == NULL) - Error("Problem with .GDEmenus"); - crop(Inline,head,tail); - if(Find(tail,"genbank")) - thisoutput->format = GENBANK; - else if(Find(tail,"gde")) + else if (Find(Inline, "outformat:")) { + if (thisoutput == NULL) Error("Problem with .GDEmenus"); + crop(Inline, head, tail); + if (Find(tail, "genbank")) + thisoutput->format = GENBANK; + else if (Find(tail, "gde")) thisoutput->format = GDE; - else if(Find(tail,"na_flat")) + else if (Find(tail, "na_flat")) thisoutput->format = NA_FLAT; - else if(Find(tail,"flat")) + else if (Find(tail, "flat")) thisoutput->format = NA_FLAT; - else if(Find(tail,"status")) + else if (Find(tail, "status")) thisoutput->format = STATUS_FILE; - else if(Find(tail,"colormask")) + else if (Find(tail, "colormask")) thisoutput->format = COLORMASK; - else fprintf(stderr,"Warning, unknown file format %s\n" - ,tail); + else + fprintf(stderr, + "Warning, unknown file format %s\n", + tail); } - else if(Find(Inline,"outsave:")) - { - if(thisoutput == NULL) - Error("Problem with .GDEmenus"); + else if (Find(Inline, "outsave:")) { + if (thisoutput == NULL) Error("Problem with .GDEmenus"); thisoutput->save = TRUE; } - else if(Find(Inline,"outoverwrite:")) - { - if(thisoutput == NULL) - Error("Problem with .GDEmenus"); + else if (Find(Inline, "outoverwrite:")) { + if (thisoutput == NULL) Error("Problem with .GDEmenus"); thisoutput->overwrite = TRUE; } } return; } - - /* Find(): Search the target string for the given key */ -Find(target,key) -char *key,*target; +Find(target, key) char *key, *target; { - int i,j,len1,dif,flag = FALSE; - dif = (strlen(target)) - (len1 = strlen(key)) +1; + int i, j, len1, dif, flag = FALSE; + dif = (strlen(target)) - (len1 = strlen(key)) + 1; - if(len1>0) - for(j=0;j 0) + for (j = 0; j < dif && flag == FALSE; j++) { flag = TRUE; - for(i=0;i0) - for(j=0;j 0) + for (j = 0; j < dif && flag == FALSE; j++) { flag = TRUE; - for(i=0;ioffset;end--); + for (; offset < length && input[offset] == ' '; offset++) + ; + for (end = length - 1; input[end] == ' ' && end > offset; end--) + ; - for(j=0,i=offset;i<=end;i++,j++) - tail[j]=input[i]; + for (j = 0, i = offset; i <= end; i++, j++) tail[j] = input[i]; tail[j] = '\0'; return; }