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

Go to the SVN repository for this file.

1 /* $Id: cuCD.cpp 95643 2021-12-03 16:24:20Z 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  * Author: Adapted from CDTree-1 code by Chris Lanczycki
27  *
28  * File Description:
29  *
30  * High-level algorithmic operations on one or more CCd objects.
31  * (methods that only traverse the cdd ASN.1 data structure are in
32  * placed in the CCd class itself)
33  *
34  * ===========================================================================
35  */
36 
37 #include <ncbi_pch.hpp>
40 #include <objects/cdd/Cdd.hpp>
41 #include <objects/cdd/Cdd_id.hpp>
45 
49 
58 #include "corelib/ncbitime.hpp"
59 #include <objects/general/Date.hpp>
67 #include <math.h>
68 
70 BEGIN_SCOPE(cd_utils)
71 
72 
74 //-------------------------------------------------------------------------
75 // return an error code indicating which, if any, checks went wrong.
76 // return value of 0 indicates all checks were ok.
77 //-------------------------------------------------------------------------
78  int RetVal = 0;
79 
80  if (!cd->AlignAnnotsValid()) {
81  RetVal = RetVal | ALIGN_ANNOTS_VALID_FAILURE;
82  }
83  return(RetVal);
84 }
85 
86 
87 
88 
89 void ResetFields(CCdCore* cd) {
90  if (cd) {
91  cd->ResetProfile_range();
92  cd->ResetTrunc_master();
93  cd->ResetPosfreq();
94  cd->ResetScoremat();
95  cd->ResetDistance();
96  cd->ResetFeatures();
97  cd->EraseUID();
98  list< CRef< CCdd_descr > >& cdDescrList = cd->SetDescription().Set();
99  list< CRef< CCdd_descr > >::iterator lit = cdDescrList.begin();
100  while (lit != cdDescrList.end())
101  {
102  if ((*lit)->IsRepeats())
103  lit = cdDescrList.erase(lit);
104  else
105  lit++;
106  }
107  }
108 }
109 
110 
111 
112 bool Reorder(CCdCore* pCD, const vector<int> positions)
113 {
114  if (!pCD->IsSeqAligns() || positions.size() == 0)
115  return false;
116 
117 // list< CRef< CSeq_align > >& alignments = (*(pCD->SetSeqannot().begin()))->SetData().SetAlign();
118  list< CRef< CSeq_align > >& alignments = pCD->GetSeqAligns();
119  if (alignments.size() != positions.size())
120  return false;
121 
122  vector<CRef< CSeq_align > > temp(alignments.size());
123  list<CRef< CSeq_align > >::iterator lit = alignments.begin();
124  int row = 0;
125  //copy aligment rows to the vector in order
126  for(;lit != alignments.end(); lit++)
127  {
128  //sanity check
129  if (positions[row] >= (int) temp.size())
130  return false;
131  temp[positions[row]] = *lit;
132  row++;
133  }
134 
135  // Before moving the alignments around, reorder the structural alignments to reflect
136  // the new ordering of the rows. If there was a problem, the structural alignments
137  // are left in their original order.
138  ReorderStructureAlignments(pCD, positions);
139 
140  alignments.clear();
141  for (unsigned int i = 0; i < temp.size(); i++)
142  {
143  alignments.push_back(temp[i]);
144  }
145  return true;
146 }
147 
148 bool ReorderStructureAlignments(CCdCore* pCD, const vector<int>& positions)
149 {
150  bool result = false;
151  if (!pCD || !pCD->IsSeqAligns() || positions.size() == 0 || !pCD->Has3DMaster())
152  return result;
153 
154  typedef CBiostruc_feature_set::TFeatures TStructureAlignments;
155  TStructureAlignments::iterator saListIt, saListEnd;
156 
158  TSAMap saMapTmp;
159  TSAMap::iterator saMapIt, saMapEnd;
160 
161  const CPDB_seq_id* pdbId = NULL;
162 
163  unsigned int i, nRows = (unsigned) pCD->GetNumRows();
164  int n3DAlign = pCD->Num3DAlignments(), nPDBs = 0;
165  if (nRows-1 != positions.size())
166  return result;
167 
168  if (!pCD->IsSetFeatures() || pCD->GetFeatures().GetFeatures().size() == 0) {
169  return result;
170  }
171 
172  TStructureAlignments& saList = pCD->SetFeatures().SetFeatures().front()->SetFeatures();
173  saListIt = saList.begin();
174  saListEnd = saList.end();
175 
176  // For each non-master row, check if it's a structure. If so, add the corresponding
177  // structure alignment to the temporary map indexed by the *new* position. Recall that
178  // positions does not include an entry for the master and positions[0] is the new position
179  // of row 1.
180  int si;
181  for (i = 0; i < (nRows - 1) && saListIt != saListEnd; ++i) {
182  si = (int) i;
183  if (pCD->GetPDB(si+1, pdbId)) {
184  saMapTmp.insert(TSAMap::value_type(positions[si], *saListIt));
185  ++saListIt;
186  ++nPDBs;
187  }
188  }
189 
190  // The number of non-master PDBs founds should be the same as the number of
191  // structural alignments. If not, then there's no way to know how to reorder
192  // them --> leave them in the original state.
193  if (nPDBs == n3DAlign) {
194  saList.clear();
195  saMapIt = saMapTmp.begin();
196  saMapEnd = saMapTmp.end();
197  for (; saMapIt != saMapEnd; ++saMapIt) {
198  saList.push_back(saMapIt->second);
199  }
200  result = true;
201  }
202  saMapTmp.clear();
203 
204  return result;
205 }
206 
208  bool result = true;
209  if (cd) {
210  //add creation date
211  list< CRef< CCdd_descr > > & descList = cd->SetDescription().Set();
212  list< CRef< CCdd_descr > >::iterator it = descList.begin();
213  for(; it != descList.end(); it++)
214  {
215  if((*it)->IsCreate_date())
216  {
217  descList.erase(it);
218  break;
219  }
220  }
221  CTime cur(CTime::eCurrent);
222  CDate* curDate = new CDate(cur, CDate::ePrecision_day);
223  if (curDate) {
224  CRef< CCdd_descr > dateDesc(new CCdd_descr);
225  dateDesc->SetCreate_date(*curDate);
226  descList.push_back(dateDesc);
227  } else {
228  result = false;
229  }
230  }
231  return result;
232 }
233 
235  bool result = true;
236  if (cd) {
237  //add creation date
238  list< CRef< CCdd_descr > > & descList = cd->SetDescription().Set();
239  list< CRef< CCdd_descr > >::iterator it = descList.begin();
240  for(; it != descList.end(); it++)
241  {
242  if((*it)->IsUpdate_date())
243  {
244  descList.erase(it);
245  break;
246  }
247  }
248  CTime cur(CTime::eCurrent);
249  CDate* curDate = new CDate(cur, CDate::ePrecision_day);
250  if (curDate) {
251  CRef< CCdd_descr > dateDesc(new CCdd_descr);
252  dateDesc->SetUpdate_date(*curDate);
253  descList.push_back(dateDesc);
254  } else {
255  result = false;
256  }
257  }
258  return result;
259 }
260 
261 // If ncbiMime contains a CD, return it. Otherwise return NULL.
263 
264  CCdCore* pCD = NULL;
265 
266  // Only mime type defined w/ a CD in it is 'general' == Biostruc-seqs-aligns-cdd,
267  // whose 'seq-align-data' choice object must have a cd. Ignore the additional
268  // 'structures' and 'structure-type' fields.
269  if (ncbiMime && ncbiMime->IsGeneral() && ncbiMime->GetGeneral().GetSeq_align_data().IsCdd()) {
270  const CCdd* tmpCCdd = &ncbiMime->GetGeneral().GetSeq_align_data().GetCdd();
271  pCD = CopyCD((const CCdCore*) tmpCCdd);
272  }
273 
274  return pCD;
275 }
276 
277 // from cdt_frame.cpp
278 // Wraps a call to CopyASNObject
279 // If copyNonASNMembers = true, all statistics, sequence strings and aligned residues
280 // data structures are copied. The CD's read status is *always* copied.
281 CCdCore* CopyCD(const CCdCore* cd) {
282 
283  string err;
284 
285  if (cd != NULL) {
286  CCdCore* newCD = CopyASNObject(*cd, &err);
287  return newCD;
288  //return CopyASNObject(*cd, &err);
289  }
290  return NULL;
291 }
292 
293 // For a specified row in cd1, find all potential matches in cd2.
294 // If cd1 == cd2, returns row1 plus any other matches (should be exactly one in a valid CD)
295 // If cd1AsChild == true, mapping assumes cd2 is parent of cd1.
296 // If cd1AsChild == false, mapping assumes cd1 is parent of cd2.
297 // In 'overlapMode', returns the row index of cd2 for *any* overlap with row1.
298 // Return number of rows found.
299 // (except for interface, almost the same as the CFootprint::isMemberOf methods;
300 // CFootprint is streamlined by factoring out the check on Seq_id's)
301 int GetMappedRowIds(CCdCore* cd1, int row1, CCdCore* cd2, vector<int>& rows2, bool cd1AsChild, bool overlapMode) {
302 
303  int Lower, Upper, Lower2, Upper2;
304  int NumMatches;
305  vector<int> matches;
306  CRef<CSeq_id> SeqId;
307 
308  // Each CD must be valid, and row1 must be valid
309  if (cd1 == NULL || cd2 == NULL || !cd1->GetSeqIDFromAlignment(row1, SeqId)) {
310  rows2.clear();
311  return 0;
312  }
313 
314  // get its alignment range
315  Lower = cd1->GetLowerBound(row1);
316  Upper = cd1->GetUpperBound(row1);
317 
318  matches.clear();
319  NumMatches = cd2->GetAllRowIndicesForSeqId(SeqId, matches); // find all row indices for a seqID (return # found)
320  if (NumMatches) {
321 
322  // for each of the matches
323  for (int j=0; j<NumMatches; j++) {
324  Lower2 = cd2->GetLowerBound(matches[j]);
325  Upper2 = cd2->GetUpperBound(matches[j]);
326  if (overlapMode) { // if the alignment ranges overlap
327  if (((Lower2 >= Lower) && (Lower2 <= Upper)) ||
328  ((Upper2 >= Lower) && (Upper2 <= Upper)) ||
329  ((Lower2 <= Lower) && (Upper2 >= Upper)) ||
330  ((Lower2 >= Lower) && (Upper2 <= Upper))) {
331  rows2.push_back(matches[j]);
332  }
333  } else if (cd1AsChild) { // cd1 == child; cd2 == parent
334  if ((Lower2 >= Lower) && (Upper2 <= Upper)) {
335  rows2.push_back(matches[j]);
336  }
337  } else { // cd2 == child; cd1 == parent
338  if ((Lower2 <= Lower) && (Upper2 >= Upper)) {
339  rows2.push_back(matches[j]);
340  }
341  }
342  }
343  }
344  return rows2.size();
345 }
346 
347 // from cdt_summary_box.cpp
348 
349 // Get overlaps of cd1 with cd2 (no parent/child relationship between CDs is assumed).
350 // If cd2 == NULL and cd1 is valid, looks for overlaps in that single CD.
351 // If cd1 == cd2, also looks for overlaps in a single CD.
352 int GetOverlappedRows(CCdCore* cd1, CCdCore* cd2, vector<int>& rowsOfCD1, vector<int>& rowsOfCD2) {
353 //------------------------------------------------------------------------
354 // get the accessions of all newest-version CDs that have aligned residues
355 // that overlap aligned residues from this CD
356 //------------------------------------------------------------------------
357 
358  int RowIndex1, NumRows = cd1->GetNumRows();
359  int NumMatches = 0;
360  vector<int> matches;
361  CRef<CSeq_id> SeqId;
362 
363  bool sameCD = (cd1 == cd2 || !cd2) ? true : false;
364 
365 // don't clear rows in case want to accummulate all overlaps in one container
366 // rowsOfCD1.clear();
367 // rowsOfCD2.clear();
368  if (cd1 == NULL && cd2 == NULL) return 0;
369  if (sameCD && !cd2) {
370  cd2 = cd1;
371  }
372 
373  // for each row of CD1
374  for (RowIndex1=0; RowIndex1<NumRows; RowIndex1++) {
375  matches.clear();
376  NumMatches = GetMappedRowIds(cd1, RowIndex1, cd2, matches, true, true);
377  if (NumMatches) {
378  // when looking in a single CD, expect to find exactly one.
379  if (sameCD && NumMatches == 1) {
380  continue;
381  }
382 
383  // for each of the matches
384  for (int j=0; j<NumMatches; j++) {
385  // when looking in a single CD, skip the self-match
386  if (sameCD && matches[j] == RowIndex1) {
387  continue;
388  }
389  // add overlap
390  rowsOfCD1.push_back(RowIndex1);
391  rowsOfCD2.push_back(matches[j]);
392  }
393  }
394  }
395  return rowsOfCD1.size();
396 }
397 
398 
399 
400 
401 // Just check if have overlapped rows; returns the number of overlap.
402 // Ignore any self-overlaps when cd1==cd2.
404  vector<int> rows1, rows2;
405  return GetOverlappedRows(cd1, cd2, rows1, rows2);
406 }
407 
408 void SetConvertedSequencesForCD(CCdCore* cd, vector<string>& convertedSequences, bool forceRecompute) {
409 
410  if (!cd || (convertedSequences.size() > 0 && !forceRecompute)) {
411  return;
412  }
413 
414  int numSeq = cd->GetNumSequences();
415 
416  convertedSequences.clear();
417  for (int i = 0; i < numSeq; ++i) {
418  convertedSequences.push_back(cd->GetSequenceStringByIndex(i));
419  }
420 }
421 
422 void SetAlignedResiduesForCD(CCdCore* cd, char** & ppAlignedResidues, bool forceRecompute) {
423 //-------------------------------------------------------------------------
424 // allocate space for, and make, an array of all aligned residues
425 //-------------------------------------------------------------------------
426  bool isMaster;
427 
428  string s;
429  int numRows = cd->GetNumRows();
430  int numAligned = cd->GetAlignmentLength();
431 
432  CRef< CSeq_align > seqAlign;
433 
434  // if space isn't allocated yet, allocate space for array of aligned residues
435  if (ppAlignedResidues == NULL) {
436  ppAlignedResidues = new char*[numRows];
437  for (int i=0; i<numRows; i++) {
438  ppAlignedResidues[i] = new char[numAligned];
439  }
440  // if space is already allocated then safe to assume array's been filled in
441 // } else {
442 // return;
443  } else if (!forceRecompute) {
444  return;
445  }
446 
447  for (int i = 0; i < numRows; i++) {
448  s = cd->GetSequenceStringByRow(i);
449  if (s.size() > 0) {
450  if (cd->GetSeqAlign(i, seqAlign)) {
451  isMaster = (i == 0);
452  SetAlignedResiduesOnSequence(seqAlign, s, ppAlignedResidues[i], isMaster);
453  }
454  }
455  }
456 }
457 
458 void GetAlignmentColumnsForCD(CCdCore* cd, map<unsigned int, string>& columns, unsigned int referenceRow)
459 {
460  bool isOK = true, useRefRow = true;
461  int j;
462  unsigned int i, col, row, pos, mapIndex, nRows, nCols, nBlocks;
463  char** alignedResidues = NULL;
464  string rowString, colString;
465  // Map column number to position on the selected reference row.
467  map<unsigned int, string> rowStrings;
468  vector<int> starts, lengths;
469  CRef< CSeq_align > seqAlign;
470 
471  // Empty the columns map first, as this is used as a way to flag problems.
472  columns.clear();
473 
474  if (!cd) return;
475 
476  // Check if the block structure is consistent.
477  try {
478  MultipleAlignment* ma = new MultipleAlignment(cd);
479  if (!ma) {
480  ERR_POST("Creation of MultipleAlignment object failed for CD " << cd->GetAccession() << ".");
481  return;
482  } else if (! ma->isBlockAligned()) {
483  delete ma;
484  ERR_POST("CD " << cd->GetAccession() << " must have a consistent block structure for column extraction.");
485  return;
486  }
487  delete ma;
488  ma = NULL;
489  } catch (...) {
490  ERR_POST("Could not extract columns for CD " << cd->GetAccession());
491  }
492 
493  nCols = cd->GetAlignmentLength();
494  nRows = cd->GetNumRows();
495 
496  // Get a reference seq-align for mapping between alignment rows.
497  // If the columns map index will simply be the column count, use the master, row 0.
498  if (referenceRow >= nRows) {
499  useRefRow = false;
500  referenceRow = 0;
501  }
502  if (! cd->GetSeqAlign(referenceRow, seqAlign)) {
503  isOK = false;
504  }
505 
506  // Initialize the column # -> reference row position mapping.
507  // If useRefRow is true, use the indicated row's coordinates as the position.
508  // Otherwise, use the column number as the position.
509  if (isOK && GetBlockStarts(seqAlign, starts, (referenceRow == 0)) > 0 && GetBlockLengths(seqAlign, lengths) > 0) {
510  nBlocks = starts.size();
511  if (nBlocks == lengths.size()) {
512  for (i = 0, col = 0; i < nBlocks; ++i) {
513  pos = (useRefRow) ? starts[i] : col;
514  for (j = 0; j < lengths[i]; ++j, ++col, ++pos) {
515  // Not explicitly checking if 'pos' is aligned since above
516  // we confirmed the CD has a valid block model.
517  colToPos[col] = pos;
518  }
519  }
520  } else {
521  isOK = false;
522  }
523  } else {
524  isOK = false;
525  }
526 
527  SetAlignedResiduesForCD(cd, alignedResidues, true);
528 
529  // Construct the columns as string objects.
530  if (isOK && alignedResidues) {
531  for (col = 0; col < nCols; ++col) {
532  colString.erase();
533  for (row = 0; row < nRows; ++row) {
534  colString += alignedResidues[row][col];
535  }
536  mapIndex = colToPos[col];
537  columns[mapIndex] = colString;
538  }
539  }
540 
541  // Clean up array of characters.
542  if (alignedResidues) {
543  for (row = 0; row < nRows; ++row) {
544  delete [] alignedResidues[row];
545  }
546  delete [] alignedResidues;
547  }
548 
549 }
550 
551 string GetVerboseNameStr(const CCdCore* cd) {
552  return ((cd) ? cd->GetAccession() + " (" + cd->GetName() + ")" : "");
553 }
554 
555 
556 // deprecated by dih, written by charlie.
557 // gets a bioseq and seqloc for master row. also puts in a seq-id which identifies cd of origin.
559 {
560  //get master bioseq
561  CRef< CBioseq > masterBioseq(new CBioseq);
562  CRef< CBioseq > bioseq;
563  cd->GetBioseqForRow(0, bioseq);
564  masterBioseq->Assign(*bioseq);
565  //add local seq-id of cd accession
566  list< CRef< CSeq_id > >& idList = masterBioseq->SetId();
567  CRef< CSeq_id > seqIdRef(new CSeq_id(CSeq_id::e_Local, cd->GetAccession(), ""));
568  idList.push_back(seqIdRef);
569  //add seq-loc of footprint
570  list< CRef< CSeq_annot > >& seqAnnots = masterBioseq->SetAnnot();
571  CRef< CSeq_annot > seqAnnot(new CSeq_annot);
572  list< CRef< CSeq_loc > >& seqlocs = seqAnnot->SetData().SetLocs();
573  CRef< CSeq_loc > seqLoc(new CSeq_loc((**idList.begin()), cd->GetLowerBound(0), cd->GetUpperBound(0)));
574  seqlocs.push_back(seqLoc);
575  seqAnnots.push_back(seqAnnot);
576  return masterBioseq;
577 }
578 
579 
581 //-------------------------------------------------------------------------
582 // same as GetMasterBioseqWithFootprintOld but uses
583 // GetBioseqWithFootprintForNthRow.
584 //-------------------------------------------------------------------------
585  string errstr;
586  return(GetBioseqWithFootprintForNthRow(cd, 0, errstr));
587 }
588 
589 
591 //-------------------------------------------------------------------------
592 // copied from Charlie's function GetMasterBioseqWithFootprintOld.
593 // gets bioseq and seqloc for any row, not just master
594 //-------------------------------------------------------------------------
595  CRef< CBioseq > BioseqForNthRow(new CBioseq);
596  CRef< CBioseq > bioseq;
597 
598  errstr.erase();
599  if (N >= cd->GetNumRows()) {
600  errstr = "can't return bioseq for " + NStr::IntToString(N)
601  + "th row, because CD has only "
602  + NStr::IntToString(cd->GetNumRows()) + "rows.\n";
603  BioseqForNthRow->Assign(*bioseq);
604  return(BioseqForNthRow);
605  }
606  //get bioseq for Nth row.
607  cd->GetBioseqForRow(N, bioseq);
608  BioseqForNthRow->Assign(*bioseq);
609  //add local seq-id of cd accession
610  list< CRef< CSeq_id > >& idList = BioseqForNthRow->SetId();
611  CRef< CSeq_id > seqIdRef(new CSeq_id(CSeq_id::e_Local, cd->GetAccession(), ""));
612  idList.push_back(seqIdRef);
613  //add seq-loc of footprint
614  list< CRef< CSeq_annot > >& seqAnnots = BioseqForNthRow->SetAnnot();
615  CRef< CSeq_annot > seqAnnot(new CSeq_annot);
616  list< CRef< CSeq_loc > >& seqlocs = seqAnnot->SetData().SetLocs();
617  CRef< CSeq_loc > seqLoc(new CSeq_loc((**idList.begin()), cd->GetLowerBound(N), cd->GetUpperBound(N)));
618  seqlocs.push_back(seqLoc);
619  seqAnnots.push_back(seqAnnot);
620  return BioseqForNthRow;
621 }
622 
623 
624 bool GetBioseqWithFootprintForNRows(CCdCore* cd, int N, vector< CRef< CBioseq > >& bioseqs, string& errstr) {
625 //-------------------------------------------------------------------------
626 // get bioseqs and seq-locs for the first N rows of cd.
627 // if cd has less than N rows, return bioseqs and seq-locs for all rows.
628 //-------------------------------------------------------------------------
629  N = N <= cd->GetNumRows() ? N : cd->GetNumRows();
630  bioseqs.clear();
631  for (int i=0; i<N; i++) {
632  bioseqs.push_back(GetBioseqWithFootprintForNthRow(cd, i, errstr));
633  if (!errstr.empty()) return(false);
634  }
635  return(true);
636 }
637 
638 
639 CRef< COrg_ref > GetCommonTax(CCdCore* cd, bool useRootWhenNoTaxInfo)
640 {
641  TTaxId comTax = ZERO_TAX_ID;
642  CRef< COrg_ref > orgRef;
643  CTaxon1 taxServer;
644  if (!taxServer.Init())
645  return orgRef;
646 
647  bool is_species;
648  bool is_uncultured;
649  string blast_name;
650  int num = cd->GetNumRows();
651 
652  for (int i = 0; i < num; i++)
653  {
654  TGi gi = INVALID_GI;
655  cd->GetGI(i,gi,false);
656  TTaxId taxid = ZERO_TAX_ID;
657  if (gi > ZERO_GI)
658  taxServer.GetTaxId4GI(gi, taxid);
659  if (taxid == ZERO_TAX_ID)
660  {
661  CRef< CBioseq > bioseq;
662  if (cd->GetBioseqForRow(i, bioseq))
663  {
664  taxid = GetTaxIdInBioseq(*bioseq);
665  }
666  }
667 
668  if (taxid > ZERO_TAX_ID)
669  {
670  if (comTax == ZERO_TAX_ID)
671  comTax = taxid;
672  else
673  {
674  TTaxId joined = taxServer.Join(comTax, taxid);
675  if (joined == ZERO_TAX_ID)
676  {
677  LOG_POST("Failed to join two taxids:"<<comTax<<" and "<<taxid<<". The latter one is ignored.");
678  }
679  else
680  comTax = joined;
681  }
682  }
683  if (comTax == TAX_ID_CONST(1)) //reach root
684  break;
685  }
686 
687  // The condition 'comTax == 0' is true only if no row satisfied (taxid > 0) above.
688  // Use root tax node as common tax node unless told not to.
689  if (comTax == ZERO_TAX_ID && useRootWhenNoTaxInfo)
690  comTax = TAX_ID_CONST(1);
691 
692  orgRef = new COrg_ref;
693  if (comTax > ZERO_TAX_ID) {
694  orgRef->Assign(*taxServer.GetOrgRef(comTax, is_species, is_uncultured, blast_name));
695  } else {
696  orgRef.Reset();
697  }
698  return orgRef;
699 }
700 
702  bool isAncestors;
703  bool result = false;
704  int nAncestors, nClassical = 0;
705 
706  if (pCD) {
707  // Check that one or neither of 'ancestors' or 'parent' is set.
708  // If the later is set, automatically means a single classical parent.
709  isAncestors = pCD->IsSetAncestors();
710  result = (isAncestors) ? !pCD->IsSetParent() : true;
711  if (result && isAncestors) {
712  list< CRef< CDomain_parent > >::const_iterator pit = pCD->GetAncestors().begin(), pit_end = pCD->GetAncestors().end();
713  while (pit != pit_end) {
714  if ((*pit)->GetParent_type() == CDomain_parent::eParent_type_classical) {
715  ++nClassical;
716  }
717  ++pit;
718  }
719  nAncestors = pCD->GetAncestors().size();
720  result = ((nClassical == 1 && nAncestors == 1) ||
721  (nClassical == 0 && nAncestors > 0));
722  }
723  }
724  return result;
725 }
726 
727 
728 bool RemasterWithStructure(CCdCore* cd, string* msg)
729 {
730  static const string msgHeader = "Remastering CD to ";
731 
732  CRef< CSeq_id > seqId;
733  cd->GetSeqIDForRow(0,0,seqId);
734  if (seqId->IsPdb())
735  return false;
737  int nrows = ac.GetNumRows();
738  int i = 1;
739  for (; i < nrows; i++)
740  {
741  ac.GetSeqIDForRow(i,seqId);
742  if (seqId->IsPdb())
743  break;
744  }
745  if ( i < nrows)
746  {
748  if (msg) {
749  *msg = msgHeader + seqId->AsFastaString();
750  }
751  return true;
752  }
753  else
754  return false;
755 }
756 
757 bool ReMasterCdWithoutUnifiedBlocks(CCdCore* cd, int Row, bool resetFields)
758 {
759  if (Row == 0)
760  return true;
761  list<CRef< CSeq_align > >& seqAlignList = cd->GetSeqAligns();
762  const CRef< CSeq_align >& guide = cd->GetSeqAlign(Row);
763  BlockModelPair guideBmp(guide);
764  int i = 1;
765  list<CRef< CSeq_align > >::iterator lit = seqAlignList.begin();
766  list<CRef< CSeq_align > >::iterator guideIt;
767  for (; lit != seqAlignList.end(); lit++)
768  {
769  if ( i != Row)
770  {
771  BlockModelPair bmp (*lit);
772  bmp.remaster(guideBmp);
773  *lit = bmp.toSeqAlign();
774  }
775  else
776  guideIt = lit;
777  i++;
778  }
779  guideBmp.reverse();
780  *guideIt = guideBmp.toSeqAlign();
781  // if there's a master3d
782  if (cd->IsSetMaster3d() && resetFields) {
783  // get rid of it
784  cd->SetMaster3d().clear();
785  }
786  // if the new master has a pdb-id
787  CRef< CSeq_id > SeqID(new CSeq_id);
788  if (cd->GetSeqIDForRow(0, 0, SeqID)) {
789  if (SeqID->IsPdb()) {
790  // make it the master3d
791  // (the ref-counter for SeqID should have been incremented in GetSeqID)
792  cd->SetMaster3d().clear();
793  cd->SetMaster3d().push_back(SeqID);
794  }
795  }
796  if (resetFields)
797  {
798  ResetFields(cd);
799  }
800  return remasterAlignannot(*cd, Row);
801 }
802 
803 bool remasterAlignannot(CCdCore& cd, unsigned int oldMasterRow)
804 {
805  // Exit if invalid row number or the old master is same as current master.
806  if ((int)oldMasterRow >= cd.GetNumRows() || oldMasterRow == 0) return false;
807 
808  bool ok = true;
809  int From, To, NewFrom, NewTo;
810  CAlign_annot_set::Tdata::iterator alignAnnotIt, alignAnnotEnd;
811  CPacked_seqint::Tdata::iterator intervalIt, intervalEnd;
812  BlockModelPair guideAlignment(cd.GetSeqAlign(oldMasterRow));
813  CRef< CSeq_id > seqIdMaster(guideAlignment.getMaster().getSeqId());
814  CRef< CSeq_id > seqIdOldMaster(guideAlignment.getSlave().getSeqId());
815 
816  // if there's an align-annot set
817  if (cd.IsSetAlignannot()) {
818  // for each alignannot
819  alignAnnotEnd = cd.SetAlignannot().Set().end();
820  for (alignAnnotIt = cd.SetAlignannot().Set().begin(); alignAnnotIt != alignAnnotEnd; alignAnnotIt++) {
821  // if it's a from-to; make sure current seq id matches
822  if ((*alignAnnotIt)->SetLocation().IsInt()) {
823  // update from and to with new master
824  From = (int) (*alignAnnotIt)->SetLocation().GetInt().GetFrom();
825  To = (int) (*alignAnnotIt)->SetLocation().GetInt().GetTo();
826  NewFrom = guideAlignment.mapToMaster(From);
827  NewTo = guideAlignment.mapToMaster(To);
828 
829  if (!seqIdOldMaster->Match((*alignAnnotIt)->SetLocation().SetInt().GetId()) || NewFrom < 0 || NewTo < 0)
830  {
831  // If somehow already have alignannot mapped to the current master, don't flag an error.
832  // Second condition is to deal with case of old/new masters being different footprints on
833  // the same sequence ==> would only be here if there was a problem in NewFrom or NewTo
834  // in that case if seqIdMaster == seqIdOldMaster and first condition passed.
835  if (seqIdMaster->Match((*alignAnnotIt)->SetLocation().SetInt().GetId()) && !seqIdMaster->Match(*seqIdOldMaster)) {
836  continue;
837  }
838  ok = false;
839  continue;
840  }
841  (*alignAnnotIt)->SetLocation().SetInt().SetFrom(NewFrom);
842  (*alignAnnotIt)->SetLocation().SetInt().SetTo(NewTo);
843  (*alignAnnotIt)->SetLocation().SetInt().SetId(*seqIdMaster);
844  }
845  // if it's a set of from-to's
846  else if ((*alignAnnotIt)->SetLocation().IsPacked_int()) {
847  // for each from-to
848  intervalIt = (*alignAnnotIt)->SetLocation().SetPacked_int().Set().begin();
849  intervalEnd = (*alignAnnotIt)->SetLocation().SetPacked_int().Set().end();
850  for (; intervalIt != intervalEnd; ++intervalIt) {
851  // update from and to with new master
852  From = (int) (*intervalIt)->GetFrom();
853  To = (int) (*intervalIt)->GetTo();
854  NewFrom = guideAlignment.mapToMaster(From);
855  NewTo = guideAlignment.mapToMaster(To);
856  if (!seqIdOldMaster->Match((*intervalIt)->GetId()) || NewFrom < 0 || NewTo < 0)
857  {
858  // If somehow already have alignannot mapped to the current master, don't flag an error.
859  // Second condition is to deal with case of old/new masters being different footprints on
860  // the same sequence ==> would only be here if there was a problem in NewFrom or NewTo
861  // in that case if seqIdMaster == seqIdOldMaster and first condition passed.
862  if (seqIdMaster->Match((*intervalIt)->GetId()) && !seqIdMaster->Match(*seqIdOldMaster)) {
863  continue;
864  }
865  ok = false;
866  continue;
867  }
868  (*intervalIt)->SetFrom(NewFrom);
869  (*intervalIt)->SetTo(NewTo);
870  (*intervalIt)->SetId(*seqIdMaster);
871  }
872  }
873  }
874  }
875  return ok;
876 }
877 
878 int PurgeConsensusSequences(CCdCore* pCD, bool resetFields)
879 {
880  int nPurged = 0;
881  vector<int> consensusRows, consensusSeqListIds;
882 
883  if (pCD) {
884  // First see if the master is a consensus; if so, remaster to 2nd row
885  if (pCD->UsesConsensusSequenceAsMaster()) {
886  ReMasterCdWithoutUnifiedBlocks(pCD, 1,true);
887  }
888 
889  // Next, find all rows using 'consensus' as a seq_id and remove them.
890 
891  nPurged = pCD->GetRowsWithConsensus(consensusRows);
892  if (nPurged) {
893  pCD->EraseTheseRows(consensusRows);
894  if (pCD->FindConsensusInSequenceList(&consensusSeqListIds)) {
895  for (int i = consensusSeqListIds.size() - 1; i >= 0 ; --i) {
896  pCD->EraseSequence(consensusSeqListIds[i]);
897  }
898  }
899  }
900  }
901 
902  return nPurged;
903 }
904 
905 
906 int IntersectByMaster(CCdCore* ccd, double rowFraction) {
907 
908  int result = -1;
909  unsigned int masterLen = (ccd) ? ccd->GetSequenceStringByRow(0).length() : 0;
910  if (masterLen == 0) return result;
911 
912  int slaveStart;
913  int nAlignedIBM = 0;
914  unsigned int i, j, nBlocks;
915  unsigned int nRows = ccd->GetNumRows();
916 
917  // If there is already a consistent block model, do nothing.
918  MultipleAlignment* ma = new MultipleAlignment(ccd);
919  if (ma && ma->isBlockAligned()) {
920  delete ma;
921  return 0;
922  }
923  delete ma;
924 
925 
926  BlockIntersector blockIntersector(masterLen);
927  BlockModel* intersectedBlockModel;
928  //BlockModel* simpleIntersectedBlockModel;
930  vector<BlockModelPair*> blockModelPairs;
931  set<int> forcedCTerminiInIntersection;
932 
933  list< CRef< CSeq_align > >& cdSeqAligns = ccd->GetSeqAligns();
934  list< CRef< CSeq_align > >::iterator cdSeqAlignIt = cdSeqAligns.begin(), cdSeqAlignEnd = cdSeqAligns.end();
935 
936  for (i = 0; cdSeqAlignIt != cdSeqAlignEnd; ++cdSeqAlignIt, ++i) {
937  bmp = new BlockModelPair(*cdSeqAlignIt);
938 
939  // We assume # of blocks and all block lengths are same on master and slave.
940  if (bmp && bmp->isValid()) {
941 
942  blockModelPairs.push_back(bmp);
943  blockIntersector.addOneAlignment(bmp->getMaster());
944 
945  // Find places the intersection can't merge blocks (i.e., where there are
946  // gaps in the slave across a block boundary, but not in the master).
947  BlockModel& slave = bmp->getSlave();
948  nBlocks = slave.getBlocks().size();
949  for (j = 0; j < nBlocks - 1; ++j) { // '-1' as I don't care about end of the C-terminal block
950  if (slave.getGapToCTerminal(j) > 0 && bmp->getMaster().getGapToCTerminal(j) == 0) {
951  forcedCTerminiInIntersection.insert(bmp->getMaster().getBlock(j).getEnd());
952  }
953  }
954  }
955  }
956 
957  // There was a problem creating one of the BlockModelPair objects from a seq_align,
958  // or one or more seq_align was invalid.
959  if (blockModelPairs.size() != cdSeqAligns.size()) {
960  return result;
961  }
962 
963  //simpleIntersectedBlockModel = blockIntersector.getIntersectedAlignment(forcedCTerminiInIntersection);
964  intersectedBlockModel = blockIntersector.getIntersectedAlignment(forcedCTerminiInIntersection, rowFraction);
965  nAlignedIBM = (intersectedBlockModel) ? intersectedBlockModel->getTotalBlockLength() : 0;
966  if (nAlignedIBM == 0) {
967  return result;
968  }
969 
970 /*
971  string testStr, testStr2;
972  string sint = intersectedBlockModel->toString();
973  string sintsimple = simpleIntersectedBlockModel->toString();
974  delete simpleIntersectedBlockModel;
975  cout << "rowFraction = 1:\n" << sintsimple << endl;
976  cout << "rowFraction = " << rowFraction << ":\n" << sint << endl;
977 */
978 
979  // As we have case where every block model isn't identical,
980  // change each seq-align to reflect the common set of aligned columns.
981  nBlocks = intersectedBlockModel->getBlocks().size();
982  for (i = 0, cdSeqAlignIt = cdSeqAligns.begin(); i < nRows - 1 ; ++i, ++cdSeqAlignIt) {
983 
984  bmp = blockModelPairs[i]; //BlockModelPair seqAlignPair(*cdSeqAlignIt);
985  BlockModel* intersectedSeqAlignSlave = new BlockModel(bmp->getSlave().getSeqId(), false);
986 
987  bmp->reverse();
988  for (j = 0; j < nBlocks; ++j) {
989  const Block& jthMasterBlock = intersectedBlockModel->getBlock(j);
990  slaveStart = bmp->mapToMaster(jthMasterBlock.getStart());
991 
992  // since we're dealing w/ an intersection, slaveStart should always be valid
993  assert(slaveStart != -1);
994 
995  Block b(slaveStart, jthMasterBlock.getLen(), jthMasterBlock.getId());
996  intersectedSeqAlignSlave->addBlock(b);
997  }
998  *cdSeqAlignIt = intersectedSeqAlignSlave->toSeqAlign(*intersectedBlockModel);
999  //testStr = intersectedSeqAlignSlave->toString();
1000  //testStr2 = bmp->getMaster().toString(); // original *slave* alignment
1001 
1002  delete bmp;
1003  }
1004  blockModelPairs.clear();
1005  result = nBlocks;
1006 
1007  delete intersectedBlockModel;
1008 
1009  return result;
1010 }
1011 
1012 END_SCOPE(cd_utils)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool GetSeqIDForRow(int row, CRef< CSeq_id > &SeqID) const
void addOneAlignment(const BlockModel &bm)
BlockModel * getIntersectedAlignment(double rowFraction=1.0)
BlockModel & getMaster()
Definition: cuBlock.cpp:925
BlockModel & getSlave()
Definition: cuBlock.cpp:935
CRef< CSeq_align > toSeqAlign() const
Definition: cuBlock.cpp:983
int mapToMaster(int slavePos) const
Definition: cuBlock.cpp:989
void reverse()
Definition: cuBlock.cpp:1062
Block & getBlock(int bn)
Definition: cuBlock.hpp:98
int getTotalBlockLength() const
Definition: cuBlock.cpp:608
CRef< CSeq_id > getSeqId() const
Definition: cuBlock.hpp:102
CRef< CSeq_align > toSeqAlign(const BlockModel &master) const
Definition: cuBlock.cpp:557
void addBlock(Block &block)
Definition: cuBlock.cpp:225
int getGapToCTerminal(int bn, int len=-1) const
Definition: cuBlock.cpp:632
vector< Block > & getBlocks()
Definition: cuBlock.hpp:97
int getLen() const
Definition: cuBlock.hpp:41
int getId() const
Definition: cuBlock.hpp:45
int getStart() const
Definition: cuBlock.hpp:42
int GetNumRows() const
Definition: cuCdCore.cpp:215
bool EraseTheseRows(const std::vector< int > &TossRows)
Definition: cuCdCore.cpp:958
bool IsSeqAligns() const
Definition: cuCdCore.cpp:1383
void EraseSequence(int SeqIndex)
Definition: cuCdCore.cpp:1077
bool Has3DMaster() const
Definition: cuCdCore.cpp:1197
@ USE_NORMAL_ALIGNMENT
Definition: cuCdCore.hpp:63
int GetUpperBound(int Row) const
Definition: cuCdCore.cpp:490
string GetSequenceStringByRow(int rowId)
Definition: cuCdCore.cpp:578
bool GetSeqAlign(int Row, CRef< CSeq_align > &seqAlign)
Definition: cuCdCore.cpp:1419
int GetRowsWithConsensus(vector< int > &consensusRows) const
Definition: cuCdCore.cpp:1572
bool GetSeqIDFromAlignment(int RowIndex, CRef< CSeq_id > &SeqID) const
Definition: cuCdCore.cpp:815
bool FindConsensusInSequenceList(vector< int > *indices=NULL) const
Definition: cuCdCore.cpp:1536
int Num3DAlignments() const
Definition: cuCdCore.cpp:1227
string GetSequenceStringByIndex(int SeqIndex)
Definition: cuCdCore.cpp:724
void EraseUID()
Definition: cuCdCore.cpp:132
int GetAllRowIndicesForSeqId(const CRef< CSeq_id > &SeqID, list< int > &rows) const
Definition: cuCdCore.cpp:406
int GetAlignmentLength() const
Definition: cuCdCore.cpp:257
int GetLowerBound(int Row) const
Definition: cuCdCore.cpp:471
const list< CRef< CSeq_align > > & GetSeqAligns() const
Definition: cuCdCore.cpp:1398
bool UsesConsensusSequenceAsMaster() const
Definition: cuCdCore.cpp:1558
bool GetGI(int Row, TGi &GI, bool ignorePDBs=true)
Definition: cuCdCore.cpp:433
bool GetBioseqForRow(int rowId, CRef< CBioseq > &bioseq)
Definition: cuCdCore.cpp:561
string GetAccession(int &Version) const
Definition: cuCdCore.cpp:81
int GetNumSequences() const
Definition: cuCdCore.cpp:244
bool GetSeqIDForRow(int Pair, int DenDiagRow, CRef< CSeq_id > &SeqID) const
Definition: cuCdCore.cpp:787
bool GetPDB(int Row, const CPDB_seq_id *&pPDB)
Definition: cuCdCore.cpp:454
CCdd_descr –.
Definition: Cdd_descr.hpp:66
Definition: Cdd.hpp:51
Definition: Date.hpp:53
@ ePrecision_day
Definition: Date.hpp:58
CRef –.
Definition: ncbiobj.hpp:618
bool GetTaxId4GI(TGi gi, TTaxId &tax_id_out)
Definition: taxon1.cpp:1371
CConstRef< COrg_ref > GetOrgRef(TTaxId tax_id, bool &is_species, bool &is_uncultured, string &blast_name, bool *is_specified=NULL)
Definition: taxon1.cpp:704
bool Init(void)
Definition: taxon1.cpp:101
TTaxId Join(TTaxId taxid1, TTaxId taxid2)
Definition: taxon1.cpp:1220
CTime –.
Definition: ncbitime.hpp:296
void clear()
Definition: map.hpp:169
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
static int nRows
Definition: cn3d_png.cpp:115
void SetAlignedResiduesOnSequence(const CRef< CSeq_align > &align, const string &sequenceString, char *&pAlignedRes, bool isMaster=false)
Definition: cuAlign.cpp:290
int GetBlockLengths(const CRef< CSeq_align > &seqAlign, vector< int > &lengths)
Definition: cuAlign.cpp:391
int GetBlockStarts(const CRef< CSeq_align > &seqAlign, vector< int > &starts, bool onMaster)
Definition: cuAlign.cpp:418
bool SetCreationDate(CCdCore *cd)
Definition: cuCD.cpp:207
bool ReMasterCdWithoutUnifiedBlocks(CCdCore *cd, int Row, bool resetFields)
Definition: cuCD.cpp:757
int NumberOfOverlappedRows(CCdCore *cd1, CCdCore *cd2)
Definition: cuCD.cpp:403
bool RemasterWithStructure(CCdCore *cd, string *msg)
Definition: cuCD.cpp:728
void ResetFields(CCdCore *cd)
Definition: cuCD.cpp:89
CCdCore * CopyCD(const CCdCore *cd)
Definition: cuCD.cpp:281
bool obeysParentTypeConstraints(const CCdCore *pCD)
Definition: cuCD.cpp:701
int GetOverlappedRows(CCdCore *cd1, CCdCore *cd2, vector< int > &rowsOfCD1, vector< int > &rowsOfCD2)
Definition: cuCD.cpp:352
int PurgeConsensusSequences(CCdCore *pCD, bool resetFields)
Definition: cuCD.cpp:878
string GetVerboseNameStr(const CCdCore *cd)
Definition: cuCD.cpp:551
void SetAlignedResiduesForCD(CCdCore *cd, char **&ppAlignedResidues, bool forceRecompute)
Definition: cuCD.cpp:422
bool Reorder(CCdCore *pCD, const vector< int > positions)
Definition: cuCD.cpp:112
CRef< COrg_ref > GetCommonTax(CCdCore *cd, bool useRootWhenNoTaxInfo)
Definition: cuCD.cpp:639
CCdCore * ExtractCDFromMime(CNcbi_mime_asn1 *ncbiMime)
Definition: cuCD.cpp:262
bool remasterAlignannot(CCdCore &cd, unsigned int oldMasterRow)
Definition: cuCD.cpp:803
void GetAlignmentColumnsForCD(CCdCore *cd, map< unsigned int, string > &columns, unsigned int referenceRow)
Definition: cuCD.cpp:458
CRef< CBioseq > GetMasterBioseqWithFootprintOld(CCdCore *cd)
Definition: cuCD.cpp:558
bool ReorderStructureAlignments(CCdCore *pCD, const vector< int > &positions)
Definition: cuCD.cpp:148
bool SetUpdateDate(CCdCore *cd)
Definition: cuCD.cpp:234
bool GetBioseqWithFootprintForNRows(CCdCore *cd, int N, vector< CRef< CBioseq > > &bioseqs, string &errstr)
Definition: cuCD.cpp:624
int GetMappedRowIds(CCdCore *cd1, int row1, CCdCore *cd2, vector< int > &rows2, bool cd1AsChild, bool overlapMode)
Definition: cuCD.cpp:301
void SetConvertedSequencesForCD(CCdCore *cd, vector< string > &convertedSequences, bool forceRecompute)
Definition: cuCD.cpp:408
int IntersectByMaster(CCdCore *ccd, double rowFraction)
Definition: cuCD.cpp:906
CRef< CBioseq > GetBioseqWithFootprintForNthRow(CCdCore *cd, int N, string &errstr)
Definition: cuCD.cpp:590
CRef< CBioseq > GetMasterBioseqWithFootprint(CCdCore *cd)
Definition: cuCD.cpp:580
int GetReMasterFailureCode(const CCdCore *cd)
Definition: cuCD.cpp:73
const int ALIGN_ANNOTS_VALID_FAILURE
Definition: cuCD.hpp:51
static ASNClass * CopyASNObject(const ASNClass &originalObject, std::string *err)
TTaxId GetTaxIdInBioseq(const CBioseq &bioseq)
Definition: cuSequence.cpp:139
static const char si[8][64]
Definition: des.c:146
thread_local unique_ptr< FtaMsgPost > bmp
Definition: ftaerr.cpp:120
#define INVALID_GI
Definition: ncbimisc.hpp:1089
#define TAX_ID_CONST(id)
Definition: ncbimisc.hpp:1112
#define ZERO_TAX_ID
Definition: ncbimisc.hpp:1115
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
const string AsFastaString(void) const
Definition: Seq_id.cpp:2265
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1033
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:300
list< CRef< CBiostruc_feature > > TFeatures
const TFeatures & GetFeatures(void) const
Get the Features member data.
void ResetTrunc_master(void)
Reset Trunc_master data member.
Definition: Cdd_.cpp:163
void ResetFeatures(void)
Reset Features data member.
Definition: Cdd_.cpp:112
TMaster3d & SetMaster3d(void)
Assign a value to Master3d data member.
Definition: Cdd_.hpp:1534
void ResetScoremat(void)
Reset Scoremat data member.
Definition: Cdd_.cpp:197
bool IsSetAlignannot(void) const
alignment annotation Check if a value has been assigned to Alignannot data member.
Definition: Cdd_.hpp:1541
void ResetProfile_range(void)
Reset Profile_range data member.
Definition: Cdd_.cpp:146
void SetFeatures(TFeatures &value)
Assign a value to Features data member.
Definition: Cdd_.cpp:117
void SetDescription(TDescription &value)
Assign a value to Description data member.
Definition: Cdd_.cpp:94
const TAncestors & GetAncestors(void) const
Get the Ancestors member data.
Definition: Cdd_.hpp:1616
void ResetDistance(void)
Reset Distance data member.
Definition: Cdd_.cpp:214
bool IsSetMaster3d(void) const
record if CD has a 3D representative Check if a value has been assigned to Master3d data member.
Definition: Cdd_.hpp:1516
bool IsSetAncestors(void) const
list of parents Check if a value has been assigned to Ancestors data member.
Definition: Cdd_.hpp:1604
void SetAlignannot(TAlignannot &value)
Assign a value to Alignannot data member.
Definition: Cdd_.cpp:322
void ResetPosfreq(void)
Reset Posfreq data member.
Definition: Cdd_.cpp:180
const TName & GetName(void) const
Get the Name member data.
Definition: Cdd_.hpp:1124
bool IsSetParent(void) const
this CD is the result of a split Check if a value has been assigned to Parent data member.
Definition: Cdd_.hpp:1382
bool IsSetFeatures(void) const
contains structure alignment data or "core" definitions Check if a value has been assigned to Feature...
Definition: Cdd_.hpp:1235
const TFeatures & GetFeatures(void) const
Get the Features member data.
Definition: Cdd_.hpp:1247
@ eParent_type_classical
the classification of parent child relations
bool IsGeneral(void) const
Check if variant General is selected.
const TCdd & GetCdd(void) const
Get the variant data.
const TGeneral & GetGeneral(void) const
Get the variant data.
bool IsCdd(void) const
Check if variant Cdd is selected.
const TSeq_align_data & GetSeq_align_data(void) const
Get the Seq_align_data member data.
bool IsPdb(void) const
Check if variant Pdb is selected.
Definition: Seq_id_.hpp:922
@ e_Local
local use
Definition: Seq_id_.hpp:95
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
TId & SetId(void)
Assign a value to Id data member.
Definition: Bioseq_.hpp:296
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
Definition: Bioseq_.hpp:372
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
Defines: CTimeFormat - storage class for time format.
#define assert(x)
Definition: srv_diag.hpp:58
else result
Definition: token2.c:20
#define N
Definition: crc32.c:57
#define const
Definition: zconf.h:230
Modified on Sat Dec 02 09:20:39 2023 by modify_doxy.py rev. 669887