Slice Tools libSlice |
Slice.hGo to the documentation of this file.00001 00002 // $Id: Slice.h,v 1.1 2005/07/29 02:55:17 mschatz Exp $ 00003 00012 #ifndef SLICE_H 00013 #define SLICE_H 1 00014 00021 00022 00024 #define HIGH_QUALITY_THRESHOLD 30 00025 00027 #define MIN_QUALITY_VALUE 1 00028 00030 #define GAP_QUALITY_VALUE_EMPTY_SLICE 1 00031 00032 00034 00039 #define MAX_QUALITY_VALUE 4000 00040 00041 #ifdef __cplusplus 00042 extern "C" 00043 { 00044 #endif 00045 00047 struct libSlice_Slice 00048 { 00050 char * bc; 00051 00053 char * qv; 00054 00056 char * rc; 00057 00059 char c; 00060 00062 00063 unsigned short dcov; 00064 }; 00065 typedef struct libSlice_Slice libSlice_Slice; 00066 00068 #define AMBIGUITY_FLAGBIT_A 0x1 00069 00071 #define AMBIGUITY_FLAGBIT_C 0x2 00072 00074 #define AMBIGUITY_FLAGBIT_G 0x4 00075 00077 #define AMBIGUITY_FLAGBIT_T 0x8 00078 00080 #define AMBIGUITY_FLAGBIT_GAP 0x10 00081 00083 struct libSlice_Consensus 00084 { 00086 unsigned int qvA; 00088 unsigned int qvC; 00090 unsigned int qvG; 00092 unsigned int qvT; 00094 unsigned int qvGap; 00095 00097 unsigned int qvConsensus; 00099 char consensus; 00100 00102 char ambiguityFlags; 00103 00104 long double cpA, cpC, cpG, cpT, cpGap; 00105 }; 00106 00107 typedef struct libSlice_Consensus libSlice_Consensus; 00108 00109 00111 struct libSlice_BaseDistribution 00112 { 00114 double freqA; 00116 double freqC; 00118 double freqG; 00120 double freqT; 00122 double freqGap; 00123 }; 00124 typedef struct libSlice_BaseDistribution libSlice_BaseDistribution; 00125 00126 #define MAX_SCORING_MODEL 4 00127 00128 00133 00134 // Set if empty slices should be recalled (to gap) or not 00135 void libSlice_setRecallEmpty(int recallEmpty); 00136 00137 // Internal function: Calculates the consensus and consensus quality 00138 // values for a single slice 00139 int libSlice_getConsensusParam(const libSlice_Slice * s, 00140 libSlice_Consensus * result, 00141 const libSlice_BaseDistribution * dist, 00142 int highQualityThreshold, 00143 int doAmbiguity); 00144 00145 // Updates the ambiguity flags using the conic model and scoring matrix 00146 int libSlice_updateAmbiguityConic(const libSlice_Slice * s, 00147 libSlice_Consensus * consensus, 00148 int highQuality); 00149 00150 00151 // Update the ambiguity flags with all high quality reads 00152 int libSlice_updateAmbiguity(const libSlice_Slice * s, 00153 libSlice_Consensus * consensus, 00154 int highQualityThreshold); 00155 00156 // Wrapper to calculate the consensus and consensus quality values 00157 // for a range of slices without using ambiguity codes 00158 int libSlice_getConsensus(const libSlice_Slice * s, 00159 libSlice_Consensus * results, 00160 const libSlice_BaseDistribution * dist, 00161 int highQualityThreshold); 00162 00163 // Wrapper to calculate the consensus and consensus quality values 00164 // for a range of slices with using ambiguity codes 00165 int libSlice_getConsensusWithAmbiguity(const libSlice_Slice * s, 00166 libSlice_Consensus * results, 00167 const libSlice_BaseDistribution * dist, 00168 int highQualityThreshold); 00170 00175 00176 // Internal function: Calculates the consensus and consensus quality 00177 // values for an array of slices 00178 int libSlice_getConsensusRangeParam(const libSlice_Slice s[], 00179 libSlice_Consensus results[], 00180 int len, 00181 const libSlice_BaseDistribution * dist, 00182 int highQualityThreshold, 00183 int doAmbiguity); 00184 00185 // Calculates the consensus of an array of slice with no ambiguity codes 00186 int libSlice_getConsensusRange(const libSlice_Slice s[], 00187 libSlice_Consensus results[], 00188 int len, 00189 const libSlice_BaseDistribution * dist, 00190 int highQualityThreshold); 00191 00192 // Calculates the consensus of an array of slice with ambiguity codes 00193 int libSlice_getConsensusRangeWithAmbiguity(const libSlice_Slice s[], 00194 libSlice_Consensus results[], 00195 int len, 00196 const libSlice_BaseDistribution * dist, 00197 int highQualityThreshold); 00198 00200 00205 00206 // Calculates the consensus quality class for a single slice 00207 char libSlice_getConsQC(const libSlice_Slice * s, int highQualityThreshold); 00208 00209 // Calculates consensus quality classes for a range of slices 00210 char * libSlice_getConsQCRange(const libSlice_Slice s[], 00211 int len, 00212 int highQualityThreshold); 00213 00215 00220 00221 // Calculate IUPAC ambiguity code based on error probabilities 00222 char libSlice_getAmbiguityCode(long double cpA, 00223 long double cpC, 00224 long double cpG, 00225 long double cpT, 00226 long double cpGap, 00227 int highQualityThreshold, 00228 int baseCount); 00229 00230 // Calculate error probabilities with a threshold into ambiguity flags 00231 char libSlice_calculateAmbiguityFlags(long double cpA, 00232 long double cpC, 00233 long double cpG, 00234 long double cpT, 00235 long double cpGap, 00236 int highQualityThreshold, 00237 int baseCount); 00238 00239 00240 // Converts a character with 5 bit flags into IUPAC Ambiguity Code 00241 char libSlice_convertAmbiguityFlags(char ambiguityFlags); 00242 00244 00245 00250 00251 // Get the compliment of a base or ambiguity code 00252 char libSlice_getCompliment(char base); 00253 00254 // Get a version string 00255 const char * libSlice_getVersion(); 00256 00257 00258 00260 00269 void * libSlice_newmem(int number, int size); 00270 00272 00274 00275 #ifdef __cplusplus 00276 } 00277 #endif 00278 00279 #endif 00280 |