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

Go to the SVN repository for this file.

1 /* $Id: annot_object.cpp 99486 2023-04-04 20:35:05Z vasilche $
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: Aleksey Grichenko, Eugene Vasilchenko
27 *
28 * File Description:
29 *
30 */
31 
32 #include <ncbi_pch.hpp>
41 #include <objmgr/error_codes.hpp>
42 
47 
50 
63 
65 
67 
71 
72 
73 #define NCBI_USE_ERRCODE_X ObjMgr_AnnotObject
74 
76 
78 
80 
81 ////////////////////////////////////////////////////////////////////
82 //
83 // CAnnotObject_Info::
84 //
85 
86 
88  TIndex index,
90  : m_Seq_annot_Info(&annot),
91  m_ObjectIndex(index),
92  m_Type(type)
93 {
94  m_Iter.m_RawPtr = 0;
95 }
96 
97 
99  TIndex index,
100  TFtable::iterator iter)
101  : m_Seq_annot_Info(&annot),
102  m_ObjectIndex(index),
103  m_Type((*iter)->GetData().GetSubtype())
104 {
105 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
106  m_Iter.m_Feat.Construct();
107 #endif
108  *m_Iter.m_Feat = iter;
109  _ASSERT(IsRegular());
110  _ASSERT(m_Iter.m_RawPtr != 0);
111 }
112 
113 
115  TIndex index,
116  TAlign::iterator iter)
117  : m_Seq_annot_Info(&annot),
118  m_ObjectIndex(index),
119  m_Type(C_Data::e_Align)
120 {
121 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
122  m_Iter.m_Align.Construct();
123 #endif
124  *m_Iter.m_Align = iter;
125  _ASSERT(IsRegular());
126  _ASSERT(m_Iter.m_RawPtr != 0);
127 }
128 
129 
131  TIndex index,
132  TGraph::iterator iter)
133  : m_Seq_annot_Info(&annot),
134  m_ObjectIndex(index),
135  m_Type(C_Data::e_Graph)
136 {
137 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
138  m_Iter.m_Graph.Construct();
139 #endif
140  *m_Iter.m_Graph = iter;
141  _ASSERT(IsRegular());
142  _ASSERT(m_Iter.m_RawPtr != 0);
143 }
144 
145 
147  TIndex index,
148  TLocs::iterator iter)
149  : m_Seq_annot_Info(&annot),
150  m_ObjectIndex(index),
151  m_Type(C_Data::e_Locs)
152 {
153 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
154  m_Iter.m_Locs.Construct();
155 #endif
156  *m_Iter.m_Locs = iter;
157  _ASSERT(IsRegular());
158  _ASSERT(m_Iter.m_RawPtr != 0);
159 }
160 
161 
163  TIndex index,
164  TFtable& cont,
165  const CSeq_feat& obj)
166  : m_Seq_annot_Info(&annot),
167  m_ObjectIndex(index),
168  m_Type(obj.GetData().GetSubtype())
169 {
170 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
171  m_Iter.m_Feat.Construct();
172 #endif
173  *m_Iter.m_Feat = cont.insert(cont.end(),
174  Ref(const_cast<CSeq_feat*>(&obj)));
175  _ASSERT(IsRegular());
176  _ASSERT(m_Iter.m_RawPtr != 0);
177 }
178 
179 
181  TIndex index,
182  TAlign& cont,
183  const CSeq_align& obj)
184  : m_Seq_annot_Info(&annot),
185  m_ObjectIndex(index),
186  m_Type(C_Data::e_Align)
187 {
188 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
189  m_Iter.m_Align.Construct();
190 #endif
191  *m_Iter.m_Align = cont.insert(cont.end(),
192  Ref(const_cast<CSeq_align*>(&obj)));
193  _ASSERT(IsRegular());
194  _ASSERT(m_Iter.m_RawPtr != 0);
195 }
196 
197 
199  TIndex index,
200  TGraph& cont,
201  const CSeq_graph& obj)
202  : m_Seq_annot_Info(&annot),
203  m_ObjectIndex(index),
204  m_Type(C_Data::e_Graph)
205 {
206 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
207  m_Iter.m_Graph.Construct();
208 #endif
209  *m_Iter.m_Graph = cont.insert(cont.end(),
210  Ref(const_cast<CSeq_graph*>(&obj)));
211  _ASSERT(IsRegular());
212  _ASSERT(m_Iter.m_RawPtr != 0);
213 }
214 
215 
217  TIndex index,
218  TLocs& cont,
219  const CSeq_loc& obj)
220  : m_Seq_annot_Info(&annot),
221  m_ObjectIndex(index),
222  m_Type(C_Data::e_Locs)
223 {
224 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
225  m_Iter.m_Locs.Construct();
226 #endif
227  *m_Iter.m_Locs = cont.insert(cont.end(),
228  Ref(const_cast<CSeq_loc*>(&obj)));
229  _ASSERT(IsRegular());
230  _ASSERT(m_Iter.m_RawPtr != 0);
231 }
232 
233 
235  const SAnnotTypeSelector& sel)
236  : m_Seq_annot_Info(0),
237  m_ObjectIndex(eChunkStub),
238  m_Type(sel)
239 {
240  m_Iter.m_Chunk = &chunk_info;
241  _ASSERT(IsChunkStub());
242  _ASSERT(m_Iter.m_RawPtr != 0);
243 }
244 
245 
247 {
248  Reset();
249 }
250 
251 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
252 
254  : m_Seq_annot_Info(info.m_Seq_annot_Info),
255  m_ObjectIndex(info.m_ObjectIndex),
256  m_Type(info.m_Type)
257 {
258  if ( info.IsRegular() ) {
259  if ( info.IsFeat() ) {
260  m_Iter.m_Feat.Construct();
261  *m_Iter.m_Feat = *info.m_Iter.m_Feat;
262  _ASSERT(IsFeat());
263  }
264  else if ( info.IsAlign() ) {
265  m_Iter.m_Align.Construct();
266  *m_Iter.m_Align = *info.m_Iter.m_Align;
267  _ASSERT(IsAlign());
268  }
269  else if ( info.IsGraph() ) {
270  m_Iter.m_Graph.Construct();
271  *m_Iter.m_Graph = *info.m_Iter.m_Graph;
272  _ASSERT(IsGraph());
273  }
274  else if ( info.IsLocs() ) {
275  m_Iter.m_Locs.Construct();
276  *m_Iter.m_Locs = *info.m_Iter.m_Locs;
277  _ASSERT(IsLocs());
278  }
279  _ASSERT(IsRegular());
280  }
281  else {
282  m_Iter.m_RawPtr = info.m_Iter.m_RawPtr;
283  _ASSERT(!IsRegular());
284  }
285 }
286 
287 
288 CAnnotObject_Info& CAnnotObject_Info::operator=(const CAnnotObject_Info& info)
289 {
290  if ( this != &info ) {
291  Reset();
292  m_Seq_annot_Info = info.m_Seq_annot_Info;
293  m_ObjectIndex = info.m_ObjectIndex;
294  m_Type = info.m_Type;
295  if ( info.IsRegular() ) {
296  if ( info.IsFeat() ) {
297  m_Iter.m_Feat.Construct();
298  *m_Iter.m_Feat = *info.m_Iter.m_Feat;
299  _ASSERT(IsFeat());
300  }
301  else if ( info.IsAlign() ) {
302  m_Iter.m_Align.Construct();
303  *m_Iter.m_Align = *info.m_Iter.m_Align;
304  _ASSERT(IsAlign());
305  }
306  else if ( info.IsGraph() ) {
307  m_Iter.m_Graph.Construct();
308  *m_Iter.m_Graph = *info.m_Iter.m_Graph;
309  _ASSERT(IsGraph());
310  }
311  else if ( info.IsLocs() ) {
312  m_Iter.m_Locs.Construct();
313  *m_Iter.m_Locs = *info.m_Iter.m_Locs;
314  _ASSERT(IsLocs());
315  }
316  _ASSERT(IsRegular());
317  }
318  else {
319  m_Iter.m_RawPtr = info.m_Iter.m_RawPtr;
320  _ASSERT(!IsRegular());
321  }
322  }
323  return *this;
324 }
325 
326 #endif
327 
328 
330 {
331 #ifdef NCBI_NON_POD_TYPE_STL_ITERATORS
332  if ( IsRegular() ) {
333  if ( IsFeat() ) {
334  m_Iter.m_Feat.Destruct();
335  }
336  else if ( IsAlign() ) {
337  m_Iter.m_Align.Destruct();
338  }
339  else if ( IsGraph() ) {
340  m_Iter.m_Graph.Destruct();
341  }
342  else if ( IsLocs() ) {
343  m_Iter.m_Locs.Destruct();
344  }
345  }
346 #endif
348  m_Iter.m_RawPtr = 0;
350  m_Seq_annot_Info = 0;
351 }
352 
353 
355 {
356  return ConstRef(GetObjectPointer());
357 }
358 
359 
361 {
362  switch ( Which() ) {
363  case C_Data::e_Ftable:
364  return GetFeatFast();
365  case C_Data::e_Graph:
366  return GetGraphFast();
367  case C_Data::e_Align:
368  return &GetAlign();
369  case C_Data::e_Locs:
370  return &GetLocs();
371  default:
372  return 0;
373  }
374 }
375 
376 
377 void CAnnotObject_Info::GetMaps(vector<CHandleRangeMap>& hrmaps,
378  const CMasterSeqSegments* master) const
379 {
380  _ASSERT(IsRegular());
381  switch ( Which() ) {
382  case C_Data::e_Ftable:
383  x_ProcessFeat(hrmaps, *GetFeatFast(), master);
384  break;
385  case C_Data::e_Graph:
386  x_ProcessGraph(hrmaps, *GetGraphFast(), master);
387  break;
388  case C_Data::e_Align:
389  {
390  const CSeq_align& align = GetAlign();
391  // TODO: separate alignment locations
392  hrmaps.clear();
393  x_ProcessAlign(hrmaps, align, master);
394  break;
395  }
396  case C_Data::e_Locs:
397  {
398  _ASSERT(!IsRemoved());
399  // Index by location in region descriptor, not by referenced one
401  if ( !annot.IsSetDesc() ) {
402  break;
403  }
404  CConstRef<CSeq_loc> region;
405  ITERATE(CSeq_annot::TDesc::Tdata, desc_it, annot.GetDesc().Get()) {
406  if ( (*desc_it)->IsRegion() ) {
407  region.Reset(&(*desc_it)->GetRegion());
408  break;
409  }
410  }
411  if ( region ) {
412  hrmaps.resize(1);
413  hrmaps[0].clear();
414  hrmaps[0].SetMasterSeq(master);
415  hrmaps[0].AddLocation(*region);
416  }
417  break;
418  }
419  default:
420  break;
421  }
422 }
423 
424 /* static */
425 void CAnnotObject_Info::x_ProcessFeat(vector<CHandleRangeMap>& hrmaps,
426  const CSeq_feat& feat,
427  const CMasterSeqSegments* master)
428 {
429  hrmaps.resize(feat.IsSetProduct()? 2: 1);
430  hrmaps[0].clear();
431  hrmaps[0].SetMasterSeq(master);
433  if ( feat.IsSetExcept_text() ) {
434  if ( feat.GetExcept_text().find("trans-splicing") != NPOS ) {
436  }
437  else if ( feat.GetExcept_text().find("circular RNA") != NPOS ) {
439  }
440  }
441  hrmaps[0].AddLocation(feat.GetLocation(), mode);
442  if ( feat.IsSetProduct() ) {
443  hrmaps[1].clear();
444  hrmaps[1].SetMasterSeq(master);
445  hrmaps[1].AddLocation(feat.GetProduct(), mode);
446  }
447 }
448 /* static */
449 void CAnnotObject_Info::x_ProcessGraph(vector<CHandleRangeMap>& hrmaps,
450  const CSeq_graph& graph,
451  const CMasterSeqSegments* master)
452 {
453  hrmaps.resize(1);
454  hrmaps[0].clear();
455  hrmaps[0].SetMasterSeq(master);
456  hrmaps[0].AddLocation(graph.GetLoc());
457 }
458 
460 {
462 }
463 
464 
466 {
467  return GetSeq_annot_Info().GetTSE_Info();
468 }
469 
470 
472 {
473  return GetSeq_annot_Info().GetTSE_Info();
474 }
475 
476 
478 {
479  return GetSeq_annot_Info().GetDataSource();
480 }
481 
482 
483 const CTempString kAnnotTypePrefix = "Seq-annot.data.";
484 
486 {
488  _ASSERT(annot.IsSetDesc());
489  ITERATE(CSeq_annot::TDesc::Tdata, desc_it, annot.GetDesc().Get()) {
490  if ( !(*desc_it)->IsUser() ) {
491  continue;
492  }
493  const CUser_object& obj = (*desc_it)->GetUser();
494  if ( !obj.GetType().IsStr() ) {
495  continue;
496  }
497  CTempString type = obj.GetType().GetStr();
498  if (type.substr(0, kAnnotTypePrefix.size()) != kAnnotTypePrefix) {
499  continue;
500  }
501  type = type.substr(kAnnotTypePrefix.size());
502  if (type == "align") {
503  idx_set.push_back(CAnnotType_Index::GetAnnotTypeRange(
504  C_Data::e_Align));
505  }
506  else if (type == "graph") {
507  idx_set.push_back(CAnnotType_Index::GetAnnotTypeRange(
508  C_Data::e_Graph));
509  }
510  else if (type == "ftable") {
511  if ( obj.GetData().size() == 0 ) {
512  // Feature type/subtype not set
513  idx_set.push_back(CAnnotType_Index::GetAnnotTypeRange(
515  continue;
516  }
517  // Parse feature types and subtypes
518  ITERATE(CUser_object::TData, data_it, obj.GetData()) {
519  const CUser_field& field = **data_it;
520  if ( !field.GetLabel().IsId() ) {
521  continue;
522  }
523  int ftype = field.GetLabel().GetId();
524  switch (field.GetData().Which()) {
526  x_Locs_AddFeatSubtype(ftype,
527  field.GetData().GetInt(), idx_set);
528  break;
530  {
532  field.GetData().GetInts()) {
533  x_Locs_AddFeatSubtype(ftype, *it, idx_set);
534  }
535  break;
536  }
537  default:
538  break;
539  }
540  }
541  }
542  }
543 }
544 
545 
547  int subtype,
548  TTypeIndexSet& idx_set) const
549 {
550  if (subtype != CSeqFeatData::eSubtype_any) {
551  size_t idx =
553  idx_set.push_back(TIndexRange(idx, idx+1));
554  }
555  else {
556  idx_set.push_back(
558  }
559 }
560 
561 
562 /* static */
563 void CAnnotObject_Info::x_ProcessAlign(vector<CHandleRangeMap>& hrmaps,
564  const CSeq_align& align,
565  const CMasterSeqSegments* master)
566 {
567  //### Check the implementation.
568  switch ( align.GetSegs().Which() ) {
570  {
571  break;
572  }
574  {
575  const CSeq_align::C_Segs::TDendiag& dendiag =
576  align.GetSegs().GetDendiag();
577  ITERATE ( CSeq_align::C_Segs::TDendiag, it, dendiag ) {
578  const CDense_diag& diag = **it;
579  int dim = diag.GetDim();
580  if (dim != (int)diag.GetIds().size()) {
581  ERR_POST_X(1, Warning << "Invalid 'ids' size in dendiag");
582  dim = min(dim, (int)diag.GetIds().size());
583  }
584  if (dim != (int)diag.GetStarts().size()) {
585  ERR_POST_X(2, Warning << "Invalid 'starts' size in dendiag");
586  dim = min(dim, (int)diag.GetStarts().size());
587  }
588  if (diag.IsSetStrands()
589  && dim != (int)diag.GetStrands().size()) {
590  ERR_POST_X(3, Warning << "Invalid 'strands' size in dendiag");
591  dim = min(dim, (int)diag.GetStrands().size());
592  }
593  if ((int)hrmaps.size() < dim) {
594  hrmaps.resize(dim);
595  }
596  TSeqPos len = (*it)->GetLen();
597  for (int row = 0; row < dim; ++row) {
598  const CSeq_id& id = *(*it)->GetIds()[row];
599  TSeqPos from = (*it)->GetStarts()[row];
600  TSeqPos to = from + len - 1;
602  if ( (*it)->IsSetStrands() ) {
603  strand = (*it)->GetStrands()[row];
604  }
605  hrmaps[row].SetMasterSeq(master);
606  hrmaps[row].AddRange(id, from, to, strand);
607  }
608  }
609  break;
610  }
612  {
613  const CSeq_align::C_Segs::TDenseg& denseg =
614  align.GetSegs().GetDenseg();
615  size_t dim = size_t(denseg.GetDim());
616  size_t numseg = size_t(denseg.GetNumseg());
617  // claimed dimension may not be accurate :-/
618  if (numseg != denseg.GetLens().size()) {
619  ERR_POST_X(4, Warning << "Invalid 'lens' size in denseg");
620  numseg = min(numseg, denseg.GetLens().size());
621  }
622  if (dim != denseg.GetIds().size()) {
623  ERR_POST_X(5, Warning << "Invalid 'ids' size in denseg");
624  dim = min(dim, denseg.GetIds().size());
625  }
626  if (dim*numseg != denseg.GetStarts().size()) {
627  ERR_POST_X(6, Warning << "Invalid 'starts' size in denseg");
628  dim = min(dim*numseg, denseg.GetStarts().size()) / numseg;
629  }
630  if (denseg.IsSetStrands()
631  && dim*numseg != denseg.GetStrands().size()) {
632  ERR_POST_X(7, Warning << "Invalid 'strands' size in denseg");
633  dim = min(dim*numseg, denseg.GetStrands().size()) / numseg;
634  }
635  if (hrmaps.size() < dim) {
636  hrmaps.resize(dim);
637  }
638  for (size_t seg = 0; seg < numseg; seg++) {
639  for (size_t row = 0; row < dim; row++) {
640  if (denseg.GetStarts()[seg*dim + row] < 0 ) {
641  continue;
642  }
643  const CSeq_id& id = *denseg.GetIds()[row];
644  TSeqPos from = denseg.GetStarts()[seg*dim + row];
645  TSeqPos to = from + denseg.GetLens()[seg] - 1;
647  if ( denseg.IsSetStrands() ) {
648  strand = denseg.GetStrands()[seg*dim + row];
649  }
650  hrmaps[row].SetMasterSeq(master);
651  hrmaps[row].AddRange(id, from, to, strand);
652  }
653  }
654  break;
655  }
657  {
658  const CSeq_align::C_Segs::TStd& std =
659  align.GetSegs().GetStd();
660  ITERATE ( CSeq_align::C_Segs::TStd, it, std ) {
661  size_t dim = size_t((*it)->GetDim());
662  if (hrmaps.size() < dim) {
663  hrmaps.resize((*it)->GetDim());
664  }
665  ITERATE ( CStd_seg::TLoc, it_loc, (*it)->GetLoc() ) {
666  CSeq_loc_CI row_it(**it_loc);
667  for (size_t row = 0; row_it; ++row_it, ++row) {
668  if (row >= hrmaps.size()) {
669  hrmaps.resize(row + 1);
670  }
671  const CSeq_id& id = row_it.GetSeq_id();
672  TSeqPos from = row_it.GetRange().GetFrom();
673  TSeqPos to = row_it.GetRange().GetTo();
674  ENa_strand strand = row_it.GetStrand();
675  hrmaps[row].SetMasterSeq(master);
676  hrmaps[row].AddRange(id, from, to, strand);
677  }
678  }
679  }
680  break;
681  }
683  {
684  const CSeq_align::C_Segs::TPacked& packed =
685  align.GetSegs().GetPacked();
686  size_t dim = size_t(packed.GetDim());
687  size_t numseg = size_t(packed.GetNumseg());
688  // claimed dimension may not be accurate :-/
689  if (dim * numseg > packed.GetStarts().size()) {
690  dim = packed.GetStarts().size() / numseg;
691  }
692  if (dim * numseg > packed.GetPresent().size()) {
693  dim = packed.GetPresent().size() / numseg;
694  }
695  if (dim > packed.GetLens().size()) {
696  dim = packed.GetLens().size();
697  }
698  if (hrmaps.size() < dim) {
699  hrmaps.resize(dim);
700  }
701  for (size_t seg = 0; seg < numseg; seg++) {
702  for (size_t row = 0; row < dim; row++) {
703  if ( packed.GetPresent()[seg*dim + row] ) {
704  hrmaps[row].SetMasterSeq(master);
705  const CSeq_id& id = *packed.GetIds()[row];
706  TSeqPos from = packed.GetStarts()[seg*dim + row];
707  TSeqPos to = from + packed.GetLens()[seg] - 1;
709  if ( packed.IsSetStrands() ) {
710  strand = packed.GetStrands()[seg*dim + row];
711  }
712  hrmaps[row].AddRange(id, from, to, strand);
713  }
714  }
715  }
716  break;
717  }
719  {
720  const CSeq_align::C_Segs::TDisc& disc =
721  align.GetSegs().GetDisc();
722  ITERATE ( CSeq_align_set::Tdata, it, disc.Get() ) {
723  x_ProcessAlign(hrmaps, **it, master);
724  }
725  break;
726  }
728  {
729  const CSeq_align::C_Segs::TSpliced& spliced =
730  align.GetSegs().GetSpliced();
731  const CSeq_id* gen_id = spliced.IsSetGenomic_id() ?
732  &spliced.GetGenomic_id() : 0;
733  const CSeq_id* prod_id = spliced.IsSetProduct_id() ?
734  &spliced.GetProduct_id() : 0;
735  hrmaps.resize(2);
736  ITERATE ( CSpliced_seg::TExons, it, spliced.GetExons() ) {
737  const CSpliced_exon& ex = **it;
738  const CSeq_id* ex_gen_id = ex.IsSetGenomic_id() ?
739  &ex.GetGenomic_id() : gen_id;
740  if ( ex_gen_id ) {
741  const CSeq_id& id = *ex_gen_id;
742  TSeqPos from = ex.GetGenomic_start();
743  TSeqPos to = ex.GetGenomic_end();
745  if ( ex.IsSetGenomic_strand() ) {
746  strand = ex.GetGenomic_strand();
747  }
748  else if ( spliced.IsSetGenomic_strand() ) {
749  strand = spliced.GetGenomic_strand();
750  }
751  hrmaps[1].SetMasterSeq(master);
752  hrmaps[1].AddRange(id, from, to, strand);
753  }
754  const CSeq_id* ex_prod_id = ex.IsSetProduct_id() ?
755  &ex.GetProduct_id() : prod_id;
756  if ( ex_prod_id ) {
757  const CSeq_id& id = *ex_prod_id;
758  TSeqPos from =
759  (ex.GetProduct_start().IsNucpos() ?
760  ex.GetProduct_start().GetNucpos() :
762  TSeqPos to =
763  (ex.GetProduct_end().IsNucpos() ?
764  ex.GetProduct_end().GetNucpos() :
767  if ( ex.IsSetProduct_strand() ) {
768  strand = ex.GetProduct_strand();
769  }
770  else if ( spliced.IsSetProduct_strand() ) {
771  strand = spliced.GetProduct_strand();
772  }
773  hrmaps[0].SetMasterSeq(master);
774  hrmaps[0].AddRange(id, from, to, strand);
775  }
776  }
777  break;
778  }
780  {
781  const CSeq_align::C_Segs::TSparse& sparse =
782  align.GetSegs().GetSparse();
783  // consensus sequence row + one row for each sub-alignment
784  size_t dim = sparse.GetRows().size() + 1;
785  if (hrmaps.size() < dim) {
786  hrmaps.resize(dim);
787  }
788  size_t row = 0;
789  hrmaps[0].SetMasterSeq(master);
790  ITERATE ( CSparse_seg::TRows, it, sparse.GetRows() ) {
791  const CSparse_align& aln_row = **it;
792  size_t numseg = aln_row.GetNumseg();
793  if (numseg != aln_row.GetFirst_starts().size()) {
794  ERR_POST_X(9, Warning <<
795  "Invalid size of 'first-starts' in sparse-align");
796  numseg = min(numseg, aln_row.GetFirst_starts().size());
797  }
798  if (numseg != aln_row.GetSecond_starts().size()) {
799  ERR_POST_X(10, Warning <<
800  "Invalid size of 'second-starts' in sparse-align");
801  numseg = min(numseg, aln_row.GetSecond_starts().size());
802  }
803  if (numseg != aln_row.GetLens().size()) {
804  ERR_POST_X(11, Warning <<
805  "Invalid size of 'lens' in sparse-align");
806  numseg = min(numseg, aln_row.GetLens().size());
807  }
808  if (aln_row.IsSetSecond_strands() &&
809  numseg != aln_row.GetSecond_strands().size()) {
810  ERR_POST_X(12, Warning <<
811  "Invalid size of 'second-strands' in sparse-align");
812  numseg = min(numseg, aln_row.GetSecond_strands().size());
813  }
814 
815  hrmaps[row+1].SetMasterSeq(master);
816  for (size_t seg = 0; seg < numseg; ++seg) {
817  TSeqPos len = aln_row.GetLens()[seg];
818  {
819  const CSeq_id& id = aln_row.GetFirst_id();
820  TSeqPos from = aln_row.GetFirst_starts()[seg];
821  TSeqPos to = from + len - 1;
822  // consensus sequence goes to the first row
823  hrmaps[0].AddRange(id, from, to);
824  }
825  {
826  const CSeq_id& id = aln_row.GetSecond_id();
827  TSeqPos from = aln_row.GetSecond_starts()[seg];
828  TSeqPos to = from + len - 1;
830  if ( aln_row.IsSetSecond_strands() ) {
831  strand = aln_row.GetSecond_strands()[row];
832  }
833  hrmaps[row+1].AddRange(id, from, to, strand);
834  }
835  }
836  row++;
837  }
838  break;
839  }
840  default:
841  {
842  ERR_POST_X(8, Warning << "Unknown type of Seq-align: "<<
843  align.GetSegs().Which());
844  break;
845  }
846  }
847 }
848 
849 
851 {
852  x_GetFeatIter()->Reset(&const_cast<CSeq_feat&>(new_obj));
854 }
855 
856 
858 {
859  x_GetAlignIter()->Reset(&const_cast<CSeq_align&>(new_obj));
861 }
862 
863 
865 {
866  x_GetGraphIter()->Reset(&const_cast<CSeq_graph&>(new_obj));
868 }
869 
870 
872 {
873  _ASSERT(IsFeat() && IsRegular() && m_Iter.m_RawPtr);
874  TFtable::iterator old_iter = *m_Iter.m_Feat;
875  *m_Iter.m_Feat = cont.insert(cont.end(), *old_iter);
876  cont.erase(old_iter);
877 }
878 
879 
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.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
const CTempString kAnnotTypePrefix
NCBI_DEFINE_ERR_SUBCODE_X(12)
const TFtable::iterator & x_GetFeatIter(void) const
TAnnotType Which(void) const
const CSeq_loc & GetLocs(void) const
const CSeq_entry_Info & GetSeq_entry_Info(void) const
void GetLocsTypes(TTypeIndexSet &idx_set) const
CConstRef< CObject > GetObject(void) const
bool IsAlign(void) const
const CSeq_annot_Info & GetSeq_annot_Info(void) const
const CObject * GetObjectPointer(void) const
static void x_ProcessFeat(vector< CHandleRangeMap > &hrmaps, const CSeq_feat &feat, const CMasterSeqSegments *master)
void x_Locs_AddFeatSubtype(int ftype, int subtype, TTypeIndexSet &idx_set) const
void x_MoveToBack(TFtable &cont)
void x_SetObject(const CSeq_feat &new_obj)
const TGraph::iterator & x_GetGraphIter(void) const
bool IsRegular(void) const
vector< TIndexRange > TTypeIndexSet
static void x_ProcessAlign(vector< CHandleRangeMap > &hrmaps, const CSeq_align &align, const CMasterSeqSegments *master)
void GetMaps(vector< CHandleRangeMap > &hrmaps, const CMasterSeqSegments *master=0) const
const CSeq_feat * GetFeatFast(void) const
C_Data::TGraph TGraph
bool IsLocs(void) const
CSeq_annot_Info * m_Seq_annot_Info
bool IsGraph(void) const
C_Data::TAlign TAlign
CDataSource & GetDataSource(void) const
static void x_ProcessGraph(vector< CHandleRangeMap > &hrmaps, const CSeq_graph &graph, const CMasterSeqSegments *master)
C_Data::TLocs TLocs
SAnnotTypeSelector m_Type
const TAlign::iterator & x_GetAlignIter(void) const
bool IsChunkStub(void) const
pair< size_t, size_t > TIndexRange
C_Data::TFtable TFtable
const void * m_RawPtr
bool IsFeat(void) const
const CSeq_align & GetAlign(void) const
const CTSE_Info & GetTSE_Info(void) const
bool IsRemoved(void) const
const CSeq_graph * GetGraphFast(void) const
union CAnnotObject_Info::@735 m_Iter
static TIndexRange GetFeatTypeRange(CSeqFeatData::E_Choice type)
static size_t GetSubtypeIndex(CSeqFeatData::ESubtype subtype)
static TIndexRange GetAnnotTypeRange(CSeq_annot::C_Data::E_Choice type)
CObject –.
Definition: ncbiobj.hpp:180
ESubtype GetSubtype(void) const
CConstRef< TObject > GetCompleteSeq_annot(void) const
const CSeq_entry_Info & GetParentSeq_entry_Info(void) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
CDataSource & GetDataSource(void) const
const CTSE_Info & GetTSE_Info(void) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
int GetSubtype(CFieldNamePanel *field_name_panel, string &ncRNA_class)
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
TRange GetRange(void) const
Get the range.
Definition: Seq_loc.hpp:1042
ENa_strand GetStrand(void) const
Definition: Seq_loc.hpp:1056
const CSeq_id & GetSeq_id(void) const
Get seq_id of the current location.
Definition: Seq_loc.hpp:1028
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
#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
#define NPOS
Definition: ncbistr.hpp:133
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
const TData & GetData(void) const
Get the Data member data.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
TInt GetInt(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
vector< CRef< CUser_field > > TData
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
E_Choice Which(void) const
Which variant is currently selected.
const TInts & GetInts(void) const
Get the variant data.
bool IsSetProduct_strand(void) const
should be 'plus' or 'minus' Check if a value has been assigned to Product_strand data member.
const TProtpos & GetProtpos(void) const
Get the variant data.
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
vector< CRef< CSeq_loc > > TLoc
Definition: Std_seg_.hpp:93
vector< CRef< CSparse_align > > TRows
Definition: Sparse_seg_.hpp:99
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
list< CRef< CStd_seg > > TStd
Definition: Seq_align_.hpp:196
CSeq_align_set TDisc
Definition: Seq_align_.hpp:198
TGenomic_start GetGenomic_start(void) const
Get the Genomic_start member data.
const TProduct_id & GetProduct_id(void) const
Get the Product_id member data.
const TFirst_id & GetFirst_id(void) const
Get the First_id member data.
bool IsSetGenomic_strand(void) const
genomic-strand represents the strand of translation Check if a value has been assigned to Genomic_str...
TAmin GetAmin(void) const
Get the Amin member data.
Definition: Prot_pos_.hpp:220
bool IsSetProduct_id(void) const
product is either protein or transcript (cDNA) Check if a value has been assigned to Product_id data ...
const TProduct_start & GetProduct_start(void) const
Get the Product_start member data.
TDim GetDim(void) const
Get the Dim member data.
const TIds & GetIds(void) const
Get the Ids member data.
const TProduct_end & GetProduct_end(void) const
Get the Product_end member data.
const TSpliced & GetSpliced(void) const
Get the variant data.
Definition: Seq_align_.cpp:219
const TSecond_starts & GetSecond_starts(void) const
Get the Second_starts member data.
const TPacked & GetPacked(void) const
Get the variant data.
Definition: Seq_align_.cpp:175
const TStd & GetStd(void) const
Get the variant data.
Definition: Seq_align_.hpp:752
const TLens & GetLens(void) const
Get the Lens member data.
list< CRef< CSpliced_exon > > TExons
bool IsSetSecond_strands(void) const
Check if a value has been assigned to Second_strands data member.
const TFirst_starts & GetFirst_starts(void) const
Get the First_starts member data.
const TDendiag & GetDendiag(void) const
Get the variant data.
Definition: Seq_align_.hpp:726
TGenomic_strand GetGenomic_strand(void) const
Get the Genomic_strand member data.
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
TNumseg GetNumseg(void) const
Get the Numseg member data.
TProduct_strand GetProduct_strand(void) const
Get the Product_strand member data.
const TStrands & GetStrands(void) const
Get the Strands member data.
const TSecond_strands & GetSecond_strands(void) const
Get the Second_strands member data.
const TSecond_id & GetSecond_id(void) const
Get the Second_id member data.
TGenomic_end GetGenomic_end(void) const
Get the Genomic_end member data.
const TStarts & GetStarts(void) const
Get the Starts member data.
list< CRef< CSeq_align > > Tdata
const TSparse & GetSparse(void) const
Get the variant data.
Definition: Seq_align_.cpp:241
bool IsSetGenomic_id(void) const
Check if a value has been assigned to Genomic_id data member.
bool IsNucpos(void) const
Check if variant Nucpos is selected.
const TRows & GetRows(void) const
Get the Rows member data.
const TDisc & GetDisc(void) const
Get the variant data.
Definition: Seq_align_.cpp:197
list< CRef< CDense_diag > > TDendiag
Definition: Seq_align_.hpp:194
TNucpos GetNucpos(void) const
Get the variant data.
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
const TGenomic_id & GetGenomic_id(void) const
Get the Genomic_id member data.
@ e_not_set
No variant selected.
Definition: Seq_align_.hpp:132
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TExcept_text & GetExcept_text(void) const
Get the Except_text member data.
Definition: Seq_feat_.hpp:1405
bool IsSetExcept_text(void) const
explain if except=TRUE Check if a value has been assigned to Except_text data member.
Definition: Seq_feat_.hpp:1393
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
const TLoc & GetLoc(void) const
Get the Loc member data.
Definition: Seq_graph_.hpp:869
const Tdata & Get(void) const
Get the member data.
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Seq_annot_.hpp:852
bool IsSetDesc(void) const
used only for stand alone Seq-annots Check if a value has been assigned to Desc data member.
Definition: Seq_annot_.hpp:840
list< CRef< CAnnotdesc > > Tdata
@ e_not_set
No variant selected.
Definition: Seq_annot_.hpp:132
@ e_Locs
used for communication between tools
Definition: Seq_annot_.hpp:137
Definition of all error codes used in objmgr libraries (xobjmgr.lib, xobjutil.lib and others).
int len
static MDB_envinfo info
Definition: mdb_load.c:37
mdb_mode_t mode
Definition: lmdb++.h:38
T min(T x_, T y_)
#define row(bind, expected)
Definition: string_bind.c:73
void SetAnnotType(TAnnotType type)
void SetFeatSubtype(TFeatSubtype subtype)
Definition: type.c:6
#define _ASSERT
#define const
Definition: zconf.h:232
Modified on Tue Apr 23 07:39:11 2024 by modify_doxy.py rev. 669887