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

Go to the SVN repository for this file.

1 /* $Id: object_index.cpp 45881 2021-01-05 03:10:02Z rudnev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 
39 
40 
41 // if "id_handle" represent an accession - return pointer to a orresponding text id
42 inline const CConstRef<CSeq_id> GetAccession(const CSeq_id_Handle& id_handle)
43 {
44  if(id_handle.HaveMatchingHandles()) {
45  CConstRef<CSeq_id> seq_id = id_handle.GetSeqId();
46  const CTextseq_id* text_id = seq_id->GetTextseq_Id();
47  return (text_id && text_id->IsSetAccession()) ? seq_id : CRef<CSeq_id>();
48  }
49  return CRef<CSeq_id>();
50 }
51 
52 
53 inline bool IsAccessionNoVersion(const CSeq_id& seq_id)
54 {
55  const CTextseq_id* text_id = seq_id.GetTextseq_Id();
56  return text_id->IsSetVersion() && ! text_id->IsSetName() &&
57  ! text_id->IsSetRelease();
58 }
59 
60 ///////////////////////////////////////////////////////////////////////////////
61 /// CSeq_id_Descr
62 
64 : m_OriginalAccNoVer(false)
65 {
66 }
67 
68 
70  CScope& scope, bool product)
71 : m_OriginalAccNoVer(false)
72 {
73  Assign(obj_handle, id, scope, product);
74 }
75 
76 
78 {
79 }
80 
81 
82 void CSeq_id_Descr::Assign(ISelObjectHandle* obj_handle, const CSeq_id& id,
83  CScope& scope, bool product)
84 {
85  m_ObjHandle = obj_handle;
86  m_Id.Reset(&id);
87  m_IdHandles = scope.GetIds(id); // extract all synonymous Ids
88  if (m_IdHandles.size() == 0) {
90  }
91  sort(m_IdHandles.begin(), m_IdHandles.end());
92  m_Product = product;
93 
94  // find or create a versionless accession
95  CConstRef<CSeq_id> acc_id;
96 
97  for( size_t i = 0; i < m_IdHandles.size(); i++ ) { // iterate by handles
98  const CSeq_id_Handle& handle = m_IdHandles[i];
99  acc_id = GetAccession(handle);
100  if(acc_id) {
101  if(IsAccessionNoVersion(*acc_id)) { // already versionless
102  m_AccNoVer = handle;
103  m_OriginalAccNoVer = true;
104  return;
105  }
106  break; // end loop with this acc_id
107  }
108  }
109 
110  if(acc_id) { // has accession with version - create a versionless one
111  m_OriginalAccNoVer = false;
112 
113  CSeq_id id;
114  id.Select(acc_id->Which());
115  const CTextseq_id* text_id = acc_id->GetTextseq_Id();
116  const_cast<CTextseq_id*>(id.GetTextseq_Id())->SetAccession(text_id->GetAccession());
118  }
119 }
120 
121 
122 ///////////////////////////////////////////////////////////////////////////////
123 /// CSeq_feat_Descr
124 
126  : m_ProductDescr(NULL)
127 {
128 }
129 
130 
132 {
133  delete m_ProductDescr;
134 }
135 
136 
137 void CSeq_feat_Descr::Assign(ISelObjectHandle* obj_handle, const CSeq_feat& feat,
138  CSeq_id_Descr* product_descr, CScope& scope)
139 {
140  m_ObjHandle.Reset(obj_handle);
141  m_Feat.Reset(&feat);
142  m_ProductDescr = product_descr;
143 }
144 
145 
146 ///////////////////////////////////////////////////////////////////////////////
147 /// CObjectIndex
148 
149 CObjectIndex::SRec::SRec(CSeq_id_Descr* descr, bool original, bool product)
150 : m_Original(original),
151  m_Product(product),
152  m_Descr(descr)
153 {
154 }
155 
156 
158 {
159  //_ASSERT( ! m_HasLoc);
160  return m_Descr;
161 }
162 
163 
165 {
166 }
167 
168 
170 {
171  Clear(NULL);
172 }
173 
174 
176 {
177  // clean-up Features
178  NON_CONST_ITERATE(TFeatDescrs, it_f, m_FeatDescrs) { //TODO ?
179  const CSeq_id_Descr* id = it_f->second->GetProductDescr();
180  TIdDescrs::iterator it_id =
181  std::find(m_IdDescrs.begin(), m_IdDescrs.end(), id);
182  if (it_id != m_IdDescrs.end()) {
183  m_IdDescrs.erase(it_id);
184  }
185 
186  delete it_f->second;
187  }
189  m_FeatMap.clear();
190 
191  // clean-up Ids
192  NON_CONST_ITERATE(TIdDescrs, it_i, m_IdDescrs) { //TODO ?
193  delete *it_i;
194  }
195  m_IdDescrs.clear();
196  m_IdMap.clear();
197 
198  // clean-up Aligns
200  delete it_a->second;
201  }
202  m_AlignMap.clear();
204 
205  m_Scope.Reset(scope);
206 }
207 
208 
209 void CObjectIndex::Add(ISelObjectHandle* obj_handle, const CSeq_id& id, bool product)
210 {
211  x_Add(obj_handle, id, product);
212 }
213 
214 
216  const CSeq_id& id, bool product)
217 {
218  CSeq_id_Descr* descr = new CSeq_id_Descr();
219  descr->Assign(obj_handle, id, *m_Scope, product);
220  m_IdDescrs.push_back(descr);
221 
222  if( ! descr->HasOriginalAccNoVer()) {
223  CSeq_id_Handle idh = descr->GetAccNoVer();
224  if (idh) {
225  // add created versionless accession to the index
226  SRec rec(descr, false, product);
227  m_IdMap.insert(TIdMap::value_type(idh, rec));
228  }
229  }
230  // otherwise versionless accession will be indexed together with all other
231  // handles and will have equal rights in matching
232 
233  // add to index all regular handles
234  const vector<CSeq_id_Handle>& handles = descr->GetIdHandles();
235  for( size_t i = 0; i < handles.size(); i++ ) {
236  const CSeq_id_Handle& h = handles[i];
237  SRec rec(descr, true, product);
239  }
240 
241  return descr;
242 }
243 
244 
245 // TODO - optimize by bit reversing
247 {
248  const CSeq_loc& loc = feature.GetLocation();
249  unsigned int start = 0;
250  unsigned int stop = 0;
251  try {
252  start = loc.GetStart(eExtreme_Positional);
253  stop = loc.GetStop(eExtreme_Positional);
254  } catch (CException&) {
255  try {
256  TSeqRange total_r = loc.GetTotalRange();
257  start = total_r.GetFrom();
258  stop = total_r.GetTo();
259  } catch (CException& e) {
260  ERR_POST("Error on CObjectIndex::x_GetFeatureCode(): " << e.GetMsg());
261  }
262  }
263  unsigned int res = start ^ ((start - stop) << 16);
264 
265  const CSeqFeatData& data = feature.GetData();
266  unsigned int type = (unsigned int) data.GetSubtype();
267  return res ^ type;
268 }
269 
270 
271 void CObjectIndex::Add(ISelObjectHandle* obj_handle, const CSeq_feat& feature)
272 {
274  if(it != m_FeatDescrs.end()) {
275  ERR_POST("CObjectIndex::Add() - feature already in index");
276  return; // already in the index
277  }
278 
279  CSeq_id_Descr* product_descr = NULL;
280 
281  // index Product ID
282  if(feature.IsSetProduct()) {
283  const CSeq_loc& prod_loc = feature.GetProduct();
284  const CSeq_id* id = prod_loc.GetId();
285  if(id) {
286  product_descr = x_Add(obj_handle, *id, true);
287  }
288  }
289 
290  // create descriptior and put in the storage map
291  CSeq_feat_Descr* descr = new CSeq_feat_Descr();
292  descr->Assign(obj_handle, feature, product_descr, *m_Scope);
293  m_FeatDescrs.insert(make_pair(&feature, descr)); // index by pointer
294 
295  TFeatCode code = x_GetFeatureCode(feature);
296  m_FeatMap.insert(TCodeToFeatMap::value_type(code, descr)); // index by code
297 }
298 
299 
300 void CObjectIndex::Add(ISelObjectHandle* obj_handle, const CSeq_align& align)
301 {
302  m_AlignMap.insert( make_pair(CConstRef<CSeq_align>(&align), obj_handle) );
303 }
304 
305 
307 {
309  if(vcf_variant.WeakMatch(*iter->first)) {
310  return iter;
311  }
312  }
313  return m_VcfVariantMap.end();
314 }
315 
317 {
319  if(vcf_variant.WeakMatch(*iter->first)) {
320  return iter;
321  }
322  }
323  return m_VcfVariantMap.end();
324 }
325 
326 
327 void CObjectIndex::Add(ISelObjectHandle* obj_handle, const CVcfVariant& vcf_variant)
328 {
329  TVcfVariantMap::iterator matching_vcf_variant(x_FindVcfVariant(vcf_variant));
330 
331  if(matching_vcf_variant == m_VcfVariantMap.end()) {
332  m_VcfVariantMap.insert(make_pair(CConstRef<CVcfVariant>(&vcf_variant), obj_handle));
333  } else {
334  matching_vcf_variant->second = obj_handle;
335  }
336 }
337 
338 
340 {
341  const type_info& info = typeid(obj);
342  if(info == typeid(CSeq_feat)) {
343  const CSeq_feat* feature = dynamic_cast<const CSeq_feat*>(&obj);
344  Add(obj_handle, *feature);
345  } else if(info == typeid(CSeq_id)) {
346  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
347  Add(obj_handle, *id);
348  } else if(info == typeid(CIdLoc)) {
349  const CIdLoc* loc = dynamic_cast<const CIdLoc*>(&obj);
350  Add(obj_handle, *loc->m_Id);
351  } else if(info == typeid(CSeq_align)) {
352  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&obj);
353  Add(obj_handle, *align);
354  } else if(info == typeid(CVcfVariant)) {
355  const CVcfVariant* vcf_variant = dynamic_cast<const CVcfVariant*>(&obj);
356  Add(obj_handle, *vcf_variant);
357  } else {
358  ERR_POST("ObjectIndex::Add() - type not supported " << info.name());
359  }
360 }
361 
362 
364 {
365  bool removed = false;
366  const type_info& info = typeid(obj);
367  if(info == typeid(CSeq_id)) {
368  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
369  removed = Remove(*id);
370  } else if(info == typeid(CSeq_feat)) {
371  const CSeq_feat* feature = dynamic_cast<const CSeq_feat*>(&obj);
372  removed = Remove(*feature);
373  } else if(info == typeid(CSeq_align)) {
374  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&obj);
375  removed = Remove(*align);
376  } else if(info == typeid(CVcfVariant)) {
377  const CVcfVariant* vcf_variant = dynamic_cast<const CVcfVariant*>(&obj);
378  removed = Remove(*vcf_variant);
379  } else {
380  ERR_POST("ObjectIndex::Remove() - type not supported " << info.name());
381  }
382  return removed;
383 }
384 
385 
386 bool CObjectIndex::Remove(const CSeq_id& id)
387 {
389  CSeq_id_Descr* descr = *it;
390  if(descr->GetId()->Match(id)) {
391  m_IdDescrs.erase(it);
392  x_RemoveFromIdMap(descr);
393  delete descr;
394  return true;
395  }
396  }
397  return false;
398 }
399 
400 
402 {
403  if(descr) {
404  // remove it from m_IdDescrs vector
405  TIdDescrs::iterator it_v = std::find(m_IdDescrs.begin(), m_IdDescrs.end(), descr);
406  if(it_v != m_IdDescrs.end()) {
407  m_IdDescrs.erase(it_v);
408  x_RemoveFromIdMap(descr);
409  //delete descr;
410  }
411  }
412 }
413 
414 
416 {
417  // remove all associated IDs from ID map
418  vector<CSeq_id_Handle> handles = descr->GetIdHandles();
419  CSeq_id_Handle idh = descr->GetAccNoVer();
420  if (idh) {
421  handles.push_back(idh);
422  }
423 
424  for( size_t i = 0; i < handles.size(); i++ ) {
425  const CSeq_id_Handle& h = handles[i];
426 
427  // for every handle in "descr" - find the entry and erase it
428  pair<TIdMap::iterator , TIdMap::iterator> p = m_IdMap.equal_range(h);
429  for( TIdMap::iterator it = p.first; it != p.second; ++it ) {
430  const SRec& rec = it->second;
431  if(rec.m_Descr == descr) {
432  m_IdMap.erase(it);
433  break; // done with this handle
434  }
435  }
436  }
437 }
438 
439 
440 bool CObjectIndex::Remove(const CSeq_feat& feature)
441 {
442  TFeatDescrs::iterator it = m_FeatDescrs.find(&feature);
443 
444  TFeatCode code = x_GetFeatureCode(feature);
445  pair<TCodeToFeatMap::iterator , TCodeToFeatMap::iterator> p =
447  // iterate by features that have the same code
448  for( TCodeToFeatMap::iterator it_d = p.first; it_d != p.second; ++it_d ) {
449  const CSeq_feat_Descr* descr = it_d->second;
450  const CSeq_feat& feat = descr->GetFeat();
451  bool found_match = false;
452  if(it != m_FeatDescrs.end()) {
453  if (&feat == &feature) {
454  found_match = true;
455  }
456  } else {
457  it = m_FeatDescrs.begin();
458  while (it != m_FeatDescrs.end() && it->second != descr) {
459  ++it;
460  }
461  if(it != m_FeatDescrs.end()) {
462  found_match = true;
463  }
464  }
465 
466  if (found_match) {
467  m_FeatMap.erase(it_d);
468  x_Remove(descr->GetProductDescr());
469  delete descr;
470  m_FeatDescrs.erase(it);
471  return true;
472  }
473  }
474 
475  return false;
476 }
477 
478 
479 bool CObjectIndex::Remove(const CSeq_align& align)
480 {
482  return true;
483 }
484 
485 bool CObjectIndex::Remove(const CVcfVariant& vcf_variant)
486 {
487  TVcfVariantMap::iterator matching_vcf_variant(x_FindVcfVariant(vcf_variant));
488  if(matching_vcf_variant != m_VcfVariantMap.end()) {
489  m_VcfVariantMap.erase(matching_vcf_variant);
490  return true;
491  }
492  return false;
493 }
494 
495 
496 bool CObjectIndex::HasMatches(const CObject& object, CScope& scope) const
497 {
498  // dispatch by type
499  const type_info& info = typeid(object);
500  if(info == typeid(CSeq_feat)) {
501  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&object);
502  return HasMatches(*feat, scope);
503  } else if(info == typeid(CSeq_id)) {
504  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&object);
505  CSeq_id_Descr descr;
506  descr.Assign(NULL, *id, scope);
507  return HasMatches(descr);
508  } else if(info == typeid(CSeq_align)) {
509  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&object);
510  return HasMatches(*align);
511  } else if(info == typeid(CVcfVariant)) {
512  const CVcfVariant* vcf_variant = dynamic_cast<const CVcfVariant*>(&object);
513  return HasMatches(*vcf_variant);
514  }
515  return false;
516 }
517 
518 
519 void CObjectIndex::GetMatches(const CObject& object, CScope& scope, TResults& results) const
520 {
521  // dispatch by type
522  const type_info& info = typeid(object);
523  if(info == typeid(CSeq_feat)) {
524  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&object);
525  GetMatches(*feat, scope, results);
526  } else if(info == typeid(CSeq_id)) {
527  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&object);
528  CSeq_id_Descr descr;
529  descr.Assign(NULL, *id, scope);
530  GetMatches(descr, results);
531  } else if(info == typeid(CSeq_align)) {
532  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&object);
533  GetMatches(*align, results);
534  } else if(info == typeid(CVcfVariant)) {
535  const CVcfVariant* vcf_variant = dynamic_cast<const CVcfVariant*>(&object);
536  return GetMatches(*vcf_variant, results);
537  }
538 }
539 
540 
541 bool CObjectIndex::HasMatches(const CSeq_id_Descr& descr) const
542 {
543  const vector<CSeq_id_Handle>& handles = descr.GetIdHandles();
546 
547  // for every element in "handles" perform a lookup
548  for( size_t i = 0; i < handles.size(); i++ ) {
549  const CSeq_id_Handle& h = handles[i];
550  if(x_HasMatches(descr, h, at_least_one, no_ver)) {
551  return true;
552  }
553  }
554 
555  if(no_ver && ! descr.HasOriginalAccNoVer()) {
556  // AccNoVer is not original so it is not in the "handles", need a separate lookup
557  const CSeq_id_Handle& h = descr.GetAccNoVer();
558  return x_HasMatches(descr, h, at_least_one, no_ver);
559  }
560  return false;
561 }
562 
563 
564 // for a given id returns the set of matching ids
566 {
567  results.clear();
568 
569  const vector<CSeq_id_Handle>& handles = descr.GetIdHandles();
572 
573  // for every element in "handles" perform a lookup and add all results
574  // to "results"
575  for( size_t i = 0; i < handles.size(); i++ ) {
576  const CSeq_id_Handle& h = handles[i];
577  x_GetMatches(descr, h, at_least_one, no_ver, results);
578  }
579 
580  if(no_ver && ! descr.HasOriginalAccNoVer()) {
581  // AccNoVer is not original so it is not in the "handles", need a separate lookup
582  const CSeq_id_Handle& h = descr.GetAccNoVer();
583  x_GetMatches(descr, h, at_least_one, no_ver, results);
584  }
585 }
586 
587 
589  bool at_least_one, bool no_ver) const
590 {
591  pair<TIdMap::const_iterator , TIdMap::const_iterator> p = m_IdMap.equal_range(h);
592  for( TIdMap::const_iterator it = p.first; it != p.second; ++it ) {
593  const SRec& rec = it->second;
595  const CSeq_id_Descr* value = rec.GetIdDescr(); // TODO
596  if(at_least_one && (rec.m_Original || no_ver)) {
597  return true;
598  } else if(value->GetIdHandles() == descr.GetIdHandles()) { // exact match for all ids
599  return true;
600  }
601  }
602  }
603  return false;
604 }
605 
606 // retrieves matches for a single handle
608  bool at_least_one, bool no_ver, TResults& results) const
609 {
610  pair<TIdMap::const_iterator , TIdMap::const_iterator> p = m_IdMap.equal_range(h);
611  for( TIdMap::const_iterator it = p.first; it != p.second; ++it ) {
612  const SRec& rec = it->second;
614  const CSeq_id_Descr* value = rec.GetIdDescr(); // TODO
615  CRef<ISelObjectHandle> ref = value->GetObjectHandle();
616  const ISelObjectHandle* obj_handle = ref.GetPointer();
617 
618  if(at_least_one && (rec.m_Original || no_ver)) {
619  results.insert(obj_handle);
620  } else if(value->GetIdHandles() == descr.GetIdHandles()) { // exact match for all ids
621  results.insert(obj_handle);
622  }
623  }
624  }
625 }
626 
627 
628 bool CObjectIndex::HasMatches(const CSeq_feat& feature, CScope& scope) const
629 {
630  //// Matching against Features in the index
631  // first - fast lookup by pointer
632  if(m_FeatDescrs.find(&feature) != m_FeatDescrs.end())
633  return true;
634 
635  // now try matching by value (not by pointer)
636  TFeatCode code = x_GetFeatureCode(feature);
637  pair<TCodeToFeatMap::const_iterator , TCodeToFeatMap::const_iterator> p =
639 
640  // iterate by features that have the same code and check if they are indeed equal
641  for( TCodeToFeatMap::const_iterator it = p.first; it != p.second; ++it ) {
642  const CSeq_feat_Descr& descr = *it->second;
643  const CSeq_feat& feat = descr.GetFeat();
644  if(feat.Equals(feature)) {
645  return true;
646  }
647  }
648 
649  //// Matching agains IDs
651  const CSeq_loc& prod_loc = feature.GetProduct();
652  const CSeq_id* id = prod_loc.GetId();
653  if(id) {
654  CSeq_id_Descr descr;
655  descr.Assign(NULL, *id, scope);
656  return HasMatches(descr);
657  }
658  }
659  return false;
660 }
661 
662 void CObjectIndex::GetMatches(const CSeq_feat& feature, CScope& scope,
663  TResults& results) const
664 {
665  // skipping mathing by pointer - we will find the same object by code
666 
667  TFeatCode code = x_GetFeatureCode(feature);
668  pair<TCodeToFeatMap::const_iterator , TCodeToFeatMap::const_iterator> p =
670 
671  // iterate by features that have the same code
672  for( TCodeToFeatMap::const_iterator it = p.first; it != p.second; ++it ) {
673  const CSeq_feat_Descr& descr = *it->second;
674  const CSeq_feat& feat = descr.GetFeat();
675  if(&feat == &feature || feat.Equals(feature)) {
676  results.insert(descr.GetObjectHandle());
677  }
678  }
679 
680  //// Matching against IDs
682  const CSeq_loc& prod_loc = feature.GetProduct();
683  const CSeq_id* id = prod_loc.GetId();
684  if(id) {
685  CSeq_id_Descr descr;
686  descr.Assign(NULL, *id, scope);
687  GetMatches(descr, results);
688  }
689  }
690 }
691 
692 
693 bool CObjectIndex::HasMatches(const CSeq_align& align) const
694 {
695  CConstRef<CSeq_align> ref(&align);
696  return m_AlignMap.find(ref) != m_AlignMap.end();
697 }
698 
699 bool CObjectIndex::HasMatches(const CVcfVariant& vcf_variant) const
700 {
701  TVcfVariantMap::const_iterator matching_vcf_variant(x_FindVcfVariant(vcf_variant));
702 
703  return matching_vcf_variant != m_VcfVariantMap.end();
704 }
705 
706 
707 void CObjectIndex::GetMatches(const CSeq_align& align, TResults& results) const
708 {
709  CConstRef<CSeq_align> ref(&align);
711  if(it != m_AlignMap.end()) {
712  results.insert(it->second);
713  }
714 }
715 
716 void CObjectIndex::GetMatches(const CVcfVariant& vcf_variant, TResults& results) const
717 {
718  TVcfVariantMap::const_iterator matching_vcf_variant(x_FindVcfVariant(vcf_variant));
719 
720  if(matching_vcf_variant == m_VcfVariantMap.end()) {
721  results.insert(matching_vcf_variant->second);
722  }
723 }
724 
725 
727 {
728  return m_IdDescrs.empty() && m_FeatDescrs.empty() && m_AlignMap.empty() && m_VcfVariantMap.empty();
729 }
730 
731 
733 {
734  typedef CConstRef<CObject> TR;
735 
736  ITERATE(TIdDescrs, it_i, m_IdDescrs) {
737  const CSeq_id_Descr* descr = *it_i;
738  if( ! descr->IsProduct() || CSelectionEvent::sm_MatchByProduct) {
739  const CSeq_id* id = descr->GetId();
740  objects.push_back(TR(id));
741  }
742  }
743 
745  const CSeq_feat* feat = it_f->first;
746  objects.push_back(TR(feat));
747  }
748 
749  ITERATE(TAlignMap, it_a, m_AlignMap) {
750  const CSeq_align* align = &*it_a->first;
751  objects.push_back(TR(align));
752  }
753 
755  const CVcfVariant* vcf_variant = &*it_v->first;
756  objects.push_back(TR(vcf_variant));
757  }
758 }
759 
760 
761 void CObjectIndex::GetOriginalIds(vector<const CSeq_id*>& ids) const
762 {
763  ITERATE(TIdDescrs, it_i, m_IdDescrs) {
764  const CSeq_id_Descr* descr = *it_i;
765  if( ! descr->IsProduct()) {
766  ids.push_back(descr->GetId());
767  }
768  }
769 }
770 
771 
772 void CObjectIndex::GetFeatures(vector<const CSeq_feat*>& features) const
773 {
775  const CSeq_feat* feat = it_f->first;
776  features.push_back(feat);
777  }
778 }
779 
780 
781 void CObjectIndex::GetAligns(vector<const CSeq_align*>& aligns) const
782 {
783  ITERATE(TAlignMap, it_a, m_AlignMap) {
784  const CSeq_align* align = &*it_a->first;
785  aligns.push_back(align);
786  }
787 }
788 
789 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
CConstRef< objects::CSeq_id > m_Id
Definition: obj_event.hpp:57
unsigned int TFeatCode
void Clear(objects::CScope *scope)
TVcfVariantMap::iterator x_FindVcfVariant(const objects::CVcfVariant &vcf_variant)
void x_GetMatches(const CSeq_id_Descr &descr, const objects::CSeq_id_Handle &h, bool at_least_one, bool no_ver, TResults &results) const
bool x_HasMatches(const CSeq_id_Descr &descr, const objects::CSeq_id_Handle &h, bool at_least_one, bool no_ver) const
bool Remove(const CObject &obj)
map< CConstRef< objects::CVcfVariant >, ISelObjectHandle * > TVcfVariantMap
void x_RemoveFromIdMap(const CSeq_id_Descr *descr)
CSeq_id_Descr * x_Add(ISelObjectHandle *obj_handle, const objects::CSeq_id &id, bool product)
void x_Remove(const CSeq_id_Descr *descr)
void GetObjects(TConstObjects &objects) const
TIdDescrs m_IdDescrs
TVcfVariantMap m_VcfVariantMap
set< const ISelObjectHandle * > TResults
static TFeatCode x_GetFeatureCode(const objects::CSeq_feat &feature)
TAlignMap m_AlignMap
bool HasMatches(const CObject &object, objects::CScope &scope) const
TCodeToFeatMap m_FeatMap
bool Empty() const
void GetAligns(vector< const objects::CSeq_align * > &aligns) const
vector< CSeq_id_Descr * > TIdDescrs
void GetFeatures(vector< const objects::CSeq_feat * > &features) const
void Add(ISelObjectHandle *obj_handle, CObject &obj)
TFeatDescrs m_FeatDescrs
void GetOriginalIds(vector< const objects::CSeq_id * > &ids) const
CRef< objects::CScope > m_Scope
void GetMatches(const CObject &object, objects::CScope &scope, TResults &results) const
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
static bool sm_MatchByProduct
Definition: obj_event.hpp:209
static EObjMatchPolicy sm_ObjMatchPolicy
Definition: obj_event.hpp:206
static EIdMatchPolicy sm_IdMatchPolicy
Definition: obj_event.hpp:207
CSeq_feat_Descr.
CRef< ISelObjectHandle > m_ObjHandle
CSeq_feat_Descr()
CSeq_feat_Descr.
CConstRef< objects::CSeq_feat > m_Feat
void Assign(ISelObjectHandle *obj_handle, const objects::CSeq_feat &feat, CSeq_id_Descr *, objects::CScope &scope)
const CSeq_id_Descr * GetProductDescr() const
CSeq_id_Descr * m_ProductDescr
const CRef< ISelObjectHandle > GetObjectHandle() const
const objects::CSeq_feat & GetFeat() const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeq_id_Descr()
CSeq_id_Descr.
CConstRef< objects::CSeq_id > m_Id
bool HasOriginalAccNoVer() const
const objects::CSeq_id_Handle & GetAccNoVer() const
void Assign(ISelObjectHandle *obj_handle, const objects::CSeq_id &id, objects::CScope &scope, bool product=false)
const TIdHandleVector & GetIdHandles() const
CRef< ISelObjectHandle > m_ObjHandle
const objects::CSeq_id * GetId() const
TIdHandleVector m_IdHandles
objects::CSeq_id_Handle m_AccNoVer
bool m_OriginalAccNoVer
bool IsProduct() const
void erase(iterator pos)
Definition: map.hpp:167
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
bool empty() const
Definition: map.hpp:149
void clear()
Definition: map.hpp:169
const_iterator find(const key_type &key) const
Definition: map.hpp:153
const_iterator_pair equal_range(const key_type &key) const
Definition: map.hpp:296
void clear()
Definition: map.hpp:309
void erase(iterator pos)
Definition: map.hpp:307
iterator insert(const value_type &val)
Definition: map.hpp:305
Definition: set.hpp:45
#define false
Definition: bool.h:36
static int type
Definition: getdata.c:31
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
bool WeakMatch(const CVcfVariant &right) const
Definition: snp_gui.hpp:315
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
const CTextseq_id * GetTextseq_Id(void) const
Return embedded CTextseq_id, if any.
Definition: Seq_id.cpp:169
bool HaveMatchingHandles(void) const
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
TIds GetIds(const CSeq_id &id, TGetFlags flags=0)
Get "native" bioseq ids without filtering and matching.
Definition: scope.cpp:401
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
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
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
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
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_id_.hpp:746
bool IsSetRelease(void) const
Check if a value has been assigned to Release data member.
bool IsSetVersion(void) const
Check if a value has been assigned to Version data member.
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TAccession & GetAccession(void) const
Get the Accession member data.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
static MDB_envinfo info
Definition: mdb_load.c:37
constexpr auto sort(_Init &&init)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
USING_SCOPE(objects)
bool IsAccessionNoVersion(const CSeq_id &seq_id)
const CConstRef< CSeq_id > GetAccession(const CSeq_id_Handle &id_handle)
static int * results[]
SRec(CSeq_id_Descr *descr, bool original=true, bool product=false)
CObjectIndex.
const CSeq_id_Descr * GetIdDescr() const
CSeq_id_Descr * m_Descr
Definition: inftrees.h:24
Definition: type.c:6
Modified on Fri Sep 20 14:57:23 2024 by modify_doxy.py rev. 669887