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

Go to the SVN repository for this file.

1 /* $Id: search_utils.cpp 47033 2022-05-23 19:38:42Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
42 
44 #include <objmgr/scope.hpp>
45 #include <objmgr/feat_ci.hpp>
46 #include <objmgr/util/sequence.hpp>
47 #include <objmgr/util/feature.hpp>
48 
51 #include <util/xregexp/regexp.hpp>
52 
54 #include <gui/objutils/snp_gui.hpp>
62 
63 #include <unordered_map>
64 
67 
68 namespace NSearchFeatPanel
69 {
70 
71  bool CTrackFeatSubtype::Track(const CTempTrackProxy*, const CLayoutTrack* t, bool visible)
72  {
73  if (visible)
74  {
75  const IFeatureTrackBase* ft = dynamic_cast<const IFeatureTrackBase*>(t);
76  if (ft) {
77  string annot = ft->GetAnnot();
78  const CDataTrack* datat = dynamic_cast<const CDataTrack*>(t);
79  if (datat)
80  {
82  const INonAsnDataSource* pNonAsnDS = dynamic_cast<const INonAsnDataSource*>(gbds.GetPointerOrNull());
83  if (pNonAsnDS) {
84  if (pNonAsnDS->HasNonAsnData(annot)) {
85  m_NonAsnBlobs.emplace(annot, pNonAsnDS);
86  }
87  return true;
88  }
89  }
90  if (ft->IsVarTrack())
91  {
92  m_var_track = true;
93  if (!annot.empty())
94  m_annots_var.insert(annot);
95  return true;
96  }
97  if (ft->IsSnpTrack())
98  {
99  m_snp_track = true;
100  if (!annot.empty())
101  m_annots_snp.insert(annot);
102  return true;
103  }
105  ft->GetFeatSubtypes(subtypes);
106  m_subtypes.insert(subtypes.begin(), subtypes.end());
107  m_annots.insert(annot);
108  m_named_annot_subtypes[CSeqUtils::NameTypeStrToValue(annot) == CSeqUtils::eAnnot_Unnamed ? kEmptyStr : annot].insert(subtypes.begin(), subtypes.end());
109  }
110  }
111  return true;
112  }
113 
114  void s_GetFeatureLabel(const CSeq_feat& feat, vector<string>& feat_labels, CScope* scope);
115 
116  void GatherFeatures(const string& text,
117  bool match_case,
118  CBioseq_Handle bsh,
119  CScope& scope,
120  CFeaturePanel* panel,
121  vector<CMappedFeatOrObject>& search_results)
122  {
123  if (!bsh)
124  return;
125 
126  CTrackFeatSubtype subtypes;
127  panel->Traverse(subtypes, true);
128 
130  sel.ResetAnnotsNames();
137 
138  bool found = false;
139 
140  if (!subtypes.GetSubtypes().empty())
141  {
142  found = true;
143  auto sub_it = subtypes.GetSubtypes().cbegin();
144  sel.SetFeatSubtype(*sub_it);
145  ++sub_it;
146  for (; sub_it != subtypes.GetSubtypes().cend(); ++sub_it)
147  {
148  sel.IncludeFeatSubtype(*sub_it);
149  }
150  }
151  for (const auto& annot : subtypes.GetAnnots())
152  {
154  {
155  sel.AddUnnamedAnnots();
156  }
157  else
158  {
159  sel.AddNamedAnnots(annot);
160  if (NStr::StartsWith(annot, "NA0"))
161  {
162  sel.IncludeNamedAnnotAccession(annot);
163  }
164  }
165  }
166 
167  if (subtypes.NonAsnDataExists()) {
168  unordered_map<string, CConstIRef<INonAsnDataSource>> NonAsnDSs(subtypes.GetNonAsnBlobs());
169  for (auto vcf_ds : NonAsnDSs) {
170  list<CRef<CObject>> results;
171  vcf_ds.second->DoSearch(vcf_ds.first, text, results);
172  for (auto result : results) {
173  const CVcfVariant* vcf_object = dynamic_cast<const CVcfVariant*>(result.GetPointer());
174  if (vcf_object) {
176  mfo.SetObject(vcf_object);
177  TSeqRange variant_range(vcf_object->GetLocation().GetTotalRange());
178  mfo.SetRange(variant_range);
179  search_results.push_back(mfo);
180  }
181  }
182  }
183  // we prioritize results of non-asn search here and don't attempt any other search if something
184  // was found in non-asn data
185  if (!search_results.empty()) {
186  return;
187  }
188  }
189  unordered_map<string, set<CSeqFeatData::ESubtype>> named_annot_subtypes = subtypes.GetNamedAnnotSubtypes();
190 
191  CFeat_CI fi(bsh, sel);
192 
193  CRef<CVariantPlacement> pPlacement;
194  CRegexp re_snp("^([rs]s)([0-9]{3,})(?::.+)?$");
195  CRegexp re_var("^([en]s)(td|v|sv)([0-9]+)(?::.+)?$");
196  bool is_snp = re_snp.IsMatch(text);
197  bool is_var = re_var.IsMatch(text);
198 
199  if ((subtypes.SnpTrackExists() && is_snp) ||
200  (subtypes.VarTrackExists() && is_var))
201  {
202  found = false;
203  named_annot_subtypes.clear();
205  try
206  {
207  NSNPWebServices::Search(text, "", SNPSearchResultList);
208  }
209  catch (exception&) {}
210  NON_CONST_ITERATE(NSNPWebServices::TSNPSearchCompoundResultList, iSNPSearchResultList, SNPSearchResultList)
211  {
212  NON_CONST_ITERATE(NSNPWebServices::TSNPSearchResultList, iSNPSearchResult, iSNPSearchResultList->second)
213  {
214  // CVariation used as a search result can have one and only one placement
215  NCBI_ASSERT((*iSNPSearchResult)->CanGetPlacements(), "Unexpected absence of placements in SNP Search Result!");
216  if (!(*iSNPSearchResult)->CanGetPlacements())
217  continue;
218  const CVariation::TPlacements& Placements((*iSNPSearchResult)->GetPlacements());
219  NCBI_ASSERT(Placements.size(), "Unexpected number of placements in SNP Search Result!");
220  if (Placements.empty())
221  continue;
222  pPlacement = Placements.front();
223  if (!pPlacement->IsSetLoc() || !sequence::IsSameBioseq(*bsh.GetSeqId(), *pPlacement->GetLoc().GetId(), &scope))
224  continue;
228  for (const auto& annot : is_snp ? subtypes.GetAnnotsSnp() : subtypes.GetAnnotsVar())
229  {
231  {
232  sel.AddUnnamedAnnots();
233  }
234  else
235  {
236  sel.AddNamedAnnots(annot);
237  sel.IncludeNamedAnnotAccession(annot);
238  }
241  }
242  fi = CFeat_CI(scope, pPlacement->GetLoc(), sel);
243  found = true;
244  break;
245  }
246  if (found)
247  break;
248  }
249  }
250 
251  if (!found)
252  return;
253 
254  for (; fi; ++fi)
255  {
256  if (pPlacement && fi->GetTotalRange() != pPlacement->GetLoc().GetTotalRange())
257  continue;
258  auto f = fi->GetSeq_feat_Handle();
259  string annot = f.GetAnnot().IsNamed() ? f.GetAnnot().GetName() : kEmptyStr;
260  if (named_annot_subtypes.find(annot) == named_annot_subtypes.end() ||
261  named_annot_subtypes[annot].find(f.GetFeatSubtype()) == named_annot_subtypes[annot].end())
262  continue;
263 
264  vector<string> feat_labels;
265  s_GetFeatureLabel(*f.GetSeq_feat(), feat_labels, &scope);
266 
267  NStr::ECase case_sens = (match_case) ? NStr::eCase : NStr::eNocase;
268 
269  auto it = find_if(feat_labels.begin(), feat_labels.end(),
270  [&text, &case_sens](const string& elem) { return (NStr::Find(elem, text, case_sens) != NPOS); });
271  if (it != feat_labels.end()) {
273  mfo.SetMappedFeat(*fi);
274  search_results.push_back(mfo);
275  }
276  }
277  }
278 
280  {
282  CRegexp re("^([0-9]+[km]?)((-|to|\\.\\.+|:|\\/|_)([0-9]+[km]?))?$", CRegexp::fCompile_ignore_case);
283  if (re.IsMatch(text))
284  {
285  re.GetMatch(text, 0, 0, CRegexp::fMatch_default, true);
286  if (re.NumFound() == 2)
287  {
288  CTempString pos = text;
289  int multiplier = 1;
290  if (NStr::EndsWith(pos, "k", NStr::eNocase))
291  {
292  multiplier = 1000;
294  }
295  if (NStr::EndsWith(pos, "m", NStr::eNocase))
296  {
297  multiplier = 1000000;
299  }
300  return TSeqRange(NStr::StringToNumeric<TSeqPos>(pos) * multiplier, NStr::StringToNumeric<TSeqPos>(pos) * multiplier);
301  }
302  else if (re.NumFound() == 5)
303  {
304  CTempString pos0 = re.GetSub(text, 1);
305  CTempString pos1 = re.GetSub(text, 4);
306  int multiplier0 = 1;
307  int multiplier1 = 1;
308  if (NStr::EndsWith(pos0, "k", NStr::eNocase))
309  {
310  multiplier0 = 1000;
312  }
313  if (NStr::EndsWith(pos1, "k", NStr::eNocase))
314  {
315  multiplier1 = 1000;
317  }
318  if (NStr::EndsWith(pos0, "m", NStr::eNocase))
319  {
320  multiplier0 = 1000000;
322  }
323  if (NStr::EndsWith(pos1, "m", NStr::eNocase))
324  {
325  multiplier1 = 1000000;
327  }
328  return TSeqRange(NStr::StringToNumeric<TSeqPos>(pos0) * multiplier0, NStr::StringToNumeric<TSeqPos>(pos1) * multiplier1);
329  }
330  }
331  return empty;
332  }
333 
335  {
336  for (int i = 1; i < CSeqFeatData::eSubtype_max; ++i)
337  {
338  CSeqFeatData::ESubtype sub = static_cast<CSeqFeatData::ESubtype>(i);
339  if (CSeqFeatData::GetTypeFromSubtype(sub) == feat)
340  subtypes.insert(sub);
341  }
342  }
343 
344  bool s_UseCustomLabel(const CSeq_feat& feat);
345  void s_GetCustomLabel(const CSeq_feat& feat, string& label);
346  void s_GetSeqLabel(const CSeq_id& id, string* label, CScope* scope);
347  void s_GetSeq_TotalRangeLabel(const CSeq_loc& loc, string* label, CScope* scope);
348 
349  void s_GetFeatureLabel(const CSeq_feat& feat, vector<string>& feat_labels, CScope* scope)
350  {
351 
352  // most of the features will have only one label, exception is: gene
353  string label;
354  if (s_UseCustomLabel(feat)) {
355  s_GetCustomLabel(feat, label);
356  }
357  /// for content, we use the product seq-id, if it
358  /// is available; otherwise, we use the standard text
359  else if (feat.IsSetProduct()) {
360  try {
361  const CSeq_id& id = sequence::GetId(feat.GetProduct(), scope);
362  s_GetSeqLabel(id, &label, scope);
363  }
364  catch (CException&) {
366  }
367  }
368  else {
369  switch (feat.GetData().GetSubtype()) {
371  { { // logic borrowed from misc_feature
372  bool got_label = false;
373  if (feat.IsSetQual()) {
374  ITERATE(CSeq_feat::TQual, it, feat.GetQual()) {
375  if (NStr::EqualNocase((*it)->GetQual(), "Name") ||
376  NStr::EqualNocase((*it)->GetQual(), "ID")) {
377  label = (*it)->GetVal();
378  got_label = true;
379  if (NStr::EqualNocase((*it)->GetQual(), "Name"))
380  break;
381  }
382  }
383  }
384  if (!got_label) {
386  label += " ";
387  if (feat.GetData().GetImp().IsSetDescr()) {
388  label += feat.GetData().GetImp().GetDescr();
389  }
390  }
391  if (label.size() > 30) label = label.substr(0, 30) + "...";
392  }}
393  break;
394 
396  if (feat.GetData().GetSite() == CSeqFeatData::eSite_other &&
397  feat.IsSetComment()) {
398  label += feat.GetComment();
399  }
400  else {
402  }
403  break;
404 
406  { {
407  label += "exon";
408  const string& q = feat.GetNamedQual("number");
409  if (!q.empty()) {
410  label += " ";
411  label += q;
412  }
413  }}
414  break;
415 
417  { {
418  /// RSID first
419  NSnp::TRsid Rsid(NSnp::GetRsid(feat));
420  if (Rsid) {
421  label += "rs";
422  label += NStr::NumericToString(Rsid);
423  }
424  else {
425  if (label.empty() && feat.IsSetComment()) {
426  label += feat.GetComment();
427  }
428  }
429  }}
430  break;
431 
433  { {
434  const CVariation_ref& var = feat.GetData().GetVariation();
435  if (var.CanGetId()) {
436  if (var.GetId().GetTag().IsId()) {
437  label += var.GetId().GetDb() + "|";
438  label += NStr::IntToString(var.GetId().GetTag().GetId());
439  }
440  else {
441  label += var.GetId().GetTag().GetStr();
442  }
443  }
444  else {
445  if (feat.IsSetLocation()) {
446  const CSeq_loc& loc = feat.GetLocation();
447  s_GetSeq_TotalRangeLabel(loc, &label, scope);
448  }
449 
450  //feature::GetLabel(*feat, label, feature::fFGL_Both, scope);
451  }
452  }}
453  break;
454 
456  { {
457  bool got_label = false;
458  if (feat.IsSetQual()) {
459  ITERATE(CSeq_feat::TQual, it, feat.GetQual()) {
460  if (NStr::EqualNocase((*it)->GetQual(), "Name") ||
461  NStr::EqualNocase((*it)->GetQual(), "ID")) {
462  label += (*it)->GetVal();
463  got_label = true;
464  break;
465  }
466  }
467  }
468  if (!got_label) {
470  }
471  }}
472  break;
473 
475  { {
476  const CSeqFeatData::TClone& clone = feat.GetData().GetClone();
477  if (clone.IsSetName()) {
478  label += clone.GetName();
479  }
480  else {
482  }
483  }}
484  break;
485 
487  { {
488  if (feat.IsSetTitle()) {
489  label += feat.GetTitle();
490  }
491  else {
492  s_GetSeq_TotalRangeLabel(feat.GetData().GetSeq(), &label, scope);
493  }
494  }}
495  break;
496 
498  {
500  if (feat.GetData().GetGene().IsSetLocus_tag()) {
501  string aux_label = feat.GetData().GetGene().GetLocus_tag();
502  if (!NStr::EqualCase(label, aux_label)) {
503  feat_labels.push_back(aux_label);
504  }
505  }
506  break;
507  }
508 
509  default:
511  break;
512  }
513  }
514  feat_labels.push_back(label);
515  }
516 
517  bool s_UseCustomLabel(const CSeq_feat& feat)
518  {
522 
523  return subtypes.end() != subtypes.find(feat.GetData().GetSubtype());
524  }
525 
526  void s_LabelFromQualifiers(const CSeq_feat& feat, string& label)
527  {
528  static vector<string> quals{ "regulatory_class", "recombination_class", "feat_class", "bound_moiety", "mobile_element_type", "mobile_element", "rpt_type",
529  "satellite", "rpt_family", "mod_base", "operon", "standard_name", "allele" };
530 
531  for (const auto& qual_name : quals) {
532  const string& value = feat.GetNamedQual(qual_name);
533  if (value.empty())
534  continue;
535 
536  label = value;
537  break;
538  }
539  }
540 
541  bool s_IncludeFeatureTypeInLabel(const objects::CSeq_feat& feat)
542  {
543  static vector<string> class_quals{ "feat_class", "regulatory_class", "recombination_class", "mobile_element_type", "mobile_element", "rpt_type", "satellite", "rpt_family" };
544  for (const auto& qual_name : class_quals) {
545  const string& value = feat.GetNamedQual(qual_name);
546  if (!value.empty())
547  return false;
548  }
549  return true;
550  }
551 
552  void s_GetCustomLabel(const CSeq_feat& feat, string& label)
553  {
554  CSeqFeatData::ESubtype subtype = feat.GetData().GetSubtype();
555  if (s_IncludeFeatureTypeInLabel(feat) && ((subtype != CSeqFeatData::eSubtype_misc_feature) && (subtype != CSeqFeatData::eSubtype_region))) // Add the subtype only for features that do not have specific qualifiers
557  string second_part;
558  if (feat.GetData().IsRegion()) {
559  second_part = feat.GetData().GetRegion();
560  }
561  else {
562  s_LabelFromQualifiers(feat, second_part);
563  }
564  if (second_part.empty() && feat.IsSetComment()) {
565  second_part = feat.GetComment();
566  size_t pos = second_part.find(';');
567  if (pos != string::npos)
568  second_part = second_part.substr(0, pos);
569  }
570  if (!second_part.empty()) {
571  if (!label.empty())
572  label += ": ";
573  label += second_part;
574  }
575  if (label.empty())
577  }
578 
579  void s_GetSeqLabel(const CSeq_id& id, string* label, CScope* scope)
580  {
581  // check: scope is NEEDED [protected]
582 
583  CConstRef<CSeq_id> id_ptr(&id);
584  /*if (scope && id_ptr->IsGi()) {
585  CSeq_id_Handle sih = sequence::GetId(id, *scope, sequence::eGetId_Best);
586  if (sih) {
587  id_ptr = sih.GetSeqId();
588  }
589  }
590  */
592  }
593 
594  void s_GetSeq_TotalRangeLabel(const CSeq_loc& loc, string* label, CScope* scope)
595  {
596  // check: scope is NEEDED [indirectly protected]
597 
598 
599  const CSeq_id& id = sequence::GetId(loc, scope);
600  TSeqRange range = loc.GetTotalRange();
601  s_GetSeqLabel(id, label, scope);
602  *label += ": ";
603  *label += NStr::IntToString(range.GetFrom() + 1, NStr::fWithCommas);
604  *label += "-";
606 
607  *label += " [";
609  *label += "]";
610 
611  string extra_info = kEmptyStr;
612  ENa_strand strand = sequence::GetStrand(loc, scope);
613  switch (strand) {
614  case eNa_strand_minus:
615  extra_info = "-";
616  break;
617  case eNa_strand_unknown:
618  break;
619  case eNa_strand_plus:
620  default:
621  extra_info = "+";
622  break;
623  }
624 
625  size_t intervals = 0;
626  switch (loc.Which()) {
627  case CSeq_loc::e_Int:
628  intervals = 1;
629  break;
630 
632  intervals = loc.GetPacked_int().Get().size();
633  break;
634 
636  intervals = loc.GetPacked_pnt().GetPoints().size();
637  break;
638 
639  case CSeq_loc::e_Mix:
640  /// FIXME: this may not always be correct -
641  /// a mix may be a mix of complex intervals
642  intervals = loc.GetMix().Get().size();
643  break;
644 
645  default:
646  break;
647  }
648 
649  if (intervals != 0) {
650  if (!extra_info.empty())
651  *label += ", ";
652  extra_info += NStr::SizetToString(intervals);
653  extra_info += " interval";
654  if (intervals != 1) {
655  extra_info += "s";
656  }
657  }
658  if (!extra_info.empty()) {
659  *label += " (";
660  *label += extra_info;
661  *label += ")";
662  }
663  }
664 }
665 
666 
668 
669 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CBioseq_Handle –.
CClone_ref –.
Definition: Clone_ref.hpp:66
CConstRef –.
Definition: ncbiobj.hpp:1266
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
virtual CRef< CSGGenBankDS > GetDataSource()=0
Method for accessing the data source.
CFeat_CI –.
Definition: feat_ci.hpp:64
File Description:
void SetMappedFeat(const objects::CMappedFeat &mapped_feat)
void SetRange(const TSeqRange &range)
void SetObject(const CObject *object)
CRegexp –.
Definition: regexp.hpp:70
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
static E_Choice GetTypeFromSubtype(ESubtype subtype)
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
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
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
File Description:
void Traverse(Tr &&tr, bool visible)
IFeatureTrackBase –.
virtual bool IsVarTrack() const
virtual string GetAnnot() const =0
virtual void GetFeatSubtypes(set< objects::CSeqFeatData::ESubtype > &subtypes) const =0
virtual bool IsSnpTrack() const
unordered_map< string, CConstIRef< INonAsnDataSource > > GetNonAsnBlobs()
bool Track(const CTempTrackProxy *, const CLayoutTrack *t, bool visible)
set< objects::CSeqFeatData::ESubtype > m_subtypes
const set< string > & GetAnnots()
const set< string > & GetAnnotsSnp()
unordered_map< string, set< objects::CSeqFeatData::ESubtype > > m_named_annot_subtypes
const set< string > & GetAnnotsVar()
unordered_map< string, CConstIRef< INonAsnDataSource > > m_NonAsnBlobs
unordered_map< string, set< objects::CSeqFeatData::ESubtype > > GetNamedAnnotSubtypes()
const set< objects::CSeqFeatData::ESubtype > & GetSubtypes()
static TRsid GetRsid(const CMappedFeat &mapped_feat)
Return rsid of SNP.
Definition: snp_utils.cpp:109
CObject_id::TId8 TRsid
Definition: snp_utils.hpp:70
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
bool empty() const
Definition: set.hpp:133
const_iterator end() const
Definition: set.hpp:136
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NCBI_ASSERT(expr, mess)
Definition: ncbidbg.hpp:130
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static TAnnotNameType NameTypeStrToValue(const string &type)
Definition: utils.cpp:140
virtual bool HasNonAsnData(const string &annot_name) const =0
@ eAnnot_Unnamed
unnamed annotation
Definition: utils.hpp:133
list< TSNPSearchCompoundResult > TSNPSearchCompoundResultList
results of a search for one or several ids
Definition: snp_gui.hpp:234
list< CRef< CVariation > > TSNPSearchResultList
various placements of a variation
Definition: snp_gui.hpp:227
static void Search(const std::string &sTerms, const std::string &sAssemblyAccession, TSNPSearchCompoundResultList &ResultList)
search for given SNP ID(s) and get a list of results
const objects::CSeq_loc & GetLocation() const
Definition: snp_gui.hpp:302
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
string GetLabel(const CSeq_id &id)
@ fLabel_Default
default options - always show the version
Definition: Seq_id.hpp:623
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
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
@ 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
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 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.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
SAnnotSelector & ExcludeAnnotType(TAnnotType type)
Exclude annotation type from the search.
SAnnotSelector & ResetAnnotsNames(void)
Select annotations from all Seq-annots.
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.
SAnnotSelector & SetFeatSubtype(TFeatSubtype subtype)
Set feature subtype (also set annotation and feat type)
SAnnotSelector & AddUnnamedAnnots(void)
Add unnamed annots to set of annots names to look for.
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1672
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
bool IsMatch(CTempString str, TMatch flags=fMatch_default)
Check existence substring which match a specified pattern.
Definition: regexp.cpp:193
CTempString GetSub(CTempString str, size_t idx=0) const
Get pattern/subpattern from previous GetMatch().
Definition: regexp.cpp:156
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
Definition: regexp.cpp:182
int NumFound() const
Get number of patterns + subpatterns.
Definition: regexp.hpp:562
@ fCompile_ignore_case
Definition: regexp.hpp:103
@ fMatch_default
Definition: regexp.hpp:127
#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
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
Definition: ncbistr.hpp:5325
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 void TrimSuffixInPlace(string &str, const CTempString suffix, ECase use_case=eCase)
Trim suffix from a string (in-place)
Definition: ncbistr.cpp:3278
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
ECase
Which type of string comparison.
Definition: ncbistr.hpp:1204
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
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
@ eCase
Case sensitive compare.
Definition: ncbistr.hpp:1205
static const char label[]
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
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 TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
bool IsSetTitle(void) const
for user defined label Check if a value has been assigned to Title data member.
Definition: Seq_feat_.hpp:1160
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
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
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TName & GetName(void) const
Get the Name member data.
Definition: Clone_ref_.hpp:405
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
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
const TGene & GetGene(void) const
Get the variant data.
TSite GetSite(void) const
Get the variant data.
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
const TVariation & GetVariation(void) const
Get the variant data.
bool IsRegion(void) const
Check if variant Region is selected.
const TImp & GetImp(void) const
Get the variant data.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const Tdata & Get(void) const
Get the member data.
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
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
const TPoints & GetPoints(void) const
Get the Points member data.
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
@ 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_Int
from to
Definition: Seq_loc_.hpp:101
@ e_Ids
used for communication between tools
Definition: Seq_annot_.hpp:136
@ e_not_set
No variant selected.
Definition: Seq_annot_.hpp:132
@ e_Locs
used for communication between tools
Definition: Seq_annot_.hpp:137
list< CRef< CVariantPlacement > > TPlacements
bool IsSetLoc(void) const
actual concrete placement we are considering Check if a value has been assigned to Loc data member.
const TLoc & GetLoc(void) const
Get the Loc member data.
const TId & GetId(void) const
Get the Id member data.
bool CanGetId(void) const
Check if it is safe to call GetId method.
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
void s_GetSeqLabel(const CSeq_id &id, string *label, CScope *scope)
bool s_IncludeFeatureTypeInLabel(const objects::CSeq_feat &feat)
void s_GetSeq_TotalRangeLabel(const CSeq_loc &loc, string *label, CScope *scope)
void GetSubtypesForType(set< objects::CSeqFeatData::ESubtype > &subtypes, objects::CSeqFeatData::E_Choice feat)
void s_GetCustomLabel(const CSeq_feat &feat, string &label)
TSeqRange SplitPosOrRange(const string &text)
bool s_UseCustomLabel(const CSeq_feat &feat)
void GatherFeatures(const string &text, bool match_case, objects::CBioseq_Handle bsh, objects::CScope &scope, CFeaturePanel *panel, vector< CMappedFeatOrObject > &search_results)
void s_GetFeatureLabel(const CSeq_feat &feat, vector< string > &feat_labels, CScope *scope)
void s_LabelFromQualifiers(const CSeq_feat &feat, string &label)
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
EIPRangeType t
Definition: ncbi_localip.c:101
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define fi
USING_SCOPE(objects)
SAnnotSelector –.
else result
Definition: token2.c:20
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
Modified on Wed Apr 17 13:10:46 2024 by modify_doxy.py rev. 669887