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

Go to the SVN repository for this file.

1 /* $Id: basic_converters.cpp 45111 2020-06-02 20:15:06Z asztalos $
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: Mike DiCuccio
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbiobj.hpp>
34 
35 #include <gui/objutils/utils.hpp>
37 
38 #include <objects/seq/Bioseq.hpp>
42 
54 
56 
60 
63 
68 #include <objects/biotree/Node.hpp>
71 
73 #include <objmgr/annot_ci.hpp>
74 #include <serial/iterator.hpp>
75 #include <objmgr/feat_ci.hpp>
76 #include <objmgr/align_ci.hpp>
77 #include <objmgr/graph_ci.hpp>
78 #include <objmgr/util/sequence.hpp>
79 #include <objmgr/util/feature.hpp>
80 
83 
84 
85 #define CHECK_CANCELLED { if (cancel && cancel->IsCanceled()) return; }
86 
87 /////////////////////////////////////////////////////////////////////////////
88 ///
89 /// Comment formatters
90 ///
91 
92 
94 {
95  if ( !idh ) {
96  return string();
97  }
98  idh = sequence::GetId(idh, scope, sequence::eGetId_Best);
99  if ( !idh ) {
100  return string();
101  }
102 
103  string label;
106 
107  switch (label[0]) {
108  case 'N':
109  switch (label[1]) {
110  case 'C':
111  return string("RefSeq chromosome");
112  case 'T':
113  return string("RefSeq genomic contig");
114  case 'M':
115  return string("RefSeq mRNA");
116  case 'G':
117  return string("RefSeq curated genomic region");
118  case 'R':
119  return string("RefSeq non-coding RNA");
120  case 'P':
121  return string("RefSeq protein");
122  case 'W':
123  return string("RefSeq WGS contig");
124  default:
125  return string("RefSeq sequence");
126  }
127  break;
128 
129  case 'X':
130  switch (label[1]) {
131  case 'M':
132  return string("RefSeq mRNA (predicted)");
133  case 'P':
134  return string("RefSeq protein (predicted)");
135  default:
136  return string("RefSeq sequence (predicted)");
137  }
138  break;
139 
140  case 'A':
141  case 'C':
142  return string("RefSeq chromosome (alternate assembly)");
143 
144  default:
145  break;
146  }
147 
149  label.erase();
150  switch (idh.GetSeqId()->Which()) {
151  case CSeq_id::e_Genbank:
152  label = "GenBank";
153  break;
154  case CSeq_id::e_Embl:
155  label = "EMBL";
156  break;
157  case CSeq_id::e_Ddbj:
158  label = "DDBJ";
159  break;
160  case CSeq_id::e_Other:
161  label = "RefSeq";
162  break;
163  case CSeq_id::e_Gpipe:
164  label = "NCBI Genome Pipeline";
165  break;
166 
167  default:
168  break;
169  }
170 
171  switch (info & CSeq_id::eAcc_division_mask) {
172  case CSeq_id::eAcc_est:
173  if ( !label.empty() ) {
174  label += " ";
175  }
176  label += "EST";
177  break;
178  case CSeq_id::eAcc_htgs:
179  if ( !label.empty() ) {
180  label += " ";
181  }
182  label += "HTGS";
183  break;
184  case CSeq_id::eAcc_wgs:
185  if ( !label.empty() ) {
186  label += " ";
187  }
188  label += "WGS";
189  break;
190 
191  default:
192  break;
193  }
194 
195  return label;
196 }
197 
198 
199 string s_GetDescription(const CSeq_loc& loc, CScope& scope)
200 {
201  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
202  return s_GetDescription(idh, scope);
203 }
204 
205 /////////////////////////////////////////////////////////////////////////////
206 
207 
208 /// Bioseq --> Seq-entry
210  CScope& scope,
211  const CObject& obj,
213  CBasicRelation::TFlags /*flags*/,
214  ICanceled* cancel)
215 {
216  const CBioseq* bs = dynamic_cast<const CBioseq*> (&obj);
217  if (bs) {
219  while (e.GetPointer() && e->GetParentEntry()) {
220  e = e->GetParentEntry();
221  }
222 
224 
225  if ( !e ) {
226  CRef<CSeq_entry> se(new CSeq_entry());
227  se->SetSeq(const_cast<CBioseq&>(*bs));
228  e.Reset(se.GetPointer());
229  }
230  objs.emplace_back(*e);
231  }
232 }
233 
234 /// Bioseq --> Seq-id
236  CScope& scope,
237  const CObject& obj,
239  CBasicRelation::TFlags /*flags*/,
240  ICanceled*)
241 {
242  const CBioseq* bs = dynamic_cast<const CBioseq*> (&obj);
243  if (bs) {
245  if (id) {
246  objs.emplace_back(*id);
247  }
248  }
249 }
250 
251 /// Bioseq-set --> Bioseq
253  CScope& scope,
254  const CObject& obj,
256  CBasicRelation::TFlags /*flags*/,
257  ICanceled* cancel)
258 {
259  const CBioseq_set* bs = dynamic_cast<const CBioseq_set*> (&obj);
260  if (bs) {
261  CTypeConstIterator<CBioseq> iter(*bs);
262  for ( ; iter; ++iter) {
264  const CBioseq& bioseq = *iter;
265  objs.emplace_back(bioseq);
266  }
267  }
268 }
269 
270 /// Bioseq-set --> Seq-entry
272  CScope& scope,
273  const CObject& obj,
275  CBasicRelation::TFlags /*flags*/,
276  ICanceled*)
277 {
278  const CBioseq_set* bs = dynamic_cast<const CBioseq_set*> (&obj);
279  if (bs) {
280  CRef<CSeq_entry> entry(new CSeq_entry());
281  entry->SetSet(const_cast<CBioseq_set&>(*bs));
282  objs.emplace_back(*entry);
283  }
284 }
285 
286 /// Dense-seg --> Seq-align
288  CScope& scope,
289  const CObject& obj,
291  CBasicRelation::TFlags /*flags*/,
292  ICanceled*)
293 {
294  const CDense_seg* ds = dynamic_cast<const CDense_seg*>(&obj);
295  if (ds) {
296  CRef<CSeq_align> aln(new CSeq_align);
297  aln->SetSegs().SetDenseg(const_cast<CDense_seg&>(*ds));
299  objs.emplace_back(*aln);
300  }
301 }
302 
304 {
305  CRef<CSeq_annot> annot(new CSeq_annot());
306  annot->SetData().SetAlign()
307  .push_back(CRef<CSeq_align>(const_cast<CSeq_align*>(&align)));
308  return annot;
309 }
310 
311 /// Seq-align --> Seq-annot
313  CScope& scope,
314  const CObject& obj,
316  CBasicRelation::TFlags /*flags*/,
317  ICanceled*)
318 {
319  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&obj);
320  if (align) {
321  CRef<CSeq_annot> annot(s_Align2Annot(*align));
322  objs.emplace_back(*annot);
323  }
324 }
325 
326 /// Seq-align -> Seq-id
328  CScope& scope,
329  const CObject& obj,
331  CBasicRelation::TFlags /*flags*/,
332  ICanceled* cancel)
333 {
334  const CSeq_align* align = dynamic_cast<const CSeq_align*> (&obj);
335  if (align) {
336  set<CSeq_id_Handle> id_set;
337  CTypeConstIterator<CSeq_id> id_iter(*align);
338  for ( ; id_iter; ++id_iter) {
340  id_set.insert(CSeq_id_Handle::GetHandle(*id_iter));
341  }
342 
343  ITERATE (set<CSeq_id_Handle>, iter, id_set) {
345  objs.emplace_back(*iter->GetSeqId());
346  }
347  }
348 }
349 
350 static void s_Seq_align_Seq_loc(const CSeq_align& align,
351  list< CConstRef<CSeq_loc> >& locs)
352 {
353  switch (align.GetSegs().Which()) {
355  {{
356  const CDense_seg& ds = align.GetSegs().GetDenseg();
357  for (int i = 0; i < ds.GetDim(); ++i) {
358  CConstRef<CSeq_id> id = ds.GetIds()[i];
359 
360  CRef<CSeq_loc> loc(new CSeq_loc());
361  loc->SetInt().SetFrom (ds.GetSeqStart(i));
362  loc->SetInt().SetTo (ds.GetSeqStop(i));
363  if (ds.IsSetStrands()) {
364  loc->SetInt().SetStrand(ds.GetSeqStrand(i));
365  }
366  loc->SetId(*id);
367  locs.push_back(loc);
368  }
369  }}
370  break;
371 
374  s_Seq_align_Seq_loc(**iter, locs);
375  }
376  break;
377 
378  default:
379  {{
380  int rows = 0;
381  try {
382  rows = align.CheckNumRows();
383  for (CSeq_align::TDim row = 0; row < rows; ++row) {
384  // range specific to the alignment
385  CRef<CSeq_loc> loc(new CSeq_loc());
386  CSeq_interval& ival = loc->SetInt();
387  ival.SetId().Assign(align.GetSeq_id(row));
388  ival.SetFrom(align.GetSeqRange(row).GetFrom());
389  ival.SetTo(align.GetSeqRange(row).GetTo());
390  locs.push_back(loc);
391 
392  // range to the whole sequence
393  loc.Reset(new CSeq_loc());
394  loc->SetWhole().Assign(align.GetSeq_id(row));
395  locs.push_back(loc);
396  }
397  } catch (std::exception&) {
398  // check row is not supported, we need to do
399  // something differently
400  }
401  if (rows == 0) {
402  set<CSeq_id_Handle> id_set;
403  CTypeConstIterator<CSeq_id> iter(align);
404  for ( ; iter; ++iter) {
405  id_set.insert(CSeq_id_Handle::GetHandle(*iter));
406  }
407  ITERATE (set<CSeq_id_Handle>, id_iter, id_set) {
408  CRef<CSeq_loc> loc(new CSeq_loc());
409  loc->SetWhole().Assign(*id_iter->GetSeqId());
410  locs.push_back(loc);
411  }
412  }
413  }}
414  break;
415  }
416 }
417 
418 static void s_AddCoalescedLocations(const list< CConstRef<CSeq_loc> >& locs,
419  CScope& scope,
421  ICanceled* cancel)
422 {
423  CScope::TSeq_id_Handles whole_ids;
424  /// step 2: coalesce these where possible
425  typedef map<CSeq_id_Handle, list<TSeqRange> > TIdRanges;
426  TIdRanges id_ranges;
427  ITERATE (list< CConstRef<CSeq_loc> >, iter, locs) {
429  try {
430  const CSeq_loc& loc = **iter;
431  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
432 
434  switch (loc.Which()) {
435  case CSeq_loc::e_Whole:
436  whole_ids.push_back(idh);
437  continue;
438  default:
439  range.SetFrom(sequence::GetStart(loc, &scope));
440  range.SetTo(sequence::GetStop(loc, &scope));
441  break;
442  }
443  id_ranges[idh].push_back(range);
444  }
445  catch (CException&) {
446  }
447  }
448  auto&& id_lens = scope.GetSequenceLengths(whole_ids);
449  _ASSERT(id_lens.size() == whole_ids.size());
450  if (id_lens.size() == whole_ids.size()) {
451  for (size_t i = 0; i < whole_ids.size(); ++i) {
452  id_ranges[whole_ids[i]].push_back(TSeqRange(0, id_lens[i] - 1));
453  }
454  }
455 
456  list< CConstRef<CSeq_loc> > overlocs;
457  ITERATE (TIdRanges, iter, id_ranges) {
459  if (iter->second.size() > 1) {
460  list<TSeqRange>::const_iterator it = iter->second.begin();
461  list<TSeqRange>::const_iterator it_end = iter->second.end();
462  TSeqRange r = *it++;
463  for ( ; it != it_end; ++it) {
464  r += *it;
465  }
466  CRef<CSeq_loc> loc(new CSeq_loc());
467  loc->SetInt().SetFrom(r.GetFrom());
468  loc->SetInt().SetTo (r.GetTo());
469  loc->SetId(*iter->first.GetSeqId());
470  overlocs.push_back(loc);
471  }
472  }
473 
474  ITERATE (list< CConstRef<CSeq_loc> >, iter, overlocs) {
476  objs.push_back(CRelation::SObject(**iter));
477  }
478 }
479 
480 /// Seq-align -> Seq-loc : Basic
482  CScope& scope,
483  const CObject& obj,
485  CBasicRelation::TFlags /*flags*/,
486  ICanceled* cancel)
487 {
488  const CSeq_align* align = dynamic_cast<const CSeq_align*> (&obj);
489  if (align) {
490  list< CConstRef<CSeq_loc> > locs;
491  s_Seq_align_Seq_loc(*align, locs);
492  ITERATE (list< CConstRef<CSeq_loc> >, loc_iter, locs) {
494  objs.emplace_back(**loc_iter);
495  }
496  }
497 }
498 
499 /// Seq-align -> Seq-loc : Coalesced
501  CScope& scope,
502  const CObject& obj,
504  CBasicRelation::TFlags /*flags*/,
505  ICanceled* cancel)
506 {
507  const CSeq_align* align = dynamic_cast<const CSeq_align*> (&obj);
508  if (align) {
509  list< CConstRef<CSeq_loc> > locs;
510  s_Seq_align_Seq_loc(*align, locs);
511  s_AddCoalescedLocations(locs, scope, objs, cancel);
512  }
513 }
514 
515 /*
516 /// Seq-align -> Seq-loc
517 static void Convert_Seq_align_Seq_loc(
518 CScope& scope,
519 const CObject& obj,
520 CBasicRelation::TObjects& objs,
521 CBasicRelation::TFlags flags)
522 {
523 const CSeq_align* align = dynamic_cast<const CSeq_align*> (&obj);
524 if (align) {
525 list< CConstRef<CSeq_loc> > locs;
526 s_Seq_align_Seq_loc(*align, locs);
527 s_AddCoalescedLocations(locs, scope, objs, "total aligned range");
528 
529 ITERATE (list< CConstRef<CSeq_loc> >, loc_iter, locs) {
530 objs.push_back(CRelation::SObject(**loc_iter));
531 }
532 }
533 }
534  */
535 
537 {
538  CRef<CSeq_annot> annot(new CSeq_annot());
539  ITERATE (CSeq_align_set::Tdata, iter, align_set.Get()) {
540  CRef<CSeq_align> ref
541  (const_cast<CSeq_align*>(iter->GetPointer()));
542  annot->SetData().SetAlign().push_back(ref);
543  }
544  return annot;
545 }
546 
547 /// Seq-align-set --> Seq-align
549  CScope& scope,
550  const CObject& obj,
552  CBasicRelation::TFlags /*flags*/,
553  ICanceled* cancel)
554 {
555  const CSeq_align_set* align =
556  dynamic_cast<const CSeq_align_set*>(&obj);
557  if (align) {
558  ITERATE (CSeq_align_set::Tdata, iter, align->Get()) {
560  objs.emplace_back(**iter);
561  }
562  }
563 }
564 
565 /// Seq-align-set -> Seq-loc
567  CScope& scope,
568  const CObject& obj,
570  CBasicRelation::TFlags /*flags*/,
571  ICanceled* cancel)
572 {
573  const CSeq_align_set* align = dynamic_cast<const CSeq_align_set*> (&obj);
574  if (align) {
575  list< CConstRef<CSeq_loc> > locs;
576  ITERATE (CSeq_align_set::Tdata, iter, align->Get()) {
578  s_Seq_align_Seq_loc(**iter, locs);
579  }
580 
581  s_AddCoalescedLocations(locs, scope, objs, cancel);
582  ITERATE (list< CConstRef<CSeq_loc> >, loc_iter, locs) {
584  objs.emplace_back(**loc_iter);
585  }
586  }
587 }
588 
589 /// Seq-align-set --> Seq-annot
591  CScope& scope,
592  const CObject& obj,
594  CBasicRelation::TFlags /*flags*/,
595  ICanceled*)
596 {
597  const CSeq_align_set* align =
598  dynamic_cast<const CSeq_align_set*>(&obj);
599  if (align) {
600  CRef<CSeq_annot> annot(s_AlignSet2Annot(*align));
601  objs.emplace_back(*annot);
602  }
603 }
604 
605 /// Seq-annot --> Seq-align
607  CScope& scope,
608  const CObject& obj,
610  CBasicRelation::TFlags /*flags*/,
611  ICanceled* cancel)
612 {
613  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*>(&obj);
614  if (annot && annot->IsSetData() && annot->GetData().IsAlign()) {
615  ITERATE (CSeq_annot::TData::TAlign, iter, annot->GetData().GetAlign()) {
617  objs.emplace_back(**iter);
618  }
619  }
620 }
621 
622 /// Seq-annot --> Seq-entry
624  CScope& scope,
625  const CObject& obj,
627  CBasicRelation::TFlags /*flags*/,
628  ICanceled*)
629 {
630  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*> (&obj);
631  if (annot) {
632  CRef<CSeq_entry> entry(new CSeq_entry());
633  entry->SetSet().SetSeq_set();
634  entry->SetSet().SetAnnot()
635  .push_back(CRef<CSeq_annot>(const_cast<CSeq_annot*>(annot)));
636  objs.emplace_back(*entry);
637  }
638 }
639 
640 /// Seq-annot --> Seq-feat
642  CScope& scope,
643  const CObject& obj,
645  CBasicRelation::TFlags /*flags*/,
646  ICanceled* cancel)
647 {
648  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*>(&obj);
649  if (annot && annot->IsSetData() && annot->GetData().IsFtable()) {
652  objs.emplace_back(**iter);
653  }
654  }
655 }
656 
657 /// Seq-annot --> Seq-graph
659  CScope& scope,
660  const CObject& obj,
662  CBasicRelation::TFlags /*flags*/,
663  ICanceled* cancel)
664 {
665  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*>(&obj);
666  if (annot && annot->IsSetData() && annot->GetData().IsGraph()) {
667  ITERATE (CSeq_annot::TData::TGraph, iter, annot->GetData().GetGraph()) {
669  objs.emplace_back(**iter);
670  }
671  }
672 }
673 
674 /// Seq-annot --> Seq-id
676  CScope& scope,
677  const CObject& obj,
679  CBasicRelation::TFlags /*flags*/,
680  ICanceled* cancel)
681 {
682  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*> (&obj);
683  if (annot) {
684  set<CSeq_id_Handle> id_set;
685  switch (annot->GetData().Which()) {
687  ITERATE (CSeq_annot::TData::TIds, iter, annot->GetData().GetIds()) {
689  const CSeq_id& id = **iter;
691  if ( !id_set.insert(idh).second ) {
692  /// already in our set
693  continue;
694  }
695  objs.push_back(CRelation::SObject(id));
696  }
697  break;
698 
700  ITERATE (CSeq_annot::TData::TLocs, iter, annot->GetData().GetLocs()) {
702  const CSeq_loc& loc = **iter;
703  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
704  if ( !id_set.insert(idh).second ) {
705  /// already in our set
706  continue;
707  }
708  objs.push_back(CRelation::SObject(*idh.GetSeqId()));
709  }
710  break;
711 
712  default:
713  {{
714  CTypeConstIterator<CSeq_id> id_iter(*annot);
715  for ( ; id_iter; ++id_iter) {
718  if ( !id_set.insert(idh).second ) {
719  /// already in our list
720  continue;
721  }
722  objs.push_back(CRelation::SObject(*id_iter));
723  }
724  }}
725  break;
726  }
727  }
728 }
729 
730 /// Seq-annot --> Seq-loc (total range)
732  CScope& scope,
733  const CObject& obj,
735  CBasicRelation::TFlags /*flags*/,
736  ICanceled* cancel)
737 {
738  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*> (&obj);
739  if (annot) {
740  ///
741  /// step 1: collect all locations
742  ///
744  TRanges ranges;
745  switch (annot->GetData().Which()) {
749 
750  const CSeq_loc& loc = (*iter)->GetLocation();
751  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
752  if (idh) {
753  TSeqRange range = loc.GetTotalRange();
754  ranges[idh] += range;
755  }
756  }
757  break;
758 
760  ITERATE (CSeq_annot::TData::TLocs, iter, annot->GetData().GetLocs()) {
762  const CSeq_loc& loc = **iter;
763  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
764  if ( !idh ) {
765  continue;
766  }
767 
769  switch (loc.Which()) {
770  case CSeq_loc::e_Whole:
771  ///
772  /// special case: skip these
773  /// total range doesn't make sense here
774  ///
775  continue;
776  /**
777  {{
778  CBioseq_Handle bsh = scope.GetBioseqHandle(idh);
779  range.SetTo(bsh.GetBioseqLength());
780  }}
781  break;
782  **/
783 
784  default:
785  range = loc.GetTotalRange();
786  break;
787  }
788  ranges[idh] += range;
789  }
790  break;
791 
793  ///
794  /// special case:
795  /// don't return these; total range doesn't make sense here
796  ///
797  /**
798  {{
799  set<CSeq_id_Handle> ids;
800  ITERATE (CSeq_annot::TData::TIds, iter, annot->GetData().GetIds()) {
801  const CSeq_id& id = **iter;
802  CSeq_id_Handle idh = CSeq_id_Handle::GetHandle(id);
803  if (ids.insert(idh).second == false) {
804  /// already in our set
805  continue;
806  }
807 
808  CRef<CSeq_loc> loc(new CSeq_loc);
809  loc->SetWhole().Assign(id);
810 
811  string s = s_GetDescription(*loc, scope);
812  objs.push_back(CRelation::SObject(*loc, s, "total range"));
813  }
814 
815  }}
816  /// return, not break...
817  **/
818  return;
819 
821  {{
822  ITERATE (CSeq_annot::TData::TAlign, align_iter, annot->GetData().GetAlign()) {
824  list< CConstRef<CSeq_loc> > locs;
825  s_Seq_align_Seq_loc(**align_iter, locs);
826  ITERATE (list< CConstRef<CSeq_loc> >, iter, locs) {
827  const CSeq_loc& loc = **iter;
828  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
829  TSeqRange range = loc.GetTotalRange();
830  ranges[idh] += range;
831  }
832  }
833  }}
834  break;
835 
837  {{
838  ITERATE (CSeq_annot::TData::TGraph, graph_iter, annot->GetData().GetGraph()) {
840  const CSeq_loc& loc = (*graph_iter)->GetLoc();
841  CSeq_id_Handle idh = sequence::GetIdHandle(loc, &scope);
842  TSeqRange range = loc.GetTotalRange();
843  ranges[idh] += range;
844  }
845  }}
846  break;
847  default:
848  {{
849  CTypeConstIterator<CSeq_id> id_iter(*annot);
850  for ( ; id_iter; ++id_iter) {
853  if (idh) {
854  ranges[idh] = TSeqRange::GetWhole();
855  }
856  }
857  }}
858  break;
859  }
860 
861  // step 2: create new locations
862  //
863  string s;
864  ITERATE (TRanges, iter, ranges) {
866  CRef<CSeq_loc> loc(new CSeq_loc);
867  if (iter->second.IsWhole()) {
868  loc->SetWhole().Assign(*iter->first.GetSeqId());
869  } else {
870  loc->SetInt().SetFrom(iter->second.GetFrom());
871  loc->SetInt().SetTo (iter->second.GetTo());
872  loc->SetId(*iter->first.GetSeqId());
873  }
874 
875  objs.emplace_back(*loc, "total range");
876  }
877  }
878 }
879 
880 /// Seq-annot --> Seq-loc (all locs)
882  CScope& scope,
883  const CObject& obj,
885  CBasicRelation::TFlags /*flags*/,
886  ICanceled* cancel)
887 {
888  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*> (&obj);
889  if (annot) {
890  ///
891  /// step 1: collect all locations
892  ///
893  switch (annot->GetData().Which()) {
897  const CSeq_loc& loc = (*iter)->GetLocation();
898 
899  string comm = s_GetDescription(loc, scope);
900  objs.emplace_back(loc, comm);
901  }
902  break;
903 
905  ITERATE (CSeq_annot::TData::TIds, iter, annot->GetData().GetIds()) {
907  const CSeq_id& id = **iter;
909 
910  CRef<CSeq_loc> loc(new CSeq_loc);
911  loc->SetWhole().Assign(id);
912 
913  objs.push_back(CRelation::SObject(*loc));
914  }
915  break;
916 
918  ITERATE (CSeq_annot::TData::TLocs, iter, annot->GetData().GetLocs()) {
920  const CSeq_loc& loc = **iter;
921  objs.push_back(CRelation::SObject(loc));
922  }
923  break;
924 
926  {{
927  ITERATE (CSeq_annot::TData::TAlign, align_iter, annot->GetData().GetAlign()) {
929  list< CConstRef<CSeq_loc> > locs;
930  s_Seq_align_Seq_loc(**align_iter, locs);
931  ITERATE (list< CConstRef<CSeq_loc> >, iter, locs) {
933  objs.push_back(CRelation::SObject(**iter));
934  }
935  }
936  }}
937  break;
938 
939  default:
940  {{
941  set<CSeq_id_Handle> id_set;
942  CTypeConstIterator<CSeq_id> id_iter(*annot);
943  for ( ; id_iter; ++id_iter) {
946  CConstRef<CSeq_id> seq_id = idh.GetSeqIdOrNull();
947  if (!seq_id.IsNull() && id_set.insert(idh).second) {
948  CRef<CSeq_loc> loc(new CSeq_loc());
949  loc->SetWhole().Assign(*idh.GetSeqId());
950  objs.push_back(CRelation::SObject(*loc));
951  }
952  }
953  }}
954  break;
955  }
956  }
957 }
958 
959 /// Seq-entry --> Bioseq
961  CScope& scope,
962  const CObject& obj,
964  CBasicRelation::TFlags /*flags*/,
965  ICanceled* cancel)
966 {
967  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
968  if (entry) {
969  CTypeConstIterator<CBioseq> iter(*entry);
970  for ( ; iter; ++iter) {
972  objs.emplace_back(*iter);
973  }
974  }
975 }
976 
977 /// Seq-entry --> Bioseq-set
979  CScope& scope,
980  const CObject& obj,
982  CBasicRelation::TFlags /*flags*/,
983  ICanceled*)
984 {
985  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
986  if (entry) {
987  if (entry->IsSet()) {
988  objs.emplace_back(entry->GetSet());
989  }
990  else {
991  CRef<CBioseq_set> bs_set(new CBioseq_set());
992  CRef<CSeq_entry> ref(const_cast<CSeq_entry*>(entry));
993  bs_set->SetSeq_set().push_back(ref);
994  objs.emplace_back(*bs_set);
995  }
996  }
997 }
998 
999 /// Seq-entry --> Seq-loc
1001  CScope& scope,
1002  const CObject& obj,
1004  CBasicRelation::TFlags /*flags*/,
1005  ICanceled* cancel)
1006 {
1007  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
1008  if (entry) {
1009  CTypeConstIterator<CBioseq> iter(*entry);
1010  for ( ; iter; ++iter) {
1012  CConstRef<CSeq_id> best_id =
1013  FindBestChoice(iter->GetId(), CSeq_id::BestRank);
1014  if (best_id) {
1015  CRef<CSeq_loc> loc(new CSeq_loc());
1016  loc->SetWhole().Assign(*best_id);
1017 
1018  objs.emplace_back(*loc);
1019  }
1020  }
1021  }
1022 }
1023 
1024 /// Seq-entry --> Seq-id
1026  CScope& scope,
1027  const CObject& obj,
1029  CBasicRelation::TFlags /*flags*/,
1030  ICanceled* cancel)
1031 {
1032  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
1033  if (entry) {
1034  CTypeConstIterator<CBioseq> iter(*entry);
1035  for ( ; iter; ++iter) {
1037  CConstRef<CSeq_id> best_id =
1038  FindBestChoice(iter->GetId(), CSeq_id::BestRank);
1039  if (best_id) {
1040  CSeq_id_Handle idh = CSeq_id_Handle::GetHandle(*best_id);
1041  objs.emplace_back(*best_id);
1042  }
1043  }
1044  }
1045 }
1046 
1047 /// Seq-entry --> Seq-submit
1049  CScope& scope,
1050  const CObject& obj,
1052  CBasicRelation::TFlags /*flags*/,
1053  ICanceled*)
1054 {
1055  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
1056  if (entry) {
1057  CRef<CSeq_submit> sub(new CSeq_submit());
1058  sub->SetData().SetEntrys().push_back
1059  (CRef<CSeq_entry>(const_cast<CSeq_entry*>(entry)));
1060  objs.emplace_back(*sub);
1061  }
1062 }
1063 
1064 /// Seq-entry --> Seq-annot
1066  CScope& scope,
1067  const CObject& obj,
1069  CBasicRelation::TFlags /*flags*/,
1070  ICanceled* cancel)
1071 {
1072  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
1073  if (entry) {
1074  CTypeConstIterator<CBioseq> iter(*entry);
1075  for ( ; iter; ++iter) {
1077  CBioseq_Handle handle = scope.GetBioseqHandle(*iter);
1078  if (handle) {
1079  CSeq_annot_CI annot_iter(handle);
1080  for ( ; annot_iter; ++annot_iter) {
1081  CConstRef<CSeq_annot> annot = annot_iter->GetCompleteSeq_annot();
1083  objs.emplace_back(*annot);
1084  }
1085  }
1086  }
1087  }
1088 }
1089 
1090 /// Seq-entry --> Seq-align
1092  CScope& scope,
1093  const CObject& obj,
1095  CBasicRelation::TFlags /*flags*/,
1096  ICanceled* cancel)
1097 {
1098  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
1099  if (entry) {
1100  CTypeConstIterator<CBioseq> iter(*entry);
1101  for ( ; iter; ++iter) {
1103  CBioseq_Handle handle = scope.GetBioseqHandle(*iter);
1104  if (handle) {
1105  CAlign_CI align_iter(handle);
1106  for ( ; align_iter; ++align_iter) {
1107  CConstRef<CSeq_align> align(&*align_iter);
1109  objs.emplace_back(*align);
1110  }
1111  }
1112  }
1113  }
1114 }
1115 
1116 /**
1117 /// Seq-feat --> Seq-id
1118 static void Convert_Seq_feat_Seq_id(
1119 CScope& scope,
1120 const CObject& obj,
1121 CBasicRelation::TObjects& objs,
1122 CBasicRelation::TFlags flags)
1123 {
1124 const CSeq_feat* feat = dynamic_cast<const CSeq_feat*> (&obj);
1125 if (feat) {
1126 try {
1127 const CSeq_id& id = sequence::GetId(feat->GetLocation(),
1128 &scope);
1129 objs.push_back(CRelation::SObject(id));
1130 }
1131 catch (...) {
1132 }
1133 
1134 if (feat->IsSetProduct()) {
1135 try {
1136 const CSeq_id& id = sequence::GetId(feat->GetProduct(),
1137 &scope);
1138 objs.push_back(CRelation::SObject(id));
1139 }
1140 catch (...) {
1141 }
1142 }
1143 
1144 // deal with dbxrefs
1145 if (feat->IsSetDbxref()) {
1146 ITERATE (CSeq_feat::TDbxref, iter, feat->GetDbxref()) {
1147 const CDbtag& dbtag = **iter;
1148 
1149 CRef<CSeq_id> id(new CSeq_id);
1150 try {
1151 id->Set(dbtag, false);
1152 objs.push_back(CRelation::SObject(*id));
1153 }
1154 catch (CSeqIdException&) {
1155 }
1156 }
1157 }
1158 }
1159 }
1160  **/
1161 
1162 /// Seq-feat --> Seq-loc : Genomic Location
1164  CScope& scope,
1165  const CObject& obj,
1167  CBasicRelation::TFlags /*flags*/,
1168  ICanceled*)
1169 {
1170  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
1171  if ( !feat ) {
1172  return;
1173  }
1174 
1175  string comm = s_GetDescription(feat->GetLocation(), scope);
1176  objs.emplace_back(feat->GetLocation(), comm);
1177 }
1178 
1179 /// Seq-feat --> Seq-loc : Genomic Location (total range)
1181  CScope& scope,
1182  const CObject& obj,
1184  CBasicRelation::TFlags /*flags*/,
1185  ICanceled*)
1186 {
1187  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
1188  if ( !feat ) {
1189  return;
1190  }
1191 
1192  const CSeq_loc& orig_loc = feat->GetLocation();
1193  if ( !orig_loc.IsInt() && !orig_loc.IsWhole() &&
1194  (!orig_loc.IsPacked_int() || orig_loc.GetPacked_int().Get().size() > 1)) {
1195  /// compose a location for the total range
1196  /// do this only for locations that are not already just a single interval
1197  try {
1198  CRef<CSeq_loc> loc(new CSeq_loc);
1199  loc->SetInt().SetFrom(feat->GetLocation().GetTotalRange().GetFrom());
1200  loc->SetInt().SetTo (feat->GetLocation().GetTotalRange().GetTo());
1201  ENa_strand strand = sequence::GetStrand(feat->GetLocation(), &scope);
1202  if (strand == eNa_strand_plus || strand == eNa_strand_minus) {
1203  loc->SetStrand(strand);
1204  }
1205  CSeq_id_Handle idh = sequence::GetIdHandle(feat->GetLocation(), &scope);
1206  loc->SetId(*idh.GetSeqId());
1207 
1208  string comm = s_GetDescription(*loc, scope);
1209  comm += " (total range)";
1210  objs.emplace_back(*loc, comm);
1211  } catch (std::exception&) {
1212  // it is very likely we got multiple seq-ids loc, discard this one.
1213  }
1214  }
1215 }
1216 
1217 /// Seq-feat --> Seq-loc : Product Location
1219  CScope& scope,
1220  const CObject& obj,
1222  CBasicRelation::TFlags /*flags*/,
1223  ICanceled*)
1224 {
1225  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
1226  if ( !feat ) {
1227  return;
1228  }
1229 
1230  if (feat->IsSetProduct()) {
1231  string comm = s_GetDescription(feat->GetProduct(), scope);
1232  comm += " (product)";
1233  objs.emplace_back(feat->GetProduct(), comm);
1234  }
1235 }
1236 
1237 /// Seq-feat --> Seq-loc : dbxrefs Location
1239  CScope& scope,
1240  const CObject& obj,
1243  ICanceled*)
1244 {
1245  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
1246  if ( !feat ) {
1247  return;
1248  }
1249 
1250  if (flags & CBasicRelation::fConvert_All && feat->IsSetDbxref()) {
1251  ITERATE (CSeq_feat::TDbxref, iter, feat->GetDbxref()) {
1252  try {
1253  const CDbtag& dbtag = **iter;
1254  CRef<CSeq_id> id(new CSeq_id);
1255  id->Set(dbtag, false);
1256  CRef<CSeq_loc> loc(new CSeq_loc());
1257  loc->SetWhole(*id);
1258 
1259  objs.emplace_back(*loc);
1260  }
1261  catch (CSeqIdException&) {
1262  }
1263  }
1264  }
1265 }
1266 
1267 
1268 /// Seq-id --> Bioseq: use CBioseq_Handle
1270  CScope& scope,
1271  const CObject& obj,
1274  ICanceled*)
1275 {
1276  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
1277  if (id) {
1278  // retrieve our handle from the scope and proceed
1279  CBioseq_Handle handle = scope.GetBioseqHandle(*id);
1280  if (handle) {
1281  CConstRef<CBioseq> bioseq;
1283  bioseq = handle.GetBioseqCore();
1284  } else {
1285  bioseq = handle.GetCompleteBioseq();
1286  }
1287  objs.emplace_back(*bioseq);
1288  }
1289  }
1290 }
1291 
1292 /// Seq-id --> Bioseq-set: use CBioseq_Handle
1294  CScope& scope,
1295  const CObject& obj,
1297  CBasicRelation::TFlags /*flags*/,
1298  ICanceled*)
1299 {
1300  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
1301  if (id) {
1302  // retrieve our handle from the scope and proceed
1303  CBioseq_Handle handle = scope.GetBioseqHandle(*id);
1304  if (handle) {
1305  CConstRef<CSeq_entry> entry =
1307  if (entry.GetPointer() && entry->IsSet()) {
1308  objs.push_back(CRelation::SObject(entry->GetSet()));
1309  }
1310  }
1311  }
1312 }
1313 
1314 /// Seq-id --> Seq-entry: use CBioseq_Handle
1316  CScope& scope,
1317  const CObject& obj,
1319  CBasicRelation::TFlags /*flags*/,
1320  ICanceled*)
1321 {
1322  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
1323  if (id) {
1324  // retrieve our handle from the scope and proceed
1325  CBioseq_Handle handle = scope.GetBioseqHandle(*id);
1326  if (handle) {
1327  CConstRef<CSeq_entry> entry =
1329  objs.push_back(CRelation::SObject(*entry));
1330  }
1331  }
1332 }
1333 
1334 /// Seq-id --> Seq-loc: use Seq-loc.whole representation
1336  CScope& scope,
1337  const CObject& obj,
1339  CBasicRelation::TFlags /*flags*/,
1340  ICanceled*)
1341 {
1342  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
1343  if (id) {
1344  CRef<CSeq_loc> loc(new CSeq_loc());
1345  loc->SetWhole().Assign(*id);
1346  objs.push_back(CRelation::SObject(*loc, "whole sequence"));
1347  }
1348 }
1349 
1350 /// Seq-loc --> Seq-align: use CFeat_CI
1352  CScope& scope,
1353  const CObject& obj,
1355  CBasicRelation::TFlags /*flags*/,
1356  ICanceled*)
1357 {
1358  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
1359  if (loc) {
1361  CAlign_CI iter(scope, *loc, sel);
1362  for (; iter; ++iter) {
1363  const CSeq_align& align = iter.GetOriginalSeq_align();
1364  objs.push_back(CRelation::SObject(align));
1365  }
1366  }
1367 }
1368 
1369 /// Seq-loc --> Seq-annot
1371  CScope& scope,
1372  const CObject& obj,
1374  CBasicRelation::TFlags /*flags*/,
1375  ICanceled*)
1376 {
1377  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
1378  if (loc) {
1380  CAnnot_CI iter(scope, *loc, sel);
1381  for (; iter; ++iter) {
1382  const CSeq_annot& annot = *iter->GetCompleteSeq_annot();
1383  objs.push_back(CRelation::SObject(annot));
1384  }
1385  }
1386 }
1387 
1388 /// Seq-loc --> Seq-feat: use CFeat_CI
1390  CScope& scope,
1391  const CObject& obj,
1393  CBasicRelation::TFlags /*flags*/,
1394  ICanceled*)
1395 {
1396  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
1397  if (loc) {
1399  CFeat_CI iter(scope, *loc, sel);
1400  for (; iter; ++iter) {
1401  const CSeq_feat& feat = iter->GetOriginalFeature();
1402  objs.push_back(CRelation::SObject(feat));
1403  }
1404  }
1405 }
1406 
1407 /// Seq-loc --> Seq-geaph: use CGraph_CI
1409  CScope& scope,
1410  const CObject& obj,
1412  CBasicRelation::TFlags /*flags*/,
1413  ICanceled*)
1414 {
1415  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
1416  if (loc) {
1418  CGraph_CI iter(scope, *loc, sel);
1419  for (; iter; ++iter) {
1420  const CSeq_graph& graph = iter->GetOriginalGraph();
1421  objs.push_back(CRelation::SObject(graph));
1422  }
1423  }
1424 }
1425 
1426 /// Seq-loc --> Seq-id: use sequence::GetId()
1428  CScope& scope,
1429  const CObject& obj,
1432  ICanceled*)
1433 {
1434  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
1435  if (loc) {
1436  try {
1437  CScope* s = &scope;
1439  s = NULL;
1440  }
1441  CSeq_id_Handle id = sequence::GetIdHandle(*loc, s);
1442  objs.push_back(CRelation::SObject(*id.GetSeqId()));
1443  }
1444  catch (std::exception&) {
1445  }
1446  }
1447 }
1448 
1449 /// Seq-submit --> Seq-annot
1451  CScope& scope,
1452  const CObject& obj,
1454  CBasicRelation::TFlags /*flags*/,
1455  ICanceled*)
1456 {
1457  const CSeq_submit* sub = dynamic_cast<const CSeq_submit*> (&obj);
1458  if (sub) {
1459  CTypeConstIterator<CSeq_annot> annot_iter(*sub);
1460  for ( ; annot_iter; ++annot_iter) {
1461  objs.push_back(CRelation::SObject(*annot_iter));
1462  }
1463  }
1464 }
1465 
1466 /// Seq-submit --> Seq-entry
1468  CScope& scope,
1469  const CObject& obj,
1471  CBasicRelation::TFlags /*flags*/,
1472  ICanceled*)
1473 {
1474  const CSeq_submit* sub = dynamic_cast<const CSeq_submit*> (&obj);
1475  if (sub && sub->GetData().IsEntrys()) {
1477  sub->GetData().GetEntrys()) {
1478  objs.push_back(CRelation::SObject(**iter));
1479  }
1480  }
1481 }
1482 
1483 /// Seq-submit --> Seq-id
1485  CScope& scope,
1486  const CObject& obj,
1488  CBasicRelation::TFlags /*flags*/,
1489  ICanceled* cancel)
1490 {
1491  const CSeq_submit* sub = dynamic_cast<const CSeq_submit*> (&obj);
1492  if (sub && sub->GetData().IsEntrys()) {
1493  CTypeConstIterator<CBioseq> iter(*sub);
1494  for ( ; iter; ++iter) {
1496  const CRef<CSeq_id>& id =
1497  FindBestChoice(iter->GetId(), CSeq_id::BestRank);
1498 
1499  objs.emplace_back(*id);
1500  }
1501  }
1502 }
1503 
1504 /// Object --> SerialObject
1506  CScope& scope,
1507  const CObject& obj,
1509  CBasicRelation::TFlags /*flags*/,
1510  ICanceled*)
1511 {
1512  const CSerialObject* cso = dynamic_cast<const CSerialObject*> (&obj);
1513  if (cso) {
1514  objs.emplace_back(*cso);
1515  }
1516 }
1517 
1518 /// *******************************************************************
1519 /// Moved from plugins/algo/init
1520 /// *******************************************************************
1521 
1522 enum EGCFlags {
1523  fGC_Seqs = 0x01,
1527 };
1528 typedef int TGCFlags;
1529 
1533 {
1534  string comment;
1535  switch (gc.GetType()) {
1537  comment = "Genomic location";
1538  break;
1539 
1541  comment = "mRNA sequence";
1542  break;
1543 
1545  comment = "rRNA sequence";
1546  break;
1547 
1549  comment = "tRNA sequence";
1550  break;
1551 
1553  comment = "Protein sequence";
1554  break;
1555 
1556  default:
1557  break;
1558  }
1559 
1560  if (gc.IsSetGenomic_coords() && (flags & fGC_GenomicCoords)) {
1562  objs.emplace_back(**iter, comment);
1563  }
1564  }
1565 
1566  if (gc.IsSetSeqs() && (flags & fGC_Seqs)) {
1567  ITERATE (CGene_commentary::TSeqs, iter, gc.GetSeqs()) {
1568  objs.emplace_back(**iter, comment);
1569  }
1570  }
1571 
1572  if (flags & fGC_Recursive) {
1573  if (gc.IsSetProducts()) {
1575  s_GeneCommentaryToLocations(**iter, objs, flags);
1576  }
1577  }
1578  if (gc.IsSetProperties()) {
1580  s_GeneCommentaryToLocations(**iter, objs, flags);
1581  }
1582  }
1583  if (gc.IsSetComment()) {
1585  s_GeneCommentaryToLocations(**iter, objs, flags);
1586  }
1587  }
1588  }
1589 }
1590 
1591 
1592 /// Entrezgene --> Seq-loc
1594  const CObject& obj,
1596  CBasicRelation::TFlags /*flags*/,
1597  ICanceled* cancel)
1598 {
1599  const CEntrezgene* egene = dynamic_cast<const CEntrezgene*> (&obj);
1600  if (egene && egene->IsSetLocus()) {
1601  ITERATE (CEntrezgene::TLocus, loc_iter, egene->GetLocus()) {
1603  const CGene_commentary& gc = **loc_iter;
1604  s_GeneCommentaryToLocations(gc, objs);
1605  }
1606  }
1607 }
1608 
1609 
1611  const CObject& obj,
1613  CBasicRelation::TFlags /*flags*/,
1614  ICanceled* cancel)
1615 {
1616  const CEntrezgene* egene = dynamic_cast<const CEntrezgene*> (&obj);
1617  if (egene && egene->IsSetLocus()) {
1618  /// retrieve all possible locations
1620  ITERATE (CEntrezgene::TLocus, loc_iter, egene->GetLocus()) {
1622  const CGene_commentary& gc = **loc_iter;
1623 
1624  if (gc.IsSetProducts()) {
1625  ITERATE (CGene_commentary::TProducts, iter, gc.GetProducts()) {
1627  fGC_Seqs);
1628  if ((*iter)->IsSetProducts()) {
1629  ITERATE (CGene_commentary::TProducts, it, (*iter)->GetProducts()) {
1631  }
1632  }
1633  }
1634  }
1635  }
1636 
1637  /// now, uniquify these
1638  set<CSeq_id_Handle> ids;
1641  const CSeq_loc& loc = dynamic_cast<const CSeq_loc&>(iter->GetObject());
1642  CSeq_id_Handle sih = sequence::GetIdHandle(loc, &scope);
1643  if (ids.insert(sih).second) {
1644  objs.push_back(*iter);
1645  }
1646  }
1647  }
1648 }
1649 
1650 
1652  const CObject& obj,
1654  CBasicRelation::TFlags /*flags*/,
1655  ICanceled* cancel)
1656 {
1657  const CEntrezgene* egene = dynamic_cast<const CEntrezgene*> (&obj);
1658  if (egene && egene->IsSetComments()) {
1659  ITERATE (CEntrezgene::TComments, iter, egene->GetComments()) {
1661  const CGene_commentary& gc = **iter;
1662  if ( !gc.IsSetHeading() || gc.GetHeading() != "Related Sequences" ) {
1663  continue;
1664  }
1665  s_GeneCommentaryToLocations(gc, objs);
1666 
1667  if (gc.IsSetProducts()) {
1668  ITERATE (CGene_commentary::TProducts, pit, gc.GetProducts()) {
1669  s_GeneCommentaryToLocations(**pit, objs);
1670  }
1671  }
1672  }
1673  }
1674 }
1675 
1676 
1678  const CObject& obj,
1680  CBasicRelation::TFlags /*flags*/,
1681  ICanceled* cancel)
1682 {
1683  const CEntrezgene* egene = dynamic_cast<const CEntrezgene*> (&obj);
1684  if (egene && egene->IsSetComments()) {
1685  ITERATE (CEntrezgene::TComments, iter, egene->GetComments()) {
1687  const CGene_commentary& gc = **iter;
1688  string heading;
1689  if (gc.IsSetHeading()) {
1690  heading = gc.GetHeading();
1691  }
1692 
1693  if ( !gc.IsSetHeading() || gc.GetHeading().find("RefSeq") == string::npos ) {
1694  continue;
1695  }
1697  }
1698  }
1699 }
1700 
1701 
1702 /// Entrezgene --> Seq-loc
1704  const CObject& obj,
1706  CBasicRelation::TFlags /*flags*/,
1707  ICanceled* cancel)
1708 {
1709  const CEntrezgene_Set* gene_set = dynamic_cast<const CEntrezgene_Set*> (&obj);
1710  if (gene_set) {
1711  ITERATE (CEntrezgene_Set::Tdata, iter, gene_set->Get()) {
1713  objs.emplace_back(**iter);
1714  }
1715  }
1716 }
1717 
1718 
1719 /// GC-Assembly --> Seq-id
1721  const CObject& obj,
1723  CBasicRelation::TFlags /*flags*/,
1724  ICanceled* cancel)
1725 {
1726  const CGC_Assembly* assm = dynamic_cast<const CGC_Assembly*>(&obj);
1727  if (assm) {
1728  vector< CConstRef<CGC_Sequence> > seqs;
1729 
1731 
1732  CGC_Assembly::TSequenceList chromosomes;
1733  assm->GetMolecules(chromosomes, CGC_Assembly::eChromosome);
1734 
1736 
1737  CGC_Assembly::TSequenceList top_level_seqs;
1738  assm->GetMolecules(top_level_seqs, CGC_Assembly::eTopLevel);
1739 
1741 
1742  set< CConstRef<CGC_Sequence> > unique_seqs;
1743  ITERATE(CGC_Assembly::TSequenceList, it, chromosomes) {
1744  if (unique_seqs.insert(*it).second) {
1745  seqs.push_back(*it);
1746  }
1747  }
1749 
1750  ITERATE(CGC_Assembly::TSequenceList, it, top_level_seqs) {
1751  if (unique_seqs.insert(*it).second) {
1752  seqs.push_back(*it);
1753  }
1754  }
1756 
1757  const CGC_AssemblyDesc& desc = assm->GetDesc();
1758  string organism;
1759  if (desc.IsSetDescr()) {
1760  ITERATE (CGC_AssemblyDesc::TDescr::Tdata, it, desc.GetDescr().Get()) {
1761  if ((*it)->IsSource() && (*it)->GetSource().IsSetTaxname()) {
1762  organism = (*it)->GetSource().GetTaxname();
1763  break;
1764  }
1765  }
1766  }
1767 
1768  string assm_name = assm->GetName();
1769 
1770  CBasicRelation::TObjects gb_objs;
1771  ITERATE (vector< CConstRef<CGC_Sequence> >, iter, seqs) {
1773  CConstRef<CSeq_id> best_id =
1774  (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Refseq, CGC_SeqIdAlias::e_Public);
1775 
1776  string chr_num = kEmptyStr;
1777  if ((*iter)->GetReplicon() && (*iter)->GetReplicon()->CanGetName()) {
1778  chr_num = (*iter)->GetReplicon()->GetName();
1779  }
1780  string chr_prefix;
1781  if ( !chr_num.empty() && chr_num.find("chr") == string::npos) {
1782  chr_prefix = "chr";
1783  }
1784 
1785 
1786  string extra_info;
1787  bool patch_type = false;
1788  if ((*iter)->CanGetPatch_type()) {
1789  if ((*iter)->GetPatch_type() == CGC_Sequence::ePatch_type_fix) {
1790  extra_info = "fix patch";
1791  patch_type = true;
1792  } else if ((*iter)->GetPatch_type() == CGC_Sequence::ePatch_type_novel) {
1793  extra_info = "novel patch";
1794  patch_type = true;
1795  }
1796  }
1797  if ((*iter)->GetParentRelation() == CGC_TaggedSequences::eState_aligned) {
1798  if ( !extra_info.empty() ) {
1799  extra_info += ", ";
1800  }
1801  if (patch_type) {
1802  extra_info += "aligned";
1803  }
1804  else {
1805  extra_info += "alt Locus";
1806  }
1807  }
1808 
1809  if ( !extra_info.empty() ) {
1810  if ( !chr_num.empty() ) {
1811  extra_info = " (" + extra_info + ")";
1812  }
1813  }
1814 
1815  string status;
1816  switch ((*iter)->GetParentRelation()) {
1818  status = "unlocalized";
1819  break;
1821  status = "unplaced";
1822  break;
1824  status = "aligned";
1825  break;
1826  default:
1827  break;
1828  }
1829 
1830  string role;
1831  if ((*iter)->CanGetRoles()) {
1832  ITERATE(CGC_Sequence::TRoles, r_iter, (*iter)->GetRoles()) {
1833  switch(*r_iter) {
1835  role = "chromosome";
1836  break;
1838  role = "component";
1839  break;
1843  role = "scaffold";
1844  break;
1845  default:
1846  break;
1847  }
1848  if ( !role.empty() ) {
1849  break;
1850  }
1851  }
1852  }
1853 
1854  string descr;
1855  if ( !organism.empty() ) {
1856  descr += organism + " ";
1857  }
1858  if (NStr::EqualNocase(chr_num, "mt")) {
1859  descr += "mitochondrion";
1860  } else if (NStr::EqualNocase(chr_num, "pltd")) {
1861  descr += "chloroplast";
1862  } else if ( !chr_num.empty() ) {
1863  descr += "chromosome " + chr_num;
1864  }
1865  if (role == "scaffold") {
1866  if (status == "unplaced" || status == "unlocalized") {
1867  descr += " " + status;
1868  }
1869  descr += " " + role + ", ";
1870  } else {
1871  descr += ", ";
1872  }
1873 
1874  descr += assm_name;
1875  if (status == "aligned") {
1876  descr += " alternate locus";
1877  }
1878 
1879  if (best_id) {
1880  CConstRef<CSeq_id> id_gi =
1881  (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Refseq, CGC_SeqIdAlias::e_Gi);
1882  objs.emplace_back(*best_id, chr_prefix + chr_num + extra_info);
1883  }
1884 
1885  CConstRef<CSeq_id> gb_id =
1886  (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Genbank, CGC_SeqIdAlias::e_Public);
1887  if (gb_id) {
1888  CConstRef<CSeq_id> id_gi =
1889  (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Genbank, CGC_SeqIdAlias::e_Gi);
1890  gb_objs.emplace_back(*gb_id, chr_prefix + chr_num + extra_info);
1891  }
1892  }
1893  std::move(gb_objs.begin(), gb_objs.end(), std::back_inserter(objs));
1894  }
1895 }
1896 
1897 
1898 /// GC-Assembly --> Seq-loc
1899 
1900 static void s_GCSeqsToSeqLocs(const CGC_Assembly& assm, const vector< CConstRef<CGC_Sequence> >& gcSeqs, CBasicRelation::TObjects& seqLocs, ICanceled* cancel)
1901 {
1902  bool is_refseq = assm.IsRefSeq();
1903  ITERATE(vector< CConstRef<CGC_Sequence> >, iter, gcSeqs) {
1905  CConstRef<CSeq_id> seq_id;
1906  if (is_refseq) {
1907  seq_id = (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Refseq, CGC_SeqIdAlias::e_Public);
1908  }
1909  else {
1910  seq_id = (*iter)->GetSynonymSeq_id(CGC_TypedSeqId::e_Genbank, CGC_SeqIdAlias::e_Public);
1911  }
1912 
1913  string chr_num = kEmptyStr;
1914  if ((*iter)->GetReplicon() && (*iter)->GetReplicon()->CanGetName()) {
1915  chr_num = (*iter)->GetReplicon()->GetName();
1916  }
1917  if (!chr_num.empty() && chr_num.find("chr") == string::npos) {
1918  chr_num = "chr" + chr_num;
1919  }
1920 
1921  string extra_info;
1922  bool patch_type = false;
1923  if ((*iter)->CanGetPatch_type()) {
1924  if ((*iter)->GetPatch_type() == CGC_Sequence::ePatch_type_fix) {
1925  extra_info = "fix patch";
1926  patch_type = true;
1927  }
1928  else if ((*iter)->GetPatch_type() == CGC_Sequence::ePatch_type_novel) {
1929  extra_info = "novel patch";
1930  patch_type = true;
1931  }
1932  }
1933  if ((*iter)->GetParentRelation() == CGC_TaggedSequences::eState_aligned) {
1934  if (!extra_info.empty()) {
1935  extra_info += ", ";
1936  }
1937  if (patch_type) {
1938  extra_info += "aligned";
1939  }
1940  else {
1941  extra_info += "alt Locus";
1942  }
1943  }
1944 
1945  if (!extra_info.empty()) {
1946  if (!chr_num.empty()) {
1947  chr_num += " (" + extra_info + ")";
1948  }
1949  else {
1950  chr_num = extra_info;
1951  }
1952  }
1953 
1954  if (seq_id) {
1955  CRef<CSeq_loc> loc(new CSeq_loc());
1956  loc->SetWhole().Assign(*seq_id);
1957  seqLocs.push_back(CRelation::SObject(*loc, chr_num));
1958  }
1959  }
1960 }
1961 
1963  const CObject& obj,
1965  CBasicRelation::TFlags /*flags*/,
1966  ICanceled* cancel)
1967 {
1968  const CGC_Assembly* assm = dynamic_cast<const CGC_Assembly*>(&obj);
1969  if (assm) {
1970  CGC_Assembly::TSequenceList chromosomes;
1971  assm->GetMolecules(chromosomes, CGC_Assembly::eChromosome);
1972  vector< CConstRef<CGC_Sequence> > seqs(chromosomes.begin(), chromosomes.end());
1974  s_GCSeqsToSeqLocs(*assm, seqs, objs, cancel);
1975  }
1976 }
1977 
1979  const CObject& obj,
1981  CBasicRelation::TFlags /*flags*/,
1982  ICanceled* cancel)
1983 {
1984  const CGC_Assembly* assm = dynamic_cast<const CGC_Assembly*>(&obj);
1985  if (assm) {
1986  CGC_Assembly::TSequenceList chromosomes;
1987  assm->GetMolecules(chromosomes, CGC_Assembly::eChromosome);
1989 
1990  CGC_Assembly::TSequenceList top_level_seqs;
1991  assm->GetMolecules(top_level_seqs, CGC_Assembly::eTopLevel);
1993 
1994  set< CConstRef<CGC_Sequence> > unique_seqs(chromosomes.begin(), chromosomes.end());
1995  vector<CConstRef<CGC_Sequence> > seqs;
1996  for (auto i : top_level_seqs) {
1997  if (unique_seqs.insert(i).second)
1998  seqs.push_back(i);
1999  }
2000 
2002  s_GCSeqsToSeqLocs(*assm, seqs, objs, cancel);
2003  }
2004 }
2005 
2006 /// BioTreeContainer --> Seq-id
2008  const CObject& obj,
2010  CBasicRelation::TFlags /*flags*/,
2011  ICanceled* cancel)
2012 {
2013  const CBioTreeContainer* biotree = dynamic_cast<const CBioTreeContainer*>(&obj);
2014  if (biotree) {
2016 
2017  int seq_id_idx = -1;
2018  const CFeatureDictSet::Tdata& fdict = biotree->GetFdict().Get();
2019  ITERATE(CFeatureDictSet::Tdata, it, fdict) {
2020  if (NStr::EqualNocase((*it)->GetName(), "seq-id")) {
2021  seq_id_idx = (*it)->GetId();
2022  break;
2023  }
2024  }
2025 
2026  if (seq_id_idx < 0) return;
2027 
2028  set<string> ids;
2029  const CNodeSet::Tdata& nodes = biotree->GetNodes().Get();
2030  ITERATE(CNodeSet::Tdata, it, nodes) {
2032  const CNode& node = **it;
2033  if (node.CanGetFeatures()) {
2034  const CNodeFeatureSet::Tdata& features = node.GetFeatures().Get();
2036  if ((*it)->GetFeatureid() == seq_id_idx) {
2037  ids.insert((*it)->GetValue());
2038  break;
2039  }
2040  }
2041  }
2042  }
2043 
2044 
2045  ITERATE (set<string>, iter, ids) {
2047  CConstRef<CSeq_id> seq_id;
2048  try {
2049  seq_id.Reset(new CSeq_id(*iter));
2050  } catch (CException&) {
2051  }
2052 
2053  if (seq_id) {
2054  objs.push_back(CRelation::SObject(*seq_id));
2055  }
2056  }
2057  }
2058 }
2059 
2060 
2061 
2062 struct SConverterEntry
2063 {
2064  const char* m_Name;
2066  const CTypeInfo* m_FromType;
2067  const CTypeInfo* m_ToType;
2069 };
2070 
2071 BEGIN_RELATION_PROPERTY_LIST(Seq_feat_Seq_loc_Gen_Loc_Prop)
2072 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Genomic Location")
2074 
2075 BEGIN_RELATION_PROPERTY_LIST(Seq_feat_Seq_loc_Gen_Loc_TotalRange_Prop)
2076 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Genomic Location (total range)")
2078 
2079 BEGIN_RELATION_PROPERTY_LIST(Seq_feat_Seq_loc_Prod_Loc_Prop)
2080 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Product Location")
2082 
2083 BEGIN_RELATION_PROPERTY_LIST(Seq_feat_Seq_loc_dbxref_Loc_Prop)
2084 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "dbxref Location")
2086 
2087 
2088 BEGIN_RELATION_PROPERTY_LIST(Convert_Seq_align_Seq_loc_Basic_Prop)
2089 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Basic")
2091 
2092 BEGIN_RELATION_PROPERTY_LIST(Convert_Seq_align_Seq_loc_Coalesced_Prop)
2093 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Total Range")
2095 
2096 BEGIN_RELATION_PROPERTY_LIST(Seq_annot_Seq_loc_All_Prop)
2097 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Genomic Location")
2099 
2100 BEGIN_RELATION_PROPERTY_LIST(Seq_annot_Seq_loc_TotalRange_Prop)
2101 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Genomic Location (total range)")
2103 
2104 /// entrezgene: moved from plugins/algo/init
2105 BEGIN_RELATION_PROPERTY_LIST(Convert_Entrezgene_Seq_loc_Genomic_Prop)
2106 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Genomic Location")
2108 
2109 BEGIN_RELATION_PROPERTY_LIST(Convert_Entrezgene_Seq_loc_Product_Prop)
2110 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Product Location")
2112 
2113 BEGIN_RELATION_PROPERTY_LIST(Convert_Entrezgene_Seq_loc_Related_Prop)
2114 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Related Sequences")
2116 
2117 BEGIN_RELATION_PROPERTY_LIST(Convert_Entrezgene_Seq_loc_RefSeq_Prop)
2118 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "RefSeq Sequences")
2120 
2121 BEGIN_RELATION_PROPERTY_LIST(Convert_GC_Assembly_Seq_loc_Chromosomes_Prop)
2122 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Assembly Chromosomes")
2124 
2125 BEGIN_RELATION_PROPERTY_LIST(Convert_GC_Assembly_Seq_loc_TopLevel_Prop)
2126 RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo()->GetName(), "Assembly Top Level sequences")
2128 
2130  // Bioseq
2131  { "Bioseq --> Seq-entry", Convert_Bioseq_Seq_entry,
2132  CBioseq::GetTypeInfo(), CSeq_entry::GetTypeInfo() },
2133  { "Bioseq --> Seq-id", Convert_Bioseq_Seq_id,
2134  CBioseq::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2135  // Bioseq-set
2136  { "Bioseq-set --> Bioseq", Convert_Bioseq_set_Bioseq,
2137  CBioseq_set::GetTypeInfo(), CBioseq::GetTypeInfo() },
2138  { "Bioseq-set --> Seq-entry", Convert_Bioseq_set_Seq_entry,
2139  CBioseq_set::GetTypeInfo(), CSeq_entry::GetTypeInfo() },
2140  // Dense-seg
2141  { "Dense-seg --> Seq-align", Convert_Dense_seg_Seq_align,
2142  CDense_seg::GetTypeInfo(), CSeq_align::GetTypeInfo() },
2143  { "Seq-align --> Seq-annot", Convert_Seq_align_Seq_annot,
2144  CSeq_align::GetTypeInfo(), CSeq_annot::GetTypeInfo() },
2145  // Seq-align
2146  { "Seq-align -> Seq-id", Convert_Seq_align_Seq_id,
2147  CSeq_align::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2148  { "Seq-align -> Seq-loc : Basic", Convert_Seq_align_Seq_loc_Basic,
2149  CSeq_align::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2150  Convert_Seq_align_Seq_loc_Basic_Prop },
2151  { "Seq-align -> Seq-loc : Coalesced", Convert_Seq_align_Seq_loc_Coalesced,
2152  CSeq_align::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2153  Convert_Seq_align_Seq_loc_Coalesced_Prop },
2154  /*
2155  { "Seq-align -> Seq-loc", Convert_Seq_align_Seq_loc,
2156  CSeq_align::GetTypeInfo(), CSeq_loc::GetTypeInfo() },
2157  */
2158  // Seq-align-set
2159  { "Seq-align-set --> Seq-align", Convert_Seq_align_set_Seq_align,
2160  CSeq_align_set::GetTypeInfo(), CSeq_align::GetTypeInfo() },
2161  { "Seq-align-set -> Seq-loc", Convert_Seq_align_set_Seq_loc,
2162  CSeq_align_set::GetTypeInfo(), CSeq_loc::GetTypeInfo() },
2163  { "Seq-align-set --> Seq-annot", Convert_Seq_align_set_Seq_annot,
2164  CSeq_align_set::GetTypeInfo(), CSeq_annot::GetTypeInfo() },
2165  // Seq-annot
2166  { "Seq-annot --> Seq-align", Convert_Seq_annot_Seq_align,
2167  CSeq_annot::GetTypeInfo(), CSeq_align::GetTypeInfo() },
2168  { "Seq-annot --> Seq-entry", Convert_Seq_annot_Seq_entry,
2169  CSeq_annot::GetTypeInfo(), CSeq_entry::GetTypeInfo() },
2170  { "Seq-annot --> Seq-feat", Convert_Seq_annot_Seq_feat,
2171  CSeq_annot::GetTypeInfo(), CSeq_feat::GetTypeInfo() },
2172  { "Seq-annot --> Seq-graph", Convert_Seq_annot_Seq_graph,
2173  CSeq_annot::GetTypeInfo(), CSeq_graph::GetTypeInfo() },
2174  { "Seq-annot --> Seq-id", Convert_Seq_annot_Seq_id,
2175  CSeq_annot::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2176 
2177  { "Seq-annot --> Seq-loc : All", Convert_Seq_annot_Seq_loc_All,
2178  CSeq_annot::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2179  Seq_annot_Seq_loc_All_Prop },
2180  { "Seq-annot --> Seq-loc : Total range", Convert_Seq_annot_Seq_loc_TotalRange,
2181  CSeq_annot::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2182  Seq_annot_Seq_loc_TotalRange_Prop },
2183 
2184  // Seq-entry
2185  { "Seq-entry --> Bioseq", Convert_Seq_entry_Bioseq,
2186  CSeq_entry::GetTypeInfo(), CBioseq::GetTypeInfo() },
2187  { "Seq-entry --> Bioseq-set", Convert_Seq_entry_Bioseq_set,
2188  CSeq_entry::GetTypeInfo(), CBioseq_set::GetTypeInfo() },
2189  { "Seq-entry --> Seq-loc", Convert_Seq_entry_Seq_loc,
2190  CSeq_entry::GetTypeInfo(), CSeq_loc::GetTypeInfo() },
2191  { "Seq-entry --> Seq-id", Convert_Seq_entry_Seq_id,
2192  CSeq_entry::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2193  { "Seq-entry --> Seq-submit", Convert_Seq_entry_SeqSubmit,
2194  CSeq_entry::GetTypeInfo(), CSeq_submit::GetTypeInfo() },
2195  { "Seq-entry --> Seq-annot", Convert_Seq_entry_Seq_annot,
2196  CSeq_entry::GetTypeInfo(), CSeq_annot::GetTypeInfo() },
2197  { "Seq-entry --> Seq-align", Convert_Seq_entry_Seq_align,
2198  CSeq_entry::GetTypeInfo(), CSeq_align::GetTypeInfo() },
2199  // Seq-feat
2200  /**
2201  { "Seq-feat --> Seq-id", Convert_Seq_feat_Seq_id,
2202  CSeq_feat::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2203  **/
2204  /*
2205  { "Seq-feat --> Seq-loc", Convert_Seq_feat_Seq_loc,
2206  CSeq_feat::GetTypeInfo(), CSeq_loc::GetTypeInfo() },
2207  */
2208  { "Seq-feat --> Seq-loc : Genomic Location", Convert_Seq_feat_Seq_loc_Gen_Loc,
2209  CSeq_feat::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2210  Seq_feat_Seq_loc_Gen_Loc_Prop },
2211  { "Seq-feat --> Seq-loc : Genomic Location (total range)", Convert_Seq_feat_Seq_loc_Gen_Loc_TotalRange,
2212  CSeq_feat::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2213  Seq_feat_Seq_loc_Gen_Loc_TotalRange_Prop },
2214  { "Seq-feat --> Seq-loc : Product Location", Convert_Seq_feat_Seq_loc_Prod_Loc,
2215  CSeq_feat::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2216  Seq_feat_Seq_loc_Prod_Loc_Prop },
2217  { "Seq-feat --> Seq-loc : dbxref Location", Convert_Seq_feat_Seq_loc_dbxref_Loc,
2218  CSeq_feat::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2219  Seq_feat_Seq_loc_dbxref_Loc_Prop },
2220  // Seq-id
2221  { "Seq-id --> Bioseq: use CBioseq_Handle", Convert_Seq_id_Bioseq,
2222  CSeq_id::GetTypeInfo(), CBioseq::GetTypeInfo() },
2223  { "Seq-id --> Bioseq-set: use CBioseq_Handle", Convert_Seq_id_Bioseq_set,
2224  CSeq_id::GetTypeInfo(), CBioseq_set::GetTypeInfo() },
2225  { "Seq-id --> Seq-entry: use CBioseq_Handle", Convert_Seq_id_Seq_entry,
2226  CSeq_id::GetTypeInfo(), CSeq_entry::GetTypeInfo() },
2227  { "Seq-id --> Seq-loc: use Seq-loc.whole representation", Convert_Seq_id_Seq_loc,
2228  CSeq_id::GetTypeInfo(), CSeq_loc::GetTypeInfo() },
2229  // Seq-loc
2230  { "Seq-loc --> Seq-align: use CFeat_CI", Convert_Seq_loc_Seq_align,
2231  CSeq_loc::GetTypeInfo(), CSeq_align::GetTypeInfo() },
2232  { "Seq-loc --> Seq-annot", Convert_Seq_loc_Seq_annot,
2233  CSeq_loc::GetTypeInfo(), CSeq_annot::GetTypeInfo() },
2234  { "Seq-loc --> Seq-feat: use CFeat_CI", Convert_Seq_loc_Seq_feat,
2235  CSeq_loc::GetTypeInfo(), CSeq_feat::GetTypeInfo() },
2236  { "Seq-loc --> Seq-graph: use CGraph_CI", Convert_Seq_loc_Seq_graph,
2237  CSeq_loc::GetTypeInfo(), CSeq_graph::GetTypeInfo() },
2238  { "Seq-loc --> Seq-id: use sequence::GetId()", Convert_Seq_loc_Seq_id,
2239  CSeq_loc::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2240  // Seq-submit
2241  { "Seq-submit --> Seq-annot", Convert_SeqSubmit_Seq_annot,
2242  CSeq_submit::GetTypeInfo(), CSeq_annot::GetTypeInfo() },
2243  { "Seq-submit --> Seq-entry", Convert_SeqSubmit_Seq_entry,
2244  CSeq_submit::GetTypeInfo(), CSeq_entry::GetTypeInfo() },
2245  { "Seq-submit --> Seq-id", Convert_SeqSubmit_Seq_id,
2246  CSeq_submit::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2247  // entrezgene
2248  { "Entrezgene --> Seq-loc : Genomic", Convert_Entrezgene_Seq_loc_Genomic,
2249  CEntrezgene::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2250  Convert_Entrezgene_Seq_loc_Genomic_Prop },
2251  { "Entrezgene --> Seq-loc : Product", Convert_Entrezgene_Seq_loc_Product,
2252  CEntrezgene::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2253  Convert_Entrezgene_Seq_loc_Product_Prop },
2254  { "Entrezgene --> Seq-loc : Related", Convert_Entrezgene_Seq_loc_Related,
2255  CEntrezgene::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2256  Convert_Entrezgene_Seq_loc_Related_Prop },
2257  { "Entrezgene --> Seq-loc : RefSeq", Convert_Entrezgene_Seq_loc_RefSeq,
2258  CEntrezgene::GetTypeInfo(), CSeq_loc::GetTypeInfo(),
2259  Convert_Entrezgene_Seq_loc_RefSeq_Prop },
2260  { "Entrezgene-Set --> Entrezgene", Convert_Entrezgene_Set_Entrezgene,
2261  CEntrezgene_Set::GetTypeInfo(), CEntrezgene::GetTypeInfo(), NULL },
2262  // BioTreeContainer
2263  { "BioTreeContainer --> Seq-id", Convert_BioTreeContainer_Seq_id,
2264  CBioTreeContainer::GetTypeInfo(), CSeq_id::GetTypeInfo() },
2265  // GC-Assembly
2266  {
2267  "GC-Assembly --> Seq-loc : Chromosomes",
2269  CGC_Assembly::GetTypeInfo(),
2270  CSeq_loc::GetTypeInfo(),
2271  Convert_GC_Assembly_Seq_loc_Chromosomes_Prop
2272  },
2273  {
2274  "GC-Assembly --> Seq-loc : TopLevel",
2276  CGC_Assembly::GetTypeInfo(),
2277  CSeq_loc::GetTypeInfo(),
2278  Convert_GC_Assembly_Seq_loc_TopLevel_Prop
2279  },
2280  {
2281  "GC-Assembly --> Seq-id",
2283  CGC_Assembly::GetTypeInfo(),
2284  CSeq_id::GetTypeInfo()
2285  }
2286 
2287  };
2288 
2290 {
2292 
2293  for (size_t i = 0;
2294  i < sizeof(m_ConverterEntries)/sizeof(m_ConverterEntries[0]); ++i) {
2296  (new CBasicRelation(m_ConverterEntries[i].m_Name,
2297  m_ConverterEntries[i].m_FromType->GetName(),
2301  }
2302 
2304  (new CBasicRelation("Object --> SerialObject",
2305  "Object", "SerialObject",
2307 }
2308 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define static
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
vector< TRangeWithFuzz > TRanges
Definition: Seq_loc.cpp:4277
User-defined methods of the data storage class.
static void Convert_Seq_feat_Seq_loc_Gen_Loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
/ Seq-feat –> Seq-id static void Convert_Seq_feat_Seq_id( CScope& scope, const CObject& obj,...
static void Convert_Seq_annot_Seq_align(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-align.
void Convert_Entrezgene_Seq_loc_Genomic(CScope &, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Entrezgene –> Seq-loc.
USING_SCOPE(objects)
void Convert_Entrezgene_Seq_loc_Product(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
#define CHECK_CANCELLED
void Convert_Entrezgene_Seq_loc_Related(CScope &, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
static void Convert_Bioseq_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Bioseq –> Seq-id.
static void Convert_Bioseq_Seq_entry(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Bioseq –> Seq-entry.
static void Convert_Seq_feat_Seq_loc_Gen_Loc_TotalRange(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-feat –> Seq-loc : Genomic Location (total range)
static void Convert_Seq_entry_Bioseq(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-entry –> Bioseq.
static void Convert_Bioseq_set_Seq_entry(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Bioseq-set –> Seq-entry.
static void Convert_Seq_loc_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-loc –> Seq-id: use sequence::GetId()
static void Convert_SeqSubmit_Seq_annot(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-submit –> Seq-annot.
static void Convert_Seq_entry_Seq_loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-entry –> Seq-loc.
static CRef< CSeq_annot > s_AlignSet2Annot(const CSeq_align_set &align_set)
static void s_AddCoalescedLocations(const list< CConstRef< CSeq_loc > > &locs, CScope &scope, CBasicRelation::TObjects &objs, ICanceled *cancel)
static void Convert_Seq_feat_Seq_loc_dbxref_Loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-feat –> Seq-loc : dbxrefs Location.
static void Convert_Seq_id_Seq_loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-id –> Seq-loc: use Seq-loc.whole representation.
static void Convert_GC_Assembly_Seq_loc_TopLevel(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
static void Convert_Seq_loc_Seq_align(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-loc –> Seq-align: use CFeat_CI.
static void Convert_BioTreeContainer_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
BioTreeContainer –> Seq-id.
void init_basic_converters()
string s_GetDescription(CSeq_id_Handle idh, CScope &scope)
Comment formatters.
static void Convert_Dense_seg_Seq_align(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Dense-seg –> Seq-align.
static void Convert_Seq_annot_Seq_graph(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-graph.
static void Convert_Seq_entry_SeqSubmit(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-entry –> Seq-submit.
static void Convert_Seq_annot_Seq_loc_All(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-loc (all locs)
static void Convert_Seq_align_Seq_annot(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-align –> Seq-annot.
static void Convert_Seq_align_Seq_loc_Basic(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-align -> Seq-loc : Basic.
static void s_GeneCommentaryToLocations(const CGene_commentary &gc, CBasicRelation::TObjects &objs, TGCFlags flags=fGC_Defaults)
static void Convert_Seq_annot_Seq_entry(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-annot –> Seq-entry.
void Convert_Entrezgene_Seq_loc_RefSeq(CScope &, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
static void Convert_Seq_id_Seq_entry(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-id –> Seq-entry: use CBioseq_Handle.
static void Convert_Seq_align_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-align -> Seq-id.
static void Convert_Bioseq_set_Bioseq(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Bioseq-set –> Bioseq.
static void s_Seq_align_Seq_loc(const CSeq_align &align, list< CConstRef< CSeq_loc > > &locs)
static void Convert_Object_SerialObject(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Object –> SerialObject.
int TGCFlags
static void Convert_GC_Assembly_Seq_loc_Chromosomes(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
static void Convert_Seq_loc_Seq_graph(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-loc –> Seq-geaph: use CGraph_CI.
RELATION_PROPERTY_ENTRY(CSeq_loc::GetTypeInfo() ->GetName(), "Genomic Location") END_RELATION_PROPERTY_LIST()
entrezgene: moved from plugins/algo/init
static void Convert_Seq_loc_Seq_feat(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-loc –> Seq-feat: use CFeat_CI.
static void Convert_Seq_entry_Seq_annot(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-entry –> Seq-annot.
static void Convert_Seq_feat_Seq_loc_Prod_Loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-feat –> Seq-loc : Product Location.
static void Convert_Seq_align_set_Seq_align(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-align-set –> Seq-align.
static void Convert_Seq_entry_Bioseq_set(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-entry –> Bioseq-set.
static void Convert_Seq_annot_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-id.
static void Convert_Seq_entry_Seq_align(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-entry –> Seq-align.
static void Convert_SeqSubmit_Seq_entry(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-submit –> Seq-entry.
static SConverterEntry m_ConverterEntries[]
static void Convert_Seq_entry_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-entry –> Seq-id.
static void Convert_SeqSubmit_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-submit –> Seq-id.
static void Convert_Seq_align_Seq_loc_Coalesced(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-align -> Seq-loc : Coalesced.
EGCFlags
******************************************************************* Moved from plugins/algo/init ****...
@ fGC_Recursive
@ fGC_GenomicCoords
@ fGC_Seqs
@ fGC_Defaults
static void Convert_Seq_align_set_Seq_annot(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-align-set –> Seq-annot.
static void Convert_Seq_align_set_Seq_loc(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-align-set -> Seq-loc.
static void s_GCSeqsToSeqLocs(const CGC_Assembly &assm, const vector< CConstRef< CGC_Sequence > > &gcSeqs, CBasicRelation::TObjects &seqLocs, ICanceled *cancel)
GC-Assembly –> Seq-loc.
void Convert_Entrezgene_Set_Entrezgene(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Entrezgene –> Seq-loc.
static void Convert_Seq_annot_Seq_feat(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-feat.
static void Convert_Seq_annot_Seq_loc_TotalRange(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
Seq-annot –> Seq-loc (total range)
static void Convert_GC_Assembly_Seq_id(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *cancel)
GC-Assembly –> Seq-id.
static void Convert_Seq_id_Bioseq_set(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-id –> Bioseq-set: use CBioseq_Handle.
static void Convert_Seq_loc_Seq_annot(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags, ICanceled *)
Seq-loc –> Seq-annot.
static void Convert_Seq_id_Bioseq(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-id –> Bioseq: use CBioseq_Handle.
static CRef< CSeq_annot > s_Align2Annot(const CSeq_align &align)
CAlign_CI –.
Definition: align_ci.hpp:63
CAnnot_CI –.
Definition: annot_ci.hpp:59
void(* TFNConvert)(objects::CScope &scope, const CObject &obj, TObjects &related, TFlags flags, ICanceled *cancel)
Definition: relation.hpp:224
CBioseq_Handle –.
CSeq_entry * GetParentEntry(void) const
Definition: Bioseq.hpp:174
Definition: Dbtag.hpp:53
ENa_strand GetSeqStrand(TDim row) const
Definition: Dense_seg.cpp:241
TSeqPos GetSeqStop(TDim row) const
Definition: Dense_seg.cpp:203
TSeqPos GetSeqStart(TDim row) const
Definition: Dense_seg.cpp:165
CEntrezgene_Set –.
CFeat_CI –.
Definition: feat_ci.hpp:64
CGC_AssemblyDesc –.
string GetName() const
Retrieve the name of this assembly.
const CGC_AssemblyDesc & GetDesc() const
Retrieve the full set of assembly descriptors.
bool IsRefSeq() const
Is this assembly a RefSeq assembly?
list< CConstRef< CGC_Sequence > > TSequenceList
Definition: GC_Assembly.hpp:67
void GetMolecules(TSequenceList &molecules, ESubset subset) const
Retrieve a subset of molecules.
CGraph_CI –.
Definition: graph_ci.hpp:234
CNode –.
Definition: Node.hpp:66
static void Register(CRelation *rel)
Definition: obj_convert.cpp:58
CObject –.
Definition: ncbiobj.hpp:180
vector< SObject > TObjects
Definition: relation.hpp:130
int TFlags
Definition: relation.hpp:65
@ fConvert_All
retrieve all possible identities if multiple can be shown
Definition: relation.hpp:53
@ fConvert_NoExpensive
do not perform any expensive tests (such as fetching from the network)
Definition: relation.hpp:60
CScope –.
Definition: scope.hpp:92
CSeqIdException –.
Definition: Seq_id.hpp:1001
CRange< TSeqPos > GetSeqRange(TDim row) const
GetSeqRange NB: On a Spliced-seg, in case the product-type is protein, these only return the amin par...
Definition: Seq_align.cpp:153
TDim CheckNumRows(void) const
Validatiors.
Definition: Seq_align.cpp:73
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
Definition: Seq_align.cpp:317
CSeq_annot_CI –.
Definition: Seq_entry.hpp:56
CSeq_entry * GetParentEntry(void) const
Definition: Seq_entry.hpp:131
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
Template class for iteration on objects of class C (non-medifiable version)
Definition: iterator.hpp:767
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
Definition: map.hpp:338
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
static uch flags
static char tmp[3200]
Definition: utf8.c:42
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static EAccessionInfo IdentifyAccession(const CTempString &accession, TParseFlags flags=fParse_AnyRaw)
Deduces information from a bare accession a la WHICH_db_accession; may report false negatives on prop...
Definition: Seq_id.cpp:1634
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
CConstRef< CSeq_id > GetSeqId(void) const
EAccessionInfo
For IdentifyAccession (below)
Definition: Seq_id.hpp:220
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
static int BestRank(const CRef< CSeq_id > &id)
Definition: Seq_id.hpp:774
@ eAcc_wgs
Definition: Seq_id.hpp:290
@ eAcc_htgs
Definition: Seq_id.hpp:288
@ eAcc_est
Definition: Seq_id.hpp:265
@ eAcc_division_mask
Definition: Seq_id.hpp:299
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
Definition: Seq_loc.cpp:3474
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
void SetStrand(ENa_strand strand)
Set the strand for all of the location's ranges.
Definition: Seq_loc.cpp:5196
TSeqPos GetStop(const CSeq_loc &loc, CScope *scope, ESeqLocExtremes ext=eExtreme_Positional)
If only one CBioseq is represented by CSeq_loc, returns the position at the stop of the location.
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
TSeqPos GetStart(const CSeq_loc &loc, CScope *scope, ESeqLocExtremes ext=eExtreme_Positional)
If only one CBioseq is represented by CSeq_loc, returns the position at the start of the location.
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
Definition: sequence.hpp:101
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
TSequenceLengths GetSequenceLengths(const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< CSeq_id_Handle > TSeq_id_Handles
Bulk retrieval methods Common argument typedef - vector of requested ids.
Definition: scope.hpp:518
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
const CSeq_align & GetOriginalSeq_align(void) const
Get original alignment.
Definition: align_ci.cpp:225
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_graph & GetOriginalGraph(void) const
Get original graph with unmapped location/product.
Definition: graph_ci.hpp:70
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
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
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
static TThisType GetWhole(void)
Definition: range.hpp:272
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
C::value_type FindBestChoice(const C &container, F score_func)
Find the best choice (lowest score) for values in a container.
Definition: ncbiutil.hpp:250
static const char label[]
list< CRef< CFeatureDescr > > Tdata
list< CRef< CNodeFeature > > Tdata
bool CanGetFeatures(void) const
Check if it is safe to call GetFeatures method.
Definition: Node_.hpp:340
list< CRef< CNode > > Tdata
Definition: NodeSet_.hpp:89
const Tdata & Get(void) const
Get the member data.
Definition: NodeSet_.hpp:164
const Tdata & Get(void) const
Get the member data.
const TFdict & GetFdict(void) const
Get the Fdict member data.
const TFeatures & GetFeatures(void) const
Get the Features member data.
Definition: Node_.hpp:346
const Tdata & Get(void) const
Get the member data.
const TNodes & GetNodes(void) const
Get the Nodes member data.
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
list< CRef< CEntrezgene > > Tdata
list< CRef< CGene_commentary > > TProperties
bool IsSetProperties(void) const
Check if a value has been assigned to Properties data member.
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
const TLocus & GetLocus(void) const
Get the Locus member data.
const TGenomic_coords & GetGenomic_coords(void) const
Get the Genomic_coords member data.
bool IsSetProducts(void) const
Check if a value has been assigned to Products data member.
const Tdata & Get(void) const
Get the member data.
const TProperties & GetProperties(void) const
Get the Properties member data.
bool IsSetLocus(void) const
location of gene on chromosome (if known) and all information about products (mRNA,...
const TComment & GetComment(void) const
Get the Comment member data.
const TSeqs & GetSeqs(void) const
Get the Seqs member data.
list< CRef< CGene_commentary > > TLocus
bool IsSetComments(void) const
Check if a value has been assigned to Comments data member.
list< CRef< CSeq_loc > > TSeqs
bool IsSetGenomic_coords(void) const
referenced sequences in genomic coords Check if a value has been assigned to Genomic_coords data memb...
const TComments & GetComments(void) const
Get the Comments member data.
list< CRef< CGene_commentary > > TProducts
list< CRef< CGene_commentary > > TComment
const THeading & GetHeading(void) const
Get the Heading member data.
list< CRef< CGene_commentary > > TComments
list< CRef< CSeq_loc > > TGenomic_coords
const TProducts & GetProducts(void) const
Get the Products member data.
bool IsSetSeqs(void) const
referenced sequences in non-genomic coords Check if a value has been assigned to Seqs data member.
TType GetType(void) const
Get the Type member data.
list< int > TRoles
@ eGC_SequenceRole_component
@ eGC_SequenceRole_scaffold
@ eGC_SequenceRole_pseudo_scaffold
@ eGC_SequenceRole_chromosome
@ eGC_SequenceRole_submitter_pseudo_scaffold
@ eState_aligned
exist only on alt-loci/patch units. List all aligned (eg cross-placed) sequences. (unaligned are list...
@ eState_unlocalized
exist only within a replicon. "random" on a given chromosome
@ eState_unplaced
exist only on primary/diploid assembly-unit. unknown chromosome
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:568
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:310
void SetType(TType value)
Assign a value to Type data member.
Definition: Seq_align_.hpp:818
TDim GetDim(void) const
Get the Dim member data.
Definition: Dense_seg_.hpp:421
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Dense_seg_.hpp:505
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
vector< CRef< CDbtag > > TDbxref
Definition: Seq_feat_.hpp:123
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
const TDbxref & GetDbxref(void) const
Get the Dbxref member data.
Definition: Seq_feat_.hpp:1333
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
bool IsSetDbxref(void) const
support for xref to other databases Check if a value has been assigned to Dbxref data member.
Definition: Seq_feat_.hpp:1321
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
void SetTo(TTo value)
Assign a value to To data member.
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const Tdata & Get(void) const
Get the member data.
void SetId(TId &value)
Assign a value to Id data member.
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_id_.hpp:746
void SetFrom(TFrom value)
Assign a value to From data member.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
Definition: Seq_loc_.hpp:534
bool IsWhole(void) const
Check if variant Whole is selected.
Definition: Seq_loc_.hpp:522
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TPacked_int & GetPacked_int(void) const
Get the variant data.
Definition: Seq_loc_.cpp:216
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_Other
for historical reasons, 'other' = 'refseq'
Definition: Seq_id_.hpp:104
@ e_Gpipe
Internal NCBI genome pipeline processing ID.
Definition: Seq_id_.hpp:113
@ e_Ddbj
DDBJ.
Definition: Seq_id_.hpp:107
@ e_Whole
whole sequence
Definition: Seq_loc_.hpp:100
TSet & SetSet(void)
Select the variant.
Definition: Seq_entry_.cpp:130
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
bool IsAlign(void) const
Check if variant Align is selected.
Definition: Seq_annot_.hpp:635
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
list< CRef< CSeq_id > > TIds
Definition: Seq_annot_.hpp:196
const TGraph & GetGraph(void) const
Get the variant data.
Definition: Seq_annot_.hpp:661
const TLocs & GetLocs(void) const
Get the variant data.
Definition: Seq_annot_.hpp:701
list< CRef< CSeq_graph > > TGraph
Definition: Seq_annot_.hpp:195
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
Definition: Seq_annot_.hpp:861
list< CRef< CSeq_align > > TAlign
Definition: Seq_annot_.hpp:194
const TIds & GetIds(void) const
Get the variant data.
Definition: Seq_annot_.hpp:681
const TAlign & GetAlign(void) const
Get the variant data.
Definition: Seq_annot_.hpp:641
bool IsGraph(void) const
Check if variant Graph is selected.
Definition: Seq_annot_.hpp:655
list< CRef< CSeq_loc > > TLocs
Definition: Seq_annot_.hpp:197
const TFtable & GetFtable(void) const
Get the variant data.
Definition: Seq_annot_.hpp:621
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
bool IsFtable(void) const
Check if variant Ftable is selected.
Definition: Seq_annot_.hpp:615
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:873
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_annot_.hpp:586
@ e_Ids
used for communication between tools
Definition: Seq_annot_.hpp:136
@ e_Locs
used for communication between tools
Definition: Seq_annot_.hpp:137
list< CRef< CSeq_entry > > TEntrys
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
bool IsEntrys(void) const
Check if variant Entrys is selected.
int i
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define BEGIN_RELATION_PROPERTY_LIST(name)
Macros to assist in building property lists for relation converters.
Definition: relation.hpp:279
#define END_RELATION_PROPERTY_LIST()
Definition: relation.hpp:285
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
#define row(bind, expected)
Definition: string_bind.c:73
struct SObject provides an interface for defining what is returned from object conversion.
Definition: relation.hpp:71
SAnnotSelector –.
CBasicRelation::TFNConvert m_pFnCvt
const CBasicRelation::SPropPair * m_Properties
const CTypeInfo * m_ToType
const CTypeInfo * m_FromType
#define _ASSERT
static const char *const features[]
Modified on Wed Apr 17 13:08:30 2024 by modify_doxy.py rev. 669887