static char const rcsid [] = "$Id: maps_cont.c,v 1.1 1998/04/22 10:14:16 stojanov Exp $"; /*****************************************************************************/ /* */ /* Unit: MAPS_CONT (Multiple Alignment to PostScript - general control unit) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 15 APR 98 */ /* */ /* Unit contains code for maintenance of the current state of the system */ /* */ /*****************************************************************************/ #include #include #include #include "maps.h" #include "maps_vars.h" /*****************************************************************************/ /* */ /* Local constants definitions for the module */ /* */ /*****************************************************************************/ #define DEFAULT_ALIGNMENT 1 #define DEFAULT_RANGE_SEQUENCE NULL #define DEFAULT_LOW_RANGE 1 #define DEFAULT_HIGH_RANGE 100000 #define DEFAULT_SEQUENCES_PATH NULL #define DEFAULT_DUMP NO_DUMP #define DEFAULT_DESCRIPTION_INCLUSION TRUE #define DEFAULT_PAGE_ORIENTATION PORTRAIT_CODE #define DEFAULT_PORTRAIT_SIZE 684 #define MIN_PORTRAIT_SIZE 360 #define MAX_PORTRAIT_SIZE 760 #define DEFAULT_LANDSCAPE_SIZE 512 #define MIN_LANDSCAPE_SIZE 280 #define MAX_LANDSCAPE_SIZE 580 #define DEFAULT_PORTRAIT_WIDTH 50 #define DEFAULT_LANDSCAPE_WIDTH 100 #define MIN_PAGE_WIDTH 1 #define MAX_PAGE_WIDTH 220 #define DEFAULT_BLOCK_SPACING 2 #define MIN_SPACING 1 #define MAX_SPACING 11 #define DEFAULT_TEXT_FONT_SIZE 10 #define DEFAULT_BANNER_FONT_SIZE 9 #define DEFAULT_TRAILER_FONT_SIZE 9 #define DEFAULT_BANNER_CODE BANNER_CODE #define DEFAULT_BANNER_FONT "Courier-Bold" #define DEFAULT_TEXT_LAYOUT VERBATIM_CODE #define DEFAULT_TEXT_PIVOT 1 #define DEFAULT_PIVOT_SEQUENCE DEFAULT_PRINCIPAL_SEQUENCE #define DEFAULT_TRAILER_CODE TRAILER_CODE #define DEFAULT_TRAILER_FONT "Times-Bold" #define DEFAULT_START_CODE ENTIRE_SEQUENCE_CODE #define DEFAULT_END_CODE ENTIRE_SEQUENCE_CODE #define DEFAULT_ADJUSTMENT 0 #define DEFAULT_OUTPUT_FORMAT TEXT_OUTPUT #define DEFAULT_OUTPUT_DIRECTION STDOUT_CODE #define DEFAULT_OUTPUT_FILE NULL #define DEFAULT_ORIGIN_FROM_RANGE -2000 #define MAXIMAL_ORIGIN_FROM_RANGE -99999 #define MINIMAL_ORIGIN_FROM_RANGE -1 #define DEFAULT_ORIGIN_TO_RANGE 2000 #define MAXIMAL_ORIGIN_TO_RANGE 99999 #define MINIMAL_ORIGIN_TO_RANGE 1 #define DEFAULT_LABEL_FONT "Helvetica" #define DEFAULT_LABEL_FONT_SIZE 8 #define MIN_LABEL_FONT_SIZE 2 #define MAX_LABEL_FONT_SIZE 16 #define DEFAULT_LANDMARK_LABEL "" #define DEFAULT_LANDMARK_LABEL_PLACE TOP_PLACE #define DEFAULT_LANDMARK_LABEL_POSITION CENTERED_POSITION #define DEFAULT_BOX_LABEL "" #define DEFAULT_BOX_LABEL_PLACE TOP_PLACE #define DEFAULT_BOX_LABEL_POSITION CENTERED_POSITION #define DEFAULT_UNDERLINE_LABEL "" #define DEFAULT_UNDERLINE_LABEL_PLACE TOP_PLACE #define DEFAULT_UNDERLINE_LABEL_POSITION CENTERED_POSITION #define DEFAULT_INFORMATION_INCLUSION FALSE #define DEFAULT_LANDMARK_MARK UNDERLINE_CODE #define DEFAULT_LANDMARK_MARK_SEQUENCE NULL #define DEFAULT_LANDMARK_MULTIPLE SINGLE_UNDERLINE #define DEFAULT_LANDMARK_MARK_STYLE NULL #define DEFAULT_BOX_STYLE NULL #define DEFAULT_UNDERLINE_KIND SINGLE_UNDERLINE #define DEFAULT_UNDERLINE_STYLE NULL #define MINIMAL_BOX_WIDTH 1 #define MAXIMAL_BOX_WIDTH 3000 #define MINIMAL_UNDERLINE_WIDTH 1 #define MAXIMAL_UNDERLINE_WIDTH 5000 #define DEFAULT_DESC_LINE_NUMBER ALL_LINES_CODE #define DEFAULT_LINE_CONTENTS NO_CONTENTS #define MIN_TICK_DISTANCE 1 #define MAX_TICK_DISTANCE 1000 #define MINIMAL_TEXT_REPEAT 1 #define CONT_EXEC_ERROR -1 #define CONT_GENERAL_ERROR -2 #define DEFAULT_ANNOTATION_MARK BOX_CODE #define DEFAULT_ANNOTATION_COUNTER UNDEFINED #define DEFAULT_ANNOTATION_MULTIPLE DOUBLE_UNDERLINE #define DEFAULT_ANNOTATION_MARK_STYLE NULL #define DEFAULT_ANNOTATION_BOX_STYLE NULL #define DEFAULT_ANNOTATION_UNDERLINE_STYLE NULL #define DEFAULT_ANNOTATION_MARK_SHADE FALSE #define DEFAULT_ANNOTATION_MARK_INTENSITY 0.0 #define DEFAULT_ANNOTATION_BOX_SHADE FALSE #define DEFAULT_ANNOTATION_BOX_INTENSITY 0.0 #define DEFAULT_ANNOTATION_LABEL_TEXT NULL #define DEFAULT_ANNOTATION_TEXT_FONT "Helvetica" #define DEFAULT_ANNOTATION_TEXT_FONT_SIZE 8 #define DEFAULT_ANNOTATION_LABEL_FIELD UNDEFINED #define DEFAULT_ANNOTATION_FIELD_FONT "Courier" #define DEFAULT_ANNOTATION_FIELD_FONT_SIZE 8 #define DEFAULT_ANNOTATION_PLACE TOP_PLACE #define DEFAULT_ANNOTATION_POSITION CENTERED_POSITION /*****************************************************************************/ /* */ /* Local type definitions for the module */ /* */ /*****************************************************************************/ /* Raw data about the landmarks to be associated with the alignment is kept */ /* in the internal (temporary) list of records, before their expansion */ typedef struct landlog_fields { int kind; char *file_name; char *sequence; char *origin; long int start; long int stop; int mark_kind; int mark_multiple; char *mark_sequence; char *mark_style; bool mark_shade; float mark_intensity; label_ptr label; int label_place; int label_position; char *label_font; int font_size; struct landlog_fields *next; } LandLog_Struct; typedef LandLog_Struct *landlog_ptr; typedef struct plainlog_fields { char *file_name; int counter; int mark_kind; int mark_multiple; char *mark_style; bool mark_shade; float mark_intensity; char *text; char *text_font; int text_size; int field; char *field_font; int field_size; int place; int position; struct plainlog_fields *next; } PlainLog_Struct; typedef PlainLog_Struct *plainlog_ptr; /* Data about the origins associated with the alignment are kept in a list */ /* of records before their expansion */ typedef struct originlog_fields { int source; char *file_name; char *name; long int position; char *sequence; long int from; long int to; struct originlog_fields *next; } OriginLog_Struct; typedef OriginLog_Struct *originlog_ptr; typedef struct boxlog_fields { char *sequence; char *origin; long int start; long int stop; label_ptr label; int label_place; int label_position; char *style; bool shade; float intensity; struct boxlog_fields *next; } BoxLog_Struct; typedef BoxLog_Struct *boxlog_ptr; typedef struct underlog_fields { int kind; char *sequence; char *origin; long int start; long int stop; char *style; label_ptr label; int label_place; int label_position; struct underlog_fields *next; } UnderLog_Struct; typedef UnderLog_Struct *underlog_ptr; typedef struct desclog_fields { int kind; int number; int contents; int tick_distance; char *inline_text; int text_repeat; struct desclog_fields *next; } DescLog_Struct; typedef DescLog_Struct *desclog_ptr; typedef struct textlog_fields { int number; bool disabled; int banner; char *banner_font; int banner_font_size; long int adjustment; int layout; int pivot; char *pivot_sequence; int trailer; char *trailer_font; int trailer_font_size; int started; int ended; struct textlog_fields *next; } TextLog_Struct; typedef TextLog_Struct *textlog_ptr; /*****************************************************************************/ /* */ /* Unit variables and internal data structures (control settings) */ /* */ /*****************************************************************************/ static bool file_locked; /* Is alignment file name provided in command line? */ static bool alignment_locked; static bool information_locked; static bool output_locked; static bool warnings_supressed; static char *alignment_file; static char *sequences_path; static strlist_ptr seq_aliases; static int alignment_number; static char *range_sequence; static long int range_start; static long int range_stop; static landlog_ptr landmark_templates; static plainlog_ptr annotation_templates; static originlog_ptr origin_templates; static boxlog_ptr boxes; static underlog_ptr underlines; static desclog_ptr top_templates; static desclog_ptr intermediate_templates; static desclog_ptr bottom_templates; static textlog_ptr text_templates; static label_ptr default_landmark_label; static label_ptr default_box_label; static label_ptr default_underline_label; static bool error_in_control; /*****************************************************************************/ /* */ /* Forward declarations of unit internal procedures - not visible from out. */ /* */ /*****************************************************************************/ void CONT_Supplementary_Definition (int line_kind, int line_number, int line_contents, int tick_distance, char *inline_text, int text_repeat); void CONT_Text_Definition (int line_number, bool seq_disabled, int banner, char *banner_font, int banner_font_size, long int adjustment, int text_layout, int pivot, char *pivot_seq, int trailer, char *trailer_font, int trailer_font_size, int start_code, int end_code); int CONT_Check_Landmarks (void); int CONT_Check_Annotations (void); int CONT_Check_Origins (void); int CONT_Check_Boxes (void); int CONT_Check_Underlines (void); int CONT_Check_Lines (void); int CONT_Expand (void); seqover_ptr CONT_Release_SeqOver (seqover_ptr list); /*****************************************************************************/ /* */ /* Begin code section */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* */ /* Procedure: CONT_Initialize */ /* */ /* Initialization of all structures of the control unit */ int CONT_Initialize (char *cl_file, bool cl_align_lock, int cl_align, bool cl_range_lock, long int cl_start, long int cl_stop, char *cl_range_seq, strlist_ptr cl_paths, char *requested_principal, strlist_ptr cl_landmarks, strlist_ptr cl_plains, strlist_ptr cl_origins, bool cl_info_lock, bool cl_info, bool cl_output_lock, int cl_output, bool cl_warnings) { strlist_ptr list_scan, old_scan; if (VARS_Initialize () < 0) { /* Initialize all global variables */ CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't initialize the program", NULL, UNDEFINED, NULL, 0, FALSE); } /* Set up the global parameters, with respect to command line settings */ error_in_control = FALSE; description_include = DEFAULT_DESCRIPTION_INCLUSION; page_orientation = DEFAULT_PAGE_ORIENTATION; if (page_orientation == PORTRAIT_CODE) page_size = DEFAULT_PORTRAIT_SIZE; else page_size = DEFAULT_LANDSCAPE_SIZE; if (page_orientation == PORTRAIT_CODE) page_width = DEFAULT_PORTRAIT_WIDTH; else page_width = DEFAULT_LANDSCAPE_WIDTH; block_spacing = DEFAULT_BLOCK_SPACING; text_font_size = DEFAULT_TEXT_FONT_SIZE; if (requested_principal == NULL) principal_sequence = NTL0_strsave (DEFAULT_PRINCIPAL_SEQUENCE); else principal_sequence = requested_principal; if (cl_info_lock) { information_locked = TRUE; information_include = cl_info; } else { information_locked = FALSE; information_include = DEFAULT_INFORMATION_INCLUSION; } information_kind = DEFAULT_STRICTNESS_CODE; if (cl_file == NULL) { file_locked = FALSE; alignment_file = NULL; } else { file_locked = TRUE; alignment_file = cl_file; } if (cl_align_lock) { alignment_locked = TRUE; alignment_number = cl_align; } else { alignment_locked = FALSE; alignment_number = DEFAULT_ALIGNMENT; } if (cl_range_lock) { range_start = cl_start; range_stop = cl_stop; if (cl_range_seq != NULL) range_sequence = cl_range_seq; else range_sequence = NTL0_strsave (principal_sequence); } else { range_sequence = NTL0_strsave (DEFAULT_RANGE_SEQUENCE); range_start = DEFAULT_LOW_RANGE; range_stop = DEFAULT_HIGH_RANGE; } if (cl_output_lock) { output_locked = TRUE; output_format = cl_output; } else { output_locked = FALSE; output_format = DEFAULT_OUTPUT_FORMAT; } warnings_supressed = cl_warnings; registered_paths = cl_paths; sequences_path = NTL0_strsave (DEFAULT_SEQUENCES_PATH); seq_aliases = NULL; /* Proceed to initialize the contents of all internal request holding strs */ landmark_templates = NULL; /* No predefined landmarks */ annotation_templates = NULL; /* No predefined annotations */ origin_templates = NULL; /* No predefined origins */ /* If there are any landmark files from the command line, add them here */ list_scan = cl_landmarks; while (list_scan != NULL) { CONT_Landmark_Definition (BULK_LANDMARK, list_scan -> string, NULL, NULL, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, NULL, NULL, (float) UNDEFINED, NULL, UNDEFINED, UNDEFINED, NULL, UNDEFINED); old_scan = list_scan; list_scan = list_scan -> next; old_scan -> string = NULL; if (old_scan -> string != NULL) free (old_scan -> string); free (old_scan); } /* If there are any plain format files from the command line, add them here */ list_scan = cl_plains; while (list_scan != NULL) { CONT_Annotations_Command (list_scan -> string, UNDEFINED, UNDEFINED, UNDEFINED, NULL, (float) UNDEFINED, NULL, NULL, UNDEFINED, UNDEFINED, NULL, UNDEFINED, UNDEFINED, UNDEFINED); old_scan = list_scan; list_scan = list_scan -> next; old_scan -> string = NULL; if (old_scan -> string != NULL) free (old_scan -> string); free (old_scan); } /* If there are any origin files from the command line, add them here */ list_scan = cl_origins; while (list_scan != NULL) { CONT_Origin_Definition (FILED_ORIGINS, list_scan -> string, NULL, UNDEFINED, NULL, UNDEFINED, UNDEFINED); old_scan = list_scan; list_scan = list_scan -> next; old_scan -> string = NULL; if (old_scan -> string != NULL) free (old_scan -> string); free (old_scan); } boxes = NULL; /* No boxes placed by default */ underlines = NULL; /* No underlines placed by default */ top_templates = (desclog_ptr) NTL0_ckalloc (sizeof (DescLog_Struct)); top_templates -> kind = TOP_LINE; top_templates -> number = ALL_LINES_CODE; top_templates -> contents = NO_CONTENTS; top_templates -> tick_distance = UNDEFINED; top_templates -> inline_text = NULL; top_templates -> text_repeat = UNDEFINED; top_templates -> next = NULL; intermediate_templates = (desclog_ptr) NTL0_ckalloc (sizeof (DescLog_Struct)); intermediate_templates -> kind = INTERMEDIATE_LINE; intermediate_templates -> number = ALL_LINES_CODE; intermediate_templates -> contents = NO_CONTENTS; intermediate_templates -> tick_distance = UNDEFINED; intermediate_templates -> inline_text = NULL; intermediate_templates -> text_repeat = UNDEFINED; intermediate_templates -> next = NULL; bottom_templates = (desclog_ptr) NTL0_ckalloc (sizeof (DescLog_Struct)); bottom_templates -> kind = BOTTOM_LINE; bottom_templates -> number = ALL_LINES_CODE; bottom_templates -> contents = NO_CONTENTS; bottom_templates -> tick_distance = UNDEFINED; bottom_templates -> inline_text = NULL; bottom_templates -> text_repeat = UNDEFINED; bottom_templates -> next = NULL; text_templates = (textlog_ptr) NTL0_ckalloc (sizeof (TextLog_Struct)); text_templates -> number = ALL_LINES_CODE; text_templates -> disabled = FALSE; text_templates -> banner = DEFAULT_BANNER_CODE; text_templates -> banner_font = NTL0_strsave (DEFAULT_BANNER_FONT); text_templates -> banner_font_size = DEFAULT_BANNER_FONT_SIZE; text_templates -> layout = DEFAULT_TEXT_LAYOUT; text_templates -> pivot = DEFAULT_TEXT_PIVOT; text_templates -> pivot_sequence = NTL0_strsave (DEFAULT_PIVOT_SEQUENCE); text_templates -> trailer = DEFAULT_TRAILER_CODE; text_templates -> trailer_font = NTL0_strsave (DEFAULT_TRAILER_FONT); text_templates -> trailer_font_size = DEFAULT_TRAILER_FONT_SIZE; text_templates -> started = DEFAULT_START_CODE; text_templates -> ended = DEFAULT_END_CODE; text_templates -> next = NULL; default_landmark_label = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); default_landmark_label -> text = NTL0_strsave (DEFAULT_LANDMARK_LABEL); default_landmark_label -> font_name = NTL0_strsave (DEFAULT_LABEL_FONT); default_landmark_label -> font_size = DEFAULT_LABEL_FONT_SIZE; default_landmark_label -> next = NULL; default_box_label = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); default_box_label -> text = NTL0_strsave (DEFAULT_BOX_LABEL); default_box_label -> font_name = NTL0_strsave (DEFAULT_LABEL_FONT); default_box_label -> font_size = DEFAULT_LABEL_FONT_SIZE; default_box_label -> next = NULL; default_underline_label = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); default_underline_label -> text = NTL0_strsave (DEFAULT_UNDERLINE_LABEL); default_underline_label -> font_name = NTL0_strsave (DEFAULT_LABEL_FONT); default_underline_label -> font_size = DEFAULT_LABEL_FONT_SIZE; default_underline_label -> next = NULL; if (LOAD_Initialize () < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't initialize the program", NULL, UNDEFINED, NULL, 0, FALSE); } /* ### Add the invocation of other module's initialization routines here ## */ return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Load_Command */ /* */ /* Action routine for the support of the load command of the specification */ void CONT_Load_Command (char *file_name, char *seq_path, strlist_ptr aliases, int alignment, char *range_seq, long int start_range, long int stop_range) { char *rep_string; strlist_ptr next_alias, alias_scan; if (file_name != NULL) { /* Alignment file provided */ if (file_locked) { rep_string = (char *) NTL0_ckalloc (44 + strlen (file_name)); sprintf (rep_string, "Can't load file '%s' - file loading blocked", file_name); CONT_Warning (rep_string); free (rep_string); } else { /* Loading new files permitted */ if (alignment_file != NULL) { rep_string = (char *) NTL0_ckalloc (36 + strlen (alignment_file) + strlen (file_name)); sprintf (rep_string, "Replacing alignment file '%s' with '%s'", alignment_file, file_name); CONT_Warning (rep_string); free (rep_string); free (alignment_file); if (sequences_path != NULL) free (sequences_path); if (seq_aliases != NULL) UTIL_Release_StrList (seq_aliases); if (alignment_locked) { rep_string = (char *) NTL0_ckalloc (48 + strlen (file_name)); sprintf (rep_string, "Loading new file '%s', alignment settings locked", file_name); CONT_Warning (rep_string); free (rep_string); } else { /* Alignment not blocked, so reset settings to default */ alignment_number = DEFAULT_ALIGNMENT; if (range_sequence != NULL) free (range_sequence); range_sequence = NTL0_strsave (DEFAULT_RANGE_SEQUENCE); range_start = DEFAULT_LOW_RANGE; range_stop = DEFAULT_HIGH_RANGE; } } else { /* There was no pre-set file name */ if (alignment_number != DEFAULT_ALIGNMENT) { /* Was there a pre-set al? */ rep_string = (char *) NTL0_ckalloc ((50 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Alignment number %d set before file '%s'", alignment_number, file_name); CONT_Warning (rep_string); free (rep_string); } } alignment_file = file_name; if (sequences_path != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal path setting", NULL, UNDEFINED, NULL, 0, TRUE); sequences_path = seq_path; if (seq_aliases != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal aliases setting", NULL, UNDEFINED, NULL, 0, TRUE); /* Check for duplicate names provided in the list of the aliases, if any */ for (alias_scan = aliases; alias_scan != NULL; alias_scan = alias_scan -> next) { next_alias = alias_scan -> next; while (next_alias != NULL) { if (!strcmp (alias_scan -> string, next_alias -> string)) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Repeated alias '", alias_scan -> string, UNDEFINED, "' for the alignment file", 0, TRUE); } next_alias = next_alias -> next; } } seq_aliases = aliases; } } /* Proceed to handle the alignment (optional) part of the input parameters */ if (alignment != UNDEFINED) { if (alignment_locked) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Can't set specification alignment - alignment number locked"); CONT_Warning (rep_string); free (rep_string); } else { /* Specification of alignment(s) to load permitted */ if (alignment_number != DEFAULT_ALIGNMENT) { rep_string = (char *) NTL0_ckalloc (39 * sizeof (char)); sprintf (rep_string, "Replacing the alignment already set"); CONT_Warning (rep_string); free (rep_string); } if (range_sequence != NULL) free (range_sequence); alignment_number = alignment; range_sequence = range_seq; range_start = start_range; range_stop = stop_range; } } } /*****************************************************************************/ /* */ /* Procedure: CONT_Landmark_Definition */ /* */ /* Action routine to handle a new landmark(s) request */ void CONT_Landmark_Definition (int landmark_kind, char *file_name, char *landmark_seq, char *origin, long int start, long int stop, int mark_kind, int underline_mult, char *mark_seq, char *mark_style, float mark_shade, label_ptr label, int place, int position, char *font, int font_size) { landlog_ptr new_landmark, landmark_scan; label_ptr label_scan; char *rep_string; /* If the landmark is a file loading request, check whether the file name */ /* is duplicated with respect to some previous request */ if (file_name != NULL) { if (landmark_kind != BULK_LANDMARK) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal specification of landmark source file", NULL, UNDEFINED, NULL, 0, TRUE); } landmark_scan = landmark_templates; while (landmark_scan != NULL) { if (landmark_scan -> kind == BULK_LANDMARK) { /* If also file request */ if (!strcmp (file_name, landmark_scan -> file_name)) { rep_string = (char *) NTL0_ckalloc ((32 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Duplicated landmarks file '%s'", file_name); CONT_Warning (rep_string); free (rep_string); } } landmark_scan = landmark_scan -> next; } } /* Allocate and fill the definition record for the new landmark */ new_landmark = (landlog_ptr) NTL0_ckalloc (sizeof (LandLog_Struct)); new_landmark -> kind = landmark_kind; if (landmark_kind == SINGLE_LANDMARK) { if (file_name != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "File (", file_name, UNDEFINED, ") specified with single landmark", 12, TRUE); } new_landmark -> file_name = NULL; /* No files for "single" landmarks */ if (landmark_seq == NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Landmark sequence must be provided", NULL, UNDEFINED, NULL, 13, TRUE); new_landmark -> sequence = landmark_seq; if (origin == NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Landmark origin must be provided", NULL, UNDEFINED, NULL, 14, TRUE); new_landmark -> origin = origin; new_landmark -> start = start; new_landmark -> stop = stop; if (mark_kind == UNDEFINED) { /* No mark specified - set to defaults */ new_landmark -> mark_kind = DEFAULT_LANDMARK_MARK; if (mark_seq != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Landmark mark sequence '", mark_seq, UNDEFINED, "' provided for no mark", 0, TRUE); new_landmark -> mark_sequence = NTL0_strsave (landmark_seq); if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for no mark", NULL, UNDEFINED, NULL, 15, TRUE); new_landmark -> mark_multiple = DEFAULT_LANDMARK_MULTIPLE; } else if (mark_kind == BOX_CODE) { new_landmark -> mark_kind = mark_kind; if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for box mark", NULL, UNDEFINED, NULL, 16, TRUE); new_landmark -> mark_multiple = UNDEFINED; if (mark_seq != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Mark sequence provided for box mark request", NULL, UNDEFINED, NULL, 40, TRUE); else new_landmark -> mark_sequence = NULL; } else { /* Must be an underline mark then */ new_landmark -> mark_kind = mark_kind; if (underline_mult == UNDEFINED) new_landmark -> mark_multiple = DEFAULT_LANDMARK_MULTIPLE; else new_landmark -> mark_multiple = underline_mult; if (mark_seq == NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Mark sequence not specified for an underline mark", NULL, UNDEFINED, NULL, 39, TRUE); else new_landmark -> mark_sequence = mark_seq; } if (mark_style == NULL) new_landmark -> mark_style = NTL0_strsave (DEFAULT_LANDMARK_MARK_STYLE); else new_landmark -> mark_style = mark_style; if ((mark_shade < (float) UNDEFINED - EPSILON) || (mark_shade > (float) UNDEFINED + EPSILON)) { if (new_landmark -> mark_kind != BOX_CODE) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal shading request", NULL, UNDEFINED, NULL, 0, TRUE); } else { new_landmark -> mark_shade = TRUE; new_landmark -> mark_intensity = mark_shade; } } else { new_landmark -> mark_shade = FALSE; new_landmark -> mark_intensity = (float) UNDEFINED; } if (label == NULL) { /* No label specified - set to default */ new_landmark -> label = NTL1_Copy_Label (default_landmark_label); if ((place != UNDEFINED) || (position != UNDEFINED)) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label_details provided for unexisting label", NULL, UNDEFINED, NULL, 18, TRUE); } new_landmark -> label_place = DEFAULT_LANDMARK_LABEL_PLACE; new_landmark -> label_position = DEFAULT_LANDMARK_LABEL_POSITION; if (font != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Font (", font, UNDEFINED, ") specified with no label", 19, TRUE); } new_landmark -> label_font = NTL0_strsave (DEFAULT_LABEL_FONT); if (font_size != UNDEFINED) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Font size (", NULL, (long int) font_size, ") specified with no label", 20, TRUE); } new_landmark -> font_size = DEFAULT_LABEL_FONT_SIZE; } else { /* Some kind of label has been specified */ label_scan = label; while (label_scan != NULL) { if (label_scan -> font_name == NULL) label_scan -> font_name = NTL0_strsave (DEFAULT_LABEL_FONT); if (label_scan -> font_size == UNDEFINED) label_scan -> font_size = DEFAULT_LABEL_FONT_SIZE; label_scan = label_scan -> next; } new_landmark -> label = label; if (place == UNDEFINED) /* No place provided - set to default */ new_landmark -> label_place = DEFAULT_LANDMARK_LABEL_PLACE; else new_landmark -> label_place = place; if (position == UNDEFINED) /* No position provided - set to default */ new_landmark -> label_position = DEFAULT_LANDMARK_LABEL_POSITION; else new_landmark -> label_position = position; if ((label != NULL) && (font != NULL)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Font (", font, UNDEFINED, ") specified for explicit label", 42, TRUE); else if ((label != NULL) && (font_size != UNDEFINED)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Font size provided for explicit label", NULL, UNDEFINED, NULL, 43, TRUE); } } else { /* Landmarks to be loaded from a file */ if (file_name == NULL) { /* Error in the parsing code - must have this */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "File not specified for loading landmarks", NULL, UNDEFINED, NULL, 22, TRUE); } new_landmark -> file_name = file_name; if (landmark_seq != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Sequence (", landmark_seq, UNDEFINED, ") illegaly provided for loaded landmarks", 24, TRUE); } new_landmark -> sequence = NULL; if (origin != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Origin (", origin, UNDEFINED, ") illegally provided for loaded landmarks", 25, TRUE); } new_landmark -> origin = NULL; if ((start != UNDEFINED) || (stop != UNDEFINED)) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Landmark boundaries provided for loaded landmarks", NULL, UNDEFINED, NULL, 26, TRUE); } new_landmark -> start = UNDEFINED; new_landmark -> stop = UNDEFINED; if (mark_kind == UNDEFINED) { /* Marking not specified - set default */ new_landmark -> mark_kind = DEFAULT_LANDMARK_MARK; if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_landmark -> mark_multiple = DEFAULT_LANDMARK_MULTIPLE; } else if (mark_kind == BOX_CODE) { new_landmark -> mark_kind = mark_kind; if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for box mark", NULL, UNDEFINED, NULL, 29, TRUE); new_landmark -> mark_multiple = UNDEFINED; } else { /* So the requested marking must be "underline" */ new_landmark -> mark_kind = mark_kind; if (underline_mult == UNDEFINED) /* Value not specified - set default */ new_landmark -> mark_multiple = DEFAULT_LANDMARK_MULTIPLE; else new_landmark -> mark_multiple = underline_mult; } if (mark_seq == NULL) /* Sequence to underline not set - use default */ new_landmark -> mark_sequence = NTL0_strsave (DEFAULT_LANDMARK_MARK_SEQUENCE); else new_landmark -> mark_sequence = mark_seq; if (mark_style == NULL) new_landmark -> mark_style = NTL0_strsave (DEFAULT_LANDMARK_MARK_STYLE); else new_landmark -> mark_style = mark_style; if ((mark_shade < (float) UNDEFINED - EPSILON) || (mark_shade > (float) UNDEFINED + EPSILON)) { if (new_landmark -> mark_kind != BOX_CODE) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal shading request", NULL, UNDEFINED, NULL, 0, TRUE); } else { new_landmark -> mark_shade = TRUE; new_landmark -> mark_intensity = mark_shade; } } else { new_landmark -> mark_shade = FALSE; new_landmark -> mark_intensity = (float) UNDEFINED; } if (label != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label provided for loaded landmarks", NULL, UNDEFINED, NULL, 31, TRUE); label = NTL1_Destroy_Label (label); } new_landmark -> label = NULL; if ((place != UNDEFINED) || (position != UNDEFINED)) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label_details provided for unexisting label", NULL, UNDEFINED, NULL, 32, TRUE); } new_landmark -> label_place = UNDEFINED; new_landmark -> label_position = UNDEFINED; /* Set the values of the font name and size to replace possibly undefined */ /* fields within the loaded landmark label records */ if (font == NULL) new_landmark -> label_font = NTL0_strsave (DEFAULT_LABEL_FONT); else new_landmark -> label_font = font; if (font_size == UNDEFINED) new_landmark -> font_size = DEFAULT_LABEL_FONT_SIZE; else new_landmark -> font_size = font_size; } new_landmark -> next = landmark_templates; landmark_templates = new_landmark; } /*****************************************************************************/ /* */ /* Procedure: CONT_Annotations_Command */ /* */ /* Action routine to handle a new annotations request */ void CONT_Annotations_Command (char *file_name, int counter, int mark_kind, int underline_mult, char *mark_style, float mark_shade, char *text, char *text_font, int text_size, int field, char *field_font, int field_size, int place, int position) { plainlog_ptr new_annotation, annot_scan; char *rep_string; /* Check whether the file name is duplicated with respect to some previous */ if (file_name == NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Missing file name for plain landmark annotations", NULL, UNDEFINED, NULL, 0, TRUE); } else { annot_scan = annotation_templates; while (annot_scan != NULL) { if (!strcmp (file_name, annot_scan -> file_name)) { rep_string = (char *) NTL0_ckalloc ((60 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Duplicated plain annotations file '%s'", file_name); CONT_Warning (rep_string); free (rep_string); } annot_scan = annot_scan -> next; } } /* Allocate and fill the definition record for the new plain annotation */ new_annotation = (plainlog_ptr) NTL0_ckalloc (sizeof (PlainLog_Struct)); new_annotation -> file_name = file_name; if (counter != UNDEFINED) { if (counter < 0) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Bad counter sequence number", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> counter = DEFAULT_ANNOTATION_COUNTER; } else new_annotation -> counter = counter; } else new_annotation -> counter = DEFAULT_ANNOTATION_COUNTER; if (mark_kind == UNDEFINED) { /* Marking not specified - set default */ new_annotation -> mark_kind = DEFAULT_ANNOTATION_MARK; if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> mark_multiple = DEFAULT_ANNOTATION_MULTIPLE; if (mark_style != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Mark style for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> mark_style = NTL0_strsave (DEFAULT_ANNOTATION_MARK_STYLE); if ((mark_shade < (float) UNDEFINED - EPSILON) || (mark_shade > (float) UNDEFINED + EPSILON)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Mark shade for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> mark_shade = DEFAULT_ANNOTATION_MARK_SHADE; new_annotation -> mark_intensity = DEFAULT_ANNOTATION_MARK_INTENSITY; if (text != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label text for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> text = NTL0_strsave (DEFAULT_ANNOTATION_LABEL_TEXT); if (text_font != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label text font for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> text_font = NTL0_strsave (DEFAULT_ANNOTATION_TEXT_FONT); if (text_size != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label text font size for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> text_size = DEFAULT_ANNOTATION_TEXT_FONT_SIZE; if (field != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label field for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> field = DEFAULT_ANNOTATION_LABEL_FIELD; if (field_font != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label field font for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> field_font = NTL0_strsave (DEFAULT_ANNOTATION_FIELD_FONT); if (field_size != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label field font size for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> field_size = DEFAULT_ANNOTATION_FIELD_FONT_SIZE; if (place != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label place for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> place = DEFAULT_ANNOTATION_PLACE; if (position != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label position for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> position = DEFAULT_ANNOTATION_POSITION; } else { new_annotation -> mark_kind = mark_kind; if (mark_kind == BOX_CODE) { if (underline_mult != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Multiple underline for box mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> mark_multiple = UNDEFINED; if (mark_style != NULL) new_annotation -> mark_style = mark_style; else new_annotation -> mark_style = NTL0_strsave (DEFAULT_ANNOTATION_BOX_STYLE); if ((mark_shade < (float) UNDEFINED - EPSILON) || (mark_shade > (float) UNDEFINED + EPSILON)) { new_annotation -> mark_shade = TRUE; new_annotation -> mark_intensity = mark_shade; } else { new_annotation -> mark_shade = DEFAULT_ANNOTATION_BOX_SHADE; new_annotation -> mark_intensity = DEFAULT_ANNOTATION_BOX_INTENSITY; } } else if (mark_kind == UNDERLINE_CODE) { if (underline_mult != UNDEFINED) new_annotation -> mark_multiple = underline_mult; else new_annotation -> mark_multiple = DEFAULT_ANNOTATION_MULTIPLE; if (mark_style != NULL) new_annotation -> mark_style = mark_style; else new_annotation -> mark_style = NTL0_strsave (DEFAULT_ANNOTATION_UNDERLINE_STYLE); if ((mark_shade < (float) UNDEFINED - EPSILON) || (mark_shade > (float) UNDEFINED + EPSILON)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Shade specified for underline mark", NULL, UNDEFINED, NULL, 28, TRUE); else { new_annotation -> mark_shade = FALSE; new_annotation -> mark_intensity = (float) UNDEFINED; } } else { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Unknown annotation mark code", NULL, UNDEFINED, NULL, 28, TRUE); } if (text != NULL) { new_annotation -> text = text; if (text_font != NULL) new_annotation -> text_font = text_font; else new_annotation -> text_font = NTL0_strsave (DEFAULT_ANNOTATION_TEXT_FONT); if (text_size != UNDEFINED) { if (text_size < MIN_LABEL_FONT_SIZE) { rep_string = (char *) NTL0_ckalloc (80 * sizeof (char)); sprintf (rep_string, "Requested label font size (%d) too small - set to minimum (%d)", text_size, MIN_LABEL_FONT_SIZE); CONT_Warning (rep_string); free (rep_string); new_annotation -> text_size = MIN_LABEL_FONT_SIZE; } else if (text_size > MAX_LABEL_FONT_SIZE) { rep_string = (char *) NTL0_ckalloc (80 * sizeof (char)); sprintf (rep_string, "Requested label font size (%d) too large - set to maximum (%d)", text_size, MAX_LABEL_FONT_SIZE); CONT_Warning (rep_string); free (rep_string); new_annotation -> text_size = MAX_LABEL_FONT_SIZE; } else new_annotation -> text_size = text_size; } else new_annotation -> text_size = DEFAULT_ANNOTATION_TEXT_FONT_SIZE; } else { new_annotation -> text = NTL0_strsave (DEFAULT_ANNOTATION_LABEL_TEXT); if (text_font != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label text font for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> text_font = NTL0_strsave (DEFAULT_ANNOTATION_TEXT_FONT); if (text_size != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label text font size for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> text_size = DEFAULT_ANNOTATION_TEXT_FONT_SIZE; } if (field != NULL) { new_annotation -> field = field; if (field_font != NULL) new_annotation -> field_font = field_font; else new_annotation -> field_font = NTL0_strsave (DEFAULT_ANNOTATION_FIELD_FONT); if (field_size != UNDEFINED) { if (field_size < MIN_LABEL_FONT_SIZE) { rep_string = (char *) NTL0_ckalloc (80 * sizeof (char)); sprintf (rep_string, "Requested label font size (%d) too small - set to minimum (%d)", field_size, MIN_LABEL_FONT_SIZE); CONT_Warning (rep_string); free (rep_string); new_annotation -> field_size = MIN_LABEL_FONT_SIZE; } else if (field_size > MAX_LABEL_FONT_SIZE) { rep_string = (char *) NTL0_ckalloc (80 * sizeof (char)); sprintf (rep_string, "Requested label font size (%d) too large - set to maximum (%d)", field_size, MAX_LABEL_FONT_SIZE); CONT_Warning (rep_string); free (rep_string); new_annotation -> field_size = MAX_LABEL_FONT_SIZE; } else new_annotation -> field_size = field_size; } else new_annotation -> field_size = DEFAULT_ANNOTATION_FIELD_FONT_SIZE; } else { new_annotation -> field = DEFAULT_ANNOTATION_LABEL_FIELD; if (field_font != NULL) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label field font for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> field_font = NTL0_strsave (DEFAULT_ANNOTATION_FIELD_FONT); if (field_size != UNDEFINED) /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Label field font size for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> field_size = DEFAULT_ANNOTATION_FIELD_FONT_SIZE; } if ((text == NULL) && (field == UNDEFINED)) { if (place != UNDEFINED) CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Label place for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> place = DEFAULT_ANNOTATION_PLACE; if (position != UNDEFINED) CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Label position for no mark", NULL, UNDEFINED, NULL, 28, TRUE); new_annotation -> position = DEFAULT_ANNOTATION_POSITION; } else { if (place != UNDEFINED) new_annotation -> place = place; else new_annotation -> place = DEFAULT_ANNOTATION_PLACE; if (position != UNDEFINED) new_annotation -> position = position; else new_annotation -> position = DEFAULT_ANNOTATION_POSITION; } } new_annotation -> next = annotation_templates; annotation_templates = new_annotation; } /*****************************************************************************/ /* */ /* Procedure: CONT_Origin_Definition */ /* */ /* Action routine to handle a new origin(s) request */ void CONT_Origin_Definition (int source_of_origins, char *file_name, char *origin_name, long int position, char *sequence, long int from, long int to) { originlog_ptr new_origin, origin_scan; char *rep_string; /* Check out first if the new origin request repeats some that has already */ /* been set */ if (source_of_origins == EXPLICIT_ORIGIN) { if (sequence == NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing sequence information about the origin", NULL, UNDEFINED, NULL, 0, TRUE); } else { /* Origin sequence properly provided for */ origin_scan = origin_templates; while (origin_scan != NULL) { if (origin_scan -> source == EXPLICIT_ORIGIN) { if (origin_name == NULL) { if ((!strcmp (sequence, origin_scan -> sequence)) && (position == origin_scan -> position)) { rep_string = (char *) NTL0_ckalloc ((60 + strlen (sequence)) * sizeof (char)); sprintf (rep_string, "Repeated origin at position %ld of sequence '%s'", position, sequence); CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 0, TRUE); free (rep_string); } } else if ((!strcmp (origin_name, origin_scan -> name)) && (!strcmp (sequence, origin_scan -> sequence))) { rep_string = (char *) NTL0_ckalloc ((38 + strlen (origin_name) + strlen (sequence)) * sizeof (char)); sprintf (rep_string, "Repeated origin '%s' in sequence '%s'", origin_name, sequence); CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 0, TRUE); free (rep_string); } } origin_scan = origin_scan -> next; } } } else { /* Origins requested to be loaded from a file */ if (file_name == NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing file name for origins loading request", NULL, UNDEFINED, NULL, 0, TRUE); } else { /* File name properly furnished */ origin_scan = origin_templates; while (origin_scan != NULL) { if (origin_scan -> source == FILED_ORIGINS) { if (!strcmp (file_name, origin_scan -> file_name)) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Repeated origin loading request from file '", file_name, UNDEFINED, NULL, 0, TRUE); } } origin_scan = origin_scan -> next; } } } /* Allocate a record to store data about the new origin request, and fill */ new_origin = (originlog_ptr) NTL0_ckalloc (sizeof (OriginLog_Struct)); new_origin -> source = source_of_origins; if (source_of_origins == EXPLICIT_ORIGIN) { if (file_name != NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "File (", file_name, UNDEFINED, ") specified for explicit origin", 46, TRUE); } new_origin -> file_name = NULL; new_origin -> name = origin_name; if (position < 1) { rep_string = (char *) NTL0_ckalloc ((44 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "Illegal position (%ld) for origin '%s'", position, origin_name); CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 48, TRUE); free (rep_string); free (new_origin -> name); free (new_origin); } else { new_origin -> position = position; if (sequence == NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Origin specified with no sequence", NULL, UNDEFINED, NULL, 49, TRUE); } new_origin -> sequence = sequence; if (from == UNDEFINED) { if (!strcmp (new_origin -> sequence, principal_sequence)) new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; else new_origin -> from = 0; } else if (from == 0) { rep_string = (char *) NTL0_ckalloc (50 * sizeof (char)); sprintf (rep_string, "From origin range 0 - reset to default (%ld)", (long int) DEFAULT_ORIGIN_FROM_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; } else if (from < MAXIMAL_ORIGIN_FROM_RANGE) { if (origin_name != NULL) { rep_string = (char *) NTL0_ckalloc ((80 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "From origin range to big (%ld) for origin '%s' - reset to maximum (%ld)", from, origin_name, (long int) MAXIMAL_ORIGIN_FROM_RANGE); } else { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "From origin range to big (%ld) for origin - reset to maximum (%ld)", from, (long int) MAXIMAL_ORIGIN_FROM_RANGE); } CONT_Warning (rep_string); free (rep_string); new_origin -> from = MAXIMAL_ORIGIN_FROM_RANGE; } else if (from > MINIMAL_ORIGIN_FROM_RANGE) { if (origin_name != NULL) { rep_string = (char *) NTL0_ckalloc ((88 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "From origin range to small (%ld) for origin '%s' - reset to minimum (%ld)", from, origin_name, (long int) MINIMAL_ORIGIN_FROM_RANGE); } else { rep_string = (char *) NTL0_ckalloc (86 * sizeof (char)); sprintf (rep_string, "From origin range to small (%ld) for origin - reset to minimum (%ld)", from, (long int) MINIMAL_ORIGIN_FROM_RANGE); } CONT_Warning (rep_string); free (rep_string); new_origin -> from = MINIMAL_ORIGIN_FROM_RANGE; } else { new_origin -> from = from; if (strcmp (new_origin -> sequence, principal_sequence)) { rep_string = (char *) NTL0_ckalloc ((70 + strlen (new_origin -> sequence) + strlen (principal_sequence)) * sizeof (char)); sprintf (rep_string, "Origin in '%s' at %ld provided from %ld, yet not in '%s'", new_origin -> sequence, new_origin -> position, new_origin -> from, principal_sequence); CONT_Warning (rep_string); free (rep_string); } } if (to == UNDEFINED) { if (!strcmp (new_origin -> sequence, principal_sequence)) new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; else new_origin -> to = 0; } else if (to == 0) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "To origin range 0 - reset to default (%ld)", (long int) DEFAULT_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; } else if (to > MAXIMAL_ORIGIN_TO_RANGE) { if (origin_name != NULL) { rep_string = (char *) NTL0_ckalloc ((78 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "To origin range to big (%ld) for origin '%s' - reset to maximum (%ld)", to, origin_name, (long int) MAXIMAL_ORIGIN_TO_RANGE); } else { rep_string = (char *) NTL0_ckalloc (76 * sizeof (char)); sprintf (rep_string, "To origin range to big (%ld) for origin - reset to maximum (%ld)", to, (long int) MAXIMAL_ORIGIN_TO_RANGE); } CONT_Warning (rep_string); free (rep_string); new_origin -> to = MAXIMAL_ORIGIN_TO_RANGE; } else if (to < MINIMAL_ORIGIN_TO_RANGE) { if (origin_name != NULL) { rep_string = (char *) NTL0_ckalloc ((83 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "To origin range to small (%ld) for origin '%s' - reset to minimum (%ld)", to, origin_name, (long int) MINIMAL_ORIGIN_TO_RANGE); } else { rep_string = (char *) NTL0_ckalloc (81 * sizeof (char)); sprintf (rep_string, "To origin range to small (%ld) for origin - reset to minimum (%ld)", to, (long int) MINIMAL_ORIGIN_TO_RANGE); } CONT_Warning (rep_string); free (rep_string); new_origin -> to = MINIMAL_ORIGIN_TO_RANGE; } else { new_origin -> to = to; if (strcmp (new_origin -> sequence, principal_sequence)) { rep_string = (char *) NTL0_ckalloc ((70 + strlen (new_origin -> sequence) + strlen (principal_sequence)) * sizeof (char)); sprintf (rep_string, "Origin in '%s' at %ld provided to %ld, yet not in '%s'", new_origin -> sequence, new_origin -> position, new_origin -> to, principal_sequence); CONT_Warning (rep_string); free (rep_string); } } if (((new_origin -> from == 0) && (new_origin -> to != 0)) || ((new_origin -> from != 0) && (new_origin -> to == 0))) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "From-to range mismatch for an origin", NULL, UNDEFINED, NULL, 0, TRUE); else if (new_origin -> from >= new_origin -> to) { rep_string = (char *) NTL0_ckalloc ((90 + strlen (origin_name)) * sizeof (char)); sprintf (rep_string, "Illegal range [%ld,%ld] for origin '%s' - reset to default [%ld,%ld]", new_origin -> from, new_origin -> to, origin_name, (long int) DEFAULT_ORIGIN_FROM_RANGE, (long int) DEFAULT_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; } } } else { /* Must be origins specified from a file */ if (file_name == NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "File name not specified for origins file", NULL, UNDEFINED, NULL, 50, TRUE); } new_origin -> file_name = file_name; if (origin_name != NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Origin name (", origin_name, UNDEFINED, ") provided for origins file", 51, TRUE); } new_origin -> name = NULL; if (position != UNDEFINED) { rep_string = (char *) NTL0_ckalloc ((50 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Position (%ld) provided for origins file '%s'", position, file_name); CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 52, TRUE); free (rep_string); } new_origin -> position = UNDEFINED; if (sequence != NULL) { rep_string = (char *) NTL0_ckalloc ((44 + strlen (sequence) + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Sequence (%s) provided for origins file '%s'", sequence, file_name); CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 53, TRUE); } new_origin -> sequence = NULL; if (from == UNDEFINED) new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; else if (from == 0) { rep_string = (char *) NTL0_ckalloc (50 * sizeof (char)); sprintf (rep_string, "From origin range 0 - reset to default (%ld)", (long int) DEFAULT_ORIGIN_FROM_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; } else if (from < MAXIMAL_ORIGIN_FROM_RANGE) { rep_string = (char *) NTL0_ckalloc ((80 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "From origin range too big (%ld) for origins from '%s' - reset to %ld", from, file_name, (long int) MAXIMAL_ORIGIN_FROM_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = MAXIMAL_ORIGIN_FROM_RANGE; } else if (from > MINIMAL_ORIGIN_FROM_RANGE) { rep_string = (char *) NTL0_ckalloc ((88 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "From origin range to small (%ld) for origins from '%s' - reset to %ld", from, file_name, (long int) MINIMAL_ORIGIN_FROM_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = MINIMAL_ORIGIN_FROM_RANGE; } else new_origin -> from = from; if (to == UNDEFINED) new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; else if (to == 0) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "To origin range 0 - reset to default (%ld)", (long int) DEFAULT_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; } else if (to > MAXIMAL_ORIGIN_TO_RANGE) { rep_string = (char *) NTL0_ckalloc ((78 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "To origin range too big (%ld) for origins from '%s' - reset to %ld", to, file_name, (long int) MAXIMAL_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> to = MAXIMAL_ORIGIN_TO_RANGE; } else if (to < MINIMAL_ORIGIN_TO_RANGE) { rep_string = (char *) NTL0_ckalloc ((83 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "To origin range to small (%ld) for origins from '%s' - reset to %ld", to, file_name, (long int) MINIMAL_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> to = MINIMAL_ORIGIN_TO_RANGE; } else new_origin -> to = to; if (new_origin -> from >= new_origin -> to) { rep_string = (char *) NTL0_ckalloc ((90 + strlen (file_name)) * sizeof (char)); sprintf (rep_string, "Illegal range [%ld,%ld] for origins from '%s' - reset to [%ld,%ld]", new_origin -> from, new_origin -> to, file_name, (long int) DEFAULT_ORIGIN_FROM_RANGE, (long int) DEFAULT_ORIGIN_TO_RANGE); CONT_Warning (rep_string); free (rep_string); new_origin -> from = DEFAULT_ORIGIN_FROM_RANGE; new_origin -> to = DEFAULT_ORIGIN_TO_RANGE; } } new_origin -> next = origin_templates; origin_templates = new_origin; } /*****************************************************************************/ /* */ /* Procedure: CONT_Description_Command */ /* */ /* Action routine to handle description block inclusion/exclusion request */ void CONT_Description_Command (int description_code) { if (description_code == DESCRIPTION) description_include = TRUE; else if (description_code == NO_DESCRIPTION) description_include = FALSE; else CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Bad description code", NULL, UNDEFINED, NULL, 55, TRUE); } /*****************************************************************************/ /* */ /* Procedure: CONT_Page_Definition */ /* */ /* Action routine to handle a new request for page layout parameter(s) */ void CONT_Page_Definition (int orientation, int size, int width, int spacing) { char *rep_string; if (orientation != UNDEFINED) { /* Request for page orientation */ if ((orientation == PORTRAIT_CODE) || (orientation == LANDSCAPE_CODE)) page_orientation = orientation; else CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Bad page orientation", NULL, UNDEFINED, NULL, 56, TRUE); if (size == UNDEFINED) { /* Request for page size */ if (orientation == PORTRAIT_CODE) page_size = DEFAULT_PORTRAIT_SIZE; else page_size = DEFAULT_LANDSCAPE_SIZE; } else if (orientation == PORTRAIT_CODE) { if (size < MIN_PORTRAIT_SIZE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Size (%d) too small for portrait page - set to min (%d)", size, MIN_PORTRAIT_SIZE); CONT_Warning (rep_string); free (rep_string); page_size = MIN_PORTRAIT_SIZE; } else if (size > MAX_PORTRAIT_SIZE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Size (%d) too big for portrait page - set to max (%d)", size, MAX_PORTRAIT_SIZE); CONT_Warning (rep_string); free (rep_string); page_size = MAX_PORTRAIT_SIZE; } else page_size = size; } else { /* Page orientation is "landscape" */ if (size < MIN_LANDSCAPE_SIZE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Size (%d) too small for landscape page - set to min (%d)", size, MIN_LANDSCAPE_SIZE); CONT_Warning (rep_string); free (rep_string); page_size = MIN_LANDSCAPE_SIZE; } else if (size > MAX_LANDSCAPE_SIZE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Size (%d) too big for landscape page - set to max (%d)", size, MAX_LANDSCAPE_SIZE); CONT_Warning (rep_string); free (rep_string); page_size = MAX_LANDSCAPE_SIZE; } else page_size = size; } } else if (size != UNDEFINED) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Page size (", NULL, size, ") provided with no orientation", 57, TRUE); } if (width != UNDEFINED) { /* Request for page width (number of chars) */ if (width < MIN_PAGE_WIDTH) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Requested page too narrow (%d) - set to minimum (%d)", width, MIN_PAGE_WIDTH); CONT_Warning (rep_string); free (rep_string); page_width = MIN_PAGE_WIDTH; } else if (width > MAX_PAGE_WIDTH) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Requested page too wide (%d) - set to maximum (%d)", width, MAX_PAGE_WIDTH); CONT_Warning (rep_string); free (rep_string); page_width = MAX_PAGE_WIDTH; } else page_width = width; } if (spacing != UNDEFINED) { /* Request for spacing between alignment blocks */ if (spacing < MIN_SPACING) { rep_string = (char *) NTL0_ckalloc (70 * sizeof (char)); sprintf (rep_string, "Requested spacing too small (%d) - set to minimum (%d)", width, MIN_SPACING); CONT_Warning (rep_string); free (rep_string); block_spacing = MIN_SPACING; } else if (spacing > MAX_SPACING) { rep_string = (char *) NTL0_ckalloc (68 * sizeof (char)); sprintf (rep_string, "Requested spacing too big (%d) - set to maximum (%d)", width, MAX_SPACING); CONT_Warning (rep_string); free (rep_string); block_spacing = MAX_SPACING; } else block_spacing = spacing; } } /*****************************************************************************/ /* */ /* Procedure: CONT_Box_Command */ /* */ /* Action routine to handle a request for a placement of a new box */ void CONT_Box_Command (char *sequence, char *origin, long int start, long int stop, char *style, float shade, label_ptr label, int place, int position) { boxlog_ptr new_box; char *rep_string; bool range_error; new_box = (boxlog_ptr) NTL0_ckalloc (sizeof (BoxLog_Struct)); if (sequence == NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing sequence for a box", NULL, UNDEFINED, NULL, 59, TRUE); else new_box -> sequence = sequence; if (origin == NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing origin for a box", NULL, UNDEFINED, NULL, 60, TRUE); else new_box -> origin = origin; range_error = FALSE; if (start > stop) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Illegal start/stop positions for a box (%ld - %ld)", start, stop); CONT_Error_Report (USER_ERROR, ERR_BAD_STRUCTURE, rep_string, NULL, UNDEFINED, NULL, 61, TRUE); free (rep_string); range_error = TRUE; new_box -> start = 1; new_box -> stop = 3; } else if (stop - start + 1 < MINIMAL_BOX_WIDTH) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Requested box too narrow (", NULL, stop - start + 1, ")", 62, TRUE); range_error = TRUE; new_box -> start = 1; new_box -> stop = 3; } else if (stop - start + 1 > MAXIMAL_BOX_WIDTH) { rep_string = (char *) NTL0_ckalloc (44 * sizeof (char)); sprintf (rep_string, "Requested box too wide (%ld)", stop - start + 1); CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 63, TRUE); free (rep_string); range_error = TRUE; new_box -> start = 1; new_box -> stop = 3; } else if ((start == 0) || (stop == 0)) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Zero is not permitted as offset with origin '", origin, UNDEFINED, "'", 64, TRUE); range_error = TRUE; new_box -> start = 1; new_box -> stop = 3; } else { new_box -> start = start; new_box -> stop = stop; } if (range_error) { free (new_box -> sequence); free (new_box -> origin); free (new_box); } else { if (style == NULL) new_box -> style = NTL0_strsave (DEFAULT_BOX_STYLE); else new_box -> style = style; if ((shade < (float) UNDEFINED - EPSILON) || (shade > (float) UNDEFINED + EPSILON)) { new_box -> shade = TRUE; new_box -> intensity = shade; } else { new_box -> shade = FALSE; new_box -> intensity = (float) UNDEFINED; } if (label != NULL) { new_box -> label = label; if (place == UNDEFINED) new_box -> label_place = DEFAULT_BOX_LABEL_PLACE; else new_box -> label_place = place; if (position == UNDEFINED) new_box -> label_position = DEFAULT_BOX_LABEL_POSITION; else new_box -> label_position = position; } else { /* No label provided for the box */ new_box -> label = NTL1_Copy_Label (default_box_label); if ((place != UNDEFINED) || (position != UNDEFINED)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Settings provided for undefined label", NULL, UNDEFINED, NULL, 65, TRUE); new_box -> label_place = DEFAULT_BOX_LABEL_PLACE; new_box -> label_position = DEFAULT_BOX_LABEL_POSITION; } new_box -> next = boxes; boxes = new_box; } } /*****************************************************************************/ /* */ /* Procedure: CONT_Underline_Command */ /* */ /* Action routine to handle a request for a placement of a new underline */ void CONT_Underline_Command (int kind, char *sequence, char *origin, long int start, long int stop, char *style, label_ptr label, int place, int position) { underlog_ptr new_underline; char *rep_string; bool range_error; new_underline = (underlog_ptr) NTL0_ckalloc (sizeof (UnderLog_Struct)); if (kind == UNDEFINED) new_underline -> kind = DEFAULT_UNDERLINE_KIND; else new_underline -> kind = kind; if (sequence == NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing sequence for underline", NULL, UNDEFINED, NULL, 66, TRUE); else new_underline -> sequence = sequence; if (origin == NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing origin for underline", NULL, UNDEFINED, NULL, 67, TRUE); else new_underline -> origin = origin; range_error = FALSE; if (start > stop) { rep_string = (char *) NTL0_ckalloc (70 * sizeof (char)); sprintf (rep_string, "Illegal start/stop positions for underline (%ld - %ld)", start, stop); CONT_Error_Report (USER_ERROR, ERR_BAD_STRUCTURE, rep_string, NULL, UNDEFINED, NULL, 68, TRUE); free (rep_string); range_error = TRUE; new_underline -> start = 1; new_underline -> stop = 3; } else if (stop - start < MINIMAL_UNDERLINE_WIDTH) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Requested underline too narrow (", NULL, stop - start + 1, ")", 69, TRUE); range_error = TRUE; new_underline -> start = 1; new_underline -> stop = 3; } else if (stop - start > MAXIMAL_UNDERLINE_WIDTH) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "Requested underline too long (%ld)", stop - start); CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 70, TRUE); free (rep_string); range_error = TRUE; new_underline -> start = 1; new_underline -> stop = 3; } else if ((start == 0) || (stop == 0)) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Zero is not permitted as offset with origin '", origin, UNDEFINED, "'", 71, TRUE); range_error = TRUE; new_underline -> start = 1; new_underline -> stop = 3; } else { new_underline -> start = start; new_underline -> stop = stop; } if (range_error) { free (new_underline -> sequence); free (new_underline -> origin); free (new_underline); } else { if (style == NULL) new_underline -> style = NTL0_strsave (DEFAULT_UNDERLINE_STYLE); else new_underline -> style = style; if (label != NULL) { new_underline -> label = label; if (place == UNDEFINED) new_underline -> label_place = DEFAULT_UNDERLINE_LABEL_PLACE; else new_underline -> label_place = place; if (position == UNDEFINED) new_underline -> label_position = DEFAULT_UNDERLINE_LABEL_POSITION; } else { /* No label provided for the underline */ new_underline -> label = NTL1_Copy_Label (default_underline_label); if ((place != UNDEFINED) || (position != UNDEFINED)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Settings provided for undefined label", NULL, UNDEFINED, NULL, 72, TRUE); new_underline -> label_place = DEFAULT_UNDERLINE_LABEL_PLACE; new_underline -> label_position = DEFAULT_UNDERLINE_LABEL_POSITION; } new_underline -> next = underlines; underlines = new_underline; } } /*****************************************************************************/ /* */ /* Procedure: CONT_Line_Definition */ /* */ /* Action routine to handle a new description for a line of the output */ void CONT_Line_Definition (int line_kind, int line_number, int line_contents, int tick_distance, char *inline_text, int text_repeat, bool seq_disabled, int banner, char *banner_font, int banner_font_size, long int adjustment, int text_layout, int pivot, char *pivot_seq, int trailer, char *trailer_font, int trailer_font_size, int start_code, int end_code) { if ((line_kind == TOP_LINE) || (line_kind == INTERMEDIATE_LINE) || (line_kind == BOTTOM_LINE)) { /* Definition concerns a "description" */ if (seq_disabled) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Disabled supplementary line", NULL, UNDEFINED, NULL, 73, TRUE); else if (banner != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Banner provided for sipplementary line", NULL, UNDEFINED, NULL, 74, TRUE); else if (banner_font != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Banner font provided for no banner", NULL, UNDEFINED, NULL, 75, TRUE); else if (banner_font_size != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Banner font size provided for no banner", NULL, UNDEFINED, NULL, 76, TRUE); else if (adjustment != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Adjustment factor provided for no banner", NULL, UNDEFINED, NULL, 76, TRUE); else if (text_layout != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Text layout provided for supplementary line", NULL, UNDEFINED, NULL, 77, TRUE); else if (pivot != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Pivot provided for supplementary line", NULL, UNDEFINED, NULL, 78, TRUE); else if (pivot_seq != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Pivot sequence provided for supplementary line", NULL, UNDEFINED, NULL, 79, TRUE); else if (trailer != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Trailer provided for sipplementary line", NULL, UNDEFINED, NULL, 80, TRUE); else if (trailer_font != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Trailer font provided for no trailer", NULL, UNDEFINED, NULL, 81, TRUE); else if (trailer_font_size != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Trailer font size provided for no trailer", NULL, UNDEFINED, NULL, 82, TRUE); else if (start_code != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Start code provided for supplementary line", NULL, UNDEFINED, NULL, 83, TRUE); else if (end_code != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "End code provided for supplementary line", NULL, UNDEFINED, NULL, 84, TRUE); else CONT_Supplementary_Definition (line_kind, line_number, line_contents, tick_distance, inline_text, text_repeat); } else if (line_kind == TEXT_LINE) { /* Definition for alignment text line */ if (line_contents != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Contents specified for a text line", NULL, UNDEFINED, NULL, 85, TRUE); else if (tick_distance != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Tickmarks requested in a text line", NULL, UNDEFINED, NULL, 86, TRUE); else if (inline_text != NULL) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Inline text requested for a text line", NULL, UNDEFINED, NULL, 88, TRUE); else if (text_repeat != UNDEFINED) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Text repeat requested for no text", NULL, UNDEFINED, NULL, 89, TRUE); else CONT_Text_Definition (line_number, seq_disabled, banner, banner_font, banner_font_size, adjustment, text_layout, pivot, pivot_seq, trailer, trailer_font, trailer_font_size, start_code, end_code); } else CONT_Error_Report (SYSTEM_ERROR, ERR_ILLEGAL_CODE, "Bad line definition", NULL, UNDEFINED, NULL, 90, TRUE); } /*****************************************************************************/ /* */ /* Procedure: CONT_Supplementary_Definition */ /* */ /* Procedure handles a definition of a new description line */ void CONT_Supplementary_Definition (int line_kind, int line_number, int line_contents, int tick_distance, char *inline_text, int text_repeat) { desclog_ptr new_line, *start_template, line_scan, line_prev, trash; char *rep_string; /* Allocate a record to store the new definition of a "description" line */ new_line = (desclog_ptr) NTL0_ckalloc (sizeof (DescLog_Struct)); /* Fill in the fields of the record and check for consistency first */ new_line -> kind = line_kind; if (line_number == UNDEFINED) new_line -> number = DEFAULT_DESC_LINE_NUMBER; else new_line -> number = line_number; if (line_contents == UNDEFINED) new_line -> contents = DEFAULT_LINE_CONTENTS; else new_line -> contents = line_contents; if ((tick_distance == UNDEFINED) && ((line_contents == TICKMARK_CODE) || (line_contents == STRIPPED_TICK_CODE))) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing distance for tickmarks", NULL, UNDEFINED, NULL, 91, TRUE); else if ((tick_distance != UNDEFINED) && (line_contents != TICKMARK_CODE) && (line_contents != STRIPPED_TICK_CODE)) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Tick distance ilegally defined", NULL, UNDEFINED, NULL, 92, TRUE); else if (tick_distance != UNDEFINED) { if (tick_distance < MIN_TICK_DISTANCE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Tickmark distance (%d) too small - set to minimum (%d)", tick_distance, MIN_TICK_DISTANCE); CONT_Warning (rep_string); free (rep_string); new_line -> tick_distance = MIN_TICK_DISTANCE; } else if (tick_distance > MAX_TICK_DISTANCE) { rep_string = (char *) NTL0_ckalloc (66 * sizeof (char)); sprintf (rep_string, "Tickmark distance (%d) too large - set to minimum (%d)", tick_distance, MAX_TICK_DISTANCE); CONT_Warning (rep_string); free (rep_string); new_line -> tick_distance = MAX_TICK_DISTANCE; } else new_line -> tick_distance = tick_distance; } else new_line -> tick_distance = UNDEFINED; if ((inline_text == NULL) && ((line_contents == LINE_TEXT_CODE) || (line_contents == REPEATED_TEXT_CODE))) { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing text for description line", NULL, UNDEFINED, NULL, 94, TRUE); } else if ((inline_text != NULL) && (line_contents != LINE_TEXT_CODE) && (line_contents != REPEATED_TEXT_CODE)) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Text provided for non-textual description", NULL, UNDEFINED, NULL, 95, TRUE); } else if (inline_text != NULL) new_line -> inline_text = inline_text; else new_line -> inline_text = NULL; if ((text_repeat == UNDEFINED) && (line_contents == REPEATED_TEXT_CODE)) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing repeat value for text", NULL, UNDEFINED, NULL, 96, TRUE); else if ((text_repeat != UNDEFINED) && (line_contents != REPEATED_TEXT_CODE)) CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "No value provided for repeated text", NULL, UNDEFINED, NULL, 97, TRUE); else if (text_repeat != UNDEFINED) { if (text_repeat < MINIMAL_TEXT_REPEAT) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Repeat interval for text (", NULL, (long int) text_repeat, ") too small", 98, TRUE); new_line -> text_repeat = MINIMAL_TEXT_REPEAT; } else if (text_repeat < strlen (new_line -> inline_text)) { rep_string = (char *) NTL0_ckalloc (80 * sizeof (char)); sprintf (rep_string, "Selected text repeat interval (%d) smaller than text length (%ld)", text_repeat, strlen (new_line -> inline_text)); CONT_Warning (rep_string); free (rep_string); new_line -> text_repeat = text_repeat; } else new_line -> text_repeat = text_repeat; } else new_line -> text_repeat = UNDEFINED; /* Verify if this line causes a redefinition within already set lines */ if (line_kind == TOP_LINE) start_template = &top_templates; else if (line_kind == INTERMEDIATE_LINE) start_template = &intermediate_templates; else start_template = &bottom_templates; line_scan = *start_template; line_prev = NULL; /* Scan the right list */ if (line_number == ALL_LINES_CODE) { /* General setting for all lines */ while (line_scan != NULL) { if (line_scan -> number != ALL_LINES_CODE) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "Description line (number %d) redefinition", line_scan -> number); CONT_Warning (rep_string); free (rep_string); } trash = line_scan; line_scan = line_scan -> next; free (trash); } *start_template = NULL; } else { /* Specific "description" line setting */ while (line_scan != NULL) { if (line_scan -> number == new_line -> number) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "Description line (number %d) redefinition", line_scan -> number); CONT_Warning (rep_string); free (rep_string); trash = line_scan; line_scan = line_scan -> next; if (line_prev == NULL) *start_template = line_scan; else line_prev -> next = line_scan; free (trash); } else { line_prev = line_scan; line_scan = line_scan -> next; } } } new_line -> next = *start_template; *start_template = new_line; } /*****************************************************************************/ /* */ /* Procedure: CONT_Text_Definition */ /* */ /* Procedure handles a definition of a text line in the output */ void CONT_Text_Definition (int line_number, bool seq_disabled, int banner, char *banner_font, int banner_font_size, long int adjustment, int text_layout, int pivot, char *pivot_seq, int trailer, char *trailer_font, int trailer_font_size, int start_code, int end_code) { textlog_ptr new_line, line_scan, line_prev, trash; char *rep_string; /* Allocate a record for the new text line definition and fill the contents */ new_line = (textlog_ptr) NTL0_ckalloc (sizeof (TextLog_Struct)); /* Check the consistency of the specification and fill the fields first */ new_line -> number = line_number; if ((seq_disabled) && (line_number == ALL_LINES_CODE)) { CONT_Warning ("Disabling request for all alignment sequences"); } new_line -> disabled = seq_disabled; if (banner == UNDEFINED) new_line -> banner = DEFAULT_BANNER_CODE; else new_line -> banner = banner; if (banner == UNDEFINED) { if (banner_font != NULL) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Banner font (", banner_font, UNDEFINED, ") illegaly provided", 99, TRUE); } if (banner_font_size != UNDEFINED) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Banner font size illegaly specified", NULL, UNDEFINED, NULL, 100, TRUE); } if (adjustment != UNDEFINED) { /* Error in the parsing code */ CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Adjustment value illegaly specified", NULL, UNDEFINED, NULL, 100, TRUE); } if (new_line -> banner != NO_BANNER) { new_line -> banner_font = NTL0_strsave (DEFAULT_BANNER_FONT); new_line -> banner_font_size = DEFAULT_BANNER_FONT_SIZE; new_line -> adjustment = DEFAULT_ADJUSTMENT; } else { /* Banner not to be shown */ new_line -> banner_font = NULL; new_line -> banner_font_size = UNDEFINED; new_line -> adjustment = DEFAULT_ADJUSTMENT; } } else { if (banner_font == NULL) { new_line -> banner_font = NTL0_strsave (DEFAULT_BANNER_FONT); if (banner_font_size != UNDEFINED) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegaly provided banner font size", NULL, UNDEFINED, NULL, 101, TRUE); } else new_line -> banner_font_size = DEFAULT_BANNER_FONT_SIZE; } else { new_line -> banner_font = banner_font; if (banner_font_size == UNDEFINED) new_line -> banner_font_size = DEFAULT_BANNER_FONT_SIZE; else { if (banner_font_size < MINIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested banner font size (%d) too small - set to minimum (%d)", banner_font_size, MINIMAL_FONT); CONT_Warning (rep_string); free (rep_string); new_line -> banner_font_size = MINIMAL_FONT; } else if (banner_font_size > MAXIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested banner font size (%d) too large - set to maximum (%d)", banner_font_size, MAXIMAL_FONT); CONT_Warning (rep_string); free (rep_string); new_line -> banner_font_size = MAXIMAL_FONT; } else new_line -> banner_font_size = banner_font_size; } } if (adjustment == UNDEFINED) new_line -> adjustment = DEFAULT_ADJUSTMENT; else new_line -> adjustment = adjustment; } new_line -> layout = text_layout; if (text_layout == VERBATIM_CODE) { if (pivot != UNDEFINED) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal pivot number (", NULL, (long int) pivot, ") in literal text", 102, TRUE); } if (pivot_seq != NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegal pivot sequence (", pivot_seq, UNDEFINED, ") in literal text", 102, TRUE); } new_line -> pivot = UNDEFINED; new_line -> pivot_sequence = NULL; } else { if ((pivot == UNDEFINED) && (pivot_seq == NULL)) { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "Missing pivot data for text line", NULL, UNDEFINED, NULL, 103, TRUE); } else if ((pivot != UNDEFINED) && (pivot_seq != NULL)) { rep_string = (char *) NTL0_ckalloc ((56 + strlen (pivot_seq)) * sizeof (char)); sprintf (rep_string, "Both pivot sequence (%s) and number (%d) provided", pivot_seq, pivot); CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, rep_string, NULL, UNDEFINED, NULL, 104, TRUE); } else { new_line -> pivot = pivot; new_line -> pivot_sequence = pivot_seq; } } if (trailer == UNDEFINED) new_line -> trailer = DEFAULT_TRAILER_CODE; else new_line -> trailer = trailer; if (trailer == UNDEFINED) { if (trailer_font != NULL) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Trailer font (", trailer_font, UNDEFINED, ") illegaly provided", 105, TRUE); } if (trailer_font_size != UNDEFINED) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Trailer font size illegaly specified", NULL, UNDEFINED, NULL, 106, TRUE); } if (new_line -> trailer != NO_TRAILER) { new_line -> trailer_font = NTL0_strsave (DEFAULT_TRAILER_FONT); new_line -> trailer_font_size = DEFAULT_TRAILER_FONT_SIZE; } else { new_line -> trailer_font = NULL; new_line -> trailer_font_size = UNDEFINED; } } else { if (trailer_font == NULL) { new_line -> trailer_font = NTL0_strsave (DEFAULT_TRAILER_FONT); if (trailer_font_size != UNDEFINED) { CONT_Error_Report (SYSTEM_ERROR, ERR_BAD_VALUE, "Illegaly provided trailer font size", NULL, UNDEFINED, NULL, 107, TRUE); } else new_line -> trailer_font_size = DEFAULT_TRAILER_FONT_SIZE; } else { new_line -> trailer_font = trailer_font; if (trailer_font_size == UNDEFINED) new_line -> trailer_font_size = DEFAULT_TRAILER_FONT_SIZE; else { if (trailer_font_size < MINIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested trailer font size (%d) too small - set to minimum (%d)", trailer_font_size, MINIMAL_FONT); CONT_Warning (rep_string); free (rep_string); new_line -> trailer_font_size = MINIMAL_FONT; } else if (trailer_font_size > MAXIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested trailer font size (%d) too large - set to maximum (%d)", trailer_font_size, MAXIMAL_FONT); CONT_Warning (rep_string); free (rep_string); new_line -> trailer_font_size = MAXIMAL_FONT; } else new_line -> trailer_font_size = trailer_font_size; } } } if (start_code == UNDEFINED) new_line -> started = DEFAULT_START_CODE; else new_line -> started = start_code; if (end_code == UNDEFINED) new_line -> ended = DEFAULT_END_CODE; else new_line -> ended = end_code; /* Verify if this line causes a redefinition within already set lines */ line_scan = text_templates; line_prev = NULL; if (line_number == ALL_LINES_CODE) { while (line_scan != NULL) { if (line_scan -> number != ALL_LINES_CODE) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "Text line (number %d) redefinition", line_scan -> number); CONT_Warning (rep_string); free (rep_string); } trash = line_scan; line_scan = line_scan -> next; free (trash); } text_templates = NULL; } else { while (line_scan != NULL) { if (line_scan -> number == new_line -> number) { rep_string = (char *) NTL0_ckalloc (48 * sizeof (char)); sprintf (rep_string, "Text line (number %d) redefinition", line_scan -> number); CONT_Warning (rep_string); free (rep_string); trash = line_scan; line_scan = line_scan -> next; if (line_prev == NULL) text_templates = line_scan; else line_prev -> next = line_scan; free (trash); } else { line_prev = line_scan; line_scan = line_scan -> next; } } } new_line -> next = text_templates; text_templates = new_line; } /*****************************************************************************/ /* */ /* Procedure: CONT_Font_Definition */ /* */ /* Action routine to handle a request for the font size in alignment output */ void CONT_Font_Definition (int font_size) { char *rep_string; if (text_font_size != DEFAULT_TEXT_FONT_SIZE) { rep_string = (char *) NTL0_ckalloc (60 * sizeof (char)); sprintf (rep_string, "Redefinition of the text font size from %d to %d", text_font_size, font_size); CONT_Warning (rep_string); free (rep_string); } if (font_size < MINIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested text font size (%d) too small - set to minimal (%d)", font_size, MINIMAL_FONT); CONT_Warning (rep_string); free (rep_string); text_font_size = MINIMAL_FONT; } else if (font_size > MAXIMAL_FONT) { rep_string = (char *) NTL0_ckalloc (78 * sizeof (char)); sprintf (rep_string, "Requested text font size (%d) too large - set to maximal (%d)", font_size, MAXIMAL_FONT); CONT_Warning (rep_string); free (rep_string); text_font_size = MAXIMAL_FONT; } else text_font_size = font_size; } /*****************************************************************************/ /* */ /* Procedure: CONT_Information_Command */ /* */ /* Action routine to handle the request for the inclusion/exclusion of the */ /* information content of alignment columns in the output */ void CONT_Information_Command (bool content, int strictness) { /* Set the kind of information content to be determined regardless of */ /* whether the content display is locked (request from command line) */ if (strictness != UNDEFINED) information_kind = strictness; /* Check if the display of the information content can be done, and set it */ if (information_locked) CONT_Warning ("Information content display mode locked - command ignored"); else information_include = content; } /*****************************************************************************/ /* */ /* Procedure: CONT_Output_Definition */ /* */ /* Action routine to handle the request for the program output kind */ void CONT_Output_Definition (int output_code) { char *rep_string; if (output_locked) { CONT_Warning ( "Can't change the output format - output locked in command line"); } else { if (output_format != DEFAULT_OUTPUT_FORMAT) { rep_string = (char *) NTL0_ckalloc ((60 + strlen (current_file_name)) * sizeof (char)); sprintf (rep_string, "Output format redefinition in the specifications file %s", current_file_name); CONT_Warning (rep_string); free (rep_string); } output_format = output_code; } } /*****************************************************************************/ /* */ /* Procedure: CONT_Exec */ /* */ /* Procedure performs alignment and specification checks that are possible */ /* only after the complete description is assembled, then passes the */ /* control to the alignment expansion and annotation; returns 0 if */ /* everything is OK, negative error status otherwise */ int CONT_Exec (void) { int error_status; /* Load the alignment first - it will serve as the basis not only for the */ /* preparation of the output, but also for any further error checking */ if (alignment_file == NULL) CONT_Error_Report (FATAL_ERROR, ERR_NO_VALUE, "Missing alignment file name", NULL, UNDEFINED, NULL, 0, FALSE); if (LOAD_Execute (alignment_file, sequences_path, seq_aliases, alignment_number, range_sequence, range_start, range_stop) < 0) return CONT_EXEC_ERROR; else { /* Alignment correctly loaded, proceed */ if ((error_status = CONT_Check_Landmarks ()) < 0) return error_status; if ((error_status = CONT_Check_Annotations ()) < 0) return error_status; if ((error_status = CONT_Check_Origins ()) < 0) return error_status; if ((error_status = CONT_Check_Boxes ()) < 0) return error_status; if ((error_status = CONT_Check_Underlines ()) < 0) return error_status; if ((error_status = CONT_Check_Lines ()) < 0) return error_status; if (error_in_control) return CONT_EXEC_ERROR; else return CONT_Expand (); } } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Landmarks */ /* */ int CONT_Check_Landmarks (void) { seqover_ptr rel_list; landlog_ptr land_scan; /* Loop for all recorded raw landmark templates, to check consistency */ land_scan = landmark_templates; while (land_scan != NULL) { /* If the landmark is single, check whether it's sequence is in the algn. */ if (land_scan -> kind == SINGLE_LANDMARK) { if ((rel_list = ALGN_Find_Sequence (land_scan -> sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Landmark sequence '", land_scan -> sequence, UNDEFINED, "' not found in the alignment", 334, FALSE); } else rel_list = CONT_Release_SeqOver (rel_list); } /* If the mark kind is "underline", check whether the marking sequence is */ /* present in the alignment */ if (land_scan -> mark_kind == UNDERLINE_CODE) { if ((land_scan -> kind == SINGLE_LANDMARK) || (land_scan -> mark_sequence != NULL)) { if ((rel_list = ALGN_Find_Sequence (land_scan -> mark_sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Mark sequence '", land_scan -> mark_sequence, UNDEFINED, "' for landmark not found in the alignment", 335, FALSE); } else rel_list = CONT_Release_SeqOver (rel_list); } } land_scan = land_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Annotations */ /* */ /* Procedure checks whether the annotations requests are given correctly */ /* with respect to the loaded alignment; returns 0 if everything is OK, */ /* negative error status otherwise */ int CONT_Check_Annotations (void) { plainlog_ptr plain_scan; /* Loop for all recorded anotation file templates, to check consistency */ plain_scan = annotation_templates; while (plain_scan != NULL) { if ((plain_scan -> counter != 0) && (plain_scan -> counter != UNDEFINED)) { if (plain_scan -> counter > alignment_records -> dimension) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Counter sequence (", NULL, (long int) plain_scan -> counter, ") does not exist in the alignment", 335, FALSE); } } plain_scan = plain_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Origins */ /* */ int CONT_Check_Origins (void) { seqover_ptr rel_list; originlog_ptr origin_scan; /* Loop for all origin requests recorded and check the consistency of each */ /* one with respect to the current alignment */ origin_scan = origin_templates; while (origin_scan != NULL) { /* If the current origin definition is specific (i.e. not comming from */ /* some database file, check whether it is specified with respect to */ /* a sequence that is actually present in the alignment */ if (origin_scan -> source == EXPLICIT_ORIGIN) { if ((rel_list = ALGN_Find_Sequence (origin_scan -> sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Origin sequence '", origin_scan -> sequence, UNDEFINED, "' not found in the alignment", 341, FALSE); } else rel_list = CONT_Release_SeqOver (rel_list); } origin_scan = origin_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Boxes */ /* */ int CONT_Check_Boxes (void) { seqover_ptr rel_list; boxlog_ptr box_scan; /* Loop for all box requests and check their legality with respect to the */ /* current alignment, as much of it as can be checked */ box_scan = boxes; while (box_scan != NULL) { /* Check whether the sequence with respect to which box is defined is */ /* present within the alignment */ if ((rel_list = ALGN_Find_Sequence (box_scan -> sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Box placement sequence '", box_scan -> sequence, UNDEFINED, "' not found in the alignment", 342, FALSE); } else rel_list = CONT_Release_SeqOver (rel_list); box_scan = box_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Underlines */ /* */ int CONT_Check_Underlines (void) { seqover_ptr rel_list; underlog_ptr underline_scan; /* Loop for all underline requests and check their legality with respect to */ /* the current alignment, as much of it as can be checked */ underline_scan = underlines; while (underline_scan != NULL) { /* Check whether the sequence with respect to which underline is defined */ /* is present within the alignment */ if ((rel_list = ALGN_Find_Sequence (underline_scan -> sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Underline placement sequence '", underline_scan -> sequence, UNDEFINED, "' not found in the alignment", 343, FALSE); } else rel_list = CONT_Release_SeqOver (rel_list); underline_scan = underline_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Check_Lines */ /* */ int CONT_Check_Lines (void) { desclog_ptr desc_scan, prev_scan, trash_desc; seqover_ptr rel_list; textlog_ptr text_scan, prev_text, trash_text; char *rep_string; int target_list; /* Loop for all top lines specified to check if the line number is legal */ /* with respect to current alignment */ desc_scan = top_templates; prev_scan = NULL; while (desc_scan != NULL) { if (desc_scan -> number != ALL_LINES_CODE) { if (desc_scan -> number > alignment_records -> dimension) { rep_string = (char *) NTL0_ckalloc (75 * sizeof (char)); sprintf (rep_string, "Top line request (%d) greater than alignment dimension - ignored", desc_scan -> number); CONT_Warning (rep_string); free (rep_string); trash_desc = desc_scan; desc_scan = desc_scan -> next; if (prev_scan == NULL) top_templates = top_templates -> next; else prev_scan -> next = (prev_scan -> next) -> next; if (trash_desc -> inline_text != NULL) free (trash_desc -> inline_text); free (trash_desc); } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } /* Loop for all intermediate lines specified to check if the line number is */ /* legal with respect to current alignment */ desc_scan = intermediate_templates; prev_scan = NULL; while (desc_scan != NULL) { if (desc_scan -> number != ALL_LINES_CODE) { if (desc_scan -> number > (alignment_records -> dimension) - 1) { rep_string = (char *) NTL0_ckalloc (75 * sizeof (char)); sprintf (rep_string, "Intermediate line request (%d) greater than permitted - ignored", desc_scan -> number); CONT_Warning (rep_string); free (rep_string); trash_desc = desc_scan; desc_scan = desc_scan -> next; if (prev_scan == NULL) intermediate_templates = intermediate_templates -> next; else prev_scan -> next = (prev_scan -> next) -> next; if (trash_desc -> inline_text != NULL) free (trash_desc -> inline_text); free (trash_desc); } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } /* Loop for all bottom lines specified to check if the line number is legal */ /* with respect to current alignment */ desc_scan = bottom_templates; prev_scan = NULL; while (desc_scan != NULL) { if (desc_scan -> number != ALL_LINES_CODE) { if (desc_scan -> number > alignment_records -> dimension) { rep_string = (char *) NTL0_ckalloc (75 * sizeof (char)); sprintf (rep_string, "Bottom line request (%d) greater than alignment dimension - ignored", desc_scan -> number); CONT_Warning (rep_string); free (rep_string); trash_desc = desc_scan; desc_scan = desc_scan -> next; if (prev_scan == NULL) bottom_templates = bottom_templates -> next; else prev_scan -> next = (prev_scan -> next) -> next; if (trash_desc -> inline_text != NULL) free (trash_desc -> inline_text); free (trash_desc); } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } else { prev_scan = desc_scan; desc_scan = desc_scan -> next; } } /* Loop for all text lines to check whether each of the requests is correct */ text_scan = text_templates; prev_text = NULL; while (text_scan != NULL) { /* Check whether the given text line number is legal within the alignment */ if (text_scan -> number != ALL_LINES_CODE) { if (text_scan -> number > alignment_records -> dimension) { rep_string = (char *) NTL0_ckalloc (75 * sizeof (char)); sprintf (rep_string, "Text line request (%d) greater than alignment dimension - ignored", text_scan -> number); CONT_Warning (rep_string); free (rep_string); trash_text = text_scan; text_scan = text_scan -> next; if (prev_text == NULL) text_templates = text_templates -> next; else prev_text -> next = (prev_text -> next) -> next; if (trash_text -> banner_font != NULL) free (trash_text -> banner_font); if (trash_text -> pivot_sequence != NULL) free (trash_text -> pivot_sequence); if (trash_text -> trailer_font) free (trash_text -> trailer_font); free (trash_text); } else { prev_text = text_scan; text_scan = text_scan -> next; } } else { prev_text = text_scan; text_scan = text_scan -> next; } } text_scan = text_templates; while (text_scan != NULL) { /* If the request is for the "dotted text", check whether the pivot */ /* sequence specification is legal */ if (text_scan -> layout == PIVOT_CODE) { if (text_scan -> pivot != UNDEFINED) { if (text_scan -> pivot > alignment_records -> dimension) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Illegal pivot number (", NULL, (long int) (text_scan -> pivot), ") with respect to the alignment", 351, FALSE); } } else if (text_scan -> pivot_sequence != NULL) { if ((rel_list = ALGN_Find_Sequence (text_scan -> pivot_sequence, ANY_LIST)) == NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Pivot sequence '", text_scan -> pivot_sequence, UNDEFINED, "' not found in the alignment", 352, FALSE); } else target_list = rel_list -> source_list; /* ID of the containg list */ if ((rel_list != NULL) && (rel_list -> next != NULL)) { /* Multip.pivots */ rel_list = CONT_Release_SeqOver (rel_list); rel_list = ALGN_Find_Sequence (text_scan -> pivot_sequence, target_list); if (rel_list -> next != NULL) { CONT_Error_Report (USER_ERROR, ERR_BAD_VALUE, "Pivot sequence '", text_scan -> pivot_sequence, UNDEFINED, "' ambiguous in the alignment", 353, FALSE); } } if (rel_list != NULL) rel_list = CONT_Release_SeqOver (rel_list); } else { CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "No pivot sequence provided for dotted text output", NULL, UNDEFINED, NULL, 354, FALSE); } } text_scan = text_scan -> next; } return 0; } /*****************************************************************************/ /* */ /* Procedure: CONT_Expand */ /* */ /* Procedure traverses the formed structures for the alignment display and */ /* performs the expansion and combination of them for the display; returns */ /* 0 if everything is OK, negative error status otherwise */ int CONT_Expand (void) { landlog_ptr landmark_scan, prev_landmark, old_landmark; plainlog_ptr annot_scan, old_annot; originlog_ptr origin_scan, prev_origin, old_origin; boxlog_ptr old_box; underlog_ptr old_underline; desclog_ptr desc_scan, *desc_vector; textlog_ptr text_scan, *text_vector; bool found; int index; if (RAWS_Initialize () < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't proceed", NULL, UNDEFINED, NULL, 0, FALSE); } /* If the "information contents" is requested for the alignment, calculate */ /* it and store for further use */ if (information_include) { if (RAWS_Expand_Information () < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't expand information", NULL, UNDEFINED, NULL, 0, FALSE); } } /* Loop through all landmark requests to expand the individual records */ /* Traverse the requests from landmark files - do the expansion */ landmark_scan = landmark_templates; prev_landmark = NULL; while (landmark_scan != NULL) { if (landmark_scan -> kind == BULK_LANDMARK) { if (RAWS_Expand_Landmarks (landmark_scan -> file_name, landmark_scan -> mark_kind, landmark_scan -> mark_multiple, landmark_scan -> mark_sequence, landmark_scan -> mark_style, landmark_scan -> mark_shade, landmark_scan -> mark_intensity, landmark_scan -> label_font, landmark_scan -> font_size) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't expand landmarks from file '", landmark_scan -> file_name, UNDEFINED, "'", 0, FALSE); } else { old_landmark = landmark_scan; if (prev_landmark == NULL) { landmark_templates = landmark_templates -> next; landmark_scan = landmark_templates; } else { prev_landmark -> next = landmark_scan -> next; landmark_scan = landmark_scan -> next; } /* Remove the "old landmark" record - already expanded & no more needed */ if (old_landmark -> file_name != NULL) free (old_landmark -> file_name); if (old_landmark -> sequence != NULL) free (old_landmark -> sequence); if (old_landmark -> origin != NULL) free (old_landmark -> origin); if (old_landmark -> mark_sequence != NULL) free (old_landmark -> mark_sequence); if (old_landmark -> mark_style != NULL) free (old_landmark -> mark_style); if (old_landmark -> label != NULL) old_landmark -> label = NTL1_Destroy_Label (old_landmark -> label); if (old_landmark -> label_font != NULL) free (old_landmark -> label_font); free (old_landmark); } } else { prev_landmark = landmark_scan; landmark_scan = landmark_scan -> next; } } /* Handle the individual landmark requests from the specification file */ while (landmark_templates != NULL) { if (RAWS_Record_Landmark (landmark_templates -> sequence, landmark_templates -> origin, landmark_templates -> start, landmark_templates -> stop, landmark_templates -> mark_kind, landmark_templates -> mark_multiple, landmark_templates -> mark_sequence, landmark_templates -> mark_style, landmark_templates -> mark_shade, landmark_templates -> mark_intensity, landmark_templates -> label, landmark_templates -> label_place, landmark_templates -> label_position) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't record landmark", NULL, UNDEFINED, NULL, 0, FALSE); } else { old_landmark = landmark_templates; landmark_templates = landmark_templates -> next; /* Remove the "old landmark" record - already expanded & no more needed */ if (old_landmark -> file_name != NULL) free (old_landmark -> file_name); if (old_landmark -> sequence != NULL) free (old_landmark -> sequence); if (old_landmark -> origin != NULL) free (old_landmark -> origin); if (old_landmark -> mark_sequence != NULL) free (old_landmark -> mark_sequence); if (old_landmark -> mark_style != NULL) free (old_landmark -> mark_style); if (old_landmark -> label != NULL) old_landmark -> label = NTL1_Destroy_Label (old_landmark -> label); if (old_landmark -> label_font != NULL) free (old_landmark -> label_font); free (old_landmark); } } /* Handle annotations requests from provided plain landmarks format files */ annot_scan = annotation_templates; while (annot_scan != NULL) { if (RAWS_Expand_Annotations (annot_scan -> file_name, annot_scan -> counter, annot_scan -> mark_kind, annot_scan -> mark_multiple, annot_scan -> mark_style, annot_scan -> mark_shade, annot_scan -> mark_intensity, annot_scan -> text, annot_scan -> text_font, annot_scan -> text_size, annot_scan -> field, annot_scan -> field_font, annot_scan -> field_size, annot_scan -> place, annot_scan -> position) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't expand annotations from file '", annot_scan -> file_name, UNDEFINED, "'", 0, FALSE); } else { old_annot = annot_scan; annot_scan = annot_scan -> next; /* Remove the "old annotation" record - already expanded & no more needed */ if (old_annot -> file_name != NULL) free (old_annot -> file_name); if (old_annot -> mark_style != NULL) free (old_annot -> mark_style); if (old_annot -> text != NULL) free (old_annot -> text); if (old_annot -> text_font != NULL) free (old_annot -> text_font); if (old_annot -> field_font != NULL) free (old_annot -> field_font); free (old_annot); } } annotation_templates = NULL; /* Loop through all origin requests to expand the definition structures */ /* Traverse the loading requests from origin files first */ origin_scan = origin_templates; prev_origin = NULL; while (origin_scan != NULL) { if (origin_scan -> source == FILED_ORIGINS) { if (RAWS_Expand_Origins (origin_scan -> file_name, origin_scan -> from, origin_scan -> to) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't expand origins from '", origin_scan -> file_name, UNDEFINED, "'", 0, FALSE); } else { old_origin = origin_scan; if (prev_origin == NULL) { origin_templates = origin_templates -> next; origin_scan = origin_templates; } else { prev_origin -> next = origin_scan -> next; origin_scan = origin_scan -> next; } /* Now release the origin template record - already expanded */ if (old_origin -> file_name != NULL) free (old_origin -> file_name); if (old_origin -> name != NULL) free (old_origin -> name); if (old_origin -> sequence != NULL) free (old_origin -> sequence); free (old_origin); } } else { /* Individual origin request record */ prev_origin = origin_scan; origin_scan = origin_scan -> next; } } /* Add the individually specified origins from the specification file */ while (origin_templates != NULL) { if (RAWS_Record_Origin (origin_templates -> name, origin_templates -> position, origin_templates -> sequence, origin_templates -> from, origin_templates -> to) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't record the explicitely provided origin", NULL, UNDEFINED, NULL, 0, FALSE); } else { old_origin = origin_templates; origin_templates = origin_templates -> next; /* Now release the origin template record - already expanded */ if (old_origin -> file_name != NULL) free (old_origin -> file_name); if (old_origin -> name != NULL) free (old_origin -> name); if (old_origin -> sequence != NULL) free (old_origin -> sequence); free (old_origin); } } /* Traverse, expand and order the list of box requests from specification */ while (boxes != NULL) { if (RAWS_Record_Box (boxes -> sequence, boxes -> origin, boxes -> start, boxes -> stop, boxes -> style, boxes -> shade, boxes -> intensity, boxes -> label, boxes -> label_place, boxes -> label_position) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't record a box", NULL, UNDEFINED, NULL, 0, FALSE); } else { old_box = boxes; boxes = boxes -> next; /* Remove the "old box" request template - not needed any more */ if (old_box -> sequence != NULL) free (old_box -> sequence); if (old_box -> origin != NULL) free (old_box -> origin); if (old_box -> label != NULL) old_box -> label = NTL1_Destroy_Label (old_box -> label); free (old_box); } } /* Traverse, expand and order the list of underline requests from specs. */ while (underlines != NULL) { if (RAWS_Record_Underline (underlines -> kind, underlines -> sequence, underlines -> origin, underlines -> start, underlines -> stop, underlines -> style, underlines -> label, underlines -> label_place, underlines -> label_position) < 0) { CONT_Error_Report (FATAL_ERROR, ERR_UNKNOWN, "Can't record an underline", NULL, UNDEFINED, NULL, 0, FALSE); } else { old_underline = underlines; underlines = underlines -> next; /* Release the underline request record - not needed any more */ if (old_underline -> sequence != NULL) free (old_underline -> sequence); if (old_underline -> origin != NULL) free (old_underline -> origin); if (old_underline -> style != NULL) free (old_underline -> style); if (old_underline -> label != NULL) old_underline -> label = NTL1_Destroy_Label (old_underline -> label); free (old_underline); } } /* Traverse, expand and order the list of description line requests */ /* Handle the list of top description lines */ /* Find the description request record for "all top lines" - there must be */ /* one and only one in the list */ desc_scan = top_templates; found = FALSE; while ((!found) && (desc_scan != NULL)) { if (desc_scan -> number == ALL_LINES_CODE) found = TRUE; else desc_scan = desc_scan -> next; } if (!found) CONT_Error_Report (SYSTEM_ERROR, ERR_NO_VALUE, "No request record for all top lines", NULL, UNDEFINED, NULL, 0, FALSE); /* Create the ordered vector of top lines and connect all of them to the */ /* record for all lines, initially */ desc_vector = (desclog_ptr *) NTL0_ckalloc ((alignment_records -> dimension) * sizeof (desclog_ptr)); for (index = 0; index < alignment_records -> dimension; index++) desc_vector [index] = desc_scan; /* Traverse the list of top line requests and connect the vector entries */ /* with the right description request records */ for (desc_scan = top_templates; desc_scan != NULL; desc_scan = desc_scan -> next) { if (desc_scan -> number != ALL_LINES_CODE) desc_vector [(desc_scan -> number) - 1] = desc_scan; desc_scan -> number = 0; } /* Sweep through all the requests and forward them to the "raw processing" */ /* module, after the modification of the lines code to indicate the last */ /* vector entry that referred to that recod */ for (index = 0; index < alignment_records -> dimension; index++) { if (RAWS_Top_Line (index + 1, (desc_vector [index]) -> number, (desc_vector [index]) -> contents, (desc_vector [index]) -> tick_distance, (desc_vector [index]) -> inline_text, (desc_vector [index]) -> text_repeat) < 0) { CONT_