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

Go to the SVN repository for this file.

1 /* $Id: gui_object_info_seq_feat.cpp 47479 2023-05-02 13:24:02Z ucko $
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: Roman Katargin, Liangshou Wu
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
35 
36 // some common includes
44 #include <gui/objutils/utils.hpp>
46 #include <gui/objutils/label.hpp>
47 #include <objmgr/util/feature.hpp>
48 #include <objmgr/util/sequence.hpp>
49 #include <objmgr/seq_vector.hpp>
52 
54 
55 // include other seq-feat implmentations
56 #include "gui_object_info_variant.cpp" /// structural variants
57 #include "gui_object_info_variation.cpp" /// SNP
61 
64 
66 {
68  typeid(IGuiObjectInfo).name(),
69  CSeq_feat::GetTypeInfo(),
71 }
72 
73 
75  SConstScopedObject& object, ICreateParams* params)
76 {
77  CGuiObjectInfoSeq_feat* gui_info = NULL;
78  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(object.object.GetPointer());
79 
80  switch (feat->GetData().GetSubtype())
81  {
83  {{
84  if (feat->GetNamedQual("type") == "primer") {
85  gui_info = new CGuiObjectInfoPrimer();
86  } else {
87  gui_info = new CGuiObjectInfoClone();
88  }
89  }}
90  break;
92  gui_info = new CGuiObjectInfoVariation();
93  break;
95  gui_info = new CGuiObjectInfoVariant();
96  break;
98  gui_info = new CGuiObjectInfoImpFeature();
99  break;
101  gui_info = new CGuiObjectInfoRegionFeature();
102  break;
104  gui_info = new CGuiObjectInfoSeqFeature();
105  break;
107  gui_info = new CGuiObjectInfoSiteFeature();
108  break;
109  default:
110  gui_info = new CGuiObjectInfoSeq_feat();
111  break;
112  }
113 
114  if (nullptr != params) {
115  const CCreateParamsSeqFeatGroup* feat_group = dynamic_cast<const CCreateParamsSeqFeatGroup*>(params);
116  if (nullptr != feat_group) {
117  gui_info->m_FeaturesGroup = feat_group->GetFeaturesGroup();
118  }
119  }
120 
121  gui_info->m_Feat.Reset(feat);
122  gui_info->m_Scope = object.scope;
123  gui_info->m_TaxId = 0;
124 
125  /// To guard against the cases where the feature contains location
126  /// with multiple seq-ids
127  const CSeq_feat_Base::TLocation& loc_obj = feat->GetLocation();
128  if (loc_obj.GetId()) {
129  gui_info->m_Location.Reset(&loc_obj);
130  }
131 
132  return gui_info;
133 }
134 
135 
137 {
138  const CFeatList& feats(*CSeqFeatData::GetFeatList());
139  CFeatListItem item;
140  if (feats.GetItemBySubtype(m_Feat->GetData().GetSubtype(), item)) {
141  return item.GetStoragekey();
142  }
143  return "";
144 }
145 
146 
148 {
149  string label;
151  return label;
152 }
153 
154 static
155 float s_GetSupportTotal(const CSeq_feat& feat)
156 {
157  float val = -1.f;
158  if (feat.IsSetExts()) {
159  const CSeq_feat::TExts& exts = feat.GetExts();
160  ITERATE (CSeq_feat::TExts, iter, exts) {
161  if ((*iter)->GetType().IsStr() &&
162  (*iter)->GetType().GetStr() == "Support" &&
163  (*iter)->GetFieldRef("Total"))
164  {
165  const auto& d = (*iter)->GetFieldRef("Total")->GetData();
166  if (d.IsInt()) {
167  val = d.GetInt();
168  break;
169  } else if (d.IsReal()) {
170  val = d.GetReal();
171  break;
172  }
173  }
174  }
175  }
176  return val;
177 }
178 
179 string s_GetSpliceSite(const CSeq_feat& feat )
180 {
181  string splice_site = "";
182 
183  if (feat.IsSetExts()) {
184  const CSeq_feat::TExts& exts = feat.GetExts();
185  ITERATE (CSeq_feat::TExts, iter, exts) {
186  if ((*iter)->GetType().IsStr() && NStr::EqualNocase((*iter)->GetType().GetStr(), "Splice Sequence")) {
187  CConstRef<CUser_field> donor = (*iter)->GetFieldRef("Donor");
188  CConstRef<CUser_field> acceptor = (*iter)->GetFieldRef("Acceptor");
189  if (!donor.IsNull() && donor->GetData().IsStr() &&
190  !acceptor.IsNull() && acceptor->GetData().IsStr()) {
191  string donor_str = donor->GetData().GetStr();
192  string acceptor_str = acceptor->GetData().GetStr();
193  splice_site = donor_str + "-" + acceptor_str + " ";
194  if (IsConsensusSplice(donor_str, acceptor_str))
195  splice_site += "(consensus)";
196  else
197  splice_site += "(non-consensus)";
198  }
199  }
200  }
201  }
202 
203  return splice_site;
204 }
205 
206 string s_GetRnaClass(const CRNA_ref &rna)
207 {
208  string rna_class;
209  do {
210  if (!rna.IsSetExt())
211  break;
212 
213  if (!rna.GetExt().IsGen())
214  break;
215 
216  if (!rna.GetExt().GetGen().IsSetClass())
217  break;
218 
219  return rna.GetExt().GetGen().GetClass();
220  } while (false);
221  return string();
222 }
223 
224 void CGuiObjectInfoSeq_feat::GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p, bool* isGeneratedBySvc) const
225 {
226  if(isGeneratedBySvc) {
227  *isGeneratedBySvc = false;
228  }
229  if (m_FeaturesGroup.empty()) {
230  x_GetFeatureToolTip(tooltip, t_title, at_p);
231  }
232  else {
233  x_GetGroupToolTip(tooltip, t_title, at_p);
234  }
235 }
236 
237 
238 void CGuiObjectInfoSeq_feat::GetLinks(ITooltipFormatter& links, bool no_ncbi_base) const
239 {
240 
241  if (m_Location.Empty())
242  return;
243 
244  CLinkUtils::TLinksMap links_by_type;
246 
247  for (const auto &feat : m_FeaturesGroup) {
248  if (!feat.first->IsSetData())
249  continue;
250  if (!feat.first->GetData().IsCdregion() && !feat.first->GetData().IsRna())
251  continue;
252 
253  CLinkUtils::AddBlastProductLink(*feat.first, m_Scope.GetObject(), links_by_type, false);
254  }
255 
256  if (links_by_type.empty())
257  return;
258 
259  links.AddLinksTitle("Links & Tools");
260 
261  for (auto it_type = links_by_type.begin(); it_type != links_by_type.end(); ++it_type) {
262  CLinkUtils::TLinks& links_by_name = it_type->second;
263 
264  for (auto it_name = links_by_name.begin(); it_name != links_by_name.end(); ++it_name) {
265  string tmp_links;
266 
267  for (size_t i = 0; i < it_name->second.size(); ++i) {
268  // This gives a separate row to each link:
269  //tmp_links += CSeqUtils::CreateLinkRow((*iter).first, (*uiter).first, (*uiter).second);
270  if (i > 0) tmp_links += ",&nbsp;";
271  tmp_links += links.CreateLink(it_name->second[i].first, it_name->second[i].second);
272  }
273 
274  links.AddLinkRow(it_name->first + ':', tmp_links, 250);
275  }
276  }
277 }
278 
279 
281 {
282  if (!m_Location)
283  return;
284 
285  string curr_text;
286  TSeqRange total_r = m_Location->GetTotalRange();
288 
289  if (strand == eNa_strand_minus) {
290  curr_text = "complement(";
291  }
292  curr_text += NStr::IntToString(total_r.GetFrom() + 1, NStr::fWithCommas);
293  if (total_r.GetLength() > 1) {
294  curr_text += "..";
295  curr_text += NStr::IntToString(total_r.GetTo() + 1, NStr::fWithCommas);
296  }
297  if (strand == eNa_strand_minus) {
298  curr_text += ")";
299  }
300  string acc = x_GetAccession();
301  if (acc.empty()) {
302  acc = "master";
303  }
304  string label = "Location";
305  if (m_IsProductFeat) {
306  label += " on ";
307  label += acc;
308  }
309  label += ":";
310  tooltip.AddRow(label, curr_text);
311 
312  string len_suffix{ " nt" };
313  if (nullptr != m_Location->GetId()) {
314  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(*m_Location);
315  if (bsh && bsh.IsAa()) {
316  len_suffix = " aa";
317  }
318  }
319 
320  TLens lens;
321  lens.push_back(TLens::value_type("Span on " + acc, NStr::IntToString(total_r.GetLength(), NStr::fWithCommas) + len_suffix));
322 
323  x_GetLocLengthRow(*m_Location, *m_Feat, lens, len_suffix);
324 
326 
327  if (lens.size() > 1) {
328  tooltip.AddSectionRow("Length");
329  ITERATE(TLens, iter, lens) {
330  tooltip.AddRow(iter->first + ":", iter->second);
331  }
332  }
333  else if (lens.size() == 1) {
334  tooltip.AddRow("Length:", lens.begin()->second);
335  }
336 }
337 
338 
340 {
341  if (!m_Location)
342  return;
343 
344  string len_suffix{ " nt" };
345  CBioseq_Handle bsh;
346  if (nullptr != m_Location->GetId()) {
347  bsh = m_Scope->GetBioseqHandle(*m_Location);
348  if (bsh && bsh.IsAa()) {
349  len_suffix = " aa";
350  }
351  }
352  if (!bsh)
353  return;
354 
355  TLens lens;
356  for (const auto &feat : m_FeaturesGroup) {
357  if (!feat.first->IsSetData())
358  continue;
359  if (feat.first->GetData().IsCdregion()) {
360  CConstRef<CSeq_loc> cds_loc = x_GetFeatLocation(*feat.first, bsh);
361  x_GetLocLengthRow(*cds_loc, *feat.first, lens, len_suffix);
362  x_GetProductLengthRow(*feat.first, lens);
363  continue;
364  }
365  if (feat.first->GetData().IsRna()) {
366  CConstRef<CSeq_loc> rna_loc = x_GetFeatLocation(*feat.first, bsh);
367  string curr_text;
368  TSeqRange total_r = rna_loc->GetTotalRange();
369  ENa_strand strand = sequence::GetStrand(*rna_loc);
370 
371  if (strand == eNa_strand_minus) {
372  curr_text = "complement(";
373  }
374  curr_text += NStr::IntToString(total_r.GetFrom() + 1, NStr::fWithCommas);
375  if (total_r.GetLength() > 1) {
376  curr_text += "..";
377  curr_text += NStr::IntToString(total_r.GetTo() + 1, NStr::fWithCommas);
378  }
379  if (strand == eNa_strand_minus) {
380  curr_text += ")";
381  }
382  tooltip.AddRow("Location:", curr_text);
383 
384 
385  string acc = x_GetAccession();
386  if (acc.empty()) {
387  acc = "master";
388  }
389 
390  lens.push_back(TLens::value_type("Span on " + acc, NStr::IntToString(total_r.GetLength(), NStr::fWithCommas) + len_suffix));
391  x_GetLocLengthRow(*rna_loc, *feat.first, lens, len_suffix);
392  continue;
393  }
394  }
395 
396  if (lens.size() > 1) {
397  tooltip.AddSectionRow("Length");
398  ITERATE(TLens, iter, lens) {
399  tooltip.AddRow(iter->first + ":", iter->second);
400  }
401  }
402  else if (lens.size() == 1) {
403  tooltip.AddRow("Length:", lens.begin()->second);
404  }
405 }
406 
407 
408 void CGuiObjectInfoSeq_feat::x_GetFeatureToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p) const
409 {
411  string text(t_title);
412  {
413  // Remove the subtype from the title
414  string to_remove(GetSubtype());
415  to_remove += ": ";
416  size_t pos = text.find(to_remove);
417  if ((pos != string::npos) && (to_remove.length() < text.length()))
418  text = text.substr(to_remove.length());
419  }
420  tooltip.AddRow(GetSubtype() + ':', text);
421 
422  // Add support info for introns: SV-2124
423  if (m_Feat->IsSetData() && m_Feat->GetData().GetSubtype() == CSeqFeatData::eSubtype_intron) {
424  auto intron_support = s_GetSupportTotal(*m_Feat);
425  tooltip.AddRow("Number of Spliced Reads:", NStr::NumericToString(intron_support));
426 
427  string splice_site = s_GetSpliceSite(*m_Feat);
428  tooltip.AddRow("Splice Sites:", splice_site);
429  }
430 
431  // Add support for ncRNA_class: SV-2907
432  if (m_Feat->IsSetData() && m_Feat->GetData().GetSubtype() == CSeqFeatData::eSubtype_ncRNA && m_Feat->GetData().IsRna()) {
433  string rna_class = s_GetRnaClass(m_Feat->GetData().GetRna());
434  if (!rna_class.empty())
435  tooltip.AddRow("ncRNA_class:", rna_class);
436  }
437 
438  const CSeq_feat::TData& data = m_Feat->GetData();
439  string curr_text;
440 
442  curr_text += "Pseudo";
443  }
445  curr_text += curr_text.empty() ? "" : ", ";
446  curr_text += "Partial";
447  }
448  if (CSeqUtils::IsPartialStart(m_Feat->GetLocation())) {
449  curr_text += curr_text.empty() ? "" : ", ";
450  curr_text += "Partial start";
451  }
452  if (CSeqUtils::IsPartialStop(m_Feat->GetLocation())) {
453  curr_text += curr_text.empty() ? "" : ", ";
454  curr_text += "Partial stop";
455  }
456  if (CSeqUtils::IsException(*m_Feat) && m_Feat->IsSetExcept_text()) {
457  curr_text += curr_text.empty() ? "" : ", ";
458  curr_text += m_Feat->GetExcept_text();
459  }
460  if (!curr_text.empty()) {
461  tooltip.AddRow("Qualifiers:", curr_text);
462  curr_text.clear();
463  }
464 
465  // Brief description goes here
466  if (data.IsSeq()) {
468  }
469  else if (data.IsGene() && data.GetGene().IsSetDesc()) {
470  curr_text += data.GetGene().GetDesc();
471  }
472  else {
474  }
475  if (curr_text != t_title) {
476  // avoid showing the duplicated information
477  tooltip.AddRow("Name:", curr_text);
478  }
479 
480  if (m_Feat->IsSetComment()
481  && m_Feat->GetComment() != t_title
482  && m_Feat->GetComment() != curr_text
483  && string::npos == t_title.find(m_Feat->GetComment())) {
484  tooltip.AddRow("Comment:", m_Feat->GetComment());
485  }
486 
487  curr_text.clear();
488 
489  // Truncate the title if it is too long
490  CLabel::TruncateLabel(&t_title, 30, 20);
491 
492  // Location-related information
493  x_AddLocationRows(tooltip);
494 
495  if (! (data.IsGene() && m_IsProductFeat)) {
496  // add portion specific to a specific sequence position
497  // such as current mouse position
498  x_AddPositionRows(tooltip, at_p);
499  }
500 
501  // add qual fields if any exist
502  if (m_Feat->IsSetQual()) {
503  bool isAnyFound(false);
504  const CSeq_feat::TQual& QualList(m_Feat->GetQual());
505  ITERATE(CSeq_feat::TQual, iQual, QualList) {
506  if ((*iQual)->IsSetQual() && (*iQual)->IsSetVal()) {
507  if (!isAnyFound) {
508  tooltip.AddSectionRow("Qualifiers");
509  isAnyFound = true;
510  }
511  tooltip.AddRow((*iQual)->GetQual() + ':', (*iQual)->GetVal());
512  }
513  }
514  }
515 }
516 
517 
518 void CGuiObjectInfoSeq_feat::x_GetGroupToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p) const
519 {
521  string text(t_title);
522  {
523  // Remove the subtype from the title
524  string to_remove(GetSubtype());
525  to_remove += ": ";
526  size_t pos = text.find(to_remove);
527  if ((pos != string::npos) && (to_remove.length() < text.length()))
528  text = text.substr(to_remove.length());
529  }
530  tooltip.AddRow(GetSubtype() + ':', text);
531 
532  const CSeq_feat::TData& data = m_Feat->GetData();
533  string curr_text;
534 
535  // Brief description goes here
536  if (data.IsSeq()) {
538  }
539  else if (data.IsGene() && data.GetGene().IsSetDesc()) {
540  curr_text += data.GetGene().GetDesc();
541  }
542  else {
544  }
545  if (curr_text != t_title) {
546  // avoid showing the duplicated information
547  tooltip.AddRow("Name:", curr_text);
548  curr_text.clear();
549  }
550  curr_text.clear();
551  string merged_feats;
552 
553  string tag_qual;
554  string status_qual;
555  // Add mRNA/CDS titles
556  for (const auto &feat : m_FeaturesGroup) {
558 
559  string feat_label;
560  CLabel::GetLabel(*feat.first, &feat_label, CLabel::eContent, m_Scope);
561  if (merged_feats.empty()) {
562  merged_feats = feat_label;
563  }
564  else {
565  merged_feats += " and " + feat_label;
566  }
567 
568  if (curr_text.empty() || !feat.first->IsSetData())
569  continue;
570  if (feat.first->GetData().IsCdregion()) {
571  tooltip.AddRow("Protein title:", curr_text);
572  if (feat.first->IsSetComment() && feat.first->GetComment() != curr_text) {
573  tooltip.AddRow("Protein comment:", feat.first->GetComment());
574  }
575  curr_text.clear();
576  }
577  else if (feat.first->GetData().IsRna()) {
578  tooltip.AddRow("RNA title:", curr_text);
579  if (feat.first->IsSetComment() && feat.first->GetComment() != curr_text) {
580  tooltip.AddRow("RNA comment:", feat.first->GetComment());
581  }
582  curr_text.clear();
583  }
584 
585  if (!tag_qual.empty() && !status_qual.empty())
586  continue;
587 
588  // add qual fields if any exist
589  if (!feat.first->IsSetQual()) {
590  continue;
591  }
592 
593  const CSeq_feat::TQual& QualList(feat.first->GetQual());
594  ITERATE(CSeq_feat::TQual, iQual, QualList) {
595  if (0 == NStr::CompareNocase((*iQual)->GetQual(), "tag")) {
596  tag_qual = (*iQual)->GetVal();
597  }
598  else if (0 == NStr::CompareNocase((*iQual)->GetQual(), "status")) {
599  status_qual = (*iQual)->GetVal();
600  }
601  }
602  }
603  if (!merged_feats.empty()) {
604  tooltip.AddRow("Merged features:", merged_feats);
605  }
606 
607  // Truncate the title if it is too long
608  CLabel::TruncateLabel(&t_title, 30, 20);
609 
610  // Location-related information
611  x_AddGroupLocationRows(tooltip);
612 
613  // Add product information
614  for (const auto &feat : m_FeaturesGroup) {
615  SConstScopedObject scoped_obj(feat.first, m_Scope);
616 
617  CIRef<IGuiObjectInfo> gui_info(CreateObjectInterface<IGuiObjectInfo>(scoped_obj, NULL));
618  if (!gui_info)
619  continue;
620 
621  CGuiObjectInfoSeq_feat* gui_info_feat = dynamic_cast<CGuiObjectInfoSeq_feat*>(gui_info.GetPointer());
622  if (nullptr == gui_info_feat)
623  continue;
624 
625  gui_info_feat->SetMappingInfo(feat.second);
626 
627  CIRef<ITooltipFormatter> extra_info = tooltip.CreateInstance();
628  gui_info_feat->x_AddExtraInfo(*extra_info, at_p);
629  if (!extra_info->IsEmpty()) {
630  string feat_label;
631  CLabel::GetLabel(*feat.first, &feat_label, CLabel::eContent, m_Scope);
632  tooltip.AddSectionRow(feat_label);
633  tooltip.Append(*extra_info);
634  }
635  }
636 
637  { // Add qualifiers
638  curr_text = "";
640  curr_text += "Pseudo";
641  }
643  curr_text += curr_text.empty() ? "" : ", ";
644  curr_text += "Partial";
645  }
646  if (CSeqUtils::IsPartialStart(m_Feat->GetLocation())) {
647  curr_text += curr_text.empty() ? "" : ", ";
648  curr_text += "Partial start";
649  }
650  if (CSeqUtils::IsPartialStop(m_Feat->GetLocation())) {
651  curr_text += curr_text.empty() ? "" : ", ";
652  curr_text += "Partial stop";
653  }
654  if (CSeqUtils::IsException(*m_Feat) && m_Feat->IsSetExcept_text()) {
655  curr_text += curr_text.empty() ? "" : ", ";
656  curr_text += m_Feat->GetExcept_text();
657  }
658  if (!curr_text.empty() && (tag_qual.empty() && status_qual.empty())) {
659  tooltip.AddRow("Qualifiers:", curr_text);
660  curr_text.clear();
661  }
662  else if (!tag_qual.empty() || !status_qual.empty()) {
663  tooltip.AddSectionRow("Qualifiers");
664  if (!tag_qual.empty())
665  tooltip.AddRow("Tag:", tag_qual);
666  if (!status_qual.empty())
667  tooltip.AddRow("Status:", status_qual);
668  if (!curr_text.empty())
669  tooltip.AddRow(curr_text);
670  curr_text.clear();
671  }
672  }
673 }
674 
675 
677 {
678  if (at_p != -1) {
679  CIRef<ITooltipFormatter> extra_info = tooltip.CreateInstance();
680  x_AddExtraInfo(*extra_info, at_p);
681  tooltip.AddSectionRow("Positional Info");
682 
683  string master_seq_id{ "Position on master:" };
684  string assm_acc = x_GetAccession();
685  if (!assm_acc.empty()) {
686  master_seq_id = assm_acc + " position:";
687  }
688  tooltip.AddRow(master_seq_id, NStr::UIntToString(at_p + 1, NStr::fWithCommas));
689  TSignedSeqPos feat_pos = x_ToFeature(at_p);
690  if ((feat_pos != -1) && (feat_pos != at_p) && !m_Feat->IsSetProduct() && !m_Feat->GetData().IsCdregion()) {
691  if (m_Feat->GetData().IsRna()) {
692  tooltip.AddRow(x_GetProductLabel() + " position:", NStr::IntToString(feat_pos + 1, NStr::fWithCommas));
693  }
694  else if (m_Feat->GetData().IsGene()) {
695  tooltip.AddRow("Gene position:", NStr::IntToString(feat_pos + 1, NStr::fWithCommas));
696  }
697  else {
698  tooltip.AddRow("Position:", NStr::IntToString(feat_pos + 1, NStr::fWithCommas));
699  }
700  }
701  tooltip.Append(*extra_info);
702  }
703 }
704 
705 
706 static const int kSeqTooltipLength = 15;
707 
708 static
710 {
712  CSeq_annot_Handle annot = feat.GetAnnot();
713  string annot_str;
714  if (annot && annot.IsNamed()) {
715  annot_str = annot.GetName();
716  sel.AddNamedAnnots(annot_str);
717  if (NStr::StartsWith(annot_str, "NA0")) {
718  sel.IncludeNamedAnnotAccession(annot_str);
719  }
720  }
721  return sel;
722 }
723 
724 
726 {
727  if ( !m_Location ) return;
728 
729  CSeqFeatData::E_Choice type = m_Feat->GetData().Which();
730  CSeqFeatData::ESubtype subtype = m_Feat->GetData().GetSubtype();
731  CConstRef<CSeq_loc> exon_loc;
734 // CMappedFeat mrna = feature::GetBestMrnaForCds(m_MappedFeat, nullptr, &sel);
735 // if (mrna)
736 // exon_loc.Reset(&mrna.GetLocation());
737  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_cdregion);
738  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_mRNA);
739  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_C_region);
740  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_V_segment);
741  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_D_segment);
742  sel.IncludeFeatSubtype(CSeqFeatData::eSubtype_J_segment);
743  sel.SetResolveAll().SetAdaptiveDepth().SetOverlapTotalRange();
744 
745  feature::CFeatTree tree;
746  CFeat_CI feat_it(*m_Scope, *m_Location, sel);
747  tree.AddFeatures(feat_it);
748  CMappedFeat parent = tree.GetParent(m_MappedFeat);
749  if (parent)
750  exon_loc.Reset(&parent.GetLocation());
751 
752 
753  } else if (type == CSeqFeatData::e_Rna
754  || subtype == CSeqFeatData::eSubtype_C_region
757  || subtype == CSeqFeatData::eSubtype_J_segment) {
758  exon_loc.Reset(&*m_Location);
759  }
760  if (exon_loc) {
762  int count = 0, prev_to = -1;
763  for (; exon_loc_ci; ++exon_loc_ci) {
764  const auto&& e = exon_loc_ci.GetRange();
765  bool minus = exon_loc_ci.GetStrand() == eNa_strand_minus;
766  ++count;
767  if (at_p >= e.GetFrom() && at_p <= e.GetTo()) {
768  tooltip.AddRow("Exon:", NStr::UIntToString(count, NStr::fWithCommas) + " of " + NStr::NumericToString(exon_loc_ci.GetSize(), NStr::fWithCommas));
769  break;
770  } else if (prev_to != -1) {
771  bool intron = false;
772  if (minus) {
773  intron = at_p > e.GetTo() && at_p < (TSeqPos)prev_to;
774  } else {
775  intron = at_p > (TSeqPos)prev_to && at_p < e.GetFrom();
776  }
777  if (intron) {
778  tooltip.AddRow("Intron:", NStr::UIntToString(count - 1, NStr::fWithCommas) + " of " + NStr::NumericToString(exon_loc_ci.GetSize() - 1, NStr::fWithCommas));
779  break;
780  }
781  }
782  prev_to = minus ? e.GetFrom() : e.GetTo();
783  }
784  }
785 
786 
788  SFeatSeg seg = x_GetHitSeg(at_p);
789  if (seg.m_Type != SFeatSeg::eType_OutOfBound) {
790  //x_GetSplicedSeqTitle(seg, at_p, tooltip);
791  if (m_Feat->IsSetProduct() || (CSeqFeatData::eSubtype_cdregion == m_Feat->GetData().GetSubtype())) {
792  x_GetProductSequence(seg, at_p, tooltip);
793  }
794  }
795  }
796 }
797 
798 
799 void CGuiObjectInfoSeq_feat::x_GetLocLengthRow(const CSeq_loc &loc, const CSeq_feat &feat, TLens &lens, const string &len_suffix) const
800 {
801  if (!loc.IsInt() && !loc.IsPnt()) {
802  try {
804  if (feat.GetData().IsCdregion()) {
805  lens.push_back(TLens::value_type("CDS length", NStr::IntToString(len, NStr::fWithCommas) + len_suffix));
806  }
807  else {
808  lens.push_back(TLens::value_type("Aligned length", NStr::IntToString(len, NStr::fWithCommas) + len_suffix));
809  }
810  }
811  catch (const CException&) {
812  }
813  }
814 }
815 
816 
818 {
819  if (feat.IsSetProduct()) {
820  try {
821  CBioseq_Handle h = m_Scope->GetBioseqHandle(*feat.GetProduct().GetId());
822 
823  if (h) {
824  string product = feat.GetData().IsRna() ? "Sequence length" : "Protein length";
825  lens.push_back(TLens::value_type(product, NStr::IntToString(h.GetBioseqLength(), NStr::fWithCommas) + (h.IsAa() ? " aa" : " nt")));
826  }
827  }
828  catch (const CException&) {
829  }
830  }
831  else {
832  string product_len = feat.GetNamedQual("product_length");
833  if (!product_len.empty()) {
834  try {
835  string product = feat.GetData().IsRna() ? "Sequence length" : "Protein length";
836  product_len += feat.GetData().IsRna() ? " nt" : " aa";
837  lens.push_back(TLens::value_type(product, product_len));
838  }
839  catch (const CException&) {
840  }
841  }
842  }
843 }
844 
845 
847 {
848  const CSeq_feat_Base::TLocation& loc_obj = feat.GetLocation();
850  /// guard against the cases where the feature contains location
851  /// with multiple seq-ids
852  if (!loc_obj.GetId()) {
853  loc = CSeqUtils::MixLocToLoc(loc_obj, handle);
854  }
855  if (!loc) {
856  loc.Reset(&loc_obj);
857  }
858  return loc;
859 }
860 
861 
864 {
865  SFeatSeg seg;
866  int pre_dir = 0; // Previous segment strand (0:unknow, 1:forward, -1:reverse)
867  TSeqPos pre_pos = -1; // Previous segment end position close to the current segment
868  TSeqPos prod_start = 0; // Current product start pos (in nucleotide bases)
869 
870  for (CSeq_loc_CI iter(*m_Location); iter; ++iter) {
871  CSeq_loc_CI::TRange range = iter.GetRange();
872  int curr_dir = 1;
873  if (iter.GetStrand() == eNa_strand_minus) {
874  curr_dir = -1;
875  }
876 
877  // check if it hits an exon
878  if (pos >= range.GetFrom() && pos <= range.GetTo()) {
880  seg.m_CrossOrigin = false;
881  seg.m_Range = range;
882  seg.m_ProdRange.Set(prod_start, prod_start + range.GetLength() - 1);
883  seg.m_ExonDirForward = curr_dir > 0;
884  break;
885  }
886 
887  // initialize current segment strand
888  if (pre_pos != -1) {
889  // check if it hits an intron
890  TSeqPos curr_pos = curr_dir > 0 ? range.GetFrom() : range.GetTo();
891 
892  if (pre_dir > 0 && curr_pos > pre_pos) {
893  if (pos > pre_pos && pos < curr_pos &&
894  (seg.m_Range.Empty() || seg.m_Range.GetLength() > curr_pos - pre_pos + 1)) {
895  seg.m_Range.Set(pre_pos, curr_pos);
897  seg.m_CrossOrigin = false;
898  seg.m_ProdRange.Set(prod_start - 1, prod_start);
899  seg.m_ExonDirForward = pre_dir > 0;
900  }
901  } else if (pre_dir < 0 && curr_pos < pre_pos) {
902  if (pos < pre_pos && pos > curr_pos &&
903  (seg.m_Range.Empty() || seg.m_Range.GetLength() > pre_pos - curr_pos + 1)) {
904  seg.m_Range.Set(curr_pos, pre_pos);
906  seg.m_CrossOrigin = false;
907  seg.m_ProdRange.Set(prod_start - 1, prod_start);
908  seg.m_ExonDirForward = pre_dir > 0;
909  }
910  } else {
911  // The intron must cross the origin
912  // It is intentional to make the 'from' > 'to' for an intron span
913  // crossing the origin.
914  if (curr_pos > pre_pos && (pos > curr_pos || pos < pre_pos)) {
915  seg.m_Range.Set(curr_pos, pre_pos);
917  seg.m_CrossOrigin = true;
918  seg.m_ProdRange.Set(prod_start - 1, prod_start);
919  seg.m_ExonDirForward = pre_dir > 0;
920  } else if (curr_pos < pre_pos && (pos > pre_pos || pos < curr_pos)) {
921  seg.m_Range.Set(pre_pos, curr_pos);
923  seg.m_CrossOrigin = true;
924  seg.m_ProdRange.Set(prod_start - 1, prod_start);
925  seg.m_ExonDirForward = pre_dir > 0;
926  }
927  }
928  }
929 
930  // backup current segmnet attributes
931  pre_pos = curr_dir > 0 ? range.GetTo() : range.GetFrom();
932  prod_start += range.GetLength();
933  pre_dir = curr_dir;
934  }
935 
936  return seg;
937 }
938 
939 
940 // This is exactly as it done in Sequin.
942 {
943  TSeqPos offset = 0; // translation offset
944  if (m_Feat->IsSetData() && m_Feat->GetData().GetSubtype() == CSeqFeatData::eSubtype_cdregion) {
945  const CCdregion& cdr = m_Feat->GetData().GetCdregion();
946  if (cdr.IsSetFrame ()) {
947  switch (cdr.GetFrame ()) {
948  case CCdregion::eFrame_two :
949  offset = 1;
950  break;
952  offset = 2;
953  break;
954  default :
955  break;
956  }
957  }
958  }
959  return offset;
960 }
961 
962 
964 {
965  if (m_MappingInfo.empty() && (m_Feat->GetData().GetSubtype() != CSeqFeatData::eSubtype_gene)) {
966  return -1;
967  }
968  if (!m_MappingInfo.empty()) {
969  for (const auto& mi : m_MappingInfo) {
970  const auto& prod_int = *mi.first;
971  const auto& gen_int = *mi.second;
972  if (pos < gen_int.GetFrom() || pos > gen_int.GetTo())
973  continue;
974  auto p = gen_int.GetStrand() == eNa_strand_minus ? gen_int.GetTo() - pos : pos - gen_int.GetFrom();
975  return (TSignedSeqPos)(prod_int.GetFrom() + p);
976  }
977  }
978  else if (m_Location) {
979  auto total_rng = m_Location->GetTotalRange();
980  if ((total_rng.GetFrom() <= pos) && (pos <= total_rng.GetTo())) {
981  if (m_Location->IsReverseStrand()) {
982  pos = total_rng.GetTo() - pos;
983  }
984  else {
985  pos = pos - total_rng.GetFrom();
986  }
987  }
988  else {
989  return -1;
990  }
991 
992  }
993  return (TSignedSeqPos)(pos);
994 }
995 
996 
998 {
999  TSignedSeqPos prod_pos = x_ToFeature(pos);
1000  if (-1 == prod_pos)
1001  return -1;
1002  TSeqPos offset = x_GetProtOffset(); // initial translation offset
1003  return (prod_pos - offset) / 3;
1004 }
1005 
1006 
1008  TSeqPos at_p,
1009  ITooltipFormatter& tooltip) const
1010 {
1011  CBioseq_Handle top_handle = m_Scope->GetBioseqHandle(*m_Location->GetId());
1012  if ( !top_handle ) {
1013  return;
1014  }
1016  const TSeqPos kSeqExonLength = 10;
1017  const TSeqPos kSeqIntronLength = 8;
1018 
1019  if (seg.m_Type == SFeatSeg::eType_Intron) {
1020  // add detailed title for intron
1021  try {
1022  string value;
1023  const TSeqRange& intr = seg.m_Range;
1024  TSeqPos left_stop = intr.GetFrom() + 1;
1025  TSeqPos left_start = (TSeqPos) (left_stop > kSeqExonLength ?
1026  left_stop - kSeqExonLength : 0);;
1027  string seq_left, seq_ins_l, seq_ins_r, seq_right;
1028 
1029  vec.GetSeqData(left_start, left_stop, seq_left);
1030  TSeqPos right_start = intr.GetTo();
1031 
1032  value = seq_left + "] ";
1033  if (seg.m_CrossOrigin) {
1034  vec.GetSeqData(left_stop, left_stop + kSeqIntronLength, seq_ins_l);
1035  value += seq_ins_l;
1036  if (vec.size() > left_stop + kSeqIntronLength) {
1037  value += "...";
1038  }
1039  value += "[origin]";
1040  if (right_start < kSeqIntronLength) {
1041  vec.GetSeqData(0, right_start, seq_ins_r);
1042  } else {
1043  value += "...";
1044  vec.GetSeqData(right_start - kSeqIntronLength, right_start, seq_ins_r);
1045  }
1046  value += seq_ins_r;
1047  } else if (intr.GetLength() > kSeqIntronLength * 2) {
1048  vec.GetSeqData(left_stop, left_stop + kSeqIntronLength, seq_ins_l);
1049  vec.GetSeqData(right_start - kSeqIntronLength, right_start, seq_ins_r);
1050  value += seq_ins_l + "..." + seq_ins_r;
1051  } else {
1052  vec.GetSeqData(left_stop, right_start + 1, seq_ins_l);
1053  value += seq_ins_l;
1054  }
1055  vec.GetSeqData(right_start, right_start + kSeqExonLength, seq_right);
1056  value += " [" + seq_right;
1057  tooltip.AddRow("Spliced sequence:", value);
1058  }
1059  catch (CException&) {
1060  /// ignore exceptions
1061  tooltip.AddRow("Spliced sequence:", "Not available");
1062  }
1063  } else if (seg.m_Type == SFeatSeg::eType_Exon) {
1064  string value;
1065  TSeqPos left = (TSeqPos) (at_p > kSeqIntronLength ? at_p - kSeqIntronLength : 0);
1066  TSeqPos right = (TSeqPos) (at_p + kSeqIntronLength + 1);
1067 
1068  int pos = at_p - left;
1069  vec.GetSeqData(left, right, value);
1070  if (!seg.m_ExonDirForward) {
1071  string rev;
1072  CSeqManip::ReverseComplement(value, CSeqUtil::e_Iupacna, 0, static_cast<TSeqPos>(value.length()), rev);
1073  swap(rev, value);
1074  }
1075  value.insert(pos + 1, "]");
1076  value.insert(pos, "[");
1077 
1078  tooltip.AddRow("Sequence:", value);
1079  }
1080 }
1081 
1082 
1083 
1085  TSeqPos at_p,
1086  ITooltipFormatter& tooltip) const
1087 {
1088  _ASSERT(m_Feat->IsSetProduct() || (CSeqFeatData::eSubtype_cdregion == m_Feat->GetData().GetSubtype()));
1089  try {
1090  bool isCDS{ CSeqFeatData::eSubtype_cdregion == m_Feat->GetData().GetSubtype() };
1091  TSeqPos base{ 1 };
1092  CRef<CSeqVector> prod_vec;
1093  if (m_Feat->IsSetProduct()) {
1094  const CSeq_loc& product = m_Feat->GetProduct();
1095  prod_vec.Reset(new CSeqVector(product, *m_Scope, CBioseq_Handle::eCoding_Iupac));
1096  } else {
1097  prod_vec.Reset(new CSeqVector(m_Feat->GetLocation(), *m_Scope, CBioseq_Handle::eCoding_Iupac));
1098  base = 3;
1099  }
1100  auto orig_pos = at_p;
1101  // are we in protein product gap?
1102  bool in_prod_gap{ false };
1103 
1104  // the easiest way to find out if we are in the protein sequence
1105  // gap is to compare prot. sequence positions on both sides of the
1106  // inron. If they are diffenet, we must be in the gap.
1107  // Otherwise it's not the gap
1108 
1109  TSignedSeqPos prod_pos = 0;
1110 
1111  TSignedSeqPos prod_pos1 = isCDS ? x_ToProduct(seg.m_ProdRange.GetFrom()) : x_ToFeature(seg.m_ProdRange.GetFrom());
1112  TSignedSeqPos prod_pos2 = isCDS ? x_ToProduct(seg.m_ProdRange.GetTo()) : x_ToFeature(seg.m_ProdRange.GetTo());
1113  const TSeqRange& intr = seg.m_Range;
1114 
1115  // first, if at_p is in the intron, move it to one end of the nearby exon
1116  if (seg.m_Type == SFeatSeg::eType_Intron) {
1117  if (prod_pos1 != prod_pos2) {
1118  in_prod_gap = true;
1119 
1120  bool at_from_end = false;
1121  if ((seg.m_CrossOrigin && at_p > intr.GetFrom()) ||
1122  (!seg.m_CrossOrigin && at_p - intr.GetFrom() < intr.GetTo() - at_p)) {
1123  at_from_end = true;
1124  }
1125 
1126  if (at_from_end == seg.m_ExonDirForward) {
1127  prod_pos = prod_pos1;
1128  } else {
1129  prod_pos = prod_pos2;
1130  }
1131  } else {
1132  prod_pos = prod_pos1;
1133  }
1134  } else { // in an exon
1135  // the real position in protein sequence
1136  prod_pos = isCDS ? x_ToProduct(orig_pos) : x_ToFeature(orig_pos);
1137 
1138  if (seg.m_ExonDirForward) {
1139  at_p = seg.m_ProdRange.GetFrom() + at_p - intr.GetFrom();
1140  } else {
1141  at_p = seg.m_ProdRange.GetFrom() + intr.GetTo() - at_p;
1142  }
1143  }
1144  if (-1 == prod_pos)
1145  return;
1146 
1147  TSeqPos from = prod_pos > kSeqTooltipLength ? prod_pos - kSeqTooltipLength : 0;
1148  from *= base;
1149  TSeqPos to = min(prod_pos + kSeqTooltipLength, int(prod_vec->size()));
1150  to *= base;
1151 
1152  if (seg.m_Type != SFeatSeg::eType_Intron) {
1153  if (!m_MappingInfo.empty()) {
1154  CSeqUtils::TMappingInfo mapping_info;
1155  const CSeqUtils::TMappingInfo* mapping_info_ptr = nullptr;
1156  if (isCDS) {
1157  mapping_info_ptr = &m_MappingInfo;
1158  } else if (m_Feat->GetData().GetSubtype() == CSeqFeatData::eSubtype_mRNA) {
1159  if (m_MappedFeat) {
1161  CSeq_annot_Handle annot = m_MappedFeat.GetAnnot();
1162  string annot_str;
1163  if (annot && annot.IsNamed()) {
1164  annot_str = annot.GetName();
1165  sel.AddNamedAnnots(annot_str);
1166  if (NStr::StartsWith(annot_str, "NA0")) {
1167  sel.IncludeNamedAnnotAccession(annot_str);
1168  }
1169  }
1170  // The following should have been used instead (and the class would not need m_MappedFeat member)
1171  // and AnnotSelector would not have been needed as well
1172  // but tookit has this function undefined CXX-11019
1173  // CConstRef<CSeq_feat> cds_feat = sequence::GetBestCdsForMrna(*m_Feat, annot.GetTSE_Handle());
1174 
1175  CMappedFeat cds_feat = feature::GetBestCdsForMrna(m_MappedFeat, nullptr, &sel);
1176  if (cds_feat) {
1177  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(*m_Location);
1178  CSeqUtils::GetMappingInfo(cds_feat, bsh, mapping_info, annot_str);
1179  mapping_info_ptr = &mapping_info;
1180  }
1181  }
1182  }
1183  if (mapping_info_ptr != nullptr) {
1184  for (const auto& mi : *mapping_info_ptr) {
1185  const auto& prod_int = *mi.first;
1186  const auto& gen_int = *mi.second;
1187  if (orig_pos < gen_int.GetFrom() || orig_pos > gen_int.GetTo())
1188  continue;
1189  auto p = gen_int.GetStrand() == eNa_strand_minus ? gen_int.GetTo() - orig_pos : orig_pos - gen_int.GetFrom();
1190  p += prod_int.GetFrom();
1191  tooltip.AddRow("CDS position:", NStr::UIntToString(p + 1, NStr::fWithCommas));
1192  break;
1193  }
1194  }
1195  }
1196  tooltip.AddRow(x_GetProductLabel() + " position:", NStr::UIntToString(prod_pos + 1, NStr::fWithCommas));
1197  }
1198 
1199  string value;
1200  string trans_seq;
1201  const CGenetic_code* genetic_code{ nullptr };
1202  if (isCDS && m_Feat->GetData().GetCdregion().IsSetCode()) {
1203  genetic_code = &(m_Feat->GetData().GetCdregion().GetCode());
1204  }
1205  string prod_seq;
1206 
1207  prod_vec->GetSeqData(from, prod_pos * base, prod_seq);
1208  if (base == 3) {
1209  CSeqTranslator::Translate(prod_seq, trans_seq, CSeqTranslator::fIs5PrimePartial, genetic_code);
1210  value += trans_seq;
1211  }
1212  else {
1213  value += prod_seq;
1214  }
1215  prod_vec->GetSeqData(prod_pos * base, prod_pos * base + base, prod_seq);
1216  string first_bracket = "[";
1217  string second_bracket = "]";
1218 
1219  if (base == 3) {
1220  CSeqTranslator::Translate(prod_seq, trans_seq, CSeqTranslator::fIs5PrimePartial, genetic_code);
1221  prod_seq = trans_seq;
1222  }
1223 
1224  if (seg.m_Type == SFeatSeg::eType_Intron) {
1225  if (in_prod_gap) {
1226  if (prod_pos == prod_pos1) {
1227  value += prod_seq + first_bracket + "..." + second_bracket;
1228  }
1229  else {
1230  value += first_bracket + "..." + second_bracket + prod_seq;
1231  }
1232  }
1233  else {
1234  value += first_bracket + prod_seq + "..." + prod_seq + second_bracket;
1235  }
1236  }
1237  else {
1238  value += first_bracket + prod_seq + second_bracket;
1239  }
1240 
1241  prod_vec->GetSeqData(prod_pos * base + base, to, prod_seq);
1242  if (base == 3) {
1243  CSeqTranslator::Translate(prod_seq, trans_seq, CSeqTranslator::fIs5PrimePartial, genetic_code);
1244  value += trans_seq;
1245  }
1246  else {
1247  value += prod_seq;
1248  }
1249 
1250  tooltip.AddRow(x_GetProductLabel() + " sequence:", value);
1251  } catch (CException&) {
1252  }
1253 }
1254 
1255 
1257 {
1258  switch (m_Feat->GetData().GetSubtype()) {
1261  return "Pseudo protein";
1262  else
1263  return "Protein";
1265  return "mRNA";
1275  return "RNA";
1276  default:
1277  return "Product";
1278  }
1279 }
1280 
1282 {
1283  if ((nullptr != m_Location->GetId()) && (nullptr != m_Scope)) {
1284  return sequence::GetAccessionForId(*m_Location->GetId(), *m_Scope);
1285  }
1286  return string();
1287 }
1288 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CBioseq_Handle –.
CCdregion –.
Definition: Cdregion.hpp:66
const TSeqFeatVector & GetFeaturesGroup() const
CFeatListItem - basic configuration data for one "feature" type.
string GetStoragekey() const
CConfigurableItems - a static list of items that can be configured.
bool GetItemBySubtype(int subtype, CFeatListItem &config_item) const
CFeat_CI –.
Definition: feat_ci.hpp:64
static void RegisterFactory(const string &interface_name, IInterfaceFactory *factory)
static void AddBlastProductLink(const objects::CSeq_feat &feat, objects::CScope &scope, TLinksMap &links, bool relative)
Definition: link_utils.cpp:605
static void AddFeatureLinks(const objects::CSeq_feat &feat, const objects::CBioseq_Handle &handle, const string &tax_id_file, TLinksMap &links, bool relative=true, bool exclude_self_links=false)
CMappedFeat –.
Definition: mapped_feat.hpp:59
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
ESubtype GetSubtype(void) const
static const CFeatList * GetFeatList()
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
@ e_Iupacna
Definition: sequtil.hpp:47
CSeqVector –.
Definition: seq_vector.hpp:65
CSeq_annot_Handle –.
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
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Return a field reference representing the tokenized key, or a NULL reference if the key doesn't exist...
Definition: User_field.cpp:226
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
Definition: map.hpp:338
bool IsConsensusSplice(const string &splice5, const string &splice3)
Consensus splice is GY..AG or AT..AC.
int offset
Definition: replacements.h:160
char data[12]
Definition: iconv.c:80
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
static bool IsException(const objects::CSeq_feat &feat)
Definition: utils.cpp:962
static bool IsPartialStart(const objects::CSeq_loc &loc)
Definition: utils.cpp:937
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static bool IsPartialFeature(const objects::CSeq_feat &feat)
Definition: utils.cpp:926
static bool IsPseudoFeature(const objects::CSeq_feat &feat)
Definition: utils.cpp:910
static bool IsPartialStop(const objects::CSeq_loc &loc)
Definition: utils.cpp:943
static CRef< objects::CSeq_loc > MixLocToLoc(const objects::CSeq_loc &mix_loc, const objects::CBioseq_Handle &handle)
Create a new seq-loc with a unique seq-id from a "mixed" loc.
Definition: utils.cpp:661
static void GetMappingInfo(const objects::CMappedFeat &mapped_feat, const objects::CBioseq_Handle &bsh, TMappingInfo &info, const string &annot=string())
Definition: utils.cpp:2281
vector< TMappedInt > TMappingInfo
Definition: utils.hpp:165
bool m_ExonDirForward
Previous segment's strand of an intron or this segment's strand if it is an exon.
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
virtual string CreateLink(const string &sLabel, const string &sUrl) const =0
construct the HTML code for a link from the displayed text label and supplied URL
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
virtual CIRef< ITooltipFormatter > CreateInstance()=0
creates another instance of the same tooltip formatter
void x_AddGroupLocationRows(ITooltipFormatter &tooltip) const
void x_AddPositionRows(ITooltipFormatter &tooltip, TSeqPos at_p) const
Add position-specific (current cursor position) information.
void x_AddLocationRows(ITooltipFormatter &tooltip) const
Add feature location-related information.
void x_GetProductLengthRow(const objects::CSeq_feat &feat, TLens &lens) const
virtual void AddLinksTitle(const string &sTitle)=0
add a row with the links title
CRef< objects::CScope > m_Scope
void x_GetFeatureToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1) const
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
bool m_IsProductFeat
Flag to indicate if the feature is a feature projected from CDS product.
void x_GetSplicedSeqTitle(const SFeatSeg &seg, TSeqPos at_p, ITooltipFormatter &tooltip) const
CConstRef< objects::CSeq_loc > x_GetFeatLocation(const objects::CSeq_feat &feat, const objects::CBioseq_Handle &handle) const
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)=0
add a row with two columns
void x_GetLocLengthRow(const objects::CSeq_loc &loc, const objects::CSeq_feat &feat, TLens &lens, const string &len_suffix) const
CConstRef< objects::CSeq_feat > m_Feat
SFeatSeg x_GetHitSeg(TSeqPos pos) const
CSeqUtils::TMappingInfo m_MappingInfo
virtual void AddSectionRow(const string &sContents)=0
add a section row
void SetMappingInfo(const CSeqUtils::TMappingInfo &mapping_info)
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
void x_GetProductSequence(const SFeatSeg &seg, TSeqPos at_p, ITooltipFormatter &tooltip) const
void x_AddExtraInfo(ITooltipFormatter &tooltip, TSeqPos at_p) const
virtual string GetSubtype() const
void x_GetGroupToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1) const
virtual string GetLabel() const
virtual void Append(const ITooltipFormatter &tooltip)=0
appends another formatter to this one
virtual void GetLinks(ITooltipFormatter &links, bool no_ncbi_base) const
Get a set of links.
CConstRef< objects::CSeq_loc > m_Location
Mapped location in top sequence coordinate (can be set externally).
TSignedSeqPos x_ToFeature(TSeqPos pos) const
TSeqRange m_ProdRange
in nucleotide coord.
static CGuiObjectInfoSeq_feat * CreateObject(SConstScopedObject &object, ICreateParams *params)
TSignedSeqPos x_ToProduct(TSeqPos pos) const
@ eContent
Definition: label.hpp:62
@ eDescription
Definition: label.hpp:68
@ eDescriptionBrief
Definition: label.hpp:67
string GetLabel(const CSeq_id &id)
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
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
size_t GetSize(void) const
Get number of ranges.
Definition: Seq_loc.cpp:2636
TRange GetRange(void) const
Get the range.
Definition: Seq_loc.hpp:1042
ENa_strand GetStrand(void) const
Definition: Seq_loc.hpp:1056
@ eOrder_Biological
Iterate sub-locations in positional order.
Definition: Seq_loc.hpp:462
CMappedFeat GetBestCdsForMrna(const CMappedFeat &mrna_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3360
@ fFGL_NoQualifiers
Leave out qualifiers.
Definition: feature.hpp:76
@ fFGL_Content
Include its content if there is any.
Definition: feature.hpp:73
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
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...
string GetAccessionForId(const objects::CSeq_id &id, CScope &scope, EAccessionVersion use_version=eWithAccessionVersion, EGetIdType flags=0)
Retrieve the accession string for a Seq-id.
Definition: sequence.cpp:708
static void Translate(const string &seq, string &prot, const CGenetic_code *code, bool include_stop=true, bool remove_trailing_X=false, bool *alt_start=NULL, bool is_5prime_complete=true, bool is_3prime_complete=true)
Translate a string using a specified genetic code.
Definition: sequence.cpp:4095
@ fIs5PrimePartial
= 0x4 Translate first codon even if not start codon (because sequence is 5' partial)
Definition: sequence.hpp:984
bool IsNamed(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
TSeqPos GetBioseqLength(void) const
bool IsAa(void) const
const string & GetName(void) const
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
const CSeq_loc & GetLocation(void) const
SAnnotSelector & IncludeNamedAnnotAccession(const string &acc, int zoom_level=0)
SAnnotSelector & AddNamedAnnots(const CAnnotName &name)
Add named annot to set of annots names to look for.
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
Definition: seq_vector.cpp:304
TSeqPos size(void) const
Definition: seq_vector.hpp:291
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
Definition: ncbiobj.hpp:1385
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType & GetObject(void)
Get object.
Definition: ncbiobj.hpp:1011
TObjectType & GetObject(void) const
Get object.
Definition: ncbiobj.hpp:1697
position_type GetLength(void) const
Definition: range.hpp:158
TThisType & Set(position_type from, position_type to)
Definition: range.hpp:188
bool Empty(void) const
Definition: range.hpp:148
#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 int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5109
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
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
static const char label[]
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsStr(void) const
Check if variant Str is selected.
const TExts & GetExts(void) const
Get the Exts member data.
Definition: Seq_feat_.hpp:1477
bool IsCdregion(void) const
Check if variant Cdregion is selected.
list< CRef< CUser_object > > TExts
Definition: Seq_feat_.hpp:127
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:534
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
bool IsSetExts(void) const
set of extensions; will replace 'ext' field Check if a value has been assigned to Exts data member.
Definition: Seq_feat_.hpp:1465
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
Definition: Cdregion_.hpp:509
@ eFrame_three
reading frame
Definition: Cdregion_.hpp:98
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
bool IsPnt(void) const
Check if variant Pnt is selected.
Definition: Seq_loc_.hpp:540
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
USING_SCOPE(objects)
structural variants
void initCGuiObjectInfoSeq_feat()
string s_GetRnaClass(const CRNA_ref &rna)
static float s_GetSupportTotal(const CSeq_feat &feat)
static const int kSeqTooltipLength
string s_GetSpliceSite(const CSeq_feat &feat)
static SAnnotSelector s_GetAnnotSelector(CSeqFeatData::ESubtype subtype, const CMappedFeat &feat)
int i
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
T minus(T x_)
T min(T x_, T y_)
Data structure for holding a feature segment.
SAnnotSelector –.
Definition: type.c:6
#define _ASSERT
Modified on Thu Apr 25 08:18:32 2024 by modify_doxy.py rev. 669887