/*****************************************************************************/ /* */ /* UNIT: NTL1_Consensus_Sequence (Level 1 library routine) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 25 JUL 97 Version 1.0 */ /* */ /* Function: */ /* */ /* Procedure decides the consensus sequence for the entire received */ /* alignment, based on the majority occurence of characters in any of its */ /* columns and guidelines about the treatment of gaps; returns the pointer */ /* to the consensus sequence */ /* */ /*****************************************************************************/ #include #include #include "ntl1.h" /*****************************************************************************/ char *NTL1_Consensus_Sequence (restricted_ptr alignment, int gaps_treatment) { char *consensus, *column; long int position, index; int row; consensus = (char *) NTL0_ckalloc (((alignment -> size) + 1) * sizeof (char)); consensus [alignment -> size] = '\0'; column = (char *) NTL0_ckalloc (((alignment -> dimension) + 1) * sizeof (char)); column [alignment -> dimension] = '\0'; for (position = 0; position < alignment -> size; position++) { index = 0; for (row = 0; row < alignment -> dimension; row++) { if (((alignment -> starts) [row] <= position) && ((alignment -> stops) [row] >= position)) { column [index++] = (alignment -> texts) [row] [position]; } } column [index] = '\0'; consensus [position] = NTL1_Consensus_Column (column, index, gaps_treatment); } free (column); return consensus; }