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

Go to the SVN repository for this file.

1 /* $Id: seq_annot_info.cpp 99506 2023-04-10 19:49:27Z 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: Eugene Vasilchenko
27 *
28 * File Description:
29 * CSeq_annot_Info info -- entry for data source information about Seq-annot
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
34 
35 #define ANNOT_EDIT_COPY 1
36 
41 #include <objmgr/impl/tse_info.hpp>
49 #include <objmgr/error_codes.hpp>
51 
55 #include <objects/seq/Annot_id.hpp>
63 
64 
65 #define NCBI_USE_ERRCODE_X ObjMgr_SeqAnnot
66 
68 
70 
72 
73 
75  : m_ChunkId(chunk_id)
76 {
77  x_SetObject(annot);
78 }
79 
80 
82  : m_ChunkId(0)
83 {
84  x_SetSNP_annot_Info(snp_annot);
85 }
86 
87 
89  TObjectCopyMap* copy_map)
90  : TParent(info, copy_map),
91  m_ChunkId(info.GetChunkId())
92 {
93  if ( !copy_map ) {
94  info.x_UpdateComplete();
95  m_ChunkId = 0;
96  }
97  x_SetObject(info, copy_map);
98 }
99 
100 
102 {
103 }
104 
105 
107 {
108  return static_cast<const CBioseq_Base_Info&>(GetBaseParent_Info());
109 }
110 
111 
113 {
114  return static_cast<CBioseq_Base_Info&>(GetBaseParent_Info());
115 }
116 
117 
119 {
121 }
122 
123 
125 {
127 }
128 
129 
131 {
133 }
134 
135 
137 {
138  x_BaseParentAttach(parent);
139 }
140 
141 
143 {
144  x_BaseParentDetach(parent);
145 }
146 
147 
149 {
151  x_DSMapObject(m_Object, ds);
152  if ( m_SNP_Info ) {
153  m_SNP_Info->x_DSAttach(ds);
154  }
155 }
156 
157 
159 {
160  if ( m_SNP_Info ) {
161  m_SNP_Info->x_DSDetach(ds);
162  }
165 }
166 
167 
169 {
170  ds.x_Map(obj, this);
171 }
172 
173 
175 {
176  ds.x_Unmap(obj, this);
177 }
178 
179 
181 {
183  if ( snp_info ) {
185  m_SNP_Info = snp_info;
186  snp_info->x_ParentAttach(*this);
187  _ASSERT(&snp_info->GetParentSeq_annot_Info() == this);
188  x_AttachObject(*snp_info);
189  }
192  x_UpdateName();
194  if ( m_SNP_Info ) {
195  m_SNP_Info->x_TSEAttach(tse);
196  }
197 }
198 
199 
201 {
202  if ( m_SNP_Info ) {
203  m_SNP_Info->x_TSEDetach(tse);
204  }
205  if ( !x_DirtyAnnotIndex() ) {
206  x_UnmapAnnotObjects(tse);
209  }
211  tse.x_UnregisterBioObject(*this);
213 }
214 
215 
217 {
218  return m_Name;
219 }
220 
221 
223 {
224  int zoom_level = -1;
225  m_Name.SetUnnamed();
226  const CSeq_annot& annot = *m_Object;
227  if ( annot.IsSetId() ) {
228  const CSeq_annot::TId& ids = annot.GetId();
229  ITERATE ( CSeq_annot::TId, it, ids ) {
230  const CAnnot_id& id = **it;
231  if ( id.IsOther() ) {
232  const CTextannot_id& text_id = id.GetOther();
233  if ( text_id.IsSetAccession() ) {
234  const string& acc = text_id.GetAccession();
235  if ( text_id.IsSetVersion() ) {
236  int ver = text_id.GetVersion();
237  m_Name.SetNamed(acc+'.'+NStr::IntToString(ver));
238  }
239  else {
240  m_Name.SetNamed(acc);
241  }
242  break;
243  }
244  }
245  }
246  }
247  if ( annot.IsSetDesc() ) {
248  const CSeq_annot::TDesc::Tdata& descs = annot.GetDesc().Get();
249  ITERATE( CSeq_annot::TDesc::Tdata, it, descs ) {
250  const CAnnotdesc& desc = **it;
251  if ( desc.Which() == CAnnotdesc::e_Name ) {
252  if ( m_Name.IsNamed() ) {
253  continue;
254  }
255  m_Name.SetNamed(desc.GetName());
256  }
257  else if ( desc.Which() == CAnnotdesc::e_User ) {
258  if ( zoom_level >= 0 ) {
259  continue;
260  }
261  const CUser_object& user = desc.GetUser();
262  const CObject_id& type = user.GetType();
263  if ( !type.IsStr() || type.GetStr() != "AnnotationTrack" ) {
264  continue;
265  }
266  CConstRef<CUser_field> field = user.GetFieldRef("ZoomLevel");
267  if ( field && field->GetData().IsInt() ) {
268  zoom_level = field->GetData().GetInt();
269  }
270  }
271  }
272  }
273  if ( HasTSE_Info() && GetTSE_Info().GetName().IsNamed() ) {
274  m_Name = GetTSE_Info().GetName();
275  }
276  if ( zoom_level >= 0 && m_Name.IsNamed() ) {
279  NStr::IntToString(zoom_level));
280  }
281 }
282 
283 
285 {
286  string ret;
287  if ( GetName().IsNamed() ) {
288  ret = GetName().GetName();
289  }
290  if ( HasTSE_Info() ) {
291  if ( !ret.empty() ) {
292  ret += '|';
293  }
294  ret += GetTSE_Info().GetDescription();
295  }
296  return ret;
297 }
298 
299 
302 {
304 }
305 
306 
309 {
311 }
312 
313 
315 {
317  return GetSeq_annotCore();
318 }
319 
320 
322 {
323  x_UpdateCore();
324  return m_Object;
325 }
326 
327 
329 {
331  m_Object.Reset(&obj);
332  if ( HasDataSource() ) {
334  }
335  x_InitAnnotList();
336  if ( HasTSE_Info() ) {
337  x_UpdateName();
339  }
340 }
341 
342 
343 namespace {
344  CRef<CSeq_annot> sx_ShallowCopy(const CSeq_annot& src)
345  {
346  CRef<CSeq_annot> obj(new CSeq_annot);
347 #if ANNOT_EDIT_COPY
348  obj->Assign(src);
349 #else
350  if ( src.IsSetId() ) {
351  obj->SetId() = src.GetId();
352  }
353  if ( src.IsSetDb() ) {
354  obj->SetDb(src.GetDb());
355  }
356  if ( src.IsSetName() ) {
357  obj->SetName(src.GetName());
358  }
359  if ( src.IsSetDesc() ) {
360  obj->SetDesc().Set() = src.GetDesc().Get();
361  }
362 #endif
363  return obj;
364  }
365 }
366 
367 
369  TObjectCopyMap* /*copy_map*/)
370 {
372  m_Object = sx_ShallowCopy(info.x_GetObject());
373  if ( HasDataSource() ) {
375  }
376  m_Name = info.m_Name;
377  if ( info.m_SNP_Info ) {
378  m_SNP_Info.Reset(new CSeq_annot_SNP_Info(*info.m_SNP_Info));
379  m_SNP_Info->x_ParentAttach(*this);
381  }
382 #if ANNOT_EDIT_COPY
383  x_InitAnnotList();
384 #else
386 #endif
388 }
389 
390 
392 {
393  _ASSERT(!m_SNP_Info && !m_Object && !snp_info.HasParent_Info());
395  m_SNP_Info.Reset(&snp_info);
396  snp_info.x_ParentAttach(*this);
397  _ASSERT(&snp_info.GetParentSeq_annot_Info() == this);
398  x_AttachObject(snp_info);
399 }
400 
401 
403 {
404  _ASSERT(m_Object);
406 
407  C_Data& data = m_Object->SetData();
408  switch ( data.Which() ) {
409  case C_Data::e_Ftable:
410  x_InitFeatList(data.SetFtable());
411  break;
412  case C_Data::e_Align:
413  x_InitAlignList(data.SetAlign());
414  break;
415  case C_Data::e_Graph:
416  x_InitGraphList(data.SetGraph());
417  break;
418  case C_Data::e_Locs:
419  x_InitLocsList(data.SetLocs());
420  break;
421  case C_Data::e_Seq_table:
422  x_InitFeatTable(data.SetSeq_table());
423  break;
424  default:
425  break;
426  }
427 }
428 
429 
431 {
432  _ASSERT(m_ObjectIndex.GetInfos().empty());
433  TAnnotIndex index = 0;
434  NON_CONST_ITERATE ( TFtable, oit, objs ) {
435  CAnnotObject_Info info(*this, index++, oit);
437  }
438 }
439 
440 
442 {
443  _ASSERT(m_ObjectIndex.GetInfos().empty());
444  TAnnotIndex index = 0;
445  NON_CONST_ITERATE ( TAlign, oit, objs ) {
446  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index++, oit));
447  }
448  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
449 }
450 
451 
453 {
454  _ASSERT(m_ObjectIndex.GetInfos().empty());
455  TAnnotIndex index = 0;
456  NON_CONST_ITERATE ( TGraph, oit, objs ) {
457  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index++, oit));
458  }
459  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
460 }
461 
462 
464 {
465  _ASSERT(m_ObjectIndex.GetInfos().empty());
466  TAnnotIndex index = 0;
467  NON_CONST_ITERATE ( TLocs, oit, objs ) {
468  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index++, oit));
469  }
470  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
471 }
472 
473 
475 {
477 
478  _ASSERT(m_ObjectIndex.GetInfos().empty());
480  // index whole Seq-table
483  _ASSERT(m_ObjectIndex.GetInfos().size() == 1u);
484  }
485  else {
487 
488  if ( IsSortedTable() ) {
489  // sorted table of small elements,
490  // index it as a single entry,
491  // then use sorted position for lookup
493  return;
494  }
495 
496  // index each row separately
497  TAnnotIndex rows = table.GetNum_rows();
498  for ( TAnnotIndex index = 0; index < rows; ++index ) {
500  }
501  _ASSERT(size_t(rows) == m_ObjectIndex.GetInfos().size());
502  }
503 }
504 
505 
507 {
508  _ASSERT(m_Object);
510 
511  const C_Data& src_data = info.x_GetObject().GetData();
512  C_Data& data = m_Object->SetData();
513  _ASSERT(data.Which() == C_Data::e_not_set);
514  switch ( src_data.Which() ) {
515  case C_Data::e_Ftable:
516  x_InitFeatList(data.SetFtable(), info);
517  break;
518  case C_Data::e_Align:
519  x_InitAlignList(data.SetAlign(), info);
520  break;
521  case C_Data::e_Graph:
522  x_InitGraphList(data.SetGraph(), info);
523  break;
524  case C_Data::e_Locs:
525  x_InitLocsList(data.SetLocs(), info);
526  break;
527  case C_Data::e_Ids:
528  data.SetIds() = src_data.GetIds();
529  break;
530  case C_Data::e_Seq_table:
531  x_InitFeatTable(data.SetSeq_table());
532  break;
533  default:
534  break;
535  }
536 }
537 
538 
540 {
541  _ASSERT(m_ObjectIndex.GetInfos().empty());
542  TAnnotIndex index = 0;
544  info.m_ObjectIndex.GetInfos() ) {
545  if ( oit->IsRemoved() ) {
547  }
548  else {
549  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index, objs,
550  oit->GetFeat()));
551  }
552  ++index;
553  }
554  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
555 }
556 
557 
559 {
560  _ASSERT(m_ObjectIndex.GetInfos().empty());
561  TAnnotIndex index = 0;
562  ITERATE ( SAnnotObjectsIndex::TObjectInfos, oit, info.m_ObjectIndex.GetInfos() ) {
563  if ( oit->IsRemoved() ) {
565  }
566  else {
567  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index, objs,
568  oit->GetAlign()));
569  }
570  ++index;
571  }
572  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
573 }
574 
575 
577 {
578  _ASSERT(m_ObjectIndex.GetInfos().empty());
579  TAnnotIndex index = 0;
580  ITERATE ( SAnnotObjectsIndex::TObjectInfos, oit, info.m_ObjectIndex.GetInfos() ) {
581  if ( oit->IsRemoved() ) {
583  }
584  else {
585  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index, objs,
586  oit->GetGraph()));
587  }
588  ++index;
589  }
590  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
591 }
592 
593 
595 {
596  _ASSERT(m_ObjectIndex.GetInfos().empty());
597  TAnnotIndex index = 0;
598  ITERATE ( SAnnotObjectsIndex::TObjectInfos, oit, info.m_ObjectIndex.GetInfos() ) {
599  if ( oit->IsRemoved() ) {
601  }
602  else {
603  m_ObjectIndex.AddInfo(CAnnotObject_Info(*this, index, objs,
604  oit->GetLocs()));
605  }
606  ++index;
607  }
608  _ASSERT(size_t(index) == m_ObjectIndex.GetInfos().size());
609 }
610 
611 
613 {
614  NCBI_THROW(CObjMgrException, eNotImplemented,
615  "CSeq_annot_Info::x_DoUpdate: unimplemented");
616 }
617 
618 
620 {
621  if ( x_DirtyAnnotIndex() ) {
622  GetTSE_Info().UpdateAnnotIndex(*this);
624  }
625 }
626 
627 
629 {
630  x_InitAnnotKeys(tse);
631 
632  if ( m_SNP_Info ) {
634  }
636 }
637 
638 
640 {
641  if ( m_ObjectIndex.IsIndexed() ) {
642  return;
643  }
645 
646  C_Data& data = m_Object->SetData();
647  switch ( data.Which() ) {
648  case C_Data::e_Ftable:
649  x_InitFeatKeys(tse);
650  break;
651  case C_Data::e_Align:
652  x_InitAlignKeys(tse);
653  break;
654  case C_Data::e_Graph:
655  x_InitGraphKeys(tse);
656  break;
657  case C_Data::e_Locs:
658  x_InitLocsKeys(tse);
659  break;
660  case C_Data::e_Seq_table:
661  x_InitFeatTableKeys(tse);
662  break;
663  default:
664  break;
665  }
666 
669 }
670 
671 
673  const SAnnotObject_Key& key,
674  const SAnnotObject_Index& index)
675 {
676  if ( key.m_Range.Empty() ) {
677  const CAnnotObject_Info& info = *index.m_AnnotObject_Info;
678  CNcbiOstrstream s;
679  if ( !info.IsRegular() ) {
680  s << "unknown object";
681  }
682  else if ( info.IsFeat() ) {
683  s << MSerial_AsnText << info.GetFeat();
684  }
685  else if ( info.IsGraph() ) {
686  s << "graph " << MSerial_AsnText << info.GetGraph().GetLoc();
687  }
688  else if ( info.IsAlign() ) {
689  s << MSerial_AsnText << info.GetAlign();
690  }
691  else {
692  s << "unknown object";
693  }
694  ERR_POST_X(6, "Failed to parse location of "<<s.rdbuf()<<" in "<<GetDescription());
695  return false;
696  }
697  bool new_id = mapper.Map(key, index);
698  m_ObjectIndex.AddMap(key, index);
699  return new_id;
700 }
701 
702 
704  size_t keys_begin)
705 {
706  size_t keys_end = m_ObjectIndex.GetKeys().size();
707  _ASSERT(keys_begin <= keys_end);
708  if ( keys_begin + 1 == keys_end &&
709  m_ObjectIndex.GetKey(keys_begin).IsSingle() ) {
710  // one simple key, store it inside CAnnotObject_Info
711  info.SetKey(m_ObjectIndex.GetKey(keys_begin));
713  }
714  else {
715  info.SetKeys(keys_begin, keys_end);
716  }
717 }
718 
719 
721 {
722  _ASSERT(m_ObjectIndex.GetInfos().size() >= m_Object->GetData().GetFtable().size());
723  size_t object_count = m_ObjectIndex.GetInfos().size();
724  m_ObjectIndex.ReserveMapSize(size_t(double(object_count)*1.1));
725 
727  SAnnotObject_Index index;
729  vector<CHandleRangeMap> hrmaps;
730 
731  CTSEAnnotObjectMapper mapper(tse, GetName());
732 
734  m_ObjectIndex.GetInfos() ) {
735  CAnnotObject_Info& info = *it;
736  if ( info.IsRemoved() ) {
737  continue;
738  }
739  _ASSERT(info.GetFeatType() == info.GetFeatFast()->GetData().Which());
740  }
742  m_ObjectIndex.GetInfos() ) {
743  CAnnotObject_Info& info = *it;
744  if ( info.IsRemoved() ) {
745  continue;
746  }
747  _ASSERT(info.GetFeatType() == info.GetFeatFast()->GetData().Which());
748  size_t keys_begin = m_ObjectIndex.GetKeys().size();
749  index.m_AnnotObject_Info = &info;
750 
751  info.GetMaps(hrmaps, master);
752 
753  index.m_AnnotLocationIndex = 0;
754 
755  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
756  bool multi_id = hrmit->GetMap().size() > 1;
757  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
758  const CHandleRange& hr = hrit->second;
759  key.m_Range = hr.GetOverlappingRange();
760  if ( key.m_Range.Empty() ) {
761  ERR_POST_X(1, "Empty region in "<<GetDescription()<<" "<<
762  MSerial_AsnText<<*info.GetFeatFast());
763  continue;
764  }
765  key.m_Handle = hrit->first;
767  if ( multi_id ) {
768  index.SetMultiIdFlag();
769  }
770  if ( info.GetFeatFast()->IsSetPartial() ) {
771  index.SetPartial(info.GetFeatFast()->GetPartial());
772  }
773  if ( hr.HasGaps() ) {
775  index.m_HandleRange->GetData() = hr;
776  if ( hr.IsCircular() ) {
777  key.m_Range = hr.GetCircularRangeStart();
778  x_Map(mapper, key, index);
779  key.m_Range = hr.GetCircularRangeEnd();
780  }
781  }
782  else {
783  index.m_HandleRange.Reset();
784  }
785  x_Map(mapper, key, index);
786  }
787  ++index.m_AnnotLocationIndex;
788  }
789  x_UpdateObjectKeys(info, keys_begin);
791  }
792 }
793 
794 
796 {
797  _ASSERT(m_ObjectIndex.GetInfos().size() >= m_Object->GetData().GetGraph().size());
798  size_t object_count = m_ObjectIndex.GetInfos().size();
799  m_ObjectIndex.ReserveMapSize(object_count);
800 
802  SAnnotObject_Index index;
804  vector<CHandleRangeMap> hrmaps;
805 
806  CTSEAnnotObjectMapper mapper(tse, GetName());
807 
809  m_ObjectIndex.GetInfos() ) {
810  CAnnotObject_Info& info = *it;
811  if ( info.IsRemoved() ) {
812  continue;
813  }
814  size_t keys_begin = m_ObjectIndex.GetKeys().size();
815  index.m_AnnotObject_Info = &info;
816 
817  info.GetMaps(hrmaps, master);
818  index.m_AnnotLocationIndex = 0;
819 
820  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
821  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
822  const CHandleRange& hr = hrit->second;
823  key.m_Range = hr.GetOverlappingRange();
824  if ( key.m_Range.Empty() ) {
825  ERR_POST_X(2, "Empty region in "<<GetDescription()<<" "<<
826  MSerial_AsnText<<*info.GetGraphFast());
827  continue;
828  }
829  key.m_Handle = hrit->first;
830  if ( hr.HasGaps() ) {
832  index.m_HandleRange->GetData() = hr;
833  }
834  else {
835  index.m_HandleRange.Reset();
836  }
837 
838  x_Map(mapper, key, index);
839  }
840  ++index.m_AnnotLocationIndex;
841  }
842  x_UpdateObjectKeys(info, keys_begin);
843  }
844 }
845 
846 
848  const CSeq_align& align,
849  const CMasterSeqSegments* master,
850  CTSEAnnotObjectMapper& mapper)
851 {
852  if ( align.GetSegs().IsDisc() ) {
853  // discontinuous alignments should be indexed separately
854  // add keys for each sub-alignment
855  const CSeq_align_set::Tdata& sub_aligns =
856  align.GetSegs().GetDisc().Get();
857  list< vector<CHandleRangeMap> > all_hrmaps;
858  TTotalRangesMap total_ranges_map;
859  for ( auto& align_ref : sub_aligns ) {
860  vector<CHandleRangeMap> hrmaps;
861  CAnnotObject_Info::x_ProcessAlign(hrmaps, *align_ref, master);
862  for ( auto& hrm : hrmaps ) {
863  ITERATE ( CHandleRangeMap, hrit, hrm ) {
864  total_ranges_map[hrit->first] += hrit->second.GetOverlappingRange();
865  }
866  }
867  all_hrmaps.push_back(hrmaps);
868  }
869  auto hrmap_iter = all_hrmaps.begin();
870  for ( auto& align_ref : sub_aligns ) {
871  x_AddAlignIndex(info, *align_ref, mapper, *hrmap_iter++, &total_ranges_map);
872  }
873  }
874  else {
875  vector<CHandleRangeMap> hrmaps;
876  CAnnotObject_Info::x_ProcessAlign(hrmaps, align, master);
877  x_AddAlignIndex(info, align, mapper, hrmaps);
878  }
879 }
880 
881 
883  const CSeq_align& align,
884  CTSEAnnotObjectMapper& mapper,
885  vector<CHandleRangeMap>& hrmaps,
886  const TTotalRangesMap* total_ranges_map)
887 {
888  SAnnotObject_Index index;
889  index.m_AnnotObject_Info = &info;
890  index.m_AnnotLocationIndex = 0;
891 
892  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
893  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
894  const CHandleRange& hr = hrit->second;
896  key.m_Range = total_ranges_map? total_ranges_map->find(hrit->first)->second: hr.GetOverlappingRange();
897  if ( key.m_Range.Empty() ) {
898  ERR_POST_X(3, "Empty region in "<<GetDescription()<<
899  " "<<MSerial_AsnText<<info.GetAlign());
900  continue;
901  }
902  key.m_Handle = hrit->first;
903  if ( total_ranges_map || hr.HasGaps() ) {
905  index.m_HandleRange->GetData() = hr;
906  }
907  else {
908  index.m_HandleRange.Reset();
909  }
910 
911  x_Map(mapper, key, index);
912  }
913  ++index.m_AnnotLocationIndex;
914  }
915 }
916 
917 
919 {
920  _ASSERT(m_ObjectIndex.GetInfos().size() >= m_Object->GetData().GetAlign().size());
921  size_t object_count = m_ObjectIndex.GetInfos().size();
922  m_ObjectIndex.ReserveMapSize(object_count);
923 
925  CTSEAnnotObjectMapper mapper(tse, GetName());
926 
928  m_ObjectIndex.GetInfos() ) {
929  CAnnotObject_Info& info = *it;
930  if ( info.IsRemoved() ) {
931  continue;
932  }
933  size_t keys_begin = m_ObjectIndex.GetKeys().size();
934  x_AddAlignKeys(info, info.GetAlign(), master, mapper);
935  x_UpdateObjectKeys(info, keys_begin);
936  }
937 }
938 
939 
941 {
942  _ASSERT(m_ObjectIndex.GetInfos().size() >= m_Object->GetData().GetLocs().size());
943  // Only one referenced location per annot is allowed
944  if ( m_ObjectIndex.GetInfos().size() != 1) {
945  return;
946  }
947 
949  if ( info.IsRemoved() ) {
950  return;
951  }
952 
954  SAnnotObject_Index index;
956  vector<CHandleRangeMap> hrmaps;
957 
958  CTSEAnnotObjectMapper mapper(tse, GetName());
959 
960  size_t keys_begin = m_ObjectIndex.GetKeys().size();
961  index.m_AnnotObject_Info = &info;
962 
963  info.GetMaps(hrmaps, master);
964  index.m_AnnotLocationIndex = 0;
965 
966  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
967  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
968  const CHandleRange& hr = hrit->second;
969  key.m_Range = hr.GetOverlappingRange();
970  if ( key.m_Range.Empty() ) {
971  ERR_POST_X(4, "Empty region in "<<GetDescription()<<" "<<
972  MSerial_AsnText<<info.GetLocs());
973  continue;
974  }
975  key.m_Handle = hrit->first;
976  if ( hr.HasGaps() ) {
978  index.m_HandleRange->GetData() = hr;
979  }
980  else {
981  index.m_HandleRange.Reset();
982  }
983  x_Map(mapper, key, index);
984  }
985  }
986  x_UpdateObjectKeys(info, keys_begin);
987 }
988 
989 
991  CRef<CSeq_point>& seq_pnt,
992  CRef<CSeq_interval>& seq_int,
993  const CAnnotObject_Info& info) const
994 {
995  m_Table_Info->UpdateSeq_feat(info.GetAnnotIndex(),
996  seq_feat, seq_pnt, seq_int);
997 }
998 
999 
1001  CRef<CSeq_loc>& seq_loc,
1002  CRef<CSeq_point>& seq_pnt,
1003  CRef<CSeq_interval>& seq_int,
1004  const CAnnotObject_Info& info) const
1005 {
1006  m_Table_Info->GetLocation().UpdateSeq_loc(info.GetAnnotIndex(),
1007  seq_loc, seq_pnt, seq_int);
1008 }
1009 
1010 
1012  CRef<CSeq_loc>& seq_loc,
1013  CRef<CSeq_point>& seq_pnt,
1014  CRef<CSeq_interval>& seq_int,
1015  const CAnnotObject_Info& info) const
1016 {
1017  m_Table_Info->GetProduct().UpdateSeq_loc(info.GetAnnotIndex(),
1018  seq_loc, seq_pnt, seq_int);
1019 }
1020 
1021 
1023 {
1024  return m_Table_Info->IsPartial(info.GetAnnotIndex());
1025 }
1026 
1027 
1029 {
1031 
1032  if ( !m_Table_Info->IsFeatTable() ) {
1033  // index whole Seq-table
1036  SAnnotObject_Index index;
1037  CHandleRangeMap hrmap;
1038  hrmap.SetMasterSeq(master);
1039  CTSEAnnotObjectMapper mapper(tse, GetName());
1041  if ( info.IsRemoved() ) {
1042  return;
1043  }
1044  size_t keys_begin = m_ObjectIndex.GetKeys().size();
1045  index.m_AnnotObject_Info = &info;
1046  index.m_AnnotLocationIndex = 0;
1048  if ( !loc ) {
1049  return;
1050  }
1051  hrmap.AddLocation(*loc);
1052  bool multi_id = hrmap.GetMap().size() > 1;
1053  ITERATE ( CHandleRangeMap, hrit, hrmap ) {
1054  const CHandleRange& hr = hrit->second;
1055  key.m_Range = hr.GetOverlappingRange();
1056  if ( key.m_Range.Empty() ) {
1057  ERR_POST_X(7, "Empty region in "<<GetDescription()<<
1058  " Seq-table location "<<MSerial_AsnText<<*loc);
1059  continue;
1060  }
1061  key.m_Handle = hrit->first;
1063  if ( multi_id ) {
1064  index.SetMultiIdFlag();
1065  }
1066  if ( hr.HasGaps() ) {
1068  index.m_HandleRange->GetData() = hr;
1069  if ( hr.IsCircular() ) {
1070  key.m_Range = hr.GetCircularRangeStart();
1071  x_Map(mapper, key, index);
1072  key.m_Range = hr.GetCircularRangeEnd();
1073  }
1074  }
1075  else {
1076  index.m_HandleRange.Reset();
1077  }
1078  x_Map(mapper, key, index);
1079  }
1080  x_UpdateObjectKeys(info, keys_begin);
1081  return;
1082  }
1083 
1084  size_t object_count = m_ObjectIndex.GetInfos().size();
1085  m_ObjectIndex.ReserveMapSize(object_count);
1086 
1088  SAnnotObject_Index index;
1089 
1090  CTSEAnnotObjectMapper mapper(tse, GetName());
1091 
1092  SAnnotObjectsIndex::TObjectInfos::iterator it =
1093  m_ObjectIndex.GetInfos().begin();
1094  for ( size_t row = 0; row < object_count; ++row, ++it ) {
1095  CAnnotObject_Info& info = *it;
1096  if ( info.GetAnnotIndex() == kWholeAnnotIndex ) {
1097  size_t keys_begin = m_ObjectIndex.GetKeys().size();
1098  index.m_AnnotObject_Info = &info;
1099  index.m_AnnotLocationIndex = 0;
1100  index.m_Flags = index.fStrand_both;
1101  index.m_HandleRange.Reset();
1103  _ASSERT(loc && loc->IsInt()); // checked in x_InitFeatTable()
1104  key.m_Handle = CSeq_id_Handle::GetHandle(loc->GetInt().GetId());
1105  key.m_Range = loc->GetTotalRange();
1106  x_Map(mapper, key, index);
1107  x_UpdateObjectKeys(info, keys_begin);
1108  continue;
1109  }
1110 
1111  if ( info.IsRemoved() ) {
1112  continue;
1113  }
1114  if ( m_Table_Info->RowIsDisabled(row) ) {
1115  continue;
1116  }
1117  size_t keys_begin = m_ObjectIndex.GetKeys().size();
1118  index.m_AnnotObject_Info = &info;
1119  bool partial = m_Table_Info->IsPartial(row);
1120  for ( index.m_AnnotLocationIndex = 0;
1121  index.m_AnnotLocationIndex < 2;
1122  index.m_AnnotLocationIndex++ ) {
1123  // index by location, then by product
1124  const CSeqTableLocColumns& loc =
1125  index.m_AnnotLocationIndex == 0?
1128  if ( loc.IsSet() ) { // if this Seq-loc field is set
1129  if ( loc.IsRealLoc() ) { // full Seq-loc object
1130  CHandleRangeMap hrmap;
1131  hrmap.SetMasterSeq(master);
1132  hrmap.AddLocation(*loc.GetLoc(row));
1133  bool multi_id = hrmap.GetMap().size() > 1;
1134  ITERATE ( CHandleRangeMap, hrit, hrmap ) {
1135  const CHandleRange& hr = hrit->second;
1136  key.m_Range = hr.GetOverlappingRange();
1137  if ( key.m_Range.Empty() ) {
1138  ERR_POST_X(8, "Empty region in "<<GetDescription()<<
1139  " Seq-table row "<<row);
1140  continue;
1141  }
1142  key.m_Handle = hrit->first;
1144  if ( multi_id ) {
1145  index.SetMultiIdFlag();
1146  }
1147  if ( hr.HasGaps() ) {
1149  index.m_HandleRange->GetData() = hr;
1150  if ( hr.IsCircular() ) {
1151  key.m_Range = hr.GetCircularRangeStart();
1152  x_Map(mapper, key, index);
1153  key.m_Range = hr.GetCircularRangeEnd();
1154  }
1155  }
1156  else {
1157  index.m_HandleRange.Reset();
1158  }
1159  index.SetPartial(partial);
1160  x_Map(mapper, key, index);
1161  }
1162  }
1163  else { // simplified Seq-loc object
1164  loc.SetTableKeyAndIndex(row, key, index);
1165  index.SetPartial(partial);
1166  x_Map(mapper, key, index);
1167  }
1168  }
1169  }
1170 
1171  x_UpdateObjectKeys(info, keys_begin);
1172  //x_MapFeatIds(info);
1173  }
1174 }
1175 
1176 
1179  EFeatIdType id_type)
1180 {
1181  if ( id.IsLocal() ) {
1182  GetTSE_Info().x_MapFeatById(id.GetLocal(), info, id_type);
1183  }
1184 }
1185 
1186 
1189  EFeatIdType id_type)
1190 {
1191  if ( id.IsLocal() ) {
1192  GetTSE_Info().x_UnmapFeatById(id.GetLocal(), info, id_type);
1193  }
1194 }
1195 
1196 
1199 {
1200  if ( gene.IsSetLocus() ) {
1201  GetTSE_Info().x_MapFeatByLocus(gene.GetLocus(), false, info);
1202  }
1203  else if ( gene.IsSetDesc() ) {
1204  GetTSE_Info().x_MapFeatByLocus(gene.GetDesc(), false, info);
1205  }
1206  if ( gene.IsSetLocus_tag() ) {
1207  GetTSE_Info().x_MapFeatByLocus(gene.GetLocus_tag(), true, info);
1208  }
1209 }
1210 
1211 
1214 {
1215  if ( gene.IsSetLocus() ) {
1216  GetTSE_Info().x_UnmapFeatByLocus(gene.GetLocus(), false, info);
1217  }
1218  else if ( gene.IsSetDesc() ) {
1219  GetTSE_Info().x_UnmapFeatByLocus(gene.GetDesc(), false, info);
1220  }
1221  if ( gene.IsSetLocus_tag() ) {
1223  }
1224 }
1225 
1226 
1228 {
1229  if ( !info.IsRegular() ) {
1230  // table?
1231  return;
1232  }
1233  const CSeq_feat& feat = *info.GetFeatFast();
1234  if ( feat.IsSetId() ) {
1235  x_MapFeatById(feat.GetId(), info, eFeatId_id);
1236  }
1237  if ( feat.IsSetIds() ) {
1238  ITERATE ( CSeq_feat::TIds, it, feat.GetIds() ) {
1239  x_MapFeatById(**it, info, eFeatId_id);
1240  }
1241  }
1242  if ( info.GetFeatType() == CSeqFeatData::e_Gene ) {
1243  x_MapFeatByGene(feat.GetData().GetGene(), info);
1244  }
1245  if ( feat.IsSetXref() ) {
1246  ITERATE ( CSeq_feat::TXref, it, feat.GetXref() ) {
1247  const CSeqFeatXref& xref = **it;
1248  if ( xref.IsSetId() ) {
1250  }
1251  }
1252  }
1253 }
1254 
1255 
1257 {
1258  if ( !info.IsRegular() ) {
1259  // table?
1260  return;
1261  }
1262  const CSeq_feat& feat = *info.GetFeatFast();
1263  if ( feat.IsSetId() ) {
1265  }
1266  if ( feat.IsSetIds() ) {
1267  ITERATE ( CSeq_feat::TIds, it, feat.GetIds() ) {
1269  }
1270  }
1271  if ( info.GetFeatType() == CSeqFeatData::e_Gene ) {
1273  }
1274  if ( feat.IsSetXref() ) {
1275  ITERATE ( CSeq_feat::TXref, it, feat.GetXref() ) {
1276  const CSeqFeatXref& xref = **it;
1277  if ( xref.IsSetId() ) {
1279  }
1280  }
1281  }
1282 }
1283 
1284 
1286 {
1287  if ( x_DirtyAnnotIndex() ) {
1288  return false;
1289  }
1290 
1291  bool ret = false;
1292  CTSE_Info& tse = GetTSE_Info();
1294  if (HasDataSource())
1295  guard.Guard(GetDataSource());
1297 
1299  SAnnotObject_Index index;
1301  vector<CHandleRangeMap> hrmaps;
1302 
1303  CTSEAnnotObjectMapper mapper(tse, GetName());
1304 
1305  index.m_AnnotObject_Info = &info;
1306 
1307  info.GetMaps(hrmaps, master);
1308  index.m_AnnotLocationIndex = 0;
1309  size_t keys_begin = m_ObjectIndex.GetKeys().size();
1310  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
1311  bool multi_id = hrmit->GetMap().size() > 1;
1312  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
1313  const CHandleRange& hr = hrit->second;
1314  key.m_Range = hr.GetOverlappingRange();
1315  if ( key.m_Range.Empty() ) {
1316  CNcbiOstrstream s;
1317  const CSerialObject* obj = 0;
1318  obj = dynamic_cast<const CSerialObject*>(info.GetObjectPointer());
1319  if ( obj ) {
1320  s << MSerial_AsnText << *obj;
1321  }
1322  else {
1323  s << "unknown annotation";
1324  }
1325  ERR_POST_X(5, "Empty region in " << GetDescription() << " "
1326  << (string)CNcbiOstrstreamToString(s));
1327  continue;
1328  }
1329  key.m_Handle = hrit->first;
1331  if ( multi_id ) {
1332  index.SetMultiIdFlag();
1333  }
1334  if ( hr.HasGaps() ) {
1336  index.m_HandleRange->GetData() = hr;
1337  if ( hr.IsCircular() ) {
1338  key.m_Range = hr.GetCircularRangeStart();
1339  if ( x_Map(mapper, key, index) ) {
1340  ret = true;
1341  }
1342  key.m_Range = hr.GetCircularRangeEnd();
1343  }
1344  }
1345  else {
1346  index.m_HandleRange.Reset();
1347  }
1348  if ( x_Map(mapper, key, index) ) {
1349  ret = true;
1350  }
1351  }
1352  ++index.m_AnnotLocationIndex;
1353  }
1354  x_UpdateObjectKeys(info, keys_begin);
1355  if ( info.IsFeat() ) {
1356  x_MapFeatIds(info);
1357  }
1358  return ret;
1359 }
1360 
1361 
1363 {
1364  if ( x_DirtyAnnotIndex() ) {
1365  return false;
1366  }
1367 
1369  return x_MapAnnotObject(info);
1370 
1371  /*
1372  if ( info.IsFeat() &&
1373  info.GetFeatSubtype() != info.GetFeatFast()->GetSubtype() ) {
1374  x_UnmapAnnotObject(info);
1375  x_MapAnnotObject(info);
1376  return;
1377  }
1378 
1379  SAnnotObject_Key key;
1380  SAnnotObject_Index index;
1381  vector<CHandleRangeMap> hrmaps;
1382 
1383  index.m_AnnotObject_Info = &info;
1384 
1385  info.GetMaps(hrmaps, master);
1386  index.m_AnnotLocationIndex = 0;
1387  size_t keys_begin = m_ObjectIndex.GetKeys().size();
1388  ITERATE ( vector<CHandleRangeMap>, hrmit, hrmaps ) {
1389  bool multi_id = hrmit->GetMap().size() > 1;
1390  ITERATE ( CHandleRangeMap, hrit, *hrmit ) {
1391  const CHandleRange& hr = hrit->second;
1392  key.m_Range = hr.GetOverlappingRange();
1393  if ( key.m_Range.Empty() ) {
1394  CNcbiOstrstream s;
1395  const CSerialObject* obj = 0;
1396  obj = dynamic_cast<const CSerialObject*>(info.GetObjectPointer());
1397  if ( obj ) {
1398  s << MSerial_AsnText << *obj;
1399  }
1400  else {
1401  s << "unknown annotation";
1402  }
1403  ERR_POST_X(9, "Empty region in "<<GetDescription()<<" "<<s.rdbuf());
1404  continue;
1405  }
1406  key.m_Handle = hrit->first;
1407  index.m_Flags = hr.GetStrandsFlag();
1408  if ( multi_id ) {
1409  index.SetMultiIdFlag();
1410  }
1411  if ( hr.HasGaps() ) {
1412  index.m_HandleRange.Reset(new CObjectFor<CHandleRange>);
1413  index.m_HandleRange->GetData() = hr;
1414  if ( hr.IsCircular() ) {
1415  key.m_Range = hr.GetCircularRangeStart();
1416  x_Map(mapper, key, index);
1417  key.m_Range = hr.GetCircularRangeEnd();
1418  }
1419  }
1420  else {
1421  index.m_HandleRange.Reset();
1422  }
1423  x_Map(mapper, key, index);
1424  }
1425  ++index.m_AnnotLocationIndex;
1426  }
1427  x_UpdateObjectKeys(info, keys_begin);
1428 
1429 
1430  CTSE_Info& tse = GetTSE_Info();
1431  CDataSource::TAnnotLockWriteGuard guard(eEmptyGuard);
1432  if (HasDataSource())
1433  guard.Guard(GetDataSource());
1434  CTSE_Info::TAnnotLockWriteGuard guard2(tse.GetAnnotLock());
1435 
1436  CTSEAnnotObjectMapper mapper(tse, GetName());
1437  // replace annotation indexes in TSE
1438 
1439  size_t old_begin, old_end;
1440  if ( info.HasSingleKey() ) {
1441  mapper.Unmap(info.GetKey(), info);
1442  old_begin = old_end = 0;
1443  }
1444  else {
1445  old_begin = info.GetKeysBegin();
1446  old_end = info.GetKeysEnd()
1447  for ( size_t i = old_begin; i < old_end; ++i ) {
1448  mapper.Unmap(m_ObjectIndex.GetKey(i), info);
1449  }
1450  }
1451  if ( new_count == 1 &&
1452  m_ObjectIndex.GetKey(keys_begin).IsSingle() ) {
1453  // one simple key, store it inside CAnnotObject_Info
1454  info.SetKey(m_ObjectIndex.GetKey(keys_begin));
1455  m_ObjectIndex.RemoveLastMap();
1456  mapper.Map(info.GetKey(), info);
1457  }
1458  else {
1459  info.SetKeys(keys_begin, keys_end);
1460  for ( size_t i = keys_begin; i < keys_end; ++i ) {
1461  mapper.Map(m_ObjectIndex.GetKey(i), info);
1462  }
1463  }
1464  */
1465 }
1466 
1467 
1469 {
1470  if ( x_DirtyAnnotIndex() ) {
1471  return;
1472  }
1473 
1474  CTSE_Info& tse = GetTSE_Info();
1476  if (HasDataSource())
1477  guard.Guard(GetDataSource());
1479 
1480  CTSEAnnotObjectMapper mapper(tse, GetName());
1481 
1482  if ( info.HasSingleKey() ) {
1483  mapper.Unmap(info.GetKey(), info);
1484  }
1485  else {
1486  for ( size_t i = info.GetKeysBegin(); i < info.GetKeysEnd(); ++i ) {
1487  mapper.Unmap(m_ObjectIndex.GetKey(i), info);
1488  }
1489  }
1490  info.ResetKey();
1491  if ( info.IsFeat() ) {
1493  }
1494 }
1495 
1496 
1498 {
1499  if ( m_SNP_Info ) {
1501  }
1502  if ( m_ObjectIndex.GetInfos().empty() ) {
1503  return;
1504  }
1505  if ( m_Object && m_Object->GetData().IsFtable() ) {
1507  x_UnmapFeatIds(*oit);
1508  }
1509  }
1511  m_ObjectIndex.Clear();
1512 }
1513 
1514 
1516 {
1517  if ( m_SNP_Info ) {
1519  }
1520  m_ObjectIndex.Clear();
1521 }
1522 
1523 
1524 namespace {
1525  void sx_CheckType(CSeq_annot::C_Data& data,
1527  const char* error)
1528  {
1529  if ( data.Which() != type ) {
1530  if ( data.Which() == data.e_not_set ) {
1531  data.Select(type);
1532  }
1533  else {
1534  NCBI_THROW(CObjMgrException, eInvalidHandle, error);
1535  }
1536  }
1537  }
1538 
1539  bool sx_SameLocation(const CSeq_feat& obj1, const CSeq_feat& obj2)
1540  {
1541  if ( !obj1.GetLocation().Equals(obj2.GetLocation()) ) {
1542  return false;
1543  }
1544  if ( obj1.IsSetProduct() ) {
1545  return obj2.IsSetProduct() &&
1546  obj1.GetProduct().Equals(obj2.GetProduct());
1547  }
1548  return !obj2.IsSetProduct();
1549  }
1550 
1551  inline
1552  bool sx_SameLocation(const CSeq_align& obj1, const CSeq_align& obj2)
1553  {
1554  return obj1.Equals(obj2);
1555  }
1556 
1557  inline
1558  bool sx_SameLocation(const CSeq_graph& obj1, const CSeq_graph& obj2)
1559  {
1560  return obj1.GetLoc().Equals(obj2.GetLoc());
1561  }
1562 
1563  template<class Set>
1564  bool sx_SameSets(const Set& old_set, const Set& new_set)
1565  {
1566  typename Set::const_iterator old_it = old_set.begin();
1567  ITERATE ( typename Set, new_it, new_set ) {
1568  if ( old_it == old_set.end() ) {
1569  return false;
1570  }
1571  if ( !(*old_it)->Equals(**new_it) ) {
1572  return false;
1573  }
1574  ++old_it;
1575  }
1576  return old_it == old_set.end();
1577  }
1578 
1579  bool sx_SameFeatIndex(const CAnnotObject_Info& info,
1580  const CSeq_feat& new_obj)
1581  {
1582  if ( info.GetFeatSubtype() != new_obj.GetData().GetSubtype() ) {
1583  return false;
1584  }
1585  const CSeq_feat& old_obj = info.GetFeat();
1586  if ( info.GetFeatType() == CSeqFeatData::e_Gene ) {
1587  if ( !old_obj.GetData().GetGene().Equals(
1588  new_obj.GetData().GetGene()) ) {
1589  return false;
1590  }
1591  }
1592  if ( !sx_SameLocation(old_obj, new_obj) ) {
1593  return false;
1594  }
1595  if ( old_obj.IsSetId() != new_obj.IsSetId() ) {
1596  return false;
1597  }
1598  if ( old_obj.IsSetId() ) {
1599  if ( !old_obj.GetId().Equals(new_obj.GetId()) ) {
1600  return false;
1601  }
1602  }
1603  if ( old_obj.IsSetIds() != new_obj.IsSetIds() ) {
1604  return false;
1605  }
1606  if ( old_obj.IsSetIds() ) {
1607  if ( !sx_SameSets(old_obj.GetIds(), new_obj.GetIds()) ) {
1608  return false;
1609  }
1610  }
1611  if ( old_obj.IsSetXref() != new_obj.IsSetXref() ) {
1612  return false;
1613  }
1614  if ( old_obj.IsSetXref() ) {
1615  if ( !sx_SameSets(old_obj.GetXref(), new_obj.GetXref()) ) {
1616  return false;
1617  }
1618  }
1619  return true;
1620  }
1621 }
1622 
1623 
1625 {
1626  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1628  _ASSERT(info.IsRegular());
1629  _ASSERT(&info.GetSeq_annot_Info() == this);
1631 }
1632 
1633 
1635 {
1636  if ( m_SNP_Info ) {
1637  NCBI_THROW(CObjMgrException, eNotImplemented,
1638  "CSeq_annot_Handle: cannot update index of SNP table");
1639  }
1640  if ( !x_DirtyAnnotIndex() ) {
1642  m_ObjectIndex.Clear();
1644  }
1645 }
1646 
1647 
1649 {
1650  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1652  _ASSERT(info.IsRegular());
1653  _ASSERT(&info.GetSeq_annot_Info() == this);
1655 
1656  // remove annotation from Seq-annot object
1657  C_Data& data = m_Object->SetData();
1658  _ASSERT(info.Which() == data.Which());
1659  switch ( data.Which() ) {
1660  case C_Data::e_Ftable:
1661  data.SetFtable().erase(info.x_GetFeatIter());
1662  break;
1663  case C_Data::e_Align:
1664  data.SetAlign().erase(info.x_GetAlignIter());
1665  break;
1666  case C_Data::e_Graph:
1667  data.SetGraph().erase(info.x_GetGraphIter());
1668  break;
1669  case C_Data::e_Locs:
1670  data.SetLocs().erase(info.x_GetLocsIter());
1671  break;
1672  default:
1673  break;
1674  }
1675 
1676  // mark CAnnotObject_Info as removed
1677  info.Reset();
1678  _ASSERT(info.IsRemoved());
1679 }
1680 
1681 
1682 pair<CSeq_annot_Info::TAnnotIndex, bool>
1684 {
1685  C_Data& data = m_Object->SetData();
1686  sx_CheckType(data, data.e_Ftable,
1687  "Cannot add Seq-feat: Seq-annot is not ftable");
1688  TAnnotIndex index = TAnnotIndex(m_ObjectIndex.GetInfos().size());
1690  index,
1691  data.SetFtable(),
1692  new_obj));
1694  _ASSERT(&info == &GetInfo(index));
1695  _ASSERT(&info.GetFeat() == &new_obj);
1696  return make_pair(index, x_MapAnnotObject(info));
1697 }
1698 
1699 
1700 pair<CSeq_annot_Info::TAnnotIndex, bool>
1702 {
1703  C_Data& data = m_Object->SetData();
1704  sx_CheckType(data, data.e_Align,
1705  "Cannot add Seq-align: Seq-annot is not align");
1706  TAnnotIndex index = TAnnotIndex(m_ObjectIndex.GetInfos().size());
1708  index,
1709  data.SetAlign(),
1710  new_obj));
1712  _ASSERT(&info == &GetInfo(index));
1713  _ASSERT(&info.GetAlign() == &new_obj);
1714  return make_pair(index, x_MapAnnotObject(info));
1715 }
1716 
1717 
1718 pair<CSeq_annot_Info::TAnnotIndex, bool>
1720 {
1721  C_Data& data = m_Object->SetData();
1722  sx_CheckType(data, data.e_Graph,
1723  "Cannot add Seq-graph: Seq-annot is not graph");
1724  TAnnotIndex index = TAnnotIndex(m_ObjectIndex.GetInfos().size());
1726  index,
1727  data.SetGraph(),
1728  new_obj));
1730  _ASSERT(&info == &GetInfo(index));
1731  _ASSERT(&info.GetGraph() == &new_obj);
1732  return make_pair(index, x_MapAnnotObject(info));
1733 }
1734 
1735 
1737 {
1738  C_Data& data = m_Object->SetData();
1739  sx_CheckType(data, data.e_Ftable,
1740  "Cannot replace Seq-feat: Seq-annot is not ftable");
1741  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1742  SAnnotObjectsIndex::TObjectInfos::iterator info_iter =
1743  m_ObjectIndex.GetInfos().begin()+index;
1744  CAnnotObject_Info& info = *info_iter;
1745  if ( info.IsRemoved() ) {
1746  TFtable& cont = data.SetFtable();
1747  TFtable::iterator cont_iter = cont.end();
1748  SAnnotObjectsIndex::TObjectInfos::const_iterator it = info_iter;
1749  SAnnotObjectsIndex::TObjectInfos::const_iterator it_end =
1750  m_ObjectIndex.GetInfos().end();
1751  for ( ; it != it_end; ++it ) {
1752  if ( !it->IsRemoved() ) {
1753  cont_iter = it->x_GetFeatIter();
1754  break;
1755  }
1756  }
1757  cont_iter =
1758  cont.insert(cont_iter, Ref(const_cast<CSeq_feat*>(&new_obj)));
1759  info = CAnnotObject_Info(*this, index, cont_iter);
1760  _ASSERT(!info.IsRemoved());
1761  return x_MapAnnotObject(info);
1762  }
1763  else if ( sx_SameFeatIndex(info, new_obj) ) {
1764  // same index -> just replace
1765  info.x_SetObject(new_obj);
1766  return false;
1767  }
1768  else {
1769  // reindex
1771  info.x_SetObject(new_obj);
1772  return x_MapAnnotObject(info);
1773  }
1774 }
1775 
1776 
1778 {
1779  C_Data& data = m_Object->SetData();
1780  sx_CheckType(data, data.e_Align,
1781  "Cannot replace Seq-align: Seq-annot is not align");
1782  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1783  SAnnotObjectsIndex::TObjectInfos::iterator info_iter =
1784  m_ObjectIndex.GetInfos().begin()+index;
1785  CAnnotObject_Info& info = *info_iter;
1786  if ( info.IsRemoved() ) {
1787  TAlign& cont = data.SetAlign();
1788  TAlign::iterator cont_iter = cont.end();
1789  SAnnotObjectsIndex::TObjectInfos::const_iterator it = info_iter;
1790  SAnnotObjectsIndex::TObjectInfos::const_iterator it_end =
1791  m_ObjectIndex.GetInfos().end();
1792  for ( ; it != it_end; ++it ) {
1793  if ( !it->IsRemoved() ) {
1794  cont_iter = it->x_GetAlignIter();
1795  break;
1796  }
1797  }
1798  cont_iter =
1799  cont.insert(cont_iter, Ref(const_cast<CSeq_align*>(&new_obj)));
1800  info = CAnnotObject_Info(*this, index, cont_iter);
1801  _ASSERT(!info.IsRemoved());
1802  return x_MapAnnotObject(info);
1803  }
1804  else if ( sx_SameLocation(info.GetAlign(), new_obj) ) {
1805  // same index -> just replace
1806  info.x_SetObject(new_obj);
1807  return false;
1808  }
1809  else {
1810  // reindex
1812  info.x_SetObject(new_obj);
1813  return x_MapAnnotObject(info);
1814  }
1815 }
1816 
1817 
1819 {
1820  C_Data& data = m_Object->SetData();
1821  sx_CheckType(data, data.e_Graph,
1822  "Cannot replace Seq-graph: Seq-annot is not graph");
1823  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1824  SAnnotObjectsIndex::TObjectInfos::iterator info_iter =
1825  m_ObjectIndex.GetInfos().begin()+index;
1826  CAnnotObject_Info& info = *info_iter;
1827  if ( info.IsRemoved() ) {
1828  TGraph& cont = data.SetGraph();
1829  TGraph::iterator cont_iter = cont.end();
1830  SAnnotObjectsIndex::TObjectInfos::const_iterator it = info_iter;
1831  SAnnotObjectsIndex::TObjectInfos::const_iterator it_end =
1832  m_ObjectIndex.GetInfos().end();
1833  for ( ; it != it_end; ++it ) {
1834  if ( !it->IsRemoved() ) {
1835  cont_iter = it->x_GetGraphIter();
1836  break;
1837  }
1838  }
1839  cont_iter =
1840  cont.insert(cont_iter, Ref(const_cast<CSeq_graph*>(&new_obj)));
1841  info = CAnnotObject_Info(*this, index, cont_iter);
1842  _ASSERT(!info.IsRemoved());
1843  return x_MapAnnotObject(info);
1844  }
1845  else if ( sx_SameLocation(info.GetGraph(), new_obj) ) {
1846  // same index -> just replace
1847  info.x_SetObject(new_obj);
1848  return false;
1849  }
1850  else {
1851  // reindex
1853  info.x_SetObject(new_obj);
1854  return x_MapAnnotObject(info);
1855  }
1856 }
1857 
1858 
1859 void CSeq_annot_Info::ReorderFtable(const vector<CSeq_feat_Handle>& feats)
1860 {
1861  C_Data& data = m_Object->SetData();
1862  if ( !data.IsFtable() ) {
1863  NCBI_THROW(CObjMgrException, eInvalidHandle,
1864  "ReorderFtable: Seq-annot annot is not ftable");
1865  }
1866  C_Data::TFtable& cont = data.SetFtable();
1867  ITERATE ( vector<CSeq_feat_Handle>, it, feats ) {
1868  if ( &it->x_GetSeq_annot_Info() != this ) {
1869  continue;
1870  }
1871  const CAnnotObject_Info& info = it->x_GetAnnotObject_Info();
1872  if ( !info.IsRegular() ) {
1873  continue;
1874  }
1875  const_cast<CAnnotObject_Info&>(info).x_MoveToBack(cont);
1876  }
1877 }
1878 
1879 
1881  const CObject_id& id,
1882  EFeatIdType id_type)
1883 {
1884  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1886  _ASSERT(info.IsRegular());
1887  _ASSERT(&info.GetSeq_annot_Info() == this);
1888  CRef<CSeq_feat> feat(&const_cast<CSeq_feat&>(info.GetFeat()));
1889  GetTSE_Info().x_MapFeatById(id, info, id_type);
1890  CRef<CFeat_id> feat_id(new CFeat_id);
1891  feat_id->SetLocal().Assign(id);
1892  if ( id_type == eFeatId_xref ) {
1893  CRef<CSeqFeatXref> feat_xref(new CSeqFeatXref);
1894  feat_xref->SetId(*feat_id);
1895  feat->SetXref().push_back(feat_xref);
1896  }
1897  else if ( !feat->IsSetId() ) {
1898  feat->SetId(*feat_id);
1899  }
1900  else {
1901  feat->SetIds().push_back(feat_id);
1902  }
1903 }
1904 
1905 
1907  const CObject_id& id,
1908  EFeatIdType id_type)
1909 {
1910  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1912  _ASSERT(info.IsRegular());
1913  _ASSERT(&info.GetSeq_annot_Info() == this);
1914  CRef<CSeq_feat> feat(&const_cast<CSeq_feat&>(info.GetFeat()));
1915  bool removed_id = false;
1916  if ( id_type == eFeatId_xref ) {
1917  if ( feat->IsSetXref() ) {
1918  NON_CONST_ITERATE ( CSeq_feat::TXref, it, feat->SetXref() ) {
1919  const CSeqFeatXref& feat_xref = **it;
1920  if ( !feat_xref.IsSetId() ) {
1921  continue;
1922  }
1923  const CFeat_id& feat_id = feat_xref.GetId();
1924  if ( feat_id.IsLocal() && feat_id.GetLocal().Equals(id) ) {
1925  feat->SetXref().erase(it);
1926  if ( feat->SetXref().empty() ) {
1927  feat->ResetXref();
1928  }
1929  removed_id = true;
1930  break;
1931  }
1932  }
1933  }
1934  }
1935  else {
1936  if ( feat->IsSetId() && feat->GetId().IsLocal() &&
1937  feat->GetId().GetLocal().Equals(id) ) {
1938  feat->ResetId();
1939  removed_id = true;
1940  }
1941  else if ( feat->IsSetIds() ) {
1942  NON_CONST_ITERATE ( CSeq_feat::TIds, it, feat->SetIds() ) {
1943  const CFeat_id& feat_id = **it;
1944  if ( feat_id.IsLocal() && feat_id.GetLocal().Equals(id) ) {
1945  feat->SetIds().erase(it);
1946  if ( feat->SetIds().empty() ) {
1947  feat->ResetIds();
1948  }
1949  removed_id = true;
1950  break;
1951  }
1952  }
1953  }
1954  }
1955  if ( !removed_id ) {
1956  NCBI_THROW(CAnnotException, eFindFailed,
1957  "CSeq_feat_EditHandle::RemoveFeatId: Feat-id not found");
1958  }
1959  GetTSE_Info().x_UnmapFeatById(id, info, id_type);
1960 }
1961 
1962 
1964  EFeatIdType id_type)
1965 {
1966  _ASSERT(size_t(index) < GetAnnotObjectInfos().size());
1968  _ASSERT(info.IsRegular());
1969  _ASSERT(&info.GetSeq_annot_Info() == this);
1970  CRef<CSeq_feat> feat(&const_cast<CSeq_feat&>(info.GetFeat()));
1971  if ( id_type == eFeatId_xref ) {
1972  if ( feat->IsSetXref() ) {
1973  ERASE_ITERATE ( CSeq_feat::TXref, it, feat->SetXref() ) {
1974  const CSeqFeatXref& feat_xref = **it;
1975  if ( !feat_xref.IsSetId() ) {
1976  continue;
1977  }
1978  const CFeat_id& feat_id = feat_xref.GetId();
1979  if ( feat_id.IsLocal() ) {
1980  GetTSE_Info().x_UnmapFeatById(feat_id.GetLocal(), info, id_type);
1981  VECTOR_ERASE(it, feat->SetXref());
1982  }
1983  }
1984  feat->ResetXref();
1985  }
1986  }
1987  else {
1988  if ( feat->IsSetId() && feat->GetId().IsLocal() ) {
1989  GetTSE_Info().x_UnmapFeatById(feat->GetId().GetLocal(), info, id_type);
1990  feat->ResetId();
1991  }
1992  else if ( feat->IsSetIds() ) {
1993  ERASE_ITERATE ( CSeq_feat::TIds, it, feat->SetIds() ) {
1994  const CFeat_id& feat_id = **it;
1995  if ( feat_id.IsLocal() ) {
1996  GetTSE_Info().x_UnmapFeatById(feat_id.GetLocal(), info, id_type);
1997  VECTOR_ERASE(it, feat->SetIds());
1998  }
1999  }
2000  feat->ResetIds();
2001  }
2002  }
2003 }
2004 
2005 
2007 {
2008  return m_Table_Info && m_Table_Info->IsSorted();
2009 }
2010 
2011 
2013 {
2014  if ( m_SNP_Info ) {
2015  return m_SNP_Info->HasLabel(index);
2016  }
2017  else {
2019  return m_Table_Info->HasLabel(index);
2020  }
2021 }
2022 
2023 
2025 {
2026  if ( m_SNP_Info ) {
2027  return m_SNP_Info->GetLabel(index);
2028  }
2029  else {
2031  return m_Table_Info->GetLabel(index);
2032  }
2033 }
2034 
2035 
2038 {
2039  CSeq_annot_SortedIter iter;
2042  _ASSERT(max_len > 0);
2043  TSeqPos min_pos = max(range.GetFrom(), max_len-1) - (max_len-1);
2044  size_t num_rows = m_Table_Info->GetNumRows();
2045  size_t a = 0, b = num_rows;
2046  while ( b-a > 1 ) {
2047  size_t m = a + (b-a)/2;
2049  if ( pos < min_pos ) {
2050  a = m;
2051  }
2052  else {
2053  b = m;
2054  }
2055  }
2056  iter.m_Table_Info = m_Table_Info;
2057  iter.m_RequestRange = range;
2058  iter.m_ObjectRow = a;
2059  iter.m_NumRows = num_rows;
2060  iter.x_Settle();
2061  return iter;
2062 }
2063 
2064 
2065 inline
2067 {
2069  return false;
2070  }
2074  return true;
2075  }
2077 }
2078 
2079 
2081 {
2082  while ( *this && !x_Valid() ) {
2083  ++m_ObjectRow;
2084  }
2085 }
2086 
2087 
2089  const CSeq_annot_SortedIter& iter) const
2090 {
2092  return m_Table_Info->MatchBitFilter(sel, iter.GetRow());
2093 }
2094 
2095 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define NCBI_ANNOT_TRACK_ZOOM_LEVEL_SUFFIX
Named annotations zoom level can be encoded in the accession string with @ suffix,...
Definition: Seq_annot.hpp:146
User-defined methods of the data storage class.
@ eFeatId_id
@ eFeatId_xref
Annotation iterators exceptions.
void SetNamed(const string &name)
Definition: annot_name.hpp:73
const string & GetName(void) const
Definition: annot_name.hpp:62
bool IsNamed(void) const
Definition: annot_name.hpp:58
void SetUnnamed(void)
Definition: annot_name.hpp:68
static void x_ProcessAlign(vector< CHandleRangeMap > &hrmaps, const CSeq_align &align, const CMasterSeqSegments *master)
CAnnot_id –.
Definition: Annot_id.hpp:66
CAnnotdesc –.
Definition: Annotdesc.hpp:66
const CSeq_entry_Info & GetParentSeq_entry_Info(void) const
void Guard(CDataSource &ds)
void x_Unmap(const CObject *obj, const CTSE_Info_Object *info)
void x_Map(const CObject *obj, const CTSE_Info_Object *info)
CFeat_id –.
Definition: Feat_id.hpp:66
void AddLocation(const CSeq_loc &loc, ETransSplicing trans_splcing=eNoTransSplicing)
void SetMasterSeq(const CMasterSeqSegments *master_seq)
const TLocMap & GetMap(void) const
TTotalRangeFlags GetStrandsFlag(void) const
bool IsCircular(void) const
TRange GetCircularRangeStart(bool include_origin=true) const
TRange GetCircularRangeEnd(bool include_origin=true) const
bool HasGaps(void) const
TRange GetOverlappingRange(TTotalRangeFlags flags=eStrandAny) const
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
Base class for all object manager exceptions.
CObjectFor –.
Definition: ncbiobj.hpp:2335
ESubtype GetSubtype(void) const
CSeqFeatXref –.
Definition: SeqFeatXref.hpp:66
static bool IsGoodFeatTable(const CSeq_table &table)
string GetLabel(size_t row) const
bool IsPartial(size_t row) const
size_t GetNumRows(void) const
bool HasLabel(size_t row) const
bool IsFeatTable(void) const
const CSeqTableLocColumns & GetLocation(void) const
bool MatchBitFilter(const SAnnotSelector &sel, size_t row) const
const CSeqTableLocColumns & GetProduct(void) const
void UpdateSeq_feat(size_t row, CRef< CSeq_feat > &seq_feat, CRef< CSeq_point > &seq_pnt, CRef< CSeq_interval > &seq_int) const
SAnnotTypeSelector GetType(void) const
bool IsSorted(void) const
CRange< TSeqPos > GetLocationRange(size_t row) const
TSeqPos GetLocationFrom(size_t row) const
TSeqPos GetSortedMaxLength(void) const
CConstRef< CSeq_loc > GetTableLocation(void) const
bool RowIsDisabled(size_t row) const
bool IsSet(void) const
void SetTableKeyAndIndex(size_t row, SAnnotObject_Key &key, SAnnotObject_Index &index) const
bool IsRealLoc(void) const
void UpdateSeq_loc(size_t row, CRef< CSeq_loc > &seq_loc, CRef< CSeq_point > &seq_pnt, CRef< CSeq_interval > &seq_int) const
CConstRef< CSeq_loc > GetLoc(size_t row) const
void x_InitFeatList(TFtable &objs)
virtual void x_DSAttachContents(CDataSource &ds)
void x_MapFeatById(const CFeat_id &id, CAnnotObject_Info &info, EFeatIdType id_type)
void x_UnmapFeatIds(CAnnotObject_Info &info)
const TAnnotObjectInfos & GetAnnotObjectInfos(void) const
CRef< CSeq_annot_SNP_Info > m_SNP_Info
virtual void x_TSEDetachContents(CTSE_Info &tse)
void Remove(TAnnotIndex index)
virtual string GetDescription(void) const
void AddFeatId(TAnnotIndex index, const CObject_id &id, EFeatIdType id_type)
const CAnnotObject_Info & GetInfo(TAnnotIndex index) const
void x_MapFeatIds(CAnnotObject_Info &info)
void x_InitAlignList(TAlign &objs)
void x_ParentDetach(CBioseq_Base_Info &parent)
void UpdateTableFeatLocation(CRef< CSeq_loc > &seq_loc, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
void x_DSUnmapObject(CConstRef< TObject > obj, CDataSource &ds)
void x_InitLocsKeys(CTSE_Info &tse)
void x_InitAnnotKeys(CTSE_Info &tse)
void x_InitAlignKeys(CTSE_Info &tse)
TAnnotIndex x_GetSNPFeatCount(void) const
void x_AddAlignIndex(CAnnotObject_Info &info, const CSeq_align &align, CTSEAnnotObjectMapper &mapper, vector< CHandleRangeMap > &hrmaps, const TTotalRangesMap *total_ranges_map=0)
virtual void x_TSEAttachContents(CTSE_Info &tse)
void x_SetObject(TObject &obj)
void x_InitFeatKeys(CTSE_Info &tse)
void x_SetSNP_annot_Info(CSeq_annot_SNP_Info &snp_info)
void x_InitFeatTableKeys(CTSE_Info &tse)
bool TableFeat_HasLabel(TAnnotIndex index) const
void x_InitFeatTable(TSeq_table &table)
string TableFeat_GetLabel(TAnnotIndex index) const
void x_UpdateName(void)
bool x_MapAnnotObject(CAnnotObject_Info &info)
CConstRef< TObject > GetCompleteSeq_annot(void) const
bool MatchBitFilter(const SAnnotSelector &sel, const CSeq_annot_SortedIter &iter) const
bool IsSortedTable(void) const
pair< TAnnotIndex, bool > Add(const CSeq_feat &new_obj)
void ClearFeatIds(TAnnotIndex index, EFeatIdType id_type)
const CAnnotName & GetName(void) const
void Update(TAnnotIndex index)
CSeq_annot_Info(CSeq_annot &annot, int chunk_id=0)
void x_ParentAttach(CBioseq_Base_Info &parent)
CRef< TObject > m_Object
void x_DoUpdate(TNeedUpdateFlags flags)
void UpdateTableFeatProduct(CRef< CSeq_loc > &seq_loc, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
void UpdateTableFeat(CRef< CSeq_feat > &seq_feat, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
void x_AddAlignKeys(CAnnotObject_Info &info, const CSeq_align &align, const CMasterSeqSegments *master, CTSEAnnotObjectMapper &mapper)
CConstRef< TObject > GetSeq_annotCore(void) const
void x_DropAnnotObjects(CTSE_Info &tse)
bool IsTableFeatPartial(const CAnnotObject_Info &feat_info) const
void x_UpdateAnnotIndexContents(CTSE_Info &tse)
void UpdateAnnotIndex(void) const
const CBioseq_Base_Info & GetParentBioseq_Base_Info(void) const
const CSeq_entry_Info & GetXrefTSE(void) const
void x_UpdateObjectKeys(CAnnotObject_Info &info, size_t keys_begin)
void RemoveFeatId(TAnnotIndex index, const CObject_id &id, EFeatIdType id_type)
C_Data::TGraph TGraph
void x_MapFeatByGene(const CGene_ref &gene, CAnnotObject_Info &info)
TAnnotIndex x_GetAnnotCount(void) const
CRef< CSeqTableInfo > m_Table_Info
void ReorderFtable(const vector< CSeq_feat_Handle > &feats)
bool x_Map(const CTSEAnnotObjectMapper &mapper, const SAnnotObject_Key &key, const SAnnotObject_Index &index)
void x_InitGraphKeys(CTSE_Info &tse)
C_Data::TAlign TAlign
void x_DSMapObject(CConstRef< TObject > obj, CDataSource &ds)
bool x_RemapAnnotObject(CAnnotObject_Info &info)
void x_UnmapFeatByGene(const CGene_ref &gene, CAnnotObject_Info &info)
void x_UnmapFeatById(const CFeat_id &id, CAnnotObject_Info &info, EFeatIdType id_type)
void x_InitAnnotList(void)
void x_InitGraphList(TGraph &objs)
const CSeq_entry_Info & GetParentSeq_entry_Info(void) const
static const TAnnotIndex kWholeAnnotIndex
bool Replace(TAnnotIndex index, const CSeq_feat &new_obj)
CSeq_annot_SortedIter StartSortedIterator(CRange< TSeqPos > range) const
void x_UnmapAnnotObject(CAnnotObject_Info &info)
void x_UnmapAnnotObjects(CTSE_Info &tse)
virtual void x_DSDetachContents(CDataSource &ds)
C_Data::TLocs TLocs
SAnnotObjectsIndex m_ObjectIndex
C_Data::TFtable TFtable
const CSeq_annot_SNP_Info & x_GetSNP_annot_Info(void) const
void x_InitLocsList(TLocs &annot)
bool HasLabel(size_t index) const
void x_DropAnnotObjects(CTSE_Info &tse)
const CSeq_annot_Info & GetParentSeq_annot_Info(void) const
void x_ParentAttach(CSeq_annot_Info &parent)
string GetLabel(size_t index) const
CSeq_annot & GetRemainingSeq_annot(void)
void x_UnmapAnnotObjects(CTSE_Info &tse)
CRange< TSeqPos > m_RequestRange
CRange< TSeqPos > m_ObjectRange
CRef< CSeqTableInfo > m_Table_Info
size_t GetRow(void) const
const CSeq_entry_Info & GetXrefTSE() const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
void Unmap(const SAnnotObject_Key &key, const CAnnotObject_Info &info) const
Definition: tse_info.hpp:971
bool Map(const SAnnotObject_Key &key, const SAnnotObject_Index &index) const
Definition: tse_info.hpp:965
void x_SetDirtyAnnotIndex(void)
void x_UpdateCore(void) const
virtual void SetBioObjectId(const CBioObjectId &id)
virtual void x_DSDetachContents(CDataSource &ds)
CDataSource & GetDataSource(void) const
void x_BaseParentAttach(CTSE_Info_Object &parent)
bool HasDataSource(void) const
void x_UpdateAnnotIndex(CTSE_Info &tse)
void x_BaseParentDetach(CTSE_Info_Object &parent)
virtual void x_TSEAttachContents(CTSE_Info &tse)
void x_DSAttach(CDataSource &ds)
virtual void x_DSAttachContents(CDataSource &ds)
void x_TSEAttach(CTSE_Info &tse)
virtual void x_TSEDetachContents(CTSE_Info &tse)
const CTSE_Info & GetTSE_Info(void) const
bool x_DirtyAnnotIndex(void) const
void x_UpdateComplete(void) const
const CTSE_Info_Object & GetBaseParent_Info(void) const
bool HasParent_Info(void) const
void x_TSEDetach(CTSE_Info &tse)
void x_AttachObject(CTSE_Info_Object &object)
void x_DSDetach(CDataSource &ds)
virtual void x_UpdateAnnotIndexContents(CTSE_Info &tse)
bool HasTSE_Info(void) const
CRef< CSeq_annot_SNP_Info > x_GetSNP_Info(const CConstRef< CSeq_annot > &annot)
Definition: tse_info.cpp:517
void x_MapFeatByLocus(const string &locus, bool tag, CAnnotObject_Info &info)
Definition: tse_info.cpp:1670
void UpdateAnnotIndex(const CSeq_id_Handle &id) const
Definition: tse_info.cpp:1009
void x_MapFeatById(TFeatIdInt id, CAnnotObject_Info &info, EFeatIdType type)
Definition: tse_info.cpp:1584
CConstRef< CMasterSeqSegments > GetMasterSeqSegments(void) const
Definition: tse_info.cpp:803
void x_UnmapFeatByLocus(const string &locus, bool tag, CAnnotObject_Info &info)
Definition: tse_info.cpp:1677
virtual string GetDescription(void) const
Definition: tse_info.cpp:2049
void x_UnmapFeatById(TFeatIdInt id, CAnnotObject_Info &info, EFeatIdType type)
Definition: tse_info.cpp:1596
CBioObjectId x_RegisterBioObject(CTSE_Info_Object &info)
Definition: tse_info.cpp:437
void x_UnmapAnnotObjects(const SAnnotObjectsIndex &infos)
Definition: tse_info.cpp:1320
TAnnotLock & GetAnnotLock(void) const
Definition: tse_info.hpp:914
const CAnnotName & GetName(void) const
Definition: tse_info.hpp:893
void x_UnregisterBioObject(CTSE_Info_Object &info)
Definition: tse_info.cpp:451
CTextannot_id –.
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Definition: User_object.cpp:84
size_type size() const
Definition: map.hpp:148
const_iterator begin() const
Definition: map.hpp:151
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
static int type
Definition: getdata.c:31
char data[12]
Definition: iconv.c:80
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 ERASE_ITERATE(Type, Var, Cont)
Non-constant version with ability to erase current element, if container permits.
Definition: ncbimisc.hpp:843
#define VECTOR_ERASE(Var, Cont)
Use this macro inside body of ERASE_ITERATE cycle to erase from vector-like container.
Definition: ncbimisc.hpp:852
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
T & GetData(void)
Get data as a reference.
Definition: ncbiobj.hpp:2346
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
position_type GetToOpen(void) const
Definition: range.hpp:138
#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:5084
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Gene_ref_.hpp:599
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
bool IsSetLocus(void) const
Official gene symbol Check if a value has been assigned to Locus data member.
Definition: Gene_ref_.hpp:493
bool IsSetDesc(void) const
descriptive name Check if a value has been assigned to Desc data member.
Definition: Gene_ref_.hpp:587
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
const TLocus & GetLocus(void) const
Get the Locus member data.
Definition: Gene_ref_.hpp:505
const TData & GetData(void) const
Get the Data member data.
bool IsInt(void) const
Check if variant Int is selected.
TInt GetInt(void) const
Get the variant data.
const TType & GetType(void) const
Get the Type member data.
bool IsDisc(void) const
Check if variant Disc is selected.
Definition: Seq_align_.hpp:772
list< CRef< CSeq_align > > Tdata
const TDisc & GetDisc(void) const
Get the variant data.
Definition: Seq_align_.cpp:197
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
TXref & SetXref(void)
Assign a value to Xref data member.
Definition: Seq_feat_.hpp:1314
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Seq_feat_.hpp:1452
TIds & SetIds(void)
Assign a value to Ids data member.
Definition: Seq_feat_.hpp:1458
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_feat_.hpp:904
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Feat_id_.cpp:134
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Feat_id_.hpp:353
const TId & GetId(void) const
Get the Id member data.
void ResetIds(void)
Reset Ids data member.
Definition: Seq_feat_.cpp:200
TLocal & SetLocal(void)
Select the variant.
Definition: Feat_id_.cpp:140
void ResetId(void)
Reset Id data member.
Definition: Seq_feat_.cpp:68
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetId(TId &value)
Assign a value to Id data member.
Definition: Seq_feat_.cpp:73
list< CRef< CFeat_id > > TIds
Definition: Seq_feat_.hpp:126
bool IsSetIds(void) const
set of Ids; will replace 'id' field Check if a value has been assigned to Ids data member.
Definition: Seq_feat_.hpp:1440
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Seq_feat_.hpp:892
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TGene & GetGene(void) const
Get the variant data.
bool IsSetId(void) const
the feature copied Check if a value has been assigned to Id data member.
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
void ResetXref(void)
Reset Xref data member.
Definition: Seq_feat_.cpp:182
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
const TId & GetId(void) const
Get the Id member data.
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
const TLoc & GetLoc(void) const
Get the Loc member data.
Definition: Seq_graph_.hpp:869
const Tdata & Get(void) const
Get the member data.
TVersion GetVersion(void) const
Get the Version member data.
const TName & GetName(void) const
Get the Name member data.
Definition: Seq_annot_.hpp:805
list< CRef< CAnnot_id > > TId
Definition: Seq_annot_.hpp:356
const TAccession & GetAccession(void) const
Get the Accession member data.
bool IsSetName(void) const
source if "other" above Check if a value has been assigned to Name data member.
Definition: Seq_annot_.hpp:793
bool IsSetVersion(void) const
Check if a value has been assigned to Version data member.
const TUser & GetUser(void) const
Get the variant data.
Definition: Annotdesc_.cpp:184
const TIds & GetIds(void) const
Get the variant data.
Definition: Seq_annot_.hpp:681
E_Choice Which(void) const
Which variant is currently selected.
Definition: Annotdesc_.hpp:466
E_Choice
Choice variants.
Definition: Seq_annot_.hpp:131
bool IsSetDb(void) const
Check if a value has been assigned to Db data member.
Definition: Seq_annot_.hpp:746
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
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Seq_annot_.hpp:721
TDb GetDb(void) const
Get the Db member data.
Definition: Seq_annot_.hpp:765
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_annot_.hpp:733
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
const TName & GetName(void) const
Get the variant data.
Definition: Annotdesc_.hpp:501
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_annot_.hpp:586
list< CRef< CAnnotdesc > > Tdata
@ e_Ids
used for communication between tools
Definition: Seq_annot_.hpp:136
@ e_not_set
No variant selected.
Definition: Seq_annot_.hpp:132
@ e_Locs
used for communication between tools
Definition: Seq_annot_.hpp:137
@ e_Name
a short name for this collection
Definition: Annotdesc_.hpp:97
@ e_User
user defined object
Definition: Annotdesc_.hpp:101
@ eEmptyGuard
Definition: guard.hpp:94
Definition of all error codes used in objmgr libraries (xobjmgr.lib, xobjutil.lib and others).
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
unsigned int a
Definition: ncbi_localip.c:102
T max(T x_, T y_)
NCBI_DEFINE_ERR_SUBCODE_X(9)
#define row(bind, expected)
Definition: string_bind.c:73
CRef< CObjectFor< CHandleRange > > m_HandleRange
CAnnotObject_Info * m_AnnotObject_Info
void SetPartial(bool partial)
bool IsSingle(void) const
bool IsIndexed(void) const
void SetName(const CAnnotName &name)
void AddInfo(const CAnnotObject_Info &info)
void ReserveMapSize(size_t size)
TObjectInfos & GetInfos(void)
const SAnnotObject_Key & GetKey(size_t i) const
bool IsEmpty(void) const
deque< CAnnotObject_Info > TObjectInfos
void AddMap(const SAnnotObject_Key &key, const SAnnotObject_Index &index)
const TObjectKeys & GetKeys(void) const
SAnnotSelector –.
Definition: type.c:6
#define _ASSERT
Modified on Fri Jun 14 16:51:55 2024 by modify_doxy.py rev. 669887