📄 block_align.cpp
字号:
return STRUCT_DP_ALGORITHM_ERROR; } return STRUCT_DP_FOUND_ALIGNMENT;}END_SCOPE(struct_dp)// leave the C-called functions outside any namespace, just in case that might// cause any problems when linking to C code...USING_SCOPE(struct_dp);int DP_GlobalBlockAlign( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_GlobalBlockAlign() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } unsigned int i, sumBlockLen = 0; for (i=0; i<blocks->nBlocks; ++i) sumBlockLen += blocks->blockSizes[i]; if (sumBlockLen > queryTo - queryFrom + 1) { ERROR_MESSAGE("DP_GlobalBlockAlign() - sum of block lengths longer than query region"); return STRUCT_DP_PARAMETER_ERROR; } int status = ValidateFrozenBlockPositions(blocks, queryFrom, queryTo, true); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlign() - ValidateFrozenBlockPositions() returned error"); return status; } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); status = CalculateGlobalMatrix(matrix, blocks, BlockScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlign() - CalculateGlobalMatrix() failed"); return status; } return TracebackGlobalAlignment(matrix, blocks, queryFrom, queryTo, alignment);}int DP_GlobalBlockAlignGeneric( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, DP_LoopPenaltyFunction LoopScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || queryTo < queryFrom || !BlockScore || !LoopScore) { ERROR_MESSAGE("DP_GlobalBlockAlignGeneric() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } unsigned int i, sumBlockLen = 0; for (i=0; i<blocks->nBlocks; ++i) sumBlockLen += blocks->blockSizes[i]; if (sumBlockLen > queryTo - queryFrom + 1) { ERROR_MESSAGE("DP_GlobalBlockAlignGeneric() - sum of block lengths longer than query region"); return STRUCT_DP_PARAMETER_ERROR; } int status = ValidateFrozenBlockPositions(blocks, queryFrom, queryTo, false); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlignGeneric() - ValidateFrozenBlockPositions() returned error"); return status; } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); status = CalculateGlobalMatrixGeneric(matrix, blocks, BlockScore, LoopScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlignGeneric() - CalculateGlobalMatrixGeneric() failed"); return status; } return TracebackGlobalAlignment(matrix, blocks, queryFrom, queryTo, alignment);}int DP_LocalBlockAlign( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_LocalBlockAlign() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_LocalBlockAlign() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrix(matrix, blocks, BlockScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_LocalBlockAlign() - CalculateLocalMatrix() failed"); return status; } return TracebackLocalAlignment(matrix, blocks, queryFrom, queryTo, alignment);}int DP_LocalBlockAlignGeneric( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, DP_LoopPenaltyFunction LoopScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_LocalBlockAlignGeneric() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_LocalBlockAlignGeneric() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrixGeneric(matrix, blocks, BlockScore, LoopScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_LocalBlockAlignGeneric() - CalculateLocalMatrixGeneric() failed"); return status; } return TracebackLocalAlignment(matrix, blocks, queryFrom, queryTo, alignment);}int DP_MultipleLocalBlockAlign( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_MultipleAlignmentResults **alignments, unsigned int maxAlignments){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_MultipleLocalBlockAlign() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_MultipleLocalBlockAlign() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrix(matrix, blocks, BlockScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_MultipleLocalBlockAlign() - CalculateLocalMatrix() failed"); return status; } return TracebackMultipleLocalAlignments(matrix, blocks, queryFrom, queryTo, alignments, maxAlignments);}int DP_MultipleLocalBlockAlignGeneric( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, DP_LoopPenaltyFunction LoopScore, unsigned int queryFrom, unsigned int queryTo, DP_MultipleAlignmentResults **alignments, unsigned int maxAlignments){ if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrixGeneric(matrix, blocks, BlockScore, LoopScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - CalculateLocalMatrixGeneric() failed"); return status; } return TracebackMultipleLocalAlignments(matrix, blocks, queryFrom, queryTo, alignments, maxAlignments);}DP_BlockInfo * DP_CreateBlockInfo(unsigned int nBlocks){ DP_BlockInfo *blocks = new DP_BlockInfo; blocks->nBlocks = nBlocks; blocks->blockPositions = new unsigned int[nBlocks]; blocks->blockSizes = new unsigned int[nBlocks]; blocks->maxLoops = new unsigned int[nBlocks - 1]; blocks->freezeBlocks = new unsigned int[nBlocks]; for (unsigned int i=0; i<nBlocks; ++i) blocks->freezeBlocks[i] = DP_UNFROZEN_BLOCK; return blocks;}void DP_DestroyBlockInfo(DP_BlockInfo *blocks){ if (!blocks) return; delete[] blocks->blockPositions; delete[] blocks->blockSizes; delete[] blocks->maxLoops; delete[] blocks->freezeBlocks; delete blocks;}void DP_DestroyAlignmentResult(DP_AlignmentResult *alignment){ if (!alignment) return; delete[] alignment->blockPositions; delete alignment;}void DP_DestroyMultipleAlignmentResults(DP_MultipleAlignmentResults *alignments){ if (!alignments) return; for (unsigned int i=0; i<alignments->nAlignments; ++i) if (alignments->alignments[i].blockPositions) delete[] alignments->alignments[i].blockPositions; delete[] alignments->alignments; delete alignments;}unsigned int DP_CalculateMaxLoopLength( unsigned int nLoops, const unsigned int *loops, double percentile, unsigned int extension, unsigned int cutoff){ vector < unsigned int > loopLengths(nLoops); unsigned int index, max; for (index=0; index<nLoops; ++index) loopLengths[index] = loops[index]; stable_sort(loopLengths.begin(), loopLengths.end()); if (percentile < 1.0) { index = (unsigned int)(percentile * (nLoops - 1) + 0.5); max = loopLengths[index] + extension; } else { // percentile >= 1.0 max = ((unsigned int)(percentile * loopLengths[nLoops - 1] + 0.5)) + extension; } if (cutoff > 0 && max > cutoff) max = cutoff; return max;}/** ---------------------------------------------------------------------------* $Log: block_align.cpp,v $* Revision 1000.2 2004/06/01 18:11:09 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.20** Revision 1.20 2004/05/21 21:41:04 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.19 2004/03/15 18:54:57 thiessen* prefer prefix vs. postfix ++/-- operators** Revision 1.18 2004/02/19 02:21:19 thiessen* fix struct_dp paths** Revision 1.17 2003/12/19 14:37:50 thiessen* add local generic loop function alignment routines** Revision 1.16 2003/12/08 16:33:58 thiessen* fix signed/unsigned mix** Revision 1.15 2003/12/08 16:21:35 thiessen* add generic loop scoring function interface** Revision 1.14 2003/09/07 01:11:25 thiessen* fix small memory leak** Revision 1.13 2003/09/07 00:06:19 thiessen* add multiple tracebacks for local alignments** Revision 1.12 2003/08/23 22:10:05 thiessen* fix local alignment block edge bug** Revision 1.11 2003/08/22 14:28:49 thiessen* add standard loop calculating function** Revision 1.10 2003/08/19 19:36:48 thiessen* avoid annoying 'might be used uninitialized' warnings** Revision 1.9 2003/08/19 19:26:21 thiessen* error if block size > query range length** Revision 1.8 2003/07/11 15:27:48 thiessen* add DP_ prefix to globals** Revision 1.7 2003/06/22 12:18:16 thiessen* fixes for unsigned/signed comparison** Revision 1.6 2003/06/22 12:11:37 thiessen* add local alignment** Revision 1.5 2003/06/19 13:48:23 thiessen* cosmetic/typo fixes** Revision 1.4 2003/06/18 21:55:15 thiessen* remove unused params** Revision 1.3 2003/06/18 21:46:09 thiessen* add traceback, alignment return structure** Revision 1.2 2003/06/18 19:10:17 thiessen* fix lf issues** Revision 1.1 2003/06/18 16:54:12 thiessen* initial checkin; working global block aligner and demo app**/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -