49 #define __CAN_USE_TOOLTIP_SVC
50 #ifdef __CAN_USE_TOOLTIP_SVC
66 #ifdef __CAN_USE_TOOLTIP_SVC
74 #ifdef __CAN_USE_TOOLTIP_SVC
86 const string& sVariationID,
94 if(isFirstGenomicLocation) {
96 "Genomic locations:" :
"Genomic location:");
97 isFirstGenomicLocation =
false;
107 string sLabel(sAccession +
" @ " + sGenomicPosFrom +
" @" + sAssembly);
108 string sUrl(
"/projects/sviewer/?id=" + sAccession +
109 "&v=" + sGenomicPosFrom +
":" + sGenomicPosTo +
110 "&mk=" + sGenomicPosFrom +
'|' + sVariationID +
"|008000");
117 #ifdef __CAN_USE_TOOLTIP_SVC
125 reg.
GetString(
"snp_web_services",
"tooltip_host",
"https://www.ncbi.nlm.nih.gov/projects/variation/tooltips")
145 if(isGeneratedBySvc) {
146 *isGeneratedBySvc =
false;
181 #ifdef __CAN_USE_TOOLTIP_SVC
185 string sTooltipResult;
188 if(isGeneratedBySvc) {
189 *isGeneratedBySvc =
true;
193 if(sTooltipResult.empty()) {
194 tooltip.
AddRow(
"Error:",
"Empty response from tooltip service");
195 LOG_POST(
Error <<
"Empty response from tooltip service for id '" << sVariationID <<
"'");
199 std::stringstream TooltipResultStream(sTooltipResult);
202 TooltipResultStream >>
MSerial_Json >> DbsnpTooltipServiceReply;
203 }
catch(
const std::exception& err) {
204 tooltip.
AddRow(
"Error:",
"Invalid response from tooltip service");
205 LOG_POST(
Error <<
"Invalid response from tooltip service for id '" << sVariationID <<
"', error: " << err.what());
212 if(isGeneratedBySvc) {
213 *isGeneratedBySvc =
false;
219 catch (
const std::exception& err) {
220 LOG_POST(
Warning <<
"NSNPWebServices::Search() failed for id '" << sVariationID <<
"':" << err.what());
230 if(!(*iSNPSearchResultList)->CanGetExt()) {
243 NCBI_ASSERT((*iSNPSearchResultList)->CanGetPlacements(),
"Unexpected absence of placements in SNP Search Result!");
245 NCBI_ASSERT(Placements.size(),
"Unexpected number of placements in SNP Search Result!");
251 FirstPriorityList.push_back(*iSNPSearchResultList);
255 SecondPriorityList.push_back(*iSNPSearchResultList);
258 ThirdPriorityList.push_back(*iSNPSearchResultList);
265 bool isFirstGenomicLocation(
true);
272 tooltip.
AddRow(
"Variation ID:", sVariationID);
275 tooltip.
AddRow(
"Variant Type:", sVariantType +
", length " + sLength);
276 #ifdef __CAN_USE_TOOLTIP_SVC
280 tooltip.
AddRow(
"Variation:", sVariationID);
286 if ( !Alleles.empty() ) {
290 tooltip.
AddRow(
"Allele origin:",
"Somatic");
293 if (
m_Feat->IsSetComment()) {
302 if (
m_Feat->IsSetDbxref()) {
314 string name =
"SNP summary:";
317 string link = base_url +
"/snp/rs";
328 name =
"Genotype information for";
331 link = base_url +
"/snp/rs";
332 link += rsid +
"#frequency_tab";
340 name =
"SNP3D Page for";
342 link = base_url +
"/projects/SNP/snp3D.cgi?rsnum=";
351 name =
"OMIM information for";
353 link = base_url +
"/projects/SNP/snp_redirect.cgi?snp_id=";
364 if(
m_Feat->CanGetLocation()) {
368 for ( ; feat_iter; ++feat_iter) {
376 if( !sGeneLocus.empty() ) {
377 name =
"Variation viewer for";
379 label +=
" (" + sGeneLocus +
")",
380 link = base_url +
"/sites/varvu?rs=";
381 link += rsid +
"&gene=" + sGeneLocus;
393 #ifdef __CAN_USE_TOOLTIP_SVC
397 string sCurrentSectionName;
399 for(
const auto& tooltip_section: tooltip_data.Get()) {
400 if(tooltip_section->CanGetSection()) {
401 sCurrentSectionName = tooltip_section->GetSection();
402 if(!sCurrentSectionName.empty()) {
406 if(tooltip_section->CanGetValues()) {
409 for(
const auto& tooltip_row: tooltip_section->GetValues()) {
410 string sURL(tooltip_row->CanGetUrl() ? tooltip_row->GetUrl() :
"");
411 string sValue(tooltip_row->GetValue());
412 bool isLink(!sURL.empty());
416 if(sCurrentSectionName ==
"Genomic locations") {
422 tooltip.
AddRow(tooltip_row->GetKey() +
":", sValue, 200, isLink);
428 if(DbsnpTooltipServiceReply.
IsError()) {
@ eExtreme_Positional
numerical value
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static string m_sTooltipServiceHost
virtual void GetLinks(ITooltipFormatter &links, bool no_ncbi_base) const
Get a set of links.
static void x_GetTooltipService()
static void x_ConvertTooltips(ITooltipFormatter &tooltip, const CDbsnpTooltipServiceReply &DbsnpTooltipServiceReply)
static bool m_isUseTooltipService
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
virtual string GetSubtype() const
static CNcbiApplication * Instance(void)
Singleton method.
CSnpBitfield is a facade for representing any version of the SNP bitfield.
bool IsTrue(EProperty prop) const
const char * GetVariationClassString() const
@ eHasSnp3D
Has 3D structure SNP3D.
static TRsid GetRsid(const CMappedFeat &mapped_feat)
Return rsid of SNP.
vector< string > TAlleles
list of alleles belonging to particular SNP a deletion is represented by a "-"
static bool IsSnp(const CMappedFeat &mapped_feat)
Determine if feature is a SNP.
static void GetAlleles(const CMappedFeat &mapped_feat, TAlleles &Alleles)
Return list of alleles encoded in qual.
static CSnpBitfield GetBitfield(const CMappedFeat &)
Return bitfield information stored in the feature.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_ASSERT(expr, mess)
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
void Warning(CExceptionArgs_Base &args)
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
static string GetNcbiBaseUrl()
virtual void FinishRow()=0
finish the row (i.e. no other contents will be added to it)
virtual string CreateGenomicLink(const string &sText, const string &sUrl) const
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
static const string c_SNPVarExt_TopLevel
list< CRef< CVariation > > TSNPSearchResultList
various placements of a variation
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
virtual bool IsTrustedData()
indicates whether the data is coming from a trusted source
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)=0
adds a value column to the row
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.
virtual void AddLinksTitle(const string &sTitle)=0
add a row with the links title
virtual void SetTrustedData(bool trusted_data)
indicates whether the data is coming from a trusted source
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")=0
adds a tag column to the row
CRef< objects::CScope > m_Scope
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)=0
add a row with two columns
CConstRef< objects::CSeq_feat > m_Feat
virtual void AddSectionRow(const string &sContents)=0
add a section row
virtual void StartRow()=0
start a new table row
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 void Search(const std::string &sTerms, const std::string &sAssemblyAccession, TSNPSearchCompoundResultList &ResultList)
search for given SNP ID(s) and get a list of results
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
string GetLabel(const CSeq_id &id)
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
TSeqPos GetStop(ESeqLocExtremes ext) const
@ fFGL_Content
Include its content if there is any.
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
const CSeq_feat & GetMappedFeature(void) const
Feature mapped to the master sequence.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
virtual bool GetBool(const string §ion, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
virtual string GetString(const string §ion, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
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.
@ fWithCommas
Use commas as thousands separator.
@ eNocase
Case insensitive compare.
static const char label[]
bool IsSetLocus(void) const
Official gene symbol Check if a value has been assigned to Locus data member.
const TLocus & GetLocus(void) const
Get the Locus member data.
const TStr & GetStr(void) const
Get the variant data.
const TTag & GetTag(void) const
Get the Tag member data.
const TData & GetData(void) const
Get the Data member data.
bool CanGetData(void) const
Check if it is safe to call GetData method.
bool IsStr(void) const
Check if variant Str is selected.
const TStr & GetStr(void) const
Get the variant data.
vector< CRef< CDbtag > > TDbxref
E_Choice Which(void) const
Which variant is currently selected.
const TData & GetData(void) const
Get the Data member data.
const TGene & GetGene(void) const
Get the variant data.
list< CRef< CVariantPlacement > > TPlacements
list< CRef< CUser_object > > TExt
const TAssembly & GetAssembly(void) const
Get the Assembly member data.
const TLoc & GetLoc(void) const
Get the Loc member data.
static void s_AddTopLevelGenomicLinks(bool &isFirstGenomicLocation, bool isMultiple, const string &sVariationID, const NSNPWebServices::TSNPSearchResultList &SNPSearchResultList, ITooltipFormatter *pFormatter)