NCBI C++ ToolKit
alignment_manager.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: alignment_manager.cpp 100477 2023-08-04 16:22:30Z lanczyck $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Paul Thiessen
27 *
28 * File Description:
29 * Classes to manipulate alignments
30 *
31 * ===========================================================================
32 */
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbistd.hpp>
36 
41 #include <objects/cdd/Cdd_id.hpp>
43 
45 
46 #include "alignment_manager.hpp"
47 #include "sequence_set.hpp"
48 #include "alignment_set.hpp"
50 #include "messenger.hpp"
51 #include "structure_set.hpp"
52 #include "sequence_viewer.hpp"
53 #include "molecule.hpp"
54 #include "show_hide_manager.hpp"
55 #include "cn3d_threader.hpp"
56 #include "update_viewer.hpp"
57 #include "sequence_display.hpp"
58 #include "cn3d_tools.hpp"
59 #include "molecule_identifier.hpp"
60 #include "cn3d_blast.hpp"
61 #include "style_manager.hpp"
62 #include "cn3d_ba_interface.hpp"
63 #include "cn3d_pssm.hpp"
64 #include "progress_meter.hpp"
65 
68 
69 
70 BEGIN_SCOPE(Cn3D)
71 
72 ///// AlignmentManager methods /////
73 
75 {
76  sequenceViewer = new SequenceViewer(this);
77  GlobalMessenger()->AddSequenceViewer(sequenceViewer);
78 
79  updateViewer = new UpdateViewer(this);
80  GlobalMessenger()->AddSequenceViewer(updateViewer);
81 
82  threader = new Threader(this);
83  blaster = new BLASTer();
84  blockAligner = new BlockAligner();
85 
86  originalMultiple = NULL;
87 }
88 
90 {
91  Init();
92  NewAlignments(sSet, aSet);
93 }
94 
96  const AlignmentSet *aSet, const UpdateAlignList& updates)
97 {
98  Init();
99  NewAlignments(sSet, aSet);
100 
101  // create BlockMultipleAlignments from updates; add to update viewer
102  PairwiseAlignmentList pairwise(1);
103  UpdateViewer::AlignmentList updateAlignments;
104  UpdateAlignList::const_iterator u, ue = updates.end();
105  for (u=updates.begin(); u!=ue; ++u) {
106  if (u->GetObject().IsSetSeqannot() && u->GetObject().GetSeqannot().GetData().IsAlign()) {
107  CSeq_annot::C_Data::TAlign::const_iterator
108  s, se = u->GetObject().GetSeqannot().GetData().GetAlign().end();
109  for (s=u->GetObject().GetSeqannot().GetData().GetAlign().begin(); s!=se; ++s) {
110 
111  // determine master sequence
112  const Sequence *master = NULL;
113  if (aSet) {
114  master = aSet->master;
115  } else if (updateAlignments.size() > 0) {
116  master = updateAlignments.front()->GetMaster();
117  } else {
118  SequenceSet::SequenceList::const_iterator q, qe = sSet->sequences.end();
119  for (q=sSet->sequences.begin(); q!=qe; ++q) {
120  if ((*q)->identifier->MatchesSeqId(
121  (*s)->GetSegs().IsDendiag() ?
122  (*s)->GetSegs().GetDendiag().front()->GetIds().front().GetObject() :
123  (*s)->GetSegs().GetDenseg().GetIds().front().GetObject()
124  )) {
125  master = *q;
126  break;
127  }
128  }
129  }
130  if (!master) {
131  ERRORMSG("AlignmentManager::AlignmentManager() - "
132  << "can't determine master sequence for updates");
133  return;
134  }
135 
136  const MasterDependentAlignment *alignment =
137  new MasterDependentAlignment(NULL, master, s->GetObject());
138  pairwise.front() = alignment;
140  multiple->updateOrigin = *u; // to keep track of which Update-align this came from
141  updateAlignments.push_back(multiple);
142  delete alignment;
143  }
144  }
145  }
146  updateViewer->AddAlignments(updateAlignments);
147 
148  // set this set of updates as the initial state of the editor's undo stack
150 }
151 
153 {
156  delete sequenceViewer;
157  delete updateViewer;
158  delete threader;
159  delete blaster;
160  delete blockAligner;
162 }
163 
165 {
166  sequenceSet = sSet;
167  alignmentSet = aSet;
168 
169  if (!alignmentSet) {
171  return;
172  }
173 
174  // all dependents start out visible
175  dependentsVisible.resize(alignmentSet->alignments.size());
176  for (unsigned int i=0; i<dependentsVisible.size(); ++i)
177  dependentsVisible[i] = true;
178 
182  for (unsigned int r=0; r<originalMultiple->NRows(); ++r)
183  originalRowOrder[r] = r;
184 }
185 
187  const vector < unsigned int >& rowOrder)
188 {
189  // create new AlignmentSet based on this multiple alignment, feed back into StructureSet
190  AlignmentSet *newAlignmentSet =
191  AlignmentSet::CreateFromMultiple(multiple->GetMaster()->parentSet, multiple, rowOrder);
192  if (newAlignmentSet) {
193  multiple->GetMaster()->parentSet->ReplaceAlignmentSet(newAlignmentSet);
194  alignmentSet = newAlignmentSet;
195  } else {
196  ERRORMSG("Couldn't create pairwise alignments from the current multiple!\n"
197  << "Alignment data in output file will be left unchanged.");
198  return;
199  }
200 
201  // see whether PSSM and/or row order have changed
202  if (!originalMultiple) {
203  originalMultiple = multiple->Clone();
204  originalRowOrder = rowOrder;
207  } else {
208 
209  // check for row order change
210  TRACEMSG("checking for row order changes..." << originalMultiple << ' ' << multiple);
211  if (originalMultiple->NRows() != multiple->NRows()) {
212  TRACEMSG("row order changed");
214  } else {
215  for (unsigned int row=0; row<originalMultiple->NRows(); ++row) {
217  multiple->GetSequenceOfRow(rowOrder[row]) ||
218  originalRowOrder[row] != rowOrder[row])
219  {
220  TRACEMSG("row order changed");
222  break;
223  }
224  }
225  }
226 
227  // check for PSSM change
228  if ((multiple->HasNoAlignedBlocks() && !originalMultiple->HasNoAlignedBlocks()) ||
230  TRACEMSG("PSSM changed - zero blocks before or after");
232  } else if (!multiple->HasNoAlignedBlocks() && !originalMultiple->HasNoAlignedBlocks()) {
233  const CPssmWithParameters
234  &originalPSSM = originalMultiple->GetPSSM().GetPSSM(),
235  &currentPSSM = multiple->GetPSSM().GetPSSM();
236  TRACEMSG("checking for PSSM changes... ");
237  if (originalPSSM.GetPssm().GetNumRows() != currentPSSM.GetPssm().GetNumRows() ||
238  originalPSSM.GetPssm().GetNumColumns() != currentPSSM.GetPssm().GetNumColumns() ||
239  originalPSSM.GetPssm().GetByRow() != currentPSSM.GetPssm().GetByRow() ||
240  !originalPSSM.GetPssm().IsSetFinalData() || !currentPSSM.GetPssm().IsSetFinalData() ||
241  originalPSSM.GetPssm().GetFinalData().GetLambda() != currentPSSM.GetPssm().GetFinalData().GetLambda() ||
242  originalPSSM.GetPssm().GetFinalData().GetKappa() != currentPSSM.GetPssm().GetFinalData().GetKappa() ||
243  originalPSSM.GetPssm().GetFinalData().GetH() != currentPSSM.GetPssm().GetFinalData().GetH() ||
244  originalPSSM.GetPssm().GetFinalData().GetScalingFactor() != currentPSSM.GetPssm().GetFinalData().GetScalingFactor()
245  ) {
246  TRACEMSG("PSSM changed");
248  } else {
249  CPssmFinalData::TScores::const_iterator
250  o = originalPSSM.GetPssm().GetFinalData().GetScores().begin(),
251  oe = originalPSSM.GetPssm().GetFinalData().GetScores().end(),
252  c = currentPSSM.GetPssm().GetFinalData().GetScores().begin();
253  for (; o!=oe; ++o, ++c) {
254  if ((*o) != (*c)) {
255  TRACEMSG("PSSM changed");
257  break;
258  }
259  }
260  }
261  }
262 
263  // keep for comparison on next save
264  delete originalMultiple;
265  originalMultiple = multiple->Clone();
267  originalRowOrder = rowOrder;
268  }
269 }
270 
272 {
273  const ViewerBase::AlignmentList& currentAlignments = sequenceViewer->GetCurrentAlignments();
274  return ((currentAlignments.size() > 0) ? currentAlignments.front() : NULL);
275 }
276 
277 static bool AlignedToAllDependents(int masterResidue,
278  const AlignmentManager::PairwiseAlignmentList& alignments)
279 {
280  AlignmentManager::PairwiseAlignmentList::const_iterator a, ae = alignments.end();
281  for (a=alignments.begin(); a!=ae; ++a) {
282  if ((*a)->masterToDependent[masterResidue] == -1) return false;
283  }
284  return true;
285 }
286 
287 static bool NoDependentInsertionsBetween(int masterFrom, int masterTo,
288  const AlignmentManager::PairwiseAlignmentList& alignments)
289 {
290  AlignmentManager::PairwiseAlignmentList::const_iterator a, ae = alignments.end();
291  for (a=alignments.begin(); a!=ae; ++a) {
292  if (((*a)->masterToDependent[masterTo] - (*a)->masterToDependent[masterFrom]) != (masterTo - masterFrom))
293  return false;
294  }
295  return true;
296 }
297 
298 static bool NoBlockBoundariesBetween(int masterFrom, int masterTo,
299  const AlignmentManager::PairwiseAlignmentList& alignments)
300 {
301  AlignmentManager::PairwiseAlignmentList::const_iterator a, ae = alignments.end();
302  for (a=alignments.begin(); a!=ae; ++a) {
303  if ((*a)->blockStructure[masterTo] != (*a)->blockStructure[masterFrom])
304  return false;
305  }
306  return true;
307 }
308 
311 {
312  PairwiseAlignmentList::const_iterator a, ae = alignments.end();
313 
314  // create sequence list; fill with sequences of master + dependents
316  *sequenceList = new BlockMultipleAlignment::SequenceList(alignments.size() + 1);
317  BlockMultipleAlignment::SequenceList::iterator s = sequenceList->begin();
318  *(s++) = alignments.front()->master;
319  for (a=alignments.begin(); a!=ae; ++a) {
320  *(s++) = (*a)->dependent;
321  if ((*a)->master != sequenceList->front()) {
322  ERRORMSG("AlignmentManager::CreateMultipleFromPairwiseWithIBM() -\n"
323  << "all pairwise alignments must have the same master sequence");
324  return NULL;
325  }
326  }
327  BlockMultipleAlignment *multipleAlignment = new BlockMultipleAlignment(sequenceList, this);
328 
329  // each block is a continuous region on the master, over which each master
330  // residue is aligned to a residue of each dependent, and where there are no
331  // insertions relative to the master in any of the dependents
332  int masterFrom = 0, masterTo;
333  unsigned int row;
334  UngappedAlignedBlock *newBlock;
335 
336  while (masterFrom < (int)multipleAlignment->GetMaster()->Length()) {
337 
338  // look for first all-aligned residue
339  if (!AlignedToAllDependents(masterFrom, alignments)) {
340  ++masterFrom;
341  continue;
342  }
343 
344  // find all next continuous all-aligned residues, but checking for
345  // block boundaries from the original master-dependent pairs, so that
346  // blocks don't get merged
347  for (masterTo=masterFrom+1;
348  masterTo < (int)multipleAlignment->GetMaster()->Length() &&
349  AlignedToAllDependents(masterTo, alignments) &&
350  NoDependentInsertionsBetween(masterFrom, masterTo, alignments) &&
351  NoBlockBoundariesBetween(masterFrom, masterTo, alignments);
352  ++masterTo) ;
353  --masterTo; // after loop, masterTo = first residue past block
354 
355  // create new block with ranges from master and all dependents
356  newBlock = new UngappedAlignedBlock(multipleAlignment);
357  newBlock->SetRangeOfRow(0, masterFrom, masterTo);
358  newBlock->width = masterTo - masterFrom + 1;
359 
360  //TESTMSG("masterFrom " << masterFrom+1 << ", masterTo " << masterTo+1);
361  for (a=alignments.begin(), row=1; a!=ae; ++a, ++row) {
362  newBlock->SetRangeOfRow(row,
363  (*a)->masterToDependent[masterFrom],
364  (*a)->masterToDependent[masterTo]);
365  //TESTMSG("dependent->from " << b->from+1 << ", dependent->to " << b->to+1);
366  }
367 
368  // copy new block into alignment
369  multipleAlignment->AddAlignedBlockAtEnd(newBlock);
370 
371  // start looking for next block
372  masterFrom = masterTo + 1;
373  }
374 
375  if (!multipleAlignment->AddUnalignedBlocks() ||
376  !multipleAlignment->UpdateBlockMapAndColors()) {
377  ERRORMSG("AlignmentManager::CreateMultipleFromPairwiseWithIBM() - error finalizing alignment");
378  return NULL;
379  }
380 
381  return multipleAlignment;
382 }
383 
385  BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator& b,
386  BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator& be,
387  int row, int *seqIndexes, bool countHighlights = false, const BlockMultipleAlignment *multiple = NULL)
388 {
389  unsigned int i = 0, c, highlighted = 0;
390  const Block::Range *range;
391  for (; b!=be; ++b) {
392  range = (*b)->GetRangeOfRow(row);
393  for (c=0; c<(*b)->width; ++c, ++i) {
394  seqIndexes[i] = range->from + c;
395  if (countHighlights) {
396  if (GlobalMessenger()->IsHighlighted(multiple->GetSequenceOfRow(row), seqIndexes[i]))
397  ++highlighted;
398  else
399  seqIndexes[i] = -1;
400  }
401  }
402  }
403  return highlighted;
404 }
405 
406 void AlignmentManager::RealignAllDependentStructures(bool highlightedOnly) const
407 {
409  if (!multiple) return;
411  multiple->GetUngappedAlignedBlocks(&blocks);
412  BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator b, be = blocks.end();
413  int nResidues = 0;
414  for (b=blocks.begin(); b!=be; ++b)
415  nResidues += (*b)->width;
416  if (nResidues == 0) {
417  WARNINGMSG("Can't realign dependents with no aligned residues!");
418  return;
419  }
420 
421  const Sequence *masterSeq = multiple->GetSequenceOfRow(0), *dependentSeq;
422  const Molecule *masterMol, *dependentMol;
423  if (!masterSeq || !(masterMol = masterSeq->molecule)) {
424  WARNINGMSG("Can't realign dependents to non-structured master!");
425  return;
426  }
427 
428  int *masterSeqIndexes = new int[nResidues], *dependentSeqIndexes = new int[nResidues];
429  b = blocks.begin();
430  int nHighlightedAligned = GetAlignedResidueIndexes(b, be, 0, masterSeqIndexes, highlightedOnly, multiple);
431  if ((highlightedOnly ? nHighlightedAligned : nResidues) < 3) {
432  WARNINGMSG("Can't realign dependents using < 3 residues!");
433  delete[] masterSeqIndexes;
434  delete[] dependentSeqIndexes;
435  return;
436  }
437 
438  double *weights = new double[nResidues];
439  const StructureObject *dependentObj;
440 
441  typedef const Vector * CVP;
442  CVP *masterCoords = new CVP[nResidues], *dependentCoords = new CVP[nResidues];
443  if (!masterMol->GetAlphaCoords(nResidues, masterSeqIndexes, masterCoords)) {
444  WARNINGMSG("Can't get master alpha coords");
445  } else if (masterSeq->GetOrSetMMDBLink() == MoleculeIdentifier::VALUE_NOT_SET) {
446  WARNINGMSG("Don't know master MMDB ID");
447  } else {
448 
449  masterMol->parentSet->InitStructureAlignments(masterSeq->identifier->mmdbID);
450 
451  unsigned int nStructureAlignments = 0;
452  for (unsigned int i=1; i<multiple->NRows(); ++i) {
453  dependentSeq = multiple->GetSequenceOfRow(i);
454  if (!dependentSeq || !(dependentMol = dependentSeq->molecule)) continue;
455 
456  b = blocks.begin();
457  GetAlignedResidueIndexes(b, be, i, dependentSeqIndexes);
458  if (dependentMol->GetAlphaCoords(nResidues, dependentSeqIndexes, dependentCoords) < 3) {
459  ERRORMSG("can't realign dependent " << dependentSeq->identifier->pdbID << ", not enough coordinates in aligned region");
460  continue;
461  }
462 
463  if (!dependentMol->GetParentOfType(&dependentObj)) continue;
464 
465  // if any Vector* is NULL, make sure that weight is 0 so the pointer won't be accessed
466  int nWeighted = 0;
467  for (int j=0; j<nResidues; ++j) {
468  if (!masterCoords[j] || !dependentCoords[j] || (highlightedOnly && masterSeqIndexes[j] < 0)) {
469  weights[j] = 0.0;
470  } else {
471  weights[j] = 1.0; // for now, just use flat weighting
472  ++nWeighted;
473  }
474  }
475  if (nWeighted < 3) {
476  WARNINGMSG("Can't realign dependent #" << (i+1) << " using < 3 residues!");
477  continue;
478  }
479 
480  INFOMSG("realigning dependent " << dependentSeq->identifier->pdbID << " against master " << masterSeq->identifier->pdbID
481  << " using coordinates of " << nWeighted << " residues");
482  (const_cast<StructureObject*>(dependentObj))->RealignStructure(nResidues, masterCoords, dependentCoords, weights, i);
483  ++nStructureAlignments;
484  }
485 
486  // if no structure alignments, remove the list entirely
487  if (nStructureAlignments == 0) masterMol->parentSet->RemoveStructureAlignments();
488  }
489 
490  delete[] masterSeqIndexes;
491  delete[] dependentSeqIndexes;
492  delete[] masterCoords;
493  delete[] dependentCoords;
494  delete[] weights;
495  return;
496 }
497 
498 void AlignmentManager::GetAlignmentSetDependentSequences(vector < const Sequence * > *sequences) const
499 {
500  sequences->resize(alignmentSet->alignments.size());
501 
502  AlignmentSet::AlignmentList::const_iterator a, ae = alignmentSet->alignments.end();
503  int i = 0;
504  for (a=alignmentSet->alignments.begin(); a!=ae; ++a, ++i) {
505  (*sequences)[i] = (*a)->dependent;
506  }
507 }
508 
509 void AlignmentManager::GetAlignmentSetDependentVisibilities(vector < bool > *visibilities) const
510 {
511  if (dependentsVisible.size() != alignmentSet->alignments.size()) // can happen if row is added/deleted
512  dependentsVisible.resize(alignmentSet->alignments.size(), true);
513 
514  // copy visibility list
515  *visibilities = dependentsVisible;
516 }
517 
518 void AlignmentManager::ShowHideCallbackFunction(const vector < bool >& itemsEnabled)
519 {
520  if (itemsEnabled.size() != dependentsVisible.size() ||
521  itemsEnabled.size() != alignmentSet->alignments.size()) {
522  ERRORMSG("AlignmentManager::ShowHideCallbackFunction() - wrong size list");
523  return;
524  }
525 
526  dependentsVisible = itemsEnabled;
528 
529  AlignmentSet::AlignmentList::const_iterator
530  a = alignmentSet->alignments.begin(), ae = alignmentSet->alignments.end();
531  const StructureObject *object;
532 
533  if ((*a)->master->molecule) {
534  // Show() redraws whole StructureObject only if necessary
535  if ((*a)->master->molecule->GetParentOfType(&object))
536  object->parentSet->showHideManager->Show(object, true);
537  // always redraw aligned molecule, in case alignment colors change
538  GlobalMessenger()->PostRedrawMolecule((*a)->master->molecule);
539  }
540  for (int i=0; a!=ae; ++a, ++i) {
541  if ((*a)->dependent->molecule) {
542  if ((*a)->dependent->molecule->GetParentOfType(&object))
543  object->parentSet->showHideManager->Show(object, dependentsVisible[i]);
544  GlobalMessenger()->PostRedrawMolecule((*a)->dependent->molecule);
545  }
546  }
547 
548  // do necessary redraws + show/hides: sequences + chains in the alignment
551  GlobalMessenger()->UnPostRedrawSequenceViewer(sequenceViewer); // Refresh() does this already
552 }
553 
554 void AlignmentManager::NewMultipleWithRows(const vector < bool >& visibilities)
555 {
556  if (visibilities.size() != alignmentSet->alignments.size()) {
557  ERRORMSG("AlignmentManager::NewMultipleWithRows() - wrong size visibility vector");
558  return;
559  }
560 
561  // make a multiple from all visible rows
562  PairwiseAlignmentList alignments;
563  AlignmentSet::AlignmentList::const_iterator a, ae=alignmentSet->alignments.end();
564  int i = 0;
565  for (a=alignmentSet->alignments.begin(); a!=ae; ++a, ++i) {
566  if (visibilities[i])
567  alignments.push_back(*a);
568  }
569 
570  // sequenceViewer will own the resulting alignment
572 }
573 
574 bool AlignmentManager::IsAligned(const Sequence *sequence, unsigned int seqIndex) const
575 {
576  if (!sequence) return false;
577  const BlockMultipleAlignment *currentAlignment = GetCurrentMultipleAlignment();
578  if (currentAlignment)
579  return currentAlignment->IsAligned(sequence, seqIndex);
580  else
581  return false;
582 }
583 
584 bool AlignmentManager::IsInAlignment(const Sequence *sequence) const
585 {
586  if (!sequence) return false;
587  const BlockMultipleAlignment *currentAlignment = GetCurrentMultipleAlignment();
588  if (currentAlignment) {
589  for (unsigned int i=0; i<currentAlignment->GetSequences()->size(); ++i) {
590  if ((*(currentAlignment->GetSequences()))[i] == sequence)
591  return true;
592  }
593  }
594  return false;
595 }
596 
597 const Vector * AlignmentManager::GetAlignmentColor(const Sequence *sequence, unsigned int seqIndex,
598  StyleSettings::eColorScheme colorScheme) const
599 {
600  const BlockMultipleAlignment *currentAlignment = GetCurrentMultipleAlignment();
601  if (currentAlignment)
602  return currentAlignment->GetAlignmentColor(sequence, seqIndex, colorScheme);
603  else
604  return NULL;
605 }
606 
607 void AlignmentManager::ShowSequenceViewer(bool showNow) const
608 {
610 }
611 
613 {
615 }
616 
618  BlockMultipleAlignment *multiple, const vector < unsigned int >& dependentsToRealign)
619 {
620  if (!multiple || sequenceViewer->GetCurrentAlignments().size() == 0 ||
621  multiple != sequenceViewer->GetCurrentAlignments().front()) {
622  ERRORMSG("AlignmentManager::RealignDependentSequences() - wrong multiple alignment");
623  return;
624  }
625  if (dependentsToRealign.size() == 0) return;
626 
627  // create alignments for each master/dependent pair, then update displays
628  UpdateViewer::AlignmentList alignments;
629  TRACEMSG("extracting rows");
630  if (multiple->ExtractRows(dependentsToRealign, &alignments)) {
631  TRACEMSG("recreating display");
632  sequenceViewer->GetCurrentDisplay()->RowsRemoved(dependentsToRealign, multiple);
633  TRACEMSG("adding to update window");
634  SetDiagPostLevel(eDiag_Warning); // otherwise, info messages take a long time if lots of rows
635  updateViewer->AddAlignments(alignments);
637  TRACEMSG("done");
639  }
640 }
641 
643 {
644  const ViewerBase::AlignmentList& currentAlignments = sequenceViewer->GetCurrentAlignments();
645  if (currentAlignments.size() == 0) return;
646 
647  // run the threader on the given alignment
648  UpdateViewer::AlignmentList singleList, replacedList;
649  Threader::AlignmentList newAlignments;
650  unsigned int nRowsAddedToMultiple;
651  bool foundSingle = false; // sanity check
652 
653  singleList.push_back(single);
654  if (threader->Realign(
655  options, currentAlignments.front(), &singleList, &newAlignments, &nRowsAddedToMultiple, sequenceViewer)) {
656 
657  // replace threaded alignment with new one(s) (or leftover where threader/merge failed)
658  UpdateViewer::AlignmentList::const_iterator a, ae = updateViewer->GetCurrentAlignments().end();
659  for (a=updateViewer->GetCurrentAlignments().begin(); a!=ae; ++a) {
660  if (*a == single) {
661  Threader::AlignmentList::const_iterator n, ne = newAlignments.end();
662  for (n=newAlignments.begin(); n!=ne; ++n)
663  replacedList.push_back(*n);
664  foundSingle = true;
665  } else
666  replacedList.push_back((*a)->Clone());
667  }
668  if (!foundSingle) ERRORMSG(
669  "AlignmentManager::ThreadUpdate() - threaded alignment not found in update viewer!");
670  updateViewer->ReplaceAlignments(replacedList);
671 
672  // tell the sequenceViewer that rows have been merged into the multiple
673  if (nRowsAddedToMultiple > 0)
674  sequenceViewer->GetCurrentDisplay()->RowsAdded(nRowsAddedToMultiple, currentAlignments.front());
675  }
676 }
677 
679 {
680  const ViewerBase::AlignmentList& currentAlignments = sequenceViewer->GetCurrentAlignments();
681  if (currentAlignments.size() == 0) return;
682 
683  // run the threader on update pairwise alignments
684  Threader::AlignmentList newAlignments;
685  unsigned int nRowsAddedToMultiple;
686  if (threader->Realign(
687  options, currentAlignments.front(), &(updateViewer->GetCurrentAlignments()),
688  &newAlignments, &nRowsAddedToMultiple, sequenceViewer)) {
689 
690  // replace update alignments with new ones (or leftovers where threader/merge failed)
691  updateViewer->ReplaceAlignments(newAlignments);
692 
693  // tell the sequenceViewer that rows have been merged into the multiple
694  if (nRowsAddedToMultiple > 0)
696  RowsAdded(nRowsAddedToMultiple, currentAlignments.front());
697  }
698 }
699 
700 void AlignmentManager::MergeUpdates(const AlignmentManager::UpdateMap& updatesToMerge, bool mergeToNeighbor)
701 {
702  if (updatesToMerge.size() == 0) return;
704  if (currentUpdates.size() == 0) return;
705 
706  // transform this structure view into an alignment view, and turn on the editor.
707  ViewerBase::AlignmentList::const_iterator u, ue = currentUpdates.end();
708  const BlockMultipleAlignment *newMultiple = NULL;
709  if (sequenceViewer->GetCurrentAlignments().size() == 0) {
710 
711  for (u=currentUpdates.begin(); u!=ue; ++u) { // find first update alignment
712  if (updatesToMerge.find(*u) != updatesToMerge.end()) {
713  newMultiple = *u;
714 
715  // create new alignment, then call SavePairwiseFromMultiple to create
716  // an AlignmentSet and the initial ASN data
717  sequenceViewer->DisplayAlignment(newMultiple->Clone());
718  vector < unsigned int > rowOrder(newMultiple->NRows());
719  for (unsigned int i=0; i<newMultiple->NRows(); ++i) rowOrder[i] = i;
720  SavePairwiseFromMultiple(newMultiple, rowOrder);
721 
722  // editor needs to be on if >1 update is to be merged in
724 
725  // set default alignment-type style
726  newMultiple->GetMaster()->parentSet->styleManager->
727  SetGlobalRenderingStyle(StyleSettings::eTubeShortcut);
728  newMultiple->GetMaster()->parentSet->styleManager->
729  SetGlobalColorScheme(StyleSettings::eAlignedShortcut);
731  break;
732  }
733  }
734  }
735 
736  BlockMultipleAlignment *multiple =
737  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
739  if (!multiple) {
740  ERRORMSG("Must have an alignment in the sequence viewer to merge with");
741  return;
742  }
743 
744  // make sure the editor is on in the sequenceViewer
745  if (!sequenceViewer->EditorIsOn())
747 
748  int nSuccessfulMerges = 0;
749  ViewerBase::AlignmentList updatesToKeep;
750  for (u=currentUpdates.begin(); u!=ue; ++u) {
751  if (*u == newMultiple) continue;
752  bool merged = false;
753  if (updatesToMerge.find(*u) != updatesToMerge.end()) {
754  merged = multiple->MergeAlignment(*u);
755  if (merged) {
756  nSuccessfulMerges += (*u)->NRows() - 1;
757  } else {
758  for (unsigned int i=0; i<(*u)->NRows(); ++i) {
759  string status = (*u)->GetRowStatusLine(i);
760  if (status.size() > 0)
761  status += "; merge failed!";
762  else
763  status = "Merge failed!";
764  (*u)->SetRowStatusLine(i, status);
765  }
766  }
767  }
768  if (!merged) {
769  BlockMultipleAlignment *keep = (*u)->Clone();
770  updatesToKeep.push_back(keep);
771  }
772  }
773 
774  updateViewer->ReplaceAlignments(updatesToKeep);
775  if (nSuccessfulMerges > 0) {
776  int where = -1;
777 
778  // if necessary, find nearest neighbor to merged sequence, and add new row after it
779  if (mergeToNeighbor && nSuccessfulMerges == 1) {
781  multiple->GetUngappedAlignedBlocks(&blocks);
782  BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator b, be = blocks.end();
783  int rowScore, bestScore = 0;
784  unsigned int col, row, lastRow = multiple->NRows() - 1;
785  const Sequence *mergeSeq = multiple->GetSequenceOfRow(lastRow);
786  for (row=0; row<lastRow; ++row) {
787  const Sequence *otherSeq = multiple->GetSequenceOfRow(row);
788  rowScore = 0;
789  for (b=blocks.begin(); b!=be; ++b) {
790  for (col=0; col<(*b)->width; ++col) {
791  rowScore += GetBLOSUM62Score(
792  mergeSeq->sequenceString[(*b)->GetRangeOfRow(lastRow)->from + col],
793  otherSeq->sequenceString[(*b)->GetRangeOfRow(row)->from + col]);
794  }
795  }
796  TRACEMSG("Merge score with row " << (row + 1) << " (" << multiple->GetSequenceOfRow(row)->identifier->ToString() << ") is " << rowScore);
797  if (row == 0 || rowScore > bestScore) {
798  where = row;
799  bestScore = rowScore;
800  }
801  }
802  INFOMSG("Closest row is #" << (where+1) << ", "
803  << multiple->GetSequenceOfRow(where)->identifier->ToString());
804  }
805 
806  sequenceViewer->GetCurrentDisplay()->RowsAdded(nSuccessfulMerges, multiple, where);
807  }
808 
809  // add pending imported structures to asn data
811 }
812 
814 {
816 }
817 
818 unsigned int AlignmentManager::NUpdates(void) const
819 {
820  return updateViewer->GetCurrentAlignments().size();
821 }
822 
823 void AlignmentManager::GetUpdateSequences(list < const Sequence * > *updateSequences) const
824 {
825  updateSequences->clear();
827  if (currentUpdates.size() == 0) return;
828  ViewerBase::AlignmentList::const_iterator u, ue = currentUpdates.end();
829  for (u=currentUpdates.begin(); u!=ue; ++u)
830  updateSequences->push_back((*u)->GetSequenceOfRow(1)); // assume update aln has just one dependent...
831 }
832 
833 bool AlignmentManager::GetStructureProteins(vector < const Sequence * > *chains) const
834 {
835  if (!chains || GetCurrentMultipleAlignment() != NULL ||
836  !sequenceViewer || !sequenceViewer->GetCurrentDisplay()) return false;
837 
839  return (chains->size() > 0);
840 }
841 
842 void AlignmentManager::ReplaceUpdatesInASN(ncbi::objects::CCdd::TPending& newUpdates) const
843 {
844  if (sequenceSet)
845  sequenceSet->parentSet->ReplaceUpdates(newUpdates);
846  else
847  ERRORMSG("AlignmentManager::ReplaceUpdatesInASN() - can't get StructureSet");
848 }
849 
851 {
852  BlockMultipleAlignment *multiple =
853  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
855  if (!multiple) return;
856 
857  // remove matching rows from multiple alignment
858  vector < unsigned int > rowsToRemove;
859  for (unsigned int i=1; i<multiple->NRows(); ++i)
860  if (multiple->GetSequenceOfRow(i)->identifier == identifier)
861  rowsToRemove.push_back(i);
862 
863  if (rowsToRemove.size() > 0) {
864 
865  // turn on editor, and update multiple pointer
866  if (!sequenceViewer->EditorIsOn()) {
868  multiple = sequenceViewer->GetCurrentAlignments().front();
869  }
870 
871  if (!multiple->ExtractRows(rowsToRemove, NULL)) {
872  ERRORMSG("AlignmentManager::PurgeSequence() - ExtractRows failed!");
873  return;
874  }
875 
876  // remove rows from SequenceDisplay
878  if (!display) {
879  ERRORMSG("AlignmentManager::PurgeSequence() - can't get SequenceDisplay!");
880  return;
881  }
882  display->RowsRemoved(rowsToRemove, multiple);
883  }
884 
885  // remove matching alignments from Update window
887  if (currentUpdates.size() == 0) return;
888  ViewerBase::AlignmentList::const_iterator u, ue = currentUpdates.end();
889 
890  for (u=currentUpdates.begin(); u!=ue; ++u) // quick check if any match found
891  if ((*u)->GetSequenceOfRow(1)->identifier == identifier) break;
892 
893  if (u != ue) {
894  ViewerBase::AlignmentList updatesToKeep;
895  for (u=currentUpdates.begin(); u!=ue; ++u) {
896  if ((*u)->GetSequenceOfRow(1)->identifier != identifier) {
897  BlockMultipleAlignment *keep = (*u)->Clone();
898  updatesToKeep.push_back(keep);
899  }
900  }
901  updateViewer->ReplaceAlignments(updatesToKeep);
902  }
903 }
904 
906 {
907  BlockMultipleAlignment *currentMultiple =
908  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
910  if (!currentMultiple) return;
911 
913  if (currentUpdates.size() == 0)
914  return;
915 
916  // run the block aligner on update pairwise alignments
917  BlockAligner::AlignmentList newAlignmentsList;
918  int nRowsAddedToMultiple;
919 
921  currentUpdates, &newAlignmentsList, &nRowsAddedToMultiple, sequenceViewer)) {
922 
923  // replace update alignments with new ones (or leftovers where algorithm failed)
924  updateViewer->ReplaceAlignments(newAlignmentsList);
925 
926  // tell the sequenceViewer that rows have been merged into the multiple
927  if (nRowsAddedToMultiple > 0)
928  sequenceViewer->GetCurrentDisplay()->RowsAdded(nRowsAddedToMultiple, currentMultiple);
929  }
930 }
931 
933 {
934  BlockMultipleAlignment *currentMultiple =
935  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
937  if (!currentMultiple) return;
938 
939  // run the block aligner on the given alignment
940  UpdateViewer::AlignmentList singleList, replacedList;
941  BlockAligner::AlignmentList newAlignments;
942  int nRowsAddedToMultiple;
943  bool foundSingle = false; // sanity check
944 
945  singleList.push_back(single);
947  currentMultiple, singleList, &newAlignments, &nRowsAddedToMultiple, sequenceViewer)) {
948 
949  // replace threaded alignment with new one
950  UpdateViewer::AlignmentList::const_iterator a, ae = updateViewer->GetCurrentAlignments().end();
951  for (a=updateViewer->GetCurrentAlignments().begin(); a!=ae; ++a) {
952  if (*a == single) {
953  BlockAligner::AlignmentList::const_iterator n, ne = newAlignments.end();
954  for (n=newAlignments.begin(); n!=ne; ++n)
955  replacedList.push_back(*n);
956  foundSingle = true;
957  } else
958  replacedList.push_back((*a)->Clone());
959  }
960  if (!foundSingle) ERRORMSG(
961  "AlignmentManager::BlockAlignUpdate() - changed alignment not found in update viewer!");
962  updateViewer->ReplaceAlignments(replacedList);
963 
964  // tell the sequenceViewer that rows have been merged into the multiple
965  if (nRowsAddedToMultiple > 0)
966  sequenceViewer->GetCurrentDisplay()->RowsAdded(nRowsAddedToMultiple, currentMultiple);
967  }
968 }
969 
970 typedef struct {
971  unsigned int multBlock, pairBlock;
974 } ExtendInfo;
975 
977  const UpdateViewer::AlignmentList& toExtend, UpdateViewer::AlignmentList *newAlignments)
978 {
979  if (multiple.HasNoAlignedBlocks())
980  return false;
981 
982  bool anyChanges = false;
983 
985  multiple.GetUngappedAlignedBlocks(&multBlocks);
986 
987  newAlignments->clear();
988  UpdateViewer::AlignmentList::const_iterator t, te = toExtend.end();
989  for (t=toExtend.begin(); t!=te; ++t) {
990  BlockMultipleAlignment *p = (*t)->Clone();
991  newAlignments->push_back(p);
992 
993  pairBlocks.clear();
994  p->GetUngappedAlignedBlocks(&pairBlocks);
995  if (pairBlocks.size() == 0)
996  continue;
997 
998  typedef list < ExtendInfo > ExtendList;
1000  ExtendMap extendMap;
1001 
1002  // find cases where a pairwise block ends inside a multiple block
1003  const UnalignedBlock *ub;
1004  for (unsigned int mb=0; mb<multBlocks.size(); ++mb) {
1005  const Block::Range *multRange = multBlocks[mb]->GetRangeOfRow(0);
1006  for (unsigned int pb=0; pb<pairBlocks.size(); ++pb) {
1007  const Block::Range *pairRange = pairBlocks[pb]->GetRangeOfRow(0);
1008 
1009  if (pairRange->from > multRange->from && pairRange->from <= multRange->to &&
1010  (ub = p->GetUnalignedBlockBefore(pairBlocks[pb])) != NULL)
1011  {
1012  ExtendList& el = extendMap[ub];
1013  el.resize(el.size() + 1);
1014  el.back().multBlock = mb;
1015  el.back().pairBlock = pb;
1016  el.back().extendPairBlockLeft = true;
1017  el.back().nResidues = pairRange->from - multRange->from;
1018  TRACEMSG("block " << (pb+1) << " wants to be extended to the left");
1019  }
1020 
1021  if (pairRange->to < multRange->to && pairRange->to >= multRange->from &&
1022  (ub = p->GetUnalignedBlockAfter(pairBlocks[pb])) != NULL)
1023  {
1024  ExtendList& el = extendMap[ub];
1025  el.resize(el.size() + 1);
1026  el.back().multBlock = mb;
1027  el.back().pairBlock = pb;
1028  el.back().extendPairBlockLeft = false;
1029  el.back().nResidues = multRange->to - pairRange->to;
1030  TRACEMSG("block " << (pb+1) << " wants to be extended to the right");
1031  }
1032  }
1033  }
1034 
1035  ExtendMap::const_iterator u, ue = extendMap.end();
1036  for (u=extendMap.begin(); u!=ue; ++u) {
1037 
1038  // don't slurp residues into non-adjacent aligned blocks from the multiple
1039  if (u->second.size() == 2 && (u->second.back().multBlock - u->second.front().multBlock > 1)) {
1040  TRACEMSG("can't extend with intervening block(s) in multiple between blocks "
1041  << (u->second.front().pairBlock+1) << " and " << (u->second.back().pairBlock+1));
1042  continue;
1043  }
1044 
1045  ExtendList::const_iterator e, ee;
1046 
1047  // extend from one side only if an unaligned block is contained entirely within a block in the multiple,
1048  // and this unaligned block is "complete" - that is, MinResidues == width.
1049  if (u->first->MinResidues() == u->first->width && u->second.size() == 2 &&
1050  u->second.front().multBlock == u->second.back().multBlock)
1051  {
1052  ExtendList& modList = const_cast<ExtendList&>(u->second);
1053  modList.front().nResidues = u->first->width;
1054  modList.erase(++(modList.begin()));
1055  }
1056 
1057  else {
1058  // check to see if there are sufficient unaligned residues to extend from both sides
1059  int available = u->first->MinResidues(), totalShifts = 0;
1060  for (e=u->second.begin(), ee=u->second.end(); e!=ee; ++e)
1061  totalShifts += e->nResidues;
1062  if (totalShifts > available) {
1063  TRACEMSG("inadequate residues to the "
1064  << (u->second.front().extendPairBlockLeft ? "left" : "right")
1065  << " of block " << (u->second.front().pairBlock+1) << "; no extension performed");
1066  continue;
1067  }
1068  }
1069 
1070  // perform any allowed extensions
1071  for (e=u->second.begin(), ee=u->second.end(); e!=ee; ++e) {
1072  int alnIdx = p->GetAlignmentIndex(0,
1073  (e->extendPairBlockLeft ?
1074  pairBlocks[e->pairBlock]->GetRangeOfRow(0)->from :
1075  pairBlocks[e->pairBlock]->GetRangeOfRow(0)->to),
1076  BlockMultipleAlignment::eLeft); // justification is irrelevant since this is an aligned block
1077  TRACEMSG("extending " << (e->extendPairBlockLeft ? "left" : "right")
1078  << " side of block " << (e->pairBlock+1) << " by " << e->nResidues << " residues");
1079  if (p->MoveBlockBoundary(alnIdx, alnIdx + (e->extendPairBlockLeft ? -e->nResidues : e->nResidues)))
1080  anyChanges = true;
1081  else
1082  ERRORMSG("MoveBlockBoundary() failed!");
1083  }
1084  }
1085 
1086  // now, merge any adjacent blocks that end within a block of the multiple
1087  const Block::Range *prevRange = NULL;
1088  vector < int > mergeIndexes;
1089  for (unsigned int pb=0; pb<pairBlocks.size(); ++pb) {
1090  const Block::Range *pairRange = pairBlocks[pb]->GetRangeOfRow(0);
1091  if (prevRange && prevRange->to == pairRange->from - 1 && multiple.IsAligned(0U, prevRange->to)) {
1092  // justification is irrelevant since this is an aligned block
1093  int mAlnIdx1 = multiple.GetAlignmentIndex(0, prevRange->to, BlockMultipleAlignment::eLeft),
1094  mAlnIdx2 = multiple.GetAlignmentIndex(0, pairRange->from, BlockMultipleAlignment::eLeft),
1095  pAlnIdx1 = p->GetAlignmentIndex(0, prevRange->to, BlockMultipleAlignment::eLeft),
1096  pAlnIdx2 = p->GetAlignmentIndex(0, pairRange->from, BlockMultipleAlignment::eLeft);
1097  if (pAlnIdx1 == pAlnIdx2 - 1 &&
1098  multiple.GetAlignedBlockNumber(mAlnIdx1) == multiple.GetAlignedBlockNumber(mAlnIdx2))
1099  {
1100  TRACEMSG("merging blocks " << pb << " and " << (pb+1));
1101  // just flag to merge later, since actually merging would mess up pb block indexes
1102  mergeIndexes.push_back(pAlnIdx1);
1103  }
1104  }
1105  prevRange = pairRange;
1106  }
1107  for (unsigned int i=0; i<mergeIndexes.size(); ++i) {
1108  if (p->MergeBlocks(mergeIndexes[i], mergeIndexes[i] + 1))
1109  anyChanges = true;
1110  else
1111  ERRORMSG("MergeBlocks() failed!");
1112  }
1113  }
1114 
1115  return anyChanges;
1116 }
1117 
1119 {
1120  BlockMultipleAlignment *currentMultiple =
1121  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
1123  if (!currentMultiple) return;
1124 
1126  if (currentUpdates.size() == 0)
1127  return;
1128 
1129  // run the block extender on update pairwise alignments
1130  UpdateViewer::AlignmentList newAlignmentsList;
1131  if (CreateNewPairwiseAlignmentsByBlockExtension(*currentMultiple, currentUpdates, &newAlignmentsList))
1132  updateViewer->ReplaceAlignments(newAlignmentsList);
1133 }
1134 
1136 {
1137  BlockMultipleAlignment *currentMultiple =
1138  (sequenceViewer->GetCurrentAlignments().size() > 0) ?
1140  if (!currentMultiple) return;
1141 
1142  // run the threader on the given alignment
1143  UpdateViewer::AlignmentList singleList, replacedList;
1144  BlockAligner::AlignmentList newAlignments;
1145 
1146  singleList.push_back(single);
1147  if (CreateNewPairwiseAlignmentsByBlockExtension(*currentMultiple, singleList, &newAlignments)) {
1148  if (newAlignments.size() != 1) {
1149  ERRORMSG("AlignmentManager::ExtendUpdate() - returned alignment list size != 1!");
1150  return;
1151  }
1152 
1153  // replace original alignment with extended one
1154  UpdateViewer::AlignmentList::const_iterator a, ae = updateViewer->GetCurrentAlignments().end();
1155  bool foundSingle = false; // sanity check
1156  for (a=updateViewer->GetCurrentAlignments().begin(); a!=ae; ++a) {
1157  if (*a == single) {
1158  replacedList.push_back(newAlignments.front());
1159  foundSingle = true;
1160  } else
1161  replacedList.push_back((*a)->Clone());
1162  }
1163  if (!foundSingle)
1164  ERRORMSG("AlignmentManager::ExtendUpdate() - changed alignment not found in update viewer!");
1165  updateViewer->ReplaceAlignments(replacedList);
1166  }
1167 }
1168 
1169 END_SCOPE(Cn3D)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static int GetAlignedResidueIndexes(BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator &b, BlockMultipleAlignment::UngappedAlignedBlockList::const_iterator &be, int row, int *seqIndexes, bool countHighlights=false, const BlockMultipleAlignment *multiple=NULL)
USING_SCOPE(objects)
static bool NoBlockBoundariesBetween(int masterFrom, int masterTo, const AlignmentManager::PairwiseAlignmentList &alignments)
static bool AlignedToAllDependents(int masterResidue, const AlignmentManager::PairwiseAlignmentList &alignments)
static bool CreateNewPairwiseAlignmentsByBlockExtension(const BlockMultipleAlignment &multiple, const UpdateViewer::AlignmentList &toExtend, UpdateViewer::AlignmentList *newAlignments)
USING_NCBI_SCOPE
static bool NoDependentInsertionsBetween(int masterFrom, int masterTo, const AlignmentManager::PairwiseAlignmentList &alignments)
void NewAlignments(const SequenceSet *sSet, const AlignmentSet *aSet)
const SequenceSet * sequenceSet
void BlockAlignUpdate(BlockMultipleAlignment *single)
void ShowSequenceViewer(bool showNow) const
bool IsInAlignment(const Sequence *sequence) const
void RealignAllDependentStructures(bool highlightedOnly) const
AlignmentManager(const SequenceSet *sSet, const AlignmentSet *aSet)
void CalculateRowScoresWithThreader(double weightPSSM)
std::vector< unsigned int > originalRowOrder
void PurgeSequence(const MoleculeIdentifier *identifier)
UpdateViewer * updateViewer
void RealignDependentSequences(BlockMultipleAlignment *multiple, const std::vector< unsigned int > &dependentsToRealign)
BlockMultipleAlignment * CreateMultipleFromPairwiseWithIBM(const PairwiseAlignmentList &alignments)
void BlockAlignAllUpdates(void)
void ExtendUpdate(BlockMultipleAlignment *single)
const Vector * GetAlignmentColor(const Sequence *sequence, unsigned int seqIndex, StyleSettings::eColorScheme colorScheme) const
void ShowHideCallbackFunction(const std::vector< bool > &itemsEnabled)
void ShowUpdateWindow(void) const
virtual ~AlignmentManager(void)
void GetUpdateSequences(std::list< const Sequence * > *updateSequences) const
std::map< BlockMultipleAlignment *, bool > UpdateMap
void GetAlignmentSetDependentVisibilities(std::vector< bool > *visibilities) const
std::list< ncbi::CRef< ncbi::objects::CUpdate_align > > UpdateAlignList
SequenceViewer * sequenceViewer
bool GetStructureProteins(std::vector< const Sequence * > *chains) const
BlockMultipleAlignment * originalMultiple
unsigned int NUpdates(void) const
void ThreadUpdate(const ThreaderOptions &options, BlockMultipleAlignment *single)
void SavePairwiseFromMultiple(const BlockMultipleAlignment *multiple, const std::vector< unsigned int > &rowOrder)
const BlockMultipleAlignment * GetCurrentMultipleAlignment(void) const
std::vector< bool > dependentsVisible
BlockAligner * blockAligner
void ReplaceUpdatesInASN(ncbi::objects::CCdd::TPending &newUpdates) const
bool IsAligned(const Sequence *sequence, unsigned int seqIndex) const
void NewMultipleWithRows(const std::vector< bool > &visibilities)
void MergeUpdates(const UpdateMap &updates, bool mergeToNeighbor)
const AlignmentSet * alignmentSet
std::list< const MasterDependentAlignment * > PairwiseAlignmentList
void GetAlignmentSetDependentSequences(std::vector< const Sequence * > *sequences) const
void ThreadAllUpdates(const ThreaderOptions &options)
AlignmentList alignments
const Sequence * master
static AlignmentSet * CreateFromMultiple(const BlockMultipleAlignment *multiple, SeqAnnotList *newAsnAlignmentData, const SequenceSet &sequenceSet, const std::vector< unsigned int > *rowOrder=NULL)
bool CreateNewPairwiseAlignmentsByBlockAlignment(BlockMultipleAlignment *multiple, const AlignmentList &toRealign, AlignmentList *newAlignments, int *nRowsAddedToMultiple, SequenceViewer *sequenceViewer)
std::list< BlockMultipleAlignment * > AlignmentList
BlockMultipleAlignment * Clone(void) const
std::vector< const Sequence * > SequenceList
const UnalignedBlock * GetUnalignedBlockBefore(const UngappedAlignedBlock *aBlock) const
bool MoveBlockBoundary(unsigned int columnFrom, unsigned int columnTo)
ncbi::CRef< ncbi::objects::CUpdate_align > updateOrigin
const Vector * GetAlignmentColor(const Sequence *sequence, unsigned int seqIndex, StyleSettings::eColorScheme colorScheme) const
const BLAST_Matrix * GetPSSM(void) const
const Sequence * GetMaster(void) const
std::vector< const UngappedAlignedBlock * > UngappedAlignedBlockList
bool ExtractRows(const std::vector< unsigned int > &slavesToRemove, AlignmentList *pairwiseAlignments)
const Sequence * GetSequenceOfRow(unsigned int row) const
unsigned int GetAlignedBlockNumber(unsigned int alignmentIndex) const
void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const
unsigned int GetAlignmentIndex(unsigned int row, unsigned int seqIndex, eUnalignedJustification justification)
bool UpdateBlockMapAndColors(bool clearRowInfo=true)
const SequenceList * GetSequences(void) const
bool MergeBlocks(unsigned int fromAlignmentIndex, unsigned int toAlignmentIndex)
bool IsAligned(unsigned int row, unsigned int seqIndex) const
bool AddAlignedBlockAtEnd(UngappedAlignedBlock *newBlock)
bool MergeAlignment(const BlockMultipleAlignment *newAlignment)
const UnalignedBlock * GetUnalignedBlockAfter(const UngappedAlignedBlock *aBlock) const
void SetRangeOfRow(unsigned int row, int from, int to)
unsigned int width
void PostRedrawMolecule(const Molecule *molecule)
Definition: messenger.cpp:85
void PostRedrawAllStructures(void)
Definition: messenger.cpp:79
void UnPostRedrawSequenceViewer(ViewerBase *viewer)
Definition: messenger.cpp:106
void RemoveSequenceViewer(const ViewerBase *sequenceViewer)
Definition: messenger.cpp:174
void AddSequenceViewer(ViewerBase *sequenceViewer)
Definition: messenger.hpp:182
void PostRedrawAllSequenceViewers(void)
Definition: messenger.cpp:90
static const int VALUE_NOT_SET
std::string ToString(void) const
int GetAlphaCoords(int nResidues, const int *seqIndexes, const Vector **coords) const
Definition: molecule.cpp:246
void GetProteinSequences(SequenceList *seqs) const
void RowsAdded(unsigned int nRowsAddedToMultiple, BlockMultipleAlignment *multiple, int where=-1)
void RowsRemoved(const std::vector< unsigned int > &rowsRemoved, const BlockMultipleAlignment *multiple)
SequenceList sequences
Definition: cav_seqset.hpp:73
void CreateSequenceWindow(bool showNow)
void DisplayAlignment(BlockMultipleAlignment *multipleAlignment)
void TurnOnEditor(void)
void DisplaySequences(const SequenceList *sequenceList)
const Molecule * molecule
const MoleculeIdentifier * identifier
unsigned int Length(void) const
string sequenceString
Definition: cav_seqset.hpp:93
int GetOrSetMMDBLink(void) const
void Show(const StructureBase *entity, bool isShown)
StructureSet * parentSet
bool GetParentOfType(const T **ptr, bool warnIfNotFound=true) const
static const unsigned int eRowOrderData
void InitStructureAlignments(int masterMMDBID)
void ReplaceAlignmentSet(AlignmentSet *newAlignmentSet)
void RemoveStructureAlignments(void)
ShowHideManager * showHideManager
void ReplaceUpdates(ncbi::objects::CCdd::TPending &newUpdates)
void SetDataChanged(unsigned int what) const
StyleManager * styleManager
static const unsigned int ePSSMData
std::list< BlockMultipleAlignment * > AlignmentList
bool Realign(const ThreaderOptions &options, BlockMultipleAlignment *masterMultiple, const AlignmentList *originalAlignments, AlignmentList *newAlignments, unsigned int *nRowsAddedToMultiple, SequenceViewer *sequenceViewer)
bool CalculateScores(const BlockMultipleAlignment *multiple, double weightPSSM)
void SavePendingStructures(void)
void ReplaceAlignments(const AlignmentList &alignmentList)
void AddAlignments(const AlignmentList &alignmentList)
std::list< BlockMultipleAlignment * > AlignmentList
void CreateUpdateWindow(void)
void SetInitialState(void)
std::list< BlockMultipleAlignment * > AlignmentList
Definition: viewer_base.hpp:89
SequenceDisplay * GetCurrentDisplay(void)
bool EditorIsOn(void) const
void Refresh(void)
const AlignmentList & GetCurrentAlignments(void) const
Definition: map.hpp:338
#define TRACEMSG(stream)
Definition: cn3d_tools.hpp:83
#define INFOMSG(stream)
Definition: cn3d_tools.hpp:84
#define WARNINGMSG(stream)
Definition: cn3d_tools.hpp:85
#define ERRORMSG(stream)
Definition: cn3d_tools.hpp:86
Include a standard set of the NCBI C++ Toolkit most basic headers.
struct parameters_t * pb[]
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
Definition: ncbidiag.cpp:6132
@ eDiag_Info
Informational message.
Definition: ncbidiag.hpp:651
@ eDiag_Warning
Warning message.
Definition: ncbidiag.hpp:652
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
TNumRows GetNumRows(void) const
Get the NumRows member data.
Definition: Pssm_.hpp:610
bool IsSetFinalData(void) const
Final representation for the PSSM Check if a value has been assigned to FinalData data member.
Definition: Pssm_.hpp:802
TH GetH(void) const
Get the H member data.
TKappa GetKappa(void) const
Get the Kappa member data.
const TScores & GetScores(void) const
Get the Scores member data.
TScalingFactor GetScalingFactor(void) const
Get the ScalingFactor member data.
const TFinalData & GetFinalData(void) const
Get the FinalData member data.
Definition: Pssm_.hpp:814
TNumColumns GetNumColumns(void) const
Get the NumColumns member data.
Definition: Pssm_.hpp:657
TByRow GetByRow(void) const
Get the ByRow member data.
Definition: Pssm_.hpp:735
const TPssm & GetPssm(void) const
Get the Pssm member data.
TLambda GetLambda(void) const
Get the Lambda member data.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is smart and slim</td> n<td> orig</td> n</tr> n<tr> n<td> last_modified</td> n<td> optional</td> n<td> Integer</td> n<td class=\"description\"> The blob last modification If provided then the exact match will be requested with n the Cassandra storage corresponding field value</td> n<td> Positive integer Not provided means that the most recent match will be selected</td> n<td></td> n</tr> n<tr> n<td> use_cache</td> n<td> optional</td> n<td> String</td> n<td class=\"description\"> The option controls if the Cassandra LMDB cache and or database should be used It n affects the seq id resolution step and the blob properties lookup step The following n options are available
int i
if(yy_accept[yy_current_state])
yy_size_t n
Messenger * GlobalMessenger(void)
Definition: messenger.cpp:73
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
unsigned int a
Definition: ncbi_localip.c:102
EIPRangeType t
Definition: ncbi_localip.c:101
bool ne(T x_, T y_, T round_)
Definition: njn_approx.hpp:82
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define U
#define row(bind, expected)
Definition: string_bind.c:73
unsigned int pairBlock
static DP_BlockInfo * blocks
static int GetBLOSUM62Score(char a, char b)
Modified on Fri Sep 20 14:58:29 2024 by modify_doxy.py rev. 669887