/*****************************************************************************/ /* */ /* UNIT: NTL3_Abs_Corres_2 (Level 3 library routine) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 16 JUL 94 Version 1.0 */ /* */ /* Function: */ /* */ /* Procedure determines the set of pairs of absolute alignment offsets for */ /* a pair of positions, given by some origin and offsets 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_2 */ /* */ /* Central procedure for the unit; returns NULL if the absolute positions */ /* have been found and set of such pairs allocated, error diagnostics */ /* structure otherwise */ errind NTL3_Abs_Corres_2 (char *reference, long int offset_1, long int offset_2, char *origins_file, char *alignment_file, twoint_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; } /* 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; } } /* Now when it is guaranteed that both origins and alignments are loaded, */ /* proceed to identify the coresponding positions */ return NTL1_Abs_Corres_2 (reference, offset_1, offset_2, origins, file_data, alignment, result); }