/*****************************************************************************/ /* */ /* UNIT: NTL3_Abs_Corres_1 (Level 3 library routine) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 20 JUL 94 Version 1.0 */ /* */ /* Function: */ /* */ /* Procedure determines the absolute alignment offset for a position, */ /* given by some origin and offset with respect to it; 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_Corres_1 */ /* */ /* Central procedure for the unit; returns NULL if the absolute position */ /* has been found and set of corresponding absolute positions allocated, */ /* error diagnostics structure otherwise */ errind NTL3_Abs_Corres_1 (char *reference, long int offset, char *origins_file, char *alignment_file, int_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_Corres_1 (reference, offset, origins, file_data, alignment, result); }