seqEntryCopy->Assign(seqEntry);
62SeqAnnotList::const_iterator
a, ae = seqAnnots.end();
63 for(
a=seqAnnots.begin();
a!=ae; ++
a) {
65seqAnnotCopy->Assign(**
a);
74SeqEntryList::const_iterator s, se = seqEntries.end();
75 for(s=seqEntries.begin(); s!=se; ++s) {
77seqEntryCopy->
Assign(**s);
81SeqAnnotList::const_iterator
a, ae = seqAnnots.end();
82 for(
a=seqAnnots.begin();
a!=ae; ++
a) {
128AlignmentSet::AlignmentList::const_iterator
a, ae = alignments.end();
129 for(
a=alignments.begin();
a!=ae; ++
a) {
139AlignmentSet::AlignmentList::const_iterator
a, ae = alignments.end();
140 for(
a=alignments.begin();
a!=ae; ++
a) {
141 if(((*a)->m_masterToSlave[masterTo] - (*a)->m_masterToSlave[masterFrom]) != (masterTo - masterFrom))
150AlignmentSet::AlignmentList::const_iterator
a, ae = alignments.end();
151 for(
a=alignments.begin();
a!=ae; ++
a) {
152 if((*a)->m_blockStructure[masterTo] != (*a)->m_blockStructure[masterFrom])
171AlignmentSet::AlignmentList::const_iterator
a, ae = alignments.end();
175BlockMultipleAlignment::SequenceList::iterator s = sequenceList.begin();
176*(s++) = alignments.front()->m_master;
177 for(
a=alignments.begin();
a!=ae; ++
a) {
178*(s++) = (*a)->m_slave;
179 if((*a)->m_master != sequenceList.front()) {
180 ERROR_MESSAGE(
"AlignmentUtility::DoIBM() - all pairwise alignments must have the same master sequence");
189 unsigned intmasterFrom = 0, masterTo,
row;
192 while(masterFrom < multipleAlignment->GetMaster()->Length()) {
203 for(masterTo=masterFrom+1;
204masterTo < multipleAlignment->GetMaster()->Length() &&
214newBlock->
m_width= masterTo - masterFrom + 1;
216 for(
a=alignments.begin(),
row=1;
a!=ae; ++
a, ++
row) {
218(*a)->m_masterToSlave[masterFrom],
219(*a)->m_masterToSlave[masterTo]);
223multipleAlignment->AddAlignedBlockAtEnd(newBlock);
226masterFrom = masterTo + 1;
229 if(!multipleAlignment->AddUnalignedBlocks() || !multipleAlignment->UpdateBlockMap()) {
230 ERROR_MESSAGE(
"AlignmentUtility::DoIBM() - error finalizing alignment");
265 unsigned introwToRealign,
conststd::vector < unsigned int >& blocksToRealign,
266 doublepercentile,
unsigned intextension,
unsigned intcutoff,
267 unsigned intqueryFrom,
unsigned intqueryTo)
275 if(
blocks.size() == 0) {
282 boolstatus =
false;
296 for(
b=0;
b<
blocks.size()-1; ++
b) {
298range =
blocks[
b]->GetRangeOfRow(
r);
299nextRange =
blocks[
b+ 1]->GetRangeOfRow(
r);
300loopLengths[
r] = nextRange->
from- range->
to- 1;
305 delete[] loopLengths;
310vector < unsigned int > rowsToRemove(1, rowToRealign);
318range =
blocks[
b]->GetRangeOfRow(0);
324 if(blocksToRealign.size() == 0)
326vector < bool > realignBlock(
blocks.size(),
false);
327 for(
r=0;
r<blocksToRealign.size(); ++
r) {
328 if(blocksToRealign[
r] <
blocks.size())
329realignBlock[blocksToRealign[
r]] =
true;
333toRealign.front()->GetUngappedAlignedBlocks(&
blocks);
335 if(!realignBlock[
b])
341 r= toRealign.front()->GetSequenceOfRow(1)->Length();
344 if(queryFrom >=
r|| queryTo >=
r|| queryFrom > queryTo)
346 TRACE_MESSAGE(
"queryFrom "<< queryFrom <<
", queryTo "<< queryTo);
351 g_dpQuery= toRealign.front()->GetSequenceOfRow(1);
354 intoriginalScore = 0;
356toRealign.front()->GetUngappedAlignedBlocks(&ob);
357BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
l, o,
le=
blocks.end();
358 for(
l=
blocks.begin(), o=ob.begin();
l!=
le; ++
l, ++o) {
360*masterRange = (*l)->GetRangeOfRow(0),
361*range = (*o)->GetRangeOfRow(1);
362 for(
unsigned int i=0;
i<(*l)->m_width; ++
i)
366 INFO_MESSAGE(
"score of extracted row with PSSM(N-1) before realignment: "<< originalScore);
372 INFO_MESSAGE(
"score of new alignment of extracted row with PSSM(N-1): "<< dpResult->
score);
376toRealign.front()->GetModifiableUngappedAlignedBlocks(&modBlocks);
377 for(
b=0;
b<modBlocks.size(); ++
b) {
378 if(realignBlock[
b]) {
379modBlocks[
b]->SetRangeOfRow(1,
382 if((
int)dpResult->
blockPositions[
b] != modBlocks[
b]->GetRangeOfRow(1)->from)
383 THROW_MESSAGE(
"dpResult block doesn't match frozen position on slave");
388 TRACE_MESSAGE(
"merging DP results back into multiple alignment");
395 if(
r< rowToRealign)
397 else if(
r== rowToRealign)
400rowOrder[
r] =
r- 1;
430std::vector<unsigned int>& rowsToRealign,
conststd::vector < unsigned int >& blocksToRealign,
431 doublepercentile,
unsigned intextension,
unsigned intcutoff,
432std::vector<unsigned int>& queryFromVec, std::vector<unsigned int>& queryToVec)
434 static const unsigned intLNO_MIN_NROWS_REMAINING = 3;
437 unsigned intqueryFrom, queryTo;
438 unsigned intnToRealign = rowsToRealign.size(), nFailed = 0;
440 stringfailedMsg, rowStr;
449 unsigned intnDifferentToRealign;
450vector<unsigned int> sortedRowsToRealign;
452setOfRows.
insert(rowsToRealign.begin(), rowsToRealign.end());
456nDifferentToRealign = setOfRows.
size();
457 if(nToRealign != nDifferentToRealign) {
458 WARNING_MESSAGE(
"Duplicate rows found among list of rows to leave out skipped\n(repeated applications of LNO on a single row has no affect)");
463 for(setIt = setOfRows.
begin(); setIt != setEnd; ++setIt) {
464 if(*setIt < 1 || *setIt >=
nRows) {
467sortedRowsToRealign.push_back(*setIt);
473nDifferentToRealign = sortedRowsToRealign.size();
480 if(nDifferentToRealign >
nRows- LNO_MIN_NROWS_REMAINING) {
481 ERROR_MESSAGE(
"need at least "<<
nRows- LNO_MIN_NROWS_REMAINING <<
" alignment rows to leave out "<< nDifferentToRealign <<
" different rows.");
484 if(
blocks.size() == 0) {
488 if(nToRealign != queryFromVec.size() || nToRealign != queryToVec.size()) {
489 ERROR_MESSAGE(
"inconsistent sizes between row list and query terminii lists for LNO");
495 boolstatus =
false;
506 unsigned int b,
r,
i;
508 unsigned int*loopLengths =
new unsigned int[
nRows];
509 for(
b=0;
b<
blocks.size()-1; ++
b) {
511range =
blocks[
b]->GetRangeOfRow(
r);
512nextRange =
blocks[
b+ 1]->GetRangeOfRow(
r);
513loopLengths[
r] = nextRange->
from- range->
to- 1;
516 nRows, loopLengths, percentile, extension, cutoff);
518 delete[] loopLengths;
521BlockMultipleAlignment::AlignmentList::iterator toRealignIt, toRealignEnd;
524 if(nDifferentToRealign != toRealign.size()) {
525 THROW_MESSAGE(
"Not as many entries in toRealign as number of different rows to realign");
530range =
blocks[
b]->GetRangeOfRow(0);
536 if(blocksToRealign.size() == 0)
539vector < bool > realignBlock(
blocks.size(),
false);
540 for(
r=0;
r<blocksToRealign.size(); ++
r) {
541 if(blocksToRealign[
r] <
blocks.size())
542realignBlock[blocksToRealign[
r]] =
true;
548toRealignIt = toRealign.begin();
549toRealignEnd = toRealign.end();
550 for(
i=0;
i< nDifferentToRealign; ++
i, ++toRealignIt) {
551 row= sortedRowsToRealign[
i];
556 while(
r< nToRealign && rowsToRealign[
r] !=
row) {
559 if(
r< nToRealign) {
560queryFrom = queryFromVec[
r];
561queryTo = queryToVec[
r];
565failedMsg.append(
"in original sorted list could not find expected row "+ rowStr);
569(*toRealignIt)->GetUngappedAlignedBlocks(&
blocks);
571 if(!realignBlock[
b])
577 r= (*toRealignIt)->GetSequenceOfRow(1)->Length();
580 if(queryFrom >=
r|| queryTo >=
r|| queryFrom > queryTo) {
583failedMsg.append(
"bad queryFrom/To range for row "+ rowStr);
586 TRACE_MESSAGE(
"row "<<
row<<
" length = "<<
r<<
"; queryFrom "<< queryFrom <<
", queryTo "<< queryTo);
591 g_dpQuery= (*toRealignIt)->GetSequenceOfRow(1);
594 intoriginalScore = 0;
596(*toRealignIt)->GetUngappedAlignedBlocks(&ob);
597BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
l, o,
le=
blocks.end();
598 for(
l=
blocks.begin(), o=ob.begin();
l!=
le; ++
l, ++o) {
600*masterRange = (*l)->GetRangeOfRow(0),
601*range = (*o)->GetRangeOfRow(1);
602 for(
unsigned int i=0;
i<(*l)->m_width; ++
i)
606 INFO_MESSAGE(
"score of extracted row with PSSM(N-"<< nDifferentToRealign <<
") before realignment: "<< originalScore);
613failedMsg.append(
"DP_GlobalBlockAlign() failed for row "+ rowStr);
616 INFO_MESSAGE(
"score of new alignment of extracted row with PSSM(N-"<< nDifferentToRealign <<
"): "<< dpResult->
score);
622(*toRealignIt)->GetModifiableUngappedAlignedBlocks(&modBlocks);
623 for(
b=0;
b<modBlocks.size(); ++
b) {
624 if(!realignBlock[
b]) {
626 if((
int)dpResult->
blockPositions[
b] != modBlocks[
b]->GetRangeOfRow(1)->from) {
629failedMsg.append(
"dpResult block doesn't match frozen position on slave for row "+ rowStr);
635 for(
b=0;
b<modBlocks.size(); ++
b) {
636 if(realignBlock[
b]) {
637modBlocks[
b]->SetRangeOfRow(1,
653 ERR_POST(
ncbi::Error<<
"Encountered problems realigning some rows; those implicated are unchanged:\n "+ failedMsg +
"\n\n");
658 TRACE_MESSAGE(
"merging DP results back into multiple alignment");
659toRealignIt = toRealign.end();
664 for(
intj=nDifferentToRealign-1; j >=0; --j, --toRealignIt) {
665 row= sortedRowsToRealign[j];
668 THROW_MESSAGE(
"MergeAlignment() failed for row "+ rowStr);
678rowOrder[
r] =
r- 1;
681 THROW_MESSAGE(
"ReorderRows() failed when reinserting row "+ rowStr);
728 ERROR_MESSAGE(
"ack - shouldn't have m_alignmentSet but empty m_seqAnnots");
768 ERROR_MESSAGE(
"AlignmentUtility::ScoreRowByPSSM() - row out of range");
774 if(
blocks.size() == 0) {
775 WARNING_MESSAGE(
"AlignmentUtility::ScoreRowByPSSM() - alignment has no blocks");
782BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator
b, be =
blocks.end();
783 for(
b=
blocks.begin();
b!=be; ++
b) {
785*masterRange = (*b)->GetRangeOfRow(0),
786*range = (*b)->GetRangeOfRow(
row);
787 for(
unsigned int i=0;
i<(*b)->m_width; ++
i)
797 return(bma) ? bma->
NRows() : 0;
801 unsigned int nRows= 0;
840 static const stringdefStr =
"Non-GI/PDB Sequence Type";
845s =
"PDB "+
id.GetPdb().GetMol().Get() +
'_'+
id.GetPdb().GetEffectiveChain_id();
846}
else if(
id.IsGi()) {
854 static const stringdefStr =
"<Could not find a sequence for row ";
866 static const stringdefStr =
"<Could not find a sequence for row ";
876idStr =
dummy->GetSeqIdStringForRow(
row);
#define WARNING_MESSAGE(s)
list< CRef< objects::CSeq_annot > > SeqAnnotList
vector< const MasterSlaveAlignment * > AlignmentList
AlignmentList m_alignments
static AlignmentSet * CreateFromMultiple(const BlockMultipleAlignment *multiple, SeqAnnotList *newAsnAlignmentData, const SequenceSet &sequenceSet, const std::vector< unsigned int > *rowOrder=NULL)
const SeqAnnotList & GetSeqAnnots(void)
void RemoveAlignAnnot(void)
const BlockMultipleAlignment * GetBlockMultipleAlignment(void)
const BLAST_Matrix * GetPSSM(void)
void RemoveMultiple(void)
bool IsRowPDB(unsigned int row)
AlignmentUtility(const ncbi::objects::CSeq_entry &seqEntry, const SeqAnnotList &seqAnnots)
std::string GetSeqIdStringForRow(unsigned int row)
void SetBlockMultipleAlignment(const BlockMultipleAlignment *bma)
bool DoLeaveOneOut(unsigned int row, const std::vector< unsigned int > &blocksToRealign, double percentile, unsigned int extension, unsigned int cutoff, unsigned int queryFrom=0, unsigned int queryTo=kMax_UInt)
AlignmentSet * m_alignmentSet
std::list< ncbi::CRef< ncbi::objects::CSeq_entry > > SeqEntryList
AlignmentUtility * Clone() const
int ScoreRowByPSSM(unsigned int row)
SeqEntryList m_seqEntries
std::list< ncbi::CRef< ncbi::objects::CSeq_annot > > SeqAnnotList
BlockMultipleAlignment * m_currentMultiple
SequenceSet * m_sequenceSet
bool DoLeaveNOut(std::vector< unsigned int > &rowsToRealign, const std::vector< unsigned int > &blocksToRealign, double percentile, unsigned int extension, unsigned int cutoff, std::vector< unsigned int > &queryFrom, std::vector< unsigned int > &queryTo)
BlockMultipleAlignment * Clone(void) const
std::list< BlockMultipleAlignment * > AlignmentList
std::vector< const Sequence * > SequenceList
const BLAST_Matrix * GetPSSM(void) const
bool ReorderRows(const std::vector< unsigned int > &newOrder)
std::vector< const UngappedAlignedBlock * > UngappedAlignedBlockList
bool ExtractRows(const std::vector< unsigned int > &slavesToRemove, AlignmentList *pairwiseAlignments)
const Sequence * GetSequenceOfRow(unsigned int row) const
void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const
unsigned int NRows(void) const
std::vector< UngappedAlignedBlock * > ModifiableUngappedAlignedBlockList
bool MergeAlignment(const BlockMultipleAlignment *newAlignment)
void SetRangeOfRow(unsigned int row, int from, int to)
std::string m_sequenceString
const ncbi::objects::CSeq_id & GetPreferredIdentifier(void) const
unsigned int Length(void) const
std::string IdentifierString(void) const
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator end() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Error(CExceptionArgs_Base &args)
const string & GetMsg(void) const
Get message string.
static bool EnableBackgroundReporting(bool enable)
Enable background reporting.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
if(yy_accept[yy_current_state])
bool le(T x_, T y_, T round_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)
unsigned int * blockPositions
unsigned int * freezeBlocks
unsigned int * blockPositions
unsigned int * blockSizes
void DP_DestroyBlockInfo(DP_BlockInfo *blocks)
unsigned int DP_CalculateMaxLoopLength(unsigned int nLoops, const unsigned int *loopLengths, double percentile, unsigned int extension, unsigned int cutoff)
#define STRUCT_DP_FOUND_ALIGNMENT
int DP_GlobalBlockAlign(const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment)
static const int DP_NEGATIVE_INFINITY
void DP_DestroyAlignmentResult(DP_AlignmentResult *alignment)
DP_BlockInfo * DP_CreateBlockInfo(unsigned int nBlocks)
static DP_BlockInfo * blocks
string SequenceIdToString(const Sequence &sequence)
DP_BlockInfo * g_dpBlocks
static bool AlignedToAllSlaves(unsigned int masterResidue, const AlignmentSet::AlignmentList &alignments)
static bool NoSlaveInsertionsBetween(unsigned int masterFrom, unsigned int masterTo, const AlignmentSet::AlignmentList &alignments)
static bool NoBlockBoundariesBetween(unsigned int masterFrom, unsigned int masterTo, const AlignmentSet::AlignmentList &alignments)
const Sequence * g_dpQuery
int ScoreByPSSM(unsigned int block, unsigned int queryPos)
const BLAST_Matrix * g_dpPSSM
#define THROW_MESSAGE(str)
#define DELETE_ALL_AND_CLEAR(container, ContainerType)
int GetPSSMScoreOfCharWithAverageOfBZ(const BLAST_Matrix *matrix, unsigned int pssmIndex, char resChar)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4