/*****************************************************************************/ /* */ /* UNIT: NTL3_Abs_Spec (Level 3 library routine) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 17 DEC 94 Version 1.0 */ /* */ /* Function: */ /* */ /* Procedure determines new offset (relative to the new origin) of a */ /* "absolute" position (with respect to the alignment); file names for both */ /* the "origins" and "alignment" files are provided as input parameters; */ /* returns the standard error structure, NULL if there were no errors */ /* */ /*****************************************************************************/ #include #include #include #include "ntl3.h" /*****************************************************************************/ /* */ /* Definitions section */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* Definitions of global (static) variables of the unit */ /*****************************************************************************/ static int origins_loaded = 0; /* Before first invocation, no origins loaded */ static int alignment_loaded = 0; /* No alignment initially loaded */ static header_ptr file_data = NULL; /* Contents of the alignment file */ static align_ptr alignment = NULL; /* Partially unpacked alignment */ static orgref_ptr origins = NULL; /* List of defined origins in sequences */ /*****************************************************************************/ /* */ /* Code section */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* */ /* PROCEDURE: NTL3_Abs_Spec */ /* */ /* Central procedure for the unit; returns NULL if there were no errors in */ /* determining the corresponding position, error diagnostics structure */ /* otherwise */ errind NTL3_Abs_Spec (long int position, char *origin, char *origins_file, char *alignment_file, appint_ptr *result) { errind load_status; /* Check whether this is the first invocation of this routine - if it is, */ /* then load the origins file into internal structure */ if (origins_loaded == 0) { /* This is the first invocation within program */ if ((load_status = NTL2_Load_Origins (origins_file, &origins)) != NULL) return load_status; else origins_loaded = 1; /* Record that origins structure is now loaded */ } /* Check whether the current alignment has already been loaded internally */ if (alignment_loaded == 0) { /* No alignment loaded yet */ /* Load the contents of the specified alignment file in appropriate format */ /* into internal structure first */ if ((load_status = NTL2_Load_AlignFile (alignment_file, &file_data)) != NULL) return load_status; else { /* Data from the file loaded, now partially expand alignment 1 */ if ((load_status = NTL1_Load_Alignment (1, file_data, &alignment)) != NULL) return load_status; else alignment_loaded = 1; /* Record that alignment data is now loaded */ } } /* Now when it is guaranteed that both origins and alignments are loaded, */ /* proceed to identify the coresponding position */ return NTL1_Abs_Spec (position, origin, origins, file_data, alignment, result); }