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

Go to the SVN repository for this file.

1 /* $Id: label.cpp 46222 2021-02-08 14:57:45Z shkeda $
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 
34 #include <serial/enumvalues.hpp>
35 
36 #include <gui/objutils/label.hpp>
39 #include <gui/objutils/tooltip.hpp>
40 #include <gui/objutils/snp_gui.hpp>
42 #include <map>
43 #include <corelib/ncbimtx.hpp>
44 #include <util/static_map.hpp>
45 
46 #include <objects/seq/Bioseq.hpp>
51 #include <objects/seq/Seqdesc.hpp>
52 
58 
67 
75 
80 
83 
88 
91 
95 
98 
104 
105 #include <objmgr/util/sequence.hpp>
108 #include <objmgr/align_ci.hpp>
109 
110 #include <serial/iterator.hpp>
112 
115 
116 
119 
120 
121 void CLabel::SetLabelByData(objects::CProjectItem& item, objects::CScope* scope)
122 {
123  string label = "No data";
124  if (item.IsSetItem()) {
125  const CSerialObject* obj = item.GetObject();
126  if(obj) {
127  label.clear();
128  GetLabel(*obj, &label, CLabel::eDefault, scope);
129  }
130  }
131  item.SetLabel(label);
132 }
133 
134 
138 
139 
141  const CObject& obj, string* label, ELabelType type
142 ){
143  const CSerialObject* so = dynamic_cast<const CSerialObject*>(&obj);
144  if( so ){
145  TTypeInfo type_info = so->GetThisTypeInfo();
146  _ASSERT(type_info != CSeq_id::GetTypeInfo());
147  _ASSERT(type_info != CSeq_loc::GetTypeInfo());
148  _ASSERT(type_info != CSeq_entry::GetTypeInfo());
149  _ASSERT(type_info != CBioseq::GetTypeInfo());
150  _ASSERT(type_info != CBioseq_set::GetTypeInfo());
151  }
152 
153  CLabel::GetLabel( obj, label, type, NULL );
154 }
155 
156 void CLabel::GetLabel(
157  const CObject& obj, string* label, ELabelType type, CScope* scope
158 ){
159  if( !label ){
160  return;
161  }
162 
163  try {
164  const CSerialObject* so = dynamic_cast<const CSerialObject*>(&obj);
165  if (so) {
168  if (iter != sm_LabelMap.end()) {
169  iter->second->GetLabel(obj, label, type, scope);
170  } else {
171  *label = "[" + so->GetThisTypeInfo()->GetName() + "]";
172  }
173  } else {
175  sm_LabelMap.find(typeid(obj).name());
176  if (iter != sm_LabelMap.end()) {
177  iter->second->GetLabel(obj, label, type, scope);
178  } else {
179  *label = "[" + string(typeid(obj).name()) + "]";
180  }
181  }
182  } catch( CException& e ){
183  LOG_POST(Error << "CLabel::GetLabel(): error: " << e.GetMsg());
184  }
185 }
186 
188  unsigned length_limit,
189  unsigned length_tolerance)
190 {
191  if (!label) return;
192  if (label->empty()) return;
193  size_t len = label->length();
194  if (len <= length_limit) return; // nothing to do
195 
196  // scan the label to find the nearest meaningful truncate point
197  bool point_found = false;
198  size_t i = length_limit;
199  size_t max_len = min(len, size_t(length_limit + length_tolerance));
200  for (; i < max_len; ++i) {
201  char c = (*label)[i];
202  if (c == ';' || c == '.') {
203  point_found = true;
204  break;
205  }
206  } // for
207 
208  if ( !point_found ) {
209  i = length_limit;
210  for (;i < max_len; ++i) {
211  char c = (*label)[i];
212  if (c == ' ' || c == ',') {
213  point_found = true;
214  break;
215  }
216  } // for
217  }
218 
219  if ( !point_found ) {
220  i = length_limit;
221  }
222 
223  label->erase(i);
224  label->append("...");
225 }
226 
227 
228 
230 {
231  CMutexGuard LOCK(sm_Mutex);
233 }
234 
235 
237 {
238  CMutexGuard LOCK(sm_Mutex);
240 }
241 
242 
244 {
245  return HasHandler( type.GetName() );
246 }
247 
248 
249 bool CLabel::HasHandler( const string& type )
250 {
251  CMutexGuard LOCK(sm_Mutex);
253  return (iter != sm_LabelMap.end());
254 }
255 
256 
257 void CLabel::RegisterTypeIcon(const string& user_type,
258  const string& user_subtype,
259  const string& icon_alias)
260 {
261  string key = user_type + "&" + user_subtype;
262 
263  CMutexGuard LOCK(sm_Mutex);
264  sm_AliasMap[key] = icon_alias;
265 }
266 
267 
268 string CLabel::GetTypeIconAlias(const string& user_type, const string& user_subtype)
269 {
270  string key = user_type + "&" + user_subtype;
271 
272  CMutexGuard LOCK(sm_Mutex);
273 
275  if(it != sm_AliasMap.end()) {
276  return it->second;
277  } else if( ! user_subtype.empty()) {
278  // ignore subtype
279  key = user_type;
280  key += "&";
281  it = sm_AliasMap.find(key);
282  if(it != sm_AliasMap.end()) {
283  return it->second;
284  }
285  }
286  return "";
287 }
288 
289 
290 string CLabel::GetTypeIconAlias(const string& user_type)
291 {
292  string key = user_type + "&";
293 
294  CMutexGuard LOCK(sm_Mutex);
296  return (it != sm_AliasMap.end()) ? it->second : "";
297 }
298 
299 
300 void CLabel::GetIconAlias(const CObject& obj, string* alias,
301  objects::CScope* scope)
302 {
303  if(alias) {
304  string type, subtype;
305  GetLabel(obj, &type, eUserType, scope);
306  GetLabel(obj, &subtype, eUserSubtype, scope);
307  *alias = GetTypeIconAlias(type, subtype);
308  }
309 }
310 
311 ///////////////////////////////////////////////////////////////////////////////
312 // Description cache (singleton)
313 
315 {
316 public:
318 public:
320 
321  string GetLabel(TGi gi) const
322  {
323  CFastMutexGuard lock(m_Lock);
325  if (it == m_DescrCache.end()) {
326  return kEmptyStr;
327  }
328  return it->second;
329  }
330  void GetLabel(TGi gi, string* label) const
331  {
332  CFastMutexGuard lock(m_Lock);
334  if (it == m_DescrCache.end()) {
335  label->clear();
336  return;
337  }
338  *label = it->second;
339  }
340  bool HasLabel(TGi gi) const
341  {
342  CFastMutexGuard lock(m_Lock);
344  if (it == m_DescrCache.end()) {
345  return false;
346  }
347  return true;
348  }
349 
350  void SetLabel(TGi gi, const string& label)
351  {
352  CFastMutexGuard lock(m_Lock);
353  m_DescrCache[GI_TO(TIntId, gi)] = label;
354  }
355 
356  void AddCaches(const map<TGi, string>& caches)
357  {
358  CFastMutexGuard lock(m_Lock);
359  map<TGi, string>::const_iterator iter = caches.begin();
360  for (; iter != caches.end(); ++iter) {
361  m_DescrCache[GI_TO(TIntId, iter->first)] = iter->second;
362  }
363  }
364 
365 private:
368 };
369 
370 static std::unique_ptr<CLabelDescriptionCacheImpl> s_DescrCachePtr;
371 
373 {
374  if (s_DescrCachePtr.get() != 0) {
375  return; // double initialization
376  }
378 }
379 
381 {
382  s_DescrCachePtr.reset(0);
383 }
384 
385 
386 static
387 TGi s_GetGi( const CSeq_id& id, CScope* scope )
388 {
389  // check: scope is NEEDED [protected]
390 
391  TGi gi = ZERO_GI;
392  try {
393  if( id.IsLocal() ) return gi;
394 
395  if( id.IsGi() ){
396  gi = id.GetGi();
397  }
398  if( (gi == ZERO_GI) && scope ){
399  CSeq_id_Handle bsh = sequence::GetId( id, *scope );
400  bsh = sequence::GetId( bsh, *scope, sequence::eGetId_ForceGi );
401  if( bsh ){
402  gi = bsh.GetGi();
403  }
404  }
405  } catch( std::exception& ){
406  gi = ZERO_GI;
407  }
408 
409  return gi;
410 }
411 
413 static sequence::CDeflineGenerator s_DefGen; ///< This class seems to be non-thread safe even as a stack var
414 
415 static
416 inline void s_GetDefline( const CSeq_id& id, CScope* scope, string* label )
417 {
418  // check: scope is NEEDED [protected]
419 
420  if( scope ){
421  CBioseq_Handle bsh = scope->GetBioseqHandle( id );
422  if( bsh ){
424  *label = s_DefGen.GenerateDefline( bsh );
425  }
426  }
427 }
428 
429 static
430 void s_GetCachedDescription( const CSeq_id& id, CScope* scope, string* label )
431 {
432  // check: scope is NEEDED [indirectly protected]
433 
434  TGi gi = ZERO_GI;
435 
436  if( s_DescrCachePtr.get() != 0 ){ // check if cache is ON
437  gi = s_GetGi( id, scope );
438  if( gi != ZERO_GI ){ // gi labels get cached
439  s_DescrCachePtr->GetLabel( gi, label );
440  if( !label->empty() ){
441  return;
442  }
443  }
444  }
445 
446  // no cache, try sequence defline first
447  s_GetDefline( id, scope, label );
448 
449  if( label->empty() ){
450  // use regular label
452  }
453 
454  if( gi != ZERO_GI ){
455  s_DescrCachePtr->SetLabel(gi, *label);
456  }
457 }
458 
460 {
461  // check: scope is NEEDED [indirectly protected]
462 
463  string fastaLabel;
464 
465  try {
466  if( s_DescrCachePtr.get() != 0 ){ // check if cache is ON
467  fastaLabel = id.AsFastaString();
468  TGi gi = s_GetGi( id, scope );
469  if( (gi != ZERO_GI) && !s_DescrCachePtr->HasLabel(gi) ){
470  string label;
471  s_GetDefline( id, scope, &label );
472  if( !label.empty() ){
473  s_DescrCachePtr->SetLabel( gi, label );
474  }
475  }
476  }
477  } NCBI_CATCH("Failed to load Seq-id: " + fastaLabel + ".");
478 }
479 
481 {
482  if (s_DescrCachePtr.get() != 0) { // check if cache is ON
483  s_DescrCachePtr->AddCaches(caches);
484  }
485 }
486 
487 ///////////////////////////////////////////////////////////////////////////////
488 // Label Handlers
489 
490 // default format function for a seq-id
491 // this is used by seq-id and seq-loc formatting
492 static inline void s_GetSeqLabel(const CSeq_id& id, string* label,
494 {
495  // check: scope is NEEDED [protected]
496 
497  CConstRef<CSeq_id> id_ptr(&id);
498  if( scope && id_ptr->IsGi() ){
500  if( sih ){
501  id_ptr = sih.GetSeqId();
502  }
503  }
504 
505  switch( type ){
506  case CLabel::eUserType:
508  break;
509 
511  {{
513  if( info & CSeq_id::fAcc_nuc ){
515 
516  } else if( info & CSeq_id::fAcc_prot ){
518  }
519  }}
520  break;
521 
522  case CLabel::eType:
523  *label += id_ptr->GetThisTypeInfo()->GetName();
524  break;
525 
526  default:
527  case CLabel::eContent:
529  break;
530 
533  break;
534 
536  *label += id_ptr->GetSeqIdString();
537  break;
539  s_GetCachedDescription(*id_ptr, scope, label);
540  break;
541 
542  case CLabel::eGi:
543  TGi gi = s_GetGi(id, scope);
544  if (gi != ZERO_GI) {
545  *label+="gi|";
547  }
548 
549  break;
550  }
551 }
552 
553 
554 //
555 // process a seq-interval
556 //
557 static inline
558 void s_GetSeq_intervalLabel(const CSeq_interval& interval, string* label,
560  const CSeq_id* last_id = NULL)
561 {
562  // check: scope is NEEDED [indirectly protected]
563 
564  switch (type) {
565  case CLabel::eUserType:
567  break;
568 
569  case CLabel::eType:
570  *label += interval.GetThisTypeInfo()->GetName();
571  break;
572 
573  default:
574  case CLabel::eContent:
576  if ( !last_id || !interval.GetId().Match(*last_id)) {
577  if ( !label->empty() ) {
578  *label += "; ";
579  }
580  s_GetSeqLabel(interval.GetId(), label, scope, type);
581  *label += ": ";
582  }
583 
584  *label += NStr::IntToString(interval.GetFrom() + 1, NStr::fWithCommas);
585  *label += "-";
586  *label += NStr::IntToString(interval.GetTo() + 1, NStr::fWithCommas);
587 
588  *label += " [";
590  *label += "]";
591 
592  if (interval.IsSetStrand()) {
593  switch (interval.GetStrand()) {
594  case eNa_strand_plus:
595  *label += " (+)";
596  break;
597  case eNa_strand_minus:
598  *label += " (-)";
599  break;
600  default:
601  *label += " (+)";
602  break;
603  }
604  }
605  break;
606  }
607 }
608 
609 static inline
610 void s_GetSeq_TotalRangeLabel(const CSeq_loc& loc, string* label,
612 {
613  // check: scope is NEEDED [indirectly protected]
614 
615  switch (type) {
616  case CLabel::eUserType:
618  break;
619 
621  break;
622 
623  case CLabel::eType:
624  *label += loc.GetThisTypeInfo()->GetName();
625  break;
626 
627  default:
628  case CLabel::eContent:
630  {{
631  const CSeq_id& id = sequence::GetId(loc, scope);
632  TSeqRange range = loc.GetTotalRange();
633  s_GetSeqLabel(id, label, scope, type);
634  *label += ": ";
635  *label += NStr::IntToString(range.GetFrom() + 1, NStr::fWithCommas);
636  *label += "-";
638 
639  *label += " [";
641  *label += "]";
642 
643  string extra_info = kEmptyStr;
644  ENa_strand strand = sequence::GetStrand(loc, scope);
645  switch (strand) {
646  case eNa_strand_minus:
647  extra_info = "-";
648  break;
649  case eNa_strand_unknown:
650  break;
651  case eNa_strand_plus:
652  default:
653  extra_info = "+";
654  break;
655  }
656 
657  size_t intervals = 0;
658  switch (loc.Which()) {
659  case CSeq_loc::e_Int:
660  intervals = 1;
661  break;
662 
664  intervals = loc.GetPacked_int().Get().size();
665  break;
666 
668  intervals = loc.GetPacked_pnt().GetPoints().size();
669  break;
670 
671  case CSeq_loc::e_Mix:
672  /// FIXME: this may not always be correct -
673  /// a mix may be a mix of complex intervals
674  intervals = loc.GetMix().Get().size();
675  break;
676 
677  default:
678  break;
679  }
680 
681  if (intervals != 0) {
682  if ( !extra_info.empty() )
683  *label += ", ";
684  extra_info += NStr::SizetToString(intervals);
685  extra_info += " interval";
686  if (intervals != 1) {
687  extra_info += "s";
688  }
689  }
690  if ( !extra_info.empty() ) {
691  *label += " (";
692  *label += extra_info;
693  *label += ")";
694  }
695  }}
696  break;
697  }
698 }
699 
700 static void s_BreakSeq_loc(const CSeq_loc& loc, vector<CRef<CSeq_loc> >& locs, CScope* scope)
701 {
702  // check: scope is NEEDED [indirectly protected]
703 
704  for (CSeq_loc_CI it(loc, CSeq_loc_CI::eEmpty_Allow); it; ++it) {
705  const CSeq_id& id = it.GetSeq_id();
706 
707  if (id.Which() == CSeq_id::e_not_set) {
708  continue;
709  }
710 
711  unsigned int i;
712  for (i = 0; i < locs.size(); ++i) {
713  if (sequence::IsSameBioseq(*locs[i]->GetId(), it.GetSeq_id(), scope, CScope::eGetBioseq_All))
714  break;
715  }
716 
717  if (i == locs.size()) {
718  locs.push_back(CRef<CSeq_loc>(new CSeq_loc()));
719  }
720 
721  locs[i]->Add(*it.GetRangeAsSeq_loc());
722  }
723 }
724 
725 //
726 // internal processing of seq-loc labels
727 // seq-locs frequently refer to GIs only - we need to use sequence accessions
728 // to make a more friendly label
729 //
730 static inline
731 const CSeq_id* s_GetLabel(const CSeq_loc& loc, string* label,
733  const CSeq_id* last_id = NULL)
734 {
735  // check: scope is NEEDED [indirectly protected]
736 
737  switch (type) {
738  case CLabel::eType:
739  *label += loc.GetThisTypeInfo()->GetName();
740  switch (loc.Which()) {
741  case CSeq_loc::e_Int:
742  *label += ".int";
743  break;
745  *label += ".packed-int";
746  break;
747  case CSeq_loc::e_Mix:
748  *label += ".mix";
749  break;
750  case CSeq_loc::e_Whole:
751  *label += ".whole";
752  break;
753  case CSeq_loc::e_Null:
754  *label += ".null";
755  break;
756 
757  default:
758  break;
759  }
760  return last_id;
761 
762  case CLabel::eUserType:
764  return last_id;
765 
767  /*switch (loc.Which()) {
768  case CSeq_loc::e_Int:
769  *label += "Interval";
770  break;
771  case CSeq_loc::e_Packed_int:
772  *label += "Intervals";
773  break;
774  case CSeq_loc::e_Mix:
775  *label += "Mixed Location";
776  break;
777  case CSeq_loc::e_Whole:
778  *label += "Location";
779  break;
780 
781  default:
782  *label += "Location";
783  break;
784  }*/
785  return last_id;
786 
787  default:
788  break;
789  }
790 
791  switch (loc.Which()) {
792  case CSeq_loc::e_Whole:
793  s_GetSeqLabel(loc.GetWhole(), label, scope, type);
794  return &loc.GetWhole();
795 
796  case CSeq_loc::e_Int:
797  s_GetSeq_intervalLabel(loc.GetInt(), label, scope, type, last_id);
798  return &loc.GetInt().GetId();
799 
801  switch (type) {
804  {{
805  CConstRef<CSeq_id> id(last_id);
806  string str;
808  loc.GetPacked_int().Get()) {
809  const CSeq_interval& ival = **iter;
810  if ( !str.empty() ) {
811  str += ", ";
812  }
813  s_GetSeq_intervalLabel(ival, &str, scope, type, id.GetPointer());
814  id.Reset(&ival.GetId());
815  }
816  *label += str;
817  return id.GetPointer();
818  }}
819 
820  default:
821  s_GetSeq_TotalRangeLabel(loc, label, scope, type);
822  return last_id;
823  }
824 
825  case CSeq_loc::e_Pnt:
826  {{
827  string str = NStr::IntToString(loc.GetPnt().GetPoint() + 1, NStr::fWithCommas);
828  if ( !last_id || !loc.GetPnt().GetId().Match(*last_id) ) {
829  if ( !label->empty() ) {
830  *label += "; ";
831  }
832  s_GetSeqLabel(loc.GetPnt().GetId(), label, scope, type);
833  *label += ": ";
834  } else if ( !label->empty() ) {
835  *label += ", ";
836  }
837  *label += str;
838  return &loc.GetPnt().GetId();
839  }}
840 
842  switch (type) {
845  {{
846  string str;
848  loc.GetPacked_pnt().GetPoints()) {
849  if ( !str.empty() ) {
850  str += ", ";
851  }
853  }
854 
855  if ( !last_id || !loc.GetPnt().GetId().Match(*last_id) ) {
856  if ( !label->empty() ) {
857  *label += "; ";
858  }
859  s_GetSeqLabel(loc.GetPnt().GetId(), label, scope, type);
860  *label += ": ";
861  } else if ( !label->empty() ) {
862  *label += ", ";
863  }
864  *label += str;
865  return &loc.GetPnt().GetId();
866  }}
867 
868  default:
869  s_GetSeq_TotalRangeLabel(loc, label, scope, type);
870  return last_id;
871  }
872 
873  case CSeq_loc::e_Mix:
874  switch (type) {
877  {{
878  string str;
879  ITERATE (CSeq_loc::TMix::Tdata, iter, loc.GetMix().Get()) {
880  if ( !str.empty() ) {
881  str += ", ";
882  }
883  last_id = s_GetLabel(**iter, &str, scope, type, last_id);
884  }
885  *label += str;
886  return last_id;
887  }}
888 
889  default:
890  if (sequence::IsOneBioseq(loc, scope)) {
891  s_GetSeq_TotalRangeLabel(loc, label, scope, type);
892  } else {
893  vector<CRef<CSeq_loc> > locs;
894  s_BreakSeq_loc(loc, locs, scope);
895 
896  for (unsigned int i = 0; i < locs.size(); ++i) {
897  if (i > 0)
898  *label += ";";
899  s_GetSeq_TotalRangeLabel(*locs[i], label, scope, type);
900  }
901  }
902  return last_id;
903  }
904 
905  default:
906  loc.GetLabel(label);
907  return NULL;
908  }
909 }
910 
911 
912 //
913 //
914 // seq-id handler
915 //
916 //
918 {
919 public:
920  void GetLabel(const CObject& obj, string* label,
921  CLabel::ELabelType type, CScope* scope) const
922  {
923  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
924  if (id) {
925  s_GetSeqLabel(*id, label, scope, type);
926  }
927  }
928 };
929 
930 
931 //
932 //
933 // seq-loc handler
934 //
935 //
937 {
938 public:
939  void GetLabel(const CObject& obj, string* label,
940  CLabel::ELabelType type, CScope* scope) const
941  {
942  const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(&obj);
943  if (loc) {
944  string s;
945  s_GetLabel(*loc, &s, scope, type);
946  *label += s;
947  }
948  }
949 };
950 
951 
952 
953 //
954 //
955 // bioseq handler
956 //
957 //
959 {
960 public:
961  void GetLabel(const CObject& obj, string* label,
962  CLabel::ELabelType type, CScope* /*scope*/) const
963  {
964  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&obj);
965  if (bioseq) {
966  switch (type) {
967  case CLabel::eUserType:
969  break;
970 
972  if(bioseq->IsNa()) {
974  } else if(bioseq->IsAa()) {
976  }
977  break;
978 
979  case CLabel::eType:
980  bioseq->GetLabel(label, CBioseq::eType);
981  break;
982  case CLabel::eContent:
983  bioseq->GetLabel(label, CBioseq::eContent);
984  break;
985 
986  default:
990  bioseq->GetLabel(label, CBioseq::eBoth);
991  break;
992  }
993  }
994  }
995 };
996 
997 //
998 //
999 // CVcfVariant handler
1000 //
1001 //
1003 {
1004 public:
1005  void GetLabel(const CObject& obj, string* label,
1006  CLabel::ELabelType type, CScope* scope) const
1007  {
1008  const CVcfVariant* vcf_variant = dynamic_cast<const CVcfVariant*>(&obj);
1009  if (vcf_variant) {
1010  string s;
1011  vcf_variant->GetLabel(s, type);
1012  *label += s;
1013  }
1014  }
1015 };
1016 
1017 
1018 //
1019 // Bioseq_set handler
1020 //
1021 static void s_GetBioseq_setType(const CBioseq_set& bst, string* label)
1022 {
1023  // NB: This table should be kept in synch with CBioseq_set::EClass values
1025  static const TPair sc_Types[] = {
1026  {CBioseq_set::eClass_not_set, "not determined"},
1027  {CBioseq_set::eClass_nuc_prot, "nuc-prot"},
1028  {CBioseq_set::eClass_segset, "segmented"},
1029  {CBioseq_set::eClass_conset, "constructed"},
1030  {CBioseq_set::eClass_parts, "parts"},
1031  {CBioseq_set::eClass_gibb, "geninfo backbone"},
1032  {CBioseq_set::eClass_gi, "geninfo"},
1033  {CBioseq_set::eClass_genbank, "genbank"},
1034  {CBioseq_set::eClass_pir, "pir"},
1035  {CBioseq_set::eClass_pub_set, "publication"},
1036  {CBioseq_set::eClass_equiv, "equivalent maps or seqs"},
1037  {CBioseq_set::eClass_swissprot, "swissprot"},
1039  {CBioseq_set::eClass_mut_set, "mutations"},
1040  {CBioseq_set::eClass_pop_set, "population study"},
1041  {CBioseq_set::eClass_phy_set, "phylogenetic study"},
1042  {CBioseq_set::eClass_eco_set, "ecological sample study"},
1043  {CBioseq_set::eClass_gen_prod_set, "genomic products"},
1044  {CBioseq_set::eClass_wgs_set, "wgs project"},
1045  {CBioseq_set::eClass_other, "other"},
1046  };
1047  typedef CStaticArrayMap<CBioseq_set::TClass, const char*> TBioseq_setTypes;
1048  DEFINE_STATIC_ARRAY_MAP(TBioseq_setTypes, sc_Bioseq_setTypes, sc_Types);
1049 
1050  TBioseq_setTypes::const_iterator i = sc_Bioseq_setTypes.find(bst.GetClass());
1051  *label += (i != sc_Bioseq_setTypes.end()) ?
1052  sc_Bioseq_setTypes.find(bst.GetClass())->second :
1053  CBioseq_set::ENUM_METHOD_NAME(EClass)()->FindName(bst.GetClass(), true);
1054 }
1055 
1056 
1057 static void s_GetIdLabel(const CBioseq_set& bst, string* label, CScope* scope)
1058 {
1059  if (bst.GetSeq_set().empty()) {
1060  return;
1061  }
1062  const CBioseq* lcl = NULL;
1063  vector<string> ids;
1064 
1066  const CBioseq* bsp = NULL;
1067  if ((*it)->IsSeq()) {
1068  bsp = &(*it)->GetSeq();
1069  } else if ((*it)->IsSet()) {
1070  const CBioseq_set& bss = (*it)->GetSet();
1071  try {
1072  switch (bss.GetClass()) {
1074  bsp = &bss.GetNucFromNucProtSet();
1075  break;
1077  bsp = &bss.GetMasterFromSegSet();
1078  break;
1079  default:
1080  break;
1081  }
1082  } catch (CException&) {
1083  bsp = NULL;
1084  }
1085  }
1086  if (bsp != NULL) {
1088  const CTextseq_id* tsip = id->GetTextseq_Id();
1089  if (tsip != NULL && tsip->IsSetAccession()) {
1090  ids.push_back(tsip->GetAccession());
1091  } else if (id->IsLocal() && id->GetLocal().IsStr()) {
1092  if (lcl == NULL) {
1093  lcl = bsp;
1094  }
1095  }
1096  }
1097  }
1098 
1099  sort(ids.begin(), ids.end());
1100  vector<string>::iterator new_end = unique(ids.begin(), ids.end());
1101  if (new_end != ids.end()) {
1102  ids.erase(new_end);
1103  }
1104 
1105  if (!ids.empty()) {
1106  *label += ids.front();
1107  if (ids.size() > 1) {
1108  *label += '-';
1109  *label += ids.back();
1110  }
1111  } else if (lcl != NULL) {
1112  CLabel::GetLabel(*lcl, label, CLabel::eContent, scope);
1113  }
1114 }
1115 
1116 
1117 static void s_GetNucProtContent(const CBioseq_set& bst, string* label, CScope* scope)
1118 {
1120 
1121  try {
1122  const CBioseq& seq = bst.GetNucFromNucProtSet();
1123  CLabel::GetLabel(seq, label, CLabel::eContent, scope);
1124  } catch (CException&) {}
1125 }
1126 
1127 
1128 static void s_GetSegsetContent(const CBioseq_set& bst, string* label, CScope* scope)
1129 {
1131 
1132  try {
1133  const CBioseq& seq = bst.GetMasterFromSegSet();
1134  CLabel::GetLabel(seq, label, CLabel::eContent, scope);
1135  } catch (CException&) {}
1136 }
1137 
1138 static void s_GetGenProdContent(const CBioseq_set& bst, string* label, CScope* scope)
1139 {
1141 
1142  try {
1143  const CBioseq& seq = bst.GetGenomicFromGenProdSet();
1144  CLabel::GetLabel(seq, label, CLabel::eContent, scope);
1145  } catch (CException&) {}
1146 }
1147 
1148 static void s_GetBioseq_setContent(const CBioseq_set& bst, string* label, CScope* scope)
1149 {
1150  switch(bst.GetClass()) {
1152  s_GetNucProtContent(bst, label, scope);
1153  break;
1154 
1156  s_GetSegsetContent(bst, label, scope);
1157  break;
1158 
1163  s_GetIdLabel(bst, label, scope);
1164  break;
1165 
1167  s_GetGenProdContent(bst, label, scope);
1168  break;
1169 
1171  // if just a wrapper return the label of the wrapped Seq-entry
1172  if (bst.GetSeq_set().size() == 1) {
1173  CLabel::GetLabel(*bst.GetSeq_set().front(), label, CLabel::eContent, scope);
1174  } else {
1176  }
1177  break;
1178 
1179  default:
1181  break;
1182  };
1183 }
1184 
1185 static bool s_HasAlignment(const CBioseq_set& bst, CScope* scope)
1186 {
1187  // check: scope is NEEDED [protected]
1188 
1189  if( scope ){
1190  CBioseq_set_Handle bsh = scope->GetBioseq_setHandle(bst);
1191  if( bsh ){
1192  CSeq_entry_Handle tse = bsh.GetTopLevelEntry();
1193 
1194  SAnnotSelector sel;
1195  sel.SetMaxSize(1);
1196  sel.SetLimitTSE(tse);
1197  CAlign_CI align_it(tse, sel);
1198  if (align_it.GetSize() != 0) {
1199  return true;
1200  }
1201  }
1202  }
1203  return false;
1204 }
1205 
1206 
1208 {
1209 public:
1210  void GetLabel(const CObject& obj, string* label,
1211  CLabel::ELabelType type, CScope* scope) const
1212  {
1213  // check: scope is NEEDED [indirectly protected]
1214 
1215  if( !label ) return;
1216 
1217 
1218  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(&obj);
1219  if (bioseq_set) {
1220  switch (type) {
1221  case CLabel::eUserType:
1223  break;
1224 
1225  case CLabel::eUserSubtype: {
1226  switch(bioseq_set->GetClass()) {
1229  break;
1232  break;
1235  break;
1237  bool aln = s_HasAlignment(*bioseq_set, scope);
1240  break;
1241  }
1243  bool aln = s_HasAlignment(*bioseq_set, scope);
1246  break;
1247  }
1249  bool aln = s_HasAlignment(*bioseq_set, scope);
1252  break;
1253  }
1255  bool aln = s_HasAlignment(*bioseq_set, scope);
1258  break;
1259  }
1260  default:
1261  break;
1262  }
1263  break;
1264  }
1265  case CLabel::eType:
1266  s_GetBioseq_setType(*bioseq_set, label);
1267  break;
1268  case CLabel::eContent:
1269  s_GetBioseq_setContent(*bioseq_set, label, scope);
1270  break;
1271 
1272  default:
1275  case CLabel::eDescription:
1276  GetLabel(*bioseq_set, label, CLabel::eType, scope);
1277  *label += ": ";
1278  GetLabel(*bioseq_set, label, CLabel::eContent, scope);
1279  break;
1280  }
1281  }
1282  }
1283 };
1284 
1285 /// handler specific for User-object features
1287 {
1288 public:
1289  void GetLabel(const CObject& obj_in, string* label,
1290  CLabel::ELabelType type, CScope* scope) const
1291  {
1292  if (label == NULL) {
1293  return;
1294  }
1295 
1296  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj_in);
1297  if (feat) {
1298  _ASSERT(feat->GetData().IsUser());
1299  const CUser_object& obj = feat->GetData().GetUser();
1300  const CObject_id& id = obj.GetType();
1301 
1302  switch (type) {
1303  case CLabel::eUserType:
1305  break;
1306 
1307  case CLabel::eUserSubtype:
1308  if (id.IsStr()) {
1309  *label += id.GetStr();
1310  break;
1311  } else if (obj.IsSetClass()) {
1312  *label += obj.GetClass();
1313  break;
1314  }
1315  break;
1316 
1317  case CLabel::eType:
1318  if (id.IsStr()) {
1319  *label += id.GetStr();
1320  break;
1321  } else if (obj.IsSetClass()) {
1322  *label += obj.GetClass();
1323  break;
1324  }
1325  break;
1326 
1329  case CLabel::eDescription:
1330  case CLabel::eContent:
1331  default:
1332  /// for content, we use the product seq-id, if it
1333  /// is available; otherwise, we use the standard text
1334  if (id.IsStr() && id.GetStr() == "clone placement") {
1335  *label += '[';
1336  *label += id.GetStr();
1337  *label += ']';
1338  ///
1339  /// clone placement user objects
1340  ///
1341  CConstRef<CUser_field> field;
1342 
1343  field = obj.GetFieldRef("clone placement.name");
1344  if (field) {
1345  if ( !label->empty() ) {
1346  *label += ' ';
1347  }
1348  *label += "/name=";
1349  *label += field->GetData().GetStr();
1350  }
1351 
1352  field = obj.GetFieldRef("clone placement.type");
1353  if (field) {
1354  if ( !label->empty() ) {
1355  *label += ' ';
1356  }
1357  *label += "/type=";
1358  *label += field->GetData().GetStr();
1359  }
1360 
1361  field = obj.GetFieldRef("clone placement.concordant");
1362  if (field) {
1363  if ( !label->empty() ) {
1364  *label += ' ';
1365  }
1366  *label += "/concordant=";
1367  *label += field->GetData().GetBool() ? "true" : "false";
1368  }
1369  } else if (id.IsStr() &&
1370  NStr::EqualNocase(id.GetStr(), "Display Data") &&
1371  obj.GetFieldRef("name")) {
1372  *label += obj.GetFieldRef("name")->GetData().GetStr();
1373  } else {
1374  /// default handler - the above steps exit early
1376  }
1377  break;
1378  }
1379  }
1380  }
1381 };
1382 
1383 
1384 static int s_GetChildNum(const objects::CSeq_feat& feat)
1385 {
1386  string num_str = feat.GetNamedQual("Child Count");
1387  if ( !num_str.empty() ) {
1388  try {
1389  return NStr::StringToInt(num_str);
1390  } catch (CException&) {
1391  // ingore it
1392  }
1393  }
1394  return -1;
1395 }
1396 
1397 
1398 static bool s_IsLOH(const CVariation_ref& var)
1399 {
1400  if (var.CanGetConsequence()) {
1402  if ((*iter)->IsLoss_of_heterozygosity()) {
1403  return true;
1404  }
1405  }
1406  }
1407  return false;
1408 }
1409 
1410 
1412 {
1413  ITERATE (CVariation_ref::TMethod, iter, method) {
1414  switch (*iter) {
1420  return true;
1421  default:
1422  break;
1423  }
1424  }
1425 
1426  return false;
1427 }
1428 
1429 // seq-feat handler
1431 {
1432 public:
1433  void GetLabel(const CObject& obj, string* label,
1434  CLabel::ELabelType type, CScope* scope) const
1435  {
1436  if (label == NULL) {
1437  return;
1438  }
1439 
1440  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
1441  if ( !feat ) {
1442  return;
1443  }
1444  if (feat->GetData().IsUser()) {
1445  m_UserHandler.GetLabel(obj, label, type, scope);
1446  return;
1447  }
1448 
1449  switch (type) {
1450  case CLabel::eUserType:
1452  break;
1453 
1454  case CLabel::eUserSubtype:
1455  switch (feat->GetData().GetSubtype()) {
1457  *label += "SNP";
1458  break;
1459 
1461  *label += "exon";
1462  break;
1464  *label += "[intron]";
1465  break;
1466 
1467  default:
1468  feature::GetLabel(*feat, label, feature::fFGL_Type, scope);
1469  break;
1470  }
1471  break;
1472 
1473  case CLabel::eType:
1474  /// for type, we just used the standard text
1475  switch (feat->GetData().GetSubtype()) {
1477  *label += "[intron]";
1478  break;
1481  feature::GetLabel(*feat, label, feature::fFGL_Type, scope);
1482  break;
1483 
1484  default:
1485  *label += feat->GetThisTypeInfo()->GetName();
1486  break;
1487  }
1488  break;
1489 
1491  if (feat->IsSetProduct()) {
1492  try {
1493  string s;
1494  const CSeq_id& id = sequence::GetId(feat->GetProduct(), scope);
1495  s_GetSeqLabel(id, &s, scope, CLabel::eContent);
1496  // For proteins, show both the accession and the protein product name.
1498  string product_str;
1500  string type_str;
1501  feature::GetLabel(*feat, &type_str, feature::fFGL_Type, scope);
1502  // Do not append the product if it contains type information only
1503  if (product_str != type_str) {
1504  s += ": ";
1505  s += product_str;
1506  }
1507  }
1508  *label += s;
1509  }
1510  catch (CException&) {
1512  }
1513  }
1514  break;
1515 
1516  case CLabel::eContent:
1517  if (x_UseCustomLabel(*feat)) {
1518  x_GetCustomLabel(*feat, *label);
1519  }
1520  /// for content, we use the product seq-id, if it
1521  /// is available; otherwise, we use the standard text
1522  else if (feat->IsSetProduct()) {
1523  try {
1524  const CSeq_id& id = sequence::GetId(feat->GetProduct(), scope);
1525  s_GetSeqLabel(id, label, scope, CLabel::eContent);
1526  }
1527  catch (CException&) {
1529  }
1530  } else {
1531  switch (feat->GetData().GetSubtype()) {
1533  {{ // logic borrowed from misc_feature
1534  bool got_label = false;
1535  if (feat->IsSetQual()) {
1536  ITERATE(CSeq_feat::TQual, it, feat->GetQual()) {
1537  if (NStr::EqualNocase((*it)->GetQual(),"Name") ||
1538  NStr::EqualNocase((*it)->GetQual(),"ID")) {
1539  *label = (*it)->GetVal();
1540  got_label = true;
1541  if (NStr::EqualNocase((*it)->GetQual(),"Name"))
1542  break;
1543  }
1544  }
1545  }
1546  if (!got_label) {
1548  *label += " ";
1549  if (feat->GetData().GetImp().IsSetDescr()) {
1550  *label += feat->GetData().GetImp().GetDescr();
1551  }
1552  }
1553  if (label->size() > 30) *label = label->substr(0, 30) + "...";
1554  }}
1555  break;
1556 
1558  if (feat->GetData().GetSite() == CSeqFeatData::eSite_other &&
1559  feat->IsSetComment()) {
1560  *label += feat->GetComment();
1561  } else {
1563  }
1564  break;
1565 
1567  {{
1568  *label += "exon";
1569  const string& q = feat->GetNamedQual("number");
1570  if ( !q.empty() ) {
1571  *label += " ";
1572  *label += q;
1573  }
1574  }}
1575  break;
1577  {{
1578  *label += "[intron]";
1579  }}
1580  break;
1582  {{
1583  /// RSID first
1584  NSnp::TRsid Rsid(NSnp::GetRsid(*feat));
1585  if(Rsid) {
1586  *label += "rs";
1587  *label += NStr::NumericToString(Rsid);
1588  }
1589  else {
1590  if (label->empty() && feat->IsSetComment()) {
1591  *label += feat->GetComment();
1592  }
1593  }
1594  }}
1595  break;
1596 
1598  {{
1599  const CVariation_ref& var = feat->GetData().GetVariation();
1600  if (var.CanGetId()) {
1601  if (var.GetId().GetTag().IsId()) {
1602  *label += var.GetId().GetDb() + "|";
1603  *label += NStr::IntToString(var.GetId().GetTag().GetId());
1604  } else {
1605  *label += var.GetId().GetTag().GetStr();
1606  }
1607  } else {
1608  if (feat->CanGetLocation()) {
1609  const CSeq_loc& loc = feat->GetLocation();
1611  }
1612 
1613  //feature::GetLabel(*feat, label, feature::fFGL_Both, scope);
1614  }
1615  }}
1616  break;
1617 
1619  {{
1620  bool got_label = false;
1621  if (feat->IsSetQual()) {
1622  ITERATE(CSeq_feat::TQual, it, feat->GetQual()) {
1623  if (NStr::EqualNocase((*it)->GetQual(),"Name") ||
1624  NStr::EqualNocase((*it)->GetQual(),"ID")) {
1625  *label += (*it)->GetVal();
1626  got_label = true;
1627  break;
1628  }
1629  }
1630  }
1631  if ( !got_label ) {
1633  }
1634  }}
1635  break;
1636 
1638  {{
1639  const CSeqFeatData::TClone& clone = feat->GetData().GetClone();
1640  if (clone.IsSetName()) {
1641  *label += clone.GetName();
1642  } else {
1644  }
1645  }}
1646  break;
1647 
1649  {{
1650  if (feat->CanGetTitle()) {
1651  *label += feat->GetTitle();
1652  } else {
1653  s_GetSeq_TotalRangeLabel(feat->GetData().GetSeq(), label, scope, type);
1654  }
1655  }}
1656  break;
1657 
1658  default:
1660  break;
1661  }
1662  }
1663  break;
1664 
1666  case CLabel::eDescription:
1667  /// the brief description contains:
1668  /// - the label containing both type and content
1669  /// - a line showing feature lengths
1670  switch (feat->GetData().GetSubtype()) {
1672  {{
1673  const CVariation_ref& var = feat->GetData().GetVariation();
1674  string validation = "Not Tested";
1675  if (var.IsSetValidated()) {
1676  if (var.GetValidated()) {
1677  validation = "Yes";
1678  } else {
1679  validation = "Fail";
1680  }
1681  } else if (var.IsSetVariant_prop() && var.GetVariant_prop().IsSetOther_validation()) {
1682  if (var.GetVariant_prop().GetOther_validation()) {
1683  validation = "Yes";
1684  } else {
1685  validation = "Fail";
1686  }
1687  }
1688 
1689  // phenotype and clinical-significance
1690  string phenotype = "";
1691  string clinical_sig = "";
1692  if (var.CanGetPhenotype()) {
1693  ITERATE (CVariation_ref::TPhenotype, pnt_iter, var.GetPhenotype()) {
1694  if (clinical_sig.empty() && (*pnt_iter)->CanGetClinical_significance()) {
1695  clinical_sig = NSnp::ClinSigAsString((*pnt_iter)->GetClinical_significance());
1696  }
1697 
1698  if (phenotype.empty() && (*pnt_iter)->CanGetTerm()) {
1699  phenotype = (*pnt_iter)->GetTerm();
1700  }
1701  }
1702  }
1703 
1704  string sample_sex = "";
1705  if (var.CanGetSomatic_origin()) {
1707  if ((*so_iter)->CanGetSource() &&
1708  (*so_iter)->GetSource().GetSubtype() == CSubSource::eSubtype_sex) {
1709  sample_sex = (*so_iter)->GetSource().GetName();
1710  break;
1711  }
1712  }
1713  }
1714 
1715  bool is_sv = (var.IsSetId() && var.GetId().GetTag().IsStr() &&
1716  var.GetId().GetTag().GetStr().find("sv") == 1);
1717 
1718  // allele type
1719  string variant_type;
1720  if (s_IsLOH(var)) {
1721  variant_type = "LOH";
1722  } else if (var.IsComplex()) {
1723  variant_type = "Complex";
1724  } else if (var.IsUniparentalDisomy()) {
1725  variant_type = "UPD";
1726  } else if (var.IsInsertion()) {
1727  variant_type = "Insertion";
1728  } else if (var.IsGain()) {
1729  if (var.CanGetMethod() && s_IsCopyNumberMethod(var.GetMethod())) {
1730  variant_type = "Copy number gain";
1731  } else {
1732  variant_type = "Duplication";
1733  }
1734  } else if (var.IsLoss()) {
1735  if (var.CanGetMethod() && s_IsCopyNumberMethod(var.GetMethod())) {
1736  variant_type = "Copy number loss";
1737  } else {
1738  variant_type = "Deletion";
1739  }
1740  } else if (var.IsDeletion()) {
1741  if (var.CanGetMethod() && s_IsCopyNumberMethod(var.GetMethod())) {
1742  variant_type = "Copy number loss";
1743  } else {
1744  variant_type = "Deletion";
1745  }
1746  } else if (var.IsInversion()) {
1747  variant_type = "Inversion";
1748  } else if (var.IsEversion()) {
1749  variant_type = "Tandem duplication";
1750  } else if (var.IsTranslocation()) {
1751  variant_type = "Translocation";
1752  } else if (var.IsDeletionInsertion()) {
1753  variant_type = "Indel";
1754  } else if (var.IsUnknown()) {
1755  variant_type = "Unknown";
1756  } else if (var.IsCNV()) {
1757  variant_type = "Copy number variation";
1758  } else {
1759  variant_type = "Other";
1760  }
1761 
1762  if (is_sv) {
1763  int child_num = s_GetChildNum(*feat);
1764  if (child_num == 0) {
1765  // sv, but treated as ssv
1766  is_sv = false;
1767  } else {
1768  if (child_num > 0) {
1769  *label += "Number of Supporting Variant Calls: ";
1770  *label += NStr::IntToString(child_num);
1771  *label += "\n";
1772  }
1773  *label += "Variant Region Type: ";
1774  *label += variant_type;
1775  if ( !phenotype.empty() ) {
1776  *label += "\nPhenotype: " + phenotype;
1777  }
1778  if ( !clinical_sig.empty() ) {
1779  *label += "\nClinical Interpretation: ";
1780  *label += clinical_sig;
1781  }
1782  if ( !sample_sex.empty() ) {
1783  *label += "\nGender: ";
1784  *label += sample_sex;
1785  }
1786  *label += "\nValidation Status: " + validation;
1787  *label += "\nTotal Length: ";
1789  feat->GetLocation().GetTotalRange().GetLength(),
1791  }
1792  }
1793 
1794  if ( !is_sv ) {
1795  if (var.CanGetParent_id()) {
1796  *label += "Parent Variant Region: ";
1797  if (var.GetParent_id().GetTag().IsId()) {
1799  } else {
1800  *label += var.GetParent_id().GetTag().GetStr();
1801  }
1802  *label += "\n";
1803  }
1804 
1805 
1806  *label += "Variant Call Type: ";
1807  *label += variant_type;
1808 
1809  if ( !phenotype.empty() ) {
1810  *label += "\nPhenotype: " + phenotype;
1811  }
1812  if ( !clinical_sig.empty() ) {
1813  *label += "\nClinical Interpretation: ";
1814  *label += clinical_sig;
1815  }
1816  if ( !sample_sex.empty() ) {
1817  *label += "\nGender: ";
1818  *label += sample_sex;
1819  }
1820 
1821  // inheritance
1823  if (var.IsSetAllele_origin()) {
1824  org = var.GetAllele_origin();
1825  } else if (var.IsSetVariant_prop() && var.GetVariant_prop().IsSetAllele_origin()) {
1826  org = var.GetVariant_prop().GetAllele_origin();
1827  }
1828 
1829  if (org > 0) {
1830  string inh;
1832  inh += "somatic ";
1833  }
1835  inh += "inherited ";
1836  }
1838  inh += "paternal ";
1839  }
1841  inh += "maternal ";
1842  }
1844  inh += "de_novo ";
1845  }
1847  inh += "biparental ";
1848  }
1850  inh += "uniparental ";
1851  }
1853  inh += "not-tested ";
1854  }
1856  inh += "tested-inconclusive ";
1857  }
1859  inh += "other";
1860  }
1861 
1863  inh = "unknown";
1864  }
1865 
1866  *label += "\nInheritance: " + inh;
1867  }
1868 
1869  // validation status
1870  *label += "\nValidation Status: " + validation;
1871 
1872  if (feat->CanGetComment()) {
1873  *label += "\n" + feat->GetComment();
1874  }
1875  }
1876 
1877  int allele_len = -1;
1878  if (var.GetData().IsInstance() && var.GetData().GetInstance().IsSetDelta()) {
1881  if ((*iter)->IsSetSeq() && (*iter)->GetSeq().IsLiteral()) {
1882  allele_len = (*iter)->GetSeq().GetLiteral().GetLength();
1883  break;
1884  }
1885  }
1886  }
1887  if (allele_len > -1) {
1888  *label += "\nAllele length: " + NStr::NumericToString(allele_len, NStr::fWithCommas);
1889  }
1890 
1891  }}
1892  break;
1893 
1895  {{
1896  const CSeqFeatData::TClone& clone = feat->GetData().GetClone();
1897  *label += "Length: ";
1900  *label += "\nStart: ";
1903  *label += ", Stop: ";
1906  if (clone.IsSetPlacement_method()) {
1907  const CEnumeratedTypeValues* type_val =
1908  CClone_ref::GetTypeInfo_enum_EPlacement_method();
1909  if (type_val) {
1910  string method = type_val->FindName(clone.GetPlacement_method(), true);
1911  if ( !method.empty() ) {
1912  *label += "\nPlacement method: " + method;
1913  }
1914  }
1915  }
1916  if (clone.IsSetConcordant()) {
1917  *label += "\nClone placement: ";
1918  *label += clone.GetConcordant() ? "concordant" : "discordant";
1919  }
1920  if (clone.IsSetUnique()) {
1921  *label += "\nClone placement: ";
1922  *label += clone.GetUnique() ? "unique" : "multiple";
1923  }
1924  if (clone.IsSetClone_seq()) {
1925  typedef map<int, vector<string> > TEndMap;
1926  TEndMap end_map;
1927  const CClone_ref::TClone_seq::Tdata& ends = clone.GetClone_seq().Get();
1928  ITERATE (CClone_ref::TClone_seq::Tdata, e_iter, ends) {
1929  const CClone_seq& seq = **e_iter;
1930  if (seq.CanGetSeq() && seq.CanGetSupport()) {
1931  const CSeq_id* id = seq.GetSeq().GetId();
1932  if( id ){
1933  CSeq_id_Handle idh;
1934  string id_str;
1935  if( scope ){
1936  idh = sequence::GetId( *id, *scope );
1937  if( idh ){
1939  if( idhb ){
1940  idh = idhb;
1941  }
1942  }
1943  }
1944  if( idh ){
1945  CConstRef<CSeq_id> seq_id_ref = idh.GetSeqId();
1946  seq_id_ref->GetLabel( &id_str, CSeq_id::eContent );
1947  } else {
1948  id->GetLabel(&id_str);
1949  }
1950  end_map[seq.GetSupport()].push_back(id_str);
1951  }
1952  }
1953  }
1954 
1955  if (end_map.count(CClone_seq::eSupport_prototype) > 0) {
1957  }
1958 
1959  if (end_map.count(CClone_seq::eSupport_supporting) > 0) {
1960  *label += "\nSupporting (" +
1962  "): ";
1964  }
1965 
1966  if (end_map.count(CClone_seq::eSupport_non_supporting) > 0) {
1967  *label += "\nNon-supporting (" +
1969  "): ";
1971  }
1972 
1973  if (end_map.count(CClone_seq::eSupport_supports_other) > 0) {
1974  *label += "\nSupports other (" +
1976  "): ";
1978  }
1979  }
1980  }}
1981  break;
1982 
1985  break;
1986 
1989  *label += " ";
1990  if (feat->GetData().GetImp().IsSetDescr()) {
1991  *label += feat->GetData().GetImp().GetDescr();
1992  }
1993  break;
1994 
1997  GetLabel(obj, label, CLabel::eContent, scope);
1998  break;
1999 
2001  {{
2002  feature::GetLabel(*feat, label, feature::fFGL_Type, scope);
2003  *label += " ";
2004  *label += CGUIUserType::sm_Tp_Feature + " : ";
2006  if (feat->IsSetQual()) {
2007  ITERATE(CSeq_feat::TQual, it, feat->GetQual()) {
2008  *label += "\n" + (*it)->GetQual() + ": " + (*it)->GetVal();
2009  }
2010  }
2011  }}
2012  break;
2013 
2015  {{
2016  *label += "Refers to: ";
2017  if (feat->CanGetTitle()) {
2018  *label += feat->GetTitle();
2019  } else {
2020  s_GetSeq_TotalRangeLabel(feat->GetData().GetSeq(), label, scope, type);
2021  }
2022  if (feat->IsSetQual()) {
2023  ITERATE(CSeq_feat::TQual, it, feat->GetQual()) {
2024  *label += "\n" + (*it)->GetQual() + ": " + (*it)->GetVal();
2025  }
2026  }
2027  }}
2028  break;
2029 
2031  if (feat->GetData().GetSite() == CSeqFeatData::eSite_other &&
2032  feat->IsSetComment()) {
2033  *label += "[Site] ";
2034  *label += feat->GetComment();
2035  } else {
2037  }
2038  break;
2039 
2040  default:
2041  feature::GetLabel(*feat, label, feature::fFGL_Type, scope);
2042  *label += " ";
2043  *label += CGUIUserType::sm_Tp_Feature + " : ";
2045  break;
2046  }
2047  break;
2048 
2050  default:
2051  if (x_UseCustomLabel(*feat)) {
2052  x_GetCustomLabel(*feat, *label);
2053  }
2054  /// for both, we use a modified construct of the base text
2055  else if (feat->IsSetProduct()) {
2056  try {
2057  string s;
2058  const CSeq_id& id = sequence::GetId(feat->GetProduct(), scope);
2059  s_GetSeqLabel(id, &s, scope, CLabel::eContent);
2060  if (!feat->GetData().IsRna()) {
2061  string product_str;
2062  string type_str;
2064  feature::GetLabel(*feat, &type_str, feature::fFGL_Type, scope);
2065  // Do not append the product if it contains type information only
2066  if (product_str != type_str) {
2067  s += ": ";
2068  s += product_str;
2069  }
2070 
2071  }
2072  *label += s;
2073  }
2074  catch (CException&) {
2076  }
2077  } else {
2078  switch (feat->GetData().GetSubtype()) {
2081  break;
2082 
2085  *label += " ";
2086  if (feat->GetData().GetImp().IsSetDescr()) {
2087  *label += feat->GetData().GetImp().GetDescr();
2088  }
2089  break;
2090 
2093  GetLabel(obj, label, CLabel::eContent, scope);
2094  break;
2095 
2097  feature::GetLabel(*feat, label,
2101  if (feat->IsSetQual()) {
2102  ITERATE(CSeq_feat::TQual, it, feat->GetQual()) {
2103  *label += "\n" + (*it)->GetQual() + ": " + (*it)->GetVal();
2104  }
2105  }
2106  break;
2107 
2109  if (feat->GetData().GetSite() == CSeqFeatData::eSite_other &&
2110  feat->IsSetComment()) {
2111  *label += "[Site] ";
2112  *label += feat->GetComment();
2113  } else {
2115  }
2116 
2117  break;
2118 
2120  {{
2121  CSnpBitfield bf_interp(*feat);
2122  if (bf_interp.isGood()) {
2123  string tag(bf_interp.GetVariationClassString());
2124  *label += tag;
2125  *label += " rs";
2127  } else {
2128  feature::GetLabel(*feat, label,
2132  }
2133 
2134  if (feat->IsSetQual()) {
2135  ///
2136  /// alleles come next
2137  NSnp::TAlleles Alleles;
2138  NSnp::GetAlleles(*feat, Alleles);
2139  if(!Alleles.empty()) {
2140  if ( !label->empty() ) {
2141  *label += "; ";
2142  }
2143  *label += "Alleles: ";
2144  *label += NStr::Join(Alleles, "/");
2145  /// Add length of allele for insertion/deletion types
2146  ///
2147  if (bf_interp.isGood() && (bf_interp.IsTrue(CSnpBitfield::eDips) || bf_interp.IsTrue(CSnpBitfield::eDeletion))) {
2148  int length = NSnp::GetLength(*feat);
2149  *label += "; deletion length=";
2150  *label += NStr::IntToString(length);
2151 
2152  }
2153  }
2154  }
2155  }}
2156  break;
2157 
2159  {{
2160  const CVariation_ref& var = feat->GetData().GetVariation();
2161  if (var.CanGetId()) {
2162  *label += "[" + var.GetId().GetDb() + "] ";
2163  if (var.GetId().GetTag().IsId()) {
2164  *label += NStr::IntToString(var.GetId().GetTag().GetId());
2165  } else {
2166  *label += var.GetId().GetTag().GetStr();
2167  }
2168  }
2169  ITERATE (CSeq_feat::TQual, iter, feat->GetQual()) {
2170  const CGb_qual& qual = **iter;
2171  *label += " " + qual.GetQual();
2172  if ( !qual.GetVal().empty() ) {
2173  *label += "=" + qual.GetVal();
2174  }
2175  }
2176  }}
2177  break;
2178 
2180  {{
2181  const CSeqFeatData::TClone& clone = feat->GetData().GetClone();
2182  if (clone.IsSetName()) {
2183  *label += clone.GetName();
2184  } else {
2186  }
2187  }}
2188  break;
2189 
2191  {{
2192  if (feat->CanGetTitle()) {
2193  *label += feat->GetTitle();
2194  } else {
2195  s_GetSeq_TotalRangeLabel(feat->GetData().GetSeq(), label, scope, type);
2196  }
2197  }}
2198  break;
2199 
2200  default:
2201  feature::GetLabel(*feat, label,
2205  break;
2206  }
2207  }
2208  break;
2209  }
2210  }
2211 protected:
2212  bool x_UseCustomLabel(const objects::CSeq_feat &feat) const;
2213  void x_GetCustomLabel(const objects::CSeq_feat &feat, string& label) const;
2214  void x_LabelFromQualifiers(const objects::CSeq_feat &feat, string& label) const;
2215  bool x_IncludeFeatureTypeInLabel(const objects::CSeq_feat &feat) const;
2216 private:
2218 };
2219 
2220 
2222 {
2226 
2227  return subtypes.end() != subtypes.find(feat.GetData().GetSubtype());
2228 }
2229 
2230 void CSeq_featHandler::x_GetCustomLabel(const CSeq_feat &feat, string& label) const
2231 {
2232  CSeqFeatData::ESubtype subtype = feat.GetData().GetSubtype();
2233  if (x_IncludeFeatureTypeInLabel(feat) && ((subtype != CSeqFeatData::eSubtype_misc_feature) && (subtype != CSeqFeatData::eSubtype_region))) // Add the subtype only for features that do not have specific qualifiers
2235  string second_part;
2236  if (feat.GetData().IsRegion()) {
2237  second_part = feat.GetData().GetRegion();
2238  }
2239  else {
2240  x_LabelFromQualifiers(feat, second_part);
2241  }
2242  if (second_part.empty() && feat.IsSetComment()) {
2243  second_part = feat.GetComment();
2244  size_t pos = second_part.find(';');
2245  if (pos != string::npos)
2246  second_part = second_part.substr(0, pos);
2247  }
2248  if (!second_part.empty()) {
2249  if (!label.empty())
2250  label += ": ";
2251  label += second_part;
2252  }
2253  if (label.empty())
2255 }
2256 
2258 {
2259  static vector<string> quals{ "regulatory_class", "recombination_class", "feat_class", "bound_moiety", "mobile_element_type", "mobile_element", "rpt_type",
2260  "satellite", "rpt_family", "mod_base", "operon", "standard_name", "allele" };
2261 
2262  for (const auto &qual_name : quals) {
2263  const string &value = feat.GetNamedQual(qual_name);
2264  if (value.empty())
2265  continue;
2266 
2267  label = value;
2268  break;
2269  }
2270 }
2271 
2272 bool CSeq_featHandler::x_IncludeFeatureTypeInLabel(const objects::CSeq_feat &feat) const
2273 {
2274  static vector<string> class_quals{ "feat_class", "regulatory_class", "recombination_class", "mobile_element_type", "mobile_element", "rpt_type", "satellite", "rpt_family" };
2275  for (const auto &qual_name : class_quals) {
2276  const string &value = feat.GetNamedQual(qual_name);
2277  if (!value.empty())
2278  return false;
2279  }
2280  return true;
2281 }
2282 
2283 //
2284 //
2285 // seq-entry handler
2286 //
2287 //
2289 {
2290 public:
2291  void GetLabel(const CObject& obj, string* label,
2292  CLabel::ELabelType type, CScope* scope) const
2293  {
2294  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*>(&obj);
2295  if (entry) {
2296  if (entry->IsSet()) {
2297  CLabel::GetLabel(entry->GetSet(), label, type, scope);
2298  } else {
2299  CLabel::GetLabel(entry->GetSeq(), label, type, scope);
2300  }
2301  }
2302  }
2303 };
2304 
2305 
2306 static void s_GetAlignmentType(const CSeq_align& align, string* label)
2307 {
2308  switch (align.GetSegs().Which()) {
2309  default:
2311  *label += "[Unknown]";
2312  break;
2314  *label += "[Dense-seg]";
2315  break;
2317  *label += "[Dense-diag]";
2318  break;
2320  *label += "[Standard-seg]";
2321  break;
2323  *label += "[Packed-seg]";
2324  break;
2326  *label += "[Discontinuous]";
2327  break;
2328  }
2329 }
2330 
2331 
2332 static void s_GetAlignmentContent(const CSeq_align& align, string* label,
2333  CScope* scope)
2334 {
2335  const CSeq_align::TSegs& asegs = align.GetSegs();
2336  CSeq_align::TSegs::E_Choice asegs_type = asegs.Which();
2337  switch (asegs_type) {
2338  default:
2340  *label += "unknown contents";
2341  break;
2343  {{
2344  const CSeq_align::TSegs::TSpliced& spliced = asegs.GetSpliced();
2345  if (spliced.CanGetProduct_id()) {
2346  const CSeq_id& product_id = spliced.GetProduct_id();
2347  string str;
2348  s_GetSeqLabel(product_id, &str, scope, CLabel::eContent);
2349  *label += str;
2350  *label += " x ";
2351  }
2352  if (spliced.CanGetGenomic_id()) {
2353  const CSeq_id& genomic_id = spliced.GetGenomic_id();
2354  string str;
2355  s_GetSeqLabel(genomic_id, &str, scope, CLabel::eContent);
2356  *label += str;
2357  }
2358  }}
2359  break;
2361  {{
2362  string str;
2363  size_t seqs = align.GetSegs().GetDenseg().GetIds().size();
2364  if (seqs < 4) {
2365  set<CSeq_id_Handle> handle_set;
2366  ITERATE (CDense_seg::TIds, id_iter, align.GetSegs().GetDenseg().GetIds()) {
2367  CSeq_id_Handle sih = CSeq_id_Handle::GetHandle(**id_iter);
2368  if ( !handle_set.insert(sih).second ) {
2369  continue;
2370  }
2371 
2372  if ( !str.empty() ) {
2373  str += " x ";
2374  }
2375  s_GetSeqLabel(*sih.GetSeqId(), &str, scope, CLabel::eContent);
2376  }
2377 
2378  if( handle_set.size() == 1 ){
2379  str += " x " + str;
2380  }
2381 
2382  } else {
2383  str = NStr::SizetToString(seqs, NStr::fWithCommas) + " sequences.";
2384  }
2385 
2386  *label += str;
2387  }}
2388  break;
2390  *label += "[Dense-diag]";
2391  break;
2393  *label += "[Standard-seg]";
2394  break;
2396  *label += "[Packed-seg]";
2397  break;
2399  *label += "[Sparse-seg]";
2400  break;
2402  {{
2403  string str;
2404  set<CSeq_id_Handle> handle_set;
2405  CTypeConstIterator<CSeq_id> id_iter(align.GetSegs());
2406  for ( ; id_iter; ++id_iter) {
2407  CSeq_id_Handle sih = CSeq_id_Handle::GetHandle(*id_iter);
2408  if ( !handle_set.insert(sih).second ) {
2409  continue;
2410  }
2411 
2412  if ( !str.empty() ) {
2413  str += " x ";
2414  }
2415  s_GetSeqLabel(*sih.GetSeqId(), &str, scope, CLabel::eContent);
2416  }
2417 
2418  *label += str;
2419  if (handle_set.size() == 1) { // paralogous alignment
2420  *label += " x ";
2421  *label += str;
2422  }
2423  }}
2424  break;
2425  }
2426 }
2427 
2428 static size_t s_CountSegments(const CSeq_align& align)
2429 {
2430  switch (align.GetSegs().Which()) {
2431  default:
2432  return 1;
2433 
2435  return align.GetSegs().GetDisc().Get().size();
2436 
2438  return align.GetSegs().GetSpliced().GetExons().size();
2439  }
2440 }
2441 
2442 
2443 
2444 static void s_GetAlignmentTooltip(const CSeq_align& align, string* label,
2445  CScope* scope)
2446 {
2447  const CSeq_align::TDim num_rows_limit = 10;
2448 
2449  ///
2450  /// first, format our seq-ids
2451  ///
2452  vector<bool> strands;
2453  CSeq_align::TDim num_rows = align.CheckNumRows();
2454  {{
2455  string ids;
2456  CSeq_align::TDim i = 0;
2457  for(; i < num_rows; ++i ){
2459  if( scope ){
2460  CSeq_id_Handle idh_best = sequence::GetId( idh, *scope, sequence::eGetId_Best);
2461  if( idh_best ){
2462  idh = idh_best;
2463  }
2464  }
2465 
2466  if ( !ids.empty() ) {
2467  ids += " x ";
2468  }
2469  CConstRef<CSeq_id> seq_id(idh.GetSeqIdOrNull());
2470  if (!seq_id) {
2471  ids = "UNK";
2472  }
2473  else {
2474  idh.GetSeqId()->GetLabel(&ids, CSeq_id::eContent);
2475  }
2476 
2477  TSeqRange range = align.GetSeqRange(i);
2478  ids += " (";
2479  ids += NStr::IntToString(range.GetFrom() + 1, NStr::fWithCommas);
2480  ids += "..";
2481  ids += NStr::IntToString(range.GetTo() + 1, NStr::fWithCommas);
2482  ids += ")";
2483 
2484  try {
2485  strands.push_back(align.GetSeqStrand(i) == eNa_strand_plus);
2486  } catch (CException&) {
2487  // ignore the exception
2488  }
2489  // break out of the loop to avoid long (slow) tooltips
2490  if (i > num_rows_limit)
2491  break;
2492  }
2493 
2494  *label += ids;
2495 
2496  if (i < num_rows) { // early escape?
2497  *label += " x ... [ total ";
2498  *label += NStr::IntToString(num_rows, NStr::fWithCommas);
2499  *label += "]";
2500  return;
2501  }
2502  }}
2503 
2504  /// only report strand for pair-wise alignments
2505  if (num_rows == 2 && strands.size() == 2) {
2506  *label += "\nStrand: ";
2507  *label += strands[0] == strands[1] ? "forward" : "reverse";
2508  }
2509 
2510  ///
2511  /// next, add a remark about the total aligned range
2512  ///
2513  CScoreBuilder builder;
2514  // new method
2515  TSeqPos align_length = builder.GetAlignLength(align);
2516  *label += "\nAligned bases: ";
2517  *label += NStr::IntToString(align_length, NStr::fWithCommas);
2518 
2519  size_t segs = s_CountSegments(align);
2520  *label += "\nAligned segments: ";
2522 
2523  char buf[255];
2524  double coverage = 0.0;
2525  *label += "\nCoverage: ";
2526  if ( !align.GetNamedScore(CSeq_align::eScore_PercentCoverage, coverage) && scope ){
2527  coverage = builder.GetPercentCoverage( *scope, align );
2528  }
2529  if (coverage < 100.0 && coverage > 99.9) {
2530  *label += "99.9+";
2531  } else {
2532  sprintf(buf, "%2.1f", coverage);
2533  *label += buf;
2534  }
2535  *label += "%";
2536 
2537  if (align_length < 1000000) {
2538  //int identities = builder.GetIdentityCount(*scope, align);
2539  //int mismatches = builder.GetMismatchCount(*scope, align);
2540  int identities = 0;
2541  int mismatches = 0;
2542  if (
2543  !( align.GetNamedScore(CSeq_align::eScore_IdentityCount, identities)
2544  && align.GetNamedScore(CSeq_align::eScore_MismatchCount, mismatches)
2545  )
2546  && scope
2547  ){
2548  builder.GetMismatchCount(*scope, align, identities, mismatches);
2549  }
2550 
2551  double identity = 0.0;
2552  *label += "\nIdentity: ";
2553  if ( !align.GetNamedScore(CSeq_align::eScore_PercentIdentity, identity) ) {
2554  identity = identities * 100.0 / align_length;
2555  }
2556  if (identity < 100.0 && identity > 99.9) {
2557  *label += "99.9+";
2558  } else {
2559  sprintf(buf, "%2.1f", identity);
2560  *label += buf;
2561  }
2562  *label += "%";
2563 
2564 
2565  *label += "\nMismatches: ";
2566  *label += NStr::IntToString(mismatches, NStr::fWithCommas);
2567  }
2568  int gap_count = builder.GetGapCount(align);
2569  *label += "\nGaps: ";
2570  *label += NStr::IntToString(gap_count, NStr::fWithCommas);
2571 
2572 #if 0
2573  switch (align.GetSegs().Which()) {
2574  default:
2579  s_GetAlignmentContent(align, label, scope);
2580  break;
2581 
2583  {{
2584  string s;
2585  size_t count = 0;
2587  if ( !s.empty() ) {
2588  s += '\n';
2589  }
2590  s += NStr::IntToString(++count) + ") ";
2591  s_GetAlignmentTooltip(**iter, &s, scope);
2592  }
2593  *label += s;
2594  }}
2595  break;
2596 
2598  {{
2599  size_t seqs = align.GetSegs().GetDenseg().GetIds().size();
2600  if (seqs != 2) {
2601  s_GetAlignmentContent(align, label, scope);
2602  break;
2603  }
2604 
2605  //
2606  // pairwise alignment
2607  //
2608  const CSeq_id& id1 = *align.GetSegs().GetDenseg().GetIds().front();
2609  const CSeq_id& id2 = *align.GetSegs().GetDenseg().GetIds().back();
2610 
2611  string str;
2612  int mate_ti = 0;
2613  if (align.GetNamedScore("matepair ti", mate_ti) ||
2614  align.GetNamedScore("bad matepair ti", mate_ti)) {
2615  //
2616  // "good" mate pair
2617  //
2618  const CSeq_id* id_trace = &id1;
2619  if (id2.IsGeneral() &&
2620  (id2.GetGeneral().GetDb() == "ti" ||
2621  id2.GetGeneral().GetDb() == "TRACE")) {
2622  id_trace = &id2;
2623  }
2624 
2625  str = "Trace: ";
2626  s_GetSeqLabel(*id_trace, &str, scope, CLabel::eContent);
2627  str += "\nMate: ti|";
2628  str += NStr::SizetToString((unsigned int)mate_ti);
2629 
2630  int code = 0;
2631  if (align.GetNamedScore("bad matepair code", code)) {
2632  switch (code) {
2633  case 1:
2634  str += "\nError: Mate has wrong orientation";
2635  break;
2636  case 2:
2637  str += "\nError: Trace has non-unique placement";
2638  break;
2639  case 3:
2640  str += "\nError: Mate lies outside expected distance from trace";
2641  break;
2642  default:
2643  str += "\nError Code: ";
2645  break;
2646  }
2647  }
2648  } else {
2649  size_t count = 0;
2650  ITERATE (CDense_seg::TIds, iter, align.GetSegs().GetDenseg().GetIds()) {
2651  if ( !str.empty() ) {
2652  str += " x ";
2653  }
2654  s_GetSeqLabel(**iter, &str, scope, CLabel::eContent);
2655 
2656  TSeqRange range = align.GetSegs().GetDenseg().GetSeqRange(count++);
2657  str += " [";
2658  str += NStr::IntToString(range.GetFrom() + 1, NStr::fWithCommas);
2659  str += "-";
2660  str += NStr::IntToString(range.GetTo() + 1, NStr::fWithCommas);
2661  str += "]";
2662  }
2663 
2664  /// compose scores if they exist
2665  string score_str;
2666  if (align.IsSetScore()) {
2667  ITERATE (CSeq_align::TScore, iter, align.GetScore()) {
2668  score_str += ' ';
2669  const CScore& score = **iter;
2670  if (score.IsSetId()) {
2671  if (score.GetId().IsId()) {
2672  score_str += NStr::IntToString(score.GetId().GetId());
2673  } else {
2674  score_str += score.GetId().GetStr();
2675  }
2676  score_str += '=';
2677  }
2678  if (score.GetValue().IsReal()) {
2679  score_str += NStr::DoubleToString(score.GetValue().GetReal());
2680  } else {
2681  score_str += NStr::DoubleToString(score.GetValue().GetInt());
2682  }
2683  }
2684  } else {
2685  score_str = " (no scores)";
2686  }
2687  str += score_str;
2688  }
2689 
2690  *label += str;
2691  }}
2692  break;
2693  }
2694 #endif
2695 }
2696 
2697 
2699 {
2700 public:
2701  void GetLabel(const CObject& obj, string* label,
2702  CLabel::ELabelType type, CScope* scope) const
2703  {
2704  // check: scope is NEEDED [indirectly protected]
2705 
2706  const CSeq_align* align = dynamic_cast<const CSeq_align*> (&obj);
2707  if( !align ) return;
2708 
2709  switch (type) {
2710  case CLabel::eUserType:
2712  break;
2713 
2714  case CLabel::eUserSubtype:
2715  *label += "";
2716  break;
2717 
2718  case CLabel::eType:
2719  s_GetAlignmentType(*align, label);
2720  return;
2721 
2722  default:
2723  case CLabel::eContent:
2725  s_GetAlignmentContent(*align, label, scope);
2726  return;
2727 
2729  s_GetAlignmentType(*align, label);
2730  *label += ' ';
2731  s_GetAlignmentContent(*align, label, scope);
2732  break;
2733 
2734  case CLabel::eDescription:
2735  s_GetAlignmentTooltip(*align, label, scope);
2736  break;
2737  }
2738  }
2739 };
2740 
2741 
2743 {
2744 public:
2745  void GetLabel(const CObject& obj, string* label,
2746  CLabel::ELabelType type, CScope* /*scope*/) const
2747  {
2748  const CSeq_align_set* align = dynamic_cast<const CSeq_align_set*> (&obj);
2749  if ( !align ) {
2750  return;
2751  }
2752 
2753  switch (type) {
2754  case CLabel::eUserType:
2756  break;
2757 
2758  case CLabel::eUserSubtype:
2759  *label += "";
2760  break;
2761 
2762  case CLabel::eType:
2763  *label += "Seq-align-set";
2764  return;
2765 
2766  default:
2767  case CLabel::eContent:
2769  *label += "Seq-align-set"; //TODO
2770  return;
2771 
2773  *label += "Seq-align-set"; //TODO
2774  break;
2775 
2776  case CLabel::eDescription:
2777  *label += "Seq-align-set"; //TODO
2778  break;
2779  }
2780  }
2781 };
2782 
2783 //
2784 // seq-annots are complicated
2785 //
2786 
2787 static void s_GetAnnotType(const CSeq_annot& annot, string* label)
2788 {
2789  const CSeq_annot::TData& annot_data = annot.GetData();
2790  switch (annot_data.Which()) {
2792  *label += "Feature Table";
2793  break;
2794 
2796  *label += "Alignment";
2797  break;
2798 
2800  *label += "Graph";
2801  break;
2802 
2804  *label += "IDs";
2805  break;
2807  *label += "Locations";
2808  break;
2809 
2810  default:
2811  *label = "Annotation";
2812  return;
2813  }
2814 }
2815 
2816 
2817 static void s_GetAnnotContent(const CSeq_annot& annot, string* label, CScope* scope)
2818 {
2819  // check: scope is NEEDED [protected]
2820 
2821  //
2822  // check for formatted comments in descriptors first
2823  //
2824  if (annot.IsSetDesc()) {
2825  const string* title = NULL;
2826  const string* name = NULL;
2827  ITERATE (CSeq_annot::TDesc::Tdata, iter, annot.GetDesc().Get()) {
2828  switch ((*iter)->Which()) {
2829  case CAnnotdesc::e_Title:
2830  title = &(*iter)->GetTitle();
2831  break;
2832 
2833  case CAnnotdesc::e_Name:
2834  name = &(*iter)->GetName();
2835  break;
2836 
2837  default:
2838  break;
2839  }
2840  }
2841 
2842  if (title) {
2843  *label = *title;
2844  return;
2845  } else if (name) {
2846  *label = *name;
2847  return;
2848  }
2849  }
2850 
2851  //
2852  // default handling
2853  //
2854  string str, extra;
2855  size_t items = 0;
2856  const CSeq_annot::TData& annot_data = annot.GetData();
2857 
2858  switch (annot_data.Which()) {
2860  str = "Feature Table, ";
2861  items = annot_data.GetFtable().size();
2862  if( items > 0 ){
2863  const CSeq_id* sid = annot_data.GetFtable().front()->GetLocation().GetId();
2864  if( sid ){
2865  CSeq_id_Handle idh;
2866  if( scope ){
2867  idh = sequence::GetId(*sid, *scope, sequence::eGetId_Canonical);
2868  }
2869  if( idh ){
2870  CSeq_id_Handle idh_best =
2871  sequence::GetId(*sid, *scope, sequence::eGetId_Best)
2872  ;
2873  if( idh_best ){
2874  idh = idh_best;
2875  }
2876  }
2877 
2878  if( idh ){
2879  CConstRef<CSeq_id> seq_id_ref = idh.GetSeqId();
2880  extra = "on " + seq_id_ref->GetSeqIdString( true );
2881  } else {
2882  extra = "on " + sid->GetSeqIdString( true );
2883  }
2884  }
2885  }
2886 
2887  break;
2888 
2890  {{
2891  ITERATE (CSeq_annot::TData::TAlign, iter, annot_data.GetAlign()) {
2892  const CSeq_align& align = **iter;
2893  string s;
2894  s_GetAlignmentContent(align, &s, scope);
2895  if (str.empty()) {
2896  str = s;
2897  } else if (str != s) {
2898  str.erase();
2899  break;
2900  }
2901  }
2902  if (str.empty()) {
2903  str = "Mixed sequence alignments";
2904  }
2905  }}
2906  if (str.empty()) {
2907  str = "Alignment, ";
2908  } else {
2909  str += ", ";
2910  }
2911  items = annot_data.GetAlign().size();
2912  break;
2913 
2915  str = "Graph, ";
2916  items = annot_data.GetGraph().size();
2917  break;
2918 
2920  str = "IDs, ";
2921  items = annot_data.GetIds().size();
2922  break;
2924  str = "Locations, ";
2925  items = annot_data.GetLocs().size();
2926  break;
2927 
2928  default:
2929  *label = "Annotation";
2930  return;
2931  }
2932 
2933  str += NStr::SizetToString( items );
2934  if( items != 1 ){
2935  str += " entries";
2936  } else {
2937  str += " entry";
2938  }
2939 
2940  if( !extra.empty() ){
2941  str += " (" + extra + ")";
2942  }
2943 
2944  *label += str;
2945 
2946 }
2947 
2948 
2950 {
2951 public:
2952  void GetLabel(const CObject& obj, string* label,
2953  CLabel::ELabelType type, CScope* scope) const
2954  {
2955  // check: scope is NEEDED [indirectly protected]
2956 
2957  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*> (&obj);
2958  if ( !annot ) {
2959  return;
2960  }
2961 
2962  switch (type) {
2963  case CLabel::eUserType:
2965  break;
2966 
2967  case CLabel::eUserSubtype: {
2968  switch(annot->GetData().Which()) {
2971  break;
2972 
2975  break;
2976 
2979  break;
2980 
2983  break;
2984 
2987  break;
2988 
2991  break;
2992 
2993  default:
2994  _ASSERT(false);
2995  break;
2996  }
2997  return;
2998  }
2999 
3000  case CLabel::eType:
3001  s_GetAnnotType(*annot, label);
3002  return;
3003 
3004  case CLabel::eContent:
3006  s_GetAnnotContent(*annot, label, scope);
3007  return;
3008 
3010  case CLabel::eDescription:
3011  s_GetAnnotType(*annot, label);
3012  *label += ": ";
3013  s_GetAnnotContent(*annot, label, scope);
3014  break;
3015 
3016  default:
3017  break;
3018  }
3019  }
3020 };
3021 
3022 //
3023 //
3024 // ValidError handler
3025 //
3026 //
3028 {
3029 public:
3030  void GetLabel(const CObject& obj, string* label,
3031  CLabel::ELabelType type, CScope* /*scope*/) const
3032  {
3033  // check: no scope info is actually used
3034 
3035  const CValidError* valerr = dynamic_cast<const CValidError*>(&obj);
3036  if ( ! valerr) {
3037  return;
3038  }
3039 
3040  switch (type) {
3041  case CLabel::eUserType:
3043  break;
3044 
3045  case CLabel::eUserSubtype:
3047  break;
3048 
3049  case CLabel::eType:
3050  *label += valerr->GetThisTypeInfo()->GetName();
3051  return;
3052 
3053  case CLabel::eContent:
3056  {
3057  CValidError_CI valerr_it(*valerr);
3058  string acc;
3059  if (valerr->TotalSize() > 0) {
3060  if (valerr_it->CanGetAccession()) {
3061  acc = valerr_it->GetAccession();
3062  }
3063  }
3064  *label += "Validation results for " + acc
3065  + ": " + NStr::SizetToString(valerr->TotalSize());
3066  if (valerr->TotalSize() == 1) {
3067  *label += " error";
3068  } else {
3069  *label += " errors";
3070  }
3071  return;
3072  }
3073 
3074  case CLabel::eDescription:
3075 
3076  *label = "Validation errors total: " + NStr::SizetToString(valerr->TotalSize());
3077  if (valerr->InfoSize() > 0) {
3078  *label += " Info: " + NStr::SizetToString(valerr->InfoSize());
3079  }
3080  if (valerr->WarningSize() > 0) {
3081  *label += " Warning: " + NStr::SizetToString(valerr->WarningSize());
3082  }
3083  if (valerr->ErrorSize() > 0) {
3084  *label += " Error: " + NStr::SizetToString(valerr->ErrorSize());
3085  }
3086  if (valerr->CriticalSize() > 0) {
3087  *label += " Reject: " + NStr::SizetToString(valerr->CriticalSize());
3088  }
3089  if (valerr->FatalSize() > 0) {
3090  *label += " Fatal: " + NStr::SizetToString(valerr->FatalSize());
3091  }
3092  return;
3093 
3094  default:
3095  break;
3096  }
3097  }
3098 };
3099 
3100 //
3101 //
3102 // CTaxIdSelSet handler
3103 //
3104 //
3106 {
3107 public:
3108  void GetLabel(const CObject& obj, string* label,
3109  CLabel::ELabelType type, CScope* /*scope*/) const
3110  {
3111  // check: no scope info is actually used
3112 
3113  const CTaxIdSelSet* tax_ids = dynamic_cast<const CTaxIdSelSet*>(&obj);
3114  if ( ! tax_ids) {
3115  return;
3116  }
3117 
3118  switch (type) {
3119  case CLabel::eUserType:
3121  break;
3122 
3123  case CLabel::eUserSubtype:
3125  break;
3126 
3127  case CLabel::eType:
3128  *label += "Set of Tax IDs";
3129  return;
3130 
3131  case CLabel::eContent:
3134  {
3135  CTaxIdSelSet::TTaxId count = tax_ids->GetSelectedTaxIds().count();
3136 
3137  *label += "Num TaxIDs: " + NStr::UIntToString((unsigned int)count);
3138  return;
3139  }
3140 
3141  case CLabel::eDescription:
3142  {
3143  *label += "Ids: ";
3144 
3145  int char_count = 0;
3147 
3148  // could be any number of ids but they will be displayed on one line in a list,
3149  // so pick a max string length which char count can't exceed
3150  for (; e != tax_ids->GetSelectedTaxIds().end() && char_count < 60; ++e) {
3151  CTaxIdSelSet::TTaxId id = *e;
3152 
3153  if (char_count > 0)
3154  *label += ", ";
3155 
3156  string idstr = NStr::UIntToString((unsigned int)id);
3157  char_count += idstr.length();
3158 
3159  *label += idstr;
3160  }
3161 
3162  /// Could not fit all the selected ids on one line:
3163  if (e != tax_ids->GetSelectedTaxIds().end())
3164  *label += " ...";
3165 
3166  return;
3167  }
3168 
3169  default:
3170  break;
3171  }
3172  }
3173 };
3174 
3175 
3176 //
3177 //
3178 // CGBProject_ver2 handler
3179 // Moved from CGBProject_ver2
3180 //
3181 //
3183 {
3184 public:
3185  void GetLabel(const CObject& obj, string* str,
3187  objects::CScope* scope) const
3188  {
3189  const CGBProject_ver2* proj = dynamic_cast<const CGBProject_ver2*>(&obj);
3190  if (proj) {
3191  switch (type) {
3192  case CLabel::eUserType:
3194  break;
3195 
3196  case CLabel::eUserSubtype:
3198  break;
3199 
3200  case CLabel::eType:
3201  *str += "Project (ver.2)";
3202  break;
3203 
3204  case CLabel::eContent:
3205  {{
3206  string title;
3207  if (proj->IsSetDescr() && proj->GetDescr().IsSetTitle()) {
3208  title = proj->GetDescr().GetTitle();
3209  }
3210 
3211  if ( !title.empty() ) {
3212  *str += title;
3213  } else if (proj->IsSetData()) {
3215 
3216  string s;
3217  for ( ; iter; ++iter) {
3218  const CSerialObject* cso = iter->GetObject();
3219  if (cso) {
3220  if ( !s.empty() ) {
3221  s += ", ";
3222  }
3223  CLabel::GetLabel(*cso, &s, type, scope);
3224  }
3225  }
3226  *str += s;
3227  }
3228  }}
3229  break;
3230 
3232  {{
3233  string type_str;
3234  GetLabel(obj, &type_str, CLabel::eType, scope);
3235  string content_str;
3236  GetLabel(obj, &content_str, CLabel::eType, scope);
3237  *str += type_str;
3238  if ( !type_str.empty() && !content_str.empty() ) {
3239  *str += ": ";
3240  }
3241  if ( !content_str.empty() ) {
3242  *str += content_str;
3243  }
3244  }}
3245  break;
3246 
3247  default:
3248  break;
3249  }
3250  }
3251  }
3252 };
3253 
3254 
3255 
3256 ////////////////////////////////////////////////////////////
3257 // label handlers for genome workbench project types
3258 // these will be regsitered at application initialization
3259 // Moved from CProjectItem
3261 {
3262 public:
3263  void GetLabel(const CObject& obj, string* str,
3265  objects::CScope* scope) const
3266  {
3267  if(str == NULL) {
3268  return;
3269  }
3270  const CProjectItem* item = dynamic_cast<const CProjectItem*>(&obj);
3271  LOG_POST(Error << MSerial_AsnText << *item);
3272  if (item) {
3273  switch(type) {
3274  case CLabel::eContent:
3275  *str = item->IsSetLabel() ? item->GetLabel() : "";
3276  break;
3277  case CLabel::eUserType:
3279  break;
3280 
3281  case CLabel::eUserSubtype:
3282  break;
3283 
3284  case CLabel::eType:
3285  *str = "Project Item";
3286  break;
3287 
3290  case CLabel::eDescription:
3292  *str = " : " + item->GetLabel();
3293  break;
3294 
3295  default:
3296  break;
3297  }
3298  }
3299  /* the old way of getting the Label, now it shall be set explicitly
3300  const CObject* obj = item->GetObject();
3301  if (obj) {
3302  CLabel::GetLabel(*obj, str, type, scope);
3303  }*/
3304  }
3305 };
3306 
3307 
3308 /// *******************************************************************
3309 /// Moved from plugins/algo/init
3310 /// *******************************************************************
3311 
3312 ///
3313 /// CBioTreeContainer label handler
3314 ///
3316 {
3317 public:
3318  void GetLabel(const CObject& obj, string* label,
3319  CLabel::ELabelType type, objects::CScope* scope) const
3320  {
3321  // check: no scope info is actually used
3322 
3323  const CBioTreeContainer* tree =
3324  dynamic_cast<const CBioTreeContainer*>(&obj);
3325  if (tree) {
3326  switch (type) {
3327  case CLabel::eUserType:
3328  *label += tree->CanGetTreetype() ? tree->GetTreetype() : "Bio Tree";
3329  break;
3330 
3331  case CLabel::eUserSubtype:
3332  break;
3333 
3334  case CLabel::eType:
3335  *label += "Biological Tree";
3336  break;
3337 
3338  case CLabel::eContent:
3339  {{
3340  string str;
3341 
3342  if (tree->IsSetLabel()) {
3343  str.append("'");
3344  str += tree->GetLabel();
3345  str.append("'");
3346  str += " ";
3347  }
3348 
3349  str += NStr::SizetToString(tree->GetNodeCount());
3350  str += " nodes, ";
3351  str += NStr::SizetToString(tree->GetLeafCount());
3352  str += " leaves";
3353 
3354  if (tree->IsSetTreetype()) {
3355  *label += tree->GetTreetype();
3356  *label += " (" + str + ")";
3357  } else {
3358  *label += "Tree, " + str;
3359  }
3360  }}
3361  break;
3362 
3363  default:
3365  GetLabel(obj, label, CLabel::eType, scope);
3366  *label += ": ";
3367  GetLabel(obj, label, CLabel::eContent, scope);
3368  break;
3369  }
3370  }
3371  }
3372 };
3373 
3374 
3375 ///
3376 /// CGCAsssemblyHandler label handler
3377 ///
3379 {
3380 public:
3381  void GetLabel(const CObject& obj, string* label,
3382  CLabel::ELabelType type, objects::CScope* scope) const
3383  {
3384  // check: no scope info is actually used
3385 
3386  const CGC_Assembly* assm = dynamic_cast<const CGC_Assembly*>(&obj);
3387  if (assm) {
3388  switch (type) {
3389  case CLabel::eUserType:
3390  case CLabel::eType:
3391  *label += "Assembly";
3392  break;
3393 
3394  case CLabel::eUserSubtype:
3395  break;
3396 
3397 
3398  case CLabel::eContent:
3399  *label += assm->GetName();
3400  break;
3401 
3403  case CLabel::eDescription:
3404  {{
3405  const CGC_AssemblyDesc& desc = assm->GetDesc();
3406  if (desc.IsSetLong_name()) {
3407  *label += desc.GetLong_name();
3408  } else if (desc.IsSetName()) {
3409  *label += desc.GetName();
3410  }
3411  }}
3412  break;
3413 
3414  default:
3416  GetLabel(obj, label, CLabel::eType, scope);
3417  *label += ": ";
3418  GetLabel(obj, label, CLabel::eContent, scope);
3419  break;
3420  }
3421  }
3422  }
3423 };
3424 
3425 
3426 ///
3427 /// CDistanceMatrix label handler
3428 ///
3430 {
3431 public:
3432  void GetLabel(const CObject& obj, string* label,
3433  CLabel::ELabelType /*type*/, objects::CScope* /*scope*/) const
3434  {
3435  // check: no scope info is used
3436 
3437  const CDistanceMatrix * mat =
3438  dynamic_cast<const CDistanceMatrix*>(&obj);
3439 
3440  if (mat) {
3441  *label += "Distance Matrix";
3442  }
3443  }
3444 };
3445 
3446 
3447 ///
3448 /// CEntrezgene label handler
3449 ///
3451 {
3452 public:
3453  void GetLabel(const CObject& obj, string* label,
3454  CLabel::ELabelType type, objects::CScope* scope) const
3455  {
3456  // check: no scope info is actually used
3457 
3458  const CEntrezgene* egene =
3459  dynamic_cast<const CEntrezgene*>(&obj);
3460  if (egene) {
3461  switch (type) {
3462  case CLabel::eUserType:
3464  break;
3465 
3466  case CLabel::eUserSubtype:
3467  break;
3468 
3469  case CLabel::eType:
3470  *label += "Entrez Gene Record";
3471  break;
3472 
3473  case CLabel::eContent:
3474  egene->GetGene().GetLabel(label);
3475  *label += " [";
3476  egene->GetSource().GetOrg().GetLabel(label);
3477  *label += "]";
3478  break;
3479 
3480  case CLabel::eDescription:
3481  egene->GetGene().GetLabel(label);
3482  if (egene->GetGene().IsSetDesc()) {
3483  *label += " : " + egene->GetGene().GetDesc();
3484  }
3485  *label += " [";
3486  egene->GetSource().GetOrg().GetLabel(label);
3487  *label += "]";
3488  break;
3489 
3490  default:
3492  GetLabel(obj, label, CLabel::eType, scope);
3493  *label += ": ";
3494  GetLabel(obj, label, CLabel::eContent, scope);
3495  break;
3496  }
3497  }
3498  }
3499 };
3500 
3501 
3502 ///
3503 /// CEntrezgene_Set label handler
3504 ///
3506 {
3507 public:
3508  void GetLabel(const CObject& obj, string* label,
3509  CLabel::ELabelType type, objects::CScope* scope) const
3510  {
3511  // check: no scope info is actually used
3512 
3513  const CEntrezgene_Set* egene_set =
3514  dynamic_cast<const CEntrezgene_Set*>(&obj);
3515  if (egene_set) {
3516  switch (type) {
3517  case CLabel::eUserType:
3518  case CLabel::eType:
3519  *label += "Entrez Gene Set";
3520  break;
3521 
3522  case CLabel::eContent:
3523  {{
3524  string s;
3525  ITERATE (CEntrezgene_Set::Tdata, iter, egene_set->Get()) {
3526  if ( !s.empty() ) {
3527  s += "; ";
3528  }
3529  (*iter)->GetGene().GetLabel(&s);
3530  s += " (";
3531  (*iter)->GetSource().GetOrg().GetLabel(&s);
3532  s += ")";
3533  }
3534  *label += s;
3535  }}
3536  break;
3537 
3538  default:
3540  GetLabel(obj, label, CLabel::eType, scope);
3541  *label += ": ";
3542  GetLabel(obj, label, CLabel::eContent, scope);
3543  break;
3544  }
3545  }
3546  }
3547 };
3548 
3549 ///
3550 /// CVariation label handler
3551 ///
3553 {
3554 public:
3555  void GetLabel(const CObject& obj, string* label,
3556  CLabel::ELabelType type, objects::CScope* scope) const
3557  {
3558  const CVariation* pVariation(dynamic_cast<const CVariation*>(&obj));
3559  if(pVariation) {
3560  switch (type) {
3561  case CLabel::eUserType:
3563  break;
3564 
3565  case CLabel::eUserSubtype:
3566  break;
3567 
3568  case CLabel::eType:
3569  *label += "Variation";
3570  break;
3571 
3572  case CLabel::eContent:
3573  if(pVariation->CanGetId()) {
3574  pVariation->GetId().GetLabel(label);
3575  }
3576  if(pVariation->CanGetOther_ids() && !pVariation->GetOther_ids().empty()) {
3577  *label += "[";
3578  const CVariation::TOther_ids& OtherIds(pVariation->GetOther_ids());
3579  ITERATE(CVariation::TOther_ids, iOtherIds, OtherIds) {
3580  if(iOtherIds != OtherIds.begin())
3581  *label += ", ";
3582  (*iOtherIds)->GetLabel(label);
3583  *label += "]";
3584  }
3585  }
3586  break;
3587 
3588  case CLabel::eDescription:
3589  if(pVariation->CanGetDescription())
3590  *label += pVariation->GetDescription();
3591  break;
3592 
3593  default:
3594  GetLabel(obj, label, CLabel::eType, scope);
3595  *label += ": ";
3596  GetLabel(obj, label, CLabel::eContent, scope);
3597  break;
3598  }
3599  }
3600  }
3601 };
3602 
3603 
3604 
3605 
3606 //
3607 // force registration at load
3608 //
3609 
3611 {
3613  {
3614  CLabel::RegisterLabelHandler(*CSeq_id::GetTypeInfo(), *new CSeq_idHandler());
3615  CLabel::RegisterLabelHandler(*CSeq_loc::GetTypeInfo(), *new CSeq_locHandler());
3616  CLabel::RegisterLabelHandler(*CBioseq::GetTypeInfo(), *new CBioseqHandler());
3617  CLabel::RegisterLabelHandler(*CBioseq_set::GetTypeInfo(), *new CBioseq_setHandler());
3618  CLabel::RegisterLabelHandler(*CSeq_feat::GetTypeInfo(), *new CSeq_featHandler());
3619  CLabel::RegisterLabelHandler(*CSeq_entry::GetTypeInfo(), *new CSeq_entryHandler());
3620  CLabel::RegisterLabelHandler(*CSeq_annot::GetTypeInfo(), *new CSeq_annotHandler());
3621  CLabel::RegisterLabelHandler(*CSeq_align::GetTypeInfo(), *new CSeq_alignHandler());
3622  CLabel::RegisterLabelHandler(*CSeq_align_set::GetTypeInfo(), *new CSeq_align_setHandler());
3623  CLabel::RegisterLabelHandler(*CValidError::GetTypeInfo(), *new CValidErrorHandler());
3625  // TBD: Need support for GetTypeInfo to see taxid collection in selection inspector
3626  //CLabel::RegisterLabelHandler(*CTaxIdSelSet::GetTypeInfo(), *new CTaxIDSetLabelHandler());
3627 
3628  // Originially located in plugins/algo/init
3629  CLabel::RegisterLabelHandler(*CBioTreeContainer::GetTypeInfo(), *new CBioTreeContainerHandler);
3630  CLabel::RegisterLabelHandler(*CGC_Assembly::GetTypeInfo(), *new CGCAsssemblyHandler);
3631  CLabel::RegisterLabelHandler(*CDistanceMatrix::GetTypeInfo(), *new CDistanceMatrixHandler);
3632  CLabel::RegisterLabelHandler(*CEntrezgene::GetTypeInfo(), *new CEntrezgeneHandler);
3633  CLabel::RegisterLabelHandler(*CVariation::GetTypeInfo(), *new CVariationHandler);
3634  CLabel::RegisterLabelHandler(*CGBProject_ver2::GetTypeInfo(), *new CGBProject_ver2LabelHandler);
3635  CLabel::RegisterLabelHandler(*CProjectItem::GetTypeInfo(), *new CProjectItemLabelHandler);
3636  }
3637 };
3638 
3639 
3641 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAlign_CI –.
Definition: align_ci.hpp:63
size_t GetSize(void) const
******************************************************************* Moved from plugins/algo/init ****...
Definition: label.cpp:3316
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3318
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *) const
Definition: label.cpp:961
CBioseq_Handle –.
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:1210
CBioseq_set_Handle –.
const CBioseq & GetNucFromNucProtSet(void) const
Definition: Bioseq_set.cpp:227
const CBioseq & GetMasterFromSegSet(void) const
Definition: Bioseq_set.cpp:275
const CBioseq & GetGenomicFromGenProdSet(void) const
Definition: Bioseq_set.cpp:251
void GetLabel(string *label, ELabelType type) const
Definition: Bioseq_set.cpp:107
@ eContent
Definition: Bioseq.hpp:103
@ eType
Definition: Bioseq.hpp:102
@ eBoth
Definition: Bioseq.hpp:104
void GetLabel(string *label, ELabelType type, bool worst=false) const
Definition: Bioseq.cpp:202
bool IsNa(void) const
Definition: Bioseq.cpp:345
bool IsAa(void) const
Definition: Bioseq.cpp:350
CClone_ref –.
Definition: Clone_ref.hpp:66
CClone_seq –.
Definition: Clone_seq.hpp:66
void GetLabel(string *label) const
Definition: Dbtag.cpp:187
CRange< TSeqPos > GetSeqRange(TDim row) const
Definition: Dense_seg.hpp:234
CDistanceMatrix label handler.
Definition: label.cpp:3430
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType, objects::CScope *) const
Definition: label.cpp:3432
CEntrezgene label handler.
Definition: label.cpp:3451
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3453
CEntrezgene_Set label handler.
Definition: label.cpp:3506
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3508
CEntrezgene_Set –.
CFastMutex –.
Definition: ncbimtx.hpp:667
void GetLabel(const CObject &obj, string *str, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3185
bool IsSetDescr() const
retrieve the descriptor set for this project
const CProjectDescr & GetDescr() const
const CProjectFolder & GetData() const
retrieve our project's data, in the form of a project folder this may be a contrived entity,...
CGCAsssemblyHandler label handler.
Definition: label.cpp:3379
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3381
CGC_AssemblyDesc –.
string GetName() const
Retrieve the name of this assembly.
const CGC_AssemblyDesc & GetDesc() const
Retrieve the full set of assembly descriptors.
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
void GetLabel(string *label) const
Definition: Gene_ref.cpp:57
void GetLabel(TGi gi, string *label) const
Definition: label.cpp:330
void AddCaches(const map< TGi, string > &caches)
Definition: label.cpp:356
map< TIntId, string > TGi2DescriptionMap
Definition: label.cpp:317
string GetLabel(TGi gi) const
Definition: label.cpp:321
bool HasLabel(TGi gi) const
Definition: label.cpp:340
TGi2DescriptionMap m_DescrCache
Definition: label.cpp:367
void SetLabel(TGi gi, const string &label)
Definition: label.cpp:350
CObject –.
Definition: ncbiobj.hpp:180
void GetLabel(string *label) const
Definition: Org_ref.cpp:57
void GetLabel(const CObject &obj, string *str, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3263
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
TSeqPos GetAlignLength(const CSeq_align &align, bool ungapped=false)
Compute the length of the alignment (= length of all segments, gaps + aligned)
int GetGapCount(const CSeq_align &align)
Compute the number of gaps in the alignment.
double GetPercentCoverage(CScope &scope, const CSeq_align &align, unsigned query=0)
Compute percent coverage of the query (sequence 0) (range 0-100)
int GetMismatchCount(CScope &scope, const CSeq_align &align)
Compute the number of mismatches in the alignment.
Definition: Score.hpp:57
ESubtype GetSubtype(void) const
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:2701
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *) const
Definition: label.cpp:2745
@ eScore_PercentCoverage
Definition: Seq_align.hpp:168
@ eScore_IdentityCount
Definition: Seq_align.hpp:145
@ eScore_PercentIdentity
Definition: Seq_align.hpp:189
@ eScore_MismatchCount
Definition: Seq_align.hpp:154
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
bool GetNamedScore(const string &id, int &score) const
Get score.
Definition: Seq_align.cpp:563
ENa_strand GetSeqStrand(TDim row) const
Get strand (the first one if segments have different strands).
Definition: Seq_align.cpp:294
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:2952
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:2291
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
CUserFeatHandler m_UserHandler
Definition: label.cpp:2217
bool x_UseCustomLabel(const objects::CSeq_feat &feat) const
Definition: label.cpp:2221
void x_LabelFromQualifiers(const objects::CSeq_feat &feat, string &label) const
Definition: label.cpp:2257
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:1433
void x_GetCustomLabel(const objects::CSeq_feat &feat, string &label) const
Definition: label.cpp:2230
bool x_IncludeFeatureTypeInLabel(const objects::CSeq_feat &feat) const
Definition: label.cpp:2272
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
Definition: Seq_feat.cpp:429
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:920
TSeqPos GetLength(void) const
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:939
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSnpBitfield is a facade for representing any version of the SNP bitfield.
bool IsTrue(EProperty prop) const
bool isGood() const
const char * GetVariationClassString() const
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
Definition: static_map.hpp:175
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *) const
Definition: label.cpp:3108
Class designed to hold a set of tax-ids represented as (on) bits in a bit vector.
const TBitVec & GetSelectedTaxIds() const
bm::id_t TTaxId
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
handler specific for User-object features
Definition: label.cpp:1287
void GetLabel(const CObject &obj_in, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:1289
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Definition: User_object.cpp:84
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *) const
Definition: label.cpp:3030
SIZE_TYPE ErrorSize() const
Definition: ValidError.hpp:214
SIZE_TYPE InfoSize() const
Definition: ValidError.hpp:200
SIZE_TYPE CriticalSize() const
Definition: ValidError.hpp:221
SIZE_TYPE WarningSize() const
Definition: ValidError.hpp:207
SIZE_TYPE TotalSize() const
Definition: ValidError.hpp:186
SIZE_TYPE FatalSize() const
Definition: ValidError.hpp:228
CVariation label handler.
Definition: label.cpp:3553
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, objects::CScope *scope) const
Definition: label.cpp:3555
TValidated GetValidated(void) const
bool IsLoss() const
bool IsSetAllele_origin(void) const
bool IsUnknown() const
TAllele_origin GetAllele_origin(void) const
bool IsComplex() const
bool IsEversion() const
bool IsUniparentalDisomy() const
bool IsDeletionInsertion() const
bool IsGain() const
bool IsSetValidated(void) const
bool IsTranslocation() const
bool IsInversion() const
bool IsInsertion() const
bool IsDeletion() const
bool IsCNV() const
void GetLabel(const CObject &obj, string *label, CLabel::ELabelType type, CScope *scope) const
Definition: label.cpp:1005
ILabelHandler interface.
Definition: label.hpp:136
static TRsid GetRsid(const CMappedFeat &mapped_feat)
Return rsid of SNP.
Definition: snp_utils.cpp:109
static int GetLength(const CMappedFeat &)
Return distance of neighbors in flanking sequence.
Definition: snp_utils.cpp:133
vector< string > TAlleles
list of alleles belonging to particular SNP a deletion is represented by a "-"
Definition: snp_utils.hpp:188
CObject_id::TId8 TRsid
Definition: snp_utils.hpp:70
static void GetAlleles(const CMappedFeat &mapped_feat, TAlleles &Alleles)
Return list of alleles encoded in qual.
Definition: snp_utils.cpp:237
static string ClinSigAsString(const CVariation_ref &var, ELetterCase LetterCase=eLetterCase_Mixed)
get a human-readable text for various clinical significance types
Definition: snp_utils.cpp:172
Constant iterator designed to enumerate "ON" bits.
Definition: bm.h:603
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
Definition: bm.h:1871
enumerator end() const
Returns enumerator pointing on the next bit after the last.
Definition: bm.h:1877
size_type count() const noexcept
population count (count of ON bits)
Definition: bm.h:2401
container_type::const_iterator const_iterator
Definition: map.hpp:53
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
size_type size() const
Definition: set.hpp:132
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
char value[7]
Definition: config.c:431
API (CDeflineGenerator) for computing sequences' titles ("definitions").
SStaticPair< const char *, const char * > TPair
static int type
Definition: getdata.c:31
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
Int8 TIntId
Definition: ncbimisc.hpp:999
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
Definition: ncbiexpt.hpp:580
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
Definition: enumerated.cpp:146
static string GetTypeIconAlias(const string &user_type, const string &user_subtype)
Definition: label.cpp:268
static void RegisterLabelHandler(const string &type, ILabelHandler &handler)
Definition: label.cpp:229
static const string sm_Tp_Sequence
Definition: user_type.hpp:64
static const string sm_Tp_ProjectItem
Definition: user_type.hpp:74
static void StopCache()
Stop cache instance (call once at gBench stop)
Definition: label.cpp:380
static const string sm_Tp_EntrezGeneRecord
Definition: user_type.hpp:58
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
static string FormatStringsOccurrences(const std::vector< string > &strings, const string &delimiter=", ")
static const string sm_Tp_Alignment
Definition: user_type.hpp:55
static const string sm_Tp_Annotation
Definition: user_type.hpp:57
static const string sm_Tp_Sequence_Set
Definition: user_type.hpp:66
static const string sm_SbTp_PhySet
Definition: user_type.hpp:98
static const string sm_SbTp_MutSet_Aln
Definition: user_type.hpp:105
static void AddCaches(const map< TGi, string > &caches)
Definition: label.cpp:480
static void GetIconAlias(const CObject &obj, string *alias, objects::CScope *scope=NULL)
Definition: label.cpp:300
static const string sm_SbTp_PhySet_Aln
Definition: user_type.hpp:103
static const string sm_SbTp_Undefined
Definition: user_type.hpp:78
static const string sm_SbTp_DNA
Definition: user_type.hpp:81
static const string sm_SbTp_EcoSet
Definition: user_type.hpp:99
static const string sm_Tp_TaxId_Set
Definition: user_type.hpp:63
static const string sm_SbTp_Graphs
Definition: user_type.hpp:87
static bool HasHandler(const CTypeInfo &type)
Definition: label.cpp:243
static const string sm_SbTp_NucProt
Definition: user_type.hpp:93
static void CacheSeqId(const objects::CSeq_id &id, objects::CScope *scope)
Generate and cache description label for the specified gi.
Definition: label.cpp:459
static string ConcatenateStrings(const std::vector< string > &strings, const string &delimiter=", ")
static void SetLabelByData(objects::CProjectItem &item, objects::CScope *scope=NULL)
Definition: label.cpp:121
static const string sm_Tp_Feature
Definition: user_type.hpp:60
static const string sm_SbTp_PopSet_Aln
Definition: user_type.hpp:102
static const string sm_SbTp_EcoSet_Aln
Definition: user_type.hpp:104
static const string sm_SbTp_GenProdSet
Definition: user_type.hpp:95
static const string sm_Tp_Alignment_Set
Definition: user_type.hpp:56
static const string sm_SbTp_Features
Definition: user_type.hpp:86
static const string sm_SbTp_Sequence_IDs
Definition: user_type.hpp:88
static void TruncateLabel(string *label, unsigned length_limit, unsigned length_tolerance)
truncate the label to some specific length with a desired leven of precision algorithm tries to analy...
Definition: label.cpp:187
static void InitCache()
Initialize cache instance (call once at gBench start)
Definition: label.cpp:372
static const string sm_SbTp_Table
Definition: user_type.hpp:90
static const string sm_Tp_ValidationResult
Definition: user_type.hpp:69
static const string sm_SbTp_Protein
Definition: user_type.hpp:82
static const string sm_SbTp_MutSet
Definition: user_type.hpp:100
static const string sm_SbTp_ProjectVer2
Definition: user_type.hpp:109
static const string sm_SbTp_SegSeq
Definition: user_type.hpp:94
static void RegisterTypeIcon(const string &user_type, const string &user_subtype, const string &icon_alias)
Definition: label.cpp:257
static const string sm_SbTp_Locations
Definition: user_type.hpp:89
static const string sm_SbTp_PopSet
Definition: user_type.hpp:97
static TLabelMap sm_LabelMap
Definition: label.hpp:128
ELabelType
Definition: label.hpp:60
static string GetTypeName()
Definition: snp_gui.hpp:304
static const string sm_Tp_Variation
Definition: user_type.hpp:71
void GetLabel(string &label, CLabel::ELabelType type) const
Definition: snp_gui.cpp:1226
static const string sm_SbTp_Alignments
Definition: user_type.hpp:85
static TAliasMap sm_AliasMap
Definition: label.hpp:129
static const string sm_Tp_Sequence_ID
Definition: user_type.hpp:65
static const string sm_Tp_Location
Definition: user_type.hpp:61
static const string sm_Tp_Project
Definition: user_type.hpp:73
@ eContentAndProduct
Definition: label.hpp:71
@ eType
Definition: label.hpp:65
@ eUserSubtype
Definition: label.hpp:64
@ eDefault
Definition: label.hpp:73
@ eUserTypeAndContent
Definition: label.hpp:66
@ eContent
Definition: label.hpp:62
@ eGi
Definition: label.hpp:70
@ eDescription
Definition: label.hpp:68
@ eUserType
Definition: label.hpp:63
@ eDescriptionBrief
Definition: label.hpp:67
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
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
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
Definition: Seq_id.cpp:2144
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:2039
CConstRef< CSeq_id > GetSeqId(void) const
EAccessionInfo
For IdentifyAccession (below)
Definition: Seq_id.hpp:220
CConstRef< CSeq_id > GetSeqIdOrNull(void) const
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1033
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
static int Score(const CRef< CSeq_id > &id)
Wrappers for use with FindBestChoice from <corelib/ncbiutil.hpp>
Definition: Seq_id.hpp:740
string GetLabel(const CSeq_id &id)
TGi GetGi(void) const
@ fLabel_Default
default options - always show the version
Definition: Seq_id.hpp:591
@ fAcc_prot
Definition: Seq_id.hpp:227
@ fAcc_nuc
Definition: Seq_id.hpp:226
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:573
@ eBoth
Type and content, delimited by a vertical bar.
Definition: Seq_id.hpp:574
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
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
Definition: Seq_loc.cpp:3467
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
@ eEmpty_Allow
ignore empty locations
Definition: Seq_loc.hpp:458
ELabelType
For compatibility with legacy code.
Definition: feature.hpp:85
@ fFGL_NoComments
Leave out comments, even as fallbacks.
Definition: feature.hpp:75
@ fFGL_NoQualifiers
Leave out qualifiers.
Definition: feature.hpp:76
@ fFGL_Content
Include its content if there is any.
Definition: feature.hpp:73
@ fFGL_Type
Always include the feature's type.
Definition: feature.hpp:72
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...
bool IsOneBioseq(const CSeq_loc &loc, CScope *scope)
Returns true if all embedded CSeq_ids represent the same CBioseq, else false.
bool IsSameBioseq(const CSeq_id &id1, const CSeq_id &id2, CScope *scope, CScope::EGetBioseqFlag get_flag=CScope::eGetBioseq_All)
Determines if two CSeq_ids represent the same CBioseq.
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
Definition: sequence.hpp:101
@ eGetId_ForceGi
return only a gi-based seq-id
Definition: sequence.hpp:99
@ eGetId_Canonical
Definition: sequence.hpp:114
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set &seqset, EMissing action=eMissing_Default)
Definition: scope.cpp:176
@ eGetBioseq_All
Search bioseq, load if not loaded yet.
Definition: scope.hpp:128
CSeq_entry_Handle GetTopLevelEntry(void) const
Return a handle for the top-level seq-entry.
SAnnotSelector & SetMaxSize(TMaxSize max_size)
Set maximum number of annotations to find.
SAnnotSelector & SetLimitTSE(const CTSE_Handle &limit)
Limit annotations to those from the TSE only.
position_type GetLength(void) const
Definition: range.hpp:158
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
Definition: ncbistr.hpp:5187
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5109
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 enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
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[]
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
list< CRef< CEntrezgene > > Tdata
const TSource & GetSource(void) const
Get the Source member data.
const Tdata & Get(void) const
Get the member data.
const TGene & GetGene(void) const
Get the Gene member data.
bool IsSetLabel(void) const
user-defined label Check if a value has been assigned to Label data member.
const TTitle & GetTitle(void) const
Get the Title member data.
bool IsSetTitle(void) const
user-defined title for the workspace Check if a value has been assigned to Title data member.
const TLabel & GetLabel(void) const
Get the Label member data.
bool IsSetData(void) const
a set of extra analyses perfromed by the user each of these may have descriptors Check if a value has...
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Gene_ref_.hpp:599
bool IsSetDesc(void) const
descriptive name Check if a value has been assigned to Desc data member.
Definition: Gene_ref_.hpp:587
const TStr & GetStr(void) const
Get the variant data.
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
const TData & GetData(void) const
Get the Data member data.
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
TBool GetBool(void) const
Get the variant data.
bool IsSetClass(void) const
endeavor which designed this object Check if a value has been assigned to Class data member.
const TClass & GetClass(void) const
Get the Class member data.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TType & GetType(void) const
Get the Type member data.
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
const TName & GetName(void) const
Get the Name member data.
const TLong_name & GetLong_name(void) const
Get the Long_name member data.
bool IsSetLong_name(void) const
Check if a value has been assigned to Long_name data member.
bool IsSetName(void) const
Names of the assembly Check if a value has been assigned to Name data member.
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Score_.hpp:432
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
const TGenomic_id & GetGenomic_id(void) const
Get the Genomic_id member data.
bool IsReal(void) const
Check if variant Real is selected.
Definition: Score_.hpp:378
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
bool CanGetGenomic_id(void) const
Check if it is safe to call GetGenomic_id method.
vector< CRef< CScore > > TScore
Definition: Seq_align_.hpp:398
E_Choice
Choice variants.
Definition: Seq_align_.hpp:131
const TProduct_id & GetProduct_id(void) const
Get the Product_id member data.
vector< CRef< CSeq_id > > TIds
Definition: Dense_seg_.hpp:106
const TSpliced & GetSpliced(void) const
Get the variant data.
Definition: Seq_align_.cpp:219
TInt GetInt(void) const
Get the variant data.
Definition: Score_.hpp:411
const TExons & GetExons(void) const
Get the Exons member data.
const TValue & GetValue(void) const
Get the Value member data.
Definition: Score_.hpp:465
bool CanGetProduct_id(void) const
Check if it is safe to call GetProduct_id method.
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Dense_seg_.hpp:505
bool IsSetScore(void) const
for whole alignment Check if a value has been assigned to Score data member.
Definition: Seq_align_.hpp:884
list< CRef< CSeq_align > > Tdata
const TScore & GetScore(void) const
Get the Score member data.
Definition: Seq_align_.hpp:896
TReal GetReal(void) const
Get the variant data.
Definition: Score_.hpp:384
const TDisc & GetDisc(void) const
Get the variant data.
Definition: Seq_align_.cpp:197
const TId & GetId(void) const
Get the Id member data.
Definition: Score_.hpp:444
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
@ e_not_set
No variant selected.
Definition: Seq_align_.hpp:132
const TVal & GetVal(void) const
Get the Val member data.
Definition: Gb_qual_.hpp:259
TConcordant GetConcordant(void) const
Get the Concordant member data.
Definition: Clone_ref_.hpp:512
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
Definition: Seq_feat_.hpp:1037
const TClone & GetClone(void) const
Get the variant data.
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
Definition: Seq_feat_.hpp:1135
bool IsUser(void) const
Check if variant User is selected.
bool IsSetUnique(void) const
OPTIONAL? Check if a value has been assigned to Unique data member.
Definition: Clone_ref_.hpp:537
const TRegion & GetRegion(void) const
Get the variant data.
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Seq_feat_.hpp:1172
const TSeq & GetSeq(void) const
Get the variant data.
bool IsSetDescr(void) const
text description Check if a value has been assigned to Descr data member.
Definition: Imp_feat_.hpp:341
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Seq_feat_.hpp:1147
bool IsSetConcordant(void) const
OPTIONAL? Check if a value has been assigned to Concordant data member.
Definition: Clone_ref_.hpp:487
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
bool CanGetSeq(void) const
Check if it is safe to call GetSeq method.
Definition: Clone_seq_.hpp:528
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
list< CRef< CClone_seq > > Tdata
const TUser & GetUser(void) const
Get the variant data.
const TName & GetName(void) const
Get the Name member data.
Definition: Clone_ref_.hpp:405
TSupport GetSupport(void) const
Get the Support member data.
Definition: Clone_seq_.hpp:583
bool CanGetLocation(void) const
Check if it is safe to call GetLocation method.
Definition: Seq_feat_.hpp:1111
const TDescr & GetDescr(void) const
Get the Descr member data.
Definition: Imp_feat_.hpp:353
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
bool IsSetPlacement_method(void) const
Check if a value has been assigned to Placement_method data member.
Definition: Clone_ref_.hpp:587
const TComment & GetComment(void) const
Get the Comment member data.
Definition: Seq_feat_.hpp:1049
bool IsSetName(void) const
Official clone symbol Check if a value has been assigned to Name data member.
Definition: Clone_ref_.hpp:393
TUnique GetUnique(void) const
Get the Unique member data.
Definition: Clone_ref_.hpp:562
TSite GetSite(void) const
Get the variant data.
const Tdata & Get(void) const
Get the member data.
const TClone_seq & GetClone_seq(void) const
Get the Clone_seq member data.
Definition: Clone_ref_.hpp:646
TPlacement_method GetPlacement_method(void) const
Get the Placement_method member data.
Definition: Clone_ref_.hpp:606
const TSeq & GetSeq(void) const
Get the Seq member data.
Definition: Clone_seq_.hpp:534
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
const TVariation & GetVariation(void) const
Get the variant data.
bool IsRna(void) const
Check if variant Rna is selected.
bool CanGetSupport(void) const
Check if it is safe to call GetSupport method.
Definition: Clone_seq_.hpp:570
bool IsRegion(void) const
Check if variant Region is selected.
bool CanGetTitle(void) const
Check if it is safe to call GetTitle method.
Definition: Seq_feat_.hpp:1166
const TImp & GetImp(void) const
Get the variant data.
bool IsSetClone_seq(void) const
Check if a value has been assigned to Clone_seq data member.
Definition: Clone_ref_.hpp:634
bool CanGetComment(void) const
Check if it is safe to call GetComment method.
Definition: Seq_feat_.hpp:1043
@ eSupport_supporting
sequence supports placement
Definition: Clone_seq_.hpp:113
@ eSupport_supports_other
supports a different placement
Definition: Clone_seq_.hpp:114
@ eSupport_prototype
sequence used to place clone
Definition: Clone_seq_.hpp:112
@ eSupport_non_supporting
does not support any placement
Definition: Clone_seq_.hpp:115
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
list< CRef< CSeq_interval > > Tdata
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const Tdata & Get(void) const
Get the member data.
const TId & GetId(void) const
Get the Id member data.
const TPnt & GetPnt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:238
TPoint GetPoint(void) const
Get the Point member data.
Definition: Seq_point_.hpp:303
const TWhole & GetWhole(void) const
Get the variant data.
Definition: Seq_loc_.cpp:172
TFrom GetFrom(void) const
Get the From member data.
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Seq_id_.hpp:877
list< CRef< CSeq_loc > > Tdata
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_point_.hpp:390
const Tdata & Get(void) const
Get the member data.
const TPacked_pnt & GetPacked_pnt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:260
vector< TSeqPos > TPoints
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Seq_id_.cpp:193
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Seq_id_.hpp:775
const TPoints & GetPoints(void) const
Get the Points member data.
TStrand GetStrand(void) const
Get the Strand member data.
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
bool IsGi(void) const
Check if variant Gi is selected.
Definition: Seq_id_.hpp:883
TTo GetTo(void) const
Get the To member data.
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
const TPacked_int & GetPacked_int(void) const
Get the variant data.
Definition: Seq_loc_.cpp:216
const TAccession & GetAccession(void) const
Get the Accession member data.
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
@ e_not_set
No variant selected.
Definition: Seq_id_.hpp:94
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
@ e_Int
from to
Definition: Seq_loc_.hpp:101
@ e_Whole
whole sequence
Definition: Seq_loc_.hpp:100
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
TClass GetClass(void) const
Get the Class member data.
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
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
list< CRef< CSeq_entry > > TSeq_set
@ eClass_equiv
a set of equivalent maps or seqs
@ eClass_parts
parts for 2 or 3
@ eClass_pop_set
population study
@ eClass_phy_set
phylogenetic study
@ eClass_conset
constructed sequence + parts
@ eClass_wgs_set
whole genome shotgun project
@ eClass_mut_set
set of mutations
@ eClass_pir
converted pir
@ eClass_eco_set
ecological sample study
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
@ eClass_gibb
geninfo backbone
@ eClass_gen_prod_set
genomic products, chrom+mRNA+protein
@ eClass_pdb_entry
a complete PDB entry
@ eClass_genbank
converted genbank
@ eClass_swissprot
converted SWISSPROT
@ eClass_segset
segmented sequence + parts
@ eClass_pub_set
all the seqs from a single publication
const Tdata & Get(void) const
Get the member data.
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
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
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 TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Seq_annot_.hpp:852
bool IsSetDesc(void) const
used only for stand alone Seq-annots Check if a value has been assigned to Desc data member.
Definition: Seq_annot_.hpp:840
const TAlign & GetAlign(void) const
Get the variant data.
Definition: Seq_annot_.hpp:641
const TFtable & GetFtable(void) const
Get the variant data.
Definition: Seq_annot_.hpp:621
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
list< CRef< CAnnotdesc > > Tdata
@ e_Ids
used for communication between tools
Definition: Seq_annot_.hpp:136
@ e_Locs
used for communication between tools
Definition: Seq_annot_.hpp:137
@ e_Name
a short name for this collection
Definition: Annotdesc_.hpp:97
@ e_Title
a title for this collection
Definition: Annotdesc_.hpp:98
bool CanGetAccession(void) const
Check if it is safe to call GetAccession method.
const TAccession & GetAccession(void) const
Get the Accession member data.
bool CanGetOther_ids(void) const
Check if it is safe to call GetOther_ids method.
bool CanGetId(void) const
Check if it is safe to call GetId method.
const TOther_ids & GetOther_ids(void) const
Get the Other_ids member data.
const TDescription & GetDescription(void) const
Get the Description member data.
bool CanGetDescription(void) const
Check if it is safe to call GetDescription method.
list< CRef< CDbtag > > TOther_ids
const TId & GetId(void) const
Get the Id member data.
const TInstance & GetInstance(void) const
Get the variant data.
const TVariant_prop & GetVariant_prop(void) const
Get the Variant_prop member data.
bool CanGetConsequence(void) const
Check if it is safe to call GetConsequence method.
bool CanGetMethod(void) const
Check if it is safe to call GetMethod method.
bool IsSetDelta(void) const
Sequence that replaces the location, in biological order.
bool IsSetVariant_prop(void) const
variant properties bit fields Check if a value has been assigned to Variant_prop data member.
list< CRef< CPhenotype > > TPhenotype
bool IsSetAllele_origin(void) const
Check if a value has been assigned to Allele_origin data member.
const TId & GetId(void) const
Get the Id member data.
const TDelta & GetDelta(void) const
Get the Delta member data.
list< CRef< C_E_Somatic_origin > > TSomatic_origin
const TData & GetData(void) const
Get the Data member data.
const TPhenotype & GetPhenotype(void) const
Get the Phenotype member data.
bool CanGetSomatic_origin(void) const
Check if it is safe to call GetSomatic_origin method.
bool IsInstance(void) const
Check if variant Instance is selected.
TOther_validation GetOther_validation(void) const
Get the Other_validation member data.
list< CRef< C_E_Consequence > > TConsequence
const TSomatic_origin & GetSomatic_origin(void) const
Get the Somatic_origin member data.
const TConsequence & GetConsequence(void) const
Get the Consequence member data.
const TParent_id & GetParent_id(void) const
Get the Parent_id member data.
list< CRef< CDelta_item > > TDelta
bool IsSetOther_validation(void) const
has this variant been validated? While a boolean flag offers no subtle distinctions of validation met...
bool CanGetParent_id(void) const
Check if it is safe to call GetParent_id method.
bool IsSetId(void) const
ids (i.e., SNP rsid / ssid, dbVar nsv/nssv) expected values include 'dbSNP|rs12334',...
bool CanGetPhenotype(void) const
Check if it is safe to call GetPhenotype method.
bool CanGetId(void) const
Check if it is safe to call GetId method.
const TMethod & GetMethod(void) const
Get the Method member data.
TAllele_origin GetAllele_origin(void) const
Get the Allele_origin member data.
@ eAllele_origin_other
stopper - 2^31
USING_SCOPE(objects)
static void s_GetBioseq_setType(const CBioseq_set &bst, string *label)
Definition: label.cpp:1021
static void s_GetAlignmentTooltip(const CSeq_align &align, string *label, CScope *scope)
Definition: label.cpp:2444
static void s_BreakSeq_loc(const CSeq_loc &loc, vector< CRef< CSeq_loc > > &locs, CScope *scope)
Definition: label.cpp:700
static void s_GetDefline(const CSeq_id &id, CScope *scope, string *label)
Definition: label.cpp:416
static void s_GetCachedDescription(const CSeq_id &id, CScope *scope, string *label)
Definition: label.cpp:430
static CFastMutex s_DFLock
Definition: label.cpp:412
static void s_GetAnnotContent(const CSeq_annot &annot, string *label, CScope *scope)
Definition: label.cpp:2817
DEFINE_STATIC_MUTEX(sm_Mutex)
static void s_GetSeq_TotalRangeLabel(const CSeq_loc &loc, string *label, CScope *scope, CLabel::ELabelType type)
Definition: label.cpp:610
static sequence::CDeflineGenerator s_DefGen
This class seems to be non-thread safe even as a stack var.
Definition: label.cpp:413
static bool s_IsCopyNumberMethod(const CVariation_ref::TMethod &method)
Definition: label.cpp:1411
static const CSeq_id * s_GetLabel(const CSeq_loc &loc, string *label, CScope *scope, CLabel::ELabelType type, const CSeq_id *last_id=NULL)
Definition: label.cpp:731
static void s_GetBioseq_setContent(const CBioseq_set &bst, string *label, CScope *scope)
Definition: label.cpp:1148
static void s_GetSeq_intervalLabel(const CSeq_interval &interval, string *label, CScope *scope, CLabel::ELabelType type, const CSeq_id *last_id=NULL)
Definition: label.cpp:558
static void s_GetGenProdContent(const CBioseq_set &bst, string *label, CScope *scope)
Definition: label.cpp:1138
static void s_GetAlignmentContent(const CSeq_align &align, string *label, CScope *scope)
Definition: label.cpp:2332
static void s_GetNucProtContent(const CBioseq_set &bst, string *label, CScope *scope)
Definition: label.cpp:1117
static void s_GetIdLabel(const CBioseq_set &bst, string *label, CScope *scope)
Definition: label.cpp:1057
static int s_GetChildNum(const objects::CSeq_feat &feat)
Definition: label.cpp:1384
static void s_GetSeqLabel(const CSeq_id &id, string *label, CScope *scope, CLabel::ELabelType type)
Definition: label.cpp:492
static bool s_HasAlignment(const CBioseq_set &bst, CScope *scope)
Definition: label.cpp:1185
static bool s_IsLOH(const CVariation_ref &var)
Definition: label.cpp:1398
static SForceRegister sm_ForceRegistration
Definition: label.cpp:3640
static std::unique_ptr< CLabelDescriptionCacheImpl > s_DescrCachePtr
Definition: label.cpp:370
static size_t s_CountSegments(const CSeq_align &align)
Definition: label.cpp:2428
static void s_GetAlignmentType(const CSeq_align &align, string *label)
Definition: label.cpp:2306
static void s_GetAnnotType(const CSeq_annot &annot, string *label)
Definition: label.cpp:2787
static TGi s_GetGi(const CSeq_id &id, CScope *scope)
Definition: label.cpp:387
static void s_GetSegsetContent(const CBioseq_set &bst, string *label, CScope *scope)
Definition: label.cpp:1128
char * buf
int i
int len
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
const char * tag
Multi-threading – mutexes; rw-locks; semaphore.
T min(T x_, T y_)
Int4 delta(size_t dimension_, const Int4 *score_)
#define DEFINE_STATIC_ARRAY_MAP(Type, Var, Array)
Definition: static_set.hpp:888
static const char * str(char *buf, int n)
Definition: stats.c:84
bool is_sv
Definition: stress32.cpp:37869
SAnnotSelector –.
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
Definition: static_set.hpp:60
Definition: inftrees.h:24
Definition: type.c:6
#define _ASSERT
Modified on Thu Mar 28 17:11:21 2024 by modify_doxy.py rev. 669887