1 #ifndef _MUSCLE_CONTEXT_H_ 2 #define _MUSCLE_CONTEXT_H_ 3 4 #include "profile.h" 5 #include <limits.h> 6 #include <time.h> 7 #include <QVector> 8 9 #define EDGE_ARRAY_SIZE 10000 10 11 class MuscleException { 12 public: 13 MuscleException(); 14 MuscleException(const char* str); 15 char str[4096]; 16 }; 17 18 typedef int (*progress_printf)(FILE *str, const char *format, ...); 19 20 class MuscleContext { 21 public: 22 MuscleContext(int nTHreads ); 23 ~MuscleContext(); 24 25 void fillUidsVectors(int rowsCount); 26 27 int nThreads; 28 29 int *cancelFlag; 30 int cancelStub; isCanceled()31 bool isCanceled() const {return *cancelFlag;} 32 33 int *progressPercent; 34 int progressStub; 35 36 37 static const int MAX_HEADINGS = 32; 38 static const unsigned NULL_NEIGHBOR = UINT_MAX; 39 unsigned m_uIdCount; 40 41 QVector<unsigned> input_uIds; 42 QVector<unsigned> tmp_uIds; 43 QVector<unsigned> output_uIds; 44 45 struct intmath_struct { 46 bool bInit; 47 } intmath; 48 49 struct params_struct { 50 SCORE g_scoreGapOpen; 51 SCORE g_scoreCenter; 52 SCORE g_scoreGapExtend; 53 SCORE g_scoreGapAmbig; 54 55 PPSCORE g_PPScore; 56 OBJSCORE g_ObjScore; 57 58 DISTANCE g_Distance1; 59 CLUSTER g_Cluster1; 60 ROOT g_Root1; 61 SEQWEIGHT g_SeqWeight1; 62 63 DISTANCE g_Distance2; 64 CLUSTER g_Cluster2; 65 ROOT g_Root2; 66 SEQWEIGHT g_SeqWeight2; 67 68 69 const char *g_pstrInFileName; 70 const char *g_pstrOutFileName; 71 const char *g_pstrFASTAOutFileName; 72 const char *g_pstrMSFOutFileName; 73 const char *g_pstrClwOutFileName; 74 const char *g_pstrClwStrictOutFileName; 75 const char *g_pstrHTMLOutFileName; 76 const char *g_pstrPHYIOutFileName; 77 const char *g_pstrPHYSOutFileName; 78 const char *g_pstrDistMxFileName1; 79 const char *g_pstrDistMxFileName2; 80 81 const char *g_pstrFileName1; 82 const char *g_pstrFileName2; 83 84 const char *g_pstrSPFileName; 85 const char *g_pstrMatrixFileName; 86 87 const char *g_pstrUseTreeFileName; 88 89 bool g_bUseTreeNoWarn; 90 91 const char *g_pstrComputeWeightsFileName; 92 const char *g_pstrScoreFileName; 93 94 const char *g_pstrProf1FileName; 95 const char *g_pstrProf2FileName; 96 97 98 99 //#if DOUBLE_AFFINE 100 SCORE g_scoreGapOpen2; 101 SCORE g_scoreGapExtend2; 102 //#endif 103 104 unsigned g_uSmoothWindowLength; 105 unsigned g_uAnchorSpacing; 106 unsigned g_uMaxTreeRefineIters; 107 108 unsigned g_uMinDiagLength; 109 unsigned g_uMaxDiagBreak; 110 unsigned g_uDiagMargin; 111 112 unsigned g_uRefineWindow; 113 unsigned g_uWindowFrom; 114 unsigned g_uWindowTo; 115 unsigned g_uSaveWindow; 116 unsigned g_uWindowOffset; 117 118 unsigned g_uMaxSubFamCount; 119 120 unsigned g_uHydrophobicRunLength; 121 float g_dHydroFactor; 122 123 float g_dSmoothScoreCeil; 124 float g_dMinBestColScore; 125 float g_dMinSmoothScore; 126 float g_dSUEFF; 127 128 bool g_bPrecompiledCenter; 129 bool g_bNormalizeCounts; 130 bool g_bDiags1; 131 bool g_bDiags2; 132 bool g_bDiags; 133 bool g_bAnchors; 134 bool g_bCatchExceptions; 135 136 bool g_bMSF; 137 bool g_bAln; 138 bool g_bClwStrict; 139 bool g_bHTML; 140 bool g_bPHYI; 141 bool g_bPHYS; 142 143 bool g_bQuiet; 144 bool g_bVerbose; 145 bool g_bRefine; 146 bool g_bRefineW; 147 bool g_bRefineX; 148 bool g_bLow; 149 bool g_bSW; 150 bool g_bClusterOnly; 151 bool g_bProfile; 152 bool g_bProfDB; 153 bool g_bPPScore; 154 bool g_bBrenner; 155 bool g_bDimer; 156 bool g_bVersion; 157 bool g_bStable; 158 bool g_bFASTA; 159 bool g_bPAS; 160 bool g_bTomHydro; 161 bool g_bMakeTree; 162 163 unsigned g_uMaxIters; 164 unsigned long g_ulMaxSecs; 165 unsigned g_uMaxMB; 166 167 SEQTYPE g_SeqType; 168 TERMGAPS g_TermGaps; 169 170 PTR_SCOREMATRIX g_ptrScoreMatrix; 171 SCORE g_scoreAmbigFactor; 172 } params; 173 174 175 //alpha.cpp 176 struct alpha_struct { 177 unsigned g_CharToLetter[MAX_CHAR]; 178 unsigned g_CharToLetterEx[MAX_CHAR]; 179 char g_LetterToChar[MAX_ALPHA]; 180 char g_LetterExToChar[MAX_ALPHA_EX]; 181 char g_UnalignChar[MAX_CHAR]; 182 char g_AlignChar[MAX_CHAR]; 183 bool g_IsWildcardChar[MAX_CHAR]; 184 bool g_IsResidueChar[MAX_CHAR]; 185 ALPHA g_Alpha; 186 unsigned g_AlphaSize; 187 char InvalidLetters[256]; 188 int InvalidLetterCount; 189 } alpha; 190 191 //muscle.h 192 struct muscle_struct { 193 int g_argc; 194 char **g_argv; 195 unsigned g_uTreeSplitNode1; 196 unsigned g_uTreeSplitNode2; 197 //double g_dNAN; 198 unsigned long g_tStart; 199 } muscle; 200 201 /* 202 //profile.h 203 struct profile_struct { 204 unsigned *ResidueGroup; 205 } profile; 206 */ 207 //nwdasimple.cpp 208 struct nwdasimple_struct { 209 bool g_bKeepSimpleDP; 210 SCORE *g_DPM; 211 SCORE *g_DPD; 212 SCORE *g_DPE; 213 SCORE *g_DPI; 214 SCORE *g_DPJ; 215 char *g_TBM; 216 char *g_TBD; 217 char *g_TBE; 218 char *g_TBI; 219 char *g_TBJ; 220 } nwdasimple; 221 222 //ppscore.cpp 223 struct ppscore_struct { 224 bool g_bTracePPScore; 225 MSA *g_ptrPPScoreMSA1; 226 MSA *g_ptrPPScoreMSA2; 227 } ppscore; 228 229 //scoredist.cpp 230 struct scoredist_struct { 231 int BLOSUM62[20][20]; 232 double BLOSUM62_Expected; 233 } scoredist; 234 235 //objscore2.cpp 236 struct objscore2_struct { 237 SCORE g_SPScoreLetters; 238 SCORE g_SPScoreGaps; 239 } objscore2; 240 241 //nwsmalls[workerID].cpp 242 struct nwsmall_struct { 243 unsigned uCachePrefixCountB; 244 unsigned uCachePrefixCountA; 245 SCORE *CacheMCurr; 246 SCORE *CacheMNext; 247 SCORE *CacheMPrev; 248 SCORE *CacheDRow; 249 char **CacheTB; 250 } *nwsmalls; 251 252 //fastdistnuc.cpp 253 struct fastdistnuc_struct { 254 static const unsigned TUPLE_COUNT = 6*6*6*6*6*6; 255 unsigned char Count1[TUPLE_COUNT]; 256 unsigned char Count2[TUPLE_COUNT]; 257 } fastdistnuc; 258 259 //fastdistmafft.cpp 260 struct fastdistmafft_struct { 261 static const unsigned TUPLE_COUNT = 6*6*6*6*6*6; 262 unsigned char Count1[TUPLE_COUNT]; 263 unsigned char Count2[TUPLE_COUNT]; 264 } fastdistmafft; 265 266 //glbalignsp.cpp 267 struct glbalignsp_struct { 268 struct DP_MEMORY 269 { 270 unsigned uLength; 271 SCORE *GapOpenA; 272 SCORE *GapOpenB; 273 SCORE *GapCloseA; 274 SCORE *GapCloseB; 275 SCORE *MPrev; 276 SCORE *MCurr; 277 SCORE *MWork; 278 SCORE *DPrev; 279 SCORE *DCurr; 280 SCORE *DWork; 281 SCORE **ScoreMxB; 282 unsigned **SortOrderA; 283 unsigned *uDeletePos; 284 FCOUNT **FreqsA; 285 int **TraceBack; 286 } DPM; 287 } glbalignsp; 288 289 //glbalignspn.cpp 290 struct glbalignspn_struct { 291 struct DP_MEMORY 292 { 293 unsigned uLength; 294 SCORE *GapOpenA; 295 SCORE *GapOpenB; 296 SCORE *GapCloseA; 297 SCORE *GapCloseB; 298 SCORE *MPrev; 299 SCORE *MCurr; 300 SCORE *MWork; 301 SCORE *DPrev; 302 SCORE *DCurr; 303 SCORE *DWork; 304 SCORE **ScoreMxB; 305 unsigned **SortOrderA; 306 unsigned *uDeletePos; 307 FCOUNT **FreqsA; 308 int **TraceBack; 309 } DPM; 310 } glbalignspn; 311 312 //glbalihnss.cpp 313 struct glbalignss_struct { 314 struct DP_MEMORY 315 { 316 unsigned uLength; 317 SCORE *MPrev; 318 SCORE *MCurr; 319 SCORE *MWork; 320 SCORE *DPrev; 321 SCORE *DCurr; 322 SCORE *DWork; 323 SCORE **MxRowA; 324 unsigned *LettersB; 325 unsigned *uDeletePos; 326 int **TraceBack; 327 } DPM; 328 } glbalignss; 329 330 //glbalignle.cpp 331 struct glbalignle_struct { 332 #define OCC 1 333 334 struct DP_MEMORY 335 { 336 unsigned uLength; 337 SCORE *GapOpenA; 338 SCORE *GapOpenB; 339 SCORE *GapCloseA; 340 SCORE *GapCloseB; 341 SCORE *MPrev; 342 SCORE *MCurr; 343 SCORE *MWork; 344 SCORE *DPrev; 345 SCORE *DCurr; 346 SCORE *DWork; 347 SCORE **ScoreMxB; 348 #if OCC 349 FCOUNT *OccA; 350 FCOUNT *OccB; 351 #endif 352 unsigned **SortOrderA; 353 unsigned *uDeletePos; 354 FCOUNT **FreqsA; 355 int **TraceBack; 356 } DPM; 357 } glbalignle; 358 359 //setnewhandler.cpp 360 struct setnewhandler_struct { 361 void *EmergencyReserve; 362 } setnewhandler; 363 364 //options.cpp 365 struct options_struct { 366 struct VALUE_OPT 367 { 368 const char *m_pstrName; 369 const char *m_pstrValue; 370 }; 371 372 373 struct FLAG_OPT 374 { 375 const char *m_pstrName; 376 bool m_bSet; 377 }; 378 VALUE_OPT *ValueOpts; 379 int ValueOptCount; 380 381 FLAG_OPT *FlagOpts; 382 int FlagOptCount; 383 } options; 384 //globals.cpp 385 struct globals_struct { 386 #ifndef MAX_PATH 387 #define MAX_PATH 260 388 #endif 389 char g_strListFileName[MAX_PATH]; 390 bool g_bListFileAppend; 391 SEQWEIGHT g_SeqWeight; 392 size_t g_MemTotal; 393 } globals; 394 395 //progress.cpp 396 struct progress_struct { 397 unsigned g_uIter; // Main MUSCLE iteration 1, 2.. 398 unsigned g_uLocalMaxIters; // Max iters 399 FILE *g_fProgress; // Default to standard error 400 progress_printf pr_printf; 401 char g_strFileName[32]; // File name 402 time_t g_tLocalStart; // Start time 403 char g_strDesc[32]; // Description 404 bool g_bWipeDesc; 405 int g_nPrevDescLength; 406 unsigned g_uTotalSteps; 407 408 } progress; 409 410 //scoregaps.cpp 411 struct scoregaps_struct { 412 struct GAPINFO 413 { 414 GAPINFO *Next; 415 unsigned Start; 416 unsigned End; 417 }; 418 419 GAPINFO **g_Gaps; 420 GAPINFO *g_FreeList; 421 unsigned g_MaxSeqCount; 422 unsigned g_MaxColCount; 423 unsigned g_ColCount; 424 bool *g_ColDiff; 425 } scoregaps; 426 427 //glbaligndiag.cpp 428 struct glbaligndiag_struct { 429 double g_dDPAreaWithoutDiags; 430 double g_dDPAreaWithDiags; 431 } glbaligndiag; 432 433 //upgma2.cpp 434 struct upgma2_struct { 435 unsigned g_uLeafCount; 436 unsigned g_uTriangleSize; 437 unsigned g_uInternalNodeCount; 438 unsigned g_uInternalNodeIndex; 439 typedef float dist_t; 440 dist_t *g_Dist; 441 dist_t *g_MinDist; 442 unsigned *g_uNearestNeighbor; 443 unsigned *g_uNodeIndex; 444 unsigned *g_uLeft; 445 unsigned *g_uRight; 446 dist_t *g_Height; 447 dist_t *g_LeftLength; 448 dist_t *g_RightLength; 449 } upgma2; 450 451 //msa2.cpp 452 struct msa2_struct { 453 const Tree *g_ptrMuscleTree; 454 WEIGHT *g_MuscleWeights; 455 unsigned g_uMuscleIdCount; 456 unsigned g_uTreeSplitNode1; 457 unsigned g_uTreeSplitNode2; 458 } msa2; 459 460 //validateids.cpp 461 struct validateids_struct { 462 #if DEBUG 463 SeqVect *g_ptrMuscleSeqVect; 464 MSA MuscleInputMSA; 465 #endif 466 unsigned g_uTreeSplitNode1; 467 unsigned g_uTreeSplitNode2; 468 } validateids; 469 470 //refinehoriz.cpp 471 struct refinehoriz_struct { 472 unsigned g_uRefineHeightSubtree; 473 unsigned g_uRefineHeightSubtreeTotal; 474 unsigned Edges1[EDGE_ARRAY_SIZE]; 475 unsigned Edges2[EDGE_ARRAY_SIZE]; 476 } refinehoriz; 477 478 //spfast.cpp 479 struct spfast_struct { 480 SCORE GapScoreMatrix[4][4]; 481 typedef SCORE SCORE44[4][4]; 482 typedef SCORE44 *ptrGapScoreMatrix; 483 bool bGapScoreMatrixInit; 484 } spfast; 485 486 //readmx.cpp 487 struct readmx_struct { 488 char Heading[MAX_HEADINGS]; 489 unsigned HeadingCount; 490 float Mx[32][32]; 491 } readmx; 492 493 //mhack.cpp 494 struct mhack_struct { 495 bool *M; 496 } mhack; 497 498 //glbalndimer.cpp 499 struct glbalndimer_stuct { 500 ProfPos PPTerm; 501 bool PPTermInitialized; 502 bool InitializePPTerm(); 503 } glbalndimer; 504 505 //subfams.cpp 506 struct subfams_struct { 507 float *ShortestPathEstimate; 508 unsigned *Predecessor; 509 } subfams; 510 511 //savebest.cpp 512 struct savebest_struct { 513 MSA *ptrBestMSA; 514 const char *pstrOutputFileName; 515 } savebest; 516 517 //enumtostr.cpp 518 struct enumtostr_struct { 519 char szMsg[64]; 520 } enumtostr; 521 522 //finddiags.cpp 523 struct finddiags_struct { 524 static const unsigned KTUP = 5; 525 static const unsigned KTUPS = 6*6*6*6*6; 526 unsigned TuplePos[KTUPS]; 527 } finddiags; 528 529 //finddiagsn.cpp 530 struct finddiagsn_struct { 531 #define pow4(i) (1 << (2*i)) // 4^i = 2^(2*i) 532 533 static const unsigned K = 7; 534 static const unsigned KTUPS = pow4(K); 535 unsigned TuplePos[KTUPS]; 536 } finddiagsn; 537 538 //globalswin32.cpp 539 struct globalswin32_struct { 540 unsigned uPeakMemUseBytes; 541 } globalswin32; 542 }; 543 544 extern MuscleContext *getMuscleContext(); 545 extern int getMuscleWorkerID(); 546 #endif //tasklocaldata_h 547