1 #ifndef DYNAMITEcompmatHEADERFILE 2 #define DYNAMITEcompmatHEADERFILE 3 #ifdef _cplusplus 4 extern "C" { 5 #endif 6 #include "wisebase.h" 7 #include "probability.h" 8 #include "randommodel.h" 9 10 11 #define CompMat_AAMATCH(comp_mat,aa1,aa2) (comp_mat->comp[aa1][aa2]) 12 /* Object CompProb 13 * 14 * Descrip: The probabilistic form of CompMat 15 * 16 * 17 */ 18 struct Wise2_CompProb { 19 int dynamite_hard_link; 20 #ifdef PTHREAD 21 pthread_mutex_t dynamite_mutex; 22 #endif 23 Probability comp[26][26]; 24 char * name; 25 } ; 26 /* CompProb defined */ 27 #ifndef DYNAMITE_DEFINED_CompProb 28 typedef struct Wise2_CompProb Wise2_CompProb; 29 #define CompProb Wise2_CompProb 30 #define DYNAMITE_DEFINED_CompProb 31 #endif 32 33 34 /* Object CompMat 35 * 36 * Descrip: This object stores BLOSUM and PAM 37 * comparison matrices. It stores them as 38 * scores: NB - this means probabilistically 39 * we are talking about some arbitary base of 40 * log which is really annoying. 41 * 42 * 43 */ 44 struct Wise2_CompMat { 45 int dynamite_hard_link; 46 #ifdef PTHREAD 47 pthread_mutex_t dynamite_mutex; 48 #endif 49 Score comp[26][26]; 50 char * name; /* if any, could be NULL */ 51 } ; 52 /* CompMat defined */ 53 #ifndef DYNAMITE_DEFINED_CompMat 54 typedef struct Wise2_CompMat Wise2_CompMat; 55 #define CompMat Wise2_CompMat 56 #define DYNAMITE_DEFINED_CompMat 57 #endif 58 59 60 61 62 /***************************************************/ 63 /* Callable functions */ 64 /* These are the functions you are expected to use */ 65 /***************************************************/ 66 67 68 69 /* Function: simple_CompProb(match,rnd) 70 * 71 * Descrip: Makes a simple CompProb matrix 72 * 73 * 74 * Arg: match [UNKN ] Undocumented argument [Probability] 75 * Arg: rnd [UNKN ] Undocumented argument [Probability] 76 * 77 * Return [UNKN ] Undocumented return value [CompProb *] 78 * 79 */ 80 CompProb * Wise2_simple_CompProb(Probability match,Probability rnd); 81 #define simple_CompProb Wise2_simple_CompProb 82 83 84 /* Function: fold_column_RandomModel_CompProb(cp,rm) 85 * 86 * Descrip: Folds a random model in over the columns 87 * 88 * 89 * Arg: cp [UNKN ] Undocumented argument [CompProb *] 90 * Arg: rm [UNKN ] Undocumented argument [RandomModel *] 91 * 92 */ 93 void Wise2_fold_column_RandomModel_CompProb(CompProb * cp,RandomModel * rm); 94 #define fold_column_RandomModel_CompProb Wise2_fold_column_RandomModel_CompProb 95 96 97 /* Function: simple_aa_CompProb(match,set,rnd) 98 * 99 * Descrip: Makes a simple CompProb with simple aa rules 100 * 101 * 102 * Arg: match [UNKN ] Undocumented argument [Probability] 103 * Arg: set [UNKN ] Undocumented argument [Probability] 104 * Arg: rnd [UNKN ] Undocumented argument [Probability] 105 * 106 * Return [UNKN ] Undocumented return value [CompProb *] 107 * 108 */ 109 CompProb * Wise2_simple_aa_CompProb(Probability match,Probability set,Probability rnd); 110 #define simple_aa_CompProb Wise2_simple_aa_CompProb 111 112 113 /* Function: CompMat_from_CompProb(cp) 114 * 115 * Descrip: Maps a CompProb to a CompMat going through 116 * Probability2Score 117 * 118 * 119 * Arg: cp [UNKN ] Undocumented argument [CompProb *] 120 * 121 * Return [UNKN ] Undocumented return value [CompMat *] 122 * 123 */ 124 CompMat * Wise2_CompMat_from_CompProb(CompProb * cp); 125 #define CompMat_from_CompProb Wise2_CompMat_from_CompProb 126 127 128 /* Function: CompProb_from_halfbit(cm) 129 * 130 * Descrip: Maps a halfbit matrix to a prob matrix by rebasing 131 * etc. 132 * 133 * *Really* not sensible! 134 * 135 * 136 * Arg: cm [UNKN ] Undocumented argument [CompMat *] 137 * 138 * Return [UNKN ] Undocumented return value [CompProb *] 139 * 140 */ 141 CompProb * Wise2_CompProb_from_halfbit(CompMat * cm); 142 #define CompProb_from_halfbit Wise2_CompProb_from_halfbit 143 144 145 /* Function: CompMat_from_halfbit(cm) 146 * 147 * Descrip: flips a halfbit based matrix (eg, blosum62) into a score 148 * based matrix just by rebasing the log etc. 149 * 150 * Not a sensible function ... 151 * 152 * 153 * 154 * Arg: cm [UNKN ] Undocumented argument [CompMat *] 155 * 156 * Return [UNKN ] Undocumented return value [CompMat *] 157 * 158 */ 159 CompMat * Wise2_CompMat_from_halfbit(CompMat * cm); 160 #define CompMat_from_halfbit Wise2_CompMat_from_halfbit 161 162 163 /* Function: factor_CompMat(cm,factor) 164 * 165 * Descrip: multiples all the scores by the amount 166 * 167 * 168 * Arg: cm [UNKN ] compmat object [CompMat *] 169 * Arg: factor [UNKN ] amount to multiple by [int] 170 * 171 */ 172 void Wise2_factor_CompMat(CompMat * cm,int factor); 173 #define factor_CompMat Wise2_factor_CompMat 174 175 176 /* Function: fail_safe_CompMat_access(cm,aa1,aa2) 177 * 178 * Descrip: gives the fail form of the macro CompMat_AAMATCH which 179 * checks that aa1 and a2 are sensible and that cm is not NULL. 180 * 181 * 182 * Arg: cm [UNKN ] compmat object [CompMat *] 183 * Arg: aa1 [UNKN ] first amino acid [int] 184 * Arg: aa2 [UNKN ] second amino acid [int] 185 * 186 * Return [UNKN ] Undocumented return value [Score] 187 * 188 */ 189 Score Wise2_fail_safe_CompMat_access(CompMat * cm,int aa1,int aa2); 190 #define fail_safe_CompMat_access Wise2_fail_safe_CompMat_access 191 192 193 /* Function: write_Blast_CompMat(cm,ofp) 194 * 195 * Descrip: writes a protien CompMat with a standard 196 * alphabet. 197 * 198 * 199 * Arg: cm [UNKN ] CompMat object [CompMat *] 200 * Arg: ofp [UNKN ] file to output [FILE *] 201 * 202 * Return [UNKN ] Undocumented return value [boolean] 203 * 204 */ 205 boolean Wise2_write_Blast_CompMat(CompMat * cm,FILE * ofp); 206 #define write_Blast_CompMat Wise2_write_Blast_CompMat 207 208 209 /* Function: write_Blast_CompMat_alphabet(cm,alphabet,ofp) 210 * 211 * Descrip: actualy writes out the Blast CFormat. The alphabet is 212 * what order you want the amino acids. If you want the 213 * standard format use /write_Blast_CompMat 214 * 215 * 216 * Arg: cm [UNKN ] comp mat object [CompMat *] 217 * Arg: alphabet [UNKN ] string for alphabet to be used [char *] 218 * Arg: ofp [UNKN ] fileoutput [FILE *] 219 * 220 * Return [UNKN ] Undocumented return value [boolean] 221 * 222 */ 223 boolean Wise2_write_Blast_CompMat_alphabet(CompMat * cm,char * alphabet,FILE * ofp); 224 #define write_Blast_CompMat_alphabet Wise2_write_Blast_CompMat_alphabet 225 226 227 /* Function: read_Blast_file_CompMat(filename) 228 * 229 * Descrip: Opens file, reads matrix, closes file. 230 * calls /read_Blast_CompMat for the actual format 231 * reading. Uses /openfile to open the file, 232 * so will open from config files. 233 * 234 * 235 * Arg: filename [UNKN ] Undocumented argument [char *] 236 * 237 * Return [UNKN ] Undocumented return value [CompMat *] 238 * 239 */ 240 CompMat * Wise2_read_Blast_file_CompMat(char * filename); 241 #define read_Blast_file_CompMat Wise2_read_Blast_file_CompMat 242 243 244 /* Function: read_Blast_CompMat(ifp) 245 * 246 * Descrip: reads a BLAST format matrix and 247 * allocates a new ComMat structure. 248 * 249 * 250 * Arg: ifp [UNKN ] Undocumented argument [FILE *] 251 * 252 * Return [UNKN ] Undocumented return value [CompMat *] 253 * 254 */ 255 CompMat * Wise2_read_Blast_CompMat(FILE * ifp); 256 #define read_Blast_CompMat Wise2_read_Blast_CompMat 257 258 259 /* Function: read_Blast_file_CompProb(filename) 260 * 261 * Descrip: Reads a BLAST format comp prob from file 262 * 263 * 264 * Arg: filename [UNKN ] Undocumented argument [char *] 265 * 266 * Return [UNKN ] Undocumented return value [CompProb *] 267 * 268 */ 269 CompProb * Wise2_read_Blast_file_CompProb(char * filename); 270 #define read_Blast_file_CompProb Wise2_read_Blast_file_CompProb 271 272 273 /* Function: read_Blast_CompProb(ifp) 274 * 275 * Descrip: reads a BLAST format matrix and 276 * allocates a new CompProb structure. 277 * 278 * 279 * Arg: ifp [READ ] file input [FILE *] 280 * 281 * Return [UNKN ] newly allocated CompProb [CompProb *] 282 * 283 */ 284 CompProb * Wise2_read_Blast_CompProb(FILE * ifp); 285 #define read_Blast_CompProb Wise2_read_Blast_CompProb 286 287 288 /* Function: blank_CompMat(void) 289 * 290 * Descrip: makes a 0,0 matrix 291 * 292 * 293 * 294 * Return [UNKN ] Undocumented return value [CompMat *] 295 * 296 */ 297 CompMat * Wise2_blank_CompMat(void); 298 #define blank_CompMat Wise2_blank_CompMat 299 300 301 /* Function: blank_CompProb(void) 302 * 303 * Descrip: makes a 1.0 prob matrix 304 * 305 * 306 * 307 * Return [UNKN ] Undocumented return value [CompProb *] 308 * 309 */ 310 CompProb * Wise2_blank_CompProb(void); 311 #define blank_CompProb Wise2_blank_CompProb 312 313 314 /* Function: hard_link_CompProb(obj) 315 * 316 * Descrip: Bumps up the reference count of the object 317 * Meaning that multiple pointers can 'own' it 318 * 319 * 320 * Arg: obj [UNKN ] Object to be hard linked [CompProb *] 321 * 322 * Return [UNKN ] Undocumented return value [CompProb *] 323 * 324 */ 325 CompProb * Wise2_hard_link_CompProb(CompProb * obj); 326 #define hard_link_CompProb Wise2_hard_link_CompProb 327 328 329 /* Function: CompProb_alloc(void) 330 * 331 * Descrip: Allocates structure: assigns defaults if given 332 * 333 * 334 * 335 * Return [UNKN ] Undocumented return value [CompProb *] 336 * 337 */ 338 CompProb * Wise2_CompProb_alloc(void); 339 #define CompProb_alloc Wise2_CompProb_alloc 340 341 342 /* Function: free_CompProb(obj) 343 * 344 * Descrip: Free Function: removes the memory held by obj 345 * Will chain up to owned members and clear all lists 346 * 347 * 348 * Arg: obj [UNKN ] Object that is free'd [CompProb *] 349 * 350 * Return [UNKN ] Undocumented return value [CompProb *] 351 * 352 */ 353 CompProb * Wise2_free_CompProb(CompProb * obj); 354 #define free_CompProb Wise2_free_CompProb 355 356 357 /* Function: hard_link_CompMat(obj) 358 * 359 * Descrip: Bumps up the reference count of the object 360 * Meaning that multiple pointers can 'own' it 361 * 362 * 363 * Arg: obj [UNKN ] Object to be hard linked [CompMat *] 364 * 365 * Return [UNKN ] Undocumented return value [CompMat *] 366 * 367 */ 368 CompMat * Wise2_hard_link_CompMat(CompMat * obj); 369 #define hard_link_CompMat Wise2_hard_link_CompMat 370 371 372 /* Function: CompMat_alloc(void) 373 * 374 * Descrip: Allocates structure: assigns defaults if given 375 * 376 * 377 * 378 * Return [UNKN ] Undocumented return value [CompMat *] 379 * 380 */ 381 CompMat * Wise2_CompMat_alloc(void); 382 #define CompMat_alloc Wise2_CompMat_alloc 383 384 385 /* Function: free_CompMat(obj) 386 * 387 * Descrip: Free Function: removes the memory held by obj 388 * Will chain up to owned members and clear all lists 389 * 390 * 391 * Arg: obj [UNKN ] Object that is free'd [CompMat *] 392 * 393 * Return [UNKN ] Undocumented return value [CompMat *] 394 * 395 */ 396 CompMat * Wise2_free_CompMat(CompMat * obj); 397 #define free_CompMat Wise2_free_CompMat 398 399 400 /* Unplaced functions */ 401 /* There has been no indication of the use of these functions */ 402 403 404 /***************************************************/ 405 /* Internal functions */ 406 /* you are not expected to have to call these */ 407 /***************************************************/ 408 boolean Wise2_replace_name_CompMat(CompMat * obj,char * name); 409 #define replace_name_CompMat Wise2_replace_name_CompMat 410 char * Wise2_access_name_CompMat(CompMat * obj); 411 #define access_name_CompMat Wise2_access_name_CompMat 412 boolean Wise2_bad_CompMat_alphabet(char * al); 413 #define bad_CompMat_alphabet Wise2_bad_CompMat_alphabet 414 415 #ifdef _cplusplus 416 } 417 #endif 418 419 #endif 420