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

Go to the SVN repository for this file.

1 /* $Id: snp_gui.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: Dmitry Rudnev
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbireg.hpp>
34 #include <corelib/ncbiapp.hpp>
47 #include <gui/objutils/snp_gui.hpp>
48 #include <gui/objutils/utils.hpp>
49 #include <gui/utils/fetch_url.hpp>
51 
52 #include <cmath>
53 #include <sstream>
54 
57 
60 
62 {
63  SAnnotSelector sel;
64 
67 
68  sel.SetExcludeExternal(false);
69  CSeqUtils::SetResolveDepth(sel, true, -1);
71  Handle.GetRangeSeq_loc(range.GetFrom(), range.GetTo()) );
72 
73  string zoomAnnotName = sAnnotName;
74  // special handling for SNP2
75  if (CSeqUtils::IsExtendedNAA(sAnnotName)) {
76  sel.IncludeNamedAnnotAccession(sAnnotName, -1);
77  sel.SetCollectNames();
78  CGraph_CI graph_iter(Handle.GetScope(), *loc, sel);
79  int best_zoom_level = kMax_Int;
80  int max_zoom_level = loc->GetTotalRange().GetLength()/2000;
81  for (auto& name : graph_iter.GetAnnotNames()) {
82  if (!name.IsNamed()) {
83  continue;
84  }
85  string base_name;
86  int zoom_level;
87  if (!ExtractZoomLevel(name.GetName(), &base_name, &zoom_level) ||
88  base_name != sAnnotName) {
89  continue;
90  }
91  if (zoom_level <= max_zoom_level) {
92  if (zoom_level > best_zoom_level || best_zoom_level > max_zoom_level) {
93  best_zoom_level = zoom_level;
94  }
95  }
96  else {
97  if (zoom_level < best_zoom_level) {
98  best_zoom_level = zoom_level;
99  }
100  }
101  }
102  if (best_zoom_level != kMax_Int) {
103  zoomAnnotName = CombineWithZoomLevel(sAnnotName, best_zoom_level);
104  }
105  sel.SetCollectNames(false);
106  sel.ResetAnnotsNames();
107  }
108  sel.IncludeNamedAnnotAccession(zoomAnnotName);
109  sel.AddNamedAnnots(zoomAnnotName);
110 
111  return CGraph_CI(Handle.GetScope(), *loc, sel);
112 }
113 
115 {
116  SAnnotSelector sel;
117 
120 
121  if(CSeqUtils::NameTypeStrToValue(sAnnotName) ==
123  sel.AddUnnamedAnnots();
124  } else {
125  sel.IncludeNamedAnnotAccession(sAnnotName);
126  sel.AddNamedAnnots(sAnnotName);
127  }
128 
129  CSeqUtils::SetResolveDepth(sel, true, -1);
131  Handle.GetRangeSeq_loc(range.GetFrom(), range.GetTo()) );
132 
133 // cerr << "using loc " << endl <<
134 // MSerial_AsnText << *loc << endl;
135  return CFeat_CI(Handle.GetScope(), *loc, sel);
136 }
137 
138 
139 size_t NSnpAnnot::EstimateSNPCount(const TSeqRange& range, const string& sAnnotName, CBioseq_Handle& Handle)
140 {
141  size_t features_estimate(0);
142  // if we have an available graph with feature density, we can estimate number of features in our range
143  CGraph_CI graph_iter(GetGraph_CI(range, sAnnotName, Handle));
144 
145  if(graph_iter) {
146  for ( ; graph_iter; ++graph_iter) {
147  const CMappedGraph& gr = *graph_iter;
148  TSeqRange gr_r = gr.GetLoc().GetTotalRange();
149  if(!gr_r.IntersectingWith(range)) {
150  continue;
151  }
152  TSeqPos comp = gr.GetComp();
153  TSeqPos pos = gr_r.GetFrom();
154  double a = gr.IsSetA()? gr.GetA(): 1.;
155  double b = gr.IsSetB()? gr.GetB(): 0.;
156  if (gr.GetGraph().IsByte()) {
157  const CByte_graph::TValues& values = gr.GetGraph().GetByte().GetValues();
158  ITERATE(CByte_graph::TValues, iter_gr, values) {
159  TSeqRange pos_r = TSeqRange(pos, pos + comp);
160  if(pos_r.IntersectingWith(range)) {
161  features_estimate += (*iter_gr * a + b);
162  }
163  pos += comp;
164  }
165  } else {
166  const CInt_graph::TValues& values = gr.GetGraph().GetInt().GetValues();
167  ITERATE(CInt_graph::TValues, iter_gr, values) {
168  TSeqRange pos_r = TSeqRange(pos, pos + comp);
169  if(pos_r.IntersectingWith(range)) {
170  features_estimate += (*iter_gr * a + b);
171  }
172  pos += comp;
173  }
174  }
175  }
176 // cerr << "features_estimate from graph: " << features_estimate << endl;
177  } else {
178  // if there's no graph, fall back to sampling a density at start, 1/3, 2/3 and end of range
179  // to avoid slowdowns, sampling is done over 100kbp ranges
180  static TSeqPos s_SamplingRange(100 * 1000);
181 
182  auto start_count(GetFeat_CI(TSeqRange(range.GetFrom(), range.GetFrom() + s_SamplingRange), sAnnotName, Handle).GetSize());
183  auto one_third_count(GetFeat_CI(TSeqRange(range.GetFrom() + range.GetLength()/3 - s_SamplingRange/2, range.GetFrom() + range.GetLength()/3 + s_SamplingRange/2), sAnnotName, Handle).GetSize());
184  auto two_third_count(GetFeat_CI(TSeqRange(range.GetFrom() + range.GetLength() * 2 / 3 - s_SamplingRange/2, range.GetFrom() + range.GetLength() * 2 / 3 + s_SamplingRange/2), sAnnotName, Handle).GetSize());
185  auto end_count(GetFeat_CI(TSeqRange(range.GetTo() - s_SamplingRange, range.GetTo()), sAnnotName, Handle).GetSize());
186  features_estimate = (double(start_count + one_third_count + two_third_count + end_count) / double(s_SamplingRange * 4)) * range.GetLength();
187 // cerr << "features_estimate from sampling: " << features_estimate << endl;
188  }
189  return features_estimate;
190 }
191 
192 const string NSnpGui::pmURL = "/pubmed/";
193 const string NSnpGui::omimURL = "/omim/";
194 const string NSnpGui::geneSymURL = "/gene/";
195 const string NSnpGui::geneRevURL = "/sites/entrez?Db=books&DbFrom=gene&Cmd=Link&LinkName=gene_books&LinkReadableName=Books&IdsFromResult=";
196 const string NSnpGui::snpURL = "/snp/rs";
197 const string NSnpGui::phenotypeURL = "/sites/entrez?db=mesh&cmd=search&term=";
198 const string NSnpGui::GAPStudyURL = "/projects/gap/cgi-bin/study.cgi?study_id=";
199 const string NSnpGui::PHAURL = "/projects/SNP/GaPBrowser_prod/callGaPBrowser2.cgi?aid=";
200 const string NSnpGui::GenomeURL = "https://www.genome.gov/gwastudies/index.cfm?snp=rs";
201 const string NSnpGui::VarVuURL = "/variation/view/?q=rs";
202 const string NSnpGui::ClinVarURL = "/clinvar/?term=rs";
203 const string NSnpGui::ClinVarIdURL = "/clinvar/variation/";
206 
207 const int NSnpGui::c_BinWidth = 14;
208 const int NSnpGui::c_BinHeight = 14;
209 
210 
211 
213 {
214  switch(ClinSigID)
215  {
217  return "ProbablePathogenic";
219  return "Pathogenic";
220  }
221  return "Default";
222 }
223 
225 {
226 
227  static const map<string, CPhenotype::EClinical_significance> sm_ClinSigMap = {
229  { "benign/likely_benign", CPhenotype::eClinical_significance_non_pathogenic },
230 
232 
233 
235  { "likely_pathogenic/_low_penetrance", CPhenotype::eClinical_significance_probable_pathogenic },
237 
239  { "pathogenic/likely_pathogenic", CPhenotype::eClinical_significance_pathogenic },
240  { "pathogenic/_low_penetrance", CPhenotype::eClinical_significance_pathogenic },
241  { "established_risk_allele", CPhenotype::eClinical_significance_pathogenic},
242 
245  { "uncertain_significance", CPhenotype::eClinical_significance_unknown },
246  { "uncertain_risk_allele", CPhenotype::eClinical_significance_unknown},
249  };
250  string s = clinsig;
251  auto it = sm_ClinSigMap.find(NStr::ToLower(s));
252  return it == sm_ClinSigMap.end() ?
254 }
255 
256 // coloring for clinical significance
257 
259 {
260  switch(ClinSigID) {
262  color.Set(0.007f, 0.588f, 0.145f);// green
263  break;
265  color.Set(0.011f, 0.784f, 0.192f); // light green
266  break;
268  color.Set(0.866f, 0.372f, 0.788f); // light purple
269  break;
271  color.Set(0.796f, 0.043f, 0.674f); // purple
272  break;
274  color.Set(0.282f, 0.309f, 0.796f); // blue
275  break;
276  default:
277  color.Set(0.349f, 0.349f, 0.349f); // gray
278  break;
279  }
280 }
281 
282 string NSnpGui::SelectClinSigTerm(const string& clinsig)
283 {
284  string sig_term = clinsig;
285  NStr::ToLower(sig_term);
286 
287  static const map<CPhenotype::EClinical_significance, short> sm_Pathogenicity = {
293  };
294  vector<string> tokens;
295  NStr::Split(sig_term, "|", tokens, NStr::fSplit_Tokenize);
296  for (auto& it : tokens) {
297  NStr::TrimPrefixInPlace(it, "_");
298  NStr::ReplaceInPlace(it, ",", "/"); // the registry entry can't have comma
299  }
300 
302  size_t max_index = 0;
303 
304  for (size_t index = 0; index < tokens.size(); ++index) {
305  auto severity = (CPhenotype::EClinical_significance)NSnpGui::ClinSigFromString(tokens[index]);
306  auto sev_it = sm_Pathogenicity.find(severity);
307  if (sev_it != sm_Pathogenicity.end()) {
308  auto max_it = sm_Pathogenicity.find(max_significance);
309  if (max_it == sm_Pathogenicity.end()) {
310  max_significance = severity;
311  max_index = index;
312  }
313  else if (sev_it->second > max_it->second) {
314  max_significance = severity;
315  max_index = index;
316  }
317  }
318  }
319  return tokens[max_index];
320 }
321 
322 
323 string NSnpGui::ClinSigAsImgURL(NSnp::TClinSigID ClinSigID, const string &colorTheme)
324 {
325  const string sBaseURL("/projects/sviewer/images/");
326  switch(ClinSigID)
327  {
329  return sBaseURL + "snp-patho-prob-patho_" + colorTheme + ".png";
331  return sBaseURL + "snp-patho-patho_" + colorTheme + ".png";
332  }
333  return sBaseURL + "snp-patho-def_" + colorTheme + ".png";
334 }
335 
336 
337 string NSnpGui::PValueAsColorKey(double pvalue)
338 {
339  static string ColorKeys[] = {
340  "PValueLevel1", // < 2
341  "PValueLevel2", // [2-3)
342  "PValueLevel3", // [3-4)
343  "PValueLevel4", // [4-5)
344  "PValueLevel5", // [5-6)
345  "PValueLevel6", // [6-7)
346  "PValueLevel7", // >= 7
347  };
348 
349  int v = (int)floor(pvalue);
350 
351  if( v < 2)
352  return ColorKeys[0];
353  else if (v < 7)
354  return ColorKeys[v-1];
355  else
356  return ColorKeys[6];
357 }
358 
359 // copied from ncbistr.cpp; unfortunately, they don't expose these constants
360 // A maximal size of a double value in a string form.
361 // Exponent size + sign + dot + ending '\0' + max.precision
362 const int kMaxDoublePrecision = 308;
364 
365 
366 string NSnpGui::PValueToString(double pvalue)
367 {
370  return string(buffer);
371 }
372 
374  CIRef<ITooltipFormatter> pFormatter,
375  TGi gi,
376  const string &colorTheme)
377 {
378  vector<string> tokens;
379 
380  switch(bin.type)
381  {
382  case NSnpBins::eCLIN:
383  case NSnpBins::eIND:
384  {
386  CConstRef<NSnpBins::SBinEntry> entry(iter->GetPointer());
387  string rsid = NStr::UIntToString(entry->snpid);
388  if(iter != bin.m_EntryList.begin()) {
389  pFormatter->AddDividerRow();
390  }
391 
392  pFormatter->StartRow();
393  if(bin.type == NSnpBins::eCLIN) {
394  pFormatter->AddTagCol("Variation ID:", ClinSigAsImgURL(entry->ClinSigID, colorTheme));
395  }
396  else {
397  pFormatter->AddTagCol("Variation ID:");
398  }
399  string sClinSig(NSnp::ClinSigAsString(entry->ClinSigID, NSnp::eLetterCase_ForceLower));
400  // "with ... allele" statement temporarily restored according to SNP-5006 09/17/12 12:16
401  pFormatter->AddValueCol(pFormatter->CreateNcbiLink("rs"+rsid, snpURL+rsid) +
402  (sClinSig.empty() ? string() : ", with " + sClinSig + " allele"));
403  pFormatter->FinishRow();
404  pFormatter->StartRow();
405  pFormatter->AddTagCol("Location:");
406  pFormatter->AddValueCol(NStr::IntToString(entry->pos+1, NStr::fWithCommas));
407  pFormatter->FinishRow();
408 
409  // parse the trait, extracting OMIM and Gene information
410  string sPackagedOMIM, sGene;
411  vector<string> tokens;
412  NStr::Split(entry->trait, "|", tokens);
413  if(tokens.size() > 0) {
414  sPackagedOMIM = tokens[0];
415  }
416  if(tokens.size() > 1) {
417  sGene = tokens[1];
418  }
419  tokens.clear();
420 
421 /* temporarily disabled according to SNP-5006 09/17/12 12:16
422  if(!snp->sHGVS.empty() || !sPackagedOMIM.empty()) {
423  pFormatter->StartRow();
424  pFormatter->AddTagCol("Phenotype:");
425  pFormatter->FinishRow();
426  if(!snp->sHGVS.empty()) {
427  pFormatter->StartRow();
428  pFormatter->AddTagCol("Allele:");
429  pFormatter->AddValueCol(snp->sHGVS);
430  pFormatter->FinishRow();
431  }
432  if(!sPackagedOMIM.empty()) {
433  tokens.clear();
434  NStr::Split(sPackagedOMIM, "^", tokens);
435  string sPhenotypeName;
436 
437  for(size_t i=0; i<tokens.size(); ++i) {
438  vector<string> OmimPair;
439  NStr::Split(tokens[i], ":", OmimPair);
440  NCBI_ASSERT(OmimPair.size() == 2, "Invalid OMIM pair record");
441  vector<string> OmimIDPair;
442  NStr::Split(OmimPair[0], ".", OmimIDPair);
443  string sOmimLink(OmimIDPair.size() == 2 ? pFormatter->CreateNcbiLink("OMIM", omimURL+OmimIDPair[0] + "#" + OmimIDPair[0] + "Variants" + OmimIDPair[1]) : "");
444  if(i>0)
445  sPhenotypeName += ", ";
446  sPhenotypeName += (OmimPair.size() == 2 ? (OmimPair[1] + (sOmimLink.empty() ? sOmimLink : (" (" + sOmimLink + ")"))) : "");
447  }
448  if(!sPhenotypeName.empty()) {
449  string sClinSig(NSnp::ClinSigAsString(snp->ClinSigID, , NSnp::eLetterCase_ForceLower));
450  pFormatter->StartRow();
451  pFormatter->AddTagCol("Name:");
452  pFormatter->AddValueCol(sPhenotypeName + (sClinSig.empty() ? string() : ", with " + sClinSig + " allele"));
453  pFormatter->FinishRow();
454  }
455  }
456  }
457 */
458  bool isGoToPresent(false);
459  x_MakeVarVuLink(entry, pFormatter, isGoToPresent, gi);
460  x_MakeClinVarLink(entry, pFormatter, isGoToPresent);
461  pFormatter->AddPubmedLinksRow(entry->pmids, isGoToPresent, true);
462  }
463  break;
464  }
465  case NSnpBins::eCITED:
466  {
468  CConstRef<NSnpBins::SBinEntry> entry(iter->GetPointer());
469  string rsid = NStr::UIntToString(entry->snpid);
470  if(iter != bin.m_EntryList.begin())
471  pFormatter->AddDividerRow();
472 
473  pFormatter->StartRow();
474  pFormatter->AddTagCol("Variation ID:");
475  pFormatter->AddValueCol(pFormatter->CreateNcbiLink("rs"+rsid, snpURL+rsid));
476  pFormatter->FinishRow();
477  pFormatter->StartRow();
478  pFormatter->AddTagCol("Location:");
479  pFormatter->AddValueCol(NStr::IntToString(entry->pos+1));
480  pFormatter->FinishRow();
481 
482  bool isGoToPresent(false);
483  pFormatter->AddPubmedLinksRow(entry->pmids, isGoToPresent, false);
484  }
485  break;
486  }
487  case NSnpBins::eGAP:
488  case NSnpBins::eGCAT:
489  {
491  if(iter != bin.m_EntryList.begin())
492  pFormatter->AddDividerRow();
493  CConstRef<NSnpBins::SBinEntry> entry(iter->GetPointer() );
494  if(entry->snpid > 0) {
495  string rsid = NStr::UIntToString(entry->snpid);
496  pFormatter->StartRow();
497  pFormatter->AddTagCol("Variation ID:");
498  pFormatter->AddValueCol(pFormatter->CreateNcbiLink("rs"+rsid, snpURL+rsid));
499  pFormatter->FinishRow();
500  }
501  string geneId;
502  if(entry->geneId > 0) {
503  geneId = NStr::UIntToString(entry->geneId);
504  } else {
505  geneId = entry->geneStringId;
506  }
507  if(!geneId.empty()) {
508  pFormatter->StartRow();
509  pFormatter->AddTagCol("Gene ID:");
510  if(!entry->geneName.empty()) {
511  geneId += " (" + entry->geneName + ")";
512  }
513  pFormatter->AddValueCol(geneId);
514  pFormatter->FinishRow();
515  }
516  pFormatter->StartRow();
517  pFormatter->AddTagCol("Location:");
518  pFormatter->AddValueCol(NStr::IntToString(entry->pos+1) +
519  (entry->pos_end == kInvalidSeqPos ? string() : (".." + NStr::IntToString(entry->pos_end+1))));
520  pFormatter->FinishRow();
521  pFormatter->StartRow();
522  pFormatter->AddTagCol("Phenotype:");
523  pFormatter->AddValueCol(pFormatter->CreateNcbiLink(entry->trait, phenotypeURL + entry->trait + "[mesh]"));
524  pFormatter->FinishRow();
525  pFormatter->StartRow();
526  pFormatter->AddTagCol("Data source:");
527  pFormatter->AddValueCol(NSnpBins::SourceAsString(entry->source));
528  pFormatter->FinishRow();
529  if(entry->pvalue > 0) {
530  pFormatter->StartRow();
531  pFormatter->AddTagCol("P-Value:");
532  pFormatter->AddValueCol(PValueToString(entry->pvalue));
533  pFormatter->FinishRow();
534  }
535  if(!entry->context.empty()) {
536  pFormatter->StartRow();
537  pFormatter->AddTagCol("Context:");
538  pFormatter->AddValueCol(entry->context);
539  pFormatter->FinishRow();
540  }
541  x_ProcessDbgaptext(entry, pFormatter);
542  if(!entry->population.empty()) {
543  pFormatter->StartRow();
544  pFormatter->AddTagCol("Population:");
545  pFormatter->AddValueCol(entry->population);
546  pFormatter->FinishRow();
547  }
548  bool isGoToPresent(false);
549  pFormatter->AddPubmedLinksRow(entry->pmids, isGoToPresent, false);
550  }
551  break;
552  }
553  }
554 }
555 
557  TLinkList& LinkList,
558  TGi gi)
559 {
560  NSnpBins::CGeneMap GeneMap(entry->genes_reported);
561 
562  // get assemblies associated with this GI
563  //!! skip this and wait for a better solution per SV-2020
564  // (https://jira.ncbi.nlm.nih.gov/browse/SV-2020?focusedCommentId=3259819&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-3259819)
565 // CSeqUtils::TAccs assm_accs;
566 // CSeqUtils::GetAssmAccs_Gi(assm_accs, gi);
567 
568  ITERATE(NSnpBins::CGeneMap, iGeneMap, GeneMap) {
569  if(!iGeneMap->first.empty()) {
570 // ITERATE(CAssemblyInfo::TAccs, i_assm_accs, assm_accs) {
571 // LinkList.push_back(TLinkList::value_type(iGeneMap->first,
572 // VarVuURL + NStr::IntToString(entry->snpid) +
573 // "&filters=source:dbsnp&assm=" + *i_assm_accs));
574 // }
575  LinkList.push_back(TLinkList::value_type(iGeneMap->first,
576  VarVuURL + NStr::IntToString(entry->snpid) +
577  "&filters=source:dbsnp"));
578  }
579  }
580 }
581 
583  CIRef<ITooltipFormatter> pFormatter,
584  bool& isGoToPresent,
585  TGi gi)
586 {
587  TLinkList LinkList;
588  x_MakeVarVuLink(entry, LinkList, gi);
589  NSnpBins::CGeneMap GeneMap(entry->genes_reported);
590  bool isFirstRow(true);
591  ITERATE(TLinkList, iLinkList, LinkList) {
592  pFormatter->StartRow();
593  pFormatter->AddTagCol(isFirstRow ? "Variation Viewer:" : "");
594  pFormatter->AddValueCol(pFormatter->CreateNcbiLink(iLinkList->first, iLinkList->second));
595  pFormatter->FinishRow();
596  isFirstRow = false;
597  }
598 }
599 
601  TLinkList& LinkList)
602 {
603  LinkList.push_back(TLinkList::value_type("rs"+NStr::IntToString(entry->snpid),
604  ClinVarURL + NStr::IntToString(entry->snpid)));
605 }
606 
608  CIRef<ITooltipFormatter> pFormatter,
609  bool& isGoToPresent)
610 {
611  TLinkList LinkList;
612  x_MakeClinVarLink(entry, LinkList);
613  bool isFirstRow(true);
614  ITERATE(TLinkList, iLinkList, LinkList) {
615  pFormatter->StartRow();
616  pFormatter->AddTagCol(isFirstRow ? "ClinVar:" : "");
617  pFormatter->AddValueCol(pFormatter->CreateNcbiLink(iLinkList->first, iLinkList->second));
618  pFormatter->FinishRow();
619  isFirstRow = false;
620  }
621 }
622 
623 
624 
626 {
627  if(entry->dbgaptext.empty())
628  return;
629 
630  typedef map<string, string> TNameValueMap;
631 
632  TNameValueMap aNameValueMap;
633 
635  entry->dbgaptext,
636  "&",
637  "=",
638  new CStringDecoder_Url());
639 
640  TNameValueMap::const_iterator iNameValue;
641 
642  if((iNameValue = aNameValueMap.find("data_src")) != aNameValueMap.end() &&
643  !iNameValue->second.empty()) {
644  pFormatter->StartRow();
645  pFormatter->AddTagCol("Data source:");
646  pFormatter->AddValueCol(NSnpBins::SourceAsString(NStr::StringToInt(iNameValue->second)));
647  pFormatter->FinishRow();
648  }
649 
650  if((iNameValue = aNameValueMap.find("phs")) != aNameValueMap.end() && !iNameValue->second.empty() && iNameValue->second != "0") {
651  // phs value must be padded with zeroes to achieve a length of 6 digits
652  string phs("phs" + string(6 - iNameValue->second.length(), '0') + iNameValue->second);
653 
654  iNameValue = aNameValueMap.find("phs_desc");
655 
656  pFormatter->StartRow();
657  pFormatter->AddTagCol(string((iNameValue != aNameValueMap.end() && !iNameValue->second.empty()) ? iNameValue->second : "PHS") + ":");
658  pFormatter->AddValueCol(pFormatter->CreateNcbiLink(phs, GAPStudyURL + phs));
659  pFormatter->FinishRow();
660  }
661 
662  if((iNameValue = aNameValueMap.find("pha")) != aNameValueMap.end() && !iNameValue->second.empty() && iNameValue->second != "0") {
663  string pha(iNameValue->second);
664  string pha_padded("pha" + string(6 - iNameValue->second.length(), '0') + iNameValue->second);
665 
666  iNameValue = aNameValueMap.find("pha_desc");
667 
668  pFormatter->StartRow();
669  pFormatter->AddTagCol(string((iNameValue != aNameValueMap.end() && !iNameValue->second.empty()) ? iNameValue->second : "PHA") + ":");
670  pFormatter->AddValueCol(pFormatter->CreateNcbiLink(pha_padded, PHAURL + pha + "&snp=" + NStr::UIntToString(entry->snpid)));
671  pFormatter->FinishRow();
672  }
673 }
674 
675 
677  TLinkList& LinkList)
678 {
679  LinkList.clear();
680 
682  switch(bin.type) {
683  case NSnpBins::eCLIN: //clinical
684  case NSnpBins::eIND: //individual
685  {
686  string snpid(NStr::UIntToString((*iter)->snpid));
687 
688  LinkList.push_back(TLinkList::value_type("RefSNP: rs" + snpid, snpURL + snpid));
689  // similar to GetBinTooltip() above, parsing of OMIM/HGVS info is
690  // temporarily disabled according to SNP-5006 09/17/12 12:16
691  // if needed to be further worked on, the code may be taken from the old version of link.cpp
692  //!! temporary GI == 0 to allow compilation for SV-2020
693  x_MakeVarVuLink(*iter, LinkList, ZERO_GI);
694 
695  break;
696  }
697  case NSnpBins::eGAP:
698  case NSnpBins::eGCAT:
699  {
700  string snpid(NStr::UIntToString((*iter)->snpid));
701 
702  LinkList.push_back(TLinkList::value_type("RefSNP: rs" + snpid, snpURL + snpid));
703  break;
704  }
705  }
706  }
707 
708  // Links for genome.gov
709  if((bin.type == NSnpBins::eGAP || bin.type == NSnpBins::eGCAT) &&
710  NStr::FindNoCase(bin.title, "nhgri") != NPOS) {
712  string snpid(NStr::UIntToString((*iter)->snpid));
713 
714  LinkList.push_back(TLinkList::value_type("NHGRI GWAS Catalog: rs" + snpid, GenomeURL + snpid + "#result_table"));
715  }
716  }
717 }
718 
720 {
721  return !ref.FindExt("VcfAttributes").IsNull();
722 }
723 
724 static
725 void s_GetVcfAttribute(const CSeq_feat& ref, const string& attr_name, string& attr_value)
726 {
727  attr_value.clear();
728  auto uo = ref.FindExt("VcfAttributes");
729  if (uo.IsNull())
730  return;
731  auto uf = uo->GetFieldRef("info");
732  if (uf.IsNull())
733  return;
734  auto info = uf->GetString();
735  auto start_pos = NStr::Find(info, attr_name);
736  if (start_pos == NPOS)
737  return;
738  start_pos += attr_name.size() + 1;
739  auto end_pos = NStr::Find(info, ";", start_pos);
740  attr_value = info.substr (start_pos, end_pos == NPOS ? NPOS : end_pos - start_pos);
741 }
742 
743 bool NSnpGui::GetClinSigValue(const CSeq_feat& ref, string& attr_value)
744 {
745  s_GetVcfAttribute(ref, "CLNSIG", attr_value);
746  return !attr_value.empty();
747 }
748 
749 
751 {
752  if(!isFromVcf(ref) || !ref.GetData().IsVariation()) {
754  }
755  const CVariation_ref& var = ref.GetData().GetVariation();
756 
757  if (var.IsSetData() && var.GetData().IsSet() && var.GetData().GetSet().IsSetVariations()) {
758  vector<string> alt_alleles;
759  string ref_allele;
760  auto var_list = var.GetData().GetSet().GetVariations();
761  for (auto iVariation: var_list) {
762  if (iVariation->IsSetData() && iVariation->GetData().IsInstance()) {
763  const CVariation_ref::TData::TInstance& VarInst(iVariation->GetData().GetInstance());
764  if (!VarInst.CanGetDelta())
765  continue;
766 
767  bool isReference(false);
769  isReference = true;
770  }
771 
773  if ((*iDelta)->CanGetSeq()) {
774  const CDelta_item::C_Seq& DeltaSeq((*iDelta)->GetSeq());
775  switch (DeltaSeq.Which()) {
777  {
778  if (DeltaSeq.GetLiteral().CanGetSeq_data()) {
779  const CSeq_data& Seq_data(DeltaSeq.GetLiteral().GetSeq_data());
780  // variations normally use Iupacna/Iupacaa
781  string sAllele;
782  if (Seq_data.IsIupacna())
783  sAllele = Seq_data.GetIupacna().Get().empty() ? "" : Seq_data.GetIupacna().Get();
784  if (Seq_data.IsIupacaa())
785  sAllele = Seq_data.GetIupacaa().Get().empty() ? "" : Seq_data.GetIupacaa().Get();
786 
787  if(isReference) {
788  ref_allele = sAllele;
789  } else {
790  alt_alleles.push_back(sAllele);
791  }
792  }
793  break;
794  }
796  // this can be a deletion
797  if(VarInst.GetType() == CVariation_inst::eType_del) {
798  alt_alleles.push_back("");
799  break;
800  }
801  default:
802  // no specific processing for other deltas
803  break;
804  }
805  }
806  }
807  }
808  }
809  return GetVcfType(ref_allele, alt_alleles);
810  }
812 }
813 
814 CVariation_inst::EType NSnpGui::GetVcfType(const string& ref_allele, const vector<string>& alt_alleles)
815 {
816  bool maybeAllSnv = (ref_allele.size() == 1);
817  if (maybeAllSnv) {
818  for (size_t u=0; u < alt_alleles.size(); ++u) {
819  if (alt_alleles[u].size() != 1) {
820  maybeAllSnv = false;
821  break;
822  }
823  }
824  if (maybeAllSnv) {
826  }
827  }
828 
829  //test for all mnvs:
830  bool maybeAllMnv = true;
831  size_t refSize = ref_allele.size();
832  for (size_t u=0; u < alt_alleles.size(); ++u) {
833  if (alt_alleles[u].size() != refSize) {
834  maybeAllMnv = false;
835  break;
836  }
837  }
838  if (maybeAllMnv) {
840  }
841  //test for all insertions:
842  bool maybeAllIns = true;
843  for (size_t u=0; u < alt_alleles.size(); ++u) {
844  if (alt_alleles[u].size() <= ref_allele.size()) {
845  maybeAllIns = false;
846  break;
847  }
848  }
849  if (maybeAllIns) {
851  }
852  if (alt_alleles.size() == 1 && alt_alleles[0].empty()) {
854  }
856 }
857 
858 
859 const string NSNPWebServices::c_SNPVarExt_SearchClass = "SNPSearch";
860 const string NSNPWebServices::c_SNPVarExt_GeneSymbol = "gene_symbol";
861 const string NSNPWebServices::c_SNPVarExt_TopLevel = "top_level";
862 const string NSNPWebServices::c_SNPVarExt_QueryId = "query_id";
863 const string NSNPWebServices::c_SNPVarExt_Comment = "comment";
864 
866 {
867  if(m_sSearchHost.empty()) {
869  m_isSearchByRsid = reg.GetBool("snp_web_services", "use_search_by_rsid", true);
870  m_sSearchHost = reg.GetString("snp_web_services",
871  "search_host",
873  ?
874  "https://www.ncbi.nlm.nih.gov/projects/variation/search-by-rsid/?format=asn1&rsid="
875  :
876  "https:///projects/SNP/beVarSearch.cgi?format=xml&report=varloc&id=");
877  }
878 }
879 
880 
881 void NSNPWebServices::Search(const std::string& sTerms, const string& sAssemblyAccession, TSNPSearchCompoundResultList& ResultList)
882 {
883  x_GetSearchHost();
884 
885  if(m_isSearchByRsid) {
886  list<string> Terms;
887  NStr::Split(sTerms, ", ", Terms, NStr::fSplit_Tokenize);
888 
889  // map of rsids to variation lists with the same rsid
890  typedef map<string, list<CRef<CVariation>>> TRsIdVariationMap;
891  TRsIdVariationMap RsIdVariationMap;
892 
893  for(auto Term: Terms) {
895  string sSNPSearchURL(m_sSearchHost + Term);
896 
897  if(!sAssemblyAccession.empty()) {
898  sSNPSearchURL += "&assm=" + sAssemblyAccession;
899  }
900  string sSearchResult;
901  CFetchURL::Fetch(sSNPSearchURL, sSearchResult, kDefaultTimeout, true/*use-cache*/);
902  TSNPSearchCompoundResult SNPSearchResult;
903 
904  CSearchByRsIdReply SearchByRsIdReply;
905  // deserialize sSearchResult into SearchByRsIdReply
906  sSearchResult >> SearchByRsIdReply;
907 
908  if(SearchByRsIdReply.IsPlacements()) {
909  for(auto iPlacements: SearchByRsIdReply.GetPlacements()) {
910  // get the placement rsid
911  string rsid(iPlacements->GetRsid());
912  if(!NStr::StartsWith(rsid, "rs", NStr::eNocase)) {
913  rsid = "rs" + rsid;
914  }
915 
916  auto pVariation(Ref(new CVariation));
917  pVariation->SetData().SetNote("SNP search result");
918  pVariation->SetDescription("SNP search result");
919  pVariation->SetId().SetDb("dbSNP");
920  pVariation->SetId().SetTag().SetStr(rsid);
921  auto pId(Ref(new CSeq_id(iPlacements->GetAcc_ver())));
922 
923  auto pLocation(Ref(new CSeq_loc(*pId,
924  iPlacements->GetFrom(),
925  iPlacements->GetFrom() + iPlacements->GetLength() - 1)));
926 
927  auto pPlacement(Ref(new CVariantPlacement));
928  pPlacement->SetLoc(*pLocation);
929  //!! review this, try to obtain actual molecule type from pId
930  pPlacement->SetMol(CVariantPlacement::eMol_genomic);
931  if(iPlacements->CanGetAssembly_acc()) {
932  pPlacement->SetAssembly().SetDb("");
933  pPlacement->SetAssembly().SetTag().SetStr(iPlacements->GetAssembly_acc());
934  }
935  pVariation->SetPlacements().push_back(pPlacement);
936 
937  // check whether we have already handled a placement with this rsid
938  auto iRsIdVariationMap(RsIdVariationMap.find(rsid));
939  if(iRsIdVariationMap == RsIdVariationMap.end()) {
940  auto InsertResult(RsIdVariationMap.insert(TRsIdVariationMap::value_type(rsid, list<CRef<CVariation>>())));
941  iRsIdVariationMap = InsertResult.first;
942  }
943  iRsIdVariationMap->second.push_back(pVariation);
944  }
945  }
946  }
947 
948  for(auto iRsIdVariationMap: RsIdVariationMap) {
949 /*
950  cerr << "Placements at point of creation: " << endl;
951  std::stringstream ostr;
952  ostr << MSerial_Json << *iRsIdVariationMap.second;
953  cerr << ostr.str() << endl;
954 */
955  ResultList.push_back(TSNPSearchCompoundResult(iRsIdVariationMap.first, iRsIdVariationMap.second));
956  }
957  } else {
958  list<string> Terms;
959  NStr::Split(sTerms, ", ", Terms, NStr::fSplit_Tokenize);
960 
961  ITERATE(list<string>, iTerms, Terms) {
962  string sSNPSearchURL(m_sSearchHost + *iTerms);
963 
964  if(!sAssemblyAccession.empty()) {
965  sSNPSearchURL += "&assm=" + sAssemblyAccession;
966  }
967  string sSearchResult;
968  CFetchURL::Fetch(sSNPSearchURL, sSearchResult, kDefaultTimeout, true/*use-cache*/);
969  TSNPSearchCompoundResult SNPSearchResult;
970 
971  xml::document ResultXml(sSearchResult.c_str(), sSearchResult.length(), NULL);
972  xml::node& ResultRoot(ResultXml.get_root_node());
973  // get the SNP id common for all results
974  xml::xpath_expression ParamIdExpr("/result_set/query/param_id");
975  const xml::node_set ParamIdSet(ResultRoot.run_xpath_query(ParamIdExpr));
976 
977  // currently expect one and only one ParamId
978  NCBI_ASSERT(ParamIdSet.size() == 1, "Unexpected number of <param_id> in SNP search result!");
979 
980  const xml::attributes& ParamIdAttrs(ParamIdSet.begin()->get_attributes());
981  string sClin, sComment, sResultID, sQueryId;
982  ITERATE(xml::attributes, iParamIdAttrs, ParamIdAttrs) {
983  string sAttrName(iParamIdAttrs->get_name());
984  if(sAttrName == "isClin")
985  sClin = iParamIdAttrs->get_value();
986  if(sAttrName == "comment")
987  sComment = iParamIdAttrs->get_value();
988  if(sAttrName == "query_id")
989  sQueryId = iParamIdAttrs->get_value();
990  if(sAttrName == "result_id")
991  sResultID = iParamIdAttrs->get_value();
992  }
993 
994  if(!sResultID.empty()) {
995  SNPSearchResult.first = sResultID;
996  // parse the individual results which are expected to have the following structure:
997  // <result_set><query><placement_set><placement placement_type= to= from= assembly_name= accession= [top_level="yes"]/><placement .../> etc
998  xml::xpath_expression PlacementExpr("/result_set/query/placement_set/placement");
999  const xml::node_set PlacementSet(ResultRoot.run_xpath_query(PlacementExpr));
1000 
1001  ITERATE(xml::node_set, iPlacementSet, PlacementSet) {
1002  const xml::attributes& PlacementAttrs(iPlacementSet->get_attributes());
1003  string sAccession, sFrom, sTo, sAssemblyName, sGeneSymbol, sTopLevel;
1004 
1005  ITERATE(xml::attributes, iPlacementAttrs, PlacementAttrs) {
1006  string sAttrName(iPlacementAttrs->get_name());
1007  if(sAttrName == "to")
1008  sTo = iPlacementAttrs->get_value();
1009  if(sAttrName == "from")
1010  sFrom = iPlacementAttrs->get_value();
1011  if(sAttrName == "assembly_name")
1012  sAssemblyName = iPlacementAttrs->get_value();
1013  if(sAttrName == "accession")
1014  sAccession = iPlacementAttrs->get_value();
1015  if(sAttrName == "gene_symbol")
1016  sGeneSymbol = iPlacementAttrs->get_value();
1017  if(sAttrName == "top_level")
1018  sTopLevel = iPlacementAttrs->get_value();
1019  }
1020  CRef<CSeq_id> pId(new CSeq_id(sAccession));
1021  CRef<CSeq_loc> pLocation(new CSeq_loc(*pId,
1022  NStr::StringToNumeric<TSeqPos>(sFrom),
1023  NStr::StringToNumeric<TSeqPos>(sTo)));
1024 
1026  pPlacement->SetLoc(*pLocation);
1027  //!! review this, try to obtain actual molecule type from pId
1028  pPlacement->SetMol(CVariantPlacement::eMol_genomic);
1029  pPlacement->SetAssembly().SetDb("");
1030  pPlacement->SetAssembly().SetTag().SetStr(sAssemblyName);
1031  CRef<CVariation> pVariation(new CVariation);
1032  pVariation->SetPlacements().push_back(pPlacement);
1033  pVariation->SetData().SetNote("SNP search result");
1034  pVariation->SetDescription("SNP search result");
1035  pVariation->SetId().SetDb("dbSNP");
1036  pVariation->SetId().SetTag().SetStr(sResultID);
1037  if(sClin == "Y")
1038  pVariation->SetVariant_prop().SetResource_link(CVariantProperties::eResource_link_clinical);
1039  if(!sComment.empty())
1040  pVariation->SetDescription(sComment);
1041 
1042  // there is no direct place to put gene_symbol, top_level flag, comment, query_id
1043  // so it goes to user object
1044  if(!sGeneSymbol.empty() || !sTopLevel.empty() || !sComment.empty() || !sQueryId.empty()) {
1045  CRef<CUser_object> pExt(new CUser_object());
1046  if(!sGeneSymbol.empty()) {
1047  pExt->AddField(c_SNPVarExt_GeneSymbol, sGeneSymbol);
1048  }
1049  if(!sQueryId.empty()) {
1050  pExt->AddField(c_SNPVarExt_QueryId, sQueryId);
1051  }
1052  if(!sComment.empty()) {
1053  pExt->AddField(c_SNPVarExt_Comment, sComment);
1054  }
1055  if(sTopLevel == "yes") {
1056  pExt->AddField(c_SNPVarExt_TopLevel, "yes");
1057  }
1058  pExt->SetClass(c_SNPVarExt_SearchClass);
1059  pExt->SetType().SetStr(c_SNPVarExt_SearchClass);
1060  pVariation->SetExt().push_back(pExt);
1061  }
1062  SNPSearchResult.second.push_back(pVariation);
1063  }
1064  ResultList.push_back(SNPSearchResult);
1065  }
1066  }
1067  }
1068 }
1069 
1071 {
1072  TSNPSearchCompoundResultList CompoundResultList;
1073  Search(sTerms, "", CompoundResultList);
1074  ITERATE(TSNPSearchCompoundResultList, iCompoundResultList, CompoundResultList) {
1075  ResultList.insert(ResultList.end(), iCompoundResultList->second.begin(), iCompoundResultList->second.end());
1076  }
1077 }
1078 
1079 
1080 static const char* sSearchByVarIdHost = "https://www.ncbi.nlm.nih.gov/projects/variation/viewer/search_by_varid/?format=json&varid=";
1081 
1082 void NSNPWebServices::SearchByVarId(const std::string& sTerms, const string& sAssemblyAccession, TSNPSearchCompoundResultList& ResultList)
1083 {
1084  list<string> Terms;
1085  NStr::Split(sTerms, ", ", Terms, NStr::fSplit_Tokenize);
1086 
1087  // map of rsids to variation lists with the same rsid
1088  typedef map<string, list<CRef<CVariation>>> TRsIdVariationMap;
1089  TRsIdVariationMap RsIdVariationMap;
1090 
1091  for(auto Term: Terms) {
1092  string sSNPSearchURL(sSearchByVarIdHost);
1093  sSNPSearchURL += Term;
1094 
1095  if(!sAssemblyAccession.empty()) {
1096  sSNPSearchURL += "&assm=" + sAssemblyAccession;
1097  }
1098 
1099  string sSearchResult;
1100  CFetchURL::Fetch(sSNPSearchURL, sSearchResult, kDefaultTimeout, true/*use-cache*/);
1101  if (sSearchResult.empty())
1102  continue;
1103 
1104  CJson_Document doc;
1105  doc.ParseString(sSearchResult);
1106  if (!doc.ReadSucceeded() || !doc.IsObject())
1107  continue;
1108 
1109  CJson_ConstObject obj = doc.GetObject();
1110  CJson_ConstArray arr = obj["SearchByVarIdReply"].GetObject()["placements"].GetArray();
1111 
1112  for ( CJson_ConstArray::const_iterator it = arr.begin(); it != arr.end(); ++it)
1113  {
1114  CJson_ConstObject obj2 = it->GetObject();
1115  string varid = obj2["varid"].GetValue().GetString();
1116  string acc_ver = obj2["acc_ver"].GetValue().GetString();
1117  TSeqPos from = static_cast<TSeqPos>(obj2["from"].GetValue().GetUint8());
1118  TSeqPos length = static_cast<TSeqPos>(obj2["length"].GetValue().GetUint8());
1119  string assembly_acc = obj2["assembly_acc"].GetValue().GetString();
1120 
1121  auto pVariation(Ref(new CVariation));
1122  pVariation->SetData().SetNote("SNP search result");
1123  pVariation->SetDescription("SNP search result");
1124  pVariation->SetId().SetDb("dbSNP");
1125  pVariation->SetId().SetTag().SetStr(varid);
1126  auto pId(Ref(new CSeq_id(acc_ver)));
1127 
1128  auto pLocation(Ref(new CSeq_loc(*pId, from, from + length - 1)));
1129 
1130  auto pPlacement(Ref(new CVariantPlacement));
1131  pPlacement->SetLoc(*pLocation);
1132  //!! review this, try to obtain actual molecule type from pId
1133  pPlacement->SetMol(CVariantPlacement::eMol_genomic);
1134  pPlacement->SetAssembly().SetDb("");
1135  pPlacement->SetAssembly().SetTag().SetStr(assembly_acc);
1136 
1137  pVariation->SetPlacements().push_back(pPlacement);
1138 
1139  // check whether we have already handled a placement with this rsid
1140  auto iRsIdVariationMap(RsIdVariationMap.find(varid));
1141  if(iRsIdVariationMap == RsIdVariationMap.end()) {
1142  auto InsertResult(RsIdVariationMap.insert(TRsIdVariationMap::value_type(varid, list<CRef<CVariation>>())));
1143  iRsIdVariationMap = InsertResult.first;
1144  }
1145  iRsIdVariationMap->second.push_back(pVariation);
1146  }
1147  }
1148 
1149  for(auto iRsIdVariationMap: RsIdVariationMap) {
1150  ResultList.push_back(TSNPSearchCompoundResult(iRsIdVariationMap.first, iRsIdVariationMap.second));
1151  }
1152 }
1153 
1154 
1155 CVcfVariant::CVcfVariant(const CSeq_id& seq_id,
1156  const string& sVariantID,
1157  size_t pos,
1158  const string& ref_allele,
1159  const string& alt_alleles) :
1160  m_sID(sVariantID),
1161  m_Pos(pos-1),
1162  m_Len(1),
1163  m_sRefAllele_orig(ref_allele)
1164 {
1165  NStr::Split(alt_alleles, ",", m_AltAlleles_orig);
1166 
1167  m_VariationType = NSnpGui::GetVcfType(m_sRefAllele_orig, m_AltAlleles_orig);
1168 
1169  m_sRefAllele_display = m_sRefAllele_orig.empty() ? string("-") : m_sRefAllele_orig;
1170  for(auto alt_allele_orig: m_AltAlleles_orig) {
1171  m_AltAlleles_display.push_back(alt_allele_orig.empty() ? string("-") : alt_allele_orig);
1172  }
1173  if(m_VariationType == CVariation_inst::eType_del && m_AltAlleles_display.empty()) {
1174  m_AltAlleles_display.push_back("-");
1175  }
1176  if(m_VariationType == CVariation_inst::eType_mnp) {
1177  m_Len = m_sRefAllele_orig.length() - 1;
1178  }
1179  if(m_VariationType == CVariation_inst::eType_del && ref_allele.length() > 1) {
1180  m_Len = m_sRefAllele_orig.length() - 1;
1181  m_Pos += 1;
1182  }
1183  CRef<CSeq_id> our_id(new CSeq_id());
1184  our_id->Assign(seq_id);
1185  m_SeqLoc.Reset(new CSeq_loc(*our_id, static_cast<CSeq_loc::TPoint>(m_Pos), static_cast<CSeq_loc::TPoint>(m_Pos + m_Len)));
1186 }
1187 
1188 CVcfVariant::CVcfVariant(const string& sSeqId,
1189  const string& sVariantID,
1190  size_t pos,
1191  const string& ref_allele,
1192  const string& alt_alleles) :
1193  CVcfVariant(CSeq_id(sSeqId, CSeq_id::fParse_AnyRaw | CSeq_id::fParse_AnyLocal), sVariantID, pos, ref_allele, alt_alleles)
1194 {
1195 }
1196 
1197 
1199 {
1201 }
1202 
1204 {
1205  return string(m_AltAlleles_orig.empty() ? "." : NStr::Join(m_AltAlleles_orig, ","));
1206 }
1207 
1208 int CVcfVariant::GetLongestAlleleLen(bool& all_alt_alleles_same_len) const
1209 {
1210  int allele_len = -1;
1211  all_alt_alleles_same_len = true;
1212  for(auto alt_allele_display: GetAltAlleles_display()) {
1213  // Ignore IDs in the form <XXX>
1214  if ((alt_allele_display.length() == 5) && (alt_allele_display[0] == '<') && (alt_allele_display[4] == '>'))
1215  continue;
1216  int new_allele_len(max(allele_len, (int)alt_allele_display.length()));
1217  if(allele_len != -1 && new_allele_len != allele_len) {
1218  all_alt_alleles_same_len = false;
1219  }
1220  allele_len = new_allele_len;
1221  }
1222  return allele_len;
1223 }
1224 
1225 
1227 {
1228  string sBriefLine(GetVariationTypeAsString() + " " + GetID() + "; Alleles: " + GetAllAlleles_display());
1229  switch(type) {
1230  case CLabel::eDescription:
1231  {
1232  label = sBriefLine + " \n" +
1234  bool all_alt_alleles_same_len(true);
1235  int allele_len = GetLongestAlleleLen(all_alt_alleles_same_len);
1236  if (allele_len > 0) {
1237  label += " \n" + string(all_alt_alleles_same_len ? "A" : "Longest a") + "llele length: " + NStr::NumericToString(allele_len, NStr::fWithCommas);
1238  }
1239  break;
1240  }
1242  label = sBriefLine;
1243  break;
1244  case CLabel::eType:
1245  label = "VCF-model-variant";
1246  break;
1247  case CLabel::eUserType:
1248  label = "VCF variant";
1249  break;
1250  case CLabel::eContent:
1251  label = GetID();
1252  break;
1253  case CLabel::eUserSubtype:
1254  label = "";
1255  break;
1256  default:
1257  label = "CVcfVariant";
1258  break;
1259  }
1260 }
1261 
1263 {
1264  switch(m_VariationType) {
1266  return "SNV";
1268  return "MNP";
1270  return "Insertion";
1272  return "Deletion";
1274  return "Delins";
1275  default:
1276  return "Unknown";
1277  }
1278 }
1279 
1281 {
1282  if (m_InfoColumns.empty())
1283  return;
1284  auto end_pos = m_InfoColumns.end();
1285 
1286  if (m_InfoColumns.find("CLNREVSTAT") != end_pos) {
1287  m_VCF_Type = EVCF_Type::eVCF_ClinVar;
1288  } else
1289  // required fileds for fbVar vcf
1290  // https://www.ncbi.nlm.nih.gov/core/assets/dbvar/files/dbVar_VCF_Submission.pdf
1291  if (m_InfoColumns.find("DBVARID") != end_pos) {
1292  m_VCF_Type = EVCF_Type::eVCF_DbVar;
1293  }
1294 
1295 
1296  auto it_info = m_InfoColumns.find("SVTYPE");
1297  if (it_info != end_pos) {
1298  static const map<string, CVariation_inst_Base::EType> svtype_map {
1299  { "DEL", CVariation_inst::eType_del }, // Deletion SetDeletion DEL
1300  { "INS", CVariation_inst::eType_ins }, // Insertion SetInsertion INS
1301  { "DUP", CVariation_inst::eType_cnv }, // Duplication SetGain DUP
1302  { "INV", CVariation_inst::eType_inv }, // Inversion SetInversion INV eType_inverted_copy?
1303  { "CNV", CVariation_inst::eType_cnv }, // Copy number variation SetCNV CNV
1304  { "BND", CVariation_inst::eType_translocation } // Translocation SetTranslocation BND
1305  };
1306 
1307  auto svtype_value = NStr::ToUpper(it_info->second);
1308  auto svtype = svtype_map.find(svtype_value);
1309  if (svtype != svtype_map.end()) {
1310  m_VariationType = svtype->second;
1311  switch (m_VariationType) {
1313  if (svtype_value == "DUP")
1315  else if (svtype_value == "CNV")
1317  break;
1320  break;
1321  default:
1322  break;
1323  }
1324  }
1325  }
1326  // Variant length to render
1327  // Exclude the ones for which POS > END
1328  it_info = m_InfoColumns.find("END");
1329  if (it_info != end_pos) {
1330  string end_str = it_info->second;
1331  if (!end_str.empty()) { // when it is specified
1332  size_t end = NStr::StringToSizet(end_str, NStr::fConvErr_NoThrow);
1333  if (end > m_Pos + 1) {
1334  m_Len = end - m_Pos;
1335  }
1336  }
1337  }
1338 
1339  if (m_VCF_Type == EVCF_Type::eVCF_ClinVar) {
1340  m_Len = m_sRefAllele_orig.length();
1341  it_info = m_InfoColumns.find("CLNVCSO");
1342  if (it_info != end_pos) {
1343  static const map<string, CVariation_inst_Base::EType> sm_CLNVCSO2Type = {
1344  {"SO:0000159", CVariation_inst::eType_del},
1345  {"SO:1000035", CVariation_inst::eType_cnv},
1346  {"SO:1000032", CVariation_inst::eType_delins},
1347  {"SO:0000667", CVariation_inst::eType_ins},
1348  {"SO:1000036", CVariation_inst::eType_inv},
1349  {"SO:0000289", CVariation_inst::eType_microsatellite },
1350  {"SO:0001563", CVariation_inst::eType_other}, //"Structural variant"},
1351  {"SO:1000173", CVariation_inst::eType_other}, //"Tandem_duplication"},
1352  {"SO:0001059", CVariation_inst::eType_other}, //"Sequence alteration"},
1353  {"SO:0000199", CVariation_inst::eType_translocation },
1354  {"SO:0001742", CVariation_inst::eType_other}, //"Copy number gain"},
1355  {"SO:0001743", CVariation_inst::eType_other}, //"Copy number loss"},
1356  {"SO:0001483", CVariation_inst::eType_snv},
1357  {"SO:0001013", CVariation_inst::eType_mnp}};
1358  auto it = sm_CLNVCSO2Type.find(it_info->second);
1359  if (it != sm_CLNVCSO2Type.end()) {
1360  m_VariationType = it->second;
1362  // if CLNVC=Microsatellite and column 5 < column 4, we should treat like a deletion -> SV-4993
1363  if (m_sRefAllele_orig.length() > 0 && (m_AltAlleles_display.empty() || m_sRefAllele_orig.length() > m_AltAlleles_display.front().length())) {
1365  }
1366  }
1367 
1369  m_Len = m_sRefAllele_orig.length() - 1;
1370  m_AltAlleles_display = {"-"};
1371  m_Pos += 1;
1372  if (m_SeqLoc) {
1373  CRef<CSeq_id> our_id(const_cast<CSeq_id*>(m_SeqLoc->GetId()));
1374  m_SeqLoc.Reset(new CSeq_loc(*our_id, static_cast<CSeq_loc::TPoint>(m_Pos), static_cast<CSeq_loc::TPoint>(m_Pos + m_Len)));
1375  }
1376  }
1377  }
1378  }
1379  }
1380 }
1381 
1383 {
1384  if (m_InfoColumns.empty()) {
1385  return ".";
1386  }
1387  string sInfoColumns;
1388  for(const auto& column_value: m_InfoColumns) {
1389  if(!sInfoColumns.empty()) {
1390  sInfoColumns += ";";
1391  }
1392  sInfoColumns += column_value.first + "=" + column_value.second;
1393  }
1394  return sInfoColumns;
1395 }
1396 
1397 
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.
const TAnnotNames & GetAnnotNames(void) const
size_t GetSize(void) const
CBioseq_Handle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
CGraph_CI –.
Definition: graph_ci.hpp:234
Random-access iterator to access const JSON array element.
CJson_Array.
bool IsObject(void) const
CJson_ConstObject GetObject(void) const
Get JSON object contents of the node.
CJson_ConstArray GetArray(void) const
Get JSON array contents of the node.
CJson_ConstValue GetValue(void) const
Get JSON value contents of the node.
CJson_Object.
Uint8 GetUint8(void) const
TStringType GetString(void) const
bool ParseString(const TStringType &v)
Read JSON data from a UTF8 string.
bool ReadSucceeded(void) const
Test if the most recent read was successful.
CMappedGraph –.
Definition: graph_ci.hpp:61
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:264
CNcbiRegistry –.
Definition: ncbireg.hpp:913
CRef –.
Definition: ncbiobj.hpp:618
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CSearchByRsIdReply –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CConstRef< CUser_object > FindExt(const string &ext_type) const
Find extension by type in exts container.
Definition: Seq_feat.cpp:564
URL-decoder for string pairs parser.
Definition: ncbistr.hpp:4565
CConstRef< CUser_field > GetFieldRef(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Definition: User_object.cpp:84
CVariantPlacement –.
CVariation_inst –.
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
storage for gene maps as seen in strings in SBinEntry::genes_reported and SBinEntry::genes_mapped
Definition: snp_bins.hpp:115
@ eIND
individual tracks (Venter, Watson, etc), data same as in eCLIN
Definition: snp_bins.hpp:58
@ eCITED
Cited Variations.
Definition: snp_bins.hpp:57
@ eCLIN
Clinical Variations.
Definition: snp_bins.hpp:56
@ eGAP
dbGaP analysis files
Definition: snp_bins.hpp:54
@ eGCAT
NHGRI GWAS Catalog Track (AKA Association Results)
Definition: snp_bins.hpp:55
static string SourceAsString(TSource Source)
get human-readable text for various source types
Definition: snp_bins.cpp:61
list< CRef< SBinEntry > > TBinEntryList
Definition: snp_bins.hpp:98
int TClinSigID
Definition: snp_utils.hpp:76
@ eLetterCase_ForceLower
always use lower case only
Definition: snp_utils.hpp:212
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
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
The xml::attributes class is used to access all the attributes of one xml::node.
Definition: attributes.hpp:78
The xml::document class is used to hold the XML tree and various bits of information about it.
Definition: document.hpp:80
The xml::node_set class is used to store xpath query result set.
Definition: node_set.hpp:68
The xml::node class is used to hold information about one XML node.
Definition: node.hpp:106
The xml::xpath_expression class is used to store xpath query string and optional XML namespaces.
This file contains the definition of the xml::event_parser class.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
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
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
#define ZERO_GI
Definition: ncbimisc.hpp:1088
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define Handle
Definition: ncbistd.hpp:119
#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
static bool IsExtendedNAA(const string &annot, bool isStrict=false)
check if a given annotation is an extended NAA (named accession[.version][number],...
Definition: utils.cpp:850
static void SetResolveDepth(objects::SAnnotSelector &sel, bool adaptive, int depth=-1)
help function for setting selector resolve depth.
Definition: utils.cpp:405
@ eAnnot_Unnamed
unnamed annotation
Definition: utils.hpp:133
@ fAnnot_UnsetNamed
Definition: utils.hpp:155
vector< string > m_AltAlleles_orig
Definition: snp_gui.hpp:332
virtual void FinishRow()=0
finish the row (i.e. no other contents will be added to it)
static void GetBinLinks(const NSnpBins::SBin &bin, TLinkList &LinkList)
get a list of links associated with a given SNP bin
Definition: snp_gui.cpp:676
string GetID() const
Definition: snp_gui.hpp:287
static const string pmURL
standard NCBI resourse URLs
Definition: snp_gui.hpp:210
string GetRefAllele_display() const
Definition: snp_gui.hpp:290
static const string snpURL
Definition: snp_gui.hpp:180
list< TSNPSearchCompoundResult > TSNPSearchCompoundResultList
results of a search for one or several ids
Definition: snp_gui.hpp:234
static const string c_SNPVarExt_TopLevel
Definition: snp_gui.hpp:262
list< CRef< CVariation > > TSNPSearchResultList
various placements of a variation
Definition: snp_gui.hpp:227
size_t m_Pos
Definition: snp_gui.hpp:327
void ParseInfoColumns()
Definition: snp_gui.cpp:1280
string m_sRefAllele_orig
Definition: snp_gui.hpp:331
static size_t EstimateSNPCount(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:139
static NSnp::TClinSigID ClinSigFromString(const string &clinsig)
converts string to clinical significance type (CPhenotype::EClinical_significance)
Definition: snp_gui.cpp:224
static const int c_BinWidth
standard width and height of a bin
Definition: snp_gui.hpp:157
static string SelectClinSigTerm(const string &clinsig)
returns the term with the highest pathogenicity if the CLNSIG string has multiple parts (terms)
Definition: snp_gui.cpp:282
static bool m_isSearchByRsid
Definition: snp_gui.hpp:269
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)=0
adds a value column to the row
const list< string > & GetAltAlleles_display() const
Definition: snp_gui.hpp:291
static string PValueAsColorKey(double pvalue)
preferred colorings for a given pvalue
Definition: snp_gui.cpp:337
string GetInfoColumnsAsString() const
Definition: snp_gui.cpp:1382
static void Fetch(const string &url, string &result, const STimeout *timeout=kDefaultTimeout, bool is_cache=false)
Fetch a URL from the net using http GET.
Definition: fetch_url.cpp:80
static const string c_SNPVarExt_SearchClass
Definition: snp_gui.hpp:260
objects::CVariation_inst::EType m_VariationType
Definition: snp_gui.hpp:338
static void x_MakeClinVarLink(CConstRef< NSnpBins::SBinEntry > BinEntry, CIRef< ITooltipFormatter > pFormatter, bool &isGoToPresent)
makes a ClinVar link suitable for putting into a tooltip
Definition: snp_gui.cpp:607
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")=0
adds a tag column to the row
size_t GetPos() const
Definition: snp_gui.hpp:288
size_t GetLen() const
Definition: snp_gui.hpp:289
static const string c_SNPVarExt_GeneSymbol
Definition: snp_gui.hpp:261
static void x_MakeVarVuLink(CConstRef< NSnpBins::SBinEntry > BinEntry, CIRef< ITooltipFormatter > pFormatter, bool &isGoToPresent, TGi gi)
makes a varVu link suitable for putting into a tooltip
Definition: snp_gui.cpp:582
static bool GetClinSigValue(const CSeq_feat &ref, string &attr_value)
returns CLNSIG attribute value from VcfAttribute user object returns false if not found
Definition: snp_gui.cpp:743
static void x_ProcessDbgaptext(CConstRef< NSnpBins::SBinEntry > BinEntry, ITooltipFormatter *pFormatter)
processes dbgaptext field and puts its contents into a tooltip
Definition: snp_gui.cpp:625
static const string geneRevURL
Definition: snp_gui.hpp:213
static void SearchByVarId(const std::string &sTerms, const string &sAssemblyAccession, TSNPSearchCompoundResultList &ResultList)
Definition: snp_gui.cpp:1082
static bool isFromVcf(const CSeq_feat &variation_ref)
Definition: snp_gui.cpp:719
CConstRef< objects::CSeq_loc > m_SeqLoc
Definition: snp_gui.hpp:344
static const string VarVuURL
Definition: snp_gui.hpp:218
static string ClinSigAsColorKey(NSnp::TClinSigID ClinSigID)
preferred colorings for SNP clinical significances
Definition: snp_gui.cpp:212
size_t m_Len
Definition: snp_gui.hpp:328
static const string phenotypeURL
Definition: snp_gui.hpp:214
static string ClinSigAsImgURL(NSnp::TClinSigID ClinSigID, const string &colorTheme)
gets a URL to an image representing the given clinical significance
Definition: snp_gui.cpp:323
static const string PHAURL
Definition: snp_gui.hpp:216
pair< string, TSNPSearchResultList > TSNPSearchCompoundResult
results of a search for a given id (string) TSNPSearchResultList may be empty if the id has been foun...
Definition: snp_gui.hpp:231
static const string geneSymURL
Definition: snp_gui.hpp:212
static const string GAPStudyURL
Definition: snp_gui.hpp:215
static CVariation_inst::EType GetVcfType(const CSeq_feat &variation_ref)
Definition: snp_gui.cpp:750
static const string GenomeURL
Definition: snp_gui.hpp:217
static CGraph_CI GetGraph_CI(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:61
static const string ClinVarIdURL
standard NCBI resourse URLs
Definition: snp_gui.hpp:179
list< string > m_AltAlleles_display
Definition: snp_gui.hpp:336
unique_ptr< objects::CInt_fuzz::ELim > m_LimitValue
Definition: snp_gui.hpp:340
static const string omimURL
Definition: snp_gui.hpp:211
static const string c_SNPVarExt_QueryId
Definition: snp_gui.hpp:263
static string PValueToString(double pvalue)
Definition: snp_gui.cpp:366
static const string c_SNPVarExt_Comment
Definition: snp_gui.hpp:264
ELabelType
Definition: label.hpp:60
list< TLink > TLinkList
list of URL links
Definition: snp_gui.hpp:144
static const string ClinVarURL
Definition: snp_gui.hpp:219
static void GetBinTooltip(const NSnpBins::SBin &bin, CIRef< ITooltipFormatter > pFormatter, TGi gi, const std::string &colorTheme)
generate a tooltip for a given bin object and put it into the formatter
Definition: snp_gui.cpp:373
int GetLongestAlleleLen(bool &all_alt_alleles_same_len) const
Definition: snp_gui.cpp:1208
static string m_sSearchHost
Definition: snp_gui.hpp:268
void GetLabel(string &label, CLabel::ELabelType type) const
Definition: snp_gui.cpp:1226
virtual void StartRow()=0
start a new table row
CVcfVariant(const objects::CSeq_id &seq_id, const string &sVariantID, size_t pos, const string &ref_allele, const string &alt_alleles)
alternative alleles separated by /
static CFeat_CI GetFeat_CI(const TSeqRange &range, const string &sAnnotName, CBioseq_Handle &Handle)
Definition: snp_gui.cpp:114
TColumns m_InfoColumns
Definition: snp_gui.hpp:345
string GetAltAlleles_orig() const
Definition: snp_gui.cpp:1203
EVCF_Type m_VCF_Type
Definition: snp_gui.hpp:352
static void ClinSigAsColor(NSnp::TClinSigID ClinSigID, CRgbaColor &color)
returns color for clinsig values (SV-4908) returns #767677 for undefined values
Definition: snp_gui.cpp:258
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const =0
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
static const int c_BinHeight
Definition: snp_gui.hpp:158
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
static void x_GetSearchHost()
Definition: snp_gui.cpp:865
string GetAllAlleles_display() const
Definition: snp_gui.cpp:1198
string GetVariationTypeAsString() const
Definition: snp_gui.cpp:1262
unique_ptr< objects::CDelta_item::EAction > m_DeltaItemAction
Definition: snp_gui.hpp:342
@ eType
Definition: label.hpp:65
@ eUserSubtype
Definition: label.hpp:64
@ eContent
Definition: label.hpp:62
@ eDescription
Definition: label.hpp:68
@ eUserType
Definition: label.hpp:63
@ eDescriptionBrief
Definition: label.hpp:67
const TPrim & Get(void) const
Definition: serialbase.hpp:347
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
TSeqPos TPoint
Definition: Seq_loc.hpp:102
TSeqPos GetComp(void) const
Definition: graph_ci.hpp:156
double GetB(void) const
Definition: graph_ci.hpp:174
SAnnotSelector & ResetAnnotsNames(void)
Select annotations from all Seq-annots.
double GetA(void) const
Definition: graph_ci.hpp:165
string CombineWithZoomLevel(const string &acc, int zoom_level)
Combine accession string and zoom level into a string with separator.
SAnnotSelector & IncludeNamedAnnotAccession(const string &acc, int zoom_level=0)
SAnnotSelector & SetExcludeExternal(bool exclude=true)
External annotations for the Object Manger are annotations located in top level Seq-entry different f...
bool IsSetB(void) const
Definition: graph_ci.hpp:170
SAnnotSelector & SetCollectNames(bool value=true)
Collect available annot names rather than annots.
bool IsSetA(void) const
Definition: graph_ci.hpp:161
SAnnotSelector & AddNamedAnnots(const CAnnotName &name)
Add named annot to set of annots names to look for.
bool ExtractZoomLevel(const string &full_name, string *acc_ptr, int *zoom_level_ptr)
Extract optional zoom level suffix from named annotation string.
const CSeq_loc & GetLoc(void) const
Definition: graph_ci.hpp:126
SAnnotSelector & AddUnnamedAnnots(void)
Add unnamed annots to set of annots names to look for.
const CSeq_graph::C_Graph & GetGraph(void) const
Definition: graph_ci.cpp:192
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
#define kMax_Int
Definition: ncbi_limits.h:184
position_type GetLength(void) const
Definition: range.hpp:158
bool IntersectingWith(const TThisType &r) const
Definition: range.hpp:331
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
virtual bool GetBool(const string &section, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
Definition: ncbireg.cpp:391
virtual string GetString(const string &section, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
Definition: ncbireg.cpp:321
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void Parse(const CTempString str, NStr::EMergeDelims merge_argsep=NStr::eMergeDelims)
Parse the string.
Definition: ncbistr.hpp:4698
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
Definition: ncbistr.hpp:5187
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
#define NPOS
Definition: ncbistr.hpp:133
static size_t StringToSizet(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to size_t.
Definition: ncbistr.cpp:1769
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
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 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 TrimPrefixInPlace(string &str, const CTempString prefix, ECase use_case=eCase)
Trim prefix from a string (in-place)
Definition: ncbistr.cpp:3242
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
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ fDoubleGeneral
Definition: ncbistr.hpp:258
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
#define kDefaultTimeout
Definition: ncbi_types.h:81
static const char label[]
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
ELim
some limit value
Definition: Int_fuzz_.hpp:209
@ eLim_gt
greater than
Definition: Int_fuzz_.hpp:211
@ eLim_unk
unknown
Definition: Int_fuzz_.hpp:210
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
bool IsVariation(void) const
Check if variant Variation is selected.
const TVariation & GetVariation(void) const
Get the variant data.
vector< char > TValues
Definition: Byte_graph_.hpp:89
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_graph_.cpp:131
const TValues & GetValues(void) const
Get the Values member data.
Definition: Int_graph_.hpp:425
const TByte & GetByte(void) const
Get the variant data.
Definition: Seq_graph_.cpp:153
vector< int > TValues
Definition: Int_graph_.hpp:88
const TValues & GetValues(void) const
Get the Values member data.
bool IsByte(void) const
Check if variant Byte is selected.
Definition: Seq_graph_.hpp:757
const TIupacaa & GetIupacaa(void) const
Get the variant data.
Definition: Seq_data_.hpp:530
bool IsIupacaa(void) const
Check if variant Iupacaa is selected.
Definition: Seq_data_.hpp:524
const TIupacna & GetIupacna(void) const
Get the variant data.
Definition: Seq_data_.hpp:510
bool CanGetSeq_data(void) const
Check if it is safe to call GetSeq_data method.
bool IsIupacna(void) const
Check if variant Iupacna is selected.
Definition: Seq_data_.hpp:504
const TSeq_data & GetSeq_data(void) const
Get the Seq_data member data.
@ eMol_genomic
"g." coordinates in HGVS
TType GetType(void) const
Get the Type member data.
E_Choice Which(void) const
Which variant is currently selected.
TObservation GetObservation(void) const
Get the Observation member data.
const TSet & GetSet(void) const
Get the variant data.
const TDelta & GetDelta(void) const
Get the Delta member data.
const TData & GetData(void) const
Get the Data member data.
bool CanGetDelta(void) const
Check if it is safe to call GetDelta method.
const TLiteral & GetLiteral(void) const
Get the variant data.
bool CanGetObservation(void) const
Check if it is safe to call GetObservation method.
bool IsSet(void) const
Check if variant Set is selected.
list< CRef< CDelta_item > > TDelta
bool IsSetVariations(void) const
Check if a value has been assigned to Variations data member.
EClinical_significance
does this variant have known clinical significance?
Definition: Phenotype_.hpp:90
const TVariations & GetVariations(void) const
Get the Variations member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
@ eType_snv
delta=[morph of length 1] NOTE: this is snV not snP; the latter requires frequency-based validation t...
@ eType_inv
delta=[del, ins.seq= RevComp(variation-location)]
@ eType_mnp
delta=[morph of length >1]
@ eType_microsatellite
delta=[del, ins.seq= repeat-unit with fuzzy multiplier] variation-location is the microsat expansion ...
@ eType_delins
delta=[del, ins]
@ eType_cnv
delta=[del, ins= 'this' with fuzzy multiplier]
@ eType_translocation
delta=like delins
@ eResource_link_clinical
Clinical if LSDB, OMIM, TPA, Diagnostic (0x10)
@ eAction_del_at
excise sequence at location if multiplier is specified, delete len(location)*multiplier positions dow...
@ e_This
same location as variation-ref itself
@ eObservation_reference
inst represents the reference base at the position
@ eClinical_significance_drug_response
Definition: Phenotype_.hpp:97
@ eClinical_significance_probable_pathogenic
Definition: Phenotype_.hpp:95
@ eClinical_significance_unknown
Definition: Phenotype_.hpp:91
@ eClinical_significance_untested
Definition: Phenotype_.hpp:92
@ eClinical_significance_pathogenic
Definition: Phenotype_.hpp:96
@ eClinical_significance_probable_non_pathogenic
Definition: Phenotype_.hpp:94
@ eClinical_significance_other
Definition: Phenotype_.hpp:99
@ eClinical_significance_histocompatibility
Definition: Phenotype_.hpp:98
@ eClinical_significance_non_pathogenic
Definition: Phenotype_.hpp:93
bool IsPlacements(void) const
Check if variant Placements is selected.
const TPlacements & GetPlacements(void) const
Get the variant data.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n background color
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
const struct ncbi::grid::netcache::search::fields::SIZE size
unsigned int a
Definition: ncbi_localip.c:102
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Process information in the NCBI Registry, including working with configuration files.
T max(T x_, T y_)
static pcre_uint8 * buffer
Definition: pcretest.c:1051
USING_SCOPE(objects)
const int kMaxDoublePrecision
Definition: snp_gui.cpp:362
static const char * sSearchByVarIdHost
Definition: snp_gui.cpp:1080
static void s_GetVcfAttribute(const CSeq_feat &ref, const string &attr_name, string &attr_value)
Definition: snp_gui.cpp:725
const int kMaxDoubleStringSize
Definition: snp_gui.cpp:363
representation of a bin
Definition: snp_bins.hpp:102
TBinEntryList m_EntryList
Definition: snp_bins.hpp:109
TBinType type
Definition: snp_bins.hpp:103
SAnnotSelector –.
Definition: type.c:6
Modified on Mon Jun 17 05:09:11 2024 by modify_doxy.py rev. 669887